Public Member Functions | Private Attributes | List of all members
MCP_Skimmer Class Reference

#include <MCP_Skimmer.h>

Public Member Functions

 MCP_Skimmer ()
 
 MCP_Skimmer (std::string infilename, std::string outfilename)
 
 MCP_Skimmer (const MCP_Skimmer &)=default
 
 ~MCP_Skimmer ()
 
void SkimMCParticle ()
 
bool BookTFile ()
 
void FillTTree ()
 
void WriteTTree ()
 
void CloseTFile ()
 
void ClearVectors ()
 
void SetDebug (bool debug)
 

Private Attributes

TFile * _intfile
 
TFile * _skimfile
 
TTree * _skimtree
 
TTree * _inttree
 
bool _debug
 
Utils_util
 
std::string _infile
 
std::string _outfile
 
int _Event
 
int _SubRun
 
int _Run
 
std::vector< float > _MC_Q2
 
std::vector< float > _MC_W
 
std::vector< float > _MC_Y
 
std::vector< float > _MC_X
 
std::vector< float > _MC_Theta
 
std::vector< float > _MC_T
 
std::vector< float > _MCVertX
 
std::vector< float > _MCVertY
 
std::vector< float > _MCVertZ
 
std::vector< float > _MCNuPx
 
std::vector< float > _MCNuPy
 
std::vector< float > _MCNuPz
 
std::vector< int > _NType
 
std::vector< int > _CCNC
 
std::vector< int > _Mode
 
std::vector< int > _Gint
 
std::vector< int > _TgtPDG
 
std::vector< int > _GT_T
 
std::vector< int > _InterT
 
std::vector< float > _Weight
 
std::vector< int > _PDG
 
std::vector< int > _Mother
 
std::vector< int > _PDGMother
 
std::vector< int > _MCPTrkID
 
std::vector< float > _MCPTime
 
std::vector< float > _MCPStartX
 
std::vector< float > _MCPStartY
 
std::vector< float > _MCPStartZ
 
std::vector< float > _MCPStartPX
 
std::vector< float > _MCPStartPY
 
std::vector< float > _MCPStartPZ
 
std::vector< std::string_MCPProc
 
std::vector< std::string_MCPEndProc
 
std::vector< float > _MCPEndX
 
std::vector< float > _MCPEndY
 
std::vector< float > _MCPEndZ
 
std::vector< float > _TrajMCPX
 
std::vector< float > _TrajMCPY
 
std::vector< float > _TrajMCPZ
 
std::vector< int > _TrajMCPTrajIndex
 
std::vector< int > daughtersToKeep = {22, 111, 310, 13, 211, 321}
 

Detailed Description

Definition at line 11 of file MCP_Skimmer.h.

Constructor & Destructor Documentation

MCP_Skimmer::MCP_Skimmer ( )

Definition at line 11 of file MCP_Skimmer.cpp.

12 : _intfile(nullptr), _skimfile(nullptr), _skimtree(nullptr), _inttree(nullptr), _debug(false), _util(new Utils()), _infile(""), _outfile("")
13 {
14 
15 }
TTree * _skimtree
Definition: MCP_Skimmer.h:53
TTree * _inttree
Definition: MCP_Skimmer.h:54
TFile * _skimfile
Definition: MCP_Skimmer.h:52
TFile * _intfile
Definition: MCP_Skimmer.h:51
std::string _outfile
Definition: MCP_Skimmer.h:58
Utils * _util
Definition: MCP_Skimmer.h:56
Definition: Utils.h:7
std::string _infile
Definition: MCP_Skimmer.h:57
MCP_Skimmer::MCP_Skimmer ( std::string  infilename,
std::string  outfilename 
)

Definition at line 17 of file MCP_Skimmer.cpp.

18 : _skimfile(nullptr), _skimtree(nullptr), _debug(false), _util(new Utils()), _infile(infilename), _outfile(outfilename)
19 {
20 
21 }
TTree * _skimtree
Definition: MCP_Skimmer.h:53
TFile * _skimfile
Definition: MCP_Skimmer.h:52
std::string _outfile
Definition: MCP_Skimmer.h:58
Utils * _util
Definition: MCP_Skimmer.h:56
Definition: Utils.h:7
std::string _infile
Definition: MCP_Skimmer.h:57
MCP_Skimmer::MCP_Skimmer ( const MCP_Skimmer )
default
MCP_Skimmer::~MCP_Skimmer ( )

Definition at line 23 of file MCP_Skimmer.cpp.

24 {
25 
26 }

Member Function Documentation

bool MCP_Skimmer::BookTFile ( )

Definition at line 417 of file MCP_Skimmer.cpp.

