CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Protected Attributes
SiStripDetSummary Class Reference

#include <SiStripDetSummary.h>

Classes

struct  Values
 

Public Member Functions

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. More...
 
void add (const DetId &detid)
 Used to compute the number of entries divided by subdetector, layer and mono/stereo. More...
 
std::map< unsigned int, ValuesgetCounts ()
 
void print (std::stringstream &ss, const bool mean=true) const
 
 SiStripDetSummary ()
 

Protected Attributes

bool computeMean_
 
std::map< unsigned int, ValuesvalueMap_
 

Detailed Description

Author
M. De Mattia
Date
26/3/2009 Class to compute and print summary information.

If values are passed together with DetIds (method add( detId, value)), it computes the mean value and rms of a given quantity and is able to print a summary divided by layer/disk for each subdetector.
If instead only DetIds are passed (method add( detId )), it prints the count divided by layer/disk for each subdetector.

Note: consider the possibility to move this class inside SiStripBaseObject as a protected member class.

Definition at line 31 of file SiStripDetSummary.h.

Constructor & Destructor Documentation

SiStripDetSummary::SiStripDetSummary ( )
inline

Definition at line 34 of file SiStripDetSummary.h.

References valueMap_.

34  : computeMean_(true)
35  {
36  // Initialize valueMap_ with zeros
37  // WARNING: this initialization is strongly connected with how the map is filled in the add method
38  // TIB: layers = 4, stereo = the first 2
39  // TOB: layers = 6, stereo = the first 2
40  // TEC: wheels = 9, stereo = 9
41  // TID: wheels = 3, stereo = 3
42  unsigned int layers[] = {4, 6, 9, 3};
43  unsigned int stereo[] = {2, 2, 9, 3};
44  Values initValues;
45  for( unsigned int subDet = 0; subDet < 4; ++subDet ) {
46  // Layers start from 1
47  for( unsigned int layer = 1; layer <= layers[subDet]; ++layer ) {
48  valueMap_[1000*(subDet+1)+layer*10] = initValues;
49  if( layer <= stereo[subDet] ) valueMap_[1000*(subDet+1)+layer*10+1] = initValues;
50  }
51  }
52  }
std::map< unsigned int, Values > valueMap_

Member Function Documentation

void SiStripDetSummary::add ( const DetId detid,
const float &  value 
)

Used to compute the mean value of the value variable divided by subdetector, layer and mono/stereo.

Definition at line 3 of file SiStripDetSummary.cc.

References TOBDetId::layer(), TIBDetId::layer(), DetId::rawId(), DetId::subdetId(), StripSubdetector::TEC, StripSubdetector::TIB, StripSubdetector::TID, StripSubdetector::TOB, relativeConstraints::value, valueMap_, TIDDetId::wheel(), and TECDetId::wheel().

Referenced by add(), SiStripDetVOff::getHVoffCounts(), SiStripDetVOff::getLVoffCounts(), SiStripLorentzAngle::printSummary(), SiStripBadStrip::printSummary(), SiStripDetVOff::printSummary(), SiStripNoises::printSummary(), SiStripBaseDelay::printSummary(), SiStripPedestals::printSummary(), SiStripApvGain::printSummary(), SiStripDelay::printSummary(), and SiStripGain::printSummary().

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 }
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:45
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
unsigned int wheel() const
wheel id
Definition: TECDetId.h:52
unsigned int layer() const
layer id
Definition: TIBDetId.h:41
unsigned int wheel() const
wheel id
Definition: TIDDetId.h:50
void SiStripDetSummary::add ( const DetId detid)
inline

Used to compute the number of entries divided by subdetector, layer and mono/stereo.

Definition at line 57 of file SiStripDetSummary.h.

References add(), and computeMean_.

58  {
59  computeMean_ = false;
60  add( detid, 0 );
61  }
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...
std::map<unsigned int, Values> SiStripDetSummary::getCounts ( )
inline

Definition at line 76 of file SiStripDetSummary.h.

References valueMap_.

Referenced by SiStripDetVOff::getHVoffCounts(), and SiStripDetVOff::getLVoffCounts().

77  {
78  return valueMap_;
79  }
std::map< unsigned int, Values > valueMap_
void SiStripDetSummary::print ( std::stringstream &  ss,
const bool  mean = true 
) const

Method used to write the output. By default mean == true and it writes the mean value. If mean == false it will write the count.

Definition at line 53 of file SiStripDetSummary.cc.

References computeMean_, prof2calltree::count, plotscripts::rms(), mathSSE::sqrt(), and valueMap_.

Referenced by SiStripLorentzAngle::printSummary(), SiStripBadStrip::printSummary(), SiStripNoises::printSummary(), SiStripDetVOff::printSummary(), SiStripBaseDelay::printSummary(), SiStripPedestals::printSummary(), SiStripApvGain::printSummary(), SiStripDelay::printSummary(), and SiStripGain::printSummary().

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 
62  std::string detector;
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 }
std::map< unsigned int, Values > valueMap_
T sqrt(T t)
Definition: SSEVec.h:46

Member Data Documentation

bool SiStripDetSummary::computeMean_
protected

Definition at line 83 of file SiStripDetSummary.h.

Referenced by add(), and print().

std::map<unsigned int, Values> SiStripDetSummary::valueMap_
protected

Definition at line 82 of file SiStripDetSummary.h.

Referenced by add(), getCounts(), print(), and SiStripDetSummary().