trim_caf.C File Reference
#include "CAFAna/Cuts/Cuts.h"
#include "CAFAna/Cuts/NumuCuts.h"
#include "CAFAna/Cuts/SpillCuts.h"
#include "CAFAna/Core/Loaders.h"
#include "CAFAna/Core/Binning.h"
#include "CAFAna/Prediction/PredictionGenerator.h"
#include "CAFAna/Prediction/PredictionInterp.h"
#include "CAFAna/Prediction/PredictionInterp2.h"
#include "CAFAna/Prediction/PredictionNumuFAHadE.h"
#include "CAFAna/Prediction/PredictionExtrap.h"
#include "CAFAna/Prediction/PredictionCombinePeriods.h"
#include "CAFAna/Systs/Systs.h"
#include "CAFAna/Systs/NumuSysts.h"
#include "CAFAna/Extrap/ModularExtrap.h"
#include "CAFAna/Analysis/Calcs.h"
#include "CAFAna/Analysis/Fit.h"
#include "CAFAna/Analysis/Surface.h"
#include "CAFAna/Analysis/Plots.h"
#include "CAFAna/Experiment/SingleSampleExperiment.h"
#include "CAFAna/Experiment/MultiExperiment.h"
#include "CAFAna/Experiment/SolarConstraints.h"
#include "CAFAna/Experiment/ReactorExperiment.h"
#include "CAFAna/Vars/FitVars.h"
#include "CAFAna/FC/FCCollection.h"
#include "CAFAna/FC/FCPoint.h"
#include "CAFAna/FC/FCSurface.h"
#include "TCanvas.h"
#include "TFile.h"
#include "TGraph.h"
#include "TH1.h"
#include "TH2.h"
#include "TMath.h"
#include "TGaxis.h"
#include "TMultiGraph.h"
#include "TLegend.h"
#include "TLatex.h"
#include "TStyle.h"
#include "THStack.h"
#include "TPaveText.h"
#include "TGraphAsymmErrors.h"
#include "TLegendEntry.h"
#include "TMarker.h"
#include "TFeldmanCousins.h"
#include "TRandom3.h"
#include "TChain.h"
#include "TTree.h"
#include "TString.h"
#include "TObjString.h"
#include "TSystem.h"
#include "TROOT.h"
#include <cmath>
#include <iostream>
#include <vector>
#include <sstream>
#include <string>
#include <fstream>
#include <iomanip>
#include <cstdlib>
#include <map>
#include "StandardRecord/StandardRecord.h"

Go to the source code of this file.


void trim_caf (std::string inputFilename)

Function Documentation

void trim_caf ( std::string  inputFilename)

Definition at line 81 of file trim_caf.C.

References caf::SRCosRej::anglecos, caf::SRCosRej::anglekal, caf::SRSlice::boxmax, caf::SRSlice::boxmin, caf::SRSlice::calE, caf::SRCosRej::cdirscore, caf::SRIDBranch::contain, caf::SRContain::cosbakcell, caf::SRContain::cosfwdcell, caf::SRTrackBranch::cosmic, caf::SRIDBranch::cosrej, om::cout, caf::SRIDBranch::cvn, allTimeWatchdog::endl, caf::StandardRecord::energy, caf::SRHeader::evt, file, check_time_usage::float, caf::SRNumuEnergy::hadcalE, caf::StandardRecord::hdr, MECModelEnuComparisons::i, caf::SRHeader::ismc, caf::SRContain::kalbakcell, caf::SRContain::kalfwdcell, caf::SRTrackBranch::kalman, caf::SRVeto::keep, caf::StandardRecord::mc, caf::SRContain::missE, caf::SRSlice::ncontplanes, caf::SRSlice::nhit, caf::SRTrackBase::ntracks, caf::SRKalman::ntracks, caf::SRTruthBranch::nu, caf::SRIDBranch::nuecosrej, caf::SREnergyBranch::numu, caf::SRContain::numucontain, caf::SRCVNResult::numuid, caf::SRCVNResult::output, caf::SRRemid::pid, caf::SRNueCosRej::pngptp, caf::SRIDBranch::remid, caf::SRHeader::run, caf::SRCosRej::scatt, caf::StandardRecord::sel, caf::StandardRecord::slc, sr, caf::SRTrackBase::tracks, caf::SRKalman::tracks, compareCafs::tree, trim(), caf::StandardRecord::trk, caf::SRIDBranch::veto, and caf::SRVector3D::y.

