3 #include <TTrackState.hxx>
5 #include "TIntegerDatum.hxx"
6 #include "TRealDatum.hxx"
7 #include "TReconCluster.hxx"
8 #include "TrackTruthInfo.hxx"
21 #include "../cvstags/TFgdOnlyModule.cxx"
25 const ND::TReconNodeContainer &nodes = track->GetNodes();
26 if (nodes.size() < 2)
return -1;
29 ND::THandle<ND::TTrackState> start = (*(nodes.begin()))->GetState();
30 ND::THandle<ND::TTrackState> stop = (*(nodes.end() - 1))->GetState();
33 TVector3 beginning = start->GetPosition().Vect();
34 TVector3 end = stop->GetPosition().Vect();
35 return (beginning - end).Mag();
48 fPids.push_back(
"_Proton");
49 fPids.push_back(
"_Pion");
50 fPids.push_back(
"_Muon");
75 fXZTracks[i] =
new TClonesArray(
"ND::TFgdOnlyModule::TFgd2DIsoTrack", 200);
77 fYZTracks[i] =
new TClonesArray(
"ND::TFgdOnlyModule::TFgd2DIsoTrack", 200);
79 fXYZTracks[i] =
new TClonesArray(
"ND::TFgdOnlyModule::TFgd3DIsoTrack", 200);
83 new TClonesArray(
"ND::TFgdOnlyModule::TFgd2DIsoTrack", 200);
86 new TClonesArray(
"ND::TFgdOnlyModule::TFgd2DIsoTrack", 200);
89 new TClonesArray(
"ND::TFgdOnlyModule::TFgd3DIsoTrack", 200);
93 f3DShowers =
new TClonesArray(
"ND::TFgdOnlyModule::TFgd3DShowerPID", 200);
96 f2DClustersXZ =
new TClonesArray(
"ND::TFgdOnlyModule::TFgd2DCluster", 200);
98 f2DClustersYZ =
new TClonesArray(
"ND::TFgdOnlyModule::TFgd2DCluster", 200);
139 Form(
"NXZTracksAllFGD%s/I", algoName),
fBufferSize);
144 Form(
"NYZTracksAllFGD%s/I", algoName),
fBufferSize);
149 Form(
"NXYZTracksAllFGD%s/I", algoName),
fBufferSize);
153 ->SetTitle(
"These tracks use only hits unused by the TPC+FGD fits");
157 ->SetTitle(
"These tracks use only hits unused by the TPC+FGD fits");
161 ->SetTitle(
"These tracks use only hits unused by the TPC+FGD fits");
165 ->SetTitle(
"All and only FGD hits used for these tracks");
169 ->SetTitle(
"All and only FGD hits used for these tracks");
173 ->SetTitle(
"All and only FGD hits used for these tracks");
177 ->SetTitle(
"Number of Showers");
180 ->SetTitle(
"Number of 2D constituents of showers");
183 ->SetTitle(
" Number of 2D constituents of showers");
186 ->SetTitle(
" Showers");
190 ->SetTitle(
" 2D constituents of showers");
193 ->SetTitle(
" 2D constituents of showers");
226 ND::THandle<ND::TAlgorithmResult> FgdResult =
event.GetFit(
"fgdRecon");
230 if (!FgdResult)
return true;
237 sprintf(buf,
"xzFgdReconTracks%s", algoName);
238 ND::THandle<ND::TReconObjectContainer> xzReconTracks =
239 FgdResult->GetResultsContainer(buf);
240 sprintf(buf,
"yzFgdReconTracks%s", algoName);
241 ND::THandle<ND::TReconObjectContainer> yzReconTracks =
242 FgdResult->GetResultsContainer(buf);
243 sprintf(buf,
"fittedFgdReconTracks%s", algoName);
244 ND::THandle<ND::TReconObjectContainer> xyzReconTracks =
245 FgdResult->GetResultsContainer(buf);
247 sprintf(buf,
"xzFgdReconTracks_allFGD%s", algoName);
248 ND::THandle<ND::TReconObjectContainer> xzReconTracksAllFGD =
249 FgdResult->GetResultsContainer(buf);
250 sprintf(buf,
"yzFgdReconTracks_allFGD%s", algoName);
251 ND::THandle<ND::TReconObjectContainer> yzReconTracksAllFGD =
252 FgdResult->GetResultsContainer(buf);
253 sprintf(buf,
"fittedFgdReconTracks_allFGD%s", algoName);
254 ND::THandle<ND::TReconObjectContainer> xyzReconTracksAllFGD =
255 FgdResult->GetResultsContainer(buf);
258 for (ND::TReconObjectContainer::iterator track = xzReconTracks->begin();
259 track != xzReconTracks->end(); track++) {
260 ND::THandle<ND::TReconTrack> tr = *track;
262 ND::THandle<ND::TTrackState> state = tr->GetState();
263 if (!state)
continue;
271 for (ND::TReconObjectContainer::iterator track = yzReconTracks->begin();
272 track != yzReconTracks->end(); track++) {
273 ND::THandle<ND::TReconTrack> tr = *track;
275 ND::THandle<ND::TTrackState> state = tr->GetState();
276 if (!state)
continue;
284 if (xyzReconTracks) {
285 for (ND::TReconObjectContainer::iterator track = xyzReconTracks->begin();
286 track != xyzReconTracks->end(); track++) {
287 ND::THandle<ND::TReconTrack> tr = *track;
289 ND::THandle<ND::TTrackState> state = tr->GetState();
290 if (!state)
continue;
299 if (xzReconTracksAllFGD) {
300 for (ND::TReconObjectContainer::iterator track =
301 xzReconTracksAllFGD->begin();
302 track != xzReconTracksAllFGD->end(); track++) {
303 ND::THandle<ND::TReconTrack> tr = *track;
305 ND::THandle<ND::TTrackState> state = tr->GetState();
306 if (!state)
continue;
313 if (yzReconTracksAllFGD) {
314 for (ND::TReconObjectContainer::iterator track =
315 yzReconTracksAllFGD->begin();
316 track != yzReconTracksAllFGD->end(); track++) {
317 ND::THandle<ND::TReconTrack> tr = *track;
319 ND::THandle<ND::TTrackState> state = tr->GetState();
320 if (!state)
continue;
328 if (xyzReconTracksAllFGD) {
329 for (ND::TReconObjectContainer::iterator track =
330 xyzReconTracksAllFGD->begin();
331 track != xyzReconTracksAllFGD->end(); track++) {
332 ND::THandle<ND::TReconTrack> tr = *track;
334 ND::THandle<ND::TTrackState> state = tr->GetState();
335 if (!state)
continue;
345 ND::THandle<ND::TReconObjectContainer> fgd3DShowers =
346 FgdResult->GetResultsContainer(
"FGDShowerPIDs");
347 std::vector<ND::THandle<ND::TReconObjectContainer> > fgd2DClustersXZ,
349 fgd2DClustersXZ.push_back(
350 FgdResult->GetResultsContainer(
"combi_basic_fgd1_xz"));
351 fgd2DClustersYZ.push_back(
352 FgdResult->GetResultsContainer(
"combi_basic_fgd1_yz"));
353 fgd2DClustersXZ.push_back(
354 FgdResult->GetResultsContainer(
"combi_basic_fgd2_xz"));
355 fgd2DClustersYZ.push_back(
356 FgdResult->GetResultsContainer(
"combi_basic_fgd2_yz"));
360 ND280NamedVerbose(
"TFgdOnlyModule",
"Have fgd3DShowers");
361 for (ND::TReconObjectContainer::iterator pidIter = fgd3DShowers->begin();
362 pidIter != fgd3DShowers->end(); pidIter++) {
363 ND::THandle<ND::TReconPID> pid = *pidIter;
372 for (std::vector<ND::THandle<ND::TReconObjectContainer> >::iterator it =
373 fgd2DClustersXZ.begin();
374 it != fgd2DClustersXZ.end(); it++) {
375 ND::THandle<ND::TReconObjectContainer> roc = (*it);
377 for (ND::TReconObjectContainer::iterator objIter = roc->begin();
378 objIter != roc->end(); objIter++) {
379 ND::THandle<ND::TReconCluster> cluster = *objIter;
386 for (std::vector<ND::THandle<ND::TReconObjectContainer> >::iterator it =
387 fgd2DClustersYZ.begin();
388 it != fgd2DClustersYZ.end(); it++) {
389 ND::THandle<ND::TReconObjectContainer> roc = (*it);
391 for (ND::TReconObjectContainer::iterator objIter = roc->begin();
392 objIter != roc->end(); objIter++) {
393 ND::THandle<ND::TReconCluster> cluster = *objIter;
405 ND::THandle<ND::TTrackState> state,
409 ND::THandle<ND::THitSelection> hits = tr->GetHits();
410 isoTrack->
NHits = hits->size();
413 for (ND::THitSelection::iterator hit = hits->begin(); hit != hits->end();
415 charge += (*hit)->GetCharge();
419 TLorentzVector posn = state->GetPosition();
421 TLorentzVector dposn = state->GetPositionVariance();
424 TVector3 dir = state->GetDirection();
427 if (Axis ==
'X') isoTrack->
Angle = atan2(dir.X(), dir.Z());
428 if (Axis ==
'Y') isoTrack->
Angle = atan2(dir.Y(), dir.Z());
432 for (ND::THitSelection::iterator hit = hits->begin(); hit != hits->end();
434 TVector3 *pos =
new TVector3((*hit)->GetPosition());
438 isoTrack->
TrajId = TrackTruthInfo::GetG4TrajectoryID(
443 ND::THandle<ND::TTrackState> state,
449 ND::THandle<ND::THitSelection> hits = tr->GetHits();
450 isoTrack->
NHits = hits->size();
453 for (ND::THitSelection::iterator hit = hits->begin(); hit != hits->end();
455 charge += (*hit)->GetCharge();
459 TLorentzVector posn = state->GetPosition();
461 TLorentzVector dposn = state->GetPositionVariance();
464 TVector3 dir = state->GetDirection();
469 ND::THandle<ND::TReconPID> pid =
fFGDPid->ApplyPID(tr);
471 ND::THandle<ND::TRealDatum> buf;
472 buf = pid->Get<ND::TRealDatum>(
"fgdPidWgt_EvsXPull_Muon");
474 isoTrack->
muonPull = buf->GetValue();
478 buf = pid->Get<ND::TRealDatum>(
"fgdPidWgt_EvsXPull_Pion");
480 isoTrack->
pionPull = buf->GetValue();
484 buf = pid->Get<ND::TRealDatum>(
"fgdPidWgt_EvsXPull_Proton");
490 ND280NamedVerbose(
"TFgdOnlyModule",
"Muon pull " << isoTrack->
muonPull);
491 ND280NamedVerbose(
"TFgdOnlyModule",
"Pion pull " << isoTrack->
pionPull);
492 ND280NamedVerbose(
"TFgdOnlyModule",
"Proton pull " << isoTrack->
protonPull);
494 isoTrack->
TrajId = TrackTruthInfo::GetG4TrajectoryID(
499 ND::THandle<ND::TReconCluster> cluster) {
500 TempObject->
Status = cluster->GetStatus();
501 TempObject->
NDOF = cluster->GetNDOF();
502 TempObject->
Quality = cluster->GetQuality();
503 TempObject->
Position = cluster->GetPosition();
504 TempObject->
EDeposit = cluster->GetEDeposit();
505 TempObject->
NumHits = cluster->GetHits()->size();
507 TempObject->
Range = cluster->Get<ND::TRealDatum>(
"range")->GetValue();
509 cluster->Get<ND::TRealDatum>(
"avgHitTime")->GetValue();
514 THandle<ND::TRealDatum> V=cluster->Get<ND::TRealDatum>(
"startPosition");
522 V=cluster->Get<ND::TRealDatum>(
"endPosition");
523 TempObject->
EndPosition.SetXYZ((*V)[0],(*V)[1],(*V)[2]);
528 V=cluster->Get<ND::TRealDatum>(
"pcaDirection");
529 TempObject->
PCADirection.SetXYZ((*V)[0],(*V)[1],(*V)[2]);
534 TrackTruthInfo::GetG4Trajectories(*(cluster->GetHits()));
538 ND::THandle<ND::TReconPID> pid) {
539 ND280NamedVerbose(
"TFgdOnlyModule",
"Filling next shower");
540 ND::TReconObjectContainer altCon = pid->GetAlternates();
541 if (altCon.size() != 1) {
542 ND280NamedWarn(
"TFgdOnlyModule",
"Expect 1 alternative hypothesis for FGD Shower PID, have "
547 ND::THandle<ND::TReconPID> alt = altCon.at(0);
549 ND280NamedWarn(
"TFgdOnlyModule",
"Unable to get alternate hypothesis");
553 ND::THandle<ND::TReconObjectContainer> cons = pid->GetConstituents();
554 if (cons->size() != 1) {
555 ND280NamedWarn(
"TFgdOnlyModule",
"Expect 1 constituent for FGD Shower PID, have " << cons->size());
559 ND::THandle<ND::TReconShower> shower = cons->at(0);
561 ND280NamedWarn(
"TFgdOnlyModule",
"Couldn't cast constituent to TReconShower");
566 if (pid->GetDirection().Z() > 0) {
574 TempObject->
Status = pid->GetStatus();
575 TempObject->
NDOF = pid->GetNDOF();
576 TempObject->
Quality = pid->GetQuality();
577 TempObject->
NumHits = pid->GetHits()->size();
579 shower->Get<ND::TRealDatum>(
"MatchingLikelihood3D")->GetValue();
584 shower->Get<ND::TRealDatum>(
"pcaValues")->at(0),
585 shower->Get<ND::TRealDatum>(
"pcaValues")->at(1),
586 shower->Get<ND::TRealDatum>(
"pcaValues")->at(2)
590 shower->Get<ND::TRealDatum>(
"Circularity")->GetValue();
592 TrackTruthInfo::GetG4Trajectories(*(pid->GetHits()));
596 ND280NamedVerbose(
"TFgdOnlyModule",
"Filling next shower hypothesis");
599 ND::THandle<ND::TReconObjectContainer> cons = hyp->GetConstituents();
600 if (cons->size() != 1) {
601 ND280NamedWarn(
"TFgdOnlyModule",
"Expect 1 constituent for FGD Shower PID, have " << cons->size());
605 ND::THandle<ND::TReconShower> shower = cons->at(0);
607 ND280NamedWarn(
"TFgdOnlyModule",
"Couldn't cast constituent to TReconShower");
611 ND::THandle<ND::TShowerState> state = shower->GetState();
613 ND280NamedWarn(
"TFgdOnlyModule",
"Couldn't get state for shower");
622 shower->Get<ND::TRealDatum>(
"QAvgInThirds")->at(0),
624 shower->Get<ND::TRealDatum>(
"QAvgInThirds")->at(1),
626 shower->Get<ND::TRealDatum>(
"QAvgInThirds")->at(2)
636 shower->Get<ND::TRealDatum>(
"SpreadInThirds")->at(0),
638 shower->Get<ND::TRealDatum>(
"SpreadInThirds")->at(1),
640 shower->Get<ND::TRealDatum>(
"SpreadInThirds")->at(2)
653 output.
EDeposit = shower->GetEDeposit();
656 output.
Direction = state->GetDirection();
658 output.
Position = state->GetPosition();
TVector3 Direction
Direection.
Int_t fN2DClustersYZ
Number of 2D constituents of showers.
int NumHits
The number of hits contributing to this cluster.
TClonesArray ** fXZTracksAllFGD
TLorentzVector OriginVariance
Variance on origin.
int NumHits
The number of hits contributing to this cluster.
TVector3 Direction
Identified direction of the shower, found using PCA.
TClonesArray ** fYZTracks
std::string AlgorithmName
Algorithm name.
TFgd3DShowerHyp Information on a specific hypothesis of an FGD shower.
TVector3 ConeAngle
Opening angle of the cone describing this shower.
double getTrackLength(ND::THandle< ND::TReconTrack > track)
TLorentzVector Position
Identified start position of the shower.
TClonesArray ** fXYZTracksAllFGD
virtual ~TFgd2DIsoTrack()
ClassImp(ND::TBeamSummaryDataModule::TBeamSummaryData)
std::vector< const char * > fTrackAlgorithms
double EDeposit
Energy deposited in this shower.
std::map< int, int > Trajectories
Map of true trajectory IDs to the number of G4 contributors that contributed to this cluster...
std::string fDescription
A longish descrition of the analysis.
TFgdOnlyModule(const char *name="FGDOnly", const char *title="FGD Only Recon Module")
TVector3 DirectionVar
Variance on the direction of the shower.
TLorentzVector Origin
Origin.
TClonesArray * f2DClustersYZ
2D constituents of showers
TClonesArray * f2DClustersXZ
2D constituents of showers
double muonPull
Muon pull.
std::vector< const char * > fPids
double MatchingLikelihood3D
The MVA likelihood value returned when matching 2D clusters in the XZ and YZ views into a single 3D c...
TLorentzVector Position
Charge-weighted position of the cluster.
std::vector< TVector3 * > HitPositions
Hit positions.
TClonesArray * f3DShowers
Showers.
TLorentzVector PositionVar
Variance on the start position of the shower.
virtual ~TFgd3DShowerHyp()
Int_t fN2DClustersXZ
Number of 2D constituents of showers.
Int_t fBufferSize
Buffer Size for TBranch.
double Cleanliness
Cleanlikness.
Int_t fN3DShowers
Number of Showers.
TLorentzVector Origin
Origin.
double Completeness
Completeness.
TFgd3DShowerHyp Fill3DShowerHyp(ND::THandle< ND::TReconPID > hyp)
double SumCharge
Sum of charge.
TVector3 QAvgInThirds
Hits are split into three groups based on their distance from the start of the shower.
virtual ~TFgdOnlyModule()
TVector3 Direction
Direection.
std::string fCVSID
Defined if an official tagged version.
void Fill2DIsoTrack(ND::THandle< ND::TReconTrack > tr, ND::THandle< ND::TTrackState > state, TFgd2DIsoTrack *isoTrack, char Axis)
Int_t * fNXZTracksAllFGD
All and only FGD hits used for these tracks.
TClonesArray ** fXZTracks
int TrajId
Trajectory id`.
int NDOF
The number of degrees of freedom in the reconstruction.
double Circularity
Dan Scully's Circularity variable, adapted for FGDs.
TClonesArray ** fXYZTracks
std::string AlgorithmName
void Fill3DShower(TFgd3DShowerPID *TempObject, ND::THandle< ND::TReconPID > pid)
double EDeposit
The energy deposited in the cluster.
int NDOF
The number of degrees of freedom in the reconstruction.
void SetNameTitle(char const *name, char const *title)
Int_t * fNXZTracks
These tracks use only hits unused by the TPC+FGD fits.
double protonPull
Proton pull.
TVector3 SpreadInThirds
Hits are split into three groups based on their distance from the start of the shower.
double Range
Range of shower along PCADirection.
TFgd2DCluster The main object that contains information on clusters of hits after the 2D reconstructi...
TFgd3DShowerPID Information on an object reconstructed using the FGD shower-based reconstruction...
virtual ~TFgd3DShowerPID()
TLorentzVector OriginVariance
Variance on origin.
TFgd3DShowerHyp Hyp1
Information assuming the particle is forward-going.
Int_t fSplitLevel
Split Level for TBranch.
double Quality
The goodness of fit for the reconstruction.
TVector3 StartPosition
Identified "start" position of the cluster, from extrapolating along PCADrection. ...
void Fill2DCluster(TFgd2DCluster *TempObject, ND::THandle< ND::TReconCluster > cluster)
int Status
The fit status.
TClonesArray ** fYZTracksAllFGD
virtual Bool_t ProcessFirstEvent(ND::TND280Event &event)
Is called after the first event is loaded in.
TVector3 EndPosition
Identified "end" position of the cluster, from extrapolating along PCADirection.
std::string fCVSTagName
Defined if an official tagged version.
Int_t * fNYZTracks
These tracks use only hits unused by the TPC+FGD fits.
double Quality
The goodness of fit for the reconstruction.
virtual bool FillTree(ND::TND280Event &)
Fill all the stuff that goes in the output tree.
void Fill3DIsoTrack(ND::THandle< ND::TReconTrack > tr, ND::THandle< ND::TTrackState > state, TFgd3DIsoTrack *isoTrack)
double Cleanliness
Cleanlikness.
double pionPull
Pion pull.
int TrajId
Trajectory id`.
TVector3 PCADirection
Primary PCA eigenvector, associated with the direction of the cluster.
std::map< int, int > Trajectories
Map of true trajectory IDs to the number of G4 contributors that contributed to this cluster...
Int_t * fNXYZTracks
These tracks use only hits unused by the TPC+FGD fits.
double SumCharge
Charge Sum.
double Completeness
Completeness.
virtual void InitializeBranches()
Initialize Branches. Don't do anything else in this function.
TVector3 PCAEigenValues
The three PCA eigenvalues.
int Status
The fit status.
TFgd3DShowerHyp Hyp2
Information assuming the particle is backward-going.
Int_t * fNYZTracksAllFGD
All and only FGD hits used for these tracks.
double AvgHitTime
Average time of hits in the cluster.
TVector3 ConeAngleVar
Variance on the cone opening angle.
virtual ~TFgd3DIsoTrack()
Int_t * fNXYZTracksAllFGD
All and only FGD hits used for these tracks.