CMS 3D CMS Logo

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