82 {
83  int fntracks3d, fcosfwdcell, fcosbakcell, fkalfwdcell, fkalbakcell, fnhit, fnhitkal, fnhitcos, ftype, frun, fncontplanes, fev;
84  float fmaxy, fminy, fanglekal, fanglecos, fkaldiry, fcosdiry, fscatt, fvisE, fremid, fvtxX, fvtxY, fvtxZ;
85  float fHadE,fmisse,ftrueE,fosc,ftracklen,foldbdt,fcvnnumu,fcvncosmic,fpngptp,fcdirscore;
87  TFile* outputFile = TFile::Open( "bdt_trimmed.root", "RECREATE" );
89  TTree *trim = new TTree("trimmed", "trimmed tree");
90  trim->SetDirectory(0);
92  trim->Branch("ntracks3d", &fntracks3d, "ntracks3d/I");
93  trim->Branch("cosfwdcell", &fcosfwdcell, "cosfwdcell/I");
94  trim->Branch("cosbakcell", &fcosbakcell, "cosbakcell/I");
95  trim->Branch("kalfwdcell", &fkalfwdcell, "kalfwdcell/I");
96  trim->Branch("kalbakcell", &fkalbakcell, "kalbakcell/I");
97  trim->Branch("type", &ftype, "type/I"); // 0 for data, 1 for CC MC, 2 for NC MC
98  trim->Branch("maxy", &fmaxy, "maxy/F");
99  trim->Branch("miny", &fminy, "miny/F");
100  trim->Branch("tracklen", &ftracklen, "tracklen/F");
101  trim->Branch("run", &frun, "run/I");
102  trim->Branch("ev", &fev, "ev/I");
103  trim->Branch("ncontplanes", &fncontplanes, "ncontplanes/I");
104  trim->Branch("anglekal", &fanglekal, "anglekal/F");
105  trim->Branch("anglecos", &fanglecos, "anglecos/F");
106  trim->Branch("kaldiry", &fkaldiry, "kaldiry/F");
107  trim->Branch("cosdiry", &fcosdiry, "cosdiry/F");
108  trim->Branch("scatt", &fscatt, "scatt/F");
109  trim->Branch("nhit", &fnhit, "nhit/I");
110  trim->Branch("nhitkal", &fnhitkal, "nhitkal/I");
111  trim->Branch("nhitcos", &fnhitcos, "nhitcos/I");
112  trim->Branch("remid", &fremid, "remid/F");
113  trim->Branch("vtx", &fvtxX, "vtx/F");
114  trim->Branch("vty", &fvtxY, "vty/F");
115  trim->Branch("vtz", &fvtxZ, "vtz/F");
116  trim->Branch("visE", &fvisE, "visE/F");
117  trim->Branch("hade", &fHadE, "hade/F");
118  trim->Branch("misse", &fmisse, "misse/F");
119  trim->Branch("trueE", &ftrueE, "trueE/F");
120  trim->Branch("osc", &fosc, "osc/F");
121  trim->Branch("cvnnumu", &fcvnnumu, "cvnnumu/F");
122  trim->Branch("cvncosmic", &fcvncosmic, "cvncosmic/F");
123  trim->Branch("cdirscore", &fcdirscore, "cdirscore/F");
124  trim->Branch("pngptp", &fpngptp, "pngptp/F");
125  trim->Branch("oldbdt", &foldbdt, "oldbdt/F");
127  //note would be useful to add: proper numu energy estimator, ppfx and x-section weights for MC
129  caf::StandardRecord* sr = 0;
131  // data
133  TFile *file = new TFile(inputFilename.c_str());
134  TTree *tree = (TTree*)file->Get("recTree");
135  tree->SetBranchAddress("rec", &sr);
137  for(int i = 0; i<tree->GetEntries(); i++) {
138  tree->GetEntry(i);
139  if(i%10000==0) std::cout << "processing " << i << " of " << tree->GetEntries() << " is " << 100.0*float(i)/float(tree->GetEntries()) << "% done" << std::endl;
141  if(sr->trk.cosmic.ntracks==0) continue; // needs to be a cosmic track
142  if(sr->trk.kalman.ntracks==0) continue; // needs to be a kalman track
143  if(sr->sel.veto.keep==0) continue; // needs to pass cosveto
144  if(sr->sel.contain.numucontain==0) continue; // numu containment; this is SA containment cut, needs to be updated by writing out explicitly
146  if(sr->hdr.ismc) { // for GENIE
147  fosc = sr->[0].woscdumb; // want to use oscillated FD; this is simplest approximation; could replace with latest best fits
148  if(sr->[0].iscc) ftype = 1; // TYPE = 1 for CC MC
149  else ftype = 2; // TYPE = 2 for NC MC
150  fmisse = sr->sel.contain.missE; // spectrator variable, could replace with newer better missing E handles
151  ftrueE = sr->[0].E;
152  }
154  else {
155  fosc = 1; // don't oscillate data
156  ftype = 0; // TYPE = 0 for data
157  fmisse = 0; // true vars don't exist for data
158  ftrueE = 0;
159  }
161  frun = sr->;
162  fev = sr->hdr.evt;
163  ftracklen = sr->trk.kalman.tracks[0].len;
164  fncontplanes = sr->slc.ncontplanes;
165  fntracks3d = sr->trk.kalman.ntracks;
166  fcosfwdcell = sr->sel.contain.cosfwdcell;
167  fcosbakcell = sr->sel.contain.cosbakcell;
168  fkalfwdcell = sr->sel.contain.kalfwdcell;
169  fkalbakcell = sr->sel.contain.kalbakcell;
170  fmaxy = sr->slc.boxmax.y;
171  fminy = sr->slc.boxmin.y;
172  fanglekal = sr->sel.cosrej.anglekal;
173  fanglecos = sr->sel.cosrej.anglecos;
174  fnhitkal = sr->trk.kalman.tracks[0].nhit;
175  fnhitcos = sr->trk.cosmic.tracks[0].nhit;
176  fremid = sr->;
177  fkaldiry = sr->trk.kalman.tracks[0].dir.y;
178  fcosdiry = sr->trk.cosmic.tracks[0].dir.y;
179  fnhit = sr->slc.nhit;
180  fvtxX = sr->trk.kalman.tracks[0].start.x;
181  fvtxY = sr->trk.kalman.tracks[0].start.y;
182  fvtxZ = sr->trk.kalman.tracks[0].start.z;
183  fscatt = sr->sel.cosrej.scatt;
184  fvisE = sr->slc.calE;
185  foldbdt = sr->sel.cosrej.numucontpid;
186  fHadE = sr->energy.numu.hadcalE;
187  fcvnnumu = sr->sel.cvn.numuid;
188  fcvncosmic = sr->sel.cvn.output[14];
189  fpngptp = sr->sel.nuecosrej.pngptp;
190  fcdirscore = sr->sel.cosrej.cdirscore;
192  trim->Fill();
193  }
195  outputFile->cd();
197  trim->Write();
199  outputFile->Close();
200 }
int cosfwdcell
cosmictrack projected # cells from end point forwards to det edge
Definition: SRContain.h:30
float missE
sum of energy of particles that leave detector. example cut: missE/trueE > 0.01 is truly uncontained ...
Definition: SRContain.h:21
SRHeader hdr
Header branch: run, subrun, etc.
SRCosRej cosrej
Output from CosRej (Cosmic Rejection)
Definition: SRIDBranch.h:47
size_t ntracks
Definition: SRKalman.h:23
SRVector3D boxmax
Maximum coordinates box containing all the hits [cm].
Definition: SRSlice.h:47
string trim(string in)
Definition: rootgINukeVal.C:65
unsigned int run
run number
Definition: SRHeader.h:21
bool ismc
data or MC? True if MC
Definition: SRHeader.h:27
int cosbakcell
cosmictrack projected # cells from start point backwards to det edge
Definition: SRContain.h:35
float scatt
sum of all all angular deviation (looping over kaltrk traj pts) / trk len
Definition: SRCosRej.h:41
unsigned int evt
ART event number, indexes trigger windows.
Definition: SRHeader.h:25
SRKalman kalman
Tracks produced by KalmanTrack.
Definition: SRTrackBranch.h:24
float pid
PID value output by kNN.
Definition: SRRemid.h:25
bool keep
Definition: SRVeto.h:34
SRVector3D boxmin
Minimum coordinates box containing all the hits [cm].
Definition: SRSlice.h:46
float anglekal
cos of angle of best ReMId Kalman track
Definition: SRCosRej.h:23
SRCVNResult cvn
Horrible hack to appease CAFAna.
Definition: SRIDBranch.h:53
bool numucontain
is this contained by Numu Standards? (can use as general containment)
Definition: SRContain.h:18
SRNueCosRej nuecosrej
Output from NueCosRej (Nue Cosmic Rejection)
Definition: SRIDBranch.h:48
SRRemid remid
Output from RecoMuonID (ReMId) package.
Definition: SRIDBranch.h:39
float calE
Calorimetric energy of the cluster [GeV].
Definition: SRSlice.h:38
std::vector< float > output
List of net output nodes.
Definition: SRCVNResult.h:19
caf::StandardRecord * sr
unsigned int nhit
number of hits
Definition: SRSlice.h:22
OStream cout
Definition: OStream.cxx:6
The StandardRecord is the primary top-level object in the Common Analysis File trees.
int kalfwdcell
Kalmantrack projected # cells from end point forwards to det edge.
Definition: SRContain.h:40
SRNumuEnergy numu
Numu energy estimator.
SRIDBranch sel
Selector (PID) branch.
float numuid
Likelihood Charge Current NuMu.
Definition: SRCVNResult.h:20
int kalbakcell
Kalmantrack projected # cells from start point backwards to det edge.
Definition: SRContain.h:45
TFile * file
Definition: cellShifts.C:17
SRSlice slc
Slice branch: nhit, extents, time, etc.
SRTruthBranch mc
Truth branch for MC: energy, flavor, etc.
SRVeto veto
Output from CosmicVeto (Preliminary preselection)
Definition: SRIDBranch.h:52
unsigned int ncontplanes
number of continuous planes
Definition: SRSlice.h:25
SRTrackBranch trk
Track branch: nhit, len, etc.
SREnergyBranch energy
Energy estimator branch.
SRTrackBase cosmic
Tracks produced by CosmicTrack.
Definition: SRTrackBranch.h:26
float anglecos
cos of angle of Cosmic Track
Definition: SRCosRej.h:24
SRContain contain
Output from SRContain (containment related variables)
Definition: SRIDBranch.h:51
std::vector< SRNeutrino > nu
implemented as a vector to maintain structure, i.e. not a pointer, but with 0 or 1 entries...
Definition: SRTruthBranch.h:25
std::vector< SRTrack > tracks
Definition: SRTrackBase.h:15
float cdirscore
chisq score difference between +c and -c assumptions in Hough timing fit (TimingFit module) for cosmi...
Definition: SRCosRej.h:58
float hadcalE
Hadronic calorimetric energy NOT on the muon track[GeV].
Definition: SRNumuEnergy.h:35
std::vector< SRKalmanTrack > tracks
3D Tracks produced by KalmanTrack
Definition: SRKalman.h:16