CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
SimpleVertexTree Class Reference

#include <SimpleVertexTree.h>

Public Member Functions

void fill (const TransientVertex &recv, const TrackingVertex *simv=0, reco::RecoToSimCollection *recSimColl=0, const float &time=0.)
 
void fill (const TransientVertex &recv, const TrackingVertex *simv=0, const float &time=0.)
 
void fill (const TransientVertex &recv, const float &time=0.)
 
void fill (const TrackingVertex *simv)
 
void fill ()
 
 SimpleVertexTree (const char *fitterName="VertexFitter", const MagneticField *magField=0)
 
virtual ~SimpleVertexTree ()
 

Private Member Functions

void defineTrackBranch (const TString &prefix, const TString &type, const float *(VertexFitterResult::*pfunc)(const int) const, const TString &index)
 

Private Attributes

float chiProb
 
float chiTot
 
int maxTrack
 
float ndf
 
int numberOfVertices
 
TString * parameterNames [5]
 
float recErr [3]
 
float recPos [3]
 
VertexFitterResultresult
 
float simPos [3]
 
TString theFitterName
 
bool trackTest
 
TTree * vertexTree
 

Detailed Description

Definition at line 41 of file SimpleVertexTree.h.

Constructor & Destructor Documentation

SimpleVertexTree::SimpleVertexTree ( const char *  fitterName = "VertexFitter",
const MagneticField magField = 0 
)

The constructor

Parameters
fitterNameThe name of the TTree, and of the associated histograms.

Definition at line 10 of file SimpleVertexTree.cc.

References VertexFitterResult::chi2Information(), defineTrackBranch(), maxTrack, numberOfVertices, VertexFitterResult::numberRecTracks(), VertexFitterResult::numberSimTracks(), parameterNames, VertexFitterResult::recErrors(), VertexFitterResult::recParameters(), VertexFitterResult::recTrack_simIndex(), VertexFitterResult::recTrackWeight(), VertexFitterResult::recVertexErr(), VertexFitterResult::recVertexPos(), VertexFitterResult::refErrors(), VertexFitterResult::refParameters(), result, VertexFitterResult::simParameters(), VertexFitterResult::simTrack_recIndex(), VertexFitterResult::simVertexPos(), VertexFitterResult::time(), VertexFitterResult::trackInformation(), VertexFitterResult::vertexPresent(), and vertexTree.

