CMS 3D CMS Logo

TrackerSectorStruct.h
Go to the documentation of this file.
1 #ifndef Alignment_APEEstimation_TrackerSectorStruct_h
2 #define Alignment_APEEstimation_TrackerSectorStruct_h
3 
4 #include <vector>
5 #include <map>
6 #include "TH1F.h"
7 #include "TH2F.h"
8 #include "TProfile.h"
9 #include "TString.h"
11 
13 
14 #include "TH1.h"
15 #include "TH2.h"
16 #include "TTree.h"
17 //class TH1;
18 //class TH2;
19 //class TH1F;
20 //class TH2F;
21 //class TProfile;
22 //class TString;
23 //class TFileDirectory;
24 
26 public:
27  inline TrackerSectorStruct();
28 
29  inline ~TrackerSectorStruct();
30 
33  : Variable(nullptr),
34  NorResXVsVar(nullptr),
35  ProbXVsVar(nullptr),
36  SigmaXHitVsVar(nullptr),
37  SigmaXTrkVsVar(nullptr),
38  SigmaXVsVar(nullptr),
39  PNorResXVsVar(nullptr),
40  PProbXVsVar(nullptr),
41  PSigmaXHitVsVar(nullptr),
42  PSigmaXTrkVsVar(nullptr),
43  PSigmaXVsVar(nullptr){};
44 
45  inline void fillCorrHists(const TString,
46  const TrackStruct::HitParameterStruct &hitParameterStruct,
47  double variable);
48  inline void fillCorrHistsX(const TrackStruct::HitParameterStruct &hitParameterStruct, double variable);
49  inline void fillCorrHistsY(const TrackStruct::HitParameterStruct &hitParameterStruct, double variable);
50 
51  TH1F *Variable;
54  };
55 
56  inline void setCorrHistParams(TFileDirectory *, double, double, double);
58  TString, TString, TString, TString, TString, int, int, double, double, std::string = "nphtr");
60  TString, TString, TString, TString, int, int, double, double, std::string = "nphtr");
62  TString, TString, TString, TString, int, int, double, double, std::string = "nphtr");
64  inline CorrelationHists bookCorrHists(TString, TString, TString, TString, int, double, double, std::string = "nphtr");
65  inline CorrelationHists bookCorrHistsX(TString, TString, TString, int, double, double, std::string = "nphtr");
66  inline CorrelationHists bookCorrHistsY(TString, TString, TString, int, double, double, std::string = "nphtr");
67 
69  double norResXMax_, sigmaXHitMax_, sigmaXMax_; // Used for x and y
70  std::map<std::string, CorrelationHists> m_correlationHistsX;
71  std::map<std::string, CorrelationHists> m_correlationHistsY;
72 
73  // Name of sector as string and as title of a histogram
75  TH1 *Name;
76 
77  // Module IDs of modules in sector
78  std::vector<unsigned int> v_rawId;
79 
80  TH1 *ResX, *NorResX, *XHit, *XTrk, *SigmaX2, *ProbX;
84  std::map<std::string, std::vector<TH1 *> > m_sigmaX;
85 
86  TH1 *ResY, *NorResY, *YHit, *YTrk, *SigmaY2, *ProbY;
89  std::map<std::string, std::vector<TH1 *> > m_sigmaY;
90 
91  //for every bin in sigmaX or sigmaY the needful histos to calculate the APE
92  std::map<unsigned int, std::map<std::string, TH1 *> > m_binnedHists;
93 
94  //for presenting results
95  TTree *RawId;
96  TH1 *EntriesX;
98  TH1 *EntriesY;
100 
101  // To book pixel-specific or strip-specific histos only
102  bool isPixel;
103 };
104 
106  : directory_(nullptr),
107  norResXMax_(999.),
108  sigmaXHitMax_(999.),
109  sigmaXMax_(999.),
110  name("default"),
111  Name(nullptr),
112  ResX(nullptr),
113  NorResX(nullptr),
114  XHit(nullptr),
115  XTrk(nullptr),
116  SigmaX2(nullptr),
117  ProbX(nullptr),
118  WidthVsPhiSensX(nullptr),
119  WidthVsWidthProjected(nullptr),
120  WidthDiffVsMaxStrip(nullptr),
121  WidthDiffVsSigmaXHit(nullptr),
122  PhiSensXVsBarycentreX(nullptr),
123  PWidthVsPhiSensX(nullptr),
124  PWidthVsWidthProjected(nullptr),
125  PWidthDiffVsMaxStrip(nullptr),
126  PWidthDiffVsSigmaXHit(nullptr),
127  PPhiSensXVsBarycentreX(nullptr),
128  ResY(nullptr),
129  NorResY(nullptr),
130  YHit(nullptr),
131  YTrk(nullptr),
132  SigmaY2(nullptr),
133  ProbY(nullptr),
134  PhiSensYVsBarycentreY(nullptr),
135  PPhiSensYVsBarycentreY(nullptr),
136  RawId(nullptr),
137  EntriesX(nullptr),
138  MeanX(nullptr),
139  RmsX(nullptr),
140  FitMeanX1(nullptr),
141  ResidualWidthX1(nullptr),
142  CorrectionX1(nullptr),
143  FitMeanX2(nullptr),
144  ResidualWidthX2(nullptr),
145  CorrectionX2(nullptr),
146  EntriesY(nullptr),
147  MeanY(nullptr),
148  RmsY(nullptr),
149  FitMeanY1(nullptr),
150  ResidualWidthY1(nullptr),
151  CorrectionY1(nullptr),
152  FitMeanY2(nullptr),
153  ResidualWidthY2(nullptr),
154  CorrectionY2(nullptr),
155  isPixel(false) {}
156 
158 
160  double norResXMax,
161  double sigmaXHitMax,
162  double sigmaXMax) {
164  norResXMax_ = norResXMax;
165  sigmaXHitMax_ = sigmaXHitMax;
167 }
168 
170  TString varTitle,
171  TString labelX,
172  TString unitX,
173  int nBinX1D,
174  int nBinX2D,
175  double minBinX,
176  double maxBinX,
178  return bookCorrHists("X", varName, varTitle, labelX, unitX, nBinX1D, nBinX2D, minBinX, maxBinX, options);
179 }
181  TString varTitle,
182  TString labelX,
183  TString unitX,
184  int nBinX1D,
185  int nBinX2D,
186  double minBinX,
187  double maxBinX,
189  return bookCorrHists("Y", varName, varTitle, labelX, unitX, nBinX1D, nBinX2D, minBinX, maxBinX, options);
190 }
192  TString varName,
193  TString varTitle,
194  TString labelX,
195  TString unitX,
196  int nBinX1D,
197  int nBinX2D,
198  double minBinX,
199  double maxBinX,
201  TString xy;
202  TString suffix;
203  if (xY == "X") {
204  xy = "x";
205  suffix = "";
206  }
207  if (xY == "Y") {
208  xy = "y";
209  suffix = "_y";
210  }
211 
212  const std::string &o(options);
213  CorrelationHists correlationHists;
214 
215  if (!(o.find('n') != std::string::npos || o.find('p') != std::string::npos || o.find('h') != std::string::npos ||
216  o.find('t') != std::string::npos || o.find('r') != std::string::npos))
217  return correlationHists;
218 
220  double norResXMax(norResXMax_), sigmaXHitMax(sigmaXHitMax_), sigmaXMax(sigmaXMax_);
221 
222  if (!directory)
223  return correlationHists;
224 
225  correlationHists.Variable = directory->make<TH1F>("h_" + varName + suffix,
226  varTitle + " " + labelX + ";" + labelX + " " + unitX + ";# hits",
227  nBinX1D,
228  minBinX,
229  maxBinX);
230 
231  if (options.find('n') != std::string::npos)
232  correlationHists.NorResXVsVar =
233  directory->make<TH2F>("h2_norRes" + xY + "Vs" + varName,
234  "r_{" + xy + "}/#sigma_{r," + xy + "} vs. " + labelX + ";" + labelX + " " + unitX +
235  ";(" + xy + "_{trk}-" + xy + "_{hit})/#sigma_{r," + xy + "}",
236  nBinX2D,
237  minBinX,
238  maxBinX,
239  25,
240  -norResXMax,
241  norResXMax);
242  if (options.find('p') != std::string::npos)
243  correlationHists.ProbXVsVar =
244  directory->make<TH2F>("h2_prob" + xY + "Vs" + varName,
245  "prob_{" + xy + "} vs. " + labelX + ";" + labelX + " " + unitX + ";prob_{" + xy + "}",
246  nBinX2D,
247  minBinX,
248  maxBinX,
249  60,
250  -0.1,
251  1.1);
252  if (options.find('h') != std::string::npos)
253  correlationHists.SigmaXHitVsVar = directory->make<TH2F>(
254  "h2_sigma" + xY + "HitVs" + varName,
255  "#sigma_{hit," + xy + "} vs. " + labelX + ";" + labelX + " " + unitX + ";#sigma_{hit," + xy + "} [#mum]",
256  nBinX2D,
257  minBinX,
258  maxBinX,
259  50,
260  0 * 10000.,
261  sigmaXHitMax * 10000.);
262  if (options.find('t') != std::string::npos)
263  correlationHists.SigmaXTrkVsVar = directory->make<TH2F>(
264  "h2_sigma" + xY + "TrkVs" + varName,
265  "#sigma_{trk," + xy + "} vs. " + labelX + ";" + labelX + " " + unitX + ";#sigma_{trk," + xy + "} [#mum]",
266  nBinX2D,
267  minBinX,
268  maxBinX,
269  50,
270  0 * 10000.,
271  sigmaXMax * 10000.);
272  if (options.find('r') != std::string::npos)
273  correlationHists.SigmaXVsVar = directory->make<TH2F>(
274  "h2_sigma" + xY + "Vs" + varName,
275  "#sigma_{r," + xy + "} vs. " + labelX + ";" + labelX + " " + unitX + ";#sigma_{r," + xy + "} [#mum]",
276  nBinX2D,
277  minBinX,
278  maxBinX,
279  50,
280  0 * 10000.,
281  sigmaXMax * 10000.);
282 
283  if (options.find('n') != std::string::npos)
284  correlationHists.PNorResXVsVar =
285  directory->make<TProfile>("p_norRes" + xY + "Vs" + varName,
286  "r_{" + xy + "}/#sigma_{r," + xy + "} vs. " + labelX + ";" + labelX + " " + unitX +
287  ";(" + xy + "_{trk}-" + xy + "_{hit})/#sigma_{r," + xy + "}",
288  nBinX2D,
289  minBinX,
290  maxBinX,
291  "s");
292  if (options.find('p') != std::string::npos)
293  correlationHists.PProbXVsVar = directory->make<TProfile>(
294  "p_prob" + xY + "Vs" + varName,
295  "prob_{" + xy + "} vs. " + labelX + ";" + labelX + " " + unitX + ";prob_{" + xy + "}",
296  nBinX2D,
297  minBinX,
298  maxBinX,
299  "s");
300  if (options.find('h') != std::string::npos)
301  correlationHists.PSigmaXHitVsVar = directory->make<TProfile>(
302  "p_sigma" + xY + "HitVs" + varName,
303  "#sigma_{hit," + xy + "} vs. " + labelX + ";" + labelX + " " + unitX + ";#sigma_{hit," + xy + "} [#mum]",
304  nBinX2D,
305  minBinX,
306  maxBinX);
307  if (options.find('t') != std::string::npos)
308  correlationHists.PSigmaXTrkVsVar = directory->make<TProfile>(
309  "p_sigma" + xY + "TrkVs" + varName,
310  "#sigma_{trk," + xy + "} vs. " + labelX + ";" + labelX + " " + unitX + ";#sigma_{trk," + xy + "} [#mum]",
311  nBinX2D,
312  minBinX,
313  maxBinX);
314  if (options.find('r') != std::string::npos)
315  correlationHists.PSigmaXVsVar = directory->make<TProfile>(
316  "p_sigma" + xY + "Vs" + varName,
317  "#sigma_{r," + xy + "} vs. " + labelX + ";" + labelX + " " + unitX + ";#sigma_{r," + xy + "} [#mum]",
318  nBinX2D,
319  minBinX,
320  maxBinX);
321 
322  return correlationHists;
323 }
324 
326  TString varName, TString labelX, TString unitX, int nBinX, double minBinX, double maxBinX, std::string options) {
327  return bookCorrHists("X", varName, labelX, unitX, nBinX, minBinX, maxBinX, options);
328 }
330  TString varName, TString labelX, TString unitX, int nBinX, double minBinX, double maxBinX, std::string options) {
331  return bookCorrHists("Y", varName, labelX, unitX, nBinX, minBinX, maxBinX, options);
332 }
334  TString varName,
335  TString labelX,
336  TString unitX,
337  int nBinX,
338  double minBinX,
339  double maxBinX,
341  TString xy;
342  if (xY == "X") {
343  xy = "x";
344  }
345  if (xY == "Y") {
346  xy = "y";
347  }
348 
349  const std::string &o(options);
350  CorrelationHists correlationHists;
351 
352  if (!(o.find('n') != std::string::npos || o.find('p') != std::string::npos || o.find('h') != std::string::npos ||
353  o.find('t') != std::string::npos || o.find('r') != std::string::npos))
354  return correlationHists;
355 
357  double norResXMax(norResXMax_), sigmaXHitMax(sigmaXHitMax_), sigmaXMax(sigmaXMax_);
358 
359  if (!directory)
360  return correlationHists;
361 
362  if (options.find('n') != std::string::npos)
363  correlationHists.NorResXVsVar =
364  directory->make<TH2F>("h2_norRes" + xY + "Vs" + varName,
365  "r_{" + xy + "}/#sigma_{r," + xy + "} vs. " + labelX + ";" + labelX + " " + unitX +
366  ";(" + xy + "_{trk}-" + xy + "_{hit})/#sigma_{r," + xy + "}",
367  nBinX,
368  minBinX,
369  maxBinX,
370  25,
371  -norResXMax,
372  norResXMax);
373  if (options.find('p') != std::string::npos)
374  correlationHists.ProbXVsVar =
375  directory->make<TH2F>("h2_prob" + xY + "Vs" + varName,
376  "prob_{" + xy + "} vs. " + labelX + ";" + labelX + " " + unitX + ";prob_{" + xy + "}",
377  nBinX,
378  minBinX,
379  maxBinX,
380  60,
381  -0.1,
382  1.1);
383  if (options.find('h') != std::string::npos)
384  correlationHists.SigmaXHitVsVar = directory->make<TH2F>(
385  "h2_sigma" + xY + "HitVs" + varName,
386  "#sigma_{hit," + xy + "} vs. " + labelX + ";" + labelX + " " + unitX + ";#sigma_{hit," + xy + "} [#mum]",
387  nBinX,
388  minBinX,
389  maxBinX,
390  50,
391  0 * 10000.,
392  sigmaXHitMax * 10000.);
393  if (options.find('t') != std::string::npos)
394  correlationHists.SigmaXTrkVsVar = directory->make<TH2F>(
395  "h2_sigma" + xY + "TrkVs" + varName,
396  "#sigma_{trk," + xy + "} vs. " + labelX + ";" + labelX + " " + unitX + ";#sigma_{trk," + xy + "} [#mum]",
397  nBinX,
398  minBinX,
399  maxBinX,
400  50,
401  0 * 10000.,
402  sigmaXMax * 10000.);
403  if (options.find('r') != std::string::npos)
404  correlationHists.SigmaXVsVar = directory->make<TH2F>(
405  "h2_sigma" + xY + "Vs" + varName,
406  "#sigma_{r," + xy + "} vs. " + labelX + ";" + labelX + " " + unitX + ";#sigma_{r," + xy + "} [#mum]",
407  nBinX,
408  minBinX,
409  maxBinX,
410  50,
411  0 * 10000.,
412  sigmaXMax * 10000.);
413 
414  if (options.find('n') != std::string::npos)
415  correlationHists.PNorResXVsVar =
416  directory->make<TProfile>("p_norRes" + xY + "Vs" + varName,
417  "r_{" + xy + "}/#sigma_{r," + xy + "} vs. " + labelX + ";" + labelX + " " + unitX +
418  ";(" + xy + "_{trk}-" + xy + "_{hit})/#sigma_{r," + xy + "}",
419  nBinX,
420  minBinX,
421  maxBinX,
422  "s");
423  if (options.find('p') != std::string::npos)
424  correlationHists.PProbXVsVar = directory->make<TProfile>(
425  "p_prob" + xY + "Vs" + varName,
426  "prob_{" + xy + "} vs. " + labelX + ";" + labelX + " " + unitX + ";prob_{" + xy + "}",
427  nBinX,
428  minBinX,
429  maxBinX,
430  "s");
431  if (options.find('h') != std::string::npos)
432  correlationHists.PSigmaXHitVsVar = directory->make<TProfile>(
433  "p_sigma" + xY + "HitVs" + varName,
434  "#sigma_{hit," + xy + "} vs. " + labelX + ";" + labelX + " " + unitX + ";#sigma_{hit," + xy + "} [#mum]",
435  nBinX,
436  minBinX,
437  maxBinX);
438  if (options.find('t') != std::string::npos)
439  correlationHists.PSigmaXTrkVsVar = directory->make<TProfile>(
440  "p_sigma" + xY + "TrkVs" + varName,
441  "#sigma_{trk," + xy + "} vs. " + labelX + ";" + labelX + " " + unitX + ";#sigma_{trk," + xy + "} [#mum]",
442  nBinX,
443  minBinX,
444  maxBinX);
445  if (options.find('r') != std::string::npos)
446  correlationHists.PSigmaXVsVar = directory->make<TProfile>(
447  "p_sigma" + xY + "Vs" + varName,
448  "#sigma_{r," + xy + "} vs. " + labelX + ";" + labelX + " " + unitX + ";#sigma_{r," + xy + "} [#mum]",
449  nBinX,
450  minBinX,
451  maxBinX);
452 
453  return correlationHists;
454 }
455 
457  double variable) {
458  return fillCorrHists("X", hitParameterStruct, variable);
459 }
461  double variable) {
462  return fillCorrHists("Y", hitParameterStruct, variable);
463 }
465  const TrackStruct::HitParameterStruct &hitParameterStruct,
466  double variable) {
467  float norRes(999.);
468  float prob(999.);
469  float errHit(999.);
470  float errTrk(999.);
471  float err(999.);
472  if (xY == "X") {
473  norRes = hitParameterStruct.norResX;
474  prob = hitParameterStruct.probX;
475  errHit = hitParameterStruct.errXHit;
476  errTrk = hitParameterStruct.errXTrk;
477  err = hitParameterStruct.errX;
478  }
479  if (xY == "Y") {
480  norRes = hitParameterStruct.norResY;
481  prob = hitParameterStruct.probY;
482  errHit = hitParameterStruct.errYHit;
483  errTrk = hitParameterStruct.errYTrk;
484  err = hitParameterStruct.errY;
485  }
486 
487  if (Variable) {
488  Variable->Fill(variable);
489  }
490 
491  if (NorResXVsVar) {
492  NorResXVsVar->Fill(variable, norRes);
493  PNorResXVsVar->Fill(variable, norRes);
494  }
495  if (ProbXVsVar) {
496  ProbXVsVar->Fill(variable, prob);
497  PProbXVsVar->Fill(variable, prob);
498  }
499  if (SigmaXHitVsVar) {
500  SigmaXHitVsVar->Fill(variable, errHit * 10000.);
501  PSigmaXHitVsVar->Fill(variable, errHit * 10000.);
502  }
503  if (SigmaXTrkVsVar) {
504  SigmaXTrkVsVar->Fill(variable, errTrk * 10000.);
505  PSigmaXTrkVsVar->Fill(variable, errTrk * 10000.);
506  }
507  if (SigmaXVsVar) {
508  SigmaXVsVar->Fill(variable, err * 10000.);
509  PSigmaXVsVar->Fill(variable, err * 10000.);
510  }
511 }
512 
513 #endif
TFileDirectory * directory_
void fillCorrHistsY(const TrackStruct::HitParameterStruct &hitParameterStruct, double variable)
std::map< std::string, std::vector< TH1 * > > m_sigmaX
std::map< std::string, std::vector< TH1 * > > m_sigmaY
void fillCorrHists(const TString, const TrackStruct::HitParameterStruct &hitParameterStruct, double variable)
CorrelationHists bookCorrHistsX(TString, TString, TString, TString, int, int, double, double, std::string="nphtr")
TProfile * PPhiSensYVsBarycentreY
TProfile * PPhiSensXVsBarycentreX
std::map< unsigned int, std::map< std::string, TH1 * > > m_binnedHists
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_correlationHistsY
bool isPixel(HitType hitType)
void fillCorrHistsX(const TrackStruct::HitParameterStruct &hitParameterStruct, double variable)
TProfile * PWidthDiffVsSigmaXHit
std::map< std::string, CorrelationHists > m_correlationHistsX
std::vector< unsigned int > v_rawId