CMS 3D CMS Logo

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