13 StructuredRecoTree::StructuredRecoTree(TTree*
tree) {
17 bool StructuredRecoTree::SetBranchAddresses() {
19 cout <<
"setting StructuredRecoTree branch addresses" <<
endl;
21 fTreeIn->SetBranchAddress(
"Event", &fEvent, &b_Event );
22 cout <<
"set Event" <<
endl;
23 fTreeIn->SetBranchAddress(
"Tracks", &fTracks , &b_Tracks );
24 cout <<
"set Track" <<
endl;
25 fTreeIn->SetBranchAddress(
"Vees", &fVees , &b_Vees );
26 cout <<
"set Vees" <<
endl;
27 fTreeIn->SetBranchAddress(
"Vertices", &fVertices , &b_Vertices );
28 cout <<
"set Vertices" <<
endl;
29 fTreeIn->SetBranchAddress(
"CalClusters", &fCalClusters , &b_CalClusters );
30 cout <<
"set CalClusters" <<
endl;
31 fTreeIn->SetBranchAddress(
"TrackG4Indices", &fTrackG4PIndices , &b_TrackG4PIndices );
32 cout <<
"set TrackG4Indices" <<
endl;
33 fTreeIn->SetBranchAddress(
"VertTrackIndices", &fVertTrackIndices, &b_VertTrackIndices );
34 fTreeIn->SetBranchAddress(
"VertTrackEnds", &fVertTrackEnds , &b_VertTrackEnds );
35 fTreeIn->SetBranchAddress(
"VeeTrackIndices", &fVeeTrackIndices , &b_VeeTrackIndices );
36 fTreeIn->SetBranchAddress(
"VeeTrackEnds", &fVeeTrackEnds , &b_VeeTrackEnds );
37 fTreeIn->SetBranchAddress(
"CalTrackIndices", &fCalClusterTrackIndices , &b_CalClusterTrackIndices );
39 fTreeIn->SetBranchAddress(
"CalG4Indices", &fCalClusterG4Indices , &b_CalClusterG4Indices );
54 cout <<
"done." <<
endl;
60 const size_t StructuredRecoTree::NTrack()
const {
61 return fTracks->size();
63 const size_t StructuredRecoTree::NVertex()
const {
64 return fVertices->size();
66 const size_t StructuredRecoTree::NVee()
const {
69 const size_t StructuredRecoTree::NCalCluster()
const {
70 return fCalClusters->size();
74 const TLorentzVector* StructuredRecoTree::TrackVertex(
const size_t& itrack)
const {
75 return &(fTracks->at(itrack).fVtx);
79 return &(fTracks->at(itrack).fEnd);
81 const size_t StructuredRecoTree::NTrackHit(
const size_t& itrack)
const {
82 return fTracks->at(itrack).fNHits;
84 const TVector3* StructuredRecoTree::TrackMomBeg(
const size_t& itrack)
const {
85 TVector3* v =
new TVector3(fTracks->at(itrack).fVtxDir);
86 (*v) *= fTracks->at(itrack).fMomBeg;
90 const TVector3* StructuredRecoTree::TrackMomEnd(
const size_t& itrack)
const {
91 TVector3* v =
new TVector3(fTracks->at(itrack).fEndDir);
92 (*v) *= fTracks->at(itrack).fMomEnd;
96 const float StructuredRecoTree::TrackVtxDirectionX(
const size_t& itrack)
const {
97 return fTracks->at(itrack).fVtxDir.X();
100 const float StructuredRecoTree::TrackVtxDirectionY(
const size_t& itrack)
const {
101 return fTracks->at(itrack).fVtxDir.Y();
104 const float StructuredRecoTree::TrackVtxDirectionZ(
const size_t& itrack)
const {
105 return fTracks->at(itrack).fVtxDir.Z();
108 const float StructuredRecoTree::TrackEndDirectionX(
const size_t& itrack)
const {
109 return fTracks->at(itrack).fEndDir.X();
112 const float StructuredRecoTree::TrackEndDirectionY(
const size_t& itrack)
const {
113 return fTracks->at(itrack).fEndDir.Y();
116 const float StructuredRecoTree::TrackEndDirectionZ(
const size_t& itrack)
const {
117 return fTracks->at(itrack).fEndDir.Z();
120 const float StructuredRecoTree::TrackLenFwd(
const size_t& itrack)
const {
121 return fTracks->at(itrack).fLenFwd;
124 const float StructuredRecoTree::TrackLenBkd(
const size_t& itrack)
const {
125 return fTracks->at(itrack).fLenBac;
128 const float StructuredRecoTree::TrackIonizFwd(
const size_t& itrack)
const {
129 return fTracks->at(itrack).fIonFwd;
132 const float StructuredRecoTree::TrackIonizBkd(
const size_t& itrack)
const {
133 return fTracks->at(itrack).fLenBac;
136 const int StructuredRecoTree::TrackChiSqrFwd(
const size_t& itrack)
const {
137 return fTracks->at(itrack).fChiFwd;
140 const int StructuredRecoTree::TrackChiSqrBkd(
const size_t& itrack)
const {
141 return fTracks->at(itrack).fChiBac;
144 const int StructuredRecoTree::TrackChgFwd(
const size_t& itrack)
const {
145 return fTracks->at(itrack).fChgFwd;
148 const int StructuredRecoTree::TrackChgBkd(
const size_t& itrack)
const {
149 return fTracks->at(itrack).fChgBac;
152 void StructuredRecoTree::TrackParBeg(
const size_t& itrack,
float pars[5])
const {
153 for(
size_t i=0; i<5; i++)
154 pars[i] = fTracks->at(itrack).fTrackParBeg[i];
157 void StructuredRecoTree::TrackParEnd(
const size_t& itrack,
float pars[5])
const {
158 for(
size_t i=0; i<5; i++)
159 pars[i] = fTracks->at(itrack).fTrackParEnd[i];
162 void StructuredRecoTree::TrackCovarBeg(
const size_t& itrack,
float covar[15])
const {
163 for(
size_t i=0; i<15; i++)
164 covar[i] = fTracks->at(itrack).fCovMatBeg[i];
167 void StructuredRecoTree::TrackCovarEnd(
const size_t& itrack,
float covar[15])
const {
168 for(
size_t i=0; i<15; i++)
169 covar[i] = fTracks->at(itrack).fCovMatEnd[i];
172 const TLorentzVector* StructuredRecoTree::TrackTruePosBeg(
const size_t& itrack)
const {
173 TLorentzVector outvec(0,0,0,0);
175 for(
size_t imctrk=0; imctrk<fTracks->at(itrack).fTruePosVtx.size(); imctrk++ ) {
176 TLorentzVector tmpvec = fTracks->at(itrack).fTruePosVtx[imctrk].second;
177 tmpvec *= fTracks->at(itrack).fTrueMomVtx[imctrk].second.P();
179 ptot += fTracks->at(itrack).fTrueMomVtx[imctrk].second.P();
183 return new TLorentzVector(outvec);
186 const TLorentzVector* StructuredRecoTree::TrackTruePosEnd(
const size_t& itrack)
const {
187 TLorentzVector outvec(0,0,0,0);
189 std::cout <<
"loop over -- " << fTracks->at(itrack).fTruePosEnd.size() <<
" -- true positions" <<
std::endl;
190 for(
size_t imctrk=0; imctrk<fTracks->at(itrack).fTruePosEnd.size(); imctrk++) {
191 TLorentzVector tmpvec = fTracks->at(itrack).fTruePosEnd[imctrk].second;
192 std::cout <<
" submomentum: " << fTracks->at(itrack).fTrueMomEnd[imctrk].second.P() <<
std::endl;
193 tmpvec *= fTracks->at(itrack).fTrueMomEnd[imctrk].second.P();
195 ptot += fTracks->at(itrack).fTrueMomEnd[imctrk].second.P();
199 return new TLorentzVector(outvec);
202 const TLorentzVector* StructuredRecoTree::TrackTrueMomBeg(
const size_t& itrack)
const {
203 TLorentzVector outvec(0,0,0,0);
205 for(
size_t imctrk=0; imctrk<fTracks->at(itrack).fTrueMomVtx.size(); imctrk++) {
206 TLorentzVector tmpvec = fTracks->at(itrack).fTrueMomVtx[imctrk].second;
207 tmpvec *= fTracks->at(itrack).fTrueMomVtx[imctrk].second.P();
209 ptot += fTracks->at(itrack).fTrueMomVtx[imctrk].second.P();
213 return new TLorentzVector(outvec);
216 const TLorentzVector* StructuredRecoTree::TrackTrueMomEnd(
const size_t& itrack)
const {
217 TLorentzVector outvec(0,0,0,0);
219 for(
size_t imctrk=0; imctrk<fTracks->at(itrack).fTrueMomEnd.size(); imctrk++) {
220 TLorentzVector tmpvec = fTracks->at(itrack).fTrueMomEnd[imctrk].second;
221 tmpvec *= fTracks->at(itrack).fTrueMomEnd[imctrk].second.P();
223 ptot += fTracks->at(itrack).fTrueMomEnd[imctrk].second.P();
227 return new TLorentzVector(outvec);
230 const float StructuredRecoTree::TrackTrueEnergy(
const size_t& itrack)
const {
232 for(
auto const&
e : fTracks->at(itrack).fTrueEnergy)
239 const size_t StructuredRecoTree::TrackNTrueTrack(
const size_t& itrack)
const {
240 return fTracks->at(itrack).fTrueEnergy.size();
243 const int StructuredRecoTree::TrackTrkIdMaxDeposit(
const size_t& itrack)
const {
256 auto it = std::max_element(fTracks->at(itrack).fTrueEnergy.begin(),fTracks->at(itrack).fTrueEnergy.end(),
257 [](
const std::pair<int,float>& lhs,
const std::pair<int,float>& rhs) ->
bool {
return lhs.second < rhs.second; }
259 if(it==fTracks->at(itrack).fTrueEnergy.end()) {
260 cout <<
"max element not found for itrack = " << itrack <<
"! (this is just a warning; is it all noise hits?)" <<
endl;
268 const float StructuredRecoTree::TrackMaxDeposit(
const size_t& itrack)
const {
270 auto it = std::max_element(fTracks->at(itrack).fTrueEnergy.begin(),fTracks->at(itrack).fTrueEnergy.end(),
271 [](
const std::pair<int,float>& lhs,
const std::pair<int,float>& rhs) ->
bool {
return lhs.second < rhs.second; }
273 if(it==fTracks->at(itrack).fTrueEnergy.end()) {
274 cout <<
"max element not found for itrack = " << itrack <<
"! (this is just a warning; is it all noise hits?)" <<
endl;
282 const pair<int,float>* StructuredRecoTree::TrackTrueDeposit(
const size_t& itrack,
size_t& itrue)
const {
284 return &(fTracks->at(itrack).fTrueEnergy.at(itrue));
288 const vector<pair<int,float>>* StructuredRecoTree::TrackTrueDeposits(
const size_t& itrack)
const {
290 return &(fTracks->at(itrack).fTrueEnergy);
294 const TLorentzVector* StructuredRecoTree::GetVertex(
const size_t& ivertex)
const {
295 return fVertices->at(ivertex).GetVertex();
298 void StructuredRecoTree::VertexCovariance(
const size_t& ivertex,
float covar[][3])
const {
299 fVertices->at(ivertex).GetCovar(covar);
304 const TLorentzVector* StructuredRecoTree::VeeVertex(
const size_t& ivee)
const {
305 return fVees->at(ivee).GetVertex();
308 void StructuredRecoTree::VeeCovariance(
const size_t& ivee,
float covar[][3])
const {
309 return fVees->at(ivee).GetCovar(covar);
312 const vector<TLorentzVector>* StructuredRecoTree::VeeMomentumPerHypothesis(
const size_t& ivee)
const {
313 return fVees->at(ivee).GetMomentaPerHypothesis();
316 const float StructuredRecoTree::VeeChiSquared(
const size_t& ivee)
const {
317 return fVees->at(ivee).GetChiSqr();
321 const CaloCluster* StructuredRecoTree::GetCalCluster(
const size_t& icluster)
const {
322 if(fCalClusters->size()==0)
325 return &(fCalClusters->at(icluster));
327 const TLorentzVector* StructuredRecoTree::CalClustPosition(
const size_t& icluster)
const {
328 return GetCalCluster(icluster)->
Position();
331 const float StructuredRecoTree::CalClustEnergy(
const size_t& icluster)
const {
332 return GetCalCluster(icluster)->Energy();
335 const float StructuredRecoTree::CalClustEnergyError(
const size_t& icluster)
const {
336 return GetCalCluster(icluster)->EnergyError();
339 const float StructuredRecoTree::CalClustTrueEnergy(
const size_t& icluster)
const{
340 return GetCalCluster(icluster)->TotalTrueEnergy();
342 const size_t StructuredRecoTree::CalClustNTrueTrack(
const size_t& icluster)
const{
343 return GetCalCluster(icluster)->NIdes();
345 const int StructuredRecoTree::CalClustTrkIdMaxDeposit(
const size_t& icluster)
const{
346 return GetCalCluster(icluster)->TrackIdMaxDep();
348 const float StructuredRecoTree::CalClustMaxDeposit(
const size_t& icluster)
const{
349 if(GetCalCluster(icluster))
350 return GetCalCluster(icluster)->MaxDeposit();
354 const std::pair<int,float>* StructuredRecoTree::CalClustTrueDeposit(
const size_t& icluster,
const size_t& itrack)
const {
355 return GetCalCluster(icluster)->GetTrackIdEdep(itrack);
357 const float StructuredRecoTree::CalClustTimeDifference(
const size_t& icluster)
const {
358 return fCalClusters->at(icluster).TimeDifference();
361 const float* StructuredRecoTree::CalClustShape(
const size_t& icluster)
const {
362 return fCalClusters->at(icluster).Shape();
365 const float StructuredRecoTree::CalClustTheta(
const size_t& icluster)
const {
366 return fCalClusters->at(icluster).Theta();
369 const float StructuredRecoTree::CalClustPhi(
const size_t& icluster)
const {
370 return fCalClusters->at(icluster).Phi();
373 const vector<TVector3>* StructuredRecoTree::CalClustEigenVecs(
const size_t& icluster)
const{
374 return fCalClusters->at(icluster).EigenVecs();
const TLorentzVector * Position() const
std::string to_string(ModuleType const mt)
QTextStream & endl(QTextStream &s)