CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalTrigPrimDigiProducer.cc
Go to the documentation of this file.
23 
24 #include <algorithm>
25 
27 :
28  theAlgo_(ps.getParameter<bool>("peakFilter"),
29  ps.getParameter<std::vector<double> >("weights"),
30  ps.getParameter<int>("latency"),
31  ps.getParameter<uint32_t>("FG_threshold"),
32  ps.getParameter<uint32_t>("ZS_threshold"),
33  ps.getParameter<int>("numberOfSamples"),
34  ps.getParameter<int>("numberOfPresamples"),
35  ps.getParameter<uint32_t>("MinSignalThreshold"),
36  ps.getParameter<uint32_t>("PMTNoiseThreshold")
37  ),
38  inputLabel_(ps.getParameter<std::vector<edm::InputTag> >("inputLabel")),
39  inputTagFEDRaw_(ps.getParameter<edm::InputTag> ("InputTagFEDRaw")),
40  runZS_(ps.getParameter<bool>("RunZS")),
41  runFrontEndFormatError_(ps.getParameter<bool>("FrontEndFormatError"))
42 {
43  produces<HcalTrigPrimDigiCollection>();
44  theAlgo_.setPeakFinderAlgorithm(ps.getParameter<int>("PeakFinderAlgorithm"));
45 }
46 
47 
49 
50  // Step A: get the conditions, for the decoding
51  edm::ESHandle<HcalTPGCoder> inputCoder;
52  eventSetup.get<HcalTPGRecord>().get(inputCoder);
53 
55  eventSetup.get<CaloTPGRecord>().get(outTranscoder);
56  outTranscoder->setup(eventSetup,CaloTPGTranscoder::HcalTPG);
57 
59  eventSetup.get<HcalLutMetadataRcd>().get(lutMetadata);
60  float rctlsb = lutMetadata->getRctLsb();
61 
62  // Step B: Create empty output
63  std::auto_ptr<HcalTrigPrimDigiCollection> result(new HcalTrigPrimDigiCollection());
64 
67 
68  iEvent.getByLabel(inputLabel_[0],hbheDigis);
69  iEvent.getByLabel(inputLabel_[1],hfDigis);
70 
71  // protect here against missing input collections
72  // there is no protection in HcalTriggerPrimitiveAlgo
73 
74  if (!hbheDigis.isValid()) {
75  edm::LogInfo("HcalTrigPrimDigiProducer")
76  << "\nWarning: HBHEDigiCollection with input tag "
77  << inputLabel_[0]
78  << "\nrequested in configuration, but not found in the event."
79  << "\nQuit returning empty product." << std::endl;
80 
81  // put empty HcalTrigPrimDigiCollection in the event
82  iEvent.put(result);
83 
84  outTranscoder->releaseSetup();
85 
86  return;
87  }
88 
89  if (!hfDigis.isValid()) {
90  edm::LogInfo("HcalTrigPrimDigiProducer")
91  << "\nWarning: HFDigiCollection with input tag "
92  << inputLabel_[1]
93  << "\nrequested in configuration, but not found in the event."
94  << "\nQuit returning empty product." << std::endl;
95 
96  // put empty HcalTrigPrimDigiCollection in the event
97  iEvent.put(result);
98 
99  outTranscoder->releaseSetup();
100 
101  return;
102  }
103 
104 
105  // Step C: Invoke the algorithm, passing in inputs and getting back outputs.
106  theAlgo_.run(inputCoder.product(),outTranscoder->getHcalCompressor().get(),
107  *hbheDigis, *hfDigis, *result, rctlsb);
108 
109  // Step C.1: Run FE Format Error / ZS for real data.
111 
113  eventSetup.get<HcalDbRecord> ().get(pSetup);
114  const HcalElectronicsMap *emap = pSetup->getHcalMapping();
115 
117  iEvent.getByLabel(inputTagFEDRaw_, fedHandle);
118 
119  if (fedHandle.isValid() && emap != 0) {
120  theAlgo_.runFEFormatError(fedHandle.product(), emap, *result);
121  } else {
122  edm::LogInfo("HcalTrigPrimDigiProducer")
123  << "\nWarning: FEDRawDataCollection with input tag "
124  << inputTagFEDRaw_
125  << "\nrequested in configuration, but not found in the event."
126  << "\nQuit returning empty product." << std::endl;
127 
128  // produce empty HcalTrigPrimDigiCollection and put it in the event
129  std::auto_ptr < HcalTrigPrimDigiCollection > emptyResult(
131 
132  iEvent.put(emptyResult);
133 
134  outTranscoder->releaseSetup();
135 
136  return;
137  }
138 
139  }
140 
141  if (runZS_) theAlgo_.runZS(*result);
142 
143  // edm::LogInfo("HcalTrigPrimDigiProducer") << "HcalTrigPrims: " << result->size();
144 
145  // Step D: Put outputs into event
146  iEvent.put(result);
147 
148  outTranscoder->releaseSetup();
149 }
150 
151 
T getParameter(std::string const &) const
edm::InputTag inputTagFEDRaw_
input tag for FEDRawDataCollection
void runFEFormatError(const FEDRawDataCollection *rawraw, const HcalElectronicsMap *emap, HcalTrigPrimDigiCollection &result)
HcalTrigPrimDigiProducer(const edm::ParameterSet &ps)
edm::SortedCollection< HcalTriggerPrimitiveDigi > HcalTrigPrimDigiCollection
void run(const HcalTPGCoder *incoder, const HcalTPGCompressor *outcoder, const HBHEDigiCollection &hbheDigis, const HFDigiCollection &hfDigis, HcalTrigPrimDigiCollection &result, float rctlsb)
HcalTriggerPrimitiveAlgo theAlgo_
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
tuple result
Definition: query.py:137
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
void runZS(HcalTrigPrimDigiCollection &tp)
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
T const * product() const
Definition: Handle.h:74
virtual void produce(edm::Event &e, const edm::EventSetup &c)
std::vector< edm::InputTag > inputLabel_
input tags for HCAL digis