Feat: cutEnable, command args parse
This commit is contained in:
parent
0369ef03fe
commit
0684422d0f
@ -29,8 +29,6 @@ include(${Geant4_USE_FILE})
|
|||||||
include_directories(${PROJECT_SOURCE_DIR}/include)
|
include_directories(${PROJECT_SOURCE_DIR}/include)
|
||||||
# Include bluet file
|
# Include bluet file
|
||||||
set(bluet_base "/home/liuyihui/bluet/")
|
set(bluet_base "/home/liuyihui/bluet/")
|
||||||
# include(${bluet_base}/sources/config/include/BluetConfig.hh)
|
|
||||||
# include(${bluet_base}/sources/modules/include/BluetDataModel.hh)
|
|
||||||
include_directories(${bluet_base}/sources/config/include)
|
include_directories(${bluet_base}/sources/config/include)
|
||||||
include_directories(${bluet_base}/sources/modules/include)
|
include_directories(${bluet_base}/sources/modules/include)
|
||||||
include_directories(${bluet_base}/sources/runner/include)
|
include_directories(${bluet_base}/sources/runner/include)
|
||||||
@ -39,13 +37,8 @@ include_directories($ENV{GARFIELD_INSTALL}/include/Garfield)
|
|||||||
|
|
||||||
# Locate sources and headers for this project
|
# Locate sources and headers for this project
|
||||||
file(GLOB analyzer ${PROJECT_SOURCE_DIR}/include/* ${PROJECT_SOURCE_DIR}/src/*)
|
file(GLOB analyzer ${PROJECT_SOURCE_DIR}/include/* ${PROJECT_SOURCE_DIR}/src/*)
|
||||||
# file(GLOB config ${bluet_base}/sources/config/include/* ${bluet_base}/sources/config/src/*)
|
# list(FILTER analyzer EXCLUDE REGEX "BluetDrawLinkDef")
|
||||||
# file(GLOB modules ${bluet_base}/sources/modules/include/* ${bluet_base}/sources/modules/src/*)
|
|
||||||
# file(GLOB runner ${bluet_base}/sources/runner/include/* ${bluet_base}/sources/runner/src/*)
|
|
||||||
# file(GLOB utils ${bluet_base}/utils/include/* ${bluet_base}/utils/src/*)
|
|
||||||
list(FILTER analyzer EXCLUDE REGEX "BluetDrawLinkDef")
|
|
||||||
|
|
||||||
# ROOT_GENERATE_DICTIONARY(D_${PROJECT_NAME} /home/fox/bluet/sources/modules/include/DrawEvent.hh LINKDEF /home/fox/bluet/sources/modules/include/BluetDrawLinkDef.hh)
|
|
||||||
add_library(SO_${PROJECT_NAME} SHARED
|
add_library(SO_${PROJECT_NAME} SHARED
|
||||||
${analyzer}
|
${analyzer}
|
||||||
# Bluet
|
# Bluet
|
||||||
@ -56,7 +49,7 @@ add_library(SO_${PROJECT_NAME} SHARED
|
|||||||
${bluet_base}/utils/src/xmlparse.cc
|
${bluet_base}/utils/src/xmlparse.cc
|
||||||
${bluet_base}/utils/include/stringhandle.hh
|
${bluet_base}/utils/include/stringhandle.hh
|
||||||
${bluet_base}/utils/src/stringhandle.cc
|
${bluet_base}/utils/src/stringhandle.cc
|
||||||
# D_${PROJECT_NAME}.cxx
|
${bluet_base}/utils/include/clipp.h
|
||||||
)
|
)
|
||||||
|
|
||||||
target_link_libraries(SO_${PROJECT_NAME} PUBLIC
|
target_link_libraries(SO_${PROJECT_NAME} PUBLIC
|
||||||
|
@ -63,6 +63,7 @@ private:
|
|||||||
double flighL;
|
double flighL;
|
||||||
double sampleT;
|
double sampleT;
|
||||||
|
|
||||||
|
bool cutEnable;
|
||||||
double EcutMin;
|
double EcutMin;
|
||||||
double EcutMax;
|
double EcutMax;
|
||||||
double tofCutMin;
|
double tofCutMin;
|
||||||
|
40
main.cc
40
main.cc
@ -1,19 +1,47 @@
|
|||||||
#include "BluetAnalyzer.hh"
|
#include "BluetAnalyzer.hh"
|
||||||
|
#include "clipp.h"
|
||||||
|
#include "stringhandle.hh"
|
||||||
|
|
||||||
#include "iostream"
|
#include "iostream"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
const string datapath = "/home/liuyihui/BluetAnalyzer/data";
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
if (argc < 3) {
|
string cfgfile;
|
||||||
cout << "Usage: " << argv[0] << " <config file> <data file>" << endl;
|
string datafile;
|
||||||
|
vector<string> ranges;
|
||||||
|
vector<string> runfiles;
|
||||||
|
Long_t rl, rr;
|
||||||
|
|
||||||
|
auto cfg = clipp::value("config file", cfgfile);
|
||||||
|
auto data =
|
||||||
|
(clipp::option("-f", "--file") & clipp::value("data file", datafile),
|
||||||
|
clipp::option("-r", "--range") &
|
||||||
|
clipp::values("number1 number2", ranges));
|
||||||
|
|
||||||
|
if (!clipp::parse(argc, const_cast<char **>(argv), cfg & data)) {
|
||||||
|
cerr << clipp::make_man_page(cfg & data, argv[0]) << endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
string cfgfile = argv[1];
|
if (ranges.size() == 0) {
|
||||||
string datafile = argv[2];
|
runfiles.push_back(datafile);
|
||||||
vector<string> runfiles;
|
} else {
|
||||||
runfiles.push_back(datafile);
|
std::vector<std::string> ifiles;
|
||||||
|
bluet::GetAllFiles(datapath, ifiles);
|
||||||
|
|
||||||
|
rl = stoll(ranges[0]);
|
||||||
|
rr = stoll(ranges[1]);
|
||||||
|
for (size_t j = 0; j < ifiles.size(); j++) {
|
||||||
|
if (bluet::SplitString(ifiles[j], '.')[4] != string("root"))
|
||||||
|
continue;
|
||||||
|
long long number = stoll(bluet::SplitString(ifiles[j], '.')[2]);
|
||||||
|
if (number >= rl && number <= rr)
|
||||||
|
runfiles.push_back(datapath + "/" + ifiles[j]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
BluetAnalyzer *bluet = new BluetAnalyzer();
|
BluetAnalyzer *bluet = new BluetAnalyzer();
|
||||||
bluet->readCutParameters(cfgfile);
|
bluet->readCutParameters(cfgfile);
|
||||||
|
@ -144,6 +144,7 @@ void BluetAnalyzer::readCutParameters(string cfgfile) {
|
|||||||
dv0 = bluet::XMLToQuantity(gas.child("DriftVelocity")) * 1e4;
|
dv0 = bluet::XMLToQuantity(gas.child("DriftVelocity")) * 1e4;
|
||||||
|
|
||||||
pugi::xml_node cut = root.child("CutParameters");
|
pugi::xml_node cut = root.child("CutParameters");
|
||||||
|
cutEnable = bluet::XMLToQuantity(cut.child("CutEnable"));
|
||||||
EcutMin = bluet::XMLToQuantity(cut.child("ECutMin"));
|
EcutMin = bluet::XMLToQuantity(cut.child("ECutMin"));
|
||||||
EcutMax = bluet::XMLToQuantity(cut.child("ECutMax"));
|
EcutMax = bluet::XMLToQuantity(cut.child("ECutMax"));
|
||||||
tofCutMin = bluet::XMLToQuantity(cut.child("TOFCutMin"));
|
tofCutMin = bluet::XMLToQuantity(cut.child("TOFCutMin"));
|
||||||
@ -173,7 +174,7 @@ void BluetAnalyzer::readCutParameters(string cfgfile) {
|
|||||||
|
|
||||||
Nbin = 100;
|
Nbin = 100;
|
||||||
tmin = 2.e2; // [ns] gamma
|
tmin = 2.e2; // [ns] gamma
|
||||||
tmax = 5.e6; // [ns] 1 eV
|
tmax = 1.e7; // [ns] 0.3 eV ts=1.2e6
|
||||||
Nrbin = 300;
|
Nrbin = 300;
|
||||||
rmax = 80.;
|
rmax = 80.;
|
||||||
Sbin = new double[Nrbin];
|
Sbin = new double[Nrbin];
|
||||||
@ -409,6 +410,8 @@ void BluetAnalyzer::defineHistograms() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool BluetAnalyzer::isGoodEvent(BluetEvent *event) {
|
bool BluetAnalyzer::isGoodEvent(BluetEvent *event) {
|
||||||
|
if (!cutEnable)
|
||||||
|
return true;
|
||||||
if (event->TOF0 < tofCutMin || event->TOF0 > tofCutMax)
|
if (event->TOF0 < tofCutMin || event->TOF0 > tofCutMax)
|
||||||
return false;
|
return false;
|
||||||
if (event->TimeStamp < stampCutMin || event->TimeStamp > stampCutMax)
|
if (event->TimeStamp < stampCutMin || event->TimeStamp > stampCutMax)
|
||||||
@ -428,6 +431,8 @@ bool BluetAnalyzer::isGoodEvent(BluetEvent *event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool BluetAnalyzer::isGoodTrack(BluetTrack *track) {
|
bool BluetAnalyzer::isGoodTrack(BluetTrack *track) {
|
||||||
|
if (!cutEnable)
|
||||||
|
return true;
|
||||||
if (track->TrSumEdep < EcutMin || track->TrSumEdep > EcutMax)
|
if (track->TrSumEdep < EcutMin || track->TrSumEdep > EcutMax)
|
||||||
return false;
|
return false;
|
||||||
if (track->TrRawLength < lengthCutMin || track->TrRawLength > lengthCutMax)
|
if (track->TrRawLength < lengthCutMin || track->TrRawLength > lengthCutMax)
|
||||||
@ -491,8 +496,8 @@ void BluetAnalyzer::FillHistograms() {
|
|||||||
|
|
||||||
double sumE = fEvent->Tracks[itrk].TrSumEdep;
|
double sumE = fEvent->Tracks[itrk].TrSumEdep;
|
||||||
double length = fEvent->Tracks[itrk].TrRawLength;
|
double length = fEvent->Tracks[itrk].TrRawLength;
|
||||||
double tmax = fEvent->Tracks[itrk].Tmax;
|
double traTmax = fEvent->Tracks[itrk].Tmax;
|
||||||
double tmin = fEvent->Tracks[itrk].Tmin;
|
double traTmin = fEvent->Tracks[itrk].Tmin;
|
||||||
double cost = fEvent->Tracks[itrk].TrCosTheta;
|
double cost = fEvent->Tracks[itrk].TrCosTheta;
|
||||||
double *xypos = fEvent->Tracks[itrk].ZmaxHit_xy;
|
double *xypos = fEvent->Tracks[itrk].ZmaxHit_xy;
|
||||||
double radius =
|
double radius =
|
||||||
@ -504,17 +509,17 @@ void BluetAnalyzer::FillHistograms() {
|
|||||||
if (radius >= rTarget && rSubstrate <= rSubstrate + 5)
|
if (radius >= rTarget && rSubstrate <= rSubstrate + 5)
|
||||||
nRing++;
|
nRing++;
|
||||||
|
|
||||||
double v0 = driftL / (tmax - tcath) / sampleT;
|
double v0 = driftL / (traTmax - tcath) / sampleT;
|
||||||
double v1 = driftL / (tmax - tmin) / sampleT;
|
double v1 = driftL / (traTmax - traTmin) / sampleT;
|
||||||
hv0->Fill(v0 * 1000.); // [mm/ns]->[mm/us]
|
hv0->Fill(v0 * 1000.); // [mm/ns]->[mm/us]
|
||||||
hv1->Fill(v1 * 1000.); // [mm/ns]->[mm/us]
|
hv1->Fill(v1 * 1000.); // [mm/ns]->[mm/us]
|
||||||
htpad->Fill((tmax - tmin) * sampleT);
|
htpad->Fill((traTmax - traTmin) * sampleT);
|
||||||
htcath->Fill((tmax - tcath) * sampleT);
|
htcath->Fill((traTmax - tcath) * sampleT);
|
||||||
|
|
||||||
hcos->Fill(fabs(cost));
|
hcos->Fill(fabs(cost));
|
||||||
hphi->Fill(fEvent->Tracks[itrk].TrPhi);
|
hphi->Fill(fEvent->Tracks[itrk].TrPhi);
|
||||||
hdeltacos1->Fill(fabs(cost), (tmax - tcath) * sampleT);
|
hdeltacos1->Fill(fabs(cost), (traTmax - tcath) * sampleT);
|
||||||
hdeltacos2->Fill(fabs(cost), (tmax - tmin) * sampleT);
|
hdeltacos2->Fill(fabs(cost), (traTmax - traTmin) * sampleT);
|
||||||
hLengthE->Fill(length, sumE);
|
hLengthE->Fill(length, sumE);
|
||||||
hprofile->Fill(xypos[0], xypos[1]);
|
hprofile->Fill(xypos[0], xypos[1]);
|
||||||
hbeamr->Fill(radius);
|
hbeamr->Fill(radius);
|
||||||
|
Loading…
Reference in New Issue
Block a user