Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-11-15 23:33:57

0001 /**
0002    \file
0003    Test analyzer for ecal conditions
0004 
0005    \author Stefano ARGIRO
0006    \version $Id: EcalTestConditionAnalyzer.cc,v 1.6 2009/07/01 08:16:25 argiro Exp $
0007    \date 05 Nov 2008
0008 */
0009 
0010 #include <string>
0011 #include "FWCore/Framework/interface/one/EDAnalyzer.h"
0012 #include "FWCore/Framework/interface/EventSetup.h"
0013 #include "FWCore/Framework/interface/MakerMacros.h"
0014 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0015 
0016 #include "CondFormats/DataRecord/interface/EcalTBWeightsRcd.h"
0017 #include "CondFormats/DataRecord/interface/EcalWeightXtalGroupsRcd.h"
0018 #include "CondFormats/DataRecord/interface/EcalChannelStatusRcd.h"
0019 #include "CondFormats/DataRecord/interface/EcalADCToGeVConstantRcd.h"
0020 #include "CondFormats/DataRecord/interface/EcalGainRatiosRcd.h"
0021 #include "CondFormats/DataRecord/interface/EcalIntercalibConstantsRcd.h"
0022 #include "CondFormats/DataRecord/interface/EcalIntercalibConstantsMCRcd.h"
0023 #include "CondFormats/DataRecord/interface/EcalIntercalibErrorsRcd.h"
0024 
0025 #include "CondFormats/EcalObjects/interface/EcalIntercalibConstants.h"
0026 #include "CondFormats/EcalObjects/interface/EcalIntercalibErrors.h"
0027 #include "CondFormats/EcalObjects/interface/EcalADCToGeVConstant.h"
0028 #include "CondFormats/EcalObjects/interface/EcalXtalGroupId.h"
0029 #include "CondFormats/EcalObjects/interface/EcalWeightXtalGroups.h"
0030 #include "CondFormats/EcalObjects/interface/EcalGainRatios.h"
0031 #include "CondFormats/EcalObjects/interface/EcalMGPAGainRatio.h"
0032 #include "CondFormats/EcalObjects/interface/EcalChannelStatus.h"
0033 #include "CondFormats/EcalObjects/interface/EcalChannelStatusCode.h"
0034 #include "CondFormats/EcalObjects/interface/EcalTBWeights.h"
0035 
0036 #include "CondTools/Ecal/interface/EcalADCToGeVXMLTranslator.h"
0037 #include "CondTools/Ecal/interface/EcalChannelStatusXMLTranslator.h"
0038 #include "CondTools/Ecal/interface/EcalGainRatiosXMLTranslator.h"
0039 #include "CondTools/Ecal/interface/EcalIntercalibConstantsXMLTranslator.h"
0040 #include "CondTools/Ecal/interface/EcalWeightGroupXMLTranslator.h"
0041 #include "CondTools/Ecal/interface/EcalTBWeightsXMLTranslator.h"
0042 
0043 #include "CondFormats/EcalObjects/interface/EcalADCToGeVConstant.h"
0044 #include "CondFormats/EcalObjects/interface/EcalIntercalibConstants.h"
0045 #include "CondFormats/EcalObjects/interface/EcalIntercalibConstantsMC.h"
0046 #include "CondFormats/EcalObjects/interface/EcalIntercalibErrors.h"
0047 #include "CondFormats/EcalObjects/interface/EcalIntercalibConstantsMC.h"
0048 
0049 /**
0050  *
0051  * Test analyzer that reads ecal records from event setup and writes XML files
0052  *
0053  */
0054 
0055 class EcalTestConditionAnalyzer : public edm::one::EDAnalyzer<> {
0056 public:
0057   explicit EcalTestConditionAnalyzer(const edm::ParameterSet&);
0058   ~EcalTestConditionAnalyzer() override = default;
0059 
0060   void analyze(edm::Event const&, edm::EventSetup const&) override;
0061 
0062 private:
0063   const edm::ESGetToken<EcalADCToGeVConstant, EcalADCToGeVConstantRcd> adcToGeVConstantToken_;
0064   const edm::ESGetToken<EcalChannelStatus, EcalChannelStatusRcd> channelStatusToken_;
0065   const edm::ESGetToken<EcalGainRatios, EcalGainRatiosRcd> gainRatiosToken_;
0066   const edm::ESGetToken<EcalIntercalibConstants, EcalIntercalibConstantsRcd> intercalibConstantsToken_;
0067   const edm::ESGetToken<EcalIntercalibConstantsMC, EcalIntercalibConstantsMCRcd> intercalibConstantsMCToken_;
0068   const edm::ESGetToken<EcalIntercalibErrors, EcalIntercalibErrorsRcd> intercalibErrorsToken_;
0069   const edm::ESGetToken<EcalTBWeights, EcalTBWeightsRcd> tbWeightsToken_;
0070   const edm::ESGetToken<EcalWeightXtalGroups, EcalWeightXtalGroupsRcd> weightXtalGroupsToken_;
0071 };
0072 
0073 EcalTestConditionAnalyzer::EcalTestConditionAnalyzer(const edm::ParameterSet&)
0074     : adcToGeVConstantToken_(esConsumes()),
0075       channelStatusToken_(esConsumes()),
0076       gainRatiosToken_(esConsumes()),
0077       intercalibConstantsToken_(esConsumes()),
0078       intercalibConstantsMCToken_(esConsumes()),
0079       intercalibErrorsToken_(esConsumes()),
0080       tbWeightsToken_(esConsumes()),
0081       weightXtalGroupsToken_(esConsumes()) {}
0082 
0083 void EcalTestConditionAnalyzer::analyze(const edm::Event& ev, const edm::EventSetup& iSetup) {
0084   // retrieve records from setup and write XML
0085   EcalCondHeader header;
0086   header.method_ = "testmethod";
0087   header.version_ = "testversion";
0088   header.datasource_ = "testdata";
0089   header.since_ = 123;
0090   header.tag_ = "testtag";
0091   header.date_ = "Mar 24 1973";
0092 
0093   const auto& adctogev = iSetup.getData(adcToGeVConstantToken_);
0094   const auto& chstatus = iSetup.getData(channelStatusToken_);
0095   const auto& gainratios = iSetup.getData(gainRatiosToken_);
0096   const auto& intercalib = iSetup.getData(intercalibConstantsToken_);
0097   const auto& intercalibmc = iSetup.getData(intercalibConstantsMCToken_);
0098   const auto& intercaliberr = iSetup.getData(intercalibErrorsToken_);
0099   const auto& tbweights = iSetup.getData(tbWeightsToken_);
0100   const auto& wgroup = iSetup.getData(weightXtalGroupsToken_);
0101 
0102   edm::LogInfo("EcalTestConditionAnalyzer") << "Got all records";
0103 
0104   const std::string ADCfile = "EcalADCToGeVConstant.xml";
0105   const std::string ChStatusfile = "EcalChannelStatus.xml";
0106   const std::string Grfile = "EcalGainRatios.xml";
0107   const std::string InterFile = "EcalIntercalibConstants.xml";
0108   const std::string InterMCFile = "EcalIntercalibConstantsMC.xml";
0109   const std::string WFile = "EcalTBWeights.xml";
0110   const std::string WGFile = "EcalWeightXtalGroups.xml";
0111 
0112   EcalADCToGeVXMLTranslator::writeXML(ADCfile, header, adctogev);
0113   EcalChannelStatusXMLTranslator::writeXML(ChStatusfile, header, chstatus);
0114   EcalGainRatiosXMLTranslator::writeXML(Grfile, header, gainratios);
0115   EcalIntercalibConstantsXMLTranslator::writeXML(InterFile, header, intercalib);
0116   EcalTBWeightsXMLTranslator::writeXML(WFile, header, tbweights);
0117   EcalWeightGroupXMLTranslator::writeXML(WGFile, header, wgroup);
0118 }
0119 
0120 DEFINE_FWK_MODULE(EcalTestConditionAnalyzer);