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  // string name( detector + boost::lexical_cast<string>(layer) + boost::lexical_cast<string>(stereo) );
38  valueMap_[detNum].mean += value;
39  valueMap_[detNum].rms += value * value;
40  valueMap_[detNum].count += 1;
41 }
42 
43 void SiStripDetSummary::print(std::stringstream& ss, const bool mean) const {
44  // Compute the mean for each detector and for each layer.
45  std::map<unsigned int, Values>::const_iterator valueMapIt = valueMap_.begin();
46 
47  ss << "subDet" << std::setw(15) << "layer" << std::setw(16) << "mono/stereo" << std::setw(20);
48  if (mean)
49  ss << "mean +- rms" << std::endl;
50  else
51  ss << "count" << std::endl;
52 
54  std::string oldDetector;
55 
56  for (; valueMapIt != valueMap_.end(); ++valueMapIt) {
57  int count = valueMapIt->second.count;
58  double mean = 0.;
59  double rms = 0.;
60  if (computeMean_ && count != 0) {
61  mean = (valueMapIt->second.mean) / count;
62  rms = (valueMapIt->second.rms) / count - mean * mean;
63  if (rms <= 0)
64  rms = 0;
65  else
66  rms = sqrt(rms);
67  }
68  // Detector type
69  switch ((valueMapIt->first) / 1000) {
70  case 1:
71  detector = "TIB ";
72  break;
73  case 2:
74  detector = "TOB ";
75  break;
76  case 3:
77  detector = "TEC ";
78  break;
79  case 4:
80  detector = "TID ";
81  break;
82  }
83  if (detector != oldDetector) {
84  ss << std::endl << detector;
85  oldDetector = detector;
86  } else
87  ss << " ";
88  // Layer number
89  int layer = (valueMapIt->first) / 10 - (valueMapIt->first) / 1000 * 100;
90  int stereo = valueMapIt->first - layer * 10 - (valueMapIt->first) / 1000 * 1000;
91 
92  ss << std::setw(15) << layer << std::setw(13) << stereo << std::setw(18);
93  if (computeMean_)
94  ss << mean << " +- " << rms << std::endl;
95  else
96  ss << count << std::endl;
97  }
98 }
SiStripDetSummary.h
SiStripPI::mean
Definition: SiStripPayloadInspectorHelper.h:169
SiStripPI::rms
Definition: SiStripPayloadInspectorHelper.h:169
TrackerTopology::tobStereo
uint32_t tobStereo(const DetId &id) const
Definition: TrackerTopology.h:275
TrackerTopology::tidWheel
unsigned int tidWheel(const DetId &id) const
Definition: TrackerTopology.h:201
SiStripDetSummary::print
void print(std::stringstream &ss, const bool mean=true) const
Definition: SiStripDetSummary.cc:43
SiStripDetSummary::trackerTopo_
const TrackerTopology * trackerTopo_
Definition: SiStripDetSummary.h:78
SiStripDetSummary::valueMap_
std::map< unsigned int, Values > valueMap_
Definition: SiStripDetSummary.h:74
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
DetId
Definition: DetId.h:17
TrackerTopology.h
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
StripSubdetector::TIB
static constexpr auto TIB
Definition: StripSubdetector.h:16
SiStripDetSummary::add
void add(DetId detid, float value)
Used to compute the mean value of the value variable divided by subdetector, layer and mono/stereo.
Definition: SiStripDetSummary.cc:6
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
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
TrackerTopology::tibStereo
uint32_t tibStereo(const DetId &id) const
Definition: TrackerTopology.h:279
TrackerTopology::tidStereo
uint32_t tidStereo(const DetId &id) const
Definition: TrackerTopology.h:283
value
Definition: value.py:1
SiStripDetSummary::computeMean_
bool computeMean_
Definition: SiStripDetSummary.h:75
TrackerTopology::tobLayer
unsigned int tobLayer(const DetId &id) const
Definition: TrackerTopology.h:147
StripSubdetector::TEC
static constexpr auto TEC
Definition: StripSubdetector.h:19
relativeConstraints.value
value
Definition: relativeConstraints.py:53
StripSubdetector::TOB
static constexpr auto TOB
Definition: StripSubdetector.h:18
hgcalTestNeighbor_cfi.detector
detector
Definition: hgcalTestNeighbor_cfi.py:6
TrackerTopology::tecWheel
unsigned int tecWheel(const DetId &id) const
Definition: TrackerTopology.h:198
StripSubdetector.h
StripSubdetector::TID
static constexpr auto TID
Definition: StripSubdetector.h:17
TrackerTopology::tecStereo
uint32_t tecStereo(const DetId &id) const
Definition: TrackerTopology.h:287
TrackerTopology::tibLayer
unsigned int tibLayer(const DetId &id) const
Definition: TrackerTopology.h:150