CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/CondFormats/SiStripObjects/src/SiStripDetSummary.cc

Go to the documentation of this file.
00001 #include "CondFormats/SiStripObjects/interface/SiStripDetSummary.h"
00002 
00003 void SiStripDetSummary::add(const DetId & detid, const float & value)
00004 {
00005   int layer = 0;
00006   int stereo = 0;
00007   int detNum = 0;
00008 
00009   // Using the operator[] if the element does not exist it is created with the default value. That is 0 for integral types.
00010   switch (detid.subdetId()) {
00011   case StripSubdetector::TIB:
00012     {
00013       TIBDetId theTIBDetId(detid.rawId());
00014       layer = theTIBDetId.layer();
00015       stereo = theTIBDetId.stereo();
00016       detNum = 1000;
00017       break;
00018     }
00019   case StripSubdetector::TOB:
00020     {
00021       TOBDetId theTOBDetId(detid.rawId());
00022       layer = theTOBDetId.layer();
00023       stereo = theTOBDetId.stereo();
00024       detNum = 2000;
00025       break;
00026     }
00027   case StripSubdetector::TEC:
00028     {
00029       TECDetId theTECDetId(detid.rawId());
00030       // is this module in TEC+ or TEC-?
00031       layer = theTECDetId.wheel();
00032       stereo = theTECDetId.stereo();
00033       detNum = 3000;
00034       break;
00035     }
00036   case StripSubdetector::TID:
00037     {
00038       TIDDetId theTIDDetId(detid.rawId());
00039       // is this module in TID+ or TID-?
00040       layer = theTIDDetId.wheel();
00041       stereo = theTIDDetId.stereo();
00042       detNum = 4000;
00043       break;
00044     }
00045   }
00046   detNum += layer*10 + stereo;
00047   // string name( detector + boost::lexical_cast<string>(layer) + boost::lexical_cast<string>(stereo) );
00048   valueMap_[detNum].mean += value;
00049   valueMap_[detNum].rms += value*value;
00050   valueMap_[detNum].count += 1;
00051 }
00052 
00053 void SiStripDetSummary::print(std::stringstream & ss, const bool mean) const
00054 {
00055   // Compute the mean for each detector and for each layer.
00056   std::map<unsigned int, Values>::const_iterator valueMapIt = valueMap_.begin();
00057 
00058   ss << "subDet" << std::setw(15) << "layer" << std::setw(16) << "mono/stereo" << std::setw(20);
00059   if( mean ) ss << "mean +- rms" << std::endl;
00060   else ss << "count" << std::endl;
00061 
00062   std::string detector;
00063   std::string oldDetector;
00064 
00065   for( ; valueMapIt != valueMap_.end(); ++valueMapIt ) {
00066     int count = valueMapIt->second.count;
00067     double mean = 0.;
00068     double rms = 0.;
00069     if( computeMean_ && count != 0 ) {
00070       mean = (valueMapIt->second.mean)/count;
00071       rms = (valueMapIt->second.rms)/count - mean*mean;
00072       if (rms <= 0)
00073         rms = 0;
00074       else
00075         rms = sqrt(rms);
00076     }
00077     // Detector type
00078     switch ((valueMapIt->first)/1000) {
00079     case 1:
00080       detector = "TIB ";
00081       break;
00082     case 2:
00083       detector = "TOB ";
00084       break;
00085     case 3:
00086       detector = "TEC ";
00087       break;
00088     case 4:
00089       detector = "TID ";
00090       break;
00091     }
00092     if( detector != oldDetector ) {
00093       ss << std::endl << detector;
00094       oldDetector = detector;
00095     }
00096     else ss << "    ";
00097     // Layer number
00098     int layer = (valueMapIt->first)/10 - (valueMapIt->first)/1000*100;
00099     int stereo = valueMapIt->first - layer*10 -(valueMapIt->first)/1000*1000;
00100 
00101     ss << std::setw(15) << layer << std::setw(13) << stereo << std::setw(18);
00102     if( computeMean_ ) ss << mean << " +- " << rms << std::endl;
00103     else ss << count << std::endl;
00104   }
00105 }