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