CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/CalibCalorimetry/CaloMiscalibTools/plugins/CaloMiscalibTools.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    CaloMiscalibTools
00004 // Class:      CaloMiscalibTools
00005 // 
00013 //
00014 // Original Author:  Lorenzo AGOSTINO
00015 //         Created:  Wed May 31 10:37:45 CEST 2006
00016 // $Id: CaloMiscalibTools.cc,v 1.4 2008/03/26 14:07:42 fra Exp $
00017 //
00018 // Modified       : Luca Malgeri 
00019 // Date:          : 11/09/2006 
00020 // Reason         : split class definition (.h) from source code (.cc)
00021 //
00022 //
00023 
00024 
00025 // system include files
00026 
00027 // user include files
00028 #include "CalibCalorimetry/CaloMiscalibTools/interface/CaloMiscalibTools.h"
00029 #include "FWCore/ParameterSet/interface/FileInPath.h"
00030 
00031 #include "CalibCalorimetry/CaloMiscalibTools/interface/MiscalibReaderFromXMLEcalBarrel.h"
00032 #include "CalibCalorimetry/CaloMiscalibTools/interface/MiscalibReaderFromXMLEcalEndcap.h"
00033 
00034 //
00035 // constructors and destructor
00036 //
00037 CaloMiscalibTools::CaloMiscalibTools(const edm::ParameterSet& iConfig)
00038 {
00039    //the following line is needed to tell the framework what
00040    // data is being produced
00041   map_.prefillMap();
00042 
00043   barrelfileinpath_=iConfig.getUntrackedParameter<std::string> ("fileNameBarrel","");
00044   endcapfileinpath_=iConfig.getUntrackedParameter<std::string> ("fileNameEndcap","");
00045 
00046   edm::FileInPath barrelfiletmp("CalibCalorimetry/CaloMiscalibTools/data/"+barrelfileinpath_);
00047   edm::FileInPath endcapfiletmp("CalibCalorimetry/CaloMiscalibTools/data/"+endcapfileinpath_);
00048   
00049   
00050   barrelfile_=barrelfiletmp.fullPath();
00051   endcapfile_=endcapfiletmp.fullPath();
00052 
00053   std::cout <<"Barrel file is:"<< barrelfile_<<std::endl;
00054   std::cout <<"endcap file is:"<< endcapfile_<<std::endl;
00055 
00056 
00057    // added by Zhen (changed since 1_2_0)
00058    setWhatProduced(this,&CaloMiscalibTools::produce);
00059    findingRecord<EcalIntercalibConstantsRcd>();
00060    //now do what ever other initialization is needed
00061 }
00062 
00063 
00064 CaloMiscalibTools::~CaloMiscalibTools()
00065 {
00066  
00067    // do anything here that needs to be done at desctruction time
00068    // (e.g. close files, deallocate resources etc.)
00069 
00070 }
00071 
00072 
00073 //
00074 // member functions
00075 //
00076 
00077 // ------------ method called to produce the data  ------------
00078 CaloMiscalibTools::ReturnType
00079 CaloMiscalibTools::produce(const EcalIntercalibConstantsRcd& iRecord)
00080 {
00081     map_.prefillMap();
00082     MiscalibReaderFromXMLEcalBarrel barrelreader_(map_);
00083     MiscalibReaderFromXMLEcalEndcap endcapreader_(map_);
00084     if(!barrelfile_.empty()) barrelreader_.parseXMLMiscalibFile(barrelfile_);
00085     if(!endcapfile_.empty())endcapreader_.parseXMLMiscalibFile(endcapfile_);
00086     map_.print();
00087     // Added by Zhen, need a new object so to not be deleted at exit
00088     //    std::cout<<"about to copy"<<std::endl;
00089     EcalIntercalibConstants* mydata=new EcalIntercalibConstants(map_.get());
00090     //    std::cout<<"mydata "<<mydata<<std::endl;
00091     return mydata;
00092 }
00093 
00094  void CaloMiscalibTools::setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue&,
00095  edm::ValidityInterval & oValidity)
00096  {
00097  oValidity = edm::ValidityInterval(edm::IOVSyncValue::beginOfTime(),edm::IOVSyncValue::endOfTime());
00098  
00099  }
00100