11  :
13 {
14 
15  vertexTree = new TTree(filterName, "Vertex fit results");
16 // trackTest
17 // = SimpleConfigurable<bool> (false, "SimpleVertexTree:trackTest").value();
18 // if (trackTest) {
19 // maxTrack = SimpleConfigurable<int> (100, "SimpleVertexTree:maximumTracksToStore").value();
20 // } else
21  maxTrack = 0;
22  result = new VertexFitterResult(maxTrack, magField);
23 
24  vertexTree->Branch("vertex",(void *)result->vertexPresent(),"vertex/I");
25  vertexTree->Branch("simPos",(void *)result->simVertexPos(),"X/F:Y/F:Z/F");
26  vertexTree->Branch("recPos",(void *)result->recVertexPos(),"X/F:Y/F:Z/F");
27  vertexTree->Branch("recErr",(void *)result->recVertexErr(),"X/F:Y/F:Z/F");
28  vertexTree->Branch("nbrTrk",(void *)result->trackInformation(),"Sim/I:Rec/I:Shared/I");
29  vertexTree->Branch("chiTot",(void *)result->chi2Information (),"chiTot/F");
30  vertexTree->Branch("ndf",(void *)(result->chi2Information ()+1),"ndf/F");
31  vertexTree->Branch("chiProb",(void *)(result->chi2Information ()+2),"chiProb/F");
32  vertexTree->Branch("time",(void *)result->time(),"time/F");
33 
34 
35  parameterNames[0] = new TString("ptinv");
36  parameterNames[1] = new TString("theta");
37  parameterNames[2] = new TString("phi");
38  parameterNames[3] = new TString("timp");
39  parameterNames[4] = new TString("limp");
40 
41  vertexTree->Branch("simTracks",(void *)result->numberSimTracks(),"simTracks/I");
42  vertexTree->Branch("simTrack_recIndex",(void *)result->simTrack_recIndex(),"simTrack_recIndex[simTracks]/I");
43  defineTrackBranch("sim", "Par", &VertexFitterResult::simParameters, "simTracks");
44 
45  vertexTree->Branch("recTracks",(void *)result->numberRecTracks(),"recTracks/I");
46  vertexTree->Branch("recTrack_simIndex",(void *)result->recTrack_simIndex(),"recTrack_simIndex[recTracks]/I");
47  vertexTree->Branch("recTrack_weight",(void *)result->recTrackWeight(),"recTrack_weight[recTracks]/F");
48  defineTrackBranch("rec", "Par", &VertexFitterResult::recParameters, "recTracks");
49  defineTrackBranch("ref", "Par", &VertexFitterResult::refParameters, "recTracks");
50  defineTrackBranch("rec", "Err", &VertexFitterResult::recErrors, "recTracks");
51  defineTrackBranch("ref", "Err", &VertexFitterResult::refErrors, "recTracks");
52 
53  numberOfVertices = 0;
54 }
void defineTrackBranch(const TString &prefix, const TString &type, const float *(VertexFitterResult::*pfunc)(const int) const, const TString &index)
const int * simTrack_recIndex()
const int * vertexPresent() const
const int * recTrack_simIndex()
const float * recTrackWeight()
const float * simVertexPos() const
const int * numberSimTracks()
const float * recVertexErr() const
const float * recParameters(const int i) const
const float * refParameters(const int i) const
const int * trackInformation() const
const int * numberRecTracks()
const float * recVertexPos() const
const float * simParameters(const int i) const
const float * chi2Information() const
TString * parameterNames[5]
const float * refErrors(const int i) const
const float * time() const
VertexFitterResult * result
const float * recErrors(const int i) const
SimpleVertexTree::~SimpleVertexTree ( )
virtual

Definition at line 70 of file SimpleVertexTree.cc.

References chiProb, gather_cfg::cout, numberOfVertices, theFitterName, and vertexTree.

