CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HTrack.cc
Go to the documentation of this file.
6 
10 
11 #include "TFile.h"
12 #include "TDirectory.h"
13 
14 
15 using namespace std;
16 
17 HTrack::HTrack(string dirName_,string name,string whereIs):
18  theName(name.c_str()),where(whereIs.c_str()){
19 
21  dbe_->cd();
22  std::string dirName=dirName_;
23  dirName+="/";
24  dirName+=name.c_str();
25  dirName+="_";
26  dirName+=whereIs.c_str();
27 
28  dbe_->cd();
29  dbe_->setCurrentFolder(dirName.c_str());
30 
31  hVariables = new HTrackVariables(dirName.c_str(),name,whereIs);
32 
33 
34  dbe_->cd();
35  dbe_->setCurrentFolder(dirName.c_str());
36  string resName = dirName;
37  resName+="/Resolution";
38  hResolution = new HResolution(resName.c_str(),name+"_Res",whereIs);
39  dbe_->cd();
40  dbe_->setCurrentFolder(dirName.c_str());
41  hTDRResolution = new HResolution(resName.c_str(),name+"_TDRRes",whereIs);
42 
43  dbe_->cd();
44  dbe_->setCurrentFolder(dirName.c_str());
45  string pullName = dirName;
46  pullName+="/Pull";
47  hPull = new HResolution(pullName.c_str(),name+"_Pull",whereIs);
48  hTDRPull = new HResolution(pullName.c_str(),name+"_TDRPull",whereIs);
49 
50 
51  doSubHisto = false;
52 
53  if(doSubHisto){
54  dbe_->cd();
55  dbe_->setCurrentFolder(dirName.c_str());
56  string subName = dirName;
57  subName+="/subHistos";
58  // [5-10] GeV range
59  hResolution_5_10 = new HResolution(subName.c_str(),name+"_Res_Pt_5_10",whereIs);
60  hTDRResolution_5_10 = new HResolution(subName.c_str(),name+"_TDRRes_Pt_5_10",whereIs);
61  hPull_5_10 = new HResolution(subName.c_str(),name+"_Pull_Pt_5_10",whereIs);
62 
63 
64  hResolution_10_40 = new HResolution(subName.c_str(),name+"_Res_Pt_10_40",whereIs);
65  hTDRResolution_10_40 = new HResolution(subName.c_str(),name+"_TDRRes_Pt_10_40",whereIs);
66  hPull_10_40 = new HResolution(subName.c_str(),name+"_Pull_Pt_10_40",whereIs);
67 
68 
69  hResolution_40_70 = new HResolution(subName.c_str(),name+"_Res_Pt_40_70",whereIs);
70  hTDRResolution_40_70 = new HResolution(subName.c_str(),name+"_TDRRes_Pt_40_70",whereIs);
71  hPull_40_70 = new HResolution(subName.c_str(),name+"_Pull_Pt_40_70",whereIs);
72 
73 
74  hResolution_70_100 = new HResolution(subName.c_str(),name+"_Res_Pt_70_100",whereIs);
75  hTDRResolution_70_100 = new HResolution(subName.c_str(),name+"_TDRRes_Pt_70_100",whereIs);
76  hPull_70_100 = new HResolution(subName.c_str(),name+"_Pull_Pt_70_100",whereIs);
77 
78 
79  hResolution_08 = new HResolution(subName.c_str(),name+"_Res_Eta_08",whereIs);
80  hTDRResolution_08 = new HResolution(subName.c_str(),name+"_TDRRes_Eta_08",whereIs);
81  hPull_08 = new HResolution(subName.c_str(),name+"_Pull_Eta_08",whereIs);
82 
83 
84  hResolution_08_12 = new HResolution(subName.c_str(),name+"_Res_Eta_08_12",whereIs);
85  hTDRResolution_08_12 = new HResolution(subName.c_str(),name+"_TDRRes_Eta_08_12",whereIs);
86  hPull_08_12 = new HResolution(subName.c_str(),name+"_Pull_Eta_08_12",whereIs);
87 
88 
89  hResolution_12_21 = new HResolution(subName.c_str(),name+"_Res_Eta_12_21",whereIs);
90  hTDRResolution_12_21 = new HResolution(subName.c_str(),name+"_TDRRes_Eta_12_21",whereIs);
91  hPull_12_21 = new HResolution(subName.c_str(),name+"_Pull_Eta_12_21",whereIs);
92 
93 
94  hResolution_12_24 = new HResolution(subName.c_str(),name+"_Res_Eta_12_24",whereIs);
95  hTDRResolution_12_24 = new HResolution(subName.c_str(),name+"_TDRRes_Eta_12_24",whereIs);
96  hPull_12_24 = new HResolution(subName.c_str(),name+"_Pull_Eta_12_24",whereIs);
97 
98 
99  hResolution_12_21_plus = new HResolution(subName.c_str(),name+"_Res_Eta_12_21_plus",whereIs);
100  hTDRResolution_12_21_plus = new HResolution(subName.c_str(),name+"_TDRRes_Eta_12_21_plus",whereIs);
101  hPull_12_21_plus = new HResolution(subName.c_str(),name+"_Pull_Eta_12_21_plus",whereIs);
102 
103 
104  hResolution_12_24_plus = new HResolution(subName.c_str(),name+"_Res_Eta_12_24_plus",whereIs);
105  hTDRResolution_12_24_plus = new HResolution(subName.c_str(),name+"_TDRRes_Eta_12_24_plus",whereIs);
106  hPull_12_24_plus = new HResolution(subName.c_str(),name+"_Pull_Eta_12_24_plus",whereIs);
107 
108 
109  hResolution_12_21_minus = new HResolution(subName.c_str(),name+"_Res_Eta_12_21_minus",whereIs);
110  hTDRResolution_12_21_minus = new HResolution(subName.c_str(),name+"_TDRRes_Eta_12_21_minus",whereIs);
111  hPull_12_21_minus = new HResolution(subName.c_str(),name+"_Pull_Eta_12_21_minus",whereIs);
112 
113 
114  hResolution_12_24_minus = new HResolution(subName.c_str(),name+"_Res_Eta_12_24_minus",whereIs);
115  hTDRResolution_12_24_minus = new HResolution(subName.c_str(),name+"_TDRRes_Eta_12_24_minus",whereIs);
116  hPull_12_24_minus = new HResolution(subName.c_str(),name+"_Pull_Eta_12_24_minus",whereIs);
117  }
118 }
119 
120 double HTrack::pull(double rec,double sim, double sigmarec){
121  return (rec-sim)/sigmarec;
122 }
123 
124 double HTrack::resolution(double rec,double sim){
125  return (rec-sim)/sim;
126 }
127 
128 
130  Fill(*tsos.freeState());
131 }
132 
134 
135  hVariables->Fill(fts.momentum().mag(),
136  fts.momentum().perp(),
137  fts.momentum().eta(),
138  fts.momentum().phi(),
139  fts.charge());
140 }
141 
143  hVariables->FillDeltaR(deltaR);
144 }
145 
146 
148  return hVariables->computeEfficiency(sim);
149 }
150 
151 
153  computeResolutionAndPull(*tsos.freeState(),simTrack);
154 }
155 
156 
158 
159 
160  // Global Resolution
161  computeResolution(fts,simTrack,hResolution);
162  computePull(fts,simTrack,hPull);
163 
164  // TDR Resolution
165  computeTDRResolution(fts,simTrack,hTDRResolution);
166  // computeTDRPull(fts,simTracks,hTDRPull);
167 
168 
169  hVariables->Fill(sqrt(simTrack.momentum().Perp2()),
170  simTrack.momentum().eta(),
171  simTrack.momentum().phi()); //FIXME
172 
173 
174  if(doSubHisto){
175  // [5-10] GeV range
176  if(sqrt(simTrack.momentum().Perp2()) <10 ){
177  computeResolution(fts,simTrack,hResolution_5_10);
179  computePull(fts,simTrack,hPull_5_10);
180  }
181 
182  // [10-40] GeV range
183  if(sqrt(simTrack.momentum().Perp2()) >=10 && sqrt(simTrack.momentum().Perp2()) < 40){
184  computeResolution(fts,simTrack,hResolution_10_40);
186  computePull(fts,simTrack,hPull_10_40);
187  }
188 
189  // [40-70] GeV range
190  if(sqrt(simTrack.momentum().Perp2()) >=40 && sqrt(simTrack.momentum().Perp2()) < 70){
191  computeResolution(fts,simTrack,hResolution_40_70);
193  computePull(fts,simTrack,hPull_40_70);
194  }
195 
196  // [70-100] GeV range
197  if(sqrt(simTrack.momentum().Perp2()) >= 70 && sqrt(simTrack.momentum().Perp2()) < 100){
198  computeResolution(fts,simTrack,hResolution_70_100);
200  computePull(fts,simTrack,hPull_70_100);
201  }
202 
203  // eta range |eta|<0.8
204  if(abs(simTrack.momentum().eta()) <= 0.8){
205  computeResolution(fts,simTrack,hResolution_08);
207  computePull(fts,simTrack,hPull_08);
208  }
209 
210  // eta range 0.8<|eta|<1.2
211  if( abs(simTrack.momentum().eta()) > 0.8 && abs(simTrack.momentum().eta()) <= 1.2 ){
212  computeResolution(fts,simTrack,hResolution_08_12);
214  computePull(fts,simTrack,hPull_08_12);
215  }
216 
217  // eta range 1.2<|eta|<2.1
218  if( abs(simTrack.momentum().eta()) > 1.2 && abs(simTrack.momentum().eta()) <= 2.1 ){
219  computeResolution(fts,simTrack,hResolution_12_21);
221  computePull(fts,simTrack,hPull_12_21);
222 
223  if(simTrack.momentum().eta() > 0){
226  computePull(fts,simTrack,hPull_12_21_plus);
227  }
228  else{
231  computePull(fts,simTrack,hPull_12_21_minus);
232  }
233  }
234 
235  // eta range 1.2<|eta|<2.4
236  if( abs(simTrack.momentum().eta()) > 1.2 && abs(simTrack.momentum().eta()) <= 2.4 ){
237  computeResolution(fts,simTrack,hResolution_12_24);
239  computePull(fts,simTrack,hPull_12_24);
240 
241  if(simTrack.momentum().eta() > 0){
244  computePull(fts,simTrack,hPull_12_24_plus);
245  }
246  else{
249  computePull(fts,simTrack,hPull_12_24_minus);
250  }
251  }
252  }
253 }
254 
256  SimTrack& simTrack,
257  HResolution* hReso){
258 
259 
260  hReso->Fill(simTrack.momentum().mag(),
261  sqrt(simTrack.momentum().Perp2()),
262  simTrack.momentum().eta(),
263  simTrack.momentum().phi(),
264  resolution(fts.momentum().mag(),simTrack.momentum().mag()),
265  resolution(fts.momentum().perp(),sqrt(simTrack.momentum().Perp2())),
266  fts.momentum().eta()-simTrack.momentum().eta(),
267  fts.momentum().phi()-simTrack.momentum().phi(),
268  fts.charge()+simTrack.type()/abs(simTrack.type())); // FIXME
269 }
270 
272  SimTrack& simTrack,
273  HResolution* hReso){
274 
275  int simCharge = -simTrack.type()/ abs(simTrack.type());
276 
277  double invSimP = (simTrack.momentum().mag() == 0 ) ? 0 : simTrack.momentum().mag();
278  double signedInverseRecMom = (simTrack.momentum().mag() == 0 ) ? 0 : fts.signedInverseMomentum();
279 
280  hReso->Fill(simTrack.momentum().mag(),
281  sqrt(simTrack.momentum().Perp2()),
282  simTrack.momentum().eta(),
283  simTrack.momentum().phi(),
284  resolution(signedInverseRecMom , simCharge*invSimP ),
285  resolution(fts.charge()/fts.momentum().perp(),simCharge/sqrt(simTrack.momentum().Perp2())));
286 }
287 
289  SimTrack& simTrack,
290  HResolution* hReso){
291 
292  // x,y,z, px,py,pz
294 
295  double partialPterror = errors[3][3]*pow(fts.momentum().x(),2) + errors[4][4]*pow(fts.momentum().y(),2);
296 
297  // sqrt( (px*spx)^2 + (py*spy)^2 ) / pt
298  double pterror = sqrt(partialPterror)/fts.momentum().perp();
299 
300  // sqrt( (px*spx)^2 + (py*spy)^2 + (pz*spz)^2 ) / p
301  double perror = sqrt(partialPterror+errors[5][5]*pow(fts.momentum().z(),2))/fts.momentum().mag();
302 
303  double phierror = sqrt(fts.curvilinearError().matrix()[2][2]);
304 
305  double etaerror = sqrt(fts.curvilinearError().matrix()[1][1])*abs(sin(fts.momentum().theta()));
306 
307 
308  hReso->Fill(simTrack.momentum().mag(),
309  sqrt(simTrack.momentum().Perp2()),
310  simTrack.momentum().eta(),
311  simTrack.momentum().phi(),
312  pull(fts.momentum().mag(),simTrack.momentum().mag(),perror),
313  pull(fts.momentum().perp(),sqrt(simTrack.momentum().Perp2()),pterror),
314  pull(fts.momentum().eta(),simTrack.momentum().eta(),etaerror),
315  pull(fts.momentum().phi(),simTrack.momentum().phi(),phierror),
316  pull(fts.charge() , -simTrack.type()/ abs(simTrack.type()), 1.)); // FIXME
317 }
void computePull(FreeTrajectoryState &fts, SimTrack &simTracks, HResolution *hReso)
Definition: HTrack.cc:288
void computeTDRResolution(FreeTrajectoryState &fts, SimTrack &simTracks, HResolution *hReso)
Definition: HTrack.cc:271
HResolution * hPull_08_12
Definition: HTrack.h:88
void computeResolutionAndPull(TrajectoryStateOnSurface &vtx, SimTrack &simTrack)
Definition: HTrack.cc:152
HResolution * hResolution_12_21
Definition: HTrack.h:91
HResolution * hTDRResolution
Definition: HTrack.h:57
HResolution * hTDRResolution_12_24_plus
Definition: HTrack.h:107
CartesianTrajectoryError cartesianError() const
HResolution * hPull
Definition: HTrack.h:54
T perp() const
Definition: PV3DBase.h:71
HTrack(std::string, std::string name, std::string whereIs="")
Definition: HTrack.cc:17
HResolution * hResolution
Definition: HTrack.h:53
double computeEfficiency(HTrackVariables *sim)
Definition: Histograms.h:92
HResolution * hTDRResolution_12_24
Definition: HTrack.h:97
HResolution * hTDRResolution_40_70
Definition: HTrack.h:72
void cd(void)
go to top directory (ie. root)
Definition: DQMStore.cc:406
HResolution * hResolution_12_24_plus
Definition: HTrack.h:106
double resolution(double rec, double sim)
Definition: HTrack.cc:124
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
ROOT::Math::SMatrix< double, 6, 6, ROOT::Math::MatRepSym< double, 6 > > AlgebraicSymMatrix66
Geom::Phi< T > phi() const
Definition: PV3DBase.h:68
T y() const
Definition: PV3DBase.h:62
#define abs(x)
Definition: mlp_lapack.h:159
HResolution * hResolution_10_40
Definition: HTrack.h:66
HResolution * hPull_10_40
Definition: HTrack.h:68
HResolution * hResolution_12_24
Definition: HTrack.h:96
TrackCharge charge() const
HResolution * hResolution_12_21_plus
Definition: HTrack.h:101
Definition: sim.h:19
const CurvilinearTrajectoryError & curvilinearError() const
HResolution * hTDRResolution_5_10
Definition: HTrack.h:62
HResolution * hResolution_12_24_minus
Definition: HTrack.h:116
Geom::Theta< T > theta() const
Definition: PV3DBase.h:74
HResolution * hResolution_5_10
Definition: HTrack.h:61
T mag() const
Definition: PV3DBase.h:66
HTrackVariables * hVariables
Definition: HTrack.h:50
HResolution * hTDRResolution_12_21_minus
Definition: HTrack.h:112
FreeTrajectoryState * freeState(bool withErrors=true) const
HResolution * hPull_12_21
Definition: HTrack.h:93
HResolution * hResolution_08_12
Definition: HTrack.h:86
T sqrt(T t)
Definition: SSEVec.h:46
HResolution * hTDRResolution_12_21
Definition: HTrack.h:92
T z() const
Definition: PV3DBase.h:63
HResolution * hTDRResolution_12_24_minus
Definition: HTrack.h:117
double computeEfficiency(HTrackVariables *sim)
Definition: HTrack.cc:147
HResolution * hResolution_40_70
Definition: HTrack.h:71
HResolution * hResolution_08
Definition: HTrack.h:81
DQMStore * dbe_
Definition: HTrack.h:48
HResolution * hPull_70_100
Definition: HTrack.h:78
void Fill(TrajectoryStateOnSurface &)
Definition: HTrack.cc:129
GlobalVector momentum() const
bool doSubHisto
Definition: HTrack.h:123
HResolution * hTDRPull
Definition: HTrack.h:58
HResolution * hPull_40_70
Definition: HTrack.h:73
const AlgebraicSymMatrix66 & matrix() const
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
HResolution * hTDRResolution_08_12
Definition: HTrack.h:87
HResolution * hPull_12_24_minus
Definition: HTrack.h:118
void computeResolution(FreeTrajectoryState &fts, SimTrack &simTracks, HResolution *hReso)
Definition: HTrack.cc:255
HResolution * hPull_12_21_minus
Definition: HTrack.h:113
void Fill(double p, double pt, double eta, double phi, double charge)
Definition: Histograms.h:73
HResolution * hPull_12_24
Definition: HTrack.h:98
HResolution * hTDRResolution_70_100
Definition: HTrack.h:77
T eta() const
Definition: PV3DBase.h:75
HResolution * hTDRResolution_08
Definition: HTrack.h:82
int type() const
particle type (HEP PDT convension)
Definition: CoreSimTrack.h:40
HResolution * hPull_12_24_plus
Definition: HTrack.h:108
const AlgebraicSymMatrix55 & matrix() const
double pull(double rec, double sim, double sigmarec)
Definition: HTrack.cc:120
const math::XYZTLorentzVectorD & momentum() const
particle info...
Definition: CoreSimTrack.h:36
HResolution * hResolution_70_100
Definition: HTrack.h:76
HResolution * hTDRResolution_10_40
Definition: HTrack.h:67
void FillDeltaR(double)
Definition: HTrack.cc:142
HResolution * hPull_5_10
Definition: HTrack.h:63
virtual Int_t Fill(Double_t x, Double_t y)
Definition: Histograms.h:1741
T x() const
Definition: PV3DBase.h:61
double signedInverseMomentum() const
HResolution * hPull_08
Definition: HTrack.h:83
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
void FillDeltaR(double deltaR)
Definition: Histograms.h:88
HResolution * hResolution_12_21_minus
Definition: HTrack.h:111
HResolution * hPull_12_21_plus
Definition: HTrack.h:103
HResolution * hTDRResolution_12_21_plus
Definition: HTrack.h:102