star-travex
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StiHifyAnalysisTreeMaker.cxx
Go to the documentation of this file.
2 
3 
5 {
6  createTree();
7  clearTreeStructs(); // prep the structures for running
8 }
9 
10 
12 {
13  // This creates the tree object, than populates 3 different branches, each with the same leaves
14  // Each of the branches corresponds to either Any hit, a hit accepted by Sti, or a hit rejected by Sti
15  aTree = new TTree("pullAnaTree","Tree for Pull Error Analysis");
16  aTree->Branch("AnyHit",&errorInfo.errorMag,"errorMag/F:pull/F:residual/F:eta/F:pT/F:phi/F:z/F");
17  aTree->Branch("AcceptedHit",&errorInfoAcc.errorMag,"errorMag/F:pull/F:residual/F:eta/F:pT/F:phi/F:z/F");
18  aTree->Branch("RejectedHit",&errorInfoRej.errorMag,"errorMag/F:pull/F:residual/F:eta/F:pT/F:phi/F:z/F");
19 }
20 
21 
22 void StiHifyAnalysisTreeMaker::FillTree(const StiHifyEvent &event, StiNodeHitStatus hitStatus, bool onlyNodesWithCandidates)
23 {
24  for (const auto& kalmTrack : event.GetTStiKalmanTracks()) // Loop over tracks in event
25  {
26  for (const auto& trkNode : kalmTrack.GetNodes()) // Loop over nodes in track
27  {
28  // Ignore nodes with 0 candidate hits when requested by user
29  if ( onlyNodesWithCandidates && !trkNode.GetCandidateProxyHits().size() )
30  continue;
31 
32  switch (hitStatus) // Decide what type of nodes you want to look at in FillTree iteration
33  {
35  FillTree(trkNode, errorInfo);
36  break;
38  if(trkNode.GetHit()) // Check if accepted
39  FillTree(trkNode, errorInfoAcc);
40  break;
42  if(!trkNode.GetHit()) //Check if not accepted
43  FillTree(trkNode, errorInfoRej);
44  break;
45  default:
46  Error("FillHists", "Internal type of Sti hit assigned to this node is not specified. "
47  "Histograms won't be filled");
48  break;
49  }
50  }
51  }
52 }
53 
55 {
56  if (trkNode.GetVolumeName().empty() || !trkNode.IsInsideVolume())
57  return;
58 
59  if (!fPrgOptions.MatchedVolName(trkNode.GetVolumeName()) ) // Limit to only volumes in volumeList
60  return;
61 
62  // Set variables needed by tree in the structure. All others are -999.
63  eI.errorMag = trkNode.GetProjError().Mag();
64  eI.residual = trkNode.CalcDistanceToClosestHit();
65  eI.pull = eI.residual/eI.errorMag;
66  eI.eta = trkNode.GetTrackP().PseudoRapidity();
67  eI.pT = trkNode.GetTrackP().Perp();
68  eI.phi = trkNode.GetTrackP().Phi();
69  eI.z = trkNode.GetTrackP().z();
70 
71  aTree->Fill(); // push structures to tree
72  clearTreeStructs(); // reset structure for next node
73 
74 }
75 
77 {
78  aTree->Write();
79 }
80 
82 {
83  // Set all values to default for next node
84  errorInfoRej.errorMag = -999;
85  errorInfoRej.residual = -999;
86  errorInfoRej.pull = -999;
87  errorInfoRej.eta = -999;
88  errorInfoRej.pT = -999;
89  errorInfoRej.phi = -999;
90  errorInfoRej.z = -999;
91  errorInfo.errorMag =-999;
92  errorInfo.residual = -999;
93  errorInfo.pull = -999;
94  errorInfo.eta = -999;
95  errorInfo.pT = -999;
96  errorInfo.phi = -999;
97  errorInfo.z = -999;
98  errorInfoAcc.errorMag =-999;
99  errorInfoAcc.residual = -999;
100  errorInfoAcc.pull = -999;
101  errorInfoAcc.eta = -999;
102  errorInfoAcc.pT = -999;
103  errorInfoAcc.phi = -999;
104  errorInfoAcc.z = -999;
105 }
void FillTree(const StiHifyEvent &event, StiNodeHitStatus hitStatus=StiNodeHitStatus::Any, bool onlyNodesWithCandidates=false)
const StiHifyPrgOptions & fPrgOptions
Command line arguments and options requested by the user.
Processes and controls user options provided in the command line.
std::string GetVolumeName() const
bool MatchedVolName(const std::string &volName) const
Note that the function returns true when the internal list of regex'es formed by the user specified o...
StiNodeHitStatus
const std::vector< TStiKalmanTrack > & GetTStiKalmanTracks() const
Definition: TStiEvent.h:38
double CalcDistanceToClosestHit() const
StiHifyAnalysisTreeMaker(const StiHifyPrgOptions &)
const TVector3 & GetTrackP() const
bool IsInsideVolume() const
const TVector3 & GetProjError() const