Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:32:03

0001 #ifndef EcalMixingModuleValidation_H
0002 #define EcalMixingModuleValidation_H
0003 
0004 /*
0005  * \file EcalMixingModuleValidation.h
0006  *
0007  * \author F. Cossutti
0008  *
0009 */
0010 
0011 #include "DQMServices/Core/interface/DQMOneEDAnalyzer.h"
0012 #include "FWCore/Framework/interface/Frameworkfwd.h"
0013 
0014 #include "FWCore/Framework/interface/Event.h"
0015 #include "FWCore/Framework/interface/EventSetup.h"
0016 #include "FWCore/Framework/interface/ESHandle.h"
0017 #include "FWCore/Framework/interface/MakerMacros.h"
0018 
0019 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0020 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0021 
0022 #include "FWCore/ServiceRegistry/interface/Service.h"
0023 
0024 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
0025 #include "SimDataFormats/EncodedEventId/interface/EncodedEventId.h"
0026 #include "SimDataFormats/Track/interface/SimTrack.h"
0027 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
0028 #include "SimDataFormats/Vertex/interface/SimVertex.h"
0029 #include "SimDataFormats/Vertex/interface/SimVertexContainer.h"
0030 #include "SimDataFormats/CaloHit/interface/PCaloHit.h"
0031 #include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h"
0032 
0033 #include "DataFormats/EcalDigi/interface/EBDataFrame.h"
0034 #include "DataFormats/EcalDigi/interface/EEDataFrame.h"
0035 #include "DataFormats/EcalDigi/interface/ESDataFrame.h"
0036 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
0037 #include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h"
0038 #include "SimDataFormats/CrossingFrame/interface/MixCollection.h"
0039 
0040 #include "SimCalorimetry/EcalSimAlgos/interface/EcalSimParameterMap.h"
0041 //#include "SimCalorimetry/EcalSimAlgos/interface/EcalShape.h"
0042 #include "SimCalorimetry/EcalSimAlgos/interface/ESShape.h"
0043 #include "SimCalorimetry/EcalSimAlgos/interface/EBShape.h"
0044 #include "SimCalorimetry/EcalSimAlgos/interface/EEShape.h"
0045 #include "SimCalorimetry/CaloSimAlgos/interface/CaloHitResponse.h"
0046 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0047 #include "CondFormats/EcalObjects/interface/EcalPedestals.h"
0048 
0049 #include "CondFormats/ESObjects/interface/ESIntercalibConstants.h"
0050 #include "CondFormats/DataRecord/interface/ESIntercalibConstantsRcd.h"
0051 #include "CondFormats/ESObjects/interface/ESMIPToGeVConstant.h"
0052 #include "CondFormats/DataRecord/interface/ESMIPToGeVConstantRcd.h"
0053 #include "CondFormats/ESObjects/interface/ESGain.h"
0054 #include "CondFormats/DataRecord/interface/ESGainRcd.h"
0055 #include "CondFormats/ESObjects/interface/ESPedestals.h"
0056 #include "CondFormats/DataRecord/interface/ESPedestalsRcd.h"
0057 #include "CondFormats/ESObjects/interface/ESIntercalibConstants.h"
0058 #include "EcalBarrelDigisValidation.h"
0059 #include "CalibCalorimetry/EcalTrivialCondModules/interface/EcalTrivialConditionRetriever.h"
0060 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0061 
0062 #include <iostream>
0063 #include <fstream>
0064 #include <vector>
0065 #include <map>
0066 
0067 namespace edm {
0068   class StreamID;
0069 }
0070 
0071 namespace CLHEP {
0072   class HepRandomEngine;
0073 }
0074 
0075 class EcalMixingModuleValidation : public DQMOneEDAnalyzer<> {
0076   typedef std::map<uint32_t, float, std::less<uint32_t> > MapType;
0077 
0078 public:
0079   /// Constructor
0080   EcalMixingModuleValidation(const edm::ParameterSet& ps);
0081 
0082   /// Destructor
0083   ~EcalMixingModuleValidation() override;
0084 
0085   void bookHistograms(DQMStore::IBooker& i, edm::Run const&, edm::EventSetup const&) override;
0086 
0087 protected:
0088   /// Analyze
0089   void analyze(edm::Event const& e, edm::EventSetup const& c) override;
0090 
0091   void dqmBeginRun(edm::Run const&, edm::EventSetup const&) override;
0092 
0093   // EndRun
0094   void dqmEndRun(const edm::Run& r, const edm::EventSetup& c) override;
0095 
0096 private:
0097   void checkPedestals(const edm::EventSetup& c);
0098 
0099   void findPedestal(const DetId& detId, int gainId, double& ped) const;
0100 
0101   void checkCalibrations(edm::EventSetup const& c);
0102 
0103   bool verbose_;
0104 
0105   std::string outputFile_;
0106 
0107   edm::EDGetTokenT<edm::HepMCProduct> HepMCToken_;
0108 
0109   edm::EDGetTokenT<EBDigiCollection> EBdigiCollectionToken_;
0110   edm::EDGetTokenT<EEDigiCollection> EEdigiCollectionToken_;
0111   edm::EDGetTokenT<ESDigiCollection> ESdigiCollectionToken_;
0112   edm::EDGetTokenT<CrossingFrame<PCaloHit> > crossingFramePCaloHitEBToken_, crossingFramePCaloHitEEToken_,
0113       crossingFramePCaloHitESToken_;
0114 
0115   edm::ESGetToken<EcalADCToGeVConstant, EcalADCToGeVConstantRcd> pAgc;
0116   edm::ESGetToken<ESGain, ESGainRcd> esgain_;
0117   edm::ESGetToken<ESMIPToGeVConstant, ESMIPToGeVConstantRcd> esMIPToGeV_;
0118   edm::ESGetToken<ESPedestals, ESPedestalsRcd> esPedestals_;
0119   edm::ESGetToken<ESIntercalibConstants, ESIntercalibConstantsRcd> esMIPs_;
0120   edm::ESGetToken<EcalPedestals, EcalPedestalsRcd> dbPed;
0121   edm::ESGetToken<CaloGeometry, CaloGeometryRecord> hGeometry;
0122 
0123   std::map<int, double, std::less<int> > gainConv_;
0124 
0125   double barrelADCtoGeV_;
0126   double endcapADCtoGeV_;
0127 
0128   MonitorElement* meEBDigiMixRatiogt100ADC_;
0129   MonitorElement* meEEDigiMixRatiogt100ADC_;
0130 
0131   MonitorElement* meEBDigiMixRatioOriggt50pc_;
0132   MonitorElement* meEEDigiMixRatioOriggt40pc_;
0133 
0134   MonitorElement* meEBbunchCrossing_;
0135   MonitorElement* meEEbunchCrossing_;
0136   MonitorElement* meESbunchCrossing_;
0137 
0138   static const int nBunch = 21;
0139 
0140   MonitorElement* meEBBunchShape_[nBunch];
0141   MonitorElement* meEEBunchShape_[nBunch];
0142   MonitorElement* meESBunchShape_[nBunch];
0143 
0144   MonitorElement* meEBShape_;
0145   MonitorElement* meEEShape_;
0146   MonitorElement* meESShape_;
0147 
0148   MonitorElement* meEBShapeRatio_;
0149   MonitorElement* meEEShapeRatio_;
0150   MonitorElement* meESShapeRatio_;
0151 
0152   std::unique_ptr<const EcalSimParameterMap> theParameterMap;
0153   //const CaloVShape * theEcalShape;
0154   std::unique_ptr<ESShape> theESShape;
0155   std::unique_ptr<EBShape> theEBShape;
0156   std::unique_ptr<EEShape> theEEShape;
0157 
0158   //CaloHitResponse * theEcalResponse;
0159   std::unique_ptr<CaloHitResponse> theESResponse;
0160   std::unique_ptr<CaloHitResponse> theEBResponse;
0161   std::unique_ptr<CaloHitResponse> theEEResponse;
0162 
0163   void computeSDBunchDigi(const edm::EventSetup& eventSetup,
0164                           const MixCollection<PCaloHit>& theHits,
0165                           MapType& ebSignalSimMap,
0166                           const EcalSubdetector& thisDet,
0167                           const double& theSimThreshold,
0168                           CLHEP::HepRandomEngine*);
0169 
0170   void bunchSumTest(std::vector<MonitorElement*>& theBunches,
0171                     MonitorElement*& theTotal,
0172                     MonitorElement*& theRatio,
0173                     int nSample);
0174 
0175   CLHEP::HepRandomEngine* randomEngine(edm::StreamID const& streamID);
0176 
0177   double esBaseline_;
0178   double esADCtokeV_;
0179   double esThreshold_;
0180 
0181   int theMinBunch;
0182   int theMaxBunch;
0183 
0184   const CaloGeometry* theGeometry;
0185 
0186   // the pedestals
0187   const EcalPedestals* thePedestals;
0188 
0189   int m_ESgain;
0190   const ESPedestals* m_ESpeds;
0191   const ESIntercalibConstants* m_ESmips;
0192   double m_ESeffwei;
0193 
0194   std::vector<CLHEP::HepRandomEngine*> randomEngines_;
0195 };
0196 
0197 #endif