Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // -*- C++ -*-
0002 //
0003 // Package:    CaloMiscalibTools
0004 // Class:      CaloMiscalibTools
0005 //
0006 /**\class CaloMiscalibTools CaloMiscalibTools.h CalibCalorimetry/CaloMiscalibTools/interface/CaloMiscalibTools.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/CaloMiscalibTools.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 CaloMiscalibTools::CaloMiscalibTools(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("CaloMiscalibTools") << "Barrel file is:" << barrelfile_;
0050   edm::LogVerbatim("CaloMiscalibTools") << "endcap file is:" << endcapfile_;
0051 
0052   // added by Zhen (changed since 1_2_0)
0053   setWhatProduced(this, &CaloMiscalibTools::produce);
0054   findingRecord<EcalIntercalibConstantsRcd>();
0055   //now do what ever other initialization is needed
0056 }
0057 
0058 CaloMiscalibTools::~CaloMiscalibTools() {
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 CaloMiscalibTools::ReturnType CaloMiscalibTools::produce(const EcalIntercalibConstantsRcd& 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   CaloMiscalibTools::ReturnType mydata = std::make_unique<EcalIntercalibConstants>(map.get());
0080   return mydata;
0081 }
0082 
0083 void CaloMiscalibTools::setIntervalFor(const edm::eventsetup::EventSetupRecordKey&,
0084                                        const edm::IOVSyncValue&,
0085                                        edm::ValidityInterval& oValidity) {
0086   oValidity = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime());
0087 }