Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-07 04:53:53

0001 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0002 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
0003 
0004 #include "CondFormats/SiStripObjects/interface/SiStripDetSummary.h"
0005 
0006 void SiStripDetSummary::add(DetId detid, float value) {
0007   int layer = 0;
0008   int stereo = 0;
0009   int detNum = 0;
0010 
0011   // Using the operator[] if the element does not exist it is created with the default value. That is 0 for integral types.
0012   switch (detid.subdetId()) {
0013     case StripSubdetector::TIB:
0014       layer = trackerTopo_->tibLayer(detid);
0015       stereo = trackerTopo_->tibStereo(detid);
0016       detNum = 1000;
0017       break;
0018     case StripSubdetector::TOB:
0019       layer = trackerTopo_->tobLayer(detid);
0020       stereo = trackerTopo_->tobStereo(detid);
0021       detNum = 2000;
0022       break;
0023     case StripSubdetector::TEC:
0024       // is this module in TEC+ or TEC-?
0025       layer = trackerTopo_->tecWheel(detid);
0026       stereo = trackerTopo_->tecStereo(detid);
0027       detNum = 3000;
0028       break;
0029     case StripSubdetector::TID:
0030       // is this module in TID+ or TID-?
0031       layer = trackerTopo_->tidWheel(detid);
0032       stereo = trackerTopo_->tidStereo(detid);
0033       detNum = 4000;
0034       break;
0035   }
0036   detNum += layer * 10 + stereo;
0037   valueMap_[detNum].mean += value;
0038   valueMap_[detNum].rms += value * value;
0039   valueMap_[detNum].count += 1;
0040 }
0041 
0042 void SiStripDetSummary::print(std::stringstream& ss, const bool mean) const {
0043   // Compute the mean for each detector and for each layer.
0044   std::map<unsigned int, Values>::const_iterator valueMapIt = valueMap_.begin();
0045 
0046   ss << "subDet" << std::setw(15) << "layer" << std::setw(16) << "mono/stereo" << std::setw(20);
0047   if (mean)
0048     ss << "mean +- rms" << std::endl;
0049   else
0050     ss << "count" << std::endl;
0051 
0052   std::string detector;
0053   std::string oldDetector;
0054 
0055   for (; valueMapIt != valueMap_.end(); ++valueMapIt) {
0056     int count = valueMapIt->second.count;
0057     double mean = 0.;
0058     double rms = 0.;
0059     if (computeMean_ && count != 0) {
0060       mean = (valueMapIt->second.mean) / count;
0061       rms = (valueMapIt->second.rms) / count - mean * mean;
0062       if (rms <= 0)
0063         rms = 0;
0064       else
0065         rms = sqrt(rms);
0066     }
0067     // Detector type
0068     switch ((valueMapIt->first) / 1000) {
0069       case 1:
0070         detector = "TIB ";
0071         break;
0072       case 2:
0073         detector = "TOB ";
0074         break;
0075       case 3:
0076         detector = "TEC ";
0077         break;
0078       case 4:
0079         detector = "TID ";
0080         break;
0081     }
0082     if (detector != oldDetector) {
0083       ss << std::endl << detector;
0084       oldDetector = detector;
0085     } else
0086       ss << "    ";
0087     // Layer number
0088     int layer = (valueMapIt->first) / 10 - (valueMapIt->first) / 1000 * 100;
0089     int stereo = valueMapIt->first - layer * 10 - (valueMapIt->first) / 1000 * 1000;
0090 
0091     ss << std::setw(15) << layer << std::setw(13) << stereo << std::setw(18);
0092     if (computeMean_)
0093       ss << mean << " +- " << rms << std::endl;
0094     else
0095       ss << count << std::endl;
0096   }
0097 }