CMS 3D CMS Logo

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