CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2_patch1/src/DQM/EcalCommon/interface/EcalDQMBinningService.h

Go to the documentation of this file.
00001 #ifndef EcalDQMBinningService_H
00002 #define EcalDQMBinningService_H
00003 
00004 #include <map>
00005 #include <stdint.h>
00006 #include <string>
00007 #include <vector>
00008 
00009 #include "DQMServices/Core/interface/MonitorElement.h"
00010 
00011 #include "DataFormats/DetId/interface/DetId.h"
00012 
00013 // Keeps a map between channel ids and DQM histogram bins
00014 // The map is booked ad-hoc
00015 
00016 namespace edm {
00017   class ParameterSet;
00018   class ActivityRegistry;
00019   class Run;
00020   class EventSetup;
00021 }
00022 class CaloGeometry;
00023 class DQMStore;
00024 class EcalElectronicsId;
00025 
00026 class EcalDQMBinningService {
00027  public:
00028   enum ObjectType {
00029     kEB,
00030     kEBMEM,
00031     kEE,
00032     kEEm,
00033     kEEp,
00034     kEEMEM,
00035     kSM,
00036     kSMMEM,
00037     kEcal,
00038     kEcal2P,
00039     kEcal3P,
00040     kEcalMEM2P,
00041     kChannel,
00042     nObjType
00043   };
00044 
00045   enum BinningType {
00046     kCrystal,
00047     kTriggerTower,
00048     kSuperCrystal,
00049     kTCC,
00050     kDCC,
00051     kProjEta,
00052     kProjPhi,
00053     kUser,
00054     kReport,
00055     kTrend,
00056     nBinType
00057   };
00058 
00059   enum Constants {
00060     nPlotType = kEcal + 1,
00061     nPresetBinnings = kProjPhi + 1,
00062 
00063     nDCC = 54,
00064     nDCCMEM = 44,
00065 
00066     nTCC = 108,
00067     kEEmTCCLow = 0, kEEmTCCHigh = 35,
00068     kEEpTCCLow = 72, kEEpTCCHigh = 107,
00069     kEBTCCLow = 36, kEBTCCHigh = 71,
00070 
00071     nEBSMEta = 85,
00072     nEBSMPhi = 20,
00073     nEBSMBins = nEBSMEta * nEBSMPhi,
00074     nEESMX = 40,
00075     nEESMY = 40,
00076     nEESMBins = nEESMX * nEESMY,
00077     nEESMXExt = 45, // for EE+-02&08
00078     nEESMBinsExt = nEESMXExt * nEESMY,
00079 
00080 
00081     nEBEtaBins = 34,
00082     nEEEtaBins = 20,
00083     nPhiBins = 36
00084   };
00085 
00086   struct AxisSpecs {
00087     int nbins;
00088     double low, high;
00089     double* edges;
00090     std::string title;
00091     AxisSpecs() : nbins(1), edges(0) {}
00092     AxisSpecs(AxisSpecs const& _specs) :
00093       nbins(_specs.nbins), low(_specs.low), high(_specs.high), edges(0), title(_specs.title)
00094     {
00095       if(_specs.edges){
00096         edges = new double[nbins + 1];
00097         for(int i(0); i <= nbins; i++) edges[i] = _specs.edges[i];
00098       }
00099     }
00100     AxisSpecs& operator=(AxisSpecs const& _rhs)
00101     {
00102       if(edges){ delete [] edges; edges = 0; }
00103       nbins = _rhs.nbins; low = _rhs.low; high = _rhs.high; title = _rhs.title;
00104       if(_rhs.edges){
00105         edges = new double[nbins + 1];
00106         for(int i(0); i <= nbins; i++) edges[i] = _rhs.edges[i];
00107       }
00108       return *this;
00109     }
00110     ~AxisSpecs() { if(edges) delete [] edges; }
00111   };
00112 
00113   EcalDQMBinningService(const edm::ParameterSet&, edm::ActivityRegistry&);
00114   ~EcalDQMBinningService();
00115 
00116   void postBeginRun(const edm::Run&, const edm::EventSetup&);
00117 
00118   std::vector<AxisSpecs> getBinning(ObjectType, BinningType, bool _isMap = true, unsigned _objOffset = 0) const;
00119 
00120   // takes care of "key translations" as well - okey and bkey can have changed after the function returns
00121   const std::vector<int>* getBinMap(ObjectType&, BinningType&) const;
00122 
00123   std::pair<unsigned, std::vector<int> > findBins(ObjectType, BinningType, const DetId&) const;
00124   std::pair<unsigned, std::vector<int> > findBins(ObjectType, BinningType, const EcalElectronicsId&) const;
00125   std::pair<unsigned, std::vector<int> > findBins(ObjectType, BinningType, unsigned) const;
00126   // EcalElectronicsId version returns at most one bin
00127 
00128   std::pair<unsigned, std::vector<int> > findBinsNoMap(ObjectType, BinningType, const DetId&) const;
00129   std::pair<unsigned, std::vector<int> > findBinsNoMap(ObjectType, BinningType, const EcalElectronicsId&) const;
00130 
00131   unsigned findOffset(ObjectType, const DetId&) const;
00132   unsigned findOffset(ObjectType, const EcalElectronicsId&) const;
00133   unsigned findOffset(ObjectType, BinningType, unsigned) const;
00134 
00135   ObjectType objectFromOffset(ObjectType, unsigned) const;
00136 
00137   int smOffsetBins(ObjectType, BinningType, unsigned) const;
00138 
00139   // used for EE binnings
00140   int xlow(int) const;
00141   int ylow(int) const;
00142 
00143   std::string channelName(uint32_t, BinningType _btype = kDCC) const;
00144 
00145   uint32_t idFromName(std::string const&) const;
00146 
00147  private:
00148   std::vector<AxisSpecs> getBinningEB_(BinningType, bool) const;
00149   std::vector<AxisSpecs> getBinningEBMEM_(BinningType, bool) const;
00150   std::vector<AxisSpecs> getBinningEE_(BinningType, bool, int) const;
00151   std::vector<AxisSpecs> getBinningEEMEM_(BinningType, bool) const;
00152   std::vector<AxisSpecs> getBinningSM_(BinningType, bool, unsigned) const;
00153   std::vector<AxisSpecs> getBinningSMMEM_(BinningType, bool, unsigned) const;
00154   std::vector<AxisSpecs> getBinningEcal_(BinningType, bool) const;
00155 
00156   const std::vector<int>* getBinMapEB_(BinningType) const;
00157   const std::vector<int>* getBinMapEBMEM_(BinningType) const;
00158   const std::vector<int>* getBinMapEE_(BinningType, int) const;
00159   const std::vector<int>* getBinMapEEMEM_(BinningType) const;
00160   const std::vector<int>* getBinMapSM_(BinningType) const;
00161   const std::vector<int>* getBinMapSMMEM_(BinningType) const;
00162   const std::vector<int>* getBinMapEcal_(BinningType) const;
00163 
00164   void findBinsCrystal_(const DetId&, ObjectType, const std::vector<int>&, std::vector<int>&) const;
00165   void findBinsTriggerTower_(const DetId&, ObjectType, const std::vector<int>&, std::vector<int>&) const;
00166   void findBinsSuperCrystal_(const DetId&, ObjectType, const std::vector<int>&, std::vector<int>&) const;
00167   void findBinsDCC_(const DetId&, ObjectType, const std::vector<int>&, std::vector<int>&) const;
00168   void findBinsTCC_(const DetId&, ObjectType, const std::vector<int>&, std::vector<int>&) const;
00169   void findBinsProjEta_(const DetId&, ObjectType, const std::vector<int>&, std::vector<int>&) const;
00170   void findBinsProjPhi_(const DetId&, ObjectType, const std::vector<int>&, std::vector<int>&) const;
00171 
00172   // need to be mutable to allow ad-hoc booking
00173   mutable std::vector<int> binMaps_[nPlotType][nPresetBinnings];
00174   /*
00175     Following dictionaries are created during postBeginRun:
00176     (kEB, kCrystal) (kEB, kSuperCrystal) (kEB, kDCC) (kEB, kTCC) (kEBMEM, kCrystal)
00177     (kEE, kCrystal) (kEE, kSuperCrystal) (kEE, kDCC) (kEE, kTCC) (kEEMEM, kCrystal)
00178     (kEEm, kCrystal) (kEEm, kSuperCrystal) (kEEm, kDCC) (kEEm, kTCC)
00179     (kEEp, kCrystal) (kEEp, kSuperCrystal) (kEEp, kDCC) (kEEp, kTCC)
00180     (kSM, kCrystal) (kSM, kSuperCrystal) (kSM, kTriggerTower) (kSMMEM, kCrystal)
00181   */
00182 
00183   mutable uint32_t cacheId_;
00184   mutable ObjectType cacheOtype_;
00185   mutable BinningType cacheBtype_;
00186   mutable std::pair<unsigned, std::vector<int> > cache_;
00187 
00188   const double etaBound_;
00189 
00190   const CaloGeometry* geometry_;
00191 
00192   bool initialized_;
00193 
00194   int verbosity_;
00195 
00196 };
00197 
00198 #endif