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