star-travex
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
VertexRootFile.cxx
Go to the documentation of this file.
1 #include <float.h>
2 
3 #include "TClonesArray.h"
4 
5 #include "StMuDSTMaker/COMMON/StMuDst.h"
6 #include "StMuDSTMaker/COMMON/StMuPrimaryVertex.h"
7 #include "StMuDSTMaker/COMMON/StMuMcVertex.h"
8 
14 
15 
16 VertexRootFile::VertexRootFile(tvx::ProgramOptions& prgOpts, Option_t *option, const char *ftitle, Int_t compress) :
17  tvx::RootFile(prgOpts, option, ftitle, compress)
18 {
19  Add( new StarEventHistContainer("event", this) );
20  Add( new StarVertexHistContainer("vertex", this) );
21  Add( new DecayVertexHists("vertex_decay_kaon", this) );
22  Add( new DecayVertexHists("vertex_decay_lambda", this) );
23  Add( new StarVertexHftHistContainer("vertex_hft", this) );
24  Add( new StarVertexHistContainer("vertex_maxrank", this) );
25 
26  // When done creating hist containers make parent TDirectoryFile the current one
27  cd();
28 }
29 
30 
31 void VertexRootFile::FillHists(const StMuDst &event)
32 {
33  hc<StarEventHistContainer>("event")->FillHists(event);
34 
35  // Currently consider only one primary vertex with idTruth = 1
36  int idTruth = 1;
37  TClonesArray *muMcVertices = event.mcArray(0);
38  StMuMcVertex *mcVertex = static_cast<StMuMcVertex*>(muMcVertices->UncheckedAt(idTruth - 1));
39 
40  TClonesArray *primaryVertices = event.primaryVertices();
41  int numPrimaryVertices = primaryVertices->GetEntriesFast();
42  StMuPrimaryVertex *recoVertex = nullptr;
43  StMuPrimaryVertex *recoVertexMaxRank = nullptr;
44  double maxRank = -DBL_MAX;
45 
46  // Loop over primary verticies in the event
47  for (int iVertex = 0; iVertex < numPrimaryVertices; iVertex++)
48  {
49  StMuPrimaryVertex *testRecoVertex = (StMuPrimaryVertex *) primaryVertices->UncheckedAt(iVertex);
50 
51  // Theoretically, there can be other reco vertices with the same truth id
52  // but for now we consider the first in the list matching the id of the
53  // simulated vertex
54  if (testRecoVertex && testRecoVertex->idTruth() == mcVertex->Id()) {
55  recoVertex = testRecoVertex;
56  }
57 
58  if (testRecoVertex->ranking() > maxRank) {
59  maxRank = testRecoVertex->ranking();
60  recoVertexMaxRank = testRecoVertex;
61  }
62  }
63 
64  hc<StarEventHistContainer>("event")->FillEfficyHists(event, *mcVertex, recoVertex, recoVertexMaxRank);
65 }
66 
67 
68 void VertexRootFile::FillHists(const StMuPrimaryVertex &vertex, const StMuMcVertex* mcVertex)
69 {
70  hc<StarVertexHistContainer>("vertex")->FillHists(vertex, mcVertex);
71 }
72 
73 
74 void VertexRootFile::FillHists(const StMuPrimaryVertex &vertex, const std::vector<TDecayVertex>& decayVertices)
75 {
76  for (const auto& decayVtx : decayVertices)
77  {
78  switch(decayVtx.parent)
79  {
80  case DecayParticle_t::Lambda:
81  case DecayParticle_t::AntiLambda:
82  hc<DecayVertexHists>("vertex_decay_lambda")->FillHists(vertex, decayVtx);
83  break;
84  case DecayParticle_t::Kaon:
85  hc<DecayVertexHists>("vertex_decay_kaon")->FillHists(vertex, decayVtx);
86  break;
87  }
88  }
89 }
90 
91 
92 void VertexRootFile::FillHistsHftTracks(const StMuPrimaryVertex &vertex, const StMuMcVertex* mcVertex)
93 {
94  hc<StarVertexHistContainer>("vertex_hft")->FillHists(vertex, mcVertex);
95 }
96 
97 
98 void VertexRootFile::FillHistsMaxRank(const StMuPrimaryVertex &vertex, const StMuMcVertex* mcVertex)
99 {
100  hc<StarVertexHistContainer>("vertex_maxrank")->FillHists(vertex, mcVertex);
101 }
VertexRootFile(tvx::ProgramOptions &prgOpts, Option_t *option="", const char *ftitle="", Int_t compress=1)
void FillHistsMaxRank(const StMuPrimaryVertex &vertex, const StMuMcVertex *mcVertex=nullptr)
void FillHistsHftTracks(const StMuPrimaryVertex &vertex, const StMuMcVertex *mcVertex=nullptr)
void FillHists(const StMuDst &event)