CMS 3D CMS Logo

SiStripDetSummary.cc
Go to the documentation of this file.
2 
3 void SiStripDetSummary::add(const DetId & detid, const float & value)
4 {
5  int layer = 0;
6  int stereo = 0;
7  int detNum = 0;
8 
9  // Using the operator[] if the element does not exist it is created with the default value. That is 0 for integral types.
10  switch (detid.subdetId()) {
12  {
13  TIBDetId theTIBDetId(detid.rawId());
14  layer = theTIBDetId.layer();
15  stereo = theTIBDetId.stereo();
16  detNum = 1000;
17  break;
18  }
20  {
21  TOBDetId theTOBDetId(detid.rawId());
22  layer = theTOBDetId.layer();
23  stereo = theTOBDetId.stereo();
24  detNum = 2000;
25  break;
26  }
28  {
29  TECDetId theTECDetId(detid.rawId());
30  // is this module in TEC+ or TEC-?
31  layer = theTECDetId.wheel();
32  stereo = theTECDetId.stereo();
33  detNum = 3000;
34  break;
35  }
37  {
38  TIDDetId theTIDDetId(detid.rawId());
39  // is this module in TID+ or TID-?
40  layer = theTIDDetId.wheel();
41  stereo = theTIDDetId.stereo();
42  detNum = 4000;
43  break;
44  }
45  }
46  detNum += layer*10 + stereo;
47  // string name( detector + boost::lexical_cast<string>(layer) + boost::lexical_cast<string>(stereo) );
48  valueMap_[detNum].mean += value;
49  valueMap_[detNum].rms += value*value;
50  valueMap_[detNum].count += 1;
51 }
52 
53 void SiStripDetSummary::print(std::stringstream & ss, const bool mean) const
54 {
55  // Compute the mean for each detector and for each layer.
56  std::map<unsigned int, Values>::const_iterator valueMapIt = valueMap_.begin();
57 
58  ss << "subDet" << std::setw(15) << "layer" << std::setw(16) << "mono/stereo" << std::setw(20);
59  if( mean ) ss << "mean +- rms" << std::endl;
60  else ss << "count" << std::endl;
61 
63  std::string oldDetector;
64 
65  for( ; valueMapIt != valueMap_.end(); ++valueMapIt ) {
66  int count = valueMapIt->second.count;
67  double mean = 0.;
68  double rms = 0.;
69  if( computeMean_ && count != 0 ) {
70  mean = (valueMapIt->second.mean)/count;
71  rms = (valueMapIt->second.rms)/count - mean*mean;
72  if (rms <= 0)
73  rms = 0;
74  else
75  rms = sqrt(rms);
76  }
77  // Detector type
78  switch ((valueMapIt->first)/1000) {
79  case 1:
80  detector = "TIB ";
81  break;
82  case 2:
83  detector = "TOB ";
84  break;
85  case 3:
86  detector = "TEC ";
87  break;
88  case 4:
89  detector = "TID ";
90  break;
91  }
92  if( detector != oldDetector ) {
93  ss << std::endl << detector;
94  oldDetector = detector;
95  }
96  else ss << " ";
97  // Layer number
98  int layer = (valueMapIt->first)/10 - (valueMapIt->first)/1000*100;
99  int stereo = valueMapIt->first - layer*10 -(valueMapIt->first)/1000*1000;
100 
101  ss << std::setw(15) << layer << std::setw(13) << stereo << std::setw(18);
102  if( computeMean_ ) ss << mean << " +- " << rms << std::endl;
103  else ss << count << std::endl;
104  }
105 }
unsigned int layer() const
layer id
Definition: TOBDetId.h:39
std::map< unsigned int, Values > valueMap_
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
T sqrt(T t)
Definition: SSEVec.h:18
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:37
void print(std::stringstream &ss, const bool mean=true) const
Definition: DetId.h:18
unsigned int wheel() const
wheel id
Definition: TECDetId.h:52
unsigned int layer() const
layer id
Definition: TIBDetId.h:41
void add(const DetId &detid, const float &value)
Used to compute the mean value of the value variable divided by subdetector, layer and mono/stereo...
unsigned int wheel() const
wheel id
Definition: TIDDetId.h:50