CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/RecoTBCalo/EcalTBTDCReconstructor/src/EcalTBTDCRecInfoProducer.cc

Go to the documentation of this file.
00001 #include "RecoTBCalo/EcalTBTDCReconstructor/interface/EcalTBTDCRecInfoProducer.h"
00002 #include "TBDataFormats/EcalTBObjects/interface/EcalTBTDCRawInfo.h"
00003 #include "TBDataFormats/EcalTBObjects/interface/EcalTBTDCRecInfo.h"
00004 #include "DataFormats/Common/interface/EDCollection.h"
00005 #include "DataFormats/Common/interface/Handle.h"
00006 #include "FWCore/Framework/interface/Selector.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 EcalTBTDCRecInfoProducer::EcalTBTDCRecInfoProducer(edm::ParameterSet const& ps)
00013 {
00014   rawInfoCollection_ = ps.getParameter<std::string>("rawInfoCollection");
00015   rawInfoProducer_   = ps.getParameter<std::string>("rawInfoProducer");
00016   eventHeaderCollection_ = ps.getParameter<std::string>("eventHeaderCollection");
00017   eventHeaderProducer_   = ps.getParameter<std::string>("eventHeaderProducer");
00018   recInfoCollection_        = ps.getParameter<std::string>("recInfoCollection");
00019 
00020 //   std::vector<double> planeShift_def;
00021 //   planeShift_def.push_back( -0.333 );
00022 //   planeShift_def.push_back( -0.333 );
00023 //   planeShift_def.push_back( -0.333 );
00024 //   planeShift_def.push_back( -0.333 );
00025 
00026 
00027 //   std::vector<double> zPosition_def;
00028 //   zPosition_def.push_back( -0.333 );
00029 //   zPosition_def.push_back( -0.333 );
00030 //   zPosition_def.push_back( -0.333 );
00031 //   zPosition_def.push_back( -0.333 );
00032   std::vector<EcalTBTDCRecInfoAlgo::EcalTBTDCRanges> tdcRanges;
00033 
00034   typedef std::vector< edm::ParameterSet > Parameters;
00035   Parameters ranges=ps.getParameter<Parameters>("tdcRanges");
00036   for(Parameters::iterator itRanges = ranges.begin(); itRanges != ranges.end(); ++itRanges) 
00037     {
00038       EcalTBTDCRecInfoAlgo::EcalTBTDCRanges aRange;
00039       aRange.runRanges.first = itRanges->getParameter<int>("startRun");
00040       aRange.runRanges.second = itRanges->getParameter<int>("endRun");
00041       aRange.tdcMin = itRanges->getParameter< std::vector<double> >("tdcMin");
00042       aRange.tdcMax = itRanges->getParameter< std::vector<double> >("tdcMax");
00043       tdcRanges.push_back(aRange);
00044     }
00045   
00046   use2004OffsetConvention_ = ps.getUntrackedParameter< bool >("use2004OffsetConvention",false);
00047 
00048   produces<EcalTBTDCRecInfo>(recInfoCollection_);
00049 
00050   algo_ = new EcalTBTDCRecInfoAlgo(tdcRanges);
00051 }
00052 
00053 EcalTBTDCRecInfoProducer::~EcalTBTDCRecInfoProducer() {
00054   if (algo_)
00055     delete algo_;
00056 }
00057 
00058 void EcalTBTDCRecInfoProducer::produce(edm::Event& e, const edm::EventSetup& es)
00059 {
00060   // Get input
00061    edm::Handle<EcalTBTDCRawInfo> ecalRawTDC;  
00062    const EcalTBTDCRawInfo* ecalTDCRawInfo = 0;
00063 
00064    //evt.getByLabel( digiProducer_, digiCollection_, pDigis);
00065    e.getByLabel( rawInfoProducer_, ecalRawTDC);
00066    if (ecalRawTDC.isValid()) {
00067      ecalTDCRawInfo = ecalRawTDC.product();
00068    }
00069 
00070    if (! ecalTDCRawInfo )
00071      {
00072        edm::LogError("EcalTBTDCRecInfoError") << "Error! can't get the product " << rawInfoCollection_.c_str() ;
00073        return;
00074      }
00075 
00076    if ( (*ecalTDCRawInfo).size() < 1 )
00077      { 
00078        edm::LogError("EcalTBTDcRecInfoError") << "Less than one TDC good channel found. Aborting" << rawInfoCollection_.c_str() ;
00079        return;
00080      }
00081    // Get input
00082    edm::Handle<EcalTBEventHeader> tbEventHeader;  
00083    const EcalTBEventHeader* ecalEventHeader = 0;
00084    //evt.getByLabel( digiProducer_, digiCollection_, pDigis);
00085    e.getByLabel( eventHeaderProducer_, tbEventHeader);
00086    if (tbEventHeader.isValid()) {
00087      ecalEventHeader = tbEventHeader.product();
00088    }
00089    
00090    if (! ecalEventHeader )
00091      {
00092        edm::LogError("EcalTBTDCRecInfoError") << "Error! can't get the product " << eventHeaderCollection_.c_str();
00093        return;
00094      }
00095 
00096   // Create empty output
00097   std::auto_ptr<EcalTBTDCRecInfo> recInfo(new EcalTBTDCRecInfo(algo_->reconstruct(*ecalRawTDC,*tbEventHeader,use2004OffsetConvention_)));
00098   
00099   e.put(recInfo,recInfoCollection_);
00100 } 
00101 
00102