CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Attributes
SiPixelDetSummary Class Reference

#include <SiPixelDetSummary.h>

Public Member Functions

void add (const DetId &detid)
 
void add (const DetId &detid, const float &value)
 
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::SiPixelDetSummary ( int  verbose = 0)

Definition at line 9 of file SiPixelDetSummary.cc.

9  : fComputeMean(true), fVerbose(verbose) {
10  unsigned int layers[] = {3, 4};
11  unsigned index = 0;
12 
13  for (unsigned int idet = 0; idet < 2; ++idet) {
14  for (unsigned int il = 0; il < layers[idet]; ++il) {
15  index = (idet + 1) * 10000 + (il + 1) * 1000;
16  if (fVerbose)
17  cout << "Adding index = " << index << endl;
18  fCountMap[index] = 0;
19  }
20  }
21 }

References gather_cfg::cout, fCountMap, fVerbose, and hgcalTopologyTester_cfi::layers.

Member Function Documentation

◆ add() [1/2]

void SiPixelDetSummary::add ( const DetId detid)

Definition at line 24 of file SiPixelDetSummary.cc.

24  {
25  fComputeMean = false;
26  add(detid, 0.);
27 }

References add(), and fComputeMean.

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

◆ add() [2/2]

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

Definition at line 30 of file SiPixelDetSummary.cc.

30  {
31  int detNum = -1;
32  int idet(-1), il(-1);
33  string name;
34 
35  switch (detid.subdetId()) {
37  idet = 1;
38  il = PixelBarrelName(detid).layerName();
39  name = PixelBarrelName(detid).name();
40  break;
41  }
43  idet = 2;
45  name = PixelEndcapName(detid).name();
46  if (hc == PixelEndcapName::pI || hc == PixelEndcapName::pO) {
47  il = 3 - PixelEndcapName(detid).diskName();
48  }
49  if (hc == PixelEndcapName::mI || hc == PixelEndcapName::mO) {
50  il = 2 + PixelEndcapName(detid).diskName();
51  }
52  break;
53  }
54  }
55 
56  detNum = idet * 10000 + il * 1000;
57 
58  if (fVerbose > 0)
59  cout << "detNum: " << detNum << " detID: " << static_cast<int>(detid) << " " << name << endl;
60 
61  fMeanMap[detNum] += value;
62  fRmsMap[detNum] += value * value;
63  fCountMap[detNum] += 1;
64 }

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

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

◆ getCounts()

std::map<int, int> SiPixelDetSummary::getCounts ( )
inline

Definition at line 34 of file SiPixelDetSummary.h.

34 { return fCountMap; }

References fCountMap.

◆ print()

void SiPixelDetSummary::print ( std::stringstream &  ss,
const bool  mean = true 
) const

Definition at line 67 of file SiPixelDetSummary.cc.

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

References submitPVResolutionJobs::count, hgcalTestNeighbor_cfi::detector, fComputeMean, fCountMap, fMeanMap, fRmsMap, phase1PixelTopology::layer, SiStripPI::mean, SiStripPI::rms, mathSSE::sqrt(), contentValuesCheck::ss, and AlCaHLTBitMon_QueryRunRegistry::string.

Member Data Documentation

◆ fComputeMean

bool SiPixelDetSummary::fComputeMean
protected

Definition at line 40 of file SiPixelDetSummary.h.

Referenced by add(), and print().

◆ fCountMap

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

Definition at line 39 of file SiPixelDetSummary.h.

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

◆ fMeanMap

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

Definition at line 37 of file SiPixelDetSummary.h.

Referenced by add(), and print().

◆ fRmsMap

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

Definition at line 38 of file SiPixelDetSummary.h.

Referenced by add(), and print().

◆ fVerbose

int SiPixelDetSummary::fVerbose
protected

Definition at line 41 of file SiPixelDetSummary.h.

Referenced by add(), and SiPixelDetSummary().

PixelEndcapName::mO
Definition: PixelEndcapName.h:18
SiStripPI::mean
Definition: SiStripPayloadInspectorHelper.h:169
PixelSubdetector::PixelEndcap
Definition: PixelSubdetector.h:11
PixelSubdetector::PixelBarrel
Definition: PixelSubdetector.h:11
SiPixelDetSummary::fMeanMap
std::map< int, double > fMeanMap
Definition: SiPixelDetSummary.h:37
gather_cfg.cout
cout
Definition: gather_cfg.py:144
PixelBarrelName
Definition: PixelBarrelName.h:16
SiPixelDetSummary::fRmsMap
std::map< int, double > fRmsMap
Definition: SiPixelDetSummary.h:38
PixelEndcapName::halfCylinder
HalfCylinder halfCylinder() const
Definition: PixelEndcapName.h:42
PixelBarrelName::layerName
int layerName() const
layer id
Definition: PixelBarrelName.h:43
SiStripPI::rms
Definition: SiStripPayloadInspectorHelper.h:169
SiPixelDetSummary::fVerbose
int fVerbose
Definition: SiPixelDetSummary.h:41
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
PixelBarrelName::name
std::string name() const override
from base class
Definition: PixelBarrelName.cc:731
PixelEndcapName
Definition: PixelEndcapName.h:16
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
submitPVResolutionJobs.count
count
Definition: submitPVResolutionJobs.py:352
verbose
static constexpr int verbose
Definition: HLTExoticaSubAnalysis.cc:25
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
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
PixelEndcapName::mI
Definition: PixelEndcapName.h:18
value
Definition: value.py:1
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PixelEndcapName::pO
Definition: PixelEndcapName.h:18
PixelEndcapName::HalfCylinder
HalfCylinder
Definition: PixelEndcapName.h:18
PixelEndcapName::diskName
int diskName() const
disk id
Definition: PixelEndcapName.h:45
relativeConstraints.value
value
Definition: relativeConstraints.py:53
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
hgcalTestNeighbor_cfi.detector
detector
Definition: hgcalTestNeighbor_cfi.py:6
SiPixelDetSummary::add
void add(const DetId &detid, const float &value)
Definition: SiPixelDetSummary.cc:30
PixelEndcapName::name
std::string name() const override
from base class
Definition: PixelEndcapName.cc:365
PixelEndcapName::pI
Definition: PixelEndcapName.h:18
SiPixelDetSummary::fCountMap
std::map< int, int > fCountMap
Definition: SiPixelDetSummary.h:39
SiPixelDetSummary::fComputeMean
bool fComputeMean
Definition: SiPixelDetSummary.h:40
hgcalTopologyTester_cfi.layers
layers
Definition: hgcalTopologyTester_cfi.py:8