CMS 3D CMS Logo

AlignmentPayloadInspectorHelper.h
Go to the documentation of this file.
1 #ifndef CONDCORE_ALIGNMENTPLUGINS_ALIGNMENTPAYLOADINSPECTORHELPER_H
2 #define CONDCORE_ALIGNMENTPLUGINS_ALIGNMENTPAYLOADINSPECTORHELPER_H
3 
4 #include <vector>
5 #include <numeric>
6 #include <string>
7 #include "TH1.h"
8 #include "TCanvas.h"
9 #include "TPaveStats.h"
10 #include "TStyle.h"
11 #include "TList.h"
13 
14 namespace AlignmentPI {
15 
16  // size of the phase-I Tracker APE payload (including both SS + DS modules)
17  static const unsigned int phase0size=19876;
18  static const float cmToUm = 10000;
19 
20  enum coordinate {
21  t_x=1,
22  t_y=2,
23  t_z=3,
27  };
28 
29  // M.M. 2017/09/12
30  // As the matrix is symmetric, we map only 6/9 terms
31  // More terms for the extended APE can be added to the following methods
32 
33  enum index {
34  XX=1,
35  XY=2,
36  XZ=3,
37  YZ=4,
38  YY=5,
39  ZZ=6
40  };
41 
42  enum partitions {
43  BPix=1, // Barrel Pixel
44  FPix=2, // Forward Pixel
45  TIB=3, // Tracker Inner Barrel
46  TID=4, // Tracker Inner Disks
47  TOB=5, // Tracker Outer Barrel
48  TEC=6 // Tracker Endcaps
49  };
50 
51  enum regions {
52  BPixL1o, //0 Barrel Pixel Layer 1 outer
53  BPixL1i, //1 Barrel Pixel Layer 1 inner
54  BPixL2o, //2 Barrel Pixel Layer 2 outer
55  BPixL2i, //3 Barrel Pixel Layer 2 inner
56  BPixL3o, //4 Barrel Pixel Layer 3 outer
57  BPixL3i, //5 Barrel Pixel Layer 3 inner
58  BPixL4o, //6 Barrel Pixel Layer 4 outer
59  BPixL4i, //7 Barrel Pixel Layer 4 inner
60  FPixmL1, //8 Forward Pixel Minus side Disk 1
61  FPixmL2, //9 Forward Pixel Minus side Disk 2
62  FPixmL3, //10 Forward Pixel Minus side Disk 3
63  FPixpL1, //11 Forward Pixel Plus side Disk 1
64  FPixpL2, //12 Forward Pixel Plus side Disk 2
65  FPixpL3, //13 Forward Pixel Plus side Disk 3
66  TIBL1Ro, //14 Inner Barrel Layer 1 Rphi outer
67  TIBL1Ri, //15 Inner Barrel Layer 1 Rphi inner
68  TIBL1So, //16 Inner Barrel Layer 1 Stereo outer
69  TIBL1Si, //17 Inner Barrel Layer 1 Stereo inner
70  TIBL2Ro, //18 Inner Barrel Layer 2 Rphi outer
71  TIBL2Ri, //19 Inner Barrel Layer 2 Rphi inner
72  TIBL2So, //20 Inner Barrel Layer 2 Stereo outer
73  TIBL2Si, //21 Inner Barrel Layer 2 Stereo inner
74  TIBL3o, //22 Inner Barrel Layer 3 outer
75  TIBL3i, //23 Inner Barrel Layer 3 inner
76  TIBL4o, //24 Inner Barrel Layer 4 outer
77  TIBL4i, //25 Inner Barrel Layer 4 inner
78  TOBL1Ro, //26 Outer Barrel Layer 1 Rphi outer
79  TOBL1Ri, //27 Outer Barrel Layer 1 Rphi inner
80  TOBL1So, //28 Outer Barrel Layer 1 Stereo outer
81  TOBL1Si, //29 Outer Barrel Layer 1 Stereo inner
82  TOBL2Ro, //30 Outer Barrel Layer 2 Rphi outer
83  TOBL2Ri, //31 Outer Barrel Layer 2 Rphi inner
84  TOBL2So, //32 Outer Barrel Layer 2 Stereo outer
85  TOBL2Si, //33 Outer Barrel Layer 2 Stereo inner
86  TOBL3o, //34 Outer Barrel Layer 3 outer
87  TOBL3i, //35 Outer Barrel Layer 3 inner
88  TOBL4o, //36 Outer Barrel Layer 4 outer
89  TOBL4i, //37 Outer Barrel Layer 4 inner
90  TOBL5o, //38 Outer Barrel Layer 5 outer
91  TOBL5i, //39 Outer Barrel Layer 5 inner
92  TOBL6o, //40 Outer Barrel Layer 6 outer
93  TOBL6i, //41 Outer Barrel Layer 6 inner
94  TIDmR1R, //42 Inner Disk Minus side Ring 1 Rphi
95  TIDmR1S, //43 Inner Disk Minus side Ring 1 Stereo
96  TIDmR2R, //44 Inner Disk Minus side Ring 2 Rphi
97  TIDmR2S, //45 Inner Disk Minus side Ring 2 Stereo
98  TIDmR3, //46 Inner Disk Minus side Ring 3
99  TIDpR1R, //47 Inner Disk Plus side Ring 1 Rphi
100  TIDpR1S, //48 Inner Disk Plus side Ring 1 Stereo
101  TIDpR2R, //49 Inner Disk Plus side Ring 2 Rphi
102  TIDpR2S, //50 Inner Disk Plus side Ring 2 Stereo
103  TIDpR3, //51 Inner Disk Plus side Ring 3
104  TECmR1R, //52 Endcaps Minus side Ring 1 Rphi
105  TECmR1S, //53 Endcaps Minus side Ring 1 Stereo
106  TECmR2R, //54 Encdaps Minus side Ring 2 Rphi
107  TECmR2S, //55 Endcaps Minus side Ring 2 Stereo
108  TECmR3, //56 Endcaps Minus side Ring 3
109  TECmR4, //57 Endcaps Minus side Ring 4
110  TECmR5, //58 Endcaps Minus side Ring 5
111  TECmR6, //59 Endcaps Minus side Ring 6
112  TECmR7, //60 Endcaps Minus side Ring 7
113  TECpR1R, //61 Endcaps Plus side Ring 1 Rphi
114  TECpR1S, //62 Endcaps Plus side Ring 1 Stereo
115  TECpR2R, //63 Encdaps Plus side Ring 2 Rphi
116  TECpR2S, //64 Endcaps Plus side Ring 2 Stereo
117  TECpR3, //65 Endcaps Plus side Ring 3
118  TECpR4, //66 Endcaps Plus side Ring 4
119  TECpR5, //67 Endcaps Plus side Ring 5
120  TECpR6, //68 Endcaps Plus side Ring 6
121  TECpR7, //67 Endcaps Plus side Ring 7
122  StripDoubleSide, // 70 -- not to be considered
123  NUM_OF_REGIONS // 71 -- default
124  };
125 
126  /*--------------------------------------------------------------------*/
128  /*--------------------------------------------------------------------*/
129  {
130  switch(e)
131  {
132  case AlignmentPI::BPixL1o : return "BPixL1o";
133  case AlignmentPI::BPixL1i : return "BPixL1i";
134  case AlignmentPI::BPixL2o : return "BPixL2o";
135  case AlignmentPI::BPixL2i : return "BPixL2i";
136  case AlignmentPI::BPixL3o : return "BPixL3o";
137  case AlignmentPI::BPixL3i : return "BPixL3i";
138  case AlignmentPI::BPixL4o : return "BPixL4o";
139  case AlignmentPI::BPixL4i : return "BPixL4i";
140  case AlignmentPI::FPixmL1 : return "FPixmL1";
141  case AlignmentPI::FPixmL2 : return "FPixmL2";
142  case AlignmentPI::FPixmL3 : return "FPixmL3";
143  case AlignmentPI::FPixpL1 : return "FPixpL1";
144  case AlignmentPI::FPixpL2 : return "FPixpL2";
145  case AlignmentPI::FPixpL3 : return "FPixpL3";
146  case AlignmentPI::TIBL1Ro : return "TIBL1Ro";
147  case AlignmentPI::TIBL1Ri : return "TIBL1Ri";
148  case AlignmentPI::TIBL1So : return "TIBL1So";
149  case AlignmentPI::TIBL1Si : return "TIBL1Si";
150  case AlignmentPI::TIBL2Ro : return "TIBL2Ro";
151  case AlignmentPI::TIBL2Ri : return "TIBL2Ri";
152  case AlignmentPI::TIBL2So : return "TIBL2So";
153  case AlignmentPI::TIBL2Si : return "TIBL2Si";
154  case AlignmentPI::TIBL3o : return "TIBL3o";
155  case AlignmentPI::TIBL3i : return "TIBL3i";
156  case AlignmentPI::TIBL4o : return "TIBL4o";
157  case AlignmentPI::TIBL4i : return "TIBL4i";
158  case AlignmentPI::TOBL1Ro : return "TOBL1Ro";
159  case AlignmentPI::TOBL1Ri : return "TOBL1Ri";
160  case AlignmentPI::TOBL1So : return "TOBL1So";
161  case AlignmentPI::TOBL1Si : return "TOBL1Si";
162  case AlignmentPI::TOBL2Ro : return "TOBL2Ro";
163  case AlignmentPI::TOBL2Ri : return "TOBL2Ri";
164  case AlignmentPI::TOBL2So : return "TOBL2So";
165  case AlignmentPI::TOBL2Si : return "TOBL2Si";
166  case AlignmentPI::TOBL3o : return "TOBL3o";
167  case AlignmentPI::TOBL3i : return "TOBL3i";
168  case AlignmentPI::TOBL4o : return "TOBL4o";
169  case AlignmentPI::TOBL4i : return "TOBL4i";
170  case AlignmentPI::TOBL5o : return "TOBL5o";
171  case AlignmentPI::TOBL5i : return "TOBL5i";
172  case AlignmentPI::TOBL6o : return "TOBL6o";
173  case AlignmentPI::TOBL6i : return "TOBL6i";
174  case AlignmentPI::TIDmR1R : return "TIDmR1R";
175  case AlignmentPI::TIDmR1S : return "TIDmR1S";
176  case AlignmentPI::TIDmR2R : return "TIDmR2R";
177  case AlignmentPI::TIDmR2S : return "TIDmR2S";
178  case AlignmentPI::TIDmR3 : return "TIDmR3";
179  case AlignmentPI::TIDpR1R : return "TIDpR1R";
180  case AlignmentPI::TIDpR1S : return "TIDpR1S";
181  case AlignmentPI::TIDpR2R : return "TIDpR2R";
182  case AlignmentPI::TIDpR2S : return "TIDpR2S";
183  case AlignmentPI::TIDpR3 : return "TIDpR3";
184  case AlignmentPI::TECmR1R : return "TECmR1R";
185  case AlignmentPI::TECmR1S : return "TECmR1S";
186  case AlignmentPI::TECmR2R : return "TECmR2R";
187  case AlignmentPI::TECmR2S : return "TECmR2S";
188  case AlignmentPI::TECmR3 : return "TECmR3";
189  case AlignmentPI::TECmR4 : return "TECmR4";
190  case AlignmentPI::TECmR5 : return "TECmR5";
191  case AlignmentPI::TECmR6 : return "TECmR6";
192  case AlignmentPI::TECmR7 : return "TECmR7";
193  case AlignmentPI::TECpR1R : return "TECpR1R";
194  case AlignmentPI::TECpR1S : return "TECpR1S";
195  case AlignmentPI::TECpR2R : return "TECpR2R";
196  case AlignmentPI::TECpR2S : return "TECpR2S";
197  case AlignmentPI::TECpR3 : return "TECpR3";
198  case AlignmentPI::TECpR4 : return "TECpR4";
199  case AlignmentPI::TECpR5 : return "TECpR5";
200  case AlignmentPI::TECpR6 : return "TECpR6";
201  case AlignmentPI::TECpR7 : return "TECpR7";
202  default:
203  edm::LogWarning("LogicError") << "Unknown partition: " << e;
204  return "";
205  }
206  }
207 
208  /*--------------------------------------------------------------------*/
209  bool isBPixOuterLadder(const DetId& detid, const TrackerTopology& tTopo,bool isPhase0)
210  /*--------------------------------------------------------------------*/
211  {
212  bool isOuter=false;
213  int layer = tTopo.pxbLayer(detid.rawId());
214  bool odd_ladder = tTopo.pxbLadder(detid.rawId())%2;
215  if (isPhase0) {
216  if (layer==2) isOuter = !odd_ladder;
217  else isOuter = odd_ladder;
218  } else {
219  if (layer==4) isOuter = odd_ladder;
220  else isOuter = !odd_ladder;
221  }
222  return isOuter;
223  }
224 
225  // ancillary struct to manage the topology
226  // info in a more compact way
227 
228  struct topolInfo
229  {
230  private:
231  uint32_t m_rawid;
233  int m_layer;
234  int m_side;
235  int m_ring;
236  bool m_isRphi;
239 
240  public:
241  void init();
242  void fillGeometryInfo(const DetId& detId,const TrackerTopology& tTopo,bool isPhase0);
244  bool sanityCheck();
245  void printAll();
246  virtual ~topolInfo(){}
247  };
248 
249  /*--------------------------------------------------------------------*/
251  /*--------------------------------------------------------------------*/
252  {
253 
254  std::cout<<" detId:" << m_rawid
255  <<" subdetid: " << m_subdetid
256  <<" layer: " << m_layer
257  <<" side: " << m_side
258  <<" ring: " << m_ring
259  <<" isRphi:" << m_isRphi
260  <<" isDoubleSide:"<< m_isDoubleSide
261  <<" isInternal:" << m_isInternal
262  << std::endl;
263  }
264 
265  /*--------------------------------------------------------------------*/
267  /*--------------------------------------------------------------------*/
268  {
269  m_rawid = 0;
270  m_subdetid = -1;
271  m_layer = -1;
272  m_side = -1;
273  m_ring = -1;
274  m_isRphi = false;
275  m_isDoubleSide = false;
276  m_isInternal = false;
277  };
278 
279  /*--------------------------------------------------------------------*/
281  /*--------------------------------------------------------------------*/
282  {
283  if(m_layer==0 ||
284  (m_subdetid==1 && m_layer>4) ||
285  (m_subdetid==2 && m_layer>3)
286  ){
287  return false;
288  } else{
289  return true;
290  }
291  }
292  /*--------------------------------------------------------------------*/
293  void topolInfo::fillGeometryInfo(const DetId& detId,const TrackerTopology& tTopo,bool isPhase0)
294  /*--------------------------------------------------------------------*/
295  {
296 
297  unsigned int subdetId = static_cast<unsigned int>(detId.subdetId());
298 
299  m_rawid = detId.rawId();
300  m_subdetid = subdetId;
301 
302  if ( subdetId == StripSubdetector::TIB) {
303  m_layer = tTopo.tibLayer(detId.rawId());
304  m_side = tTopo.tibSide(detId.rawId());
305  m_isRphi = tTopo.isRPhi(detId.rawId());
306  m_isDoubleSide = tTopo.tibIsDoubleSide(detId.rawId());
307  m_isInternal = tTopo.tibIsInternalString(detId.rawId());
308  }
309  else if ( subdetId == StripSubdetector::TOB ){
310  m_layer = tTopo.tobLayer(detId.rawId());
311  m_side = tTopo.tobSide(detId.rawId());
312  m_isRphi = tTopo.isRPhi(detId.rawId());
313  m_isDoubleSide = tTopo.tobIsDoubleSide(detId.rawId());
314  m_isInternal = tTopo.tobModule(detId.rawId())%2;
315  }
316  else if ( subdetId == StripSubdetector::TID) {
317  m_layer = tTopo.tidWheel(detId.rawId());
318  m_side = tTopo.tidSide(detId.rawId());
319  m_isRphi = tTopo.isRPhi(detId.rawId());
320  m_ring = tTopo.tidRing(detId.rawId());
321  m_isDoubleSide = tTopo.tidIsDoubleSide(detId.rawId());
322  m_isInternal = tTopo.tidModuleInfo(detId.rawId())[0];
323  }
324  else if ( subdetId == StripSubdetector::TEC ){
325  m_layer = tTopo.tecWheel(detId.rawId());
326  m_side = tTopo.tecSide(detId.rawId());
327  m_isRphi = tTopo.isRPhi(detId.rawId());
328  m_ring = tTopo.tecRing(detId.rawId());
329  m_isDoubleSide = tTopo.tecIsDoubleSide(detId.rawId());
330  m_isInternal = tTopo.tecPetalInfo(detId.rawId())[0];
331  }
332  else if ( subdetId == PixelSubdetector::PixelBarrel ) {
333  m_layer = tTopo.pxbLayer(detId.rawId());
334  m_isInternal = !AlignmentPI::isBPixOuterLadder(detId,tTopo,isPhase0);
335  }
336  else if ( subdetId == PixelSubdetector::PixelEndcap ) {
337  m_layer = tTopo.pxfDisk(detId.rawId());
338  m_side = tTopo.pxfSide(detId.rawId());
339  }
340  else
341  edm::LogWarning("LogicError") << "Unknown subdetid: " << subdetId;
342  }
343 
344  // ------------ method to assign a partition based on the topology struct info ---------------
345 
346  /*--------------------------------------------------------------------*/
348  /*--------------------------------------------------------------------*/
349  {
350 
352 
353  if(m_isDoubleSide){
355  }
356 
357  // BPix
358  if(m_subdetid==1){
359  switch(m_layer)
360  {
361  case 1:
363  break;
364  case 2:
366  break;
367  case 3:
369  break;
370  case 4:
372  break;
373  default:
374  edm::LogWarning("LogicError") << "Unknow BPix layer: " << m_layer;
375  break;
376  }
377  // FPix
378  } else if (m_subdetid==2) {
379  switch(m_layer)
380  {
381  case 1:
382  m_side > 1 ? ret = AlignmentPI::FPixpL1 : ret = AlignmentPI::FPixmL1;
383  break;
384  case 2:
385  m_side > 1 ? ret = AlignmentPI::FPixpL2 : ret = AlignmentPI::FPixmL2;
386  break;
387  case 3:
388  m_side > 1 ? ret = AlignmentPI::FPixpL3 : ret = AlignmentPI::FPixmL3;
389  break;
390  default:
391  edm::LogWarning("LogicError") << "Unknow FPix disk: " << m_layer;
392  break;
393  }
394  // TIB
395  } else if (m_subdetid==3) {
396  switch(m_layer)
397  {
398  case 1:
399  if(m_isRphi){
401  } else {
403  }
404  break;
405  case 2:
406  if(m_isRphi){
408  } else {
410  }
411  break;
412  case 3:
414  break;
415  case 4:
417  break;
418  default:
419  edm::LogWarning("LogicError") << "Unknow TIB layer: " << m_layer;
420  break;
421  }
422  // TID
423  } else if (m_subdetid==4) {
424  switch(m_ring)
425  {
426  case 1:
427  if(m_isRphi){
429  } else {
431  }
432  break;
433  case 2:
434  if(m_isRphi){
436  } else {
438  }
439  break;
440  case 3:
441  m_side > 1 ? ret = AlignmentPI::TIDpR3 : ret = AlignmentPI::TIDmR3;
442  break;
443  default:
444  edm::LogWarning("LogicError") << "Unknow TID wheel: " << m_layer;
445  break;
446  }
447  // TOB
448  } else if (m_subdetid==5) {
449  switch(m_layer)
450  {
451  case 1:
452  if(m_isRphi){
454  } else {
456  }
457  break;
458  case 2:
459  if(m_isRphi){
461  } else {
463  }
464  break;
465  case 3:
467  break;
468  case 4:
470  break;
471  case 5:
473  break;
474  case 6:
476  break;
477  default:
478  edm::LogWarning("LogicError") << "Unknow TOB layer: " << m_layer;
479  break;
480  }
481  // TEC
482  } else if (m_subdetid==6) {
483  switch(m_ring)
484  {
485  case 1:
486  if(m_isRphi){
488  } else {
490  }
491  break;
492  case 2:
493  if(m_isRphi){
495  } else {
497  }
498  break;
499  case 3:
500  m_side > 1 ? ret = AlignmentPI::TECpR3 : ret = AlignmentPI::TECmR3;
501  break;
502  case 4:
503  m_side > 1 ? ret = AlignmentPI::TECpR4 : ret = AlignmentPI::TECmR4;
504  break;
505  case 5:
506  m_side > 1 ? ret = AlignmentPI::TECpR5 : ret = AlignmentPI::TECmR5;
507  break;
508  case 6:
509  m_side > 1 ? ret = AlignmentPI::TECpR6 : ret = AlignmentPI::TECmR6;
510  break;
511  case 7:
512  m_side > 1 ? ret = AlignmentPI::TECpR7 : ret = AlignmentPI::TECmR7;
513  break;
514  default:
515  edm::LogWarning("LogicError") << "Unknow TEC ring: " << m_ring;
516  break;
517  }
518  }
519 
520  return ret;
521 
522  }
523 
524  /*--------------------------------------------------------------------*/
526  /*--------------------------------------------------------------------*/
527  {
528  switch(coord){
529  case t_x : return "x-translation";
530  case t_y : return "y-translation";
531  case t_z : return "z-translation";
532  case rot_alpha : return "#alpha angle rotation";
533  case rot_beta : return "#beta angle rotation";
534  case rot_gamma : return "#gamma angle rotation";
535  default : return "should never be here!";
536  }
537  }
538 
539  /*--------------------------------------------------------------------*/
541  /*--------------------------------------------------------------------*/
542  {
543  switch(i){
544  case XX : return "XX";
545  case XY : return "XY";
546  case XZ : return "XZ";
547  case YZ : return "YX";
548  case YY : return "YY";
549  case ZZ : return "ZZ";
550  default : return "should never be here!";
551  }
552  }
553 
554  /*--------------------------------------------------------------------*/
556  /*--------------------------------------------------------------------*/
557  {
558  switch(i){
559  case BPix : return "BPix";
560  case FPix : return "FPix";
561  case TIB : return "TIB";
562  case TID : return "TID";
563  case TOB : return "TOB";
564  case TEC : return "TEC";
565  default : return "should never be here!";
566  }
567  }
568 
569  /*--------------------------------------------------------------------*/
570  std::pair<int,int> getIndices(AlignmentPI::index i)
571  /*--------------------------------------------------------------------*/
572  {
573  switch(i){
574  case XX : return std::make_pair(0,0);
575  case XY : return std::make_pair(0,1);
576  case XZ : return std::make_pair(0,2);
577  case YZ : return std::make_pair(1,0);
578  case YY : return std::make_pair(1,1);
579  case ZZ : return std::make_pair(2,2);
580  default : return std::make_pair(-1,-1);
581  }
582  }
583 
584  /*--------------------------------------------------------------------*/
585  void makeNicePlotStyle(TH1 *hist,int color)
586  /*--------------------------------------------------------------------*/
587  {
588 
589  hist->SetStats(kFALSE);
590 
591  hist->GetXaxis()->SetTitleColor(color);
592  hist->SetLineColor(color);
593  hist->SetTitleSize(0.08);
594  hist->SetLineWidth(2);
595  hist->GetXaxis()->CenterTitle(true);
596  hist->GetYaxis()->CenterTitle(true);
597  hist->GetXaxis()->SetTitleFont(42);
598  hist->GetYaxis()->SetTitleFont(42);
599  hist->GetXaxis()->SetNdivisions(505);
600  hist->GetXaxis()->SetTitleSize(0.06);
601  hist->GetYaxis()->SetTitleSize(0.06);
602  hist->GetXaxis()->SetTitleOffset(1.0);
603  hist->GetYaxis()->SetTitleOffset(1.3);
604  hist->GetXaxis()->SetLabelFont(42);
605  hist->GetYaxis()->SetLabelFont(42);
606  hist->GetYaxis()->SetLabelSize(.05);
607  hist->GetXaxis()->SetLabelSize(.05);
608 
609  }
610 
611  /*--------------------------------------------------------------------*/
613  /*--------------------------------------------------------------------*/
614  {
615  char buffer[255];
616  TPaveText* stat = new TPaveText(0.60,0.75,0.95,0.95,"NDC");
617  sprintf(buffer,"%s \n",AlignmentPI::getStringFromPart(part).c_str());
618  stat->AddText(buffer);
619 
620  sprintf(buffer,"Entries : %i\n",(int)hist->GetEntries());
621  stat->AddText(buffer);
622 
623  if(std::abs(hist->GetMean())>0.01){
624  sprintf(buffer,"Mean : %6.2f\n",hist->GetMean());
625  } else {
626  sprintf(buffer,"Mean : %6.2f e-2\n",100*hist->GetMean());
627  }
628  stat->AddText(buffer);
629 
630  if(std::abs(hist->GetRMS())>0.01){
631  sprintf(buffer,"RMS : %6.2f\n",hist->GetRMS());
632  } else {
633  sprintf(buffer,"RMS : %6.2f e-2\n",100*hist->GetRMS());
634  }
635  stat->AddText(buffer);
636 
637  stat->SetLineColor(color);
638  stat->SetTextColor(color);
639  stat->SetFillColor(10);
640  stat->SetShadowColor(10);
641  stat->Draw();
642  }
643 
644  /*--------------------------------------------------------------------*/
645  std::pair<float,float> getTheRange(std::map<uint32_t,float> values,const float nsigma)
646  /*--------------------------------------------------------------------*/
647  {
648  float sum = std::accumulate(std::begin(values),
649  std::end(values),
650  0.0,
651  [] (float value, const std::map<uint32_t,float>::value_type& p)
652  { return value + p.second; }
653  );
654 
655  float m = sum / values.size();
656 
657  float accum = 0.0;
658  std::for_each (std::begin(values),
659  std::end(values),
661  {accum += (p.second - m) * (p.second - m);}
662  );
663 
664  float stdev = sqrt(accum / (values.size()-1));
665 
666  if(stdev!=0.){
667  return std::make_pair(m-nsigma*stdev,m+nsigma*stdev);
668  } else {
669  return std::make_pair(m>0.? 0.95*m : 1.05*m, m>0? 1.05*m : 0.95*m);
670  }
671  }
672 
673  /*--------------------------------------------------------------------*/
674  std::pair<double,double> calculatePosition(TVirtualPad* myPad,int boundary)
675  /*--------------------------------------------------------------------*/
676  {
677 
678  int ix1;
679  int ix2;
680  int iw = myPad->GetWw();
681  int ih = myPad->GetWh();
682  double x1p,y1p,x2p,y2p;
683  myPad->GetPadPar(x1p,y1p,x2p,y2p);
684  ix1 = (int)(iw*x1p);
685  ix2 = (int)(iw*x2p);
686  double wndc = std::min(1.,(double)iw/(double)ih);
687  double rw = wndc/(double)iw;
688  double x1ndc = (double)ix1*rw;
689  double x2ndc = (double)ix2*rw;
690  double rx1,ry1,rx2,ry2;
691  myPad->GetRange(rx1,ry1,rx2,ry2);
692  double rx = (x2ndc-x1ndc)/(rx2-rx1);
693  double _sx;
694  _sx = rx*(boundary-rx1)+x1ndc;
695  double _dx = _sx+0.05;
696 
697  return std::make_pair(_sx,_dx);
698  }
699 
700 
701 }
702 
703 #endif
bool tecIsDoubleSide(const DetId &id) const
bool tobIsDoubleSide(const DetId &id) const
bool tibIsDoubleSide(const DetId &id) const
unsigned int tibLayer(const DetId &id) const
unsigned int tidRing(const DetId &id) const
void makeNicePlotStyle(TH1 *hist, int color)
std::vector< unsigned int > tidModuleInfo(const DetId &id) const
unsigned int pxfDisk(const DetId &id) const
unsigned int tecRing(const DetId &id) const
ring id
unsigned int pxbLadder(const DetId &id) const
std::string getStringFromPart(AlignmentPI::partitions i)
unsigned int tidWheel(const DetId &id) const
bool isBPixOuterLadder(const DetId &detid, const TrackerTopology &tTopo, bool isPhase0)
std::pair< float, float > getTheRange(std::map< uint32_t, float > values, const float nsigma)
std::pair< int, int > getIndices(AlignmentPI::index i)
static const float cmToUm
uint32_t rawId() const
get the raw id
Definition: DetId.h:44
void makeNiceStats(TH1F *hist, AlignmentPI::partitions part, int color)
unsigned int tibSide(const DetId &id) const
static const unsigned int phase0size
std::vector< unsigned int > tecPetalInfo(const DetId &id) const
std::pair< double, double > calculatePosition(TVirtualPad *myPad, int boundary)
unsigned int tidSide(const DetId &id) const
T sqrt(T t)
Definition: SSEVec.h:18
unsigned int tobSide(const DetId &id) const
void fillGeometryInfo(const DetId &detId, const TrackerTopology &tTopo, bool isPhase0)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define end
Definition: vmac.h:39
Definition: value.py:1
T min(T a, T b)
Definition: MathUtil.h:58
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:38
unsigned int pxbLayer(const DetId &id) const
Definition: DetId.h:18
std::string getStringFromCoordinate(AlignmentPI::coordinate coord)
part
Definition: HCALResponse.h:20
AlignmentPI::regions filterThePartition()
bool tidIsDoubleSide(const DetId &id) const
std::string getStringFromIndex(AlignmentPI::index i)
unsigned int tobModule(const DetId &id) const
#define begin
Definition: vmac.h:32
unsigned int pxfSide(const DetId &id) const
def stdev(xlist)
Definition: plotscripts.py:67
std::string getStringFromRegionEnum(AlignmentPI::regions e)
bool isRPhi(const DetId &id) const
bool tibIsInternalString(const DetId &id) const
unsigned int tecWheel(const DetId &id) const
unsigned int tobLayer(const DetId &id) const
unsigned int tecSide(const DetId &id) const