418 {
419  _intfile = new TFile( _infile.c_str() );
420  if(nullptr == _intfile)
421  return false;
422 
423  _inttree = (TTree*) _intfile->Get( "anatree/GArAnaTree" );
424  if(nullptr == _inttree)
425  return false;
426 
427  _skimfile = new TFile(_outfile.c_str(), "RECREATE");
428  if(nullptr == _skimfile){
429  return false;
430  }
431  else
432  {
433 
434  TDirectory *anatree = _skimfile->mkdir("anatree");
435  anatree->cd();
436  _skimtree = new TTree( "GArAnaTree", "GArAnaTree" );
437 
438  _skimtree->Branch("Event", &_Event);
439  _skimtree->Branch("SubRun", &_SubRun);
440  _skimtree->Branch("Run", &_Run);
441 
442  //Generator info
443  _skimtree->Branch("NType", &_NType);
444  _skimtree->Branch("CCNC", &_CCNC);
445  _skimtree->Branch("MC_Q2", &_MC_Q2);
446  _skimtree->Branch("MC_W", &_MC_W);
447  _skimtree->Branch("MC_Y", &_MC_Y);
448  _skimtree->Branch("MC_X", &_MC_X);
449  _skimtree->Branch("MC_Theta", &_MC_Theta);
450  _skimtree->Branch("MC_T", &_MC_T);
451  _skimtree->Branch("Mode", &_Mode);
452  _skimtree->Branch("Gint", &_Gint);
453  _skimtree->Branch("TgtPDG", &_TgtPDG);
454  _skimtree->Branch("GT_T", &_GT_T);
455  _skimtree->Branch("MCVertX", &_MCVertX);
456  _skimtree->Branch("MCVertY", &_MCVertY);
457  _skimtree->Branch("MCVertZ", &_MCVertZ);
458  _skimtree->Branch("MCNuPx", &_MCNuPx);
459  _skimtree->Branch("MCNuPy", &_MCNuPy);
460  _skimtree->Branch("MCNuPz", &_MCNuPz);
461  _skimtree->Branch("InterT", &_InterT);
462  _skimtree->Branch("Weight", &_Weight);
463 
464  //MC info
465  _skimtree->Branch("PDG", &_PDG);
466  _skimtree->Branch("MCPTrkID", &_MCPTrkID);
467  _skimtree->Branch("MCPTime", &_MCPTime);
468  _skimtree->Branch("MCPStartX", &_MCPStartX);
469  _skimtree->Branch("MCPStartY", &_MCPStartY);
470  _skimtree->Branch("MCPStartZ", &_MCPStartZ);
471  _skimtree->Branch("MCPEndX", &_MCPEndX);
472  _skimtree->Branch("MCPEndY", &_MCPEndY);
473  _skimtree->Branch("MCPEndZ", &_MCPEndZ);
474  _skimtree->Branch("Mother", &_Mother);
475  _skimtree->Branch("PDGMother", &_PDGMother);
476  _skimtree->Branch("MCPStartPX", &_MCPStartPX);
477  _skimtree->Branch("MCPStartPY", &_MCPStartPY);
478  _skimtree->Branch("MCPStartPZ", &_MCPStartPZ);
479  _skimtree->Branch("MCPProc", &_MCPProc);
480  _skimtree->Branch("MCPEndProc", &_MCPEndProc);
481  _skimtree->Branch("TrajMCPX", &_TrajMCPX);
482  _skimtree->Branch("TrajMCPY", &_TrajMCPY);
483  _skimtree->Branch("TrajMCPZ", &_TrajMCPZ);
484  _skimtree->Branch("TrajMCPTrajIndex", &_TrajMCPTrajIndex);
485 
486  return true;
487  }
488 }
TTree * _skimtree
Definition: MCP_Skimmer.h:53
std::vector< std::string > _MCPProc
Definition: MCP_Skimmer.h:96
std::vector< float > _MCPStartX
Definition: MCP_Skimmer.h:90
std::vector< float > _MCPEndZ
Definition: MCP_Skimmer.h:100
std::vector< int > _GT_T
Definition: MCP_Skimmer.h:81
std::vector< float > _MCPStartZ
Definition: MCP_Skimmer.h:92
std::vector< int > _Gint
Definition: MCP_Skimmer.h:79
TTree * _inttree
Definition: MCP_Skimmer.h:54
std::vector< float > _Weight
Definition: MCP_Skimmer.h:83
std::vector< float > _MCPStartPZ
Definition: MCP_Skimmer.h:95
std::vector< float > _MCNuPy
Definition: MCP_Skimmer.h:74
std::vector< float > _TrajMCPY
Definition: MCP_Skimmer.h:102
std::vector< int > _MCPTrkID
Definition: MCP_Skimmer.h:88
std::vector< float > _MCPTime
Definition: MCP_Skimmer.h:89
std::vector< float > _MCPStartY
Definition: MCP_Skimmer.h:91
std::vector< float > _MCVertY
Definition: MCP_Skimmer.h:71
std::vector< float > _TrajMCPX
Definition: MCP_Skimmer.h:101
std::vector< int > _TrajMCPTrajIndex
Definition: MCP_Skimmer.h:104
std::vector< float > _TrajMCPZ
Definition: MCP_Skimmer.h:103
std::vector< float > _MCPEndX
Definition: MCP_Skimmer.h:98
std::vector< float > _MC_Y
Definition: MCP_Skimmer.h:66
std::vector< float > _MCPEndY
Definition: MCP_Skimmer.h:99
std::vector< int > _Mode
Definition: MCP_Skimmer.h:78
std::vector< float > _MC_T
Definition: MCP_Skimmer.h:69
std::vector< float > _MCPStartPX
Definition: MCP_Skimmer.h:93
std::vector< int > _InterT
Definition: MCP_Skimmer.h:82
std::vector< std::string > _MCPEndProc
Definition: MCP_Skimmer.h:97
TFile * _skimfile
Definition: MCP_Skimmer.h:52
std::vector< int > _NType
Definition: MCP_Skimmer.h:76
TFile * _intfile
Definition: MCP_Skimmer.h:51
std::vector< float > _MC_W
Definition: MCP_Skimmer.h:65
std::vector< int > _TgtPDG
Definition: MCP_Skimmer.h:80
std::vector< float > _MCVertX
Definition: MCP_Skimmer.h:70
std::string _outfile
Definition: MCP_Skimmer.h:58
std::vector< int > _PDG
Definition: MCP_Skimmer.h:85
std::vector< int > _Mother
Definition: MCP_Skimmer.h:86
std::vector< float > _MC_X
Definition: MCP_Skimmer.h:67
std::vector< float > _MC_Theta
Definition: MCP_Skimmer.h:68
std::vector< float > _MCNuPz
Definition: MCP_Skimmer.h:75
std::vector< int > _PDGMother
Definition: MCP_Skimmer.h:87
std::vector< float > _MC_Q2
Definition: MCP_Skimmer.h:64
std::vector< float > _MCVertZ
Definition: MCP_Skimmer.h:72
std::vector< float > _MCNuPx
Definition: MCP_Skimmer.h:73
std::vector< float > _MCPStartPY
Definition: MCP_Skimmer.h:94
std::string _infile
Definition: MCP_Skimmer.h:57
std::vector< int > _CCNC
Definition: MCP_Skimmer.h:77
void MCP_Skimmer::ClearVectors ( )

