2 #include "TGeomInfo.hxx"
3 #include "TPrincipal.h"
4 #include "TRealDatum.hxx"
5 #include "TReconHit.hxx"
6 #include "TShowerTruthInfo.hxx"
7 #include "TrackTruthInfo.hxx"
14 #include "../cvstags/TP0DECALReconModule.cxx"
17 if (Name.Contains(
"LS")) {
19 }
else if (Name.Contains(
"LT")) {
21 }
else if (Name.Contains(
"LB")) {
23 }
else if (Name.Contains(
"RS")) {
25 }
else if (Name.Contains(
"RT")) {
27 }
else if (Name.Contains(
"RB")) {
47 new TClonesArray(
"ND::TP0DECALReconModule::TP0DECALReconTrack", 200);
49 new TClonesArray(
"ND::TP0DECALReconModule::TP0DECALReconShower", 200);
51 new TClonesArray(
"ND::TP0DECALReconModule::TP0DECALLayerCharge", 200);
64 fOutputTree->Branch(
"NReconTracks", &fNReconTracks,
"NReconTracks/I",fBufferSize)
65 ->SetTitle(
"Number TP0DECALReconTrack Objects ");
66 fOutputTree->Branch(
"NReconShowers", &fNReconShowers,
"NReconShowers/I",fBufferSize)
67 ->SetTitle(
"Number of TP0DECALReconShower Objects ");
68 fOutputTree->Branch(
"NLayerCharge", &fNLayerCharge,
"NLayerCharge/I",fBufferSize)
69 ->SetTitle(
" Number of TP0DECALLayerCharge objects");
72 fOutputTree->Branch(
"ReconTracks", &fReconTracks, fBufferSize, fSplitLevel)
73 ->SetTitle(
" TP0DECALReconTrack Objects");
75 fOutputTree->Branch(
"ReconShowers", &fReconShowers, fBufferSize, fSplitLevel)
76 ->SetTitle(
"TP0DECALReconShower Objects ");
77 fOutputTree->Branch(
"LayerCharge", &fLayerCharge, fBufferSize, fSplitLevel)
78 ->SetTitle(
"TP0DECALLayerCharge Objects ");
82 bool isMC =
event.GetContext().IsMC();
87 fReconTracks->Clear();
89 fReconShowers->Clear();
91 fLayerCharge->Clear();
93 if (!event.GetFit(
"P0DECALPid")) {
98 ND::THandle<ND::TAlgorithmResult> ecalFinalResult =
99 event.GetFit(
"P0DECALPid");
101 for (ND::TDataVector::iterator dataIter = ecalFinalResult->begin();
102 dataIter != ecalFinalResult->end(); ++dataIter) {
103 std::string class_name = (*dataIter)->ClassName();
104 if (class_name.find(
"ND::TReconObjectContainer") != std::string::npos) {
105 ND::TReconObjectContainer *reconContainer =
106 dynamic_cast<ND::TReconObjectContainer *
>(*dataIter);
108 if (!reconContainer) {
114 TString reconContainerName = reconContainer->GetFullName();
116 if (reconContainerName.Contains(
"final")) {
118 for (ND::TReconObjectContainer::iterator reconIter =
119 reconContainer->begin();
120 reconIter != reconContainer->end(); ++reconIter) {
121 std::string reco_class_name = (*reconIter)->ClassName();
124 if (reco_class_name.find(
"ND::TReconPID") != std::string::npos) {
125 ND::THandle<ND::TReconPID> pid = (*reconIter);
126 ND::THandle<ND::TReconObjectContainer> conContainer =
127 pid->GetConstituents();
129 for (ND::TReconObjectContainer::iterator conIter =
130 conContainer->begin();
131 conIter != conContainer->end(); ++conIter) {
132 std::string constituent_class_name = (*conIter)->ClassName();
134 if (constituent_class_name.find(
"ND::TReconTrack") !=
136 ND::THandle<ND::TReconTrack> track = (*conIter);
139 if (track->GetEDeposit()) {
144 ecalReconTrack->
UniqueID = track->GetUniqueID();
145 ecalReconTrack->
Direction = track->GetDirection();
146 ecalReconTrack->
Position = track->GetPosition();
150 ND::THandle<ND::THitSelection> track_hitsel =
152 std::string module(
"unknown");
154 ND::THandle<ND::TReconHit> track_reconhit =
155 *(track_hitsel->begin());
156 module = ND::TGeomInfo::Get()
158 .GetModule(track_reconhit->GetGeomId())
161 ecalReconTrack->
Module = module;
164 ecalReconTrack->
StackNo = (int)track->GetDetectors();
167 ecalReconTrack->
Curvature = track->GetCurvature();
168 ecalReconTrack->
EDeposit = track->GetEDeposit();
169 ecalReconTrack->
NDOF = track->GetNDOF();
170 ecalReconTrack->
Quality = track->GetQuality();
171 ecalReconTrack->
Width = track->GetWidth();
176 TLorentzVector trueInitPos(-9999, -9999, -9999, -9999);
177 TLorentzVector trueFinalPos(-9999, -9999, -9999, -9999);
178 TLorentzVector trueInitMom(-9999, -9999, -9999, -9999);
180 int trueParentID = -999;
181 double truePur = -9999.0;
182 double trueEff = -9999.0;
184 ND::THandle<ND::THitSelection> track_hits = track->GetHits();
187 trueID = TrackTruthInfo::GetG4TrajIDHits(*track_hits,
189 ND::THandle<ND::TG4TrajectoryContainer>
190 trajectoryContainer =
191 event.Get<ND::TG4TrajectoryContainer>(
192 "truth/G4Trajectories");
193 ND::THandle<ND::TG4Trajectory> g4traj(0);
194 if (trajectoryContainer) {
195 g4traj = trajectoryContainer->GetTrajectory(trueID);
198 trueInitPos = g4traj->GetInitialPosition();
199 trueFinalPos = g4traj->GetFinalPosition();
200 trueInitMom = g4traj->GetInitialMomentum();
201 truePDG = g4traj->GetPDGEncoding();
202 trueParentID = g4traj->GetParentId();
206 ecalReconTrack->
TrueID = trueID;
207 ecalReconTrack->
TruePDG = truePDG;
219 if (track->Get<ND::TRealDatum>(
"AMR")) {
220 ecalReconTrack->
AMR =
221 track->Get<ND::TRealDatum>(
"AMR")->GetValue();
223 ecalReconTrack->
AMR = -1;
226 if (track->Get<ND::TRealDatum>(
"CWTrackWidth")) {
228 track->Get<ND::TRealDatum>(
"CWTrackWidth")->GetValue();
233 if (track->Get<ND::TRealDatum>(
"Max_Ratio")) {
235 track->Get<ND::TRealDatum>(
"Max_Ratio")->GetValue();
240 if (track->Get<ND::TRealDatum>(
"NormChargeSD")) {
242 track->Get<ND::TRealDatum>(
"NormChargeSD")->GetValue();
247 if (track->Get<ND::TRealDatum>(
"PathChargeRatio")) {
249 track->Get<ND::TRealDatum>(
"PathChargeRatio")
255 if (track->Get<ND::TRealDatum>(
"TrShval")) {
257 track->Get<ND::TRealDatum>(
"TrShval")->GetValue();
263 ND::THandle<ND::TReconObjectContainer> clusterContainer =
264 track->GetConstituents();
265 for (ND::TReconObjectContainer::iterator clusterIter =
266 clusterContainer->begin();
267 clusterIter != clusterContainer->end(); ++clusterIter) {
268 std::string track_constituent_class_name =
269 (*clusterIter)->ClassName();
270 if (track_constituent_class_name.find(
271 "ND::TReconCluster") != std::string::npos) {
272 ND::THandle<ND::TReconCluster> cluster = (*clusterIter);
274 if (cluster->Get<ND::TRealDatum>(
"BenCWPos")) {
277 cluster->Get<ND::TRealDatum>(
"BenCWPos")->at(0),
278 cluster->Get<ND::TRealDatum>(
"BenCWPos")->at(1),
279 cluster->Get<ND::TRealDatum>(
"BenCWPos")->at(2)
284 if (cluster->Get<ND::TRealDatum>(
"AMR")) {
285 ecalReconTrack->
AMR =
286 cluster->Get<ND::TRealDatum>(
"AMR")->GetValue();
288 ecalReconTrack->
AMR = -1;
291 if (cluster->Get<ND::TRealDatum>(
"CWTrackWidth")) {
293 cluster->Get<ND::TRealDatum>(
"CWTrackWidth")
299 if (cluster->Get<ND::TRealDatum>(
"Max_Ratio")) {
301 cluster->Get<ND::TRealDatum>(
"Max_Ratio")
307 if (cluster->Get<ND::TRealDatum>(
"NormChargeSD")) {
309 cluster->Get<ND::TRealDatum>(
"NormChargeSD")
315 if (cluster->Get<ND::TRealDatum>(
"PathChargeRatio")) {
317 cluster->Get<ND::TRealDatum>(
"PathChargeRatio")
323 ecalReconTrack->
NHits = (int)cluster->GetHits()->size();
327 }
else if (constituent_class_name.find(
"ND::TReconShower") !=
329 ND::THandle<ND::TReconShower> shower = (*conIter);
332 if (shower->GetEDeposit()) {
333 ecalReconShower =
new ((*fReconShowers)[fNReconShowers])
336 ecalReconShower->
UniqueID = shower->GetUniqueID();
337 ecalReconShower->
StackNo = (int)shower->GetDetectors();
340 ecalReconShower->
ConeAngle = shower->GetConeAngle();
341 ecalReconShower->
Direction = shower->GetDirection();
342 ecalReconShower->
EDeposit = shower->GetEDeposit();
343 ecalReconShower->
NDOF = shower->GetNDOF();
344 ecalReconShower->
Position = shower->GetPosition();
345 ecalReconShower->
Quality = shower->GetQuality();
349 ND::THandle<ND::THitSelection> shower_hitsel =
352 ND::THandle<ND::TReconHit> shower_reconhit =
353 *(shower_hitsel->begin());
354 module = ND::TGeomInfo::Get()
356 .GetModule(shower_reconhit->GetGeomId())
358 ecalReconShower->
Module = module;
365 ND::TShowerTruthInfo showerTruth(pid);
366 std::vector<ND::TShowerTruthInfo::TruthInfo> results =
367 showerTruth.GetPrimaryTrajectories();
368 if (results.size() > 0) {
369 trueID = results[0].ParticleID;
372 ecalReconShower->
TrueID = trueID;
379 if (shower->Get<ND::TRealDatum>(
"AMR")) {
380 ecalReconShower->
AMR =
381 shower->Get<ND::TRealDatum>(
"AMR")->GetValue();
383 ecalReconShower->
AMR = -1;
386 if (shower->Get<ND::TRealDatum>(
"CWTrackWidth")) {
388 shower->Get<ND::TRealDatum>(
"CWTrackWidth")->GetValue();
393 if (shower->Get<ND::TRealDatum>(
"Max_Ratio")) {
395 shower->Get<ND::TRealDatum>(
"Max_Ratio")->GetValue();
400 if (shower->Get<ND::TRealDatum>(
"NormChargeSD")) {
402 shower->Get<ND::TRealDatum>(
"NormChargeSD")->GetValue();
407 if (shower->Get<ND::TRealDatum>(
"PathChargeRatio")) {
409 shower->Get<ND::TRealDatum>(
"PathChargeRatio")
415 if (shower->Get<ND::TRealDatum>(
"TrShval")) {
417 shower->Get<ND::TRealDatum>(
"TrShval")->GetValue();
423 ND::THandle<ND::TReconObjectContainer> clusterContainer =
424 shower->GetConstituents();
425 for (ND::TReconObjectContainer::iterator clusterIter =
426 clusterContainer->begin();
427 clusterIter != clusterContainer->end(); ++clusterIter) {
428 std::string shower_constituent_class_name =
429 (*clusterIter)->ClassName();
430 if (shower_constituent_class_name.find(
431 "ND::TReconCluster") != std::string::npos) {
432 ND::THandle<ND::TReconCluster> cluster = (*clusterIter);
435 if (cluster->Get<ND::TRealDatum>(
"BenCWPos")) {
437 cluster->Get<ND::TRealDatum>(
"BenCWPos")->at(0),
438 cluster->Get<ND::TRealDatum>(
"BenCWPos")->at(1),
439 cluster->Get<ND::TRealDatum>(
"BenCWPos")->at(2)
445 if (cluster->Get<ND::TRealDatum>(
"AMR")) {
446 ecalReconShower->
AMR =
447 cluster->Get<ND::TRealDatum>(
"AMR")->GetValue();
449 ecalReconShower->
AMR = -1;
452 if (cluster->Get<ND::TRealDatum>(
"CWTrackWidth")) {
454 cluster->Get<ND::TRealDatum>(
"CWTrackWidth")
460 if (cluster->Get<ND::TRealDatum>(
"Max_Ratio")) {
462 cluster->Get<ND::TRealDatum>(
"Max_Ratio")
468 if (cluster->Get<ND::TRealDatum>(
"NormChargeSD")) {
470 cluster->Get<ND::TRealDatum>(
"NormChargeSD")
476 if (cluster->Get<ND::TRealDatum>(
"PathChargeRatio")) {
478 cluster->Get<ND::TRealDatum>(
"PathChargeRatio")
484 ecalReconShower->
NHits = (int)cluster->GetHits()->size();
492 }
else if (reconContainerName.Contains(
"charge_by_layer")) {
493 for (ND::TReconObjectContainer::iterator reconIter =
494 reconContainer->begin();
495 reconIter != reconContainer->end(); ++reconIter) {
496 ND::THandle<ND::TReconCluster> cluster = (*reconIter);
504 TString algoname = cluster->GetAlgorithmName();
505 if (algoname.Contains(
"Left")) {
508 if (algoname.Contains(
"Right")) {
513 if (algoname.Contains(
"Top")) {
516 if (algoname.Contains(
"Bottom")) {
519 if (algoname.Contains(
"Side")) {
523 if (cluster->Get<ND::TRealDatum>(
"first_time")) {
525 cluster->Get<ND::TRealDatum>(
"first_time")->GetValue();
530 if (cluster->Get<ND::TRealDatum>(
"last_time")) {
532 cluster->Get<ND::TRealDatum>(
"last_time")->GetValue();
537 if (cluster->Get<ND::TRealDatum>(
"layer_charge")) {
538 for (
int nlay = 0; nlay < 6; nlay++) {
539 LayerCharge->
Charge[nlay] =
540 cluster->Get<ND::TRealDatum>(
"layer_charge")->at(nlay);
double AMR
PID Variable: Axis Max Ratio - the ratio of primary and secondary components of a 2D PCA...
int NHits
The number of THits which contributed to this reconstruction cluster.
double AMR
PID Variable: Axis Max Ratio - the ratio of primary and secondary components of a 2D PCA...
TVector3 BenCWPosition
Ben Smith's charge weighted reconstruction position.
UInt_t UniqueID
The object UniqueID which can be used to match this object to the Global Recon object.
double Quality
The 'quality' of the reconstruction according to the relevant TReconTrack, from ND::TReconBase::GetQu...
virtual bool FillTree(ND::TND280Event &)
Fill all the stuff that goes in the output tree.
ClassImp(ND::TBeamSummaryDataModule::TBeamSummaryData)
double LastTime
The latest hit time of the relevant cluster.
std::string fDescription
A longish descrition of the analysis.
UInt_t UniqueID
The object UniqueID which can be used to match this object to the Global Recon object.
Summary of reconstruction information held within a TReconShower.
double EDeposit
The reconstructed energy deposited by the corresponding TReconTrack.
TClonesArray * fLayerCharge
TClonesArray of TP0DECALLayerCharge Objects.
virtual void InitializeModule()
Initialize Module, override if necessary.
double PathChargeRatio
The ratio of total hit charges between the front half and back half of the TReconTrack.
double NormChargeSD
PID Variable: Normalised standard deviation of the contributing reconstructed hit charges...
TVector3 Direction
The Direction of the corresponding TReconTrack.
double TrueHitEfficiency
For MC events: The 'completeness' of the ND::THits which make up the corresponding ND::TReconTrack...
double TrShval
PID Variable: The output of the ANN using the other PID Variables as input. Shower-like events have a...
int TrueID
For MC events: The Id of the corresponding ND::TG4Trajectory.
int TrueParentID
For MC events: The Id of the true trajectory's parent ND::TG4Trajectory.
double NormChargeSD
PID Variable: Normalised standard deviation of the contributing reconstructed hit charges...
double Max_Ratio
PID Variable: The ratio between highest and lowest hit charges in the reconstruction cluster...
int TruePDG
For MC events: The PDG code of the true particle.
int StackNo
The stack in which the TReconTrack resides.
TVector3 Direction
The Direction of the corresponding TReconShower.
int NHits
The number of THits which contributed to this reconstruction cluster.
virtual Bool_t ProcessFirstEvent(ND::TND280Event &event)
Is called after the first event is loaded in.
TLorentzVector TrueFinalPos
For MC events: The true final position of the corresponding ND::TG4Trajectory.
virtual ~TP0DECALReconTrack()
TLorentzVector Position
The reconstructed starting 4-position of the TReconTrack.
TLorentzVector Position
The reconstructed starting 4-position of the TReconTrack.
TString module_name
The name of the module.
double FirstTime
The earliest hit time of the relevant cluster.
double TrueHitPurity
For MC events: The 'cleanliness' of the ND::THits which make up the corresponding ND::TReconTrack...
int GetStackNo(TString Name)
virtual ~TP0DECALLayerCharge()
TLorentzVector TrueInitPos
For MC events: The true initial position of the corresponding ND::TG4Trajectory.
virtual ~TP0DECALReconShower()
std::string fCVSID
Defined if an official tagged version.
virtual ~TP0DECALReconModule()
double Max_Ratio
PID Variable: The ratio between highest and lowest hit charges in the reconstruction cluster...
std::string Module
The name of the module in which the TReconTrack resides.
void SetNameTitle(char const *name, char const *title)
TClonesArray * fReconShowers
TClonesArray of TP0DECALReconShower Objects.
int StackNo
The stack in which the TReconTrack resides.
virtual void InitializeBranches()
Initialize Branches. Don't do anything else in this function.
TClonesArray * fReconTracks
TClonesArray of TP0DECALReconTrack Objects.
int NDOF
The Number of Degrees of Freedom in the reconstruction of the.
TLorentzVector TrueInitMom
For MC events: The true initial momentum of the corresponding ND::TG4Trajectory.
TVector3 ConeAngle
The opening angle of the corresponding TReconShower.
double Charge[6]
The total charge deposited in each of 6layers. Index 0 corresponds the innermost layer.
TVector3 Width
The 'width' of the corresponding TReconTrack.
TP0DECALReconModule(const char *name="P0DECal", const char *title="P0D ECal Recon Module")
double TrShval
PID Variable: The output of the ANN using the other PID Variables as input. Track-like events have a ...
std::string Module
The name of the module in which the TReconTrack resides.
int NDOF
The Number of Degrees of Freedom in the reconstruction of the.
double EDeposit
The reconstructed energy deposited by the corresponding TReconTrack.
std::string fCVSTagName
Defined if an official tagged version.
TVector3 BenCWPosition
Ben's charge weighted reconstruction position.
double PathChargeRatio
The ratio of total hit charges between the front half and back half of the TReconShower.
Summary of reconstruction information held within a TReconTrack.
void SetSplitLevel(Int_t splitlevel)
ROOT output parameters, usually no need to touch.
double CWTrackWidth
PID Variable: Width of the track in bars, weighted by the charge in each bar.
double Curvature
The curvature around the x axis of the corresponding TReconTrack.
double CWTrackWidth
PID Variable: Width of the track in bars, weighted by the charge in each bar.
int TrueID
For MC events: The Id of the primary corresponding ND::TG4Trajectory.
double Quality
The 'quality' of the reconstruction according to the relevant.