CMS 3D CMS Logo

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