Definition at line 28 of file MCP_Skimmer.cpp.

29 {
30  _MC_Q2.clear();
31  _MC_W.clear();
32  _MC_Y.clear();
33  _MC_X.clear();
34  _MC_Theta.clear();
35  _MC_T.clear();
36  _MCVertX.clear();
37  _MCVertY.clear();
38  _MCVertZ.clear();
39  _MCNuPx.clear();
40  _MCNuPy.clear();
41  _MCNuPz.clear();
42  _NType.clear();
43  _CCNC.clear();
44  _Mode.clear();
45  _Gint.clear();
46  _TgtPDG.clear();
47  _GT_T.clear();
48  _InterT.clear();
49  _Weight.clear();
50 
51  _PDG.clear();
52  _Mother.clear();
53  _PDGMother.clear();
54  _MCPTrkID.clear();
55  _MCPTime.clear();
56  _MCPStartX.clear();
57  _MCPStartY.clear();
58  _MCPStartZ.clear();
59  _MCPStartPX.clear();
60  _MCPStartPY.clear();
61  _MCPStartPZ.clear();
62  _MCPProc.clear();
63  _MCPEndProc.clear();
64  _MCPEndX.clear();
65  _MCPEndY.clear();
66  _MCPEndZ.clear();
67  _TrajMCPX.clear();
68  _TrajMCPY.clear();
69  _TrajMCPZ.clear();
70  _TrajMCPTrajIndex.clear();
71 }
std::vector< std::string > _MCPProc
Definition: MCP_Skimmer.h:96
std::vector< float > _MCPStartX
Definition: MCP_Skimmer.h:90
std::vector< float > _MCPEndZ
Definition: MCP_Skimmer.h:100
std::vector< int > _GT_T
Definition: MCP_Skimmer.h:81
std::vector< float > _MCPStartZ
Definition: MCP_Skimmer.h:92
std::vector< int > _Gint
Definition: MCP_Skimmer.h:79
std::vector< float > _Weight
Definition: MCP_Skimmer.h:83
std::vector< float > _MCPStartPZ
Definition: MCP_Skimmer.h:95
std::vector< float > _MCNuPy
Definition: MCP_Skimmer.h:74
std::vector< float > _TrajMCPY
Definition: MCP_Skimmer.h:102
std::vector< int > _MCPTrkID
Definition: MCP_Skimmer.h:88
std::vector< float > _MCPTime
Definition: MCP_Skimmer.h:89
std::vector< float > _MCPStartY
Definition: MCP_Skimmer.h:91
std::vector< float > _MCVertY
Definition: MCP_Skimmer.h:71
std::vector< float > _TrajMCPX
Definition: MCP_Skimmer.h:101
std::vector< int > _TrajMCPTrajIndex
Definition: MCP_Skimmer.h:104
std::vector< float > _TrajMCPZ
Definition: MCP_Skimmer.h:103
std::vector< float > _MCPEndX
Definition: MCP_Skimmer.h:98
std::vector< float > _MC_Y
Definition: MCP_Skimmer.h:66
std::vector< float > _MCPEndY
Definition: MCP_Skimmer.h:99
std::vector< int > _Mode
Definition: MCP_Skimmer.h:78
std::vector< float > _MC_T
Definition: MCP_Skimmer.h:69
std::vector< float > _MCPStartPX
Definition: MCP_Skimmer.h:93
std::vector< int > _InterT
Definition: MCP_Skimmer.h:82
std::vector< std::string > _MCPEndProc
Definition: MCP_Skimmer.h:97
std::vector< int > _NType
Definition: MCP_Skimmer.h:76
std::vector< float > _MC_W
Definition: MCP_Skimmer.h:65
std::vector< int > _TgtPDG
Definition: MCP_Skimmer.h:80
std::vector< float > _MCVertX
Definition: MCP_Skimmer.h:70
std::vector< int > _PDG
Definition: MCP_Skimmer.h:85
std::vector< int > _Mother
Definition: MCP_Skimmer.h:86
std::vector< float > _MC_X
Definition: MCP_Skimmer.h:67
std::vector< float > _MC_Theta
Definition: MCP_Skimmer.h:68
std::vector< float > _MCNuPz
Definition: MCP_Skimmer.h:75
std::vector< int > _PDGMother
Definition: MCP_Skimmer.h:87
std::vector< float > _MC_Q2
Definition: MCP_Skimmer.h:64
std::vector< float > _MCVertZ
Definition: MCP_Skimmer.h:72
std::vector< float > _MCNuPx
Definition: MCP_Skimmer.h:73
std::vector< float > _MCPStartPY
Definition: MCP_Skimmer.h:94
std::vector< int > _CCNC
Definition: MCP_Skimmer.h:77
void MCP_Skimmer::CloseTFile ( )

Definition at line 500 of file MCP_Skimmer.cpp.

501 {
502  if(_skimfile != nullptr) {
503  _skimfile->Close();
504  return;
505  }
506  else{ return; }
507 }
TFile * _skimfile
Definition: MCP_Skimmer.h:52
void MCP_Skimmer::FillTTree ( )

Definition at line 490 of file MCP_Skimmer.cpp.

491 {
492  if(_skimtree != nullptr) {
493  _skimfile->cd("anatree");
494  _skimtree->Fill();
495  }
496 
497  return;
498 }
TTree * _skimtree
Definition: MCP_Skimmer.h:53
TFile * _skimfile
Definition: MCP_Skimmer.h:52
void MCP_Skimmer::SetDebug ( bool  debug)
inline

Definition at line 46 of file MCP_Skimmer.h.

void MCP_Skimmer::SkimMCParticle ( )

Definition at line 73 of file MCP_Skimmer.cpp.

