Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
// -*- C++ -*-
//
// Package:    CaloMiscalibTools
// Class:      CaloMiscalibTools
//
/**\class CaloMiscalibTools CaloMiscalibTools.h CalibCalorimetry/CaloMiscalibTools/interface/CaloMiscalibTools.h

 Description: <one line class summary>

 Implementation:
     <Notes on implementation>
*/
//
// Original Author:  Lorenzo AGOSTINO
//         Created:  Wed May 31 10:37:45 CEST 2006
//
// Modified       : Luca Malgeri
// Date:          : 11/09/2006
// Reason         : split class definition (.h) from source code (.cc)
//
//

// system include files

// user include files
#include "CalibCalorimetry/CaloMiscalibTools/interface/CaloMiscalibTools.h"
#include "FWCore/ParameterSet/interface/FileInPath.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "CalibCalorimetry/CaloMiscalibTools/interface/MiscalibReaderFromXMLEcalBarrel.h"
#include "CalibCalorimetry/CaloMiscalibTools/interface/MiscalibReaderFromXMLEcalEndcap.h"

//
// constructors and destructor
//
CaloMiscalibTools::CaloMiscalibTools(const edm::ParameterSet& iConfig) {
  //the following line is needed to tell the framework what
  // data is being produced

  barrelfileinpath_ = iConfig.getUntrackedParameter<std::string>("fileNameBarrel", "");
  endcapfileinpath_ = iConfig.getUntrackedParameter<std::string>("fileNameEndcap", "");

  edm::FileInPath barrelfiletmp("CalibCalorimetry/CaloMiscalibTools/data/" + barrelfileinpath_);
  edm::FileInPath endcapfiletmp("CalibCalorimetry/CaloMiscalibTools/data/" + endcapfileinpath_);

  barrelfile_ = barrelfiletmp.fullPath();
  endcapfile_ = endcapfiletmp.fullPath();

  edm::LogVerbatim("CaloMiscalibTools") << "Barrel file is:" << barrelfile_;
  edm::LogVerbatim("CaloMiscalibTools") << "endcap file is:" << endcapfile_;

  // added by Zhen (changed since 1_2_0)
  setWhatProduced(this, &CaloMiscalibTools::produce);
  findingRecord<EcalIntercalibConstantsRcd>();
  //now do what ever other initialization is needed
}

CaloMiscalibTools::~CaloMiscalibTools() {
  // do anything here that needs to be done at desctruction time
  // (e.g. close files, deallocate resources etc.)
}

//
// member functions
//

// ------------ method called to produce the data  ------------
CaloMiscalibTools::ReturnType CaloMiscalibTools::produce(const EcalIntercalibConstantsRcd& iRecord) {
  CaloMiscalibMapEcal map;
  map.prefillMap();
  MiscalibReaderFromXMLEcalBarrel barrelreader_(map);
  MiscalibReaderFromXMLEcalEndcap endcapreader_(map);
  if (!barrelfile_.empty())
    barrelreader_.parseXMLMiscalibFile(barrelfile_);
  if (!endcapfile_.empty())
    endcapreader_.parseXMLMiscalibFile(endcapfile_);
  map.print();
  // Added by Zhen, need a new object so to not be deleted at exit
  CaloMiscalibTools::ReturnType mydata = std::make_unique<EcalIntercalibConstants>(map.get());
  return mydata;
}

void CaloMiscalibTools::setIntervalFor(const edm::eventsetup::EventSetupRecordKey&,
                                       const edm::IOVSyncValue&,
                                       edm::ValidityInterval& oValidity) {
  oValidity = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(), edm::IOVSyncValue::endOfTime());
}