4 #include <TGeomInfo.hxx>
5 #include <TRecPackManager.hxx>
6 #include <TReconTrack.hxx>
7 #include <TTrackState.hxx>
9 #include <TrackTruthInfo.hxx>
13 #include "TTFBChannelId.hxx"
14 #include "TTFBDigit.hxx"
16 #include <TRealDatum.hxx>
18 #include <TrackingUtils.hxx>
30 $Id: eventAnalysis TSmrdReconModule.cxx,2024/03/20:09:46:11,Alexander_J_Finch,lapw.lancs.ac.uk $"
41 fSmrdReconHits =
new TClonesArray(
"ND::TSmrdReconModule::TSmrdReconHit", 200);
43 fSmrdIsoTracks =
new TClonesArray(
"ND::TSmrdReconModule::TSmrdIsoTrack", 200);
57 ->SetTitle(
"The number of SMRD TReconHits.");
60 ->SetTitle(
"The SMRD TReconHits.");
63 ->SetTitle(
"The number of SMRD isolated tracks.");
66 ->SetTitle(
"The SMRD isolated tracks.");
76 ND::THandle<ND::TAlgorithmResult> SmrdResult =
event.GetFit(
"smrdRecon");
77 ND::THandle<ND::THitSelection> smrdReconHitsMatched;
78 ND::THandle<ND::THitSelection> smrdReconHitsUnused;
79 ND::THandle<ND::THitSelection> smrdReconHitsUsed;
80 ND::THandle<ND::TReconObjectContainer> xyzReconTracks;
83 smrdReconHitsUnused = SmrdResult->GetHitSelection(
"unused");
84 smrdReconHitsMatched = SmrdResult->GetHitSelection(
"matchedSmrdReconHits");
85 smrdReconHitsUsed = SmrdResult->GetHitSelection(
"used");
86 xyzReconTracks = SmrdResult->GetResultsContainer(
"final");
93 if (smrdReconHitsUnused) {
94 for (ND::THitSelection::iterator h = smrdReconHitsUnused->begin();
95 h != smrdReconHitsUnused->end(); ++h) {
96 ND::THandle<ND::THit> hit = *h;
103 if ((*h)->GetContributorCount() != 2) {
104 ND280Warn(
"warning: more or less than two smrd single hits contributed"
105 <<
" to this TReconHit; skipping this TReconHit");
110 ND::THandle<ND::THit> contrhit1 = (*h)->GetContributor(0);
111 ND::THandle<ND::THit> contrhit2 = (*h)->GetContributor(1);
113 if ((!contrhit1) || (!contrhit2)) {
114 ND280Warn(
"warning: failed get constituents for SMRD TRecon hit; skip "
115 <<
"this TReconHit");
122 reconHit->
Position = TLorentzVector(hit->GetPosition(), hit->GetTime());
124 TLorentzVector(hit->GetUncertainty(), hit->GetTimeUncertainty());
125 reconHit->
Charge = hit->GetCharge();
127 reconHit->
dZ = (*h)->GetPosition().Z() - contrhit1->GetPosition().Z();
128 reconHit->
dT = contrhit1->GetTime() - contrhit2->GetTime();
132 bool isTopWall = ND::TGeomInfo::SMRD().IsSMRDTopWall(hit);
133 bool isBottomWall = ND::TGeomInfo::SMRD().IsSMRDBottomWall(hit);
134 bool isRightWall = ND::TGeomInfo::SMRD().IsSMRDRightWall(hit);
135 bool isLeftWall = ND::TGeomInfo::SMRD().IsSMRDLeftWall(hit);
150 reconHit->
Yoke = ND::TGeomInfo::SMRD().GetYokeRingNumber(hit);
151 reconHit->
Layer = ND::TGeomInfo::SMRD().GetSMRDRingNumber(hit);
152 reconHit->
Tower = ND::TGeomInfo::SMRD().GetSMRDTowerNumber(hit);
153 reconHit->
Counter = ND::TGeomInfo::SMRD().GetSMRDScintNumber(hit);
156 ND::TChannelId chan = contrhit1->GetChannelId();
157 ND::TTFBChannelId tfbid(chan);
159 reconHit->
RMM = tfbid.GetRMM();
160 reconHit->
TFB = tfbid.GetTFB();
167 if (smrdReconHitsMatched) {
168 if (std::find(smrdReconHitsMatched->begin(),
169 smrdReconHitsMatched->end(),
170 *h) != smrdReconHitsMatched->end()) {
178 if (smrdReconHitsUsed) {
179 for (ND::THitSelection::iterator h = smrdReconHitsUsed->begin();
180 h != smrdReconHitsUsed->end(); h++) {
181 ND::THandle<ND::THit> hit = *h;
188 if ((*h)->GetContributorCount() != 2) {
189 ND280Warn(
"warning: more or less than two smrd single hits contributed"
190 <<
" to this TReconHit; skipping this TReconHit");
195 ND::THandle<ND::THit> contrhit1 = (*h)->GetContributor(0);
196 ND::THandle<ND::THit> contrhit2 = (*h)->GetContributor(1);
198 if (!contrhit1 || !contrhit2) {
199 ND280Warn(
"warning: failed get constituents for SMRD TRecon hit; "
200 <<
"skip this TReconHit");
207 reconHit->
Position = TLorentzVector(hit->GetPosition(), hit->GetTime());
209 TLorentzVector(hit->GetUncertainty(), hit->GetTimeUncertainty());
210 reconHit->
Charge = hit->GetCharge();
212 reconHit->
dZ = (*h)->GetPosition().Z() - contrhit1->GetPosition().Z();
213 reconHit->
dT = contrhit1->GetTime() - contrhit2->GetTime();
218 bool isTopWall = ND::TGeomInfo::SMRD().IsSMRDTopWall(hit);
219 bool isBottomWall = ND::TGeomInfo::SMRD().IsSMRDBottomWall(hit);
220 bool isRightWall = ND::TGeomInfo::SMRD().IsSMRDRightWall(hit);
221 bool isLeftWall = ND::TGeomInfo::SMRD().IsSMRDLeftWall(hit);
236 reconHit->
Yoke = ND::TGeomInfo::SMRD().GetYokeRingNumber(hit);
237 reconHit->
Layer = ND::TGeomInfo::SMRD().GetSMRDRingNumber(hit);
238 reconHit->
Tower = ND::TGeomInfo::SMRD().GetSMRDTowerNumber(hit);
239 reconHit->
Counter = ND::TGeomInfo::SMRD().GetSMRDScintNumber(hit);
242 ND::TChannelId chan = contrhit1->GetChannelId();
243 ND::TTFBChannelId tfbid(chan);
245 reconHit->
RMM = tfbid.GetRMM();
246 reconHit->
TFB = tfbid.GetTFB();
252 if (smrdReconHitsMatched) {
253 if (std::find(smrdReconHitsMatched->begin(),
254 smrdReconHitsMatched->end(),
255 *h) != smrdReconHitsMatched->end()) {
265 if (xyzReconTracks) {
266 bool isMC =
event.GetContext().IsMC();
268 for (ND::TReconObjectContainer::iterator t = xyzReconTracks->begin();
269 t != xyzReconTracks->end(); t++) {
270 ND::THandle<ND::TReconTrack> track = *t;
275 ND::THandle<ND::TTrackState> trackState = track->GetState();
283 ND::TReconNodeContainer &nodes = track->GetNodes();
285 ND::THandle<ND::TTrackState> frontState =
286 TrackingUtils::GetFirstState(*track);
291 ND::THandle<ND::TTrackState> backState =
292 TrackingUtils::GetLastState(*track);
297 ND::THandle<ND::THitSelection> hits = track->GetHits();
304 isoTrack->
Chi2 = track->GetQuality();
308 ND::THandle<ND::TRealDatum> totalCharge =
309 track->Get<ND::TRealDatum>(
"totalCharge");
312 track->Get<ND::TRealDatum>(
"totalCharge")->GetValue();
317 ND::THandle<ND::TRealDatum> smrdTimeRD =
318 track->Get<ND::TRealDatum>(
"averageHitTime");
321 track->Get<ND::TRealDatum>(
"averageHitTime")->GetValue();
324 isoTrack->
NHits = hits->size();
325 isoTrack->
NNodes = nodes.size();
326 isoTrack->
Status = track->CheckStatus(track->kSuccess);
327 isoTrack->
NDOF = track->GetNDOF();
328 isoTrack->
UniqueID = track->GetUniqueID();
331 std::string name(
"RECPACK_KalmanFilter");
332 if ((track->GetAlgorithmName().find(name) != std::string::npos) &&
333 (track->CheckStatus(track->kSuccess))) {
339 isoTrack->
FrontPos = frontState->GetPosition();
342 isoTrack->
BackPos = backState->GetPosition();
345 TVector3 backpos = backState->GetPosition().Vect();
346 TVector3 frontpos = frontState->GetPosition().Vect();
349 isoTrack->
Direction = trackState->GetDirection();
353 TVector3 diff = backpos - frontpos;
354 isoTrack->
Range = diff.Mag();
357 isoTrack->
ThetaAngle = trackState->GetDirection().Theta();
358 isoTrack->
PhiAngle = trackState->GetDirection().Phi();
362 TLorentzVector trueInitPos(-9999, -9999, -9999, -9999);
363 TLorentzVector trueFinalPos(-9999, -9999, -9999, -9999);
364 TLorentzVector trueInitMom(-9999, -9999, -9999, -9999);
366 int trueParentId = -999;
367 double truePurity = -9999.0;
368 double trueEff = -9999.0;
371 trueId = TrackTruthInfo::GetG4TrajIDHits(*hits, trueEff, truePurity);
373 ND::THandle<ND::TG4TrajectoryContainer> trajectoryContainer =
374 event.Get<ND::TG4TrajectoryContainer>(
"truth/G4Trajectories");
375 ND::THandle<ND::TG4Trajectory> g4traj(0);
376 if (trajectoryContainer)
377 g4traj = trajectoryContainer->GetTrajectory(trueId);
380 trueInitPos = g4traj->GetInitialPosition();
381 trueFinalPos = g4traj->GetFinalPosition();
382 trueInitMom = g4traj->GetInitialMomentum();
383 truePDG = g4traj->GetPDGEncoding();
384 trueParentId = g4traj->GetParentId();
390 gGeoManager->FindNode(trueInitPos.X(), trueInitPos.Y(), trueInitPos.Z());
391 gGeoManager->GetCurrentNodeId();
397 gGeoManager->FindNode(trueFinalPos.X(), trueFinalPos.Y(),
399 gGeoManager->GetCurrentNodeId();
404 isoTrack->
TrueId = trueId;
TLorentzVector FrontPosVariance
Variance on the position of the 'first' TTrackState of the corresponding ND::TReconTrack.
double dT
The difference between the reconstructed ND::THit times between the two contributors.
double avgtime
Average hit time of the corresponding ND::TReconTrack.
virtual void InitializeModule()
Initialize Module, override if necessary.
UInt_t UniqueID
The Unique ID of the corresponding ND::TReconTrack, used for global-subdetector matching.
int NHits
Number of ND::THits which are associated with the corresponding ND::TReconTrack.
int Status
The reported Status of the corresponding ND::TReconTrack.
double EDeposit
The total reconstructed charge of the corresponding ND::TReconTrack.
TLorentzVector PositionUncertainty
The uncertainty on the reconstructed 4-position of the corresponding double ended ND::THit...
ClassImp(ND::TBeamSummaryDataModule::TBeamSummaryData)
Int_t fNSmrdReconHits
The number of SMRD TReconHits.
std::string fDescription
A longish descrition of the analysis.
Both-sided SMRD TReconHit that isn't included in any reconstructed track.
virtual bool FillTree(ND::TND280Event &)
Fill all the stuff that goes in the output tree.
TVector3 DirectionVariance
Variance on the direction the TTrackState which is the state of the corresponding ND::TReconTrack...
virtual Bool_t ProcessFirstEvent(ND::TND280Event &event)
Is called after the first event is loaded in.
TLorentzVector TrueInitMom
For MC events: The true initial momentum of the corresponding ND::TG4Trajectory.
double PhiAngle
Polar coordinate phi of the TSmrdIsoTrack::Direction.
double TrueHitPurity
For MC events: The 'cleanliness' of the ND::THits which make up the corresponding ND::TReconTrack...
double dZ
The difference in Z between the combined ND::THit(double ended bars) and the first contributor ND::T...
TLorentzVector TrueFinalPos
For MC events: The true final position of the corresponding ND::TG4Trajectory.
int TrueInitDet
For MC events: The subdetector in which TSmrdIsoTrack::TrueInitPos lies.
bool IsUsed
Designates if the corresponding ND::THit was used in a reconstructed object.
TLorentzVector TrueInitPos
For MC events: The true initial position of the corresponding ND::TG4Trajectory.
Int_t fBufferSize
Buffer Size for TBranch.
int Tower
The SMRD tower number.
int TrueFinalDet
For MC events: The subdetector in which TSmrdIsoTrack::TrueFinalPos lies.
int KalmanStatus
Kalman filter refit result for the corresponding ND::TReconTrack.
Int_t fNSmrdIsoTracks
The number of SMRD isolated tracks.
std::string fCVSID
Defined if an official tagged version.
TClonesArray * fSmrdReconHits
The SMRD TReconHits.
TLorentzVector BackPosVariance
Variance on the position of the 'last' TTrackState of the corresponding ND::TReconTrack.
int NNodes
Number of TReconNodes which are constituents of the corresponding ND::TReconTrack.
UInt_t RMM
The RMM Id of the channel corresponding to the first contributor hit.
int Yoke
The SMRD yoke number.
void SetNameTitle(char const *name, char const *title)
double Range
The spacial distance between TSmrdIsoTrack::FrontPos and TSmrdIsoTrack::BackPos.
double ThetaAngle
Polar coordinate theta of the TSmrdIsoTrack::Direction.
UInt_t TFB
The TFB Id of the channel corresponding to the first contributor hit.
TLorentzVector Position
The reconstructed 4-position of the corresponding double ended ND::THit.
double TrueHitEff
For MC events: The 'completeness' of the ND::THits which make up the corresponding ND::TReconTrack...
int NDOF
The Number of Degrees of Freedom in the reconstruction of the corresponding ND::TReconTrack.
double Chi2
The reported reconstruction 'quality' of the corresponding ND::TReconTrack.
TLorentzVector FrontPos
Position of the 'first' TTrackState of the corresponding ND::TReconTrack.
double ContribCharge[2]
The reconstructed charges from each contributor of the double ended bar.
TSmrdReconModule(const char *name="SMRD", const char *title="SMRD Recon Module")
int Wall
The SMRD wall in which this the corresponding ND::THit resides. Is assigned a value from TSmrdReconMo...
Int_t fSplitLevel
Split Level for TBranch.
std::string AlgorithmName
Name of the reconstruction algorithm.
int TrueId
For MC events: The Id of the corresponding ND::TG4Trajectory.
int TruePDG
For MC events: The PDG code of the true particle.
std::string fCVSTagName
Defined if an official tagged version.
double Charge
The reconstructed charge of the corresponding double ended ND::THit.
int Counter
The SMRD scintillator number.
int Layer
The SMRD ring number.
ESubdetector PathToSubdetector(const std::string path)
TVector3 Direction
Direction of the TTrackState which is the state of the corresponding ND::TReconTrack.
bool IsInnerMatched
Designates if the corresponding ND::THit was matched.
int TrueParentId
For MC events: The Id of the true trajectory's parent ND::TG4Trajectory.
virtual ~TSmrdReconModule()
TLorentzVector BackPos
Position of the 'last' TTrackState of the corresponding ND::TReconTrack.
virtual void InitializeBranches()
Initialize Branches. Don't do anything else in this function.
TClonesArray * fSmrdIsoTracks
The SMRD isolated tracks.