CMS 3D CMS Logo

EcalTBH2TDCRecInfoProducer.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  triggerDataCollection_ = ps.getParameter<std::string>("triggerDataCollection");
17  triggerDataProducer_ = ps.getParameter<std::string>("triggerDataProducer");
18  recInfoCollection_ = ps.getParameter<std::string>("recInfoCollection");
19 
20 
21  std::vector<EcalTBH2TDCRecInfoAlgo::EcalTBH2TDCRanges> tdcRanges;
22 
23  typedef std::vector< edm::ParameterSet > Parameters;
24  Parameters ranges=ps.getParameter<Parameters>("tdcZeros");
25  for(Parameters::iterator itRanges = ranges.begin(); itRanges != ranges.end(); ++itRanges)
26  {
28  aRange.runRanges.first = itRanges->getParameter<int>("startRun");
29  aRange.runRanges.second = itRanges->getParameter<int>("endRun");
30  aRange.tdcZero = itRanges->getParameter< double >("tdcZero");
31  tdcRanges.push_back(aRange);
32  }
33 
34  produces<EcalTBTDCRecInfo>(recInfoCollection_);
35 
36  algo_ = new EcalTBH2TDCRecInfoAlgo(tdcRanges);
37 }
38 
40 {
41  if (algo_)
42  delete algo_;
43 }
44 
46 {
47  int runNumber = e.id().run();
48  // Get input
49  edm::Handle<HcalTBTiming> ecalRawTDC;
50  const HcalTBTiming* ecalTDCRawInfo = nullptr;
51 
52  //evt.getByLabel( digiProducer_, digiCollection_, pDigis);
53  e.getByLabel( rawInfoProducer_, ecalRawTDC);
54  if (ecalRawTDC.isValid()) {
55  ecalTDCRawInfo = ecalRawTDC.product();
56  }
57 
58 
59  if (! ecalTDCRawInfo )
60  {
61  edm::LogError("EcalTBTDCRecInfoError") << "Error! can't get the product " << rawInfoCollection_.c_str() ;
62  return;
63  }
64 
65 
66  // Get input
67  edm::Handle<HcalTBTriggerData> triggerData;
68  const HcalTBTriggerData* h2TriggerData = nullptr;
69  //evt.getByLabel( digiProducer_, digiCollection_, pDigis);
70  e.getByLabel(triggerDataProducer_, triggerData);
71  if (triggerData.isValid()) {
72  h2TriggerData = triggerData.product();
73  }
74 
75  if (! h2TriggerData )
76  {
77  edm::LogError("EcalTBTDCRecInfoError") << "Error! can't get the product " << triggerDataCollection_.c_str();
78  return;
79  }
80 
81 
82  if (!h2TriggerData->wasBeamTrigger())
83  {
84  e.put(std::make_unique<EcalTBTDCRecInfo>(0.5),recInfoCollection_);
85  }
86  else
87  {
88  e.put(std::make_unique<EcalTBTDCRecInfo>(algo_->reconstruct(runNumber,*ecalRawTDC)),recInfoCollection_);
89  }
90 
91 
92 }
93 
94 
RunNumber_t run() const
Definition: EventID.h:39
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
EcalTBH2TDCRecInfoProducer(const edm::ParameterSet &ps)
EcalTBTDCRecInfo reconstruct(const int &runNumber, const HcalTBTiming &TDCRawInfo) const
vector< ParameterSet > Parameters
bool isValid() const
Definition: HandleBase.h:74
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:535
string ranges
Definition: diffTwoXMLs.py:78
T const * product() const
Definition: Handle.h:81
edm::EventID id() const
Definition: EventBase.h:60
void produce(edm::Event &e, const edm::EventSetup &es) override
bool wasBeamTrigger() const
returns true if this trigger came from beam data