test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackerSectorStruct.h
Go to the documentation of this file.
1 #ifndef Alignment_APEEstimation_TrackerSectorStruct_h
2 #define Alignment_APEEstimation_TrackerSectorStruct_h
3 
4 
5 #include <vector>
6 #include <map>
7 #include "TH1F.h"
8 #include "TH2F.h"
9 #include "TProfile.h"
10 #include "TString.h"
12 
14 
15 
16 #include "TH1.h"
17 #include "TH2.h"
18 #include "TTree.h"
19 //class TH1;
20 //class TH2;
21 //class TH1F;
22 //class TH2F;
23 //class TProfile;
24 //class TString;
25 //class TFileDirectory;
26 
27 
28 
29 
30 
31 
32 
33 
34 
36  public:
37 
38  inline TrackerSectorStruct();
39 
40  inline ~TrackerSectorStruct();
41 
42 
43 
46  NorResXVsVar(0), ProbXVsVar(0),
50 
51  inline void fillCorrHists(const TString, const TrackStruct::HitParameterStruct& hitParameterStruct, double variable);
52  inline void fillCorrHistsX(const TrackStruct::HitParameterStruct& hitParameterStruct, double variable);
53  inline void fillCorrHistsY(const TrackStruct::HitParameterStruct& hitParameterStruct, double variable);
54 
55  TH1F *Variable;
60  };
61 
62 
63  inline void setCorrHistParams(TFileDirectory*, double, double, double);
64  inline CorrelationHists bookCorrHists(TString, TString, TString, TString, TString, int, int, double, double, std::string ="nphtr");
65  inline CorrelationHists bookCorrHistsX(TString, TString, TString, TString, int, int, double, double, std::string ="nphtr");
66  inline CorrelationHists bookCorrHistsY(TString, TString, TString, TString, int, int, double, double, std::string ="nphtr");
68  inline CorrelationHists bookCorrHists(TString, TString ,TString ,TString, int, double, double, std::string ="nphtr");
69  inline CorrelationHists bookCorrHistsX(TString ,TString ,TString, int, double, double, std::string ="nphtr");
70  inline CorrelationHists bookCorrHistsY(TString ,TString ,TString, int, double, double, std::string ="nphtr");
71 
72 
73 
74 
76  double norResXMax_, sigmaXHitMax_, sigmaXMax_; // Used for x and y
77  std::map<std::string,CorrelationHists> m_correlationHistsX;
78  std::map<std::string,CorrelationHists> m_correlationHistsY;
79 
80 
81  // Name of sector as string and as title of a histogram
83  TH1 *Name;
84 
85  // Module IDs of modules in sector
86  std::vector<unsigned int> v_rawId;
87 
88 
89  TH1 *ResX, *NorResX, *XHit, *XTrk,
90  *SigmaX2, *ProbX;
95  std::map<std::string,std::vector<TH1*> > m_sigmaX;
96 
97  TH1 *ResY, *NorResY, *YHit, *YTrk,
98  *SigmaY2, *ProbY;
101  std::map<std::string,std::vector<TH1*> > m_sigmaY;
102 
103 
104  //for every bin in sigmaX or sigmaY the needful histos to calculate the APE
105  std::map<unsigned int, std::map<std::string,TH1*> > m_binnedHists;
106 
107 
108  //for presenting results
109  TTree *RawId;
110  TH1 *EntriesX;
113  TH1 *EntriesY;
116 
117  // To book pixel-specific or strip-specific histos only
118  bool isPixel;
119 };
120 
121 
122 
123 
124 
125 
126 
127 
128 
130  norResXMax_(999.), sigmaXHitMax_(999.), sigmaXMax_(999.),
131  name("default"), Name(0),
132  ResX(0), NorResX(0), XHit(0), XTrk(0),
133  SigmaX2(0), ProbX(0),
134  WidthVsPhiSensX(0), WidthVsWidthProjected(0), WidthDiffVsMaxStrip(0), WidthDiffVsSigmaXHit(0),
135  PhiSensXVsBarycentreX(0),
136  PWidthVsPhiSensX(0), PWidthVsWidthProjected(0), PWidthDiffVsMaxStrip(0), PWidthDiffVsSigmaXHit(0),
137  PPhiSensXVsBarycentreX(0),
138  ResY(0), NorResY(0), YHit(0), YTrk(0),
139  SigmaY2(0), ProbY(0),
140  PhiSensYVsBarycentreY(0),
141  PPhiSensYVsBarycentreY(0),
142  RawId(0),
143  EntriesX(0),
144  MeanX(0), RmsX(0), FitMeanX1(0), ResidualWidthX1(0), CorrectionX1(0),
145  FitMeanX2(0), ResidualWidthX2(0), CorrectionX2(0),
146  EntriesY(0),
147  MeanY(0), RmsY(0), FitMeanY1(0), ResidualWidthY1(0), CorrectionY1(0),
148  FitMeanY2(0), ResidualWidthY2(0), CorrectionY2(0),
149  isPixel(false){}
150 
151 
152 
154 
155 
156 
157 void
158 TrackerSectorStruct::setCorrHistParams(TFileDirectory *directory, double norResXMax, double sigmaXHitMax, double sigmaXMax){
160  norResXMax_ = norResXMax;
161  sigmaXHitMax_ = sigmaXHitMax;
162  sigmaXMax_ = sigmaXMax;
163 }
164 
165 
166 
168 TrackerSectorStruct::bookCorrHistsX(TString varName,TString varTitle,TString labelX,TString unitX,int nBinX1D,int nBinX2D,double minBinX,double maxBinX,std::string options){
169  return bookCorrHists("X", varName, varTitle, labelX, unitX, nBinX1D, nBinX2D, minBinX, maxBinX, options);
170 }
172 TrackerSectorStruct::bookCorrHistsY(TString varName,TString varTitle,TString labelX,TString unitX,int nBinX1D,int nBinX2D,double minBinX,double maxBinX,std::string options){
173  return bookCorrHists("Y", varName, varTitle, labelX, unitX, nBinX1D, nBinX2D, minBinX, maxBinX, options);
174 }
176 TrackerSectorStruct::bookCorrHists(TString xY,TString varName,TString varTitle,TString labelX,TString unitX,int nBinX1D,int nBinX2D,double minBinX,double maxBinX,std::string options){
177  TString xy;
178  TString suffix;
179  if(xY=="X"){
180  xy = "x";
181  suffix = "";
182  }
183  if(xY=="Y"){
184  xy = "y";
185  suffix = "_y";
186  }
187 
188  std::string o(options);
189  CorrelationHists correlationHists;
190 
191  if(!(o.find("n") != std::string::npos || o.find("p") != std::string::npos || o.find("h") != std::string::npos ||
192  o.find("t") != std::string::npos || o.find("r") != std::string::npos))return correlationHists;
193 
195  double norResXMax(norResXMax_), sigmaXHitMax(sigmaXHitMax_), sigmaXMax(sigmaXMax_);
196 
197  if(!directory)return correlationHists;
198 
199 
200  correlationHists.Variable = directory->make<TH1F>("h_"+varName+suffix,varTitle+" "+labelX+";"+labelX+" "+unitX+";# hits",nBinX1D,minBinX,maxBinX);
201 
202  if(options.find("n") != std::string::npos)
203  correlationHists.NorResXVsVar = directory->make<TH2F>("h2_norRes"+xY+"Vs"+varName,"r_{"+xy+"}/#sigma_{r,"+xy+"} vs. "+labelX+";"+labelX+" "+unitX+";("+xy+"_{trk}-"+xy+"_{hit})/#sigma_{r,"+xy+"}",nBinX2D,minBinX,maxBinX,25,-norResXMax,norResXMax);
204  if(options.find("p") != std::string::npos)
205  correlationHists.ProbXVsVar = directory->make<TH2F>("h2_prob"+xY+"Vs"+varName,"prob_{"+xy+"} vs. "+labelX+";"+labelX+" "+unitX+";prob_{"+xy+"}",nBinX2D,minBinX,maxBinX,60,-0.1,1.1);
206  if(options.find("h") != std::string::npos)
207  correlationHists.SigmaXHitVsVar = directory->make<TH2F>("h2_sigma"+xY+"HitVs"+varName,"#sigma_{hit,"+xy+"} vs. "+labelX+";"+labelX+" "+unitX+";#sigma_{hit,"+xy+"} [#mum]",nBinX2D,minBinX,maxBinX,50,0*10000.,sigmaXHitMax*10000.);
208  if(options.find("t") != std::string::npos)
209  correlationHists.SigmaXTrkVsVar = directory->make<TH2F>("h2_sigma"+xY+"TrkVs"+varName,"#sigma_{trk,"+xy+"} vs. "+labelX+";"+labelX+" "+unitX+";#sigma_{trk,"+xy+"} [#mum]",nBinX2D,minBinX,maxBinX,50,0*10000.,sigmaXMax*10000.);
210  if(options.find("r") != std::string::npos)
211  correlationHists.SigmaXVsVar = directory->make<TH2F>("h2_sigma"+xY+"Vs"+varName,"#sigma_{r,"+xy+"} vs. "+labelX+";"+labelX+" "+unitX+";#sigma_{r,"+xy+"} [#mum]",nBinX2D,minBinX,maxBinX,50,0*10000.,sigmaXMax*10000.);
212 
213  if(options.find("n") != std::string::npos)
214  correlationHists.PNorResXVsVar = directory->make<TProfile>("p_norRes"+xY+"Vs"+varName,"r_{"+xy+"}/#sigma_{r,"+xy+"} vs. "+labelX+";"+labelX+" "+unitX+";("+xy+"_{trk}-"+xy+"_{hit})/#sigma_{r,"+xy+"}",nBinX2D,minBinX,maxBinX,"s");
215  if(options.find("p") != std::string::npos)
216  correlationHists.PProbXVsVar = directory->make<TProfile>("p_prob"+xY+"Vs"+varName,"prob_{"+xy+"} vs. "+labelX+";"+labelX+" "+unitX+";prob_{"+xy+"}",nBinX2D,minBinX,maxBinX,"s");
217  if(options.find("h") != std::string::npos)
218  correlationHists.PSigmaXHitVsVar = directory->make<TProfile>("p_sigma"+xY+"HitVs"+varName,"#sigma_{hit,"+xy+"} vs. "+labelX+";"+labelX+" "+unitX+";#sigma_{hit,"+xy+"} [#mum]",nBinX2D,minBinX,maxBinX);
219  if(options.find("t") != std::string::npos)
220  correlationHists.PSigmaXTrkVsVar = directory->make<TProfile>("p_sigma"+xY+"TrkVs"+varName,"#sigma_{trk,"+xy+"} vs. "+labelX+";"+labelX+" "+unitX+";#sigma_{trk,"+xy+"} [#mum]",nBinX2D,minBinX,maxBinX);
221  if(options.find("r") != std::string::npos)
222  correlationHists.PSigmaXVsVar = directory->make<TProfile>("p_sigma"+xY+"Vs"+varName,"#sigma_{r,"+xy+"} vs. "+labelX+";"+labelX+" "+unitX+";#sigma_{r,"+xy+"} [#mum]",nBinX2D,minBinX,maxBinX);
223 
224  return correlationHists;
225 }
226 
227 
228 
230 TrackerSectorStruct::bookCorrHistsX(TString varName,TString labelX,TString unitX,int nBinX,double minBinX,double maxBinX,std::string options){
231  return bookCorrHists("X", varName, labelX, unitX, nBinX, minBinX, maxBinX, options);
232 }
234 TrackerSectorStruct::bookCorrHistsY(TString varName,TString labelX,TString unitX,int nBinX,double minBinX,double maxBinX,std::string options){
235  return bookCorrHists("Y", varName, labelX, unitX, nBinX, minBinX, maxBinX, options);
236 }
238 TrackerSectorStruct::bookCorrHists(TString xY,TString varName,TString labelX,TString unitX,int nBinX,double minBinX,double maxBinX,std::string options){
239  TString xy;
240  if(xY=="X"){
241  xy = "x";
242  }
243  if(xY=="Y"){
244  xy = "y";
245  }
246 
247  std::string o(options);
248  CorrelationHists correlationHists;
249 
250  if(!(o.find("n") != std::string::npos || o.find("p") != std::string::npos || o.find("h") != std::string::npos ||
251  o.find("t") != std::string::npos || o.find("r") != std::string::npos))return correlationHists;
252 
254  double norResXMax(norResXMax_), sigmaXHitMax(sigmaXHitMax_), sigmaXMax(sigmaXMax_);
255 
256  if(!directory)return correlationHists;
257 
258 
259  if(options.find("n") != std::string::npos)
260  correlationHists.NorResXVsVar = directory->make<TH2F>("h2_norRes"+xY+"Vs"+varName,"r_{"+xy+"}/#sigma_{r,"+xy+"} vs. "+labelX+";"+labelX+" "+unitX+";("+xy+"_{trk}-"+xy+"_{hit})/#sigma_{r,"+xy+"}",nBinX,minBinX,maxBinX,25,-norResXMax,norResXMax);
261  if(options.find("p") != std::string::npos)
262  correlationHists.ProbXVsVar = directory->make<TH2F>("h2_prob"+xY+"Vs"+varName,"prob_{"+xy+"} vs. "+labelX+";"+labelX+" "+unitX+";prob_{"+xy+"}",nBinX,minBinX,maxBinX,60,-0.1,1.1);
263  if(options.find("h") != std::string::npos)
264  correlationHists.SigmaXHitVsVar = directory->make<TH2F>("h2_sigma"+xY+"HitVs"+varName,"#sigma_{hit,"+xy+"} vs. "+labelX+";"+labelX+" "+unitX+";#sigma_{hit,"+xy+"} [#mum]",nBinX,minBinX,maxBinX,50,0*10000.,sigmaXHitMax*10000.);
265  if(options.find("t") != std::string::npos)
266  correlationHists.SigmaXTrkVsVar = directory->make<TH2F>("h2_sigma"+xY+"TrkVs"+varName,"#sigma_{trk,"+xy+"} vs. "+labelX+";"+labelX+" "+unitX+";#sigma_{trk,"+xy+"} [#mum]",nBinX,minBinX,maxBinX,50,0*10000.,sigmaXMax*10000.);
267  if(options.find("r") != std::string::npos)
268  correlationHists.SigmaXVsVar = directory->make<TH2F>("h2_sigma"+xY+"Vs"+varName,"#sigma_{r,"+xy+"} vs. "+labelX+";"+labelX+" "+unitX+";#sigma_{r,"+xy+"} [#mum]",nBinX,minBinX,maxBinX,50,0*10000.,sigmaXMax*10000.);
269 
270  if(options.find("n") != std::string::npos)
271  correlationHists.PNorResXVsVar = directory->make<TProfile>("p_norRes"+xY+"Vs"+varName,"r_{"+xy+"}/#sigma_{r,"+xy+"} vs. "+labelX+";"+labelX+" "+unitX+";("+xy+"_{trk}-"+xy+"_{hit})/#sigma_{r,"+xy+"}",nBinX,minBinX,maxBinX,"s");
272  if(options.find("p") != std::string::npos)
273  correlationHists.PProbXVsVar = directory->make<TProfile>("p_prob"+xY+"Vs"+varName,"prob_{"+xy+"} vs. "+labelX+";"+labelX+" "+unitX+";prob_{"+xy+"}",nBinX,minBinX,maxBinX,"s");
274  if(options.find("h") != std::string::npos)
275  correlationHists.PSigmaXHitVsVar = directory->make<TProfile>("p_sigma"+xY+"HitVs"+varName,"#sigma_{hit,"+xy+"} vs. "+labelX+";"+labelX+" "+unitX+";#sigma_{hit,"+xy+"} [#mum]",nBinX,minBinX,maxBinX);
276  if(options.find("t") != std::string::npos)
277  correlationHists.PSigmaXTrkVsVar = directory->make<TProfile>("p_sigma"+xY+"TrkVs"+varName,"#sigma_{trk,"+xy+"} vs. "+labelX+";"+labelX+" "+unitX+";#sigma_{trk,"+xy+"} [#mum]",nBinX,minBinX,maxBinX);
278  if(options.find("r") != std::string::npos)
279  correlationHists.PSigmaXVsVar = directory->make<TProfile>("p_sigma"+xY+"Vs"+varName,"#sigma_{r,"+xy+"} vs. "+labelX+";"+labelX+" "+unitX+";#sigma_{r,"+xy+"} [#mum]",nBinX,minBinX,maxBinX);
280 
281  return correlationHists;
282 }
283 
284 
285 
286 
287 void
289  return fillCorrHists("X", hitParameterStruct, variable);
290 }
291 void
293  return fillCorrHists("Y", hitParameterStruct, variable);
294 }
295 void
296 TrackerSectorStruct::CorrelationHists::fillCorrHists(const TString xY, const TrackStruct::HitParameterStruct& hitParameterStruct, double variable){
297  float norRes(999.);
298  float prob(999.);
299  float errHit(999.);
300  float errTrk(999.);
301  float err(999.);
302  if(xY=="X"){
303  norRes = hitParameterStruct.norResX;
304  prob = hitParameterStruct.probX;
305  errHit = hitParameterStruct.errXHit;
306  errTrk = hitParameterStruct.errXTrk;
307  err = hitParameterStruct.errX;
308  }
309  if(xY=="Y"){
310  norRes = hitParameterStruct.norResY;
311  prob = hitParameterStruct.probY;
312  errHit = hitParameterStruct.errYHit;
313  errTrk = hitParameterStruct.errYTrk;
314  err = hitParameterStruct.errY;
315  }
316 
317  if(Variable){Variable->Fill(variable);}
318 
319  if(NorResXVsVar){
320  NorResXVsVar->Fill(variable,norRes);
321  PNorResXVsVar->Fill(variable,norRes);
322  }
323  if(ProbXVsVar){
324  ProbXVsVar->Fill(variable,prob);
325  PProbXVsVar->Fill(variable,prob);
326  }
327  if(SigmaXHitVsVar){
328  SigmaXHitVsVar->Fill(variable,errHit*10000.);
329  PSigmaXHitVsVar->Fill(variable,errHit*10000.);
330  }
331  if(SigmaXTrkVsVar){
332  SigmaXTrkVsVar->Fill(variable,errTrk*10000.);
333  PSigmaXTrkVsVar->Fill(variable,errTrk*10000.);
334  }
335  if(SigmaXVsVar){
336  SigmaXVsVar->Fill(variable,err*10000.);
337  PSigmaXVsVar->Fill(variable,err*10000.);
338  }
339 
340 }
341 
342 
343 
344 
345 
346 #endif
TFileDirectory * directory_
void fillCorrHistsY(const TrackStruct::HitParameterStruct &hitParameterStruct, double variable)
std::map< std::string, std::vector< TH1 * > > m_sigmaY
std::map< std::string, std::vector< TH1 * > > m_sigmaX
void fillCorrHists(const TString, const TrackStruct::HitParameterStruct &hitParameterStruct, double variable)
CorrelationHists bookCorrHistsX(TString, TString, TString, TString, int, int, double, double, std::string="nphtr")
TProfile * PPhiSensXVsBarycentreX
T * make(const Args &...args) const
make new ROOT object
TProfile * PWidthVsWidthProjected
CorrelationHists bookCorrHistsY(TString, TString, TString, TString, int, int, double, double, std::string="nphtr")
void setCorrHistParams(TFileDirectory *, double, double, double)
CorrelationHists bookCorrHists(TString, TString, TString, TString, TString, int, int, double, double, std::string="nphtr")
std::map< std::string, CorrelationHists > m_correlationHistsX
std::map< unsigned int, std::map< std::string, TH1 * > > m_binnedHists
bool isPixel(HitType hitType)
volatile std::atomic< bool > shutdown_flag false
std::map< std::string, CorrelationHists > m_correlationHistsY
void fillCorrHistsX(const TrackStruct::HitParameterStruct &hitParameterStruct, double variable)
TProfile * PWidthDiffVsSigmaXHit
std::vector< unsigned int > v_rawId