CMS 3D CMS Logo

SiStripDetSummary.cc
Go to the documentation of this file.
3 
5 
6 void SiStripDetSummary::add(DetId detid, float value) {
7  int layer = 0;
8  int stereo = 0;
9  int detNum = 0;
10 
11  // Using the operator[] if the element does not exist it is created with the default value. That is 0 for integral types.
12  switch (detid.subdetId()) {
14  layer = trackerTopo_->tibLayer(detid);
15  stereo = trackerTopo_->tibStereo(detid);
16  detNum = 1000;
17  break;
19  layer = trackerTopo_->tobLayer(detid);
20  stereo = trackerTopo_->tobStereo(detid);
21  detNum = 2000;
22  break;
24  // is this module in TEC+ or TEC-?
25  layer = trackerTopo_->tecWheel(detid);
26  stereo = trackerTopo_->tecStereo(detid);
27  detNum = 3000;
28  break;
30  // is this module in TID+ or TID-?
31  layer = trackerTopo_->tidWheel(detid);
32  stereo = trackerTopo_->tidStereo(detid);
33  detNum = 4000;
34  break;
35  }
36  detNum += layer * 10 + stereo;
37  valueMap_[detNum].mean += value;
38  valueMap_[detNum].rms += value * value;
39  valueMap_[detNum].count += 1;
40 }
41 
42 void SiStripDetSummary::print(std::stringstream& ss, const bool mean) const {
43  // Compute the mean for each detector and for each layer.
44  std::map<unsigned int, Values>::const_iterator valueMapIt = valueMap_.begin();
45 
46  ss << "subDet" << std::setw(15) << "layer" << std::setw(16) << "mono/stereo" << std::setw(20);
47  if (mean)
48  ss << "mean +- rms" << std::endl;
49  else
50  ss << "count" << std::endl;
51 
53  std::string oldDetector;
54 
55  for (; valueMapIt != valueMap_.end(); ++valueMapIt) {
56  int count = valueMapIt->second.count;
57  double mean = 0.;
58  double rms = 0.;
59  if (computeMean_ && count != 0) {
60  mean = (valueMapIt->second.mean) / count;
61  rms = (valueMapIt->second.rms) / count - mean * mean;
62  if (rms <= 0)
63  rms = 0;
64  else
65  rms = sqrt(rms);
66  }
67  // Detector type
68  switch ((valueMapIt->first) / 1000) {
69  case 1:
70  detector = "TIB ";
71  break;
72  case 2:
73  detector = "TOB ";
74  break;
75  case 3:
76  detector = "TEC ";
77  break;
78  case 4:
79  detector = "TID ";
80  break;
81  }
82  if (detector != oldDetector) {
83  ss << std::endl << detector;
84  oldDetector = detector;
85  } else
86  ss << " ";
87  // Layer number
88  int layer = (valueMapIt->first) / 10 - (valueMapIt->first) / 1000 * 100;
89  int stereo = valueMapIt->first - layer * 10 - (valueMapIt->first) / 1000 * 1000;
90 
91  ss << std::setw(15) << layer << std::setw(13) << stereo << std::setw(18);
92  if (computeMean_)
93  ss << mean << " +- " << rms << std::endl;
94  else
95  ss << count << std::endl;
96  }
97 }
static constexpr auto TEC
unsigned int tobLayer(const DetId &id) const
uint32_t tidStereo(const DetId &id) const
unsigned int tidWheel(const DetId &id) const
unsigned int tecWheel(const DetId &id) const
void print(std::stringstream &ss, const bool mean=true) const
std::map< unsigned int, Values > valueMap_
constexpr std::array< uint8_t, layerIndexSize > layer
const TrackerTopology * trackerTopo_
uint32_t tobStereo(const DetId &id) const
T sqrt(T t)
Definition: SSEVec.h:19
void add(DetId detid, float value)
Used to compute the mean value of the value variable divided by subdetector, layer and mono/stereo...
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
Definition: value.py:1
static constexpr auto TOB
Definition: DetId.h:17
static constexpr auto TIB
uint32_t tecStereo(const DetId &id) const
unsigned int tibLayer(const DetId &id) const
static constexpr auto TID
uint32_t tibStereo(const DetId &id) const