Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-03-17 23:26:15

0001 #ifndef MESetBinningUtils_H
0002 #define MESetBinningUtils_H
0003 
0004 #include "DQMServices/Core/interface/DQMStore.h"
0005 #include "Geometry/EcalMapping/interface/EcalElectronicsMapping.h"
0006 
0007 #include <string>
0008 
0009 class DetId;
0010 class EcalElectronicsId;
0011 namespace edm {
0012   class ParameterSet;
0013   class ParameterSetDescription;
0014 }  // namespace edm
0015 
0016 namespace ecaldqm {
0017   namespace binning {
0018     enum ObjectType {
0019       kEB,
0020       kEE,
0021       kEEm,
0022       kEEp,
0023       kSM,
0024       kEBSM,
0025       kEESM,
0026       kSMMEM,
0027       kEBSMMEM,
0028       kEESMMEM,
0029       kEcal,
0030       kMEM,
0031       kEBMEM,
0032       kEEMEM,
0033       kEcal2P,
0034       kEcal3P,
0035       kEE2P,
0036       kMEM2P,
0037       kChannel,
0038       nObjType
0039     };
0040 
0041     enum BinningType {
0042       kCrystal,
0043       kTriggerTower,
0044       kSuperCrystal,
0045       kPseudoStrip,
0046       kTCC,
0047       kDCC,
0048       kProjEta,
0049       kProjPhi,
0050       kRCT,
0051       kUser,
0052       kReport,
0053       kTrend,
0054       nBinType
0055     };
0056 
0057     enum Constants {
0058       nPresetBinnings = kRCT + 1,
0059 
0060       nEBSMEta = 85,
0061       nEBSMPhi = 20,
0062       nEESMX = 40,
0063       nEESMXRed = 30,  // for EE+-01&05&09
0064       nEESMXExt = 45,  // for EE+-02&08
0065       nEESMY = 40,
0066       nEESMYRed = 35,  // for EE+-03&07
0067 
0068       nEBEtaBins = 34,
0069       nEEEtaBins = 20,
0070       nPhiBins = 36
0071     };
0072 
0073     struct AxisSpecs {
0074       int nbins;
0075       float low, high;
0076       float *edges;
0077       std::string *labels;
0078       std::string title;
0079       AxisSpecs() : nbins(0), low(0.), high(0.), edges(nullptr), labels(nullptr), title("") {}
0080       AxisSpecs(AxisSpecs const &_specs)
0081           : nbins(_specs.nbins),
0082             low(_specs.low),
0083             high(_specs.high),
0084             edges(nullptr),
0085             labels(nullptr),
0086             title(_specs.title) {
0087         if (_specs.edges) {
0088           edges = new float[nbins + 1];
0089           for (int i(0); i <= nbins; i++)
0090             edges[i] = _specs.edges[i];
0091         }
0092         if (_specs.labels) {
0093           labels = new std::string[nbins];
0094           for (int i(0); i < nbins; i++)
0095             labels[i] = _specs.labels[i];
0096         }
0097       }
0098       AxisSpecs &operator=(AxisSpecs const &_rhs) {
0099         if (edges) {
0100           delete[] edges;
0101           edges = nullptr;
0102         }
0103         if (labels) {
0104           delete[] labels;
0105           labels = nullptr;
0106         }
0107         nbins = _rhs.nbins;
0108         low = _rhs.low;
0109         high = _rhs.high;
0110         title = _rhs.title;
0111         if (_rhs.edges) {
0112           edges = new float[nbins + 1];
0113           for (int i(0); i <= nbins; i++)
0114             edges[i] = _rhs.edges[i];
0115         }
0116         if (_rhs.labels) {
0117           labels = new std::string[nbins];
0118           for (int i(0); i < nbins; i++)
0119             labels[i] = _rhs.labels[i];
0120         }
0121         return *this;
0122       }
0123       ~AxisSpecs() {
0124         delete[] edges;
0125         delete[] labels;
0126       }
0127     };
0128 
0129     AxisSpecs getBinning(EcalElectronicsMapping const *, ObjectType, BinningType, bool, int, unsigned);
0130 
0131     int findBin1D(EcalElectronicsMapping const *, ObjectType, BinningType, DetId const &);
0132     int findBin1D(EcalElectronicsMapping const *, ObjectType, BinningType, EcalElectronicsId const &);
0133     int findBin1D(EcalElectronicsMapping const *, ObjectType, BinningType, int);
0134 
0135     int findBin2D(EcalElectronicsMapping const *, ObjectType, BinningType, DetId const &);
0136     int findBin2D(EcalElectronicsMapping const *, ObjectType, BinningType, EcalElectronicsId const &);
0137     int findBin2D(EcalElectronicsMapping const *, ObjectType, BinningType, int);
0138 
0139     unsigned findPlotIndex(EcalElectronicsMapping const *, ObjectType, DetId const &);
0140     unsigned findPlotIndex(EcalElectronicsMapping const *, ObjectType, EcalElectronicsId const &);
0141     unsigned findPlotIndex(EcalElectronicsMapping const *, ObjectType, int, BinningType _btype = kDCC);
0142 
0143     ObjectType getObject(ObjectType, unsigned);
0144 
0145     unsigned getNObjects(ObjectType);
0146 
0147     bool isValidIdBin(EcalElectronicsMapping const *, ObjectType, BinningType, unsigned, int);
0148 
0149     std::string channelName(EcalElectronicsMapping const *, uint32_t, BinningType _btype = kDCC);
0150 
0151     uint32_t idFromName(std::string const &);
0152     uint32_t idFromBin(ObjectType, BinningType, unsigned, int);
0153 
0154     AxisSpecs formAxis(edm::ParameterSet const &);
0155     void fillAxisDescriptions(edm::ParameterSetDescription &);
0156 
0157     ObjectType translateObjectType(std::string const &);
0158     BinningType translateBinningType(std::string const &);
0159     dqm::legacy::MonitorElement::Kind translateKind(std::string const &);
0160 
0161     /* Functions used only internally within binning namespace */
0162 
0163     // used for SM binnings
0164     int xlow_(int);
0165     int ylow_(int);
0166 
0167     AxisSpecs getBinningEB_(BinningType, bool, int);
0168     AxisSpecs getBinningEE_(BinningType, bool, int, int);
0169     AxisSpecs getBinningSM_(BinningType, bool, unsigned, int, EcalElectronicsMapping const *);
0170     AxisSpecs getBinningSMMEM_(BinningType, bool, unsigned, int);
0171     AxisSpecs getBinningEcal_(BinningType, bool, int);
0172     AxisSpecs getBinningMEM_(BinningType, bool, int, int);
0173 
0174     int findBinCrystal_(EcalElectronicsMapping const *, ObjectType, DetId const &, int = -1);
0175     int findBinCrystal_(EcalElectronicsMapping const *, ObjectType, EcalElectronicsId const &);
0176     int findBinTriggerTower_(EcalElectronicsMapping const *, ObjectType, DetId const &);
0177     int findBinPseudoStrip_(EcalElectronicsMapping const *, ObjectType, DetId const &);
0178     int findBinRCT_(ObjectType, DetId const &);
0179     int findBinSuperCrystal_(EcalElectronicsMapping const *, ObjectType, DetId const &, int = -1);
0180     int findBinSuperCrystal_(EcalElectronicsMapping const *, ObjectType, EcalElectronicsId const &);
0181   }  // namespace binning
0182 }  // namespace ecaldqm
0183 
0184 #endif