CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_14/src/CondFormats/SiStripObjects/interface/SiStripDetSummary.h

Go to the documentation of this file.
00001 #ifndef SiStripDetSummary_h
00002 #define SiStripDetSummary_h
00003 
00004 #include "DataFormats/SiStripDetId/interface/TIDDetId.h" 
00005 #include "DataFormats/SiStripDetId/interface/TECDetId.h" 
00006 #include "DataFormats/SiStripDetId/interface/TIBDetId.h" 
00007 #include "DataFormats/SiStripDetId/interface/TOBDetId.h" 
00008 #include "DataFormats/DetId/interface/DetId.h"
00009 
00010 #include <sstream>
00011 #include <map>
00012 #include <cmath>
00013 #include <iomanip>
00014 #include <iostream>
00015 
00031 class SiStripDetSummary
00032 {
00033 public:
00034   SiStripDetSummary() : computeMean_(true)
00035   {
00036     // Initialize valueMap_ with zeros
00037     // WARNING: this initialization is strongly connected with how the map is filled in the add method
00038     // TIB: layers = 4, stereo = the first 2
00039     // TOB: layers = 6, stereo = the first 2
00040     // TEC: wheels = 9, stereo = 9
00041     // TID: wheels = 3, stereo = 3
00042     unsigned int layers[] = {4, 6, 9, 3};
00043     unsigned int stereo[] = {2, 2, 9, 3};
00044     Values initValues;
00045     for( unsigned int subDet = 0; subDet < 4; ++subDet ) {
00046       // Layers start from 1
00047       for( unsigned int layer = 1; layer <= layers[subDet]; ++layer ) {
00048         valueMap_[1000*(subDet+1)+layer*10] = initValues;
00049         if( layer <= stereo[subDet] ) valueMap_[1000*(subDet+1)+layer*10+1] = initValues;
00050       }
00051     }
00052   }
00053 
00055   void add(const DetId & detid, const float & value);
00057   inline void add(const DetId & detid)
00058   {
00059     computeMean_ = false;
00060     add( detid, 0 );
00061   }
00062 
00067   void print(std::stringstream& ss, const bool mean = true) const;
00068 
00069   struct Values
00070   {
00071     Values() : mean(0.), rms(0.), count(0) {}
00072     double mean;
00073     double rms;
00074     unsigned int count;
00075   };
00076   std::map<unsigned int, Values> getCounts()
00077   {
00078     return valueMap_;
00079   }
00080 protected:
00081   // Maps to store the value and the counts
00082   std::map<unsigned int, Values> valueMap_;
00083   bool computeMean_;
00084 };
00085 
00086 #endif