Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-16 03:23:20

0001 #ifndef CalibCalorimetry_EcalPedestalOffsets_EcalPedOffset_H
0002 #define CalibCalorimetry_EcalPedestalOffsets_EcalPedOffset_H
0003 
0004 /**
0005  * \file EcalPedOffset.h
0006  * \class EcalPedOffset
0007  * \brief calculate the best DAC value to obtain a pedestal = 200
0008  * \author P. Govoni (pietro.govoni@cernNOSPAM.ch)
0009  *
0010  */
0011 
0012 #include <map>
0013 #include <string>
0014 
0015 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0016 #include "FWCore/Framework/interface/Event.h"
0017 #include "FWCore/Framework/interface/EventSetup.h"
0018 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0019 
0020 #include <DataFormats/EcalDigi/interface/EcalDigiCollections.h>
0021 #include <DataFormats/EcalRawData/interface/EcalRawDataCollections.h>
0022 #include <Geometry/EcalMapping/interface/EcalElectronicsMapping.h>
0023 #include <Geometry/EcalMapping/interface/EcalMappingRcd.h>
0024 
0025 #include "CalibCalorimetry/EcalPedestalOffsets/interface/TPedResult.h"
0026 #include "CalibCalorimetry/EcalPedestalOffsets/interface/TPedValues.h"
0027 
0028 class EcalPedOffset : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
0029 public:
0030   //! Constructor
0031   EcalPedOffset(const edm::ParameterSet &ps);
0032 
0033   //! Destructor
0034   ~EcalPedOffset() override;
0035 
0036   ///! Analyze
0037   void analyze(edm::Event const &event, edm::EventSetup const &eventSetup) override;
0038 
0039   //! BeginRun
0040   void beginRun(edm::Run const &, edm::EventSetup const &eventSetup) override;
0041 
0042   //! EndRun
0043   void endRun(edm::Run const &, edm::EventSetup const &) override;
0044 
0045   //! EndJob
0046   void endJob(void) override;
0047 
0048   //! write the results into xml format
0049   void writeXMLFiles(std::string fileName);
0050 
0051   //! WriteDB
0052   void writeDb();
0053 
0054   //! create the plots of the DAC pedestal trend
0055   void makePlots();
0056 
0057 private:
0058   const EcalElectronicsMapping *ecalElectronicsMap_;
0059 
0060   std::string intToString(int num);
0061   void readDACs(const edm::Handle<EBDigiCollection> &pDigis, const std::map<int, int> &DACvalues);
0062   void readDACs(const edm::Handle<EEDigiCollection> &pDigis, const std::map<int, int> &DACvalues);
0063 
0064   const edm::InputTag m_barrelDigiCollection;  //!< secondary name given to collection of digis
0065   const edm::InputTag m_endcapDigiCollection;  //!< secondary name given to collection of digis
0066   const edm::InputTag m_headerCollection;      //!< name of module/plugin/producer making headers
0067 
0068   const edm::EDGetTokenT<EcalRawDataCollection> m_rawDataToken;
0069   const edm::EDGetTokenT<EBDigiCollection> m_ebDigiToken;
0070   const edm::EDGetTokenT<EEDigiCollection> m_eeDigiToken;
0071   const edm::ESGetToken<EcalElectronicsMapping, EcalMappingRcd> m_mappingToken;
0072 
0073   std::string m_xmlFile;  //!< name of the xml file to be saved
0074 
0075   std::map<int, TPedValues *> m_pedValues;
0076   std::map<int, TPedResult *> m_pedResult;
0077 
0078   int m_DACmin;
0079   int m_DACmax;
0080   double m_RMSmax;
0081   int m_bestPed;
0082 
0083   //! database host name
0084   std::string m_dbHostName;
0085   //! database name
0086   std::string m_dbName;
0087   //! database user name
0088   std::string m_dbUserName;
0089   //! database user password
0090   std::string m_dbPassword;
0091   //! database
0092   int m_dbHostPort;
0093   //! allow the creation of a new moniov if not existing in the DB
0094   //! by default it is false.
0095   bool m_create_moniov;
0096   // used to retrieve the run_iov
0097   std::string m_location;
0098   //! run number
0099   int m_run;
0100 
0101   //! the root file where to store the detail plots
0102   std::string m_plotting;
0103   //! max slope (in magnitude) allowed for linearity test
0104   double m_maxSlopeAllowed_;
0105   //! min slope (in magnitude) allowed for linearity test
0106   double m_minSlopeAllowed_;
0107   //! max chi2/ndf allowed for linearity test
0108   double m_maxChi2OverNDFAllowed_;
0109 };
0110 
0111 #endif