4 #include "TGeomInfo.hxx"
5 #include "TPrincipal.h"
6 #include "TRealDatum.hxx"
19 $Id: eventAnalysis TTRExReconModule.cxx,2024/03/20:09:46:11,Alexander_J_Finch,lapw.lancs.ac.uk $"
31 fPatterns =
new TClonesArray(
"ND::TTRExReconModule::TTPCAnaPattern", 200);
41 return (fNPatterns ?
true :
false);
47 fOutputTree->Branch(
"NPatterns", &fNPatterns,
"NPatterns/I", fBufferSize);
49 fOutputTree->Branch(
"Patterns", &fPatterns, fBufferSize, fSplitLevel);
55 fPatterns->Clear(
"C");
58 fIsMC =
event.GetContext().IsMC();
61 ND::THandle<ND::TAlgorithmResult> TRExResult =
event.GetFit(
"TREXRecon");
64 ND::THandle<ND::TReconObjectContainer> PatternReco =
65 TRExResult->GetResultsContainer(
"TRExUnmergedReco");
66 ND::THandle<ND::TReconObjectContainer> StandardReco =
67 TRExResult->GetResultsContainer(
"GasInteractionOutput");
69 int pattern_count = 0;
77 for (ND::TReconObjectContainer::iterator patternIt =
78 StandardReco->begin();
79 patternIt < StandardReco->end(); patternIt++) {
80 ND::THandle<ND::TReconVertex> c_pattern =
82 ND::THandle<ND::TReconPID> d_pattern_pid =
84 ND::THandle<ND::TReconTrack> d_pattern_no_pid =
86 ND::THandle<ND::TReconBase> generic_pattern = *patternIt;
92 if ((c_pattern) && (c_pattern->Get<ND::TIntegerDatum>(
"PatternId")))
94 c_pattern->Get<ND::TIntegerDatum>(
"PatternId")->GetValue();
95 if ((d_pattern_pid) &&
96 (d_pattern_pid->Get<ND::TIntegerDatum>(
"PatternId")))
98 d_pattern_pid->Get<ND::TIntegerDatum>(
"PatternId")->GetValue();
99 if ((d_pattern_no_pid) &&
100 (d_pattern_no_pid->Get<ND::TIntegerDatum>(
"PatternId")))
102 d_pattern_no_pid->Get<ND::TIntegerDatum>(
"PatternId")->GetValue();
110 if (c_pattern) tpc = GetTPCFromPattern(c_pattern);
111 if (d_pattern_pid) tpc = GetTPCFromPattern(d_pattern_pid);
112 if (d_pattern_no_pid) tpc = GetTPCFromPattern(d_pattern_no_pid);
118 ND::THandle<ND::THitSelection> p0dhits =
event.GetHitSelection(
"p0d");
120 ND::THandle<ND::TAlgorithmResult> p0dhitsResult(
121 new ND::TAlgorithmResult(*p0dhits));
122 ND::TP0DVetoForTPC vetoForTPC;
123 THandle<TAlgorithmResult> vetoResult =
124 vetoForTPC.Process(*p0dhitsResult);
125 if (vetoResult) outputPattern->
S1Sflag =
false;
131 if (FGDHitVeto(1, 5, event, 0)) outputPattern->
S1Sflag =
false;
136 if (FGDHitVeto(2, 5, event, 0)) outputPattern->
S1Sflag =
false;
143 outputPattern->
TPC = GetTPCFromPattern(c_pattern);
148 std::list<ND::THandle<ND::TReconBase> > patternpaths;
149 std::list<ND::THandle<ND::TReconVertex> > patternjuncs;
151 ND::THandle<ND::TReconObjectContainer> patt_con =
152 c_pattern->GetConstituents();
154 for (ND::TReconObjectContainer::iterator conIt = patt_con->begin();
155 conIt < patt_con->end(); conIt++) {
156 ND::THandle<ND::TReconVertex> junc = *conIt;
157 ND::THandle<ND::TReconTrack> track = *conIt;
158 ND::THandle<ND::TReconPID> pid = *conIt;
159 ND::THandle<ND::TReconBase> path = *conIt;
161 if (junc) patternjuncs.push_back(junc);
162 if (track || pid) patternpaths.push_back(path);
166 outputPattern->
NJunctions = patternjuncs.size();
167 outputPattern->
NPaths = patternpaths.size();
169 std::map<int, std::vector<int> > path_junctions;
178 for (ND::TReconObjectContainer::iterator conIt = patt_con->begin();
179 conIt < patt_con->end(); conIt++) {
182 ND::THandle<ND::TReconVertex> junc = *conIt;
185 new ((*(outputPattern->
Junctions))[junc_id])
190 if (junc->Get<ND::TIntegerDatum>(
"JunctionId"))
192 junc->Get<ND::TIntegerDatum>(
"JunctionId")->GetValue();
193 outputJunction->
Position = junc->GetPosition();
196 ND::THandle<ND::THitSelection> junchits = junc->GetHits();
197 TVector3 maxima(-999999.9, -999999.9, -999999.9);
198 TVector3 minima(999999.9, 999999.9, 999999.9);
202 for (ND::THitSelection::iterator hitIt = junchits->begin();
203 hitIt != junchits->end(); hitIt++) {
207 ND::THandle<ND::THit> hit = *hitIt;
211 if (junc->Get<ND::TRealDatum>(
"T0"))
212 t0 = junc->Get<ND::TRealDatum>(
"T0")->GetValue();
216 double RPx = hit->GetPosition().X();
217 double Sense = int(ND::TGeomInfo::Get().TPC().GetDriftSense(
221 double TimeOffset = 259.;
224 double DriftVelocity = 0.0785;
226 double DriftDistance =
227 (hit->GetTime() - t0 - TimeOffset) * DriftVelocity;
228 double hitX = RPx - (Sense * DriftDistance);
230 double hitY = hit->GetPosition().Y();
231 double hitZ = hit->GetPosition().Z();
233 if (hitX > maxima.X()) {
236 if (hitX < minima.X()) {
240 if (hitY > maxima.Y()) maxima.SetY(hitY);
241 if (hitY < minima.Y()) minima.SetY(hitY);
243 if (hitZ > maxima.Z()) maxima.SetZ(hitZ);
244 if (hitZ < minima.Z()) minima.SetZ(hitZ);
251 ND::THandle<ND::TReconObjectContainer> juncpaths =
252 junc->GetConstituents();
254 int njuncpaths = juncpaths->size();
255 outputJunction->
NPaths = njuncpaths;
256 outputJunction->
PathIDs =
new int[njuncpaths];
258 int juncpath_count = 0;
259 for (ND::TReconObjectContainer::iterator pathIt =
261 pathIt != juncpaths->end(); pathIt++) {
263 ND::THandle<ND::TReconBase> juncpath = *pathIt;
267 for (std::list<ND::THandle<ND::TReconBase> >::iterator
268 listIt = patternpaths.begin();
269 listIt != patternpaths.end(); listIt++) {
270 if (juncpath == *listIt) {
272 int i = std::distance(patternpaths.begin(), listIt);
273 outputJunction->
PathIDs[juncpath_count] = i;
275 path_junctions[i].push_back(junc_id);
279 juncpath_count = juncpath_count + 1;
283 junc_id = junc_id + 1;
288 ND::THandle<ND::TReconPID> pid = *conIt;
289 ND::THandle<ND::TReconTrack> track = *conIt;
297 outputPath->
PathID = path_id;
298 FillPathInfo(outputPath, pid, patternpaths, StandardReco,
302 int npathjuncs = path_junctions[path_id].size();
305 for (
int i = 0; i < npathjuncs; i++) {
306 outputPath->
JunctionIDs[i] = path_junctions[path_id][i];
310 path_id = path_id + 1;
319 outputPath->
PathID = path_id;
320 FillPathInfo(outputPath, track, patternpaths, StandardReco,
324 int npathjuncs = path_junctions[path_id].size();
327 for (
int i = 0; i < npathjuncs; i++) {
328 outputPath->
JunctionIDs[i] = path_junctions[path_id][i];
332 path_id = path_id + 1;
336 pattern_count = pattern_count + 1;
344 std::list<ND::THandle<ND::TReconBase> > patternpaths;
347 outputPattern->
TPC = GetTPCFromPattern(d_pattern_pid);
349 outputPattern->
NPaths = 1;
359 FillPathInfo(outputPath, d_pattern_pid, patternpaths, StandardReco,
362 pattern_count = pattern_count + 1;
363 }
else if (d_pattern_no_pid) {
364 outputPattern->
TPC = GetTPCFromPattern(d_pattern_no_pid);
366 outputPattern->
NPaths = 1;
376 FillPathInfo(outputPath, d_pattern_no_pid, patternpaths, StandardReco,
379 pattern_count = pattern_count + 1;
383 fNPatterns = pattern_count;
384 }
else if (PatternReco) {
396 ND::THandle<ND::TReconVertex> pattern) {
405 ND::THandle<ND::TReconTrack> pattern) {
414 ND::THandle<ND::TReconPID> pattern) {
423 TTPCAnaPath* outputPath, ND::THandle<ND::TReconPID> path,
424 std::list<ND::THandle<ND::TReconBase> > patternpaths,
425 ND::THandle<ND::TReconObjectContainer> patterns,
426 ND::THandle<ND::TReconBase> parent_pattern) {
429 path->Get<ND::TIntegerDatum>(
"PathId")->GetValue();
431 outputPath->
Time = path->GetPosition().T();
433 ND::TReconNodeContainer pathnodes = path->GetNodes();
434 int node_counter = 0;
435 for (ND::TReconNodeContainer::iterator nodeIt = pathnodes.begin();
436 nodeIt != pathnodes.end(); nodeIt++) {
439 ND::THandle<ND::TReconState> recon_state = (*nodeIt)->GetState();
440 if (!recon_state)
continue;
441 ND::THandle<ND::TPIDState> pid_state =
442 (ND::THandle<ND::TPIDState>)recon_state;
443 if (!pid_state)
continue;
445 TVector3 node_pos = pid_state->GetPosition().Vect();
446 if (node_counter == 2) outputPath->
LastPosition = node_pos;
448 if (node_counter < 2) outputPath->
LastPosition = TVector3(9999, 9999, 9999);
450 ND::THandle<ND::TPIDState> state = path->GetState();
452 outputPath->
Length = path->Get<ND::TRealDatum>(
"Length")->GetValue();
453 outputPath->
T0Source = path->Get<ND::TIntegerDatum>(
"T0Source")->GetValue();
454 outputPath->
LikFit = path->CheckStatus(ND::TReconBase::kLikelihoodFit);
455 outputPath->
Success = path->CheckStatus(ND::TReconBase::kSuccess);
456 if (outputPath->
LikFit) outputPath->
FitLikelihood = path->Get<ND::TRealDatum>(
"FitLogLikelihood")->GetValue();
459 outputPath->
PID = path->GetParticleId();
460 outputPath->
G4ID = TrackTruthInfo::GetG4TrajIDHits(*(path->GetHits()));
462 outputPath->
Momentum = path->GetMomentum();
463 if (state->GetMomentumVariance() > 0.) {
464 outputPath->
MomentumError = sqrt(state->GetMomentumVariance());
466 outputPath->
Direction = path->GetDirection();
467 outputPath->
Charge = path->GetCharge();
469 ND::THandle<ND::THitSelection> hits = path->GetHits();
477 outputPath->
EleExp = 9999;
491 outputPath->
PDist = 999999.;
493 outputPath->
T0Range[0] = 999999.;
494 outputPath->
T0Range[1] = 999999.;
498 if (path->Get<ND::TRealDatum>(
"tpcPid_PullEle")) outputPath->
ElePull = (Double_t)path->Get<ND::TRealDatum>(
"tpcPid_PullEle")->GetValue();
499 if (path->Get<ND::TRealDatum>(
"tpcPid_dEdxexpEle")) outputPath->
EleExp = (Double_t)path->Get<ND::TRealDatum>(
"tpcPid_dEdxexpEle")->GetValue();
500 if (path->Get<ND::TRealDatum>(
"tpcPid_SigmaEle")) outputPath->
EleSigma = (Double_t)path->Get<ND::TRealDatum>(
"tpcPid_SigmaEle")->GetValue();
502 if (path->Get<ND::TRealDatum>(
"tpcPid_PullMuon")) outputPath->
MuonPull = (Double_t)path->Get<ND::TRealDatum>(
"tpcPid_PullMuon")->GetValue();
503 if (path->Get<ND::TRealDatum>(
"tpcPid_dEdxexpMuon")) outputPath->
MuonExp = (Double_t)path->Get<ND::TRealDatum>(
"tpcPid_dEdxexpMuon")->GetValue();
504 if (path->Get<ND::TRealDatum>(
"tpcPid_SigmaMuon")) outputPath->
MuonSigma = (Double_t)path->Get<ND::TRealDatum>(
"tpcPid_SigmaMuon")->GetValue();
506 if (path->Get<ND::TRealDatum>(
"tpcPid_PullPion")) outputPath->
PionPull = (Double_t)path->Get<ND::TRealDatum>(
"tpcPid_PullPion")->GetValue();
507 if (path->Get<ND::TRealDatum>(
"tpcPid_dEdxexpPion")) outputPath->
PionExp = (Double_t)path->Get<ND::TRealDatum>(
"tpcPid_dEdxexpPion")->GetValue();
508 if (path->Get<ND::TRealDatum>(
"tpcPid_SigmaPion")) outputPath->
PionSigma = (Double_t)path->Get<ND::TRealDatum>(
"tpcPid_SigmaPion")->GetValue();
510 if (path->Get<ND::TRealDatum>(
"tpcPid_PullKaon")) outputPath->
KaonPull = (Double_t)path->Get<ND::TRealDatum>(
"tpcPid_PullKaon")->GetValue();
511 if (path->Get<ND::TRealDatum>(
"tpcPid_dEdxexpKaon")) outputPath->
KaonExp = (Double_t)path->Get<ND::TRealDatum>(
"tpcPid_dEdxexpKaon")->GetValue();
512 if (path->Get<ND::TRealDatum>(
"tpcPid_SigmaKaon")) outputPath->
KaonSigma = (Double_t)path->Get<ND::TRealDatum>(
"tpcPid_SigmaKaon")->GetValue();
514 if (path->Get<ND::TRealDatum>(
"tpcPid_PullProton")) outputPath->
ProtonPull = (Double_t)path->Get<ND::TRealDatum>(
"tpcPid_PullProton")->GetValue();
515 if (path->Get<ND::TRealDatum>(
"tpcPid_dEdxexpProton")) outputPath->
ProtonExp = (Double_t)path->Get<ND::TRealDatum>(
"tpcPid_dEdxexpProton")->GetValue();
516 if (path->Get<ND::TRealDatum>(
"tpcPid_SigmaProton")) outputPath->
ProtonSigma = (Double_t)path->Get<ND::TRealDatum>(
"tpcPid_SigmaProton")->GetValue();
518 if (path->Get<ND::TRealDatum>(
"RefitDistortionCorrMom")) outputPath->
PDist = (Double_t)path->Get<ND::TRealDatum>(
"RefitDistortionCorrMom")->GetValue();
519 if (path->Get<ND::TRealDatum>(
"RefitEFieldDistortionMom")) outputPath->
PEField = (Double_t)path->Get<ND::TRealDatum>(
"RefitEFieldDistortionMom")->GetValue();
521 if (path->Get<ND::TRealDatum>(
"T0Range")){
522 outputPath->
T0Range[0] = (Double_t) path->Get<ND::TRealDatum>(
"T0Range")->at(0);
523 outputPath->
T0Range[1] = (Double_t) path->Get<ND::TRealDatum>(
"T0Range")->at(1);
525 if (path->Get<ND::TRealDatum>(
"T0Range_DeltaX")){
526 outputPath->
T0RangeDeltaX[0] = (Double_t) path->Get<ND::TRealDatum>(
"T0Range_DeltaX")->at(0);
527 outputPath->
T0RangeDeltaX[1] = (Double_t) path->Get<ND::TRealDatum>(
"T0Range_DeltaX")->at(1);
535 FillPathMatchingInfo(outputPath, path, patternpaths, patterns,
540 TTPCAnaPath* outputPath, ND::THandle<ND::TReconTrack> path,
541 std::list<ND::THandle<ND::TReconBase> > patternpaths,
542 ND::THandle<ND::TReconObjectContainer> patterns,
543 ND::THandle<ND::TReconBase> parent_pattern) {
545 outputPath->
PathMatchingID = path->Get<ND::TIntegerDatum>(
"PathId")->GetValue();
547 outputPath->
Time = path->GetPosition().T();
548 ND::TReconNodeContainer pathnodes = path->GetNodes();
549 int node_counter = 0;
550 for (ND::TReconNodeContainer::iterator nodeIt = pathnodes.begin();
551 nodeIt != pathnodes.end(); nodeIt++) {
554 ND::THandle<ND::TReconState> recon_state = (*nodeIt)->GetState();
555 if (!recon_state)
continue;
556 ND::THandle<ND::TTrackState> track_state =
557 (ND::THandle<ND::TTrackState>)recon_state;
558 if (!track_state)
continue;
560 TVector3 node_pos = track_state->GetPosition().Vect();
561 if (node_counter == 2) outputPath->
LastPosition = node_pos;
563 if (node_counter < 2) outputPath->
LastPosition = TVector3(9999, 9999, 9999);
565 outputPath->
Length = path->Get<ND::TRealDatum>(
"Length")->GetValue();
566 outputPath->
T0Source = path->Get<ND::TIntegerDatum>(
"T0Source")->GetValue();
567 outputPath->
LikFit = path->CheckStatus(ND::TReconBase::kLikelihoodFit);
568 outputPath->
Success = path->CheckStatus(ND::TReconBase::kSuccess);
569 if (outputPath->
LikFit) outputPath->
FitLikelihood = path->Get<ND::TRealDatum>(
"FitLogLikelihood")->GetValue();
573 outputPath->
G4ID = TrackTruthInfo::GetG4TrajIDHits(*(path->GetHits()));
577 outputPath->
Direction = path->GetDirection();
579 ND::THandle<ND::THitSelection> hits = path->GetHits();
586 outputPath->
EleExp = -9999;
601 outputPath->
PDist = 999999.;
603 outputPath->
T0Range[0] = 999999.;
604 outputPath->
T0Range[1] = 999999.;
608 if (path->Get<ND::TRealDatum>(
"RefitDistortionCorrMom")) outputPath->
PDist = (Double_t)path->Get<ND::TRealDatum>(
"RefitDistortionCorrMom")->GetValue();
609 if (path->Get<ND::TRealDatum>(
"RefitEFieldDistortionMom")) outputPath->
PEField = (Double_t)path->Get<ND::TRealDatum>(
"RefitEFieldDistortionMom")->GetValue();
611 if (path->Get<ND::TRealDatum>(
"T0Range")){
612 outputPath->
T0Range[0] = (Double_t) path->Get<ND::TRealDatum>(
"T0Range")->at(0);
613 outputPath->
T0Range[1] = (Double_t) path->Get<ND::TRealDatum>(
"T0Range")->at(1);
615 if (path->Get<ND::TRealDatum>(
"T0Range_DeltaX")){
616 outputPath->
T0RangeDeltaX[0] = (Double_t) path->Get<ND::TRealDatum>(
"T0Range_DeltaX")->at(0);
617 outputPath->
T0RangeDeltaX[1] = (Double_t) path->Get<ND::TRealDatum>(
"T0Range_DeltaX")->at(1);
625 FillPathMatchingInfo(outputPath, path, patternpaths, patterns,
630 ND::TND280Event& event,
int mode) {
633 double fgd_limits[2] = {0, 0};
636 fgd_limits[0] = TGeomInfo::Get().FGD().FGD1ActiveMin().Z();
637 fgd_limits[1] = TGeomInfo::Get().FGD().FGD1ActiveMax().Z();
641 fgd_limits[0] = TGeomInfo::Get().FGD().FGD2ActiveMin().Z();
642 fgd_limits[1] = TGeomInfo::Get().FGD().FGD2ActiveMax().Z();
645 double backside = fgd_limits[1] - frac * (fgd_limits[1] - fgd_limits[0]);
648 ND::THitSelection endhits;
649 ND::THandle<ND::THitSelection> fgd_hits =
event.GetHitSelection(
"fgd");
651 for (ND::THitSelection::iterator hitIt = fgd_hits->begin();
652 hitIt != fgd_hits->end(); hitIt++) {
653 ND::THandle<ND::THit> hit = *hitIt;
655 if ((hit->GetPosition().Z() > backside) &&
656 (hit->GetPosition().Z() < fgd_limits[1]))
657 endhits.push_back(hit);
663 std::sort(endhits.begin(), endhits.end(),
timeLessThan());
666 if (endhits.size() > 0) {
667 for (ND::THitSelection::iterator targetHit = endhits.begin();
668 targetHit < (endhits.end() - 1); targetHit++) {
669 double target_hit_time = (*targetHit)->GetTime();
670 double total_charge = 0;
673 for (ND::THitSelection::iterator otherHit = targetHit + 1;
674 otherHit < endhits.end(); otherHit++) {
675 double other_hit_time = (*otherHit)->GetTime();
677 if ((other_hit_time - target_hit_time) > 100.0 * unit::ns)
break;
678 hit_count = hit_count + 1;
679 total_charge = total_charge + (*otherHit)->GetCharge();
688 if (total_charge >= 25.0)
698 TTPCAnaPath* outputPath, ND::THandle<ND::TReconBase> path,
699 std::list<ND::THandle<ND::TReconBase> > patternpaths,
700 ND::THandle<ND::TReconObjectContainer> patterns,
701 ND::THandle<ND::TReconBase> parent_pattern) {
703 int temp_NMatchingPaths = 0;
705 std::vector<int> temp_MatchingPathIDs;
707 std::vector<double> temp_PathMatchingLikelihood;
710 for (std::list<ND::THandle<ND::TReconBase> >::iterator listIt =
711 patternpaths.begin();
712 listIt != patternpaths.end(); listIt++) {
713 ND::THandle<ND::TReconBase> testpath = *listIt;
714 if (!testpath)
continue;
716 bool lklhd_fit = testpath->CheckStatus(ND::TReconBase::kLikelihoodFit);
717 if (!lklhd_fit)
continue;
719 bool fit_success = testpath->CheckStatus(ND::TReconBase::kSuccess);
720 if (!fit_success)
continue;
722 if (!(testpath->Get<ND::TIntegerDatum>(
"PathId")))
continue;
723 int test_PathMatchingID =
724 testpath->Get<ND::TIntegerDatum>(
"PathId")->GetValue();
725 if (!(testpath->Get<ND::TIntegerDatum>(
"PathIdMatch")))
continue;
726 if (!(testpath->Get<ND::TRealDatum>(
"PathMatchLklhd")))
continue;
728 int test_nmatchingpaths =
729 (int)testpath->Get<ND::TIntegerDatum>(
"PathIdMatch")->size();
730 for (
int j = 0; j < test_nmatchingpaths; j++) {
731 int test_matchingpathid =
732 (int)testpath->Get<ND::TIntegerDatum>(
"PathIdMatch")->at(j);
734 temp_NMatchingPaths++;
735 temp_MatchingPathIDs.push_back(test_PathMatchingID);
736 temp_PathMatchingLikelihood.push_back(
737 (
double)testpath->Get<ND::TRealDatum>(
"PathMatchLklhd")->at(j));
743 if (temp_NMatchingPaths) {
748 for (
int i = 0; i < n_matching_paths; i++) {
755 int temp_NMatchingPatterns = 0;
757 std::vector<int> temp_MatchingPatternIDs;
759 std::vector<int> temp_MatchingPatternPathIDs;
761 std::vector<double> temp_PatternMatchingLikelihood;
764 if (parent_pattern->Get<ND::TIntegerDatum>(
"PatternId")) {
765 int parent_pattern_ID =
766 parent_pattern->Get<ND::TIntegerDatum>(
"PatternId")->GetValue();
769 for (ND::TReconObjectContainer::iterator pattIt = patterns->begin();
770 pattIt < patterns->end(); pattIt++) {
771 ND::THandle<ND::TReconBase> testpattern = *pattIt;
772 if (!testpattern)
continue;
773 if (!(testpattern->Get<ND::TIntegerDatum>(
"PatternId")))
continue;
775 testpattern->Get<ND::TIntegerDatum>(
"PatternId")->GetValue();
776 if (testpattern_ID == parent_pattern_ID)
779 ND::THandle<ND::TReconObjectContainer> patt_cons =
780 testpattern->GetConstituents();
781 if (patt_cons && patt_cons->size() > 1) {
782 for (ND::TReconObjectContainer::iterator conIt = patt_cons->begin();
783 conIt < patt_cons->end(); conIt++) {
784 ND::THandle<ND::TReconBase> testpath = *conIt;
786 if (!testpath)
continue;
788 testpath->CheckStatus(ND::TReconBase::kLikelihoodFit);
789 if (!lklhd_fit)
continue;
790 bool fit_success = testpath->CheckStatus(ND::TReconBase::kSuccess);
791 if (!fit_success)
continue;
792 if (!(testpath->Get<ND::TIntegerDatum>(
"PatternIdMatch")))
continue;
793 if (!(testpath->Get<ND::TIntegerDatum>(
"PatternPathIdMatch")))
795 if (!(testpath->Get<ND::TRealDatum>(
"PatternMatchLklhd")))
continue;
796 if (!(testpath->Get<ND::TIntegerDatum>(
"PathId")))
continue;
798 testpath->Get<ND::TIntegerDatum>(
"PathId")->GetValue();
800 int N_matchingpatt_test =
801 testpath->Get<ND::TIntegerDatum>(
"PatternIdMatch")->size();
802 for (
int j = 0; j < N_matchingpatt_test; j++) {
803 int matchingpattID_test =
804 (int)testpath->Get<ND::TIntegerDatum>(
"PatternIdMatch")->at(j);
805 int matchingpattpathID_test =
806 (int)testpath->Get<ND::TIntegerDatum>(
"PatternPathIdMatch")
808 if ((matchingpattID_test == parent_pattern_ID) &&
809 (matchingpattpathID_test == path_ID)) {
810 temp_NMatchingPatterns++;
811 temp_MatchingPatternIDs.push_back(testpattern_ID);
812 temp_MatchingPatternPathIDs.push_back(testpath_ID);
813 temp_PatternMatchingLikelihood.push_back(
814 testpath->Get<ND::TRealDatum>(
"PatternMatchLklhd")->at(j));
820 ND::THandle<ND::TReconBase> testpath = testpattern;
822 if (!testpath)
continue;
823 bool lklhd_fit = testpath->CheckStatus(ND::TReconBase::kLikelihoodFit);
824 if (!lklhd_fit)
continue;
825 bool fit_success = testpath->CheckStatus(ND::TReconBase::kSuccess);
826 if (!fit_success)
continue;
827 if (!(testpath->Get<ND::TIntegerDatum>(
"PatternIdMatch")))
continue;
828 if (!(testpath->Get<ND::TIntegerDatum>(
"PatternPathIdMatch")))
continue;
829 if (!(testpath->Get<ND::TRealDatum>(
"PatternMatchLklhd")))
continue;
830 if (!(testpath->Get<ND::TIntegerDatum>(
"PathId")))
continue;
832 testpath->Get<ND::TIntegerDatum>(
"PathId")->GetValue();
834 int N_matchingpatt_test =
835 testpath->Get<ND::TIntegerDatum>(
"PatternIdMatch")->size();
836 for (
int j = 0; j < N_matchingpatt_test; j++) {
837 int matchingpattID_test =
838 (int)testpath->Get<ND::TIntegerDatum>(
"PatternIdMatch")->at(j);
839 int matchingpattpathID_test =
840 (int)testpath->Get<ND::TIntegerDatum>(
"PatternPathIdMatch")
842 if ((matchingpattID_test == parent_pattern_ID) &&
843 (matchingpattpathID_test == path_ID)) {
844 temp_NMatchingPatterns++;
845 temp_MatchingPatternIDs.push_back(testpattern_ID);
846 temp_MatchingPatternPathIDs.push_back(testpath_ID);
847 temp_PatternMatchingLikelihood.push_back(
848 testpath->Get<ND::TRealDatum>(
"PatternMatchLklhd")->at(j));
855 if (temp_NMatchingPatterns) {
861 for (
int i = 0; i < n_matching_patterns; i++) {
865 temp_PatternMatchingLikelihood[i];
Int_t NMatchingPaths
^ The unique identifiers of the associated junctions
virtual Bool_t ProcessFirstEvent(ND::TND280Event &event)
Is called after the first event is loaded in.
Double_t ElePull
Pull-related values.
Int_t PatternID
The ID of the pattern.
TTPCAnaJunction An object describing a meeting point of two or more paths, and containing all associa...
TTRExReconModule(const char *name="TREx", const char *title="TPC Recon Extension Module")
virtual ~TTPCAnaJunction()
TTPCAnaPath An object describing a track-like grouping of hits in the TPC.
ClassImp(ND::TBeamSummaryDataModule::TBeamSummaryData)
Int_t PathID
A unique identifier for the path within the pattern.
std::string fDescription
A longish descrition of the analysis.
Double_t * PatternMatchingLikelihood
Double_t * PathMatchingLikelihood
^ The unique identifiers of the paths
bool FGDHitVeto(int FGD, int nhits_threshold, ND::TND280Event &event, int mode)
Double_t FitLikelihood
Value of log likelihood from fit.
Double_t Length
The length of the path.
virtual void InitializeModule()
Initialize Module, override if necessary.
Double_t MomentumError
The momentum error of the path.
TVector3 LastPosition
The end position of the path.
Int_t NMatchingPatterns
^ The likelihood of matching to that path.
TClonesArray * Paths
The constituent paths of the pattern.
Int_t G4ID
G4 ID of the primary true trajectory associated with this path.
Int_t TPC
The TPC in which the pattern resides.
Bool_t S1Sflag
A flag to say whether this pattern would pass the TPC gas Stage 1 Selection.
Int_t JunctionID
A unique identifier for the junction within the pattern.
std::string fCVSID
Defined if an official tagged version.
Double_t Time
The T0 for the path.
Int_t NClusters
Number of clusters in the path.
Bool_t LikFit
True if the likelihood fit was performed.
Int_t NJunctions
The number of junctions in the pattern.
void SetNameTitle(char const *name, char const *title)
void FillPathInfo(TTPCAnaPath *outputPath, ND::THandle< ND::TReconPID > path, std::list< ND::THandle< ND::TReconBase > > patternpaths, ND::THandle< ND::TReconObjectContainer > patterns, ND::THandle< ND::TReconBase > parent_pattern)
Fills a TTPCAnaPath with information from either a TReconTrack or a TReconPID.
Int_t NJunctions
The number of junctions to which the path connects.
Double_t Momentum
The momentum of the path.
TVector3 FirstPosition
The start position of the path.
virtual void InitializeBranches()
Initialize Branches. Don't do anything else in this function.
Double_t T0RangeDeltaX[2]
Int_t T0Source
Enumerator of T0 sources.
TTPCAnaPattern The master object for any connected system of hits in a TPC.
Int_t * MatchingPatternPathIDs
virtual bool FillTree(ND::TND280Event &)
Fill all the stuff that goes in the output tree.
TVector3 MaximumCoordinates
^ The unique identifiers of the associated paths.
virtual bool IsFullEventWorthSaving(ND::TND280Event &event)
Returns true if there is at least one recon object.
std::string fCVSTagName
Defined if an official tagged version.
Bool_t IsContained
True if the path does not leave the TPC; false otherwise.
TVector3 MinimumCoordinates
The most extreme hit positions in the negative direction.
virtual ~TTRExReconModule()
TVector3 Direction
The direction of the path.
int GetTPCFromPattern(ND::THandle< ND::TReconVertex >)
Returns TPC in which the pattern was found for all 3 possible input types.
Int_t NPaths
The number of paths connected to the junction.
Double_t NetCharge
The total charge left by the path on the micromegas.
Int_t NPaths
The number of paths.
Int_t * MatchingPatternIDs
Double_t Charge
Charge of the path.
virtual ~TTPCAnaPattern()
TLorentzVector Position
The spatial coordinates of the junction.
TClonesArray * Junctions
The constituent junctions of the pattern.
Int_t PID
The PID of the path.
Bool_t Success
True if the likelihood fit succeeded.
void FillPathMatchingInfo(TTPCAnaPath *outputPath, ND::THandle< ND::TReconBase > path, std::list< ND::THandle< ND::TReconBase > > patternpaths, ND::THandle< ND::TReconObjectContainer > patterns, ND::THandle< ND::TReconBase > parent_pattern)