CMS 3D CMS Logo

Public Member Functions | Protected Attributes

SiPixelDetSummary Class Reference

#include <SiPixelDetSummary.h>

List of all members.

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.

                                               : fComputeMean(true), fVerbose(verbose) {

  unsigned int layers[] = {3, 4};
  unsigned index = 0; 

  for (unsigned int idet = 0; idet < 2; ++idet) {
    for (unsigned int il = 0; il < layers[idet]; ++il) {
      index = (idet+1)*10000 + (il+1)*1000; 
      if (fVerbose) cout << "Adding index = " << index << endl;
      fCountMap[index] = 0; 
    }
  }
}

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, PixelEndcapName::name(), PixelBarrelName::name(), mergeVDriftHistosByStation::name, PixelEndcapName::pI, PixelSubdetector::PixelBarrel, PixelSubdetector::PixelEndcap, PixelEndcapName::pO, DetId::subdetId(), and relativeConstraints::value.

Referenced by add().

                                                                    {
  
  int detNum = -1;
  int idet(-1), il(-1); 
  string name;

  switch (detid.subdetId()) {
  case PixelSubdetector::PixelBarrel: {
    idet = 1;
    il   = PixelBarrelName(detid).layerName();
    name = PixelBarrelName(detid).name();
    break;
  }
  case PixelSubdetector::PixelEndcap: {
    idet = 2;
    PixelEndcapName::HalfCylinder hc = PixelEndcapName(detid).halfCylinder();
    name = PixelEndcapName(detid).name();
    if (hc == PixelEndcapName::pI || hc == PixelEndcapName::pO) {
      il = 3 - PixelEndcapName(detid).diskName();
    }
    if (hc == PixelEndcapName::mI || hc == PixelEndcapName::mO) {
      il = 2 + PixelEndcapName(detid).diskName();
    }
    break;
  }
  }

  detNum = idet*10000 + il*1000;

  if (fVerbose > 0)
    cout << "detNum: " << detNum 
         << " detID: " << static_cast<int>(detid) 
         << " " << name
         << endl;

  fMeanMap[detNum] += value;
  fRmsMap[detNum] += value*value;
  fCountMap[detNum] += 1;
}
void SiPixelDetSummary::add ( const DetId detid)

Definition at line 27 of file SiPixelDetSummary.cc.

References add(), and fComputeMean.

                                               {
  fComputeMean= false; 
  add(detid, 0.); 
}
std::map<int, int> SiPixelDetSummary::getCounts ( ) [inline]

Definition at line 34 of file SiPixelDetSummary.h.

References fCountMap.

{ return 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(), mathSSE::sqrt(), and AlCaHLTBitMon_QueryRunRegistry::string.

                                                                         {
  std::map<int, int>::const_iterator countIt   = fCountMap.begin();
  std::map<int, double>::const_iterator meanIt = fMeanMap.begin();
  std::map<int, double>::const_iterator rmsIt  = fRmsMap.begin();
  
  ss << "subDet" << setw(15) << "layer" << setw(16);
  if (mean) ss << "mean +- rms" << endl;
  else ss << "count" << endl;

  std::string detector;
  std::string oldDetector;

  for (; countIt != fCountMap.end(); ++countIt, ++meanIt, ++rmsIt ) {
    int count = countIt->second;
    double mean = 0.;
    double rms = 0.;
    if (fComputeMean && count != 0) {
      mean = (meanIt->second)/count;
      rms = (rmsIt->second)/count - mean*mean;
      if (rms <= 0)
        rms = 0;
      else
        rms = sqrt(rms);
    }

    // -- Detector type
    switch ((countIt->first)/10000) {
    case 1:
      detector = "BPIX";
      break;
    case 2:
      detector = "FPIX";
      break;
    }
    if( detector != oldDetector ) {
      ss << std::endl << detector;
      oldDetector = detector;
    }
    else ss << "    ";

    // -- Layer number
    int layer = (countIt->first)/1000 - (countIt->first)/10000*10;
    
    ss << std::setw(15) << layer << std::setw(13) ;
    if (fComputeMean) ss << mean << " +- " << rms << std::endl;
    else ss << countIt->second << std::endl;
  }
}

Member Data Documentation

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().