17 #include "CAFAna/Core/Binning.h" 23 #include "CAFAna/Core/Var.h" 34 #include "TLorentzVector.h" 60 const std::string trainingSet =
"muonid_training_sample";
61 const std::string testingSet =
"muonid_testing_sample";
65 if (setname ==
"train"){
66 cout <<
"Making Training Trim file from dataset: " << trainingSet <<
endl;
67 samQuery =
"dataset_def_name_newest_snapshot " + trainingSet;
69 else if (setname ==
"test"){
70 cout <<
"Making Testing Trim File from dataset: " << testingSet <<
endl;
71 samQuery =
"dataset_def_name_newest_snapshot " + testingSet;
74 cerr <<
"Setname should be either \"train\" or \"test\". Exiting." <<
endl;
78 TFile outputFile(outputFilename.c_str(),
"RECREATE");
80 TTree *sigTree =
new TTree(
"sigTree",
"Signal Events");
81 TTree *bkgTree =
new TTree(
"bkgTree",
"Background Events");
89 float fScatLL = -999.0;
90 float fDedxLL = -999.0;
91 float fAvededxlast10cm = -999.0;
92 float fAvededxlast20cm = -999.0;
93 float fAvededxlast30cm = -999.0;
94 float fAvededxlast40cm = -999.0;
101 sigTree->Branch(
"DedxLL", &fDedxLL,
"DedxLL/F");
102 sigTree->Branch(
"ScatLL", &fScatLL,
"ScatLL/F");
103 sigTree->Branch(
"Avededxlast10cm", &fAvededxlast10cm,
"Avededxlast10cm/F");
104 sigTree->Branch(
"Avededxlast20cm", &fAvededxlast20cm,
"Avededxlast20cm/F");
105 sigTree->Branch(
"Avededxlast30cm", &fAvededxlast30cm,
"Avededxlast30cm/F");
106 sigTree->Branch(
"Avededxlast40cm", &fAvededxlast40cm,
"Avededxlast40cm/F");
108 bkgTree->Branch(
"DedxLL", &fDedxLL,
"DedxLL/F");
109 bkgTree->Branch(
"ScatLL", &fScatLL,
"ScatLL/F");
110 bkgTree->Branch(
"Avededxlast10cm", &fAvededxlast10cm,
"Avededxlast10cm/F");
111 bkgTree->Branch(
"Avededxlast20cm", &fAvededxlast20cm,
"Avededxlast20cm/F");
112 bkgTree->Branch(
"Avededxlast30cm", &fAvededxlast30cm,
"Avededxlast30cm/F");
113 bkgTree->Branch(
"Avededxlast40cm", &fAvededxlast40cm,
"Avededxlast40cm/F");
123 if(
getenv(
"CAFANA_STRIDE")){
124 stride = atoi(
getenv(
"CAFANA_STRIDE"));
125 if(stride > 1 &&
getenv(
"CAFANA_OFFSET")){
126 offset = atoi(
getenv(
"CAFANA_OFFSET"));
133 int Nfiles = filesrc->
NFiles();
138 bool foundFile =
true;
140 if(!file1) foundFile =
false;
141 assert(!file1->IsZombie());
148 if(!prog) prog =
new Progress(
TString::Format(
"Filling signal and background trees from %d files", Nfiles).Data());
150 if(Nfiles > 1 && prog) prog->
SetProgress((fileIdx+1.)/Nfiles);
153 TTree *
recTree = (TTree*)file1->Get(
"recTree");
155 TTree *spillTree = (TTree*)file1->Get(
"spillTree");
159 recTree->SetBranchAddress(
"rec", &sr);
162 spillTree->SetBranchAddress(
"spill", &sp);
169 if(sp->
ismc) ismc =
true;
173 bool istrigger =
false;
174 if(sp->
trigger == 2) istrigger =
true;
177 bool goodspill =
false;
188 if(sp->
hornI < -202 || sp->
hornI > -198)
continue;
190 if(sp->
posx < -2.00 || sp->
posx > +2.00)
continue;
192 if(sp->
posy < -2.00 || sp->
posy > +2.00)
continue;
198 bool gdspill =
false;
234 Int_t numberOfEntries = recTree->GetEntriesFast();
238 for (Int_t event = 0;
event < numberOfEntries; ++event) {
239 recTree->GetEntry(event);
241 if(sr->
vtx.nelastic == 0)
continue;
242 if(sr->
mc.
nnu < 1)
continue;
250 bool isquality =
false;
251 bool iscontprong =
true;
257 if(
std::min( start.X(), stop.X() ) < -180.0 ||
258 std::max( start.X(), stop.X() ) > 180.0 ||
259 std::min( start.Y(), stop.Y() ) < -180.0 ||
260 std::max( start.Y(), stop.Y() ) > 180.0 ||
261 std::min( start.Z(), stop.Z() ) < 20.0 ||
262 std::max( start.Z(), stop.Z() ) > 1525.0 ){
275 if (isquality && iscontprong){
278 if( nkals < 1 )
continue;
281 for (
int itrk = 0; itrk < nkals; ++itrk){
295 fAvededxlast10cm = 30;
300 fAvededxlast20cm = 30;
305 fAvededxlast30cm = 30;
310 fAvededxlast40cm = 30;
329 }
while( (file1 =(TFile*)filesrc->
GetNextFile()) );
Near Detector underground.
T max(const caf::Proxy< T > &a, T b)
unsigned long int spilltimesec
Spill time in seconds [s].
unsigned int nmissingdcmslg
# of DCMS with 63 or more bad FEBs (LiveGeometry, subset of baddcmslg)
Far Detector at Ash River.
Cuts and Vars for the 2020 FD DiF Study.
void trimvar(const std::string outputFilename, const std::string setname)
std::vector< SRFuzzyKProng > png
Vector of 3D prong objects.
Det_t det
Detector, ND = 1, FD = 2, NDOS = 3.
unsigned int nmissingdcms
# of missing DCMs
float posy
y position on target
float dcmedgematchfrac
How many hits at the DCM edge are matched in the adjacent DCM?
float fracdcm3hits
fraction of DCM3 hits in horizontal modules
SRKalman kalman
Tracks produced by KalmanTrack.
unsigned int nshwlid
number of shwlid showers - either 0 or number of 3d prongs
int NFiles() const override
May return -1 indicating the number of files is not known.
std::string getenv(std::string const &name)
bool isgoodspill
Was the pot for a spill good? (only applicable to data, default true)
float widthy
Spill width in y dimension.
File source based on a SAM query or dataset (definition)
float widthx
Spill width in x dimension.
short nnu
Number of neutrinos in nu vector (0 or 1)
unsigned int nhit
number of hits
The StandardRecord is the primary top-level object in the Common Analysis File trees.
signed long long int deltaspilltimensec
Delta time [ns].
void SetProgress(double frac)
Update the progress fraction between zero and one.
bool eventincomplete
Data Quality DAQ Header information.
SRElastic elastic
Single vertex found by Elastic Arms.
virtual TFile * GetNextFile() override
Returns the next file in sequence, ready for reading.
assert(nhit_max >=nhit_nbins)
A simple ascii-art progress bar.
SRSlice slc
Slice branch: nhit, extents, time, etc.
SRTruthBranch mc
Truth branch for MC: energy, flavor, etc.
SRFuzzyK fuzzyk
Primary 3D prong object.
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
unsigned char trigger
The trigger type from RawTrigger::fTriggerMask_TriggerType.
T min(const caf::Proxy< T > &a, T b)
unsigned int ncontplanes
number of continuous planes
SRTrackBranch trk
Track branch: nhit, len, etc.
void Done()
Call this when action is completed.
bool ismc
data or MC? True if MC
std::vector< SRKalmanTrack > tracks
3D Tracks produced by KalmanTrack
float posx
x position on target
SRVertexBranch vtx
Vertex branch: location, time, etc.