71 {
72  std::cout << std::endl<< "End of SimpleVertexTree for "<< theFitterName << std::endl;
73  std::cout << std::endl<< "Number of vertices fit: "<< numberOfVertices<<std::endl;
74 
75  //
76  // save current root directory
77  //
78  TDirectory* rootDir = gDirectory;
79  //
80  // close files
81  //
82  vertexTree->GetDirectory()->cd();
83  vertexTree->Write();
84  if (numberOfVertices>0) {
85  TH1F *resX = new TH1F(theFitterName + "_ResX","Residual x coordinate: "+theFitterName, 100, -0.03, 0.03);
86  TH1F *resY = new TH1F(theFitterName + "_ResY","Residual y coordinate: "+theFitterName, 100, -0.03, 0.03);
87  TH1F *resZ = new TH1F(theFitterName + "_ResZ","Residual z coordinate: "+theFitterName, 100, -0.03, 0.03);
88  TH1F *pullX = new TH1F(theFitterName + "_PullX","Pull x coordinate: "+theFitterName, 100, -10., 10.);
89  TH1F *pullY = new TH1F(theFitterName + "_PullY","Pull y coordinate: "+theFitterName, 100, -10., 10.);
90  TH1F *pullZ = new TH1F(theFitterName + "_PullZ","Pull z coordinate: "+theFitterName, 100, -10., 10.);
91  TH1F *chiNorm = new TH1F(theFitterName + "_ChiNorm","Normalized chi-square: " +theFitterName, 100, 0., 10.);
92  TH1F *chiProb = new TH1F(theFitterName + "_ChiProb","Chi-square probability: "+theFitterName, 100, 0., 1.);
93  vertexTree->Project(theFitterName + "_ResX", "(simPos.X-recPos.X)");
94  vertexTree->Project(theFitterName + "_ResY", "(simPos.Y-recPos.Y)");
95  vertexTree->Project(theFitterName + "_ResZ", "(simPos.Z-recPos.Z)");
96  vertexTree->Project(theFitterName + "_PullX", "(simPos.X-recPos.X)/recErr.X");
97  vertexTree->Project(theFitterName + "_PullY", "(simPos.Y-recPos.Y)/recErr.Y");
98  vertexTree->Project(theFitterName + "_PullZ", "(simPos.Z-recPos.Z)/recErr.Z");
99  vertexTree->Project(theFitterName + "_ChiNorm", "chiTot/ndf");
100  vertexTree->Project(theFitterName + "_ChiProb", "chiProb");
101  std::cout << "Mean of Residual distribution X: "<< resX->GetMean()<<std::endl;
102  std::cout << "Mean of Residual distribution Y: "<< resY->GetMean()<<std::endl;
103  std::cout << "Mean of Residual distribution Z: "<< resZ->GetMean()<<std::endl;
104  std::cout << "RMS of Residual distribution X: "<< resX->GetRMS()<<std::endl;
105  std::cout << "RMS of Residual distribution Y: "<< resY->GetRMS()<<std::endl;
106  std::cout << "RMS of Residual distribution Z: "<< resZ->GetRMS()<<std::endl;
107  std::cout << "Mean of Pull distribution X: "<< pullX->GetMean()<<std::endl;
108  std::cout << "Mean of Pull distribution Y: "<< pullY->GetMean()<<std::endl;
109  std::cout << "Mean of Pull distribution Z: "<< pullZ->GetMean()<<std::endl;
110  std::cout << "RMS of Pull distribution X: "<< pullX->GetRMS()<<std::endl;
111  std::cout << "RMS of Pull distribution Y: "<< pullY->GetRMS()<<std::endl;
112  std::cout << "RMS of Pull distribution Z: "<< pullZ->GetRMS()<<std::endl;
113  std::cout << "Average chi-square probability: "<< chiProb->GetMean()<<std::endl;
114  std::cout << "Average normalized chi-square : "<< chiNorm->GetMean()<<std::endl;
115  resX->Write();
116  resY->Write();
117  resZ->Write();
118  pullX->Write();
119  pullY->Write();
120  pullZ->Write();
121  chiNorm->Write();
122  chiProb->Write();
123  }
124  delete vertexTree;
125  //
126  // restore directory
127  //
128  rootDir->cd();
129  std::cout << std::endl;
130 
131 }

Member Function Documentation

void SimpleVertexTree::defineTrackBranch ( const TString &  prefix,
const TString &  type,
const float *(VertexFitterResult::*)(const int) const  pfunc,
const TString &  index 
)
private

Definition at line 57 of file SimpleVertexTree.cc.

References electrons_cff::branchName, mps_fire::i, parameterNames, result, and vertexTree.

Referenced by SimpleVertexTree().

60 {
61  TString branchName, branchVariables;
62  for ( int i=0; i<5; i++ ) {
63  branchName = prefix + type + '_' + *parameterNames[i];
64  branchVariables = branchName + '[' + index + "]/F";
65  vertexTree->Branch(branchName,(void *)(result->*pfunc)(i),branchVariables);
66  }
67 }
type
Definition: HCALResponse.h:21
TString * parameterNames[5]
VertexFitterResult * result
void SimpleVertexTree::fill ( const TransientVertex recv,
const TrackingVertex simv = 0,
reco::RecoToSimCollection recSimColl = 0,
const float &  time = 0. 
)

Entry for a RecVertex. If the vertex was not associated to a TkSimVertex, an empty pointer can be given (would be identical to the next method). Timing information for the fit can also be provided.

Definition at line 133 of file SimpleVertexTree.cc.

References VertexFitterResult::fill(), fill(), and result.

