CMS 3D CMS Logo

SiPixelDetSummary.cc
Go to the documentation of this file.
2 
5 
6 using namespace std;
7 
8 // ----------------------------------------------------------------------
9 SiPixelDetSummary::SiPixelDetSummary(int verbose): fComputeMean(true), fVerbose(verbose) {
10 
11  unsigned int layers[] = {3, 4};
12  unsigned index = 0;
13 
14  for (unsigned int idet = 0; idet < 2; ++idet) {
15  for (unsigned int il = 0; il < layers[idet]; ++il) {
16  index = (idet+1)*10000 + (il+1)*1000;
17  if (fVerbose) cout << "Adding index = " << index << endl;
18  fCountMap[index] = 0;
19  }
20  }
21 }
22 
23 
24 // ----------------------------------------------------------------------
25 void SiPixelDetSummary::add(const DetId & detid) {
26  fComputeMean= false;
27  add(detid, 0.);
28 }
29 
30 
31 // ----------------------------------------------------------------------
32 void SiPixelDetSummary::add(const DetId & detid, const float & value) {
33 
34  int detNum = -1;
35  int idet(-1), il(-1);
36  string name;
37 
38  switch (detid.subdetId()) {
40  idet = 1;
41  il = PixelBarrelName(detid).layerName();
42  name = PixelBarrelName(detid).name();
43  break;
44  }
46  idet = 2;
48  name = PixelEndcapName(detid).name();
49  if (hc == PixelEndcapName::pI || hc == PixelEndcapName::pO) {
50  il = 3 - PixelEndcapName(detid).diskName();
51  }
52  if (hc == PixelEndcapName::mI || hc == PixelEndcapName::mO) {
53  il = 2 + PixelEndcapName(detid).diskName();
54  }
55  break;
56  }
57  }
58 
59  detNum = idet*10000 + il*1000;
60 
61  if (fVerbose > 0)
62  cout << "detNum: " << detNum
63  << " detID: " << static_cast<int>(detid)
64  << " " << name
65  << endl;
66 
67  fMeanMap[detNum] += value;
68  fRmsMap[detNum] += value*value;
69  fCountMap[detNum] += 1;
70 }
71 
72 // ----------------------------------------------------------------------
73 void SiPixelDetSummary::print(std::stringstream & ss, const bool mean) const {
74  std::map<int, int>::const_iterator countIt = fCountMap.begin();
75  std::map<int, double>::const_iterator meanIt = fMeanMap.begin();
76  std::map<int, double>::const_iterator rmsIt = fRmsMap.begin();
77 
78  ss << "subDet" << setw(15) << "layer" << setw(16);
79  if (mean) ss << "mean +- rms" << endl;
80  else ss << "count" << endl;
81 
83  std::string oldDetector;
84 
85  for (; countIt != fCountMap.end(); ++countIt, ++meanIt, ++rmsIt ) {
86  int count = countIt->second;
87  double mean = 0.;
88  double rms = 0.;
89  if (fComputeMean && count != 0) {
90  mean = (meanIt->second)/count;
91  rms = (rmsIt->second)/count - mean*mean;
92  if (rms <= 0)
93  rms = 0;
94  else
95  rms = sqrt(rms);
96  }
97 
98  // -- Detector type
99  switch ((countIt->first)/10000) {
100  case 1:
101  detector = "BPIX";
102  break;
103  case 2:
104  detector = "FPIX";
105  break;
106  }
107  if( detector != oldDetector ) {
108  ss << std::endl << detector;
109  oldDetector = detector;
110  }
111  else ss << " ";
112 
113  // -- Layer number
114  int layer = (countIt->first)/1000 - (countIt->first)/10000*10;
115 
116  ss << std::setw(15) << layer << std::setw(13) ;
117  if (fComputeMean) ss << mean << " +- " << rms << std::endl;
118  else ss << countIt->second << std::endl;
119  }
120 }
std::vector< LayerSetAndLayers > layers(const SeedingLayerSetsHits &sets)
Definition: LayerTriplets.cc:4
std::string name() const override
from base class
void add(const DetId &detid, const float &value)
std::map< int, double > fMeanMap
T sqrt(T t)
Definition: SSEVec.h:18
void print(std::stringstream &ss, const bool mean=true) const
SiPixelDetSummary(int verbose=0)
std::string name() const override
from base class
Definition: value.py:1
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:38
Definition: DetId.h:18
std::map< int, double > fRmsMap
int layerName() const
layer id
std::map< int, int > fCountMap
susybsm::HSCParticleCollection hc
Definition: classes.h:25
int diskName() const
disk id
HalfCylinder halfCylinder() const