CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoTBCalo/EcalTBHodoscopeReconstructor/src/EcalTBHodoscopeRecInfoProducer.cc

Go to the documentation of this file.
00001 #include "RecoTBCalo/EcalTBHodoscopeReconstructor/interface/EcalTBHodoscopeRecInfoProducer.h"
00002 #include "TBDataFormats/EcalTBObjects/interface/EcalTBHodoscopeRawInfo.h"
00003 #include "TBDataFormats/EcalTBObjects/interface/EcalTBHodoscopeRecInfo.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 EcalTBHodoscopeRecInfoProducer::EcalTBHodoscopeRecInfoProducer(edm::ParameterSet const& ps)
00013 {
00014   rawInfoCollection_ = ps.getParameter<std::string>("rawInfoCollection");
00015   rawInfoProducer_   = ps.getParameter<std::string>("rawInfoProducer");
00016   recInfoCollection_        = ps.getParameter<std::string>("recInfoCollection");
00017   fitMethod_ = ps.getParameter<int>("fitMethod");
00018 
00019 //   std::vector<double> planeShift_def;
00020 //   planeShift_def.push_back( -0.333 );
00021 //   planeShift_def.push_back( -0.333 );
00022 //   planeShift_def.push_back( -0.333 );
00023 //   planeShift_def.push_back( -0.333 );
00024   std::vector<double> planeShift = ps.getParameter< std::vector<double> >("planeShift");
00025 
00026 //   std::vector<double> zPosition_def;
00027 //   zPosition_def.push_back( -0.333 );
00028 //   zPosition_def.push_back( -0.333 );
00029 //   zPosition_def.push_back( -0.333 );
00030 //   zPosition_def.push_back( -0.333 );
00031   std::vector<double> zPosition = ps.getParameter< std::vector<double> >("zPosition");
00032   
00033   produces<EcalTBHodoscopeRecInfo>(recInfoCollection_);
00034   
00035   algo_ = new EcalTBHodoscopeRecInfoAlgo(fitMethod_, planeShift, zPosition);
00036 }
00037 
00038 EcalTBHodoscopeRecInfoProducer::~EcalTBHodoscopeRecInfoProducer() {
00039   delete algo_;
00040 }
00041 
00042 void EcalTBHodoscopeRecInfoProducer::produce(edm::Event& e, const edm::EventSetup& es)
00043 {
00044   // Get input
00045    edm::Handle<EcalTBHodoscopeRawInfo> ecalRawHodoscope;  
00046    const EcalTBHodoscopeRawInfo* ecalHodoRawInfo = 0;
00047    //evt.getByLabel( digiProducer_, digiCollection_, pDigis);
00048    e.getByLabel( rawInfoProducer_, ecalRawHodoscope);
00049    if (ecalRawHodoscope.isValid()) {
00050      ecalHodoRawInfo = ecalRawHodoscope.product();
00051    }
00052 
00053    if (! ecalHodoRawInfo )
00054      {
00055        edm::LogError("EcalTBHodoscopeRecInfoError") << "Error! can't get the product " << rawInfoCollection_.c_str() ;
00056        return;
00057      }
00058 
00059    if ( (*ecalHodoRawInfo).planes() != 4 )
00060      { 
00061        edm::LogError("EcalTBHodoscopeRecInfoError") << "Number of planes different from expected " << rawInfoCollection_.c_str() ;
00062        return;
00063      }
00064 
00065   // Create empty output
00066   std::auto_ptr<EcalTBHodoscopeRecInfo> recInfo(new EcalTBHodoscopeRecInfo(algo_->reconstruct(*ecalRawHodoscope)));
00067   
00068   e.put(recInfo,recInfoCollection_);
00069 } 
00070 
00071