star-travex
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
StarVertexHistContainer.cxx
Go to the documentation of this file.
1 #include "TH1I.h"
2 #include "TH2I.h"
3 
5 
6 #include "StMuDSTMaker/COMMON/StMuPrimaryVertex.h"
7 #include "StMuDSTMaker/COMMON/StMuMcVertex.h"
8 
9 
10 StarVertexHistContainer::StarVertexHistContainer(const std::string name, TDirectory* motherDir, const std::string option) :
11  tvx::HistContainer(name, motherDir, option)
12 {
13  Add( new TH1I("hNumTracksToVertex", "Number of Tracks Assigned to Vertex", 50, 0, 50) );
14  Add( new TH1F("hVertexRank", "Vertex Rank", 100, -100, 100) );
15 
16  Add( new TH1I("hVertexX", "; Reco Vertex X Position, cm; Counts; ", 50, -1, 1) );
17  Add( new TH1I("hVertexY", "; Reco Vertex Y Position, cm; Counts; ", 50, -1, 1) );
18  Add( new TH1I("hVertexZ", "; Reco Vertex Z Position, cm; Counts; ", 50, -30, 30) );
19 
20  Add( new TH2I("hVertexXvY", "; Reco Vertex X Position, cm; Reco Vertex Y Position, cm; Counts", 50, -1, 1, 50, -1, 1) );
21  h("hVertexXvY")->SetOption("colz");
22  Add( new TH2I("hVertexZvX", "; Reco Vertex Z Position, cm; Reco Vertex X Position, cm; Counts", 50, -30, 30, 50, -1, 1) );
23  h("hVertexZvX")->SetOption("colz");
24  Add( new TH2I("hVertexZvY", "; Reco Vertex Z Position, cm; Reco Vertex Y Position, cm; Counts", 50, -30, 30, 50, -1, 1) );
25  h("hVertexZvY")->SetOption("colz");
26 
27  Add( new TH1I("hMcVertexX", "; MC Vertex X Position, cm; Counts; ", 50, -1, 1) );
28  Add( new TH1I("hMcVertexY", "; MC Vertex Y Position, cm; Counts; ", 50, -1, 1) );
29  Add( new TH1I("hMcVertexZ", "; MC Vertex Z Position, cm; Counts; ", 50, -30, 30) );
30 
31  Add( new TH2I("hMcVertexXvY", "; MC Vertex X Position, cm; Reco Vertex Y Position, cm; Counts", 50, -1, 1, 50, -1, 1) );
32  h("hMcVertexXvY")->SetOption("colz");
33  Add( new TH2I("hMcVertexZvX", "; MC Vertex Z Position, cm; Reco Vertex X Position, cm; Counts", 50, -30, 30, 50, -1, 1) );
34  h("hMcVertexZvX")->SetOption("colz");
35  Add( new TH2I("hMcVertexZvY", "; MC Vertex Z Position, cm; Reco Vertex Y Position, cm; Counts", 50, -30, 30, 50, -1, 1) );
36  h("hMcVertexZvY")->SetOption("colz");
37 
38  Add( new TH1I("hMcRecoVertexDeltaX", "; MC - Reco Vertex X, cm; Counts; ", 50, -0.3, 0.3) );
39  Add( new TH1I("hMcRecoVertexDeltaY", "; MC - Reco Vertex Y, cm; Counts; ", 50, -0.3, 0.3) );
40  Add( new TH1I("hMcRecoVertexDeltaZ", "; MC - Reco Vertex Z, cm; Counts; ", 50, -0.3, 0.3) );
41 
42  Add( new TH1I("hMcRecoVertexDelta", "; MC - Reco Vertex Dist, cm; Counts; ", 50, 0, 0.5) );
43 
44  TH1* h = new TH1I("hVertexErrorMag", "Vertex Position Error Magnitude; sqrt(#sigma_{x}^{2} + #sigma_{y}^{2} + #sigma_{z}^{2}), cm", 50, 0, 1);
45  Add(h);
46 
47  Add( new TH1I("hVertexErrorX", "; Reco Vertex X Position Error, cm; Counts; ", 50, 0, 0.35) );
48  Add( new TH1I("hVertexErrorY", "; Reco Vertex Y Position Error, cm; Counts; ", 50, 0, 0.35) );
49  Add( new TH1I("hVertexErrorZ", "; Reco Vertex Z Position Error, cm; Counts; ", 50, 0, 0.50) );
50 
51  // The following histograms require info from simulated vertex
52  Add( new TH1I("hVertexPullX", "; Vertex Pull Distribution in X; Counts; ", 50, -5, 5) );
53  Add( new TH1I("hVertexPullY", "; Vertex Pull Distribution in Y; Counts; ", 50, -5, 5) );
54  Add( new TH1I("hVertexPullZ", "; Vertex Pull Distribution in Z; Counts; ", 50, -5, 5) );
55 }
56 
57 
58 void StarVertexHistContainer::FillHists(const StMuPrimaryVertex &vertex, const StMuMcVertex* mcVertex)
59 {
60  h("hNumTracksToVertex")->Fill(vertex.noTracks());
61  h("hVertexRank")->Fill(vertex.ranking());
62 
63  h("hVertexX")->Fill(vertex.position().x());
64  h("hVertexY")->Fill(vertex.position().y());
65  h("hVertexZ")->Fill(vertex.position().z());
66 
67  h("hVertexXvY")->Fill(vertex.position().x(), vertex.position().y());
68  h("hVertexZvX")->Fill(vertex.position().z(), vertex.position().x());
69  h("hVertexZvY")->Fill(vertex.position().z(), vertex.position().y());
70 
71  h("hVertexErrorMag")->Fill(vertex.posError().mag());
72  h("hVertexErrorX")->Fill(vertex.posError().x());
73  h("hVertexErrorY")->Fill(vertex.posError().y());
74  h("hVertexErrorZ")->Fill(vertex.posError().z());
75 
76  // Proceed with histogram requiring info about simulated vertex
77  if (!mcVertex) return;
78 
79  h("hMcVertexX")->Fill(mcVertex->XyzV().x());
80  h("hMcVertexY")->Fill(mcVertex->XyzV().y());
81  h("hMcVertexZ")->Fill(mcVertex->XyzV().z());
82 
83  h("hMcVertexXvY")->Fill(mcVertex->XyzV().x(), mcVertex->XyzV().y());
84  h("hMcVertexZvX")->Fill(mcVertex->XyzV().z(), mcVertex->XyzV().x());
85  h("hMcVertexZvY")->Fill(mcVertex->XyzV().z(), mcVertex->XyzV().y());
86 
87  h("hMcRecoVertexDeltaX")->Fill(mcVertex->XyzV().x() - vertex.position().x());
88  h("hMcRecoVertexDeltaY")->Fill(mcVertex->XyzV().y() - vertex.position().y());
89  h("hMcRecoVertexDeltaZ")->Fill(mcVertex->XyzV().z() - vertex.position().z());
90 
91  h("hMcRecoVertexDelta")->Fill( (mcVertex->XyzV() - vertex.position()).mag() );
92 
93  h("hVertexPullX")->Fill( (vertex.position().x() - mcVertex->XyzV().x())/vertex.posError().x() );
94  h("hVertexPullY")->Fill( (vertex.position().y() - mcVertex->XyzV().y())/vertex.posError().y() );
95  h("hVertexPullZ")->Fill( (vertex.position().z() - mcVertex->XyzV().z())/vertex.posError().z() );
96 }
StarVertexHistContainer(const std::string name, TDirectory *motherDir=nullptr, const std::string option="")
void FillHists(const StMuPrimaryVertex &vertex, const StMuMcVertex *mcVertex=nullptr)