CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/RecoTBCalo/EcalTBTDCReconstructor/src/EcalTBH2TDCRecInfoProducer.cc

Go to the documentation of this file.
00001 #include "RecoTBCalo/EcalTBTDCReconstructor/interface/EcalTBH2TDCRecInfoProducer.h"
00002 #include "TBDataFormats/HcalTBObjects/interface/HcalTBTiming.h"
00003 #include "TBDataFormats/HcalTBObjects/interface/HcalTBTriggerData.h"
00004 #include "TBDataFormats/EcalTBObjects/interface/EcalTBTDCRecInfo.h"
00005 #include "DataFormats/Common/interface/EDCollection.h"
00006 #include "DataFormats/Common/interface/Handle.h"
00007 #include "FWCore/Framework/interface/Selector.h"
00008 #include "FWCore/Framework/interface/ESHandle.h"
00009 #include "FWCore/Framework/interface/EventSetup.h"
00010 
00011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00012     
00013 EcalTBH2TDCRecInfoProducer::EcalTBH2TDCRecInfoProducer(edm::ParameterSet const& ps)
00014 {
00015   rawInfoCollection_ = ps.getParameter<std::string>("rawInfoCollection");
00016   rawInfoProducer_   = ps.getParameter<std::string>("rawInfoProducer");
00017   triggerDataCollection_ = ps.getParameter<std::string>("triggerDataCollection");
00018   triggerDataProducer_   = ps.getParameter<std::string>("triggerDataProducer");
00019   recInfoCollection_        = ps.getParameter<std::string>("recInfoCollection");
00020 
00021 
00022   std::vector<EcalTBH2TDCRecInfoAlgo::EcalTBH2TDCRanges> tdcRanges;
00023 
00024   typedef std::vector< edm::ParameterSet > Parameters;
00025   Parameters ranges=ps.getParameter<Parameters>("tdcZeros");
00026   for(Parameters::iterator itRanges = ranges.begin(); itRanges != ranges.end(); ++itRanges) 
00027     {
00028       EcalTBH2TDCRecInfoAlgo::EcalTBH2TDCRanges aRange;
00029       aRange.runRanges.first = itRanges->getParameter<int>("startRun");
00030       aRange.runRanges.second = itRanges->getParameter<int>("endRun");
00031       aRange.tdcZero = itRanges->getParameter< double >("tdcZero");
00032       tdcRanges.push_back(aRange);
00033     }
00034   
00035   produces<EcalTBTDCRecInfo>(recInfoCollection_);
00036   
00037   algo_ = new EcalTBH2TDCRecInfoAlgo(tdcRanges);
00038 }
00039 
00040 EcalTBH2TDCRecInfoProducer::~EcalTBH2TDCRecInfoProducer() 
00041 {
00042   if (algo_)
00043     delete algo_;
00044 }
00045 
00046 void EcalTBH2TDCRecInfoProducer::produce(edm::Event& e, const edm::EventSetup& es)
00047 {
00048   int runNumber = e.id().run();
00049   // Get input
00050   edm::Handle<HcalTBTiming> ecalRawTDC;  
00051   const HcalTBTiming* ecalTDCRawInfo = 0;
00052   
00053   //evt.getByLabel( digiProducer_, digiCollection_, pDigis);
00054   e.getByLabel( rawInfoProducer_, ecalRawTDC);
00055   if (ecalRawTDC.isValid()) {
00056     ecalTDCRawInfo = ecalRawTDC.product();
00057   }
00058 
00059   
00060   if (! ecalTDCRawInfo )
00061     {
00062       edm::LogError("EcalTBTDCRecInfoError") << "Error! can't get the product " << rawInfoCollection_.c_str() ;
00063       return;
00064     }
00065   
00066   
00067   // Get input
00068   edm::Handle<HcalTBTriggerData> triggerData;  
00069   const HcalTBTriggerData* h2TriggerData = 0;
00070   //evt.getByLabel( digiProducer_, digiCollection_, pDigis);
00071   e.getByLabel(triggerDataProducer_, triggerData);
00072   if (triggerData.isValid()) {
00073     h2TriggerData = triggerData.product();
00074   }
00075   
00076   if (! h2TriggerData )
00077     {
00078       edm::LogError("EcalTBTDCRecInfoError") << "Error! can't get the product " << triggerDataCollection_.c_str();
00079       return;
00080     }
00081   
00082   
00083   if (!h2TriggerData->wasBeamTrigger())
00084     {
00085       std::auto_ptr<EcalTBTDCRecInfo> recInfo(new EcalTBTDCRecInfo(0.5));
00086       e.put(recInfo,recInfoCollection_);
00087     }
00088    else
00089      {
00090        std::auto_ptr<EcalTBTDCRecInfo> recInfo(new EcalTBTDCRecInfo(algo_->reconstruct(runNumber,*ecalRawTDC)));
00091        e.put(recInfo,recInfoCollection_);
00092      }
00093   
00094 
00095 } 
00096 
00097