135 {
136  result->fill(recv, simv, recSimColl, time);
137  fill();
138 }
void fill(const TransientVertex &recv, const TrackingVertex *simv=0, reco::RecoToSimCollection *recSimColl=0, const float &time=0)
VertexFitterResult * result
void SimpleVertexTree::fill ( const TransientVertex recv,
const TrackingVertex simv = 0,
const float &  time = 0. 
)
void SimpleVertexTree::fill ( const TransientVertex recv,
const float &  time = 0. 
)

Entry for a RecVertex, without associated vertex. Timing information for the fit can also be provided.

Definition at line 140 of file SimpleVertexTree.cc.

References VertexFitterResult::fill(), fill(), and result.

141 {
142  result->fill(recv, nullptr, nullptr, time);
143  fill();
144 }
void fill(const TransientVertex &recv, const TrackingVertex *simv=0, reco::RecoToSimCollection *recSimColl=0, const float &time=0)
VertexFitterResult * result
void SimpleVertexTree::fill ( const TrackingVertex simv)

Entry for a TkSimVertex, without RecVertex.

Definition at line 146 of file SimpleVertexTree.cc.

References VertexFitterResult::fill(), fill(), and result.

147 {
148  result->fill(TransientVertex(), simv, nullptr);
149  fill();
150 }
void fill(const TransientVertex &recv, const TrackingVertex *simv=0, reco::RecoToSimCollection *recSimColl=0, const float &time=0)
VertexFitterResult * result
void SimpleVertexTree::fill ( void  )

To be used if one wants to record "Failed Fits", e.g. to synchronise two Trees

Definition at line 167 of file SimpleVertexTree.cc.

References numberOfVertices, VertexFitterResult::reset(), result, and vertexTree.

Referenced by fill().

168 {
170  static std::atomic<int> nFill{0};
171  TDirectory* rootDir = gDirectory;
172  //
173  // fill entry
174  //
175  vertexTree->GetDirectory()->cd();
176  vertexTree->Fill();
177  if ( (++nFill)%1000==0 ) vertexTree->AutoSave();
178  //
179  // restore directory
180  //
181  rootDir->cd();
182  result->reset();
183 
184 
185 }
VertexFitterResult * result

Member Data Documentation

float SimpleVertexTree::chiProb
private

Definition at line 99 of file SimpleVertexTree.h.

Referenced by ~SimpleVertexTree().

float SimpleVertexTree::chiTot
private

Definition at line 99 of file SimpleVertexTree.h.

int SimpleVertexTree::maxTrack
private

Definition at line 106 of file SimpleVertexTree.h.

Referenced by SimpleVertexTree().

float SimpleVertexTree::ndf
private

Definition at line 99 of file SimpleVertexTree.h.

int SimpleVertexTree::numberOfVertices
private

Definition at line 100 of file SimpleVertexTree.h.

Referenced by fill(), SimpleVertexTree(), and ~SimpleVertexTree().

TString* SimpleVertexTree::parameterNames[5]
private

Definition at line 107 of file SimpleVertexTree.h.

Referenced by defineTrackBranch(), and SimpleVertexTree().

float SimpleVertexTree::recErr[3]
private

Definition at line 98 of file SimpleVertexTree.h.

float SimpleVertexTree::recPos[3]
private

Definition at line 97 of file SimpleVertexTree.h.

VertexFitterResult* SimpleVertexTree::result
private

Definition at line 102 of file SimpleVertexTree.h.

Referenced by defineTrackBranch(), fill(), and SimpleVertexTree().

float SimpleVertexTree::simPos[3]
private

Definition at line 96 of file SimpleVertexTree.h.

TString SimpleVertexTree::theFitterName
private

Definition at line 103 of file SimpleVertexTree.h.

Referenced by ~SimpleVertexTree().

bool SimpleVertexTree::trackTest
private

Definition at line 105 of file SimpleVertexTree.h.

TTree* SimpleVertexTree::vertexTree
private

Definition at line 101 of file SimpleVertexTree.h.

Referenced by defineTrackBranch(), fill(), SimpleVertexTree(), and ~SimpleVertexTree().