CMS 3D CMS Logo

EcalTBH2TDCRecInfoProducer.cc
Go to the documentation of this file.
9 
11 
13  rawInfoCollection_ = ps.getParameter<std::string>("rawInfoCollection");
14  rawInfoProducer_ = ps.getParameter<std::string>("rawInfoProducer");
15  triggerDataCollection_ = ps.getParameter<std::string>("triggerDataCollection");
16  triggerDataProducer_ = ps.getParameter<std::string>("triggerDataProducer");
17  recInfoCollection_ = ps.getParameter<std::string>("recInfoCollection");
18 
19  std::vector<EcalTBH2TDCRecInfoAlgo::EcalTBH2TDCRanges> tdcRanges;
20 
21  typedef std::vector<edm::ParameterSet> Parameters;
22  Parameters ranges = ps.getParameter<Parameters>("tdcZeros");
23  for (Parameters::iterator itRanges = ranges.begin(); itRanges != ranges.end(); ++itRanges) {
25  aRange.runRanges.first = itRanges->getParameter<int>("startRun");
26  aRange.runRanges.second = itRanges->getParameter<int>("endRun");
27  aRange.tdcZero = itRanges->getParameter<double>("tdcZero");
28  tdcRanges.push_back(aRange);
29  }
30 
31  produces<EcalTBTDCRecInfo>(recInfoCollection_);
32 
34 }
35 
37  if (algo_)
38  delete algo_;
39 }
40 
42  int runNumber = e.id().run();
43  // Get input
44  edm::Handle<HcalTBTiming> ecalRawTDC;
45  const HcalTBTiming* ecalTDCRawInfo = nullptr;
46 
47  //evt.getByLabel( digiProducer_, digiCollection_, pDigis);
48  e.getByLabel(rawInfoProducer_, ecalRawTDC);
49  if (ecalRawTDC.isValid()) {
50  ecalTDCRawInfo = ecalRawTDC.product();
51  }
52 
53  if (!ecalTDCRawInfo) {
54  edm::LogError("EcalTBTDCRecInfoError") << "Error! can't get the product " << rawInfoCollection_.c_str();
55  return;
56  }
57 
58  // Get input
60  const HcalTBTriggerData* h2TriggerData = nullptr;
61  //evt.getByLabel( digiProducer_, digiCollection_, pDigis);
62  e.getByLabel(triggerDataProducer_, triggerData);
63  if (triggerData.isValid()) {
64  h2TriggerData = triggerData.product();
65  }
66 
67  if (!h2TriggerData) {
68  edm::LogError("EcalTBTDCRecInfoError") << "Error! can't get the product " << triggerDataCollection_.c_str();
69  return;
70  }
71 
72  if (!h2TriggerData->wasBeamTrigger()) {
73  e.put(std::make_unique<EcalTBTDCRecInfo>(0.5), recInfoCollection_);
74  } else {
75  e.put(std::make_unique<EcalTBTDCRecInfo>(algo_->reconstruct(runNumber, *ecalRawTDC)), recInfoCollection_);
76  }
77 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
EcalTBH2TDCRecInfoProducer(const edm::ParameterSet &ps)
T const * product() const
Definition: Handle.h:70
EcalTBTDCRecInfo reconstruct(const int &runNumber, const HcalTBTiming &TDCRawInfo) const
Log< level::Error, false > LogError
string ranges
Definition: diffTwoXMLs.py:79
bool isValid() const
Definition: HandleBase.h:70
std::vector< AlignmentParameters * > Parameters
Definition: Utilities.h:32
void produce(edm::Event &e, const edm::EventSetup &es) override
bool wasBeamTrigger() const
returns true if this trigger came from beam data