74 {
75  int Event = 0;
76  int SubRun = 0;
77  int Run = 0;
78 
79  std::vector<float> *MC_Q2 = 0;
80  std::vector<float> *MC_W = 0;
81  std::vector<float> *MC_Y = 0;
82  std::vector<float> *MC_X = 0;
83  std::vector<float> *MC_Theta = 0;
84  std::vector<float> *MC_T = 0;
85  std::vector<float> *MCVertX = 0;
86  std::vector<float> *MCVertY = 0;
87  std::vector<float> *MCVertZ = 0;
88  std::vector<float> *MCNuPx = 0;
89  std::vector<float> *MCNuPy = 0;
90  std::vector<float> *MCNuPz = 0;
91  std::vector<int> *NType = 0;
92  std::vector<int> *CCNC = 0;
93  std::vector<int> *Mode = 0;
94  std::vector<int> *Gint=0;
95  std::vector<int> *TgtPDG=0;
96  std::vector<int> *GT_T=0;
97  std::vector<int> *InterT=0;
98  std::vector<float> *Weight=0;
99 
100  std::vector<int> *PDG = 0;
101  std::vector<int> *Mother=0;
102  std::vector<int> *PDGMother=0;
103  std::vector<int> *MCPTrkID = 0;
104  std::vector<float> *MCPTime = 0;
105  std::vector<float> *MCPStartX = 0;
106  std::vector<float> *MCPStartY = 0;
107  std::vector<float> *MCPStartZ = 0;
108  std::vector<float> *MCPStartPX = 0;
109  std::vector<float> *MCPStartPY = 0;
110  std::vector<float> *MCPStartPZ = 0;
111  std::vector<std::string> *MCPProc = 0;
112  std::vector<std::string> *MCPEndProc = 0;
113  std::vector<float> *MCPEndX = 0;
114  std::vector<float> *MCPEndY = 0;
115  std::vector<float> *MCPEndZ = 0;
116  std::vector<float> *TrajMCPX = 0;
117  std::vector<float> *TrajMCPY = 0;
118  std::vector<float> *TrajMCPZ = 0;
119  std::vector<int> *TrajMCPTrajIndex = 0;
120 
121  _inttree->SetBranchStatus("*", 0);
122  _inttree->SetBranchStatus("Event", 1);
123  _inttree->SetBranchStatus("SubRun", 1);
124  _inttree->SetBranchStatus("Run", 1);
125 
126  _inttree->SetBranchStatus("NType", 1);
127  _inttree->SetBranchStatus("CCNC", 1);
128  _inttree->SetBranchStatus("MC_Q2", 1);
129  _inttree->SetBranchStatus("MC_W", 1);
130  _inttree->SetBranchStatus("MC_Y", 1);
131  _inttree->SetBranchStatus("MC_X", 1);
132  _inttree->SetBranchStatus("MC_Theta", 1);
133  _inttree->SetBranchStatus("MC_T", 1);
134  _inttree->SetBranchStatus("Mode", 1);
135  _inttree->SetBranchStatus("Gint", 1);
136  _inttree->SetBranchStatus("TgtPDG", 1);
137  _inttree->SetBranchStatus("GT_T", 1);
138  _inttree->SetBranchStatus("MCVertX", 1);
139  _inttree->SetBranchStatus("MCVertY", 1);
140  _inttree->SetBranchStatus("MCVertZ", 1);
141  _inttree->SetBranchStatus("MCNuPx", 1);
142  _inttree->SetBranchStatus("MCNuPy", 1);
143  _inttree->SetBranchStatus("MCNuPz", 1);
144  _inttree->SetBranchStatus("InterT", 1);
145  _inttree->SetBranchStatus("Weight", 1);
146 
147  //MC info
148  _inttree->SetBranchStatus("PDG", 1);
149  _inttree->SetBranchStatus("MCPTrkID", 1);
150  _inttree->SetBranchStatus("MCPTime", 1);
151  _inttree->SetBranchStatus("MCPStartX", 1);
152  _inttree->SetBranchStatus("MCPStartY", 1);
153  _inttree->SetBranchStatus("MCPStartZ", 1);
154  _inttree->SetBranchStatus("MCPEndX", 1);
155  _inttree->SetBranchStatus("MCPEndY", 1);
156  _inttree->SetBranchStatus("MCPEndZ", 1);
157  _inttree->SetBranchStatus("Mother", 1);
158  _inttree->SetBranchStatus("PDGMother", 1);
159  _inttree->SetBranchStatus("MCPStartPX", 1);
160  _inttree->SetBranchStatus("MCPStartPY", 1);
161  _inttree->SetBranchStatus("MCPStartPZ", 1);
162  _inttree->SetBranchStatus("MCPProc", 1);
163  _inttree->SetBranchStatus("MCPEndProc", 1);
164  _inttree->SetBranchStatus("TrajMCPX", 1);
165  _inttree->SetBranchStatus("TrajMCPY", 1);
166  _inttree->SetBranchStatus("TrajMCPZ", 1);
167  _inttree->SetBranchStatus("TrajMCPTrajIndex", 1);
168 
169  //-------------------
170 
171  _inttree->SetBranchAddress("Event", &Event);
172  _inttree->SetBranchAddress("SubRun", &SubRun);
173  _inttree->SetBranchAddress("Run", &Run);
174 
175  //Generator info
176  _inttree->SetBranchAddress("NType", &NType);
177  _inttree->SetBranchAddress("CCNC", &CCNC);
178  _inttree->SetBranchAddress("MC_Q2", &MC_Q2);
179  _inttree->SetBranchAddress("MC_W", &MC_W);
180  _inttree->SetBranchAddress("MC_Y", &MC_Y);
181  _inttree->SetBranchAddress("MC_X", &MC_X);
182  _inttree->SetBranchAddress("MC_Theta", &MC_Theta);
183  _inttree->SetBranchAddress("MC_T", &MC_T);
184  _inttree->SetBranchAddress("Mode", &Mode);
185  _inttree->SetBranchAddress("Gint", &Gint);
186  _inttree->SetBranchAddress("TgtPDG", &TgtPDG);
187  _inttree->SetBranchAddress("GT_T", &GT_T);
188  _inttree->SetBranchAddress("MCVertX", &MCVertX);
189  _inttree->SetBranchAddress("MCVertY", &MCVertY);
190  _inttree->SetBranchAddress("MCVertZ", &MCVertZ);
191  _inttree->SetBranchAddress("MCNuPx", &MCNuPx);
192  _inttree->SetBranchAddress("MCNuPy", &MCNuPy);
193  _inttree->SetBranchAddress("MCNuPz", &MCNuPz);
194  _inttree->SetBranchAddress("InterT", &InterT);
195  _inttree->SetBranchAddress("Weight", &Weight);
196 
197  //MC info
198  _inttree->SetBranchAddress("PDG", &PDG);
199  _inttree->SetBranchAddress("MCPTrkID", &MCPTrkID);
200  _inttree->SetBranchAddress("MCPTime", &MCPTime);
201  _inttree->SetBranchAddress("MCPStartX", &MCPStartX);
202  _inttree->SetBranchAddress("MCPStartY", &MCPStartY);
203  _inttree->SetBranchAddress("MCPStartZ", &MCPStartZ);
204  _inttree->SetBranchAddress("MCPEndX", &MCPEndX);
205  _inttree->SetBranchAddress("MCPEndY", &MCPEndY);
206  _inttree->SetBranchAddress("MCPEndZ", &MCPEndZ);
207  _inttree->SetBranchAddress("Mother", &Mother);
208  _inttree->SetBranchAddress("PDGMother", &PDGMother);
209  _inttree->SetBranchAddress("MCPStartPX", &MCPStartPX);
210  _inttree->SetBranchAddress("MCPStartPY", &MCPStartPY);
211  _inttree->SetBranchAddress("MCPStartPZ", &MCPStartPZ);
212  _inttree->SetBranchAddress("MCPProc", &MCPProc);
213  _inttree->SetBranchAddress("MCPEndProc", &MCPEndProc);
214  _inttree->SetBranchAddress("TrajMCPX", &TrajMCPX);
215  _inttree->SetBranchAddress("TrajMCPY", &TrajMCPY);
216  _inttree->SetBranchAddress("TrajMCPZ", &TrajMCPZ);
217  _inttree->SetBranchAddress("TrajMCPTrajIndex", &TrajMCPTrajIndex);
218 
219  // Main event loop
220  for( int entry = 0; entry < _inttree->GetEntries(); entry++ )
221  {
222  _inttree->GetEntry(entry);
223 
224  this->ClearVectors();
225 
226  if(Event%100 == 0)
227  std::cout << "Treating Evt " << Event << std::endl;
228 
229  _Event = Event;
230  _Run = Run;
231  _SubRun = SubRun;
232 
233  for(size_t i = 0; i < NType->size(); i++)
234  {
235  _CCNC.push_back(CCNC->at(i));
236  _NType.push_back(NType->at(i));
237  _MC_Q2.push_back(MC_Q2->at(i));
238  _MC_W.push_back(MC_W->at(i));
239  _MC_Y.push_back(MC_Y->at(i));
240  _MC_X.push_back(MC_X->at(i));
241  _MC_Theta.push_back(MC_Theta->at(i));
242  _Mode.push_back(Mode->at(i));
243  _MC_T.push_back(MC_T->at(i));
244  _InterT.push_back(InterT->at(i));
245  _MCVertX.push_back(MCVertX->at(i));
246  _MCVertY.push_back(MCVertY->at(i));
247  _MCVertZ.push_back(MCVertZ->at(i));
248  _MCNuPx.push_back(MCNuPx->at(i));
249  _MCNuPy.push_back(MCNuPy->at(i));
250  _MCNuPz.push_back(MCNuPz->at(i));
251  }
252 
253  for(size_t i = 0; i < Gint->size(); i++)
254  {
255  _Gint.push_back(Gint->at(i));
256  _TgtPDG.push_back(TgtPDG->at(i));
257  _GT_T.push_back(GT_T->at(i));
258  _Weight.push_back(Weight->at(i));
259  }
260 
261  std::map<int, int> mcp_kid_mother_map;
262 
263  for(size_t i = 0; i < MCPStartPX->size(); i++ )
264  {
265  //check if daughter has mother until we find the original mother
266  //get current kid trk id
267  int this_kid_trkid = MCPTrkID->at(i);
268  int this_kid_mother = Mother->at(i);
269  //Mother->at(i) returns the mother trkid
270 
271  //Has no mother -> primaries
272  if(this_kid_mother == 0) {
273  // std::cout << "Kid " << this_kid_trkid << " Mother " << this_kid_mother << std::endl;
274  continue;
275  }
276 
277  //loop over the mcp again and go back in history need to check Mother->at(j) until it is 0 then we found the original mcp
278  for(size_t j = 0; j < MCPStartPX->size(); j++ )
279  {
280  int mother_trk_id = MCPTrkID->at(j);
281  int mother = Mother->at(j);
282 
283  //found the mother
284  if(mother_trk_id == this_kid_mother)
285  {
286  //need to check if it has mother if yes loop until mother is 0
287  if(mother == 0)
288  {
289  //found the original particle
290  // std::cout << "Kid " << this_kid_trkid << " Mother " << this_kid_mother << std::endl;
291  //fill a map linking kid track id to mother track id to know which ones to skip and replace their mother by the original one
292  mcp_kid_mother_map[this_kid_trkid] = this_kid_mother;
293  break;
294  }
295  else
296  {
297  this_kid_mother = mother;
298  j = 0;
299  }
300  }
301  }
302  }
303 
304  //Vector of indexes to keep
305  std::vector<int> IndexesToKeep;
306 
307  //Check which indexes to keep
308  for(size_t i = 0; i < MCPStartPX->size(); i++)
309  {
310  TVector3 spoint(MCPStartX->at(i), MCPStartY->at(i), MCPStartZ->at(i));//start point
311  TVector3 epoint(MCPEndX->at(i), MCPEndY->at(i), MCPEndZ->at(i));//end point
312  std::string process = MCPProc->at(i);
313  std::string endprocess = MCPEndProc->at(i);
314 
315  //found a particle that has already an ancestor
316  if( mcp_kid_mother_map.find(MCPTrkID->at(i)) != mcp_kid_mother_map.end() )
317  {
318  // However keep the daughters for specific ones
319  // - D0s and V0s (kinks and decays) such as gamma, pi0, K0, muon, pion and kaon
320  // - backscatters from calo to tracker important for background
321  // - breamstrahlung photons / delta rays
322 
323  //keep D0s and V0s from decays, conversions (a lot of compton or Ioni)
324  if( std::find(daughtersToKeep.begin(), daughtersToKeep.end(), PDGMother->at(i)) != daughtersToKeep.end() && _util->PointInTPC(spoint) && (process == "Decay" || process == "conv") ) {
325  if(_debug){
326  std::cout << "Keeping D0 or V0" << std::endl;
327  std::cout << "Index " << i << " TrkID " << MCPTrkID->at(i) << " pdg " << PDG->at(i) << " mother pdg " << PDGMother->at(i);
328  std::cout << " process " << process << " endprocess " << endprocess << std::endl;
329  std::cout << " Start point X: " << spoint.X() << " Y: " << spoint.Y() << " Z: " << spoint.Z() << std::endl;
330  std::cout << " End point X: " << epoint.X() << " Y: " << epoint.Y() << " Z: " << epoint.Z() << std::endl;
331  std::cout << " Origin in tracker " << _util->PointInTPC(spoint) << std::endl;
332  std::cout << " Decayed in Calo " << _util->hasDecayedInCalo(epoint) << std::endl;
333  }
334  IndexesToKeep.push_back(i);
335  }
336  //check for backscatter
337  else if( _util->isBackscatter(spoint, epoint) ) {
338  if(_debug){
339  std::cout << "Keeping Backscatter" << std::endl;
340  std::cout << "Index " << i << " TrkID " << MCPTrkID->at(i) << " pdg " << PDG->at(i) << " mother pdg " << PDGMother->at(i);
341  std::cout << " process " << process << " endprocess " << endprocess << std::endl;
342  std::cout << " Start point X: " << spoint.X() << " Y: " << spoint.Y() << " Z: " << spoint.Z() << std::endl;
343  std::cout << " End point X: " << epoint.X() << " Y: " << epoint.Y() << " Z: " << epoint.Z() << std::endl;
344  std::cout << " Origin in tracker " << _util->PointInTPC(spoint) << std::endl;
345  std::cout << " Decayed in Calo " << _util->hasDecayedInCalo(epoint) << std::endl;
346  }
347  IndexesToKeep.push_back(i);
348  }
349  //if Bremsstrahlung photon
350  else if ( _util->isBremsstrahlung(spoint, PDG->at(i), PDGMother->at(i)) && process == "eBrem" ) {
351  if(_debug){
352  std::cout << "Keeping Bremsstrahlung" << std::endl;
353  std::cout << "Index " << i << " TrkID " << MCPTrkID->at(i) << " pdg " << PDG->at(i) << " mother pdg " << PDGMother->at(i);
354  std::cout << " process " << process << " endprocess " << endprocess << std::endl;
355  std::cout << " Start point X: " << spoint.X() << " Y: " << spoint.Y() << " Z: " << spoint.Z() << std::endl;
356  std::cout << " End point X: " << epoint.X() << " Y: " << epoint.Y() << " Z: " << epoint.Z() << std::endl;
357  std::cout << " Origin in tracker " << _util->PointInTPC(spoint) << std::endl;
358  std::cout << " Decayed in Calo " << _util->hasDecayedInCalo(epoint) << std::endl;
359  }
360  IndexesToKeep.push_back(i);
361  }
362  else {
363  continue;
364  }
365  }
366 
367  //keep only primaries whatever they are from (inside TPC or outside)
368  if(MCPProc->at(i) == "primary"){
369  if(_debug){
370  std::cout << "Keeping Primary particle" << std::endl;
371  std::cout << "Index " << i << " TrkID " << MCPTrkID->at(i) << " pdg " << PDG->at(i) << " mother pdg " << PDGMother->at(i);
372  std::cout << " process " << process << " endprocess " << endprocess << std::endl;
373  std::cout << " Start point X: " << spoint.X() << " Y: " << spoint.Y() << " Z: " << spoint.Z() << std::endl;
374  std::cout << " End point X: " << epoint.X() << " Y: " << epoint.Y() << " Z: " << epoint.Z() << std::endl;
375  std::cout << " Origin in tracker " << _util->PointInTPC(spoint) << std::endl;
376  std::cout << " Decayed in Calo " << _util->hasDecayedInCalo(epoint) << std::endl;
377  }
378  IndexesToKeep.push_back(i);
379  }
380  }
381 
382 
383  for(size_t i = 0; i < IndexesToKeep.size(); i++)
384  {
385  _PDG.push_back(PDG->at(i));
386  _MCPStartPX.push_back(MCPStartPX->at(i));
387  _MCPStartPY.push_back(MCPStartPY->at(i));
388  _MCPStartPZ.push_back(MCPStartPZ->at(i));
389  _MCPTrkID.push_back(MCPTrkID->at(i));
390  _MCPTime.push_back(MCPTime->at(i));
391  _MCPStartX.push_back(MCPStartX->at(i));
392  _MCPStartY.push_back(MCPStartY->at(i));
393  _MCPStartZ.push_back(MCPStartZ->at(i));
394  _MCPEndX.push_back(MCPEndX->at(i));
395  _MCPEndY.push_back(MCPEndY->at(i));
396  _MCPEndZ.push_back(MCPEndZ->at(i));
397  _MCPProc.push_back(MCPProc->at(i));
398  _MCPEndProc.push_back(MCPEndProc->at(i));
399  _Mother.push_back(Mother->at(i));
400  _PDGMother.push_back(PDGMother->at(i));
401 
402  for(size_t itraj = 0; itraj < TrajMCPX->size(); itraj++){
403  //keep only traj from kept mcp
404  if(TrajMCPTrajIndex->at(itraj) == (int) i){
405  _TrajMCPX.push_back(TrajMCPX->at(itraj));
406  _TrajMCPY.push_back(TrajMCPY->at(itraj));
407  _TrajMCPZ.push_back(TrajMCPZ->at(itraj));
408  _TrajMCPTrajIndex.push_back(TrajMCPTrajIndex->at(itraj));
409  }
410  }
411  }
412 
413  this->FillTTree();
414  }//end tree loop
415 }
bool isBremsstrahlung(const TVector3 &spoint, const int &pdg, const int &motherpdg)
Definition: Utils.cpp:130
std::vector< std::string > _MCPProc
Definition: MCP_Skimmer.h:96
std::vector< float > _MCPStartX
Definition: MCP_Skimmer.h:90
std::vector< float > _MCPEndZ
Definition: MCP_Skimmer.h:100
QList< Entry > entry
std::vector< int > _GT_T
Definition: MCP_Skimmer.h:81
std::vector< float > _MCPStartZ
Definition: MCP_Skimmer.h:92
std::vector< int > _Gint
Definition: MCP_Skimmer.h:79
void ClearVectors()
Definition: MCP_Skimmer.cpp:28
TTree * _inttree
Definition: MCP_Skimmer.h:54
std::vector< float > _Weight
Definition: MCP_Skimmer.h:83
std::string string
Definition: nybbler.cc:12
std::vector< float > _MCPStartPZ
Definition: MCP_Skimmer.h:95
void FillTTree()
std::vector< float > _MCNuPy
Definition: MCP_Skimmer.h:74
std::vector< float > _TrajMCPY
Definition: MCP_Skimmer.h:102
std::vector< int > _MCPTrkID
Definition: MCP_Skimmer.h:88
std::vector< float > _MCPTime
Definition: MCP_Skimmer.h:89
std::vector< float > _MCPStartY
Definition: MCP_Skimmer.h:91
bool hasDecayedInCalo(const TVector3 &point)
Definition: Utils.cpp:91
const uint PDG
Definition: qregexp.cpp:140
std::vector< float > _MCVertY
Definition: MCP_Skimmer.h:71
std::vector< float > _TrajMCPX
Definition: MCP_Skimmer.h:101
def process(f, kind)
Definition: search.py:254
std::vector< int > _TrajMCPTrajIndex
Definition: MCP_Skimmer.h:104
std::vector< float > _TrajMCPZ
Definition: MCP_Skimmer.h:103
std::vector< float > _MCPEndX
Definition: MCP_Skimmer.h:98
std::vector< float > _MC_Y
Definition: MCP_Skimmer.h:66
std::vector< float > _MCPEndY
Definition: MCP_Skimmer.h:99
bool PointInTPC(const TVector3 &point)
Definition: Utils.cpp:43
std::vector< int > _Mode
Definition: MCP_Skimmer.h:78
std::vector< int > daughtersToKeep
Definition: MCP_Skimmer.h:107
std::vector< float > _MC_T
Definition: MCP_Skimmer.h:69
std::vector< float > _MCPStartPX
Definition: MCP_Skimmer.h:93
std::vector< int > _InterT
Definition: MCP_Skimmer.h:82
std::vector< std::string > _MCPEndProc
Definition: MCP_Skimmer.h:97
bool isBackscatter(const TVector3 &spoint, const TVector3 &epoint)
Definition: Utils.cpp:114
std::vector< int > _NType
Definition: MCP_Skimmer.h:76
std::vector< float > _MC_W
Definition: MCP_Skimmer.h:65
std::vector< int > _TgtPDG
Definition: MCP_Skimmer.h:80
std::vector< float > _MCVertX
Definition: MCP_Skimmer.h:70
Definition: types.h:32
Utils * _util
Definition: MCP_Skimmer.h:56
std::vector< int > _PDG
Definition: MCP_Skimmer.h:85
std::vector< int > _Mother
Definition: MCP_Skimmer.h:86
std::vector< float > _MC_X
Definition: MCP_Skimmer.h:67
std::vector< float > _MC_Theta
Definition: MCP_Skimmer.h:68
std::vector< float > _MCNuPz
Definition: MCP_Skimmer.h:75
std::vector< int > _PDGMother
Definition: MCP_Skimmer.h:87
std::vector< float > _MC_Q2
Definition: MCP_Skimmer.h:64
std::vector< float > _MCVertZ
Definition: MCP_Skimmer.h:72
std::vector< float > _MCNuPx
Definition: MCP_Skimmer.h:73
std::vector< float > _MCPStartPY
Definition: MCP_Skimmer.h:94
QTextStream & endl(QTextStream &s)
std::vector< int > _CCNC
Definition: MCP_Skimmer.h:77
void MCP_Skimmer::WriteTTree ( )

Definition at line 509 of file MCP_Skimmer.cpp.

510 {
511  if(_skimtree != nullptr) {
512  _skimfile->cd("anatree");
513  _skimtree->Write();
514  _skimfile->Close();
515  }
516 
517  return;
518 }
TTree * _skimtree
Definition: MCP_Skimmer.h:53
TFile * _skimfile
Definition: MCP_Skimmer.h:52

Member Data Documentation

std::vector<int> MCP_Skimmer::_CCNC
private

Definition at line 77 of file MCP_Skimmer.h.

bool MCP_Skimmer::_debug
private

Definition at line 55 of file MCP_Skimmer.h.

int MCP_Skimmer::_Event
private

Definition at line 60 of file MCP_Skimmer.h.

std::vector<int> MCP_Skimmer::_Gint
private

Definition at line 79 of file MCP_Skimmer.h.

std::vector<int> MCP_Skimmer::_GT_T
private

Definition at line 81 of file MCP_Skimmer.h.

std::string MCP_Skimmer::_infile
private

Definition at line 57 of file MCP_Skimmer.h.

std::vector<int> MCP_Skimmer::_InterT
private

Definition at line 82 of file MCP_Skimmer.h.

TFile* MCP_Skimmer::_intfile
private

Definition at line 51 of file MCP_Skimmer.h.

TTree* MCP_Skimmer::_inttree
private

Definition at line 54 of file MCP_Skimmer.h.

std::vector<float> MCP_Skimmer::_MC_Q2
private

Definition at line 64 of file MCP_Skimmer.h.

std::vector<float> MCP_Skimmer::_MC_T
private

Definition at line 69 of file MCP_Skimmer.h.

std::vector<float> MCP_Skimmer::_MC_Theta
private

Definition at line 68 of file MCP_Skimmer.h.

std::vector<float> MCP_Skimmer::_MC_W
private

Definition at line 65 of file MCP_Skimmer.h.

std::vector<float> MCP_Skimmer::_MC_X
private

Definition at line 67 of file MCP_Skimmer.h.

std::vector<float> MCP_Skimmer::_MC_Y
private

Definition at line 66 of file MCP_Skimmer.h.

std::vector<float> MCP_Skimmer::_MCNuPx
private

Definition at line 73 of file MCP_Skimmer.h.

std::vector<float> MCP_Skimmer::_MCNuPy
private

Definition at line 74 of file MCP_Skimmer.h.

std::vector<float> MCP_Skimmer::_MCNuPz
private

Definition at line 75 of file MCP_Skimmer.h.

std::vector<std::string> MCP_Skimmer::_MCPEndProc
private

Definition at line 97 of file MCP_Skimmer.h.

std::vector<float> MCP_Skimmer::_MCPEndX
private

Definition at line 98 of file MCP_Skimmer.h.

std::vector<float> MCP_Skimmer::_MCPEndY
private

Definition at line 99 of file MCP_Skimmer.h.

std::vector<float> MCP_Skimmer::_MCPEndZ
private

Definition at line 100 of file MCP_Skimmer.h.

std::vector<std::string> MCP_Skimmer::_MCPProc
private

Definition at line 96 of file MCP_Skimmer.h.

std::vector<float> MCP_Skimmer::_MCPStartPX
private

Definition at line 93 of file MCP_Skimmer.h.

std::vector<float> MCP_Skimmer::_MCPStartPY
private

Definition at line 94 of file MCP_Skimmer.h.

std::vector<float> MCP_Skimmer::_MCPStartPZ
private

Definition at line 95 of file MCP_Skimmer.h.

std::vector<float> MCP_Skimmer::_MCPStartX
private

Definition at line 90 of file MCP_Skimmer.h.

std::vector<float> MCP_Skimmer::_MCPStartY
private

Definition at line 91 of file MCP_Skimmer.h.

std::vector<float> MCP_Skimmer::_MCPStartZ
private

Definition at line 92 of file MCP_Skimmer.h.

std::vector<float> MCP_Skimmer::_MCPTime
private

Definition at line 89 of file MCP_Skimmer.h.

std::vector<int> MCP_Skimmer::_MCPTrkID
private

Definition at line 88 of file MCP_Skimmer.h.

std::vector<float> MCP_Skimmer::_MCVertX
private

Definition at line 70 of file MCP_Skimmer.h.

std::vector<float> MCP_Skimmer::_MCVertY
private

Definition at line 71 of file MCP_Skimmer.h.

std::vector<float> MCP_Skimmer::_MCVertZ
private

Definition at line 72 of file MCP_Skimmer.h.

std::vector<int> MCP_Skimmer::_Mode
private

Definition at line 78 of file MCP_Skimmer.h.

std::vector<int> MCP_Skimmer::_Mother
private

Definition at line 86 of file MCP_Skimmer.h.

std::vector<int> MCP_Skimmer::_NType
private

Definition at line 76 of file MCP_Skimmer.h.

std::string MCP_Skimmer::_outfile
private

Definition at line 58 of file MCP_Skimmer.h.

std::vector<int> MCP_Skimmer::_PDG
private

Definition at line 85 of file MCP_Skimmer.h.

std::vector<int> MCP_Skimmer::_PDGMother
private

Definition at line 87 of file MCP_Skimmer.h.

int MCP_Skimmer::_Run
private

Definition at line 62 of file MCP_Skimmer.h.

TFile* MCP_Skimmer::_skimfile
private

Definition at line 52 of file MCP_Skimmer.h.

TTree* MCP_Skimmer::_skimtree
private

Definition at line 53 of file MCP_Skimmer.h.

int MCP_Skimmer::_SubRun
private

Definition at line 61 of file MCP_Skimmer.h.

std::vector<int> MCP_Skimmer::_TgtPDG
private

Definition at line 80 of file MCP_Skimmer.h.

std::vector<int> MCP_Skimmer::_TrajMCPTrajIndex
private

Definition at line 104 of file MCP_Skimmer.h.

std::vector<float> MCP_Skimmer::_TrajMCPX
private

Definition at line 101 of file MCP_Skimmer.h.

std::vector<float> MCP_Skimmer::_TrajMCPY
private

Definition at line 102 of file MCP_Skimmer.h.

std::vector<float> MCP_Skimmer::_TrajMCPZ
private

Definition at line 103 of file MCP_Skimmer.h.

Utils* MCP_Skimmer::_util
private

Definition at line 56 of file MCP_Skimmer.h.

std::vector<float> MCP_Skimmer::_Weight
private

Definition at line 83 of file MCP_Skimmer.h.

std::vector<int> MCP_Skimmer::daughtersToKeep = {22, 111, 310, 13, 211, 321}
private

Definition at line 107 of file MCP_Skimmer.h.


The documentation for this class was generated from the following files: