Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-10-14 01:44:33

0001 #include "RecoTBCalo/EcalTBHodoscopeReconstructor/interface/EcalTBHodoscopeRecInfoProducer.h"
0002 #include "TBDataFormats/EcalTBObjects/interface/EcalTBHodoscopeRawInfo.h"
0003 #include "TBDataFormats/EcalTBObjects/interface/EcalTBHodoscopeRecInfo.h"
0004 #include "DataFormats/Common/interface/EDCollection.h"
0005 #include "DataFormats/Common/interface/Handle.h"
0006 #include "FWCore/Framework/interface/ESHandle.h"
0007 #include "FWCore/Framework/interface/EventSetup.h"
0008 
0009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0010 
0011 EcalTBHodoscopeRecInfoProducer::EcalTBHodoscopeRecInfoProducer(edm::ParameterSet const& ps)
0012     : rawInfoProducerToken_(consumes(ps.getParameter<std::string>("rawInfoProducer"))),
0013       rawInfoCollection_(ps.getParameter<std::string>("rawInfoCollection")),
0014       recInfoCollection_(ps.getParameter<std::string>("recInfoCollection")),
0015       fitMethod_(ps.getParameter<int>("fitMethod")),
0016       algo_(fitMethod_,
0017             ps.getParameter<std::vector<double> >("planeShift"),
0018             ps.getParameter<std::vector<double> >("zPosition")) {
0019   //   std::vector<double> planeShift_def;
0020   //   planeShift_def.push_back( -0.333 );
0021   //   planeShift_def.push_back( -0.333 );
0022   //   planeShift_def.push_back( -0.333 );
0023   //   planeShift_def.push_back( -0.333 );
0024 
0025   //   std::vector<double> zPosition_def;
0026   //   zPosition_def.push_back( -0.333 );
0027   //   zPosition_def.push_back( -0.333 );
0028   //   zPosition_def.push_back( -0.333 );
0029   //   zPosition_def.push_back( -0.333 );
0030 
0031   produces<EcalTBHodoscopeRecInfo>(recInfoCollection_);
0032 }
0033 
0034 void EcalTBHodoscopeRecInfoProducer::produce(edm::StreamID, edm::Event& e, const edm::EventSetup& es) const {
0035   // Get input
0036   edm::Handle<EcalTBHodoscopeRawInfo> ecalRawHodoscope = e.getHandle(rawInfoProducerToken_);
0037   const EcalTBHodoscopeRawInfo* ecalHodoRawInfo = nullptr;
0038   if (ecalRawHodoscope.isValid()) {
0039     ecalHodoRawInfo = ecalRawHodoscope.product();
0040   }
0041 
0042   if (!ecalHodoRawInfo) {
0043     edm::LogError("EcalTBHodoscopeRecInfoError") << "Error! can't get the product " << rawInfoCollection_.c_str();
0044     return;
0045   }
0046 
0047   if ((*ecalHodoRawInfo).planes() != 4) {
0048     edm::LogError("EcalTBHodoscopeRecInfoError")
0049         << "Number of planes different from expected " << rawInfoCollection_.c_str();
0050     return;
0051   }
0052 
0053   // Create empty output
0054 
0055   e.put(std::make_unique<EcalTBHodoscopeRecInfo>(algo_.reconstruct(*ecalRawHodoscope)), recInfoCollection_);
0056 }