Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:57:32

0001 // -*- C++ -*-
0002 //
0003 // Package:    CaloMiscalibToolsMC
0004 // Class:      CaloMiscalibToolsMC
0005 //
0006 /**\class CaloMiscalibToolsMC CaloMiscalibToolsMC.h CalibCalorimetry/CaloMiscalibToolsMC/interface/CaloMiscalibToolsMC.h
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Lorenzo AGOSTINO
0015 //         Created:  Wed May 31 10:37:45 CEST 2006
0016 //
0017 // Modified       : Luca Malgeri
0018 // Date:          : 11/09/2006
0019 // Reason         : split class definition (.h) from source code (.cc)
0020 //
0021 //
0022 
0023 // system include files
0024 
0025 // user include files
0026 #include "CalibCalorimetry/CaloMiscalibTools/interface/CaloMiscalibToolsMC.h"
0027 #include "FWCore/ParameterSet/interface/FileInPath.h"
0028 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0029 
0030 #include "CalibCalorimetry/CaloMiscalibTools/interface/MiscalibReaderFromXMLEcalBarrel.h"
0031 #include "CalibCalorimetry/CaloMiscalibTools/interface/MiscalibReaderFromXMLEcalEndcap.h"
0032 
0033 //
0034 // constructors and destructor
0035 //
0036 CaloMiscalibToolsMC::CaloMiscalibToolsMC(const edm::ParameterSet& iConfig) {
0037   //the following line is needed to tell the framework what
0038   // data is being produced
0039 
0040   barrelfileinpath_ = iConfig.getUntrackedParameter<std::string>("fileNameBarrel", "");
0041   endcapfileinpath_ = iConfig.getUntrackedParameter<std::string>("fileNameEndcap", "");
0042 
0043   edm::FileInPath barrelfiletmp("CalibCalorimetry/CaloMiscalibTools/data/" + barrelfileinpath_);
0044   edm::FileInPath endcapfiletmp("CalibCalorimetry/CaloMiscalibTools/data/" + endcapfileinpath_);
0045 
0046   barrelfile_ = barrelfiletmp.fullPath();
0047   endcapfile_ = endcapfiletmp.fullPath();
0048 
0049   edm::LogVerbatim("CaloMiscalibToolsMC") << "Barrel file is:" << barrelfile_;
0050   edm::LogVerbatim("CaloMiscalibToolsMC") << "endcap file is:" << endcapfile_;
0051 
0052   // added by Zhen (changed since 1_2_0)
0053   setWhatProduced(this, &CaloMiscalibToolsMC::produce);
0054   findingRecord<EcalIntercalibConstantsMCRcd>();
0055   //now do what ever other initialization is needed
0056 }
0057 
0058 CaloMiscalibToolsMC::~CaloMiscalibToolsMC() {
0059   // do anything here that needs to be done at desctruction time
0060   // (e.g. close files, deallocate resources etc.)
0061 }
0062 
0063 //
0064 // member functions
0065 //
0066 
0067 // ------------ method called to produce the data  ------------
0068 CaloMiscalibToolsMC::ReturnType CaloMiscalibToolsMC::produce(const EcalIntercalibConstantsMCRcd& iRecord) {
0069   CaloMiscalibMapEcal map;
0070   map.prefillMap();
0071   MiscalibReaderFromXMLEcalBarrel barrelreader_(map);
0072   MiscalibReaderFromXMLEcalEndcap endcapreader_(map);
0073   if (!barrelfile_.empty())
0074     barrelreader_.parseXMLMiscalibFile(barrelfile_);
0075   if (!endcapfile_.empty())
0076     endcapreader_.parseXMLMiscalibFile(endcapfile_);
0077   map.print();
0078   // Added by Zhen, need a new object so to not be deleted at exit
0079   CaloMiscalibToolsMC::ReturnType mydata = std::make_unique<EcalIntercalibConstantsMC>(map.get());
0080   return mydata;
0081 }
0082 
0083 void CaloMiscalibToolsMC::setIntervalFor(const edm::eventsetup::EventSetupRecordKey&,
0084                                          const edm::IOVSyncValue&,
0085                                          edm::ValidityInterval& oValidity) {
0086   oValidity = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime());
0087 }