CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Protected Attributes | Private Attributes
SiStripDetSummary Class Reference

#include <SiStripDetSummary.h>

Classes

struct  Values
 

Public Member Functions

void add (DetId detid, float value)
 Used to compute the mean value of the value variable divided by subdetector, layer and mono/stereo. More...
 
void add (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 (const TrackerTopology *tTopo)
 

Protected Attributes

bool computeMean_
 
std::map< unsigned int, ValuesvalueMap_
 

Private Attributes

const TrackerTopologytrackerTopo_
 

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 28 of file SiStripDetSummary.h.

Constructor & Destructor Documentation

SiStripDetSummary::SiStripDetSummary ( const TrackerTopology tTopo)
inlineexplicit

Definition at line 31 of file SiStripDetSummary.h.

References add(), LayerTriplets::layers(), and valueMap_.

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

Member Function Documentation

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

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

Definition at line 5 of file SiStripDetSummary.cc.

References DetId::subdetId(), StripSubdetector::TEC, TrackerTopology::tecStereo(), TrackerTopology::tecWheel(), StripSubdetector::TIB, TrackerTopology::tibLayer(), TrackerTopology::tibStereo(), StripSubdetector::TID, TrackerTopology::tidStereo(), TrackerTopology::tidWheel(), StripSubdetector::TOB, TrackerTopology::tobLayer(), TrackerTopology::tobStereo(), trackerTopo_, relativeConstraints::value, and valueMap_.

Referenced by add(), SiStripPI::fillNoiseDetSummary(), counter.Counter::register(), SequenceTypes.Task::remove(), SequenceTypes.Task::replace(), and SiStripDetSummary().

6 {
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 }
unsigned int tibLayer(const DetId &id) const
uint32_t tobStereo(const DetId &id) const
unsigned int tidWheel(const DetId &id) const
std::map< unsigned int, Values > valueMap_
const TrackerTopology * trackerTopo_
uint32_t tidStereo(const DetId &id) const
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
Definition: value.py:1
uint32_t tecStereo(const DetId &id) const
uint32_t tibStereo(const DetId &id) const
unsigned int tecWheel(const DetId &id) const
unsigned int tobLayer(const DetId &id) const
void SiStripDetSummary::add ( DetId  detid)
inline

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

Definition at line 54 of file SiStripDetSummary.h.

References add(), computeMean_, SiStripPI::mean, and print().

Referenced by counter.Counter::register(), SequenceTypes.Task::remove(), and SequenceTypes.Task::replace().

55  {
56  computeMean_ = false;
57  add( detid, 0 );
58  }
void add(DetId detid, 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 73 of file SiStripDetSummary.h.

References valueMap_.

74  {
75  return valueMap_;
76  }
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 43 of file SiStripDetSummary.cc.

References computeMean_, KineDebug3::count(), gamEcalExtractorBlocks_cff::detector, SiStripPI::rms, mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, and valueMap_.

Referenced by add().

44 {
45  // Compute the mean for each detector and for each layer.
46  std::map<unsigned int, Values>::const_iterator valueMapIt = valueMap_.begin();
47 
48  ss << "subDet" << std::setw(15) << "layer" << std::setw(16) << "mono/stereo" << std::setw(20);
49  if( mean ) ss << "mean +- rms" << std::endl;
50  else 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  }
86  else 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_ ) ss << mean << " +- " << rms << std::endl;
93  else ss << count << std::endl;
94  }
95 }
std::map< unsigned int, Values > valueMap_
T sqrt(T t)
Definition: SSEVec.h:18

Member Data Documentation

bool SiStripDetSummary::computeMean_
protected

Definition at line 80 of file SiStripDetSummary.h.

Referenced by add(), and print().

const TrackerTopology* SiStripDetSummary::trackerTopo_
private

Definition at line 82 of file SiStripDetSummary.h.

Referenced by add().

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

Definition at line 79 of file SiStripDetSummary.h.

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