CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalTBTDCRecInfoProducer.cc
Go to the documentation of this file.
9 
11 
13 {
14  rawInfoCollection_ = ps.getParameter<std::string>("rawInfoCollection");
15  rawInfoProducer_ = ps.getParameter<std::string>("rawInfoProducer");
16  eventHeaderCollection_ = ps.getParameter<std::string>("eventHeaderCollection");
17  eventHeaderProducer_ = ps.getParameter<std::string>("eventHeaderProducer");
18  recInfoCollection_ = ps.getParameter<std::string>("recInfoCollection");
19 
20 // std::vector<double> planeShift_def;
21 // planeShift_def.push_back( -0.333 );
22 // planeShift_def.push_back( -0.333 );
23 // planeShift_def.push_back( -0.333 );
24 // planeShift_def.push_back( -0.333 );
25 
26 
27 // std::vector<double> zPosition_def;
28 // zPosition_def.push_back( -0.333 );
29 // zPosition_def.push_back( -0.333 );
30 // zPosition_def.push_back( -0.333 );
31 // zPosition_def.push_back( -0.333 );
32  std::vector<EcalTBTDCRecInfoAlgo::EcalTBTDCRanges> tdcRanges;
33 
34  typedef std::vector< edm::ParameterSet > Parameters;
35  Parameters ranges=ps.getParameter<Parameters>("tdcRanges");
36  for(Parameters::iterator itRanges = ranges.begin(); itRanges != ranges.end(); ++itRanges)
37  {
39  aRange.runRanges.first = itRanges->getParameter<int>("startRun");
40  aRange.runRanges.second = itRanges->getParameter<int>("endRun");
41  aRange.tdcMin = itRanges->getParameter< std::vector<double> >("tdcMin");
42  aRange.tdcMax = itRanges->getParameter< std::vector<double> >("tdcMax");
43  tdcRanges.push_back(aRange);
44  }
45 
46  use2004OffsetConvention_ = ps.getUntrackedParameter< bool >("use2004OffsetConvention",false);
47 
48  produces<EcalTBTDCRecInfo>(recInfoCollection_);
49 
50  algo_ = new EcalTBTDCRecInfoAlgo(tdcRanges);
51 }
52 
54  if (algo_)
55  delete algo_;
56 }
57 
59 {
60  // Get input
62  const EcalTBTDCRawInfo* ecalTDCRawInfo = 0;
63 
64  //evt.getByLabel( digiProducer_, digiCollection_, pDigis);
65  e.getByLabel( rawInfoProducer_, ecalRawTDC);
66  if (ecalRawTDC.isValid()) {
67  ecalTDCRawInfo = ecalRawTDC.product();
68  }
69 
70  if (! ecalTDCRawInfo )
71  {
72  edm::LogError("EcalTBTDCRecInfoError") << "Error! can't get the product " << rawInfoCollection_.c_str() ;
73  return;
74  }
75 
76  if ( (*ecalTDCRawInfo).size() < 1 )
77  {
78  edm::LogError("EcalTBTDcRecInfoError") << "Less than one TDC good channel found. Aborting" << rawInfoCollection_.c_str() ;
79  return;
80  }
81  // Get input
82  edm::Handle<EcalTBEventHeader> tbEventHeader;
83  const EcalTBEventHeader* ecalEventHeader = 0;
84  //evt.getByLabel( digiProducer_, digiCollection_, pDigis);
85  e.getByLabel( eventHeaderProducer_, tbEventHeader);
86  if (tbEventHeader.isValid()) {
87  ecalEventHeader = tbEventHeader.product();
88  }
89 
90  if (! ecalEventHeader )
91  {
92  edm::LogError("EcalTBTDCRecInfoError") << "Error! can't get the product " << eventHeaderCollection_.c_str();
93  return;
94  }
95 
96  // Create empty output
97  std::auto_ptr<EcalTBTDCRecInfo> recInfo(new EcalTBTDCRecInfo(algo_->reconstruct(*ecalRawTDC,*tbEventHeader,use2004OffsetConvention_)));
98 
99  e.put(recInfo,recInfoCollection_);
100 }
101 
102 
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
EcalTBTDCRecInfo reconstruct(const EcalTBTDCRawInfo &TDCRawInfo, const EcalTBEventHeader &eventHeader, bool use2004OffsetConvention) const
vector< ParameterSet > Parameters
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
EcalTBTDCRecInfoAlgo * algo_
EcalTBTDCRecInfoProducer(const edm::ParameterSet &ps)
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
string ranges
Definition: diffTwoXMLs.py:78
virtual void produce(edm::Event &e, const edm::EventSetup &es)
T const * product() const
Definition: Handle.h:74