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  unsigned int layers[] = {3, 4};
11  unsigned index = 0;
12 
13  for (unsigned int idet = 0; idet < 2; ++idet) {
14  for (unsigned int il = 0; il < layers[idet]; ++il) {
15  index = (idet + 1) * 10000 + (il + 1) * 1000;
16  if (fVerbose)
17  cout << "Adding index = " << index << endl;
18  fCountMap[index] = 0;
19  }
20  }
21 }
22 
23 // ----------------------------------------------------------------------
24 void SiPixelDetSummary::add(const DetId& detid) {
25  fComputeMean = false;
26  add(detid, 0.);
27 }
28 
29 // ----------------------------------------------------------------------
30 void SiPixelDetSummary::add(const DetId& detid, const float& value) {
31  int detNum = -1;
32  int idet(-1), il(-1);
33  string name;
34 
35  switch (detid.subdetId()) {
37  idet = 1;
38  il = PixelBarrelName(detid).layerName();
39  name = PixelBarrelName(detid).name();
40  break;
41  }
43  idet = 2;
45  name = PixelEndcapName(detid).name();
46  if (hc == PixelEndcapName::pI || hc == PixelEndcapName::pO) {
47  il = 3 - PixelEndcapName(detid).diskName();
48  }
49  if (hc == PixelEndcapName::mI || hc == PixelEndcapName::mO) {
50  il = 2 + PixelEndcapName(detid).diskName();
51  }
52  break;
53  }
54  }
55 
56  detNum = idet * 10000 + il * 1000;
57 
58  if (fVerbose > 0)
59  cout << "detNum: " << detNum << " detID: " << static_cast<int>(detid) << " " << name << endl;
60 
61  fMeanMap[detNum] += value;
62  fRmsMap[detNum] += value * value;
63  fCountMap[detNum] += 1;
64 }
65 
66 // ----------------------------------------------------------------------
67 void SiPixelDetSummary::print(std::stringstream& ss, const bool mean) const {
68  std::map<int, int>::const_iterator countIt = fCountMap.begin();
69  std::map<int, double>::const_iterator meanIt = fMeanMap.begin();
70  std::map<int, double>::const_iterator rmsIt = fRmsMap.begin();
71 
72  ss << "subDet" << setw(15) << "layer" << setw(16);
73  if (mean)
74  ss << "mean +- rms" << endl;
75  else
76  ss << "count" << endl;
77 
79  std::string oldDetector;
80 
81  for (; countIt != fCountMap.end(); ++countIt, ++meanIt, ++rmsIt) {
82  int count = countIt->second;
83  double mean = 0.;
84  double rms = 0.;
85  if (fComputeMean && count != 0) {
86  mean = (meanIt->second) / count;
87  rms = (rmsIt->second) / count - mean * mean;
88  if (rms <= 0)
89  rms = 0;
90  else
91  rms = sqrt(rms);
92  }
93 
94  // -- Detector type
95  switch ((countIt->first) / 10000) {
96  case 1:
97  detector = "BPIX";
98  break;
99  case 2:
100  detector = "FPIX";
101  break;
102  }
103  if (detector != oldDetector) {
104  ss << std::endl << detector;
105  oldDetector = detector;
106  } else
107  ss << " ";
108 
109  // -- Layer number
110  int layer = (countIt->first) / 1000 - (countIt->first) / 10000 * 10;
111 
112  ss << std::setw(15) << layer << std::setw(13);
113  if (fComputeMean)
114  ss << mean << " +- " << rms << std::endl;
115  else
116  ss << countIt->second << std::endl;
117  }
118 }
SiPixelDetSummary.h
PixelEndcapName::mO
Definition: PixelEndcapName.h:18
PixelBarrelName.h
SiStripPI::mean
Definition: SiStripPayloadInspectorHelper.h:169
PixelSubdetector::PixelEndcap
Definition: PixelSubdetector.h:11
SiPixelDetSummary::SiPixelDetSummary
SiPixelDetSummary(int verbose=0)
Definition: SiPixelDetSummary.cc:9
PixelSubdetector::PixelBarrel
Definition: PixelSubdetector.h:11
SiPixelDetSummary::fMeanMap
std::map< int, double > fMeanMap
Definition: SiPixelDetSummary.h:37
gather_cfg.cout
cout
Definition: gather_cfg.py:144
PixelBarrelName
Definition: PixelBarrelName.h:16
SiPixelDetSummary::print
void print(std::stringstream &ss, const bool mean=true) const
Definition: SiPixelDetSummary.cc:67
SiPixelDetSummary::fRmsMap
std::map< int, double > fRmsMap
Definition: SiPixelDetSummary.h:38
PixelEndcapName::halfCylinder
HalfCylinder halfCylinder() const
Definition: PixelEndcapName.h:42
PixelBarrelName::layerName
int layerName() const
layer id
Definition: PixelBarrelName.h:43
SiStripPI::rms
Definition: SiStripPayloadInspectorHelper.h:169
SiPixelDetSummary::fVerbose
int fVerbose
Definition: SiPixelDetSummary.h:41
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
DetId
Definition: DetId.h:17
PixelBarrelName::name
std::string name() const override
from base class
Definition: PixelBarrelName.cc:731
PixelEndcapName
Definition: PixelEndcapName.h:16
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
verbose
static constexpr int verbose
Definition: HLTExoticaSubAnalysis.cc:25
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
PixelEndcapName::mI
Definition: PixelEndcapName.h:18
funct::true
true
Definition: Factorize.h:173
value
Definition: value.py:1
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PixelEndcapName::pO
Definition: PixelEndcapName.h:18
std
Definition: JetResolutionObject.h:76
PixelEndcapName::HalfCylinder
HalfCylinder
Definition: PixelEndcapName.h:18
PixelEndcapName::diskName
int diskName() const
disk id
Definition: PixelEndcapName.h:45
relativeConstraints.value
value
Definition: relativeConstraints.py:53
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
hgcalTestNeighbor_cfi.detector
detector
Definition: hgcalTestNeighbor_cfi.py:6
SiPixelDetSummary::add
void add(const DetId &detid, const float &value)
Definition: SiPixelDetSummary.cc:30
PixelEndcapName::name
std::string name() const override
from base class
Definition: PixelEndcapName.cc:365
PixelEndcapName::pI
Definition: PixelEndcapName.h:18
SiPixelDetSummary::fCountMap
std::map< int, int > fCountMap
Definition: SiPixelDetSummary.h:39
SiPixelDetSummary::fComputeMean
bool fComputeMean
Definition: SiPixelDetSummary.h:40
hgcalTopologyTester_cfi.layers
layers
Definition: hgcalTopologyTester_cfi.py:8
PixelEndcapName.h