CMS 3D CMS Logo

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

#include <SiPixelDetSummary.h>

Public Member Functions

void add (const DetId &detid, const float &value)
 
void add (const DetId &detid)
 
std::map< int, int > getCounts ()
 
void print (std::stringstream &ss, const bool mean=true) const
 
 SiPixelDetSummary (int verbose=0)
 

Protected Attributes

bool fComputeMean
 
std::map< int, int > fCountMap
 
std::map< int, double > fMeanMap
 
std::map< int, double > fRmsMap
 
int fVerbose
 

Detailed Description

Author
Urs Langenegger, using SiStripDetSummary
Date
2010/05/04 Class to compute and print pixel detector 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.

Definition at line 25 of file SiPixelDetSummary.h.

Constructor & Destructor Documentation

SiPixelDetSummary::SiPixelDetSummary ( int  verbose = 0)

Definition at line 11 of file SiPixelDetSummary.cc.

References gather_cfg::cout, fCountMap, fVerbose, and getHLTprescales::index.

11  : fComputeMean(true), fVerbose(verbose) {
12 
13  unsigned int layers[] = {3, 4};
14  unsigned index = 0;
15 
16  for (unsigned int idet = 0; idet < 2; ++idet) {
17  for (unsigned int il = 0; il < layers[idet]; ++il) {
18  index = (idet+1)*10000 + (il+1)*1000;
19  if (fVerbose) cout << "Adding index = " << index << endl;
20  fCountMap[index] = 0;
21  }
22  }
23 }
std::map< int, int > fCountMap
tuple cout
Definition: gather_cfg.py:121

Member Function Documentation

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

Definition at line 34 of file SiPixelDetSummary.cc.

References gather_cfg::cout, cond::rpcobgas::detid, PixelEndcapName::diskName(), fCountMap, fMeanMap, fRmsMap, fVerbose, PixelEndcapName::halfCylinder(), PixelBarrelName::layerName(), PixelEndcapName::mI, PixelEndcapName::mO, PixelBarrelName::name(), PixelEndcapName::name(), mergeVDriftHistosByStation::name, PixelEndcapName::pI, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, PixelEndcapName::pO, DetId::subdetId(), and relativeConstraints::value.

Referenced by add().

34  {
35 
36  int detNum = -1;
37  int idet(-1), il(-1);
38  string name;
39 
40  switch (detid.subdetId()) {
42  idet = 1;
43  il = PixelBarrelName(detid).layerName();
44  name = PixelBarrelName(detid).name();
45  break;
46  }
48  idet = 2;
50  name = PixelEndcapName(detid).name();
51  if (hc == PixelEndcapName::pI || hc == PixelEndcapName::pO) {
52  il = 3 - PixelEndcapName(detid).diskName();
53  }
54  if (hc == PixelEndcapName::mI || hc == PixelEndcapName::mO) {
55  il = 2 + PixelEndcapName(detid).diskName();
56  }
57  break;
58  }
59  }
60 
61  detNum = idet*10000 + il*1000;
62 
63  if (fVerbose > 0)
64  cout << "detNum: " << detNum
65  << " detID: " << static_cast<int>(detid)
66  << " " << name
67  << endl;
68 
69  fMeanMap[detNum] += value;
70  fRmsMap[detNum] += value*value;
71  fCountMap[detNum] += 1;
72 }
std::map< int, double > fMeanMap
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
virtual std::string name() const
from base class
std::map< int, double > fRmsMap
int layerName() const
layer id
virtual std::string name() const
from base class
std::map< int, int > fCountMap
tuple cout
Definition: gather_cfg.py:121
int diskName() const
disk id
HalfCylinder halfCylinder() const
void SiPixelDetSummary::add ( const DetId detid)

Definition at line 27 of file SiPixelDetSummary.cc.

References add(), and fComputeMean.

27  {
28  fComputeMean= false;
29  add(detid, 0.);
30 }
void add(const DetId &detid, const float &value)
std::map<int, int> SiPixelDetSummary::getCounts ( )
inline

Definition at line 34 of file SiPixelDetSummary.h.

References fCountMap.

34 { return fCountMap; }
std::map< int, int > fCountMap
void SiPixelDetSummary::print ( std::stringstream &  ss,
const bool  mean = true 
) const

Definition at line 75 of file SiPixelDetSummary.cc.

References prof2calltree::count, fComputeMean, fCountMap, fMeanMap, fRmsMap, plotscripts::rms(), and mathSSE::sqrt().

75  {
76  std::map<int, int>::const_iterator countIt = fCountMap.begin();
77  std::map<int, double>::const_iterator meanIt = fMeanMap.begin();
78  std::map<int, double>::const_iterator rmsIt = fRmsMap.begin();
79 
80  ss << "subDet" << setw(15) << "layer" << setw(16);
81  if (mean) ss << "mean +- rms" << endl;
82  else ss << "count" << endl;
83 
84  std::string detector;
85  std::string oldDetector;
86 
87  for (; countIt != fCountMap.end(); ++countIt, ++meanIt, ++rmsIt ) {
88  int count = countIt->second;
89  double mean = 0.;
90  double rms = 0.;
91  if (fComputeMean && count != 0) {
92  mean = (meanIt->second)/count;
93  rms = (rmsIt->second)/count - mean*mean;
94  if (rms <= 0)
95  rms = 0;
96  else
97  rms = sqrt(rms);
98  }
99 
100  // -- Detector type
101  switch ((countIt->first)/10000) {
102  case 1:
103  detector = "BPIX";
104  break;
105  case 2:
106  detector = "FPIX";
107  break;
108  }
109  if( detector != oldDetector ) {
110  ss << std::endl << detector;
111  oldDetector = detector;
112  }
113  else ss << " ";
114 
115  // -- Layer number
116  int layer = (countIt->first)/1000 - (countIt->first)/10000*10;
117 
118  ss << std::setw(15) << layer << std::setw(13) ;
119  if (fComputeMean) ss << mean << " +- " << rms << std::endl;
120  else ss << countIt->second << std::endl;
121  }
122 }
std::map< int, double > fMeanMap
T sqrt(T t)
Definition: SSEVec.h:46
std::map< int, double > fRmsMap
std::map< int, int > fCountMap

Member Data Documentation

bool SiPixelDetSummary::fComputeMean
protected

Definition at line 40 of file SiPixelDetSummary.h.

Referenced by add(), and print().

std::map<int, int> SiPixelDetSummary::fCountMap
protected

Definition at line 39 of file SiPixelDetSummary.h.

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

std::map<int, double> SiPixelDetSummary::fMeanMap
protected

Definition at line 37 of file SiPixelDetSummary.h.

Referenced by add(), and print().

std::map<int, double> SiPixelDetSummary::fRmsMap
protected

Definition at line 38 of file SiPixelDetSummary.h.

Referenced by add(), and print().

int SiPixelDetSummary::fVerbose
protected

Definition at line 41 of file SiPixelDetSummary.h.

Referenced by add(), and SiPixelDetSummary().