Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-06-10 02:53:36

0001 #ifndef CalibFormats_HcalObjects_HcalDbService_h
0002 #define CalibFormats_HcalObjects_HcalDbService_h
0003 
0004 //
0005 // F.Ratnikov (UMd), Aug. 9, 2005
0006 //
0007 
0008 #include <memory>
0009 #include <map>
0010 #include <atomic>
0011 
0012 #include "DataFormats/HcalDetId/interface/HcalGenericDetId.h"
0013 #include "CalibFormats/HcalObjects/interface/HcalCoder.h"
0014 #include "CalibFormats/HcalObjects/interface/HcalCalibrationsSet.h"
0015 #include "CalibFormats/HcalObjects/interface/HcalCalibrationWidthsSet.h"
0016 
0017 #include "CondFormats/HcalObjects/interface/AllObjects.h"
0018 
0019 class HcalCalibrations;
0020 class HcalCalibrationWidths;
0021 class HcalTopology;
0022 
0023 class HcalDbService {
0024 public:
0025   HcalDbService();
0026   ~HcalDbService();
0027 
0028   const HcalTopology* getTopologyUsed() const;
0029 
0030   const HcalCalibrations& getHcalCalibrations(const HcalGenericDetId& fId) const;
0031   const HcalCalibrationWidths& getHcalCalibrationWidths(const HcalGenericDetId& fId) const;
0032   const HcalCalibrationsSet* getHcalCalibrationsSet() const;
0033   const HcalCalibrationWidthsSet* getHcalCalibrationWidthsSet() const;
0034 
0035   const HcalPedestal* getPedestal(const HcalGenericDetId& fId) const;
0036   const HcalPedestalWidth* getPedestalWidth(const HcalGenericDetId& fId) const;
0037   const HcalPedestal* getEffectivePedestal(const HcalGenericDetId& fId) const;
0038   const HcalPedestalWidth* getEffectivePedestalWidth(const HcalGenericDetId& fId) const;
0039   const HcalGain* getGain(const HcalGenericDetId& fId) const;
0040   const HcalGainWidth* getGainWidth(const HcalGenericDetId& fId) const;
0041   const HcalQIECoder* getHcalCoder(const HcalGenericDetId& fId) const;
0042   const HcalQIEShape* getHcalShape(const HcalGenericDetId& fId) const;
0043   const HcalQIEShape* getHcalShape(const HcalQIECoder* coder) const;
0044   const HcalElectronicsMap* getHcalMapping() const;
0045   const HcalFrontEndMap* getHcalFrontEndMapping() const;
0046   const HcalRespCorr* getHcalRespCorr(const HcalGenericDetId& fId) const;
0047   const HcalTimeCorr* getHcalTimeCorr(const HcalGenericDetId& fId) const;
0048   const HcalL1TriggerObject* getHcalL1TriggerObject(const HcalGenericDetId& fId) const;
0049   const HcalChannelStatus* getHcalChannelStatus(const HcalGenericDetId& fId) const;
0050   const HcalZSThreshold* getHcalZSThreshold(const HcalGenericDetId& fId) const;
0051   const HcalLUTCorr* getHcalLUTCorr(const HcalGenericDetId& fId) const;
0052   const HcalPFCorr* getHcalPFCorr(const HcalGenericDetId& fId) const;
0053   const HcalLutMetadata* getHcalLutMetadata() const;
0054   const HcalQIEType* getHcalQIEType(const HcalGenericDetId& fId) const;
0055   const HcalSiPMParameter* getHcalSiPMParameter(const HcalGenericDetId& fId) const;
0056   const HcalSiPMCharacteristics* getHcalSiPMCharacteristics() const;
0057   const HcalTPChannelParameter* getHcalTPChannelParameter(const HcalGenericDetId& fId, bool throwOnFail = true) const;
0058   const HcalTPParameters* getHcalTPParameters() const;
0059   const HcalMCParam* getHcalMCParam(const HcalGenericDetId& fId) const;
0060   const HcalRecoParam* getHcalRecoParam(const HcalGenericDetId& fId) const;
0061 
0062   void setData(const HcalPedestals* fItem, bool eff = false) {
0063     if (eff)
0064       mEffectivePedestals = fItem;
0065     else
0066       mPedestals = fItem;
0067     mCalibSet = nullptr;
0068   }
0069   void setData(const HcalPedestalWidths* fItem, bool eff = false) {
0070     if (eff)
0071       mEffectivePedestalWidths = fItem;
0072     else
0073       mPedestalWidths = fItem;
0074     mCalibWidthSet = nullptr;
0075   }
0076   void setData(const HcalGains* fItem) {
0077     mGains = fItem;
0078     mCalibSet = nullptr;
0079   }
0080   void setData(const HcalGainWidths* fItem) {
0081     mGainWidths = fItem;
0082     mCalibWidthSet = nullptr;
0083   }
0084   void setData(const HcalQIEData* fItem) {
0085     mQIEData = fItem;
0086     mCalibSet = nullptr;
0087     mCalibWidthSet = nullptr;
0088   }
0089   void setData(const HcalQIETypes* fItem) {
0090     mQIETypes = fItem;
0091     mCalibSet = nullptr;
0092   }
0093   void setData(const HcalChannelQuality* fItem) { mChannelQuality = fItem; }
0094   void setData(const HcalElectronicsMap* fItem) { mElectronicsMap = fItem; }
0095   void setData(const HcalFrontEndMap* fItem) { mFrontEndMap = fItem; }
0096   void setData(const HcalRespCorrs* fItem) {
0097     mRespCorrs = fItem;
0098     mCalibSet = nullptr;
0099   }
0100   void setData(const HcalTimeCorrs* fItem) {
0101     mTimeCorrs = fItem;
0102     mCalibSet = nullptr;
0103   }
0104   void setData(const HcalZSThresholds* fItem) { mZSThresholds = fItem; }
0105   void setData(const HcalL1TriggerObjects* fItem) { mL1TriggerObjects = fItem; }
0106   void setData(const HcalLUTCorrs* fItem) {
0107     mLUTCorrs = fItem;
0108     mCalibSet = nullptr;
0109   }
0110   void setData(const HcalPFCorrs* fItem) { mPFCorrs = fItem; }
0111   void setData(const HcalLutMetadata* fItem) { mLutMetadata = fItem; }
0112   void setData(const HcalSiPMParameters* fItem) {
0113     mSiPMParameters = fItem;
0114     mCalibSet = nullptr;
0115   }
0116   void setData(const HcalSiPMCharacteristics* fItem) { mSiPMCharacteristics = fItem; }
0117   void setData(const HcalTPChannelParameters* fItem) {
0118     mTPChannelParameters = fItem;
0119     mCalibSet = nullptr;
0120   }
0121   void setData(const HcalTPParameters* fItem) { mTPParameters = fItem; }
0122   void setData(const HcalMCParams* fItem) { mMCParams = fItem; }
0123   void setData(const HcalRecoParams* fItem) { mRecoParams = fItem; }
0124 
0125 private:
0126   bool makeHcalCalibration(const HcalGenericDetId& fId,
0127                            HcalCalibrations* fObject,
0128                            bool pedestalInADC,
0129                            bool effPedestalInADC) const;
0130   void buildCalibrations() const;
0131   bool makeHcalCalibrationWidth(const HcalGenericDetId& fId,
0132                                 HcalCalibrationWidths* fObject,
0133                                 bool pedestalInADC,
0134                                 bool effPedestalInADC) const;
0135   void buildCalibWidths() const;
0136   bool convertPedestals(const HcalGenericDetId& fId, const HcalPedestal* pedestal, float* pedTrue, bool inADC) const;
0137   bool convertPedestalWidths(const HcalGenericDetId& fId,
0138                              const HcalPedestalWidth* pedestalwidth,
0139                              const HcalPedestal* pedestal,
0140                              float* pedTrueWidth,
0141                              bool inADC) const;
0142   const HcalPedestals* mPedestals;
0143   const HcalPedestalWidths* mPedestalWidths;
0144   const HcalPedestals* mEffectivePedestals;
0145   const HcalPedestalWidths* mEffectivePedestalWidths;
0146   const HcalGains* mGains;
0147   const HcalGainWidths* mGainWidths;
0148   const HcalQIEData* mQIEData;
0149   const HcalQIETypes* mQIETypes;
0150   const HcalChannelQuality* mChannelQuality;
0151   const HcalElectronicsMap* mElectronicsMap;
0152   const HcalFrontEndMap* mFrontEndMap;
0153   const HcalRespCorrs* mRespCorrs;
0154   const HcalZSThresholds* mZSThresholds;
0155   const HcalL1TriggerObjects* mL1TriggerObjects;
0156   const HcalTimeCorrs* mTimeCorrs;
0157   const HcalLUTCorrs* mLUTCorrs;
0158   const HcalPFCorrs* mPFCorrs;
0159   const HcalLutMetadata* mLutMetadata;
0160   const HcalSiPMParameters* mSiPMParameters;
0161   const HcalSiPMCharacteristics* mSiPMCharacteristics;
0162   const HcalTPChannelParameters* mTPChannelParameters;
0163   const HcalTPParameters* mTPParameters;
0164   const HcalMCParams* mMCParams;
0165   const HcalRecoParams* mRecoParams;
0166   //  bool mPedestalInADC;
0167   mutable std::atomic<HcalCalibrationsSet const*> mCalibSet;
0168   mutable std::atomic<HcalCalibrationWidthsSet const*> mCalibWidthSet;
0169 };
0170 
0171 #endif