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.
24 
25 #include <algorithm>
26 
28 :
29  theAlgo_(ps.getParameter<bool>("peakFilter"),
30  ps.getParameter<std::vector<double> >("weights"),
31  ps.getParameter<int>("latency"),
32  ps.getParameter<uint32_t>("FG_threshold"),
33  ps.getParameter<uint32_t>("ZS_threshold"),
34  ps.getParameter<int>("numberOfSamples"),
35  ps.getParameter<int>("numberOfPresamples"),
36  ps.getParameter<uint32_t>("MinSignalThreshold"),
37  ps.getParameter<uint32_t>("PMTNoiseThreshold")
38  ),
39  inputLabel_(ps.getParameter<std::vector<edm::InputTag> >("inputLabel")),
40  inputTagFEDRaw_(ps.getParameter<edm::InputTag> ("InputTagFEDRaw")),
41  runZS_(ps.getParameter<bool>("RunZS")),
42  runFrontEndFormatError_(ps.getParameter<bool>("FrontEndFormatError"))
43 {
44  produces<HcalTrigPrimDigiCollection>();
45  theAlgo_.setPeakFinderAlgorithm(ps.getParameter<int>("PeakFinderAlgorithm"));
46 }
47 
48 
50 
51  // Step A: get the conditions, for the decoding
52  edm::ESHandle<HcalTPGCoder> inputCoder;
53  eventSetup.get<HcalTPGRecord>().get(inputCoder);
54 
56  eventSetup.get<CaloTPGRecord>().get(outTranscoder);
57  outTranscoder->setup(eventSetup,CaloTPGTranscoder::HcalTPG);
58 
60  eventSetup.get<HcalLutMetadataRcd>().get(lutMetadata);
61  float rctlsb = lutMetadata->getRctLsb();
62 
64  eventSetup.get<CaloGeometryRecord>().get(pG);
65 
66  // Step B: Create empty output
67  std::auto_ptr<HcalTrigPrimDigiCollection> result(new HcalTrigPrimDigiCollection());
68 
71 
72  iEvent.getByLabel(inputLabel_[0],hbheDigis);
73  iEvent.getByLabel(inputLabel_[1],hfDigis);
74 
75  // protect here against missing input collections
76  // there is no protection in HcalTriggerPrimitiveAlgo
77 
78  if (!hbheDigis.isValid()) {
79  edm::LogInfo("HcalTrigPrimDigiProducer")
80  << "\nWarning: HBHEDigiCollection with input tag "
81  << inputLabel_[0]
82  << "\nrequested in configuration, but not found in the event."
83  << "\nQuit returning empty product." << std::endl;
84 
85  // put empty HcalTrigPrimDigiCollection in the event
86  iEvent.put(result);
87 
88  outTranscoder->releaseSetup();
89 
90  return;
91  }
92 
93  if (!hfDigis.isValid()) {
94  edm::LogInfo("HcalTrigPrimDigiProducer")
95  << "\nWarning: HFDigiCollection with input tag "
96  << inputLabel_[1]
97  << "\nrequested in configuration, but not found in the event."
98  << "\nQuit returning empty product." << std::endl;
99 
100  // put empty HcalTrigPrimDigiCollection in the event
101  iEvent.put(result);
102 
103  outTranscoder->releaseSetup();
104 
105  return;
106  }
107 
108 
109  // Step C: Invoke the algorithm, passing in inputs and getting back outputs.
110  theAlgo_.run(inputCoder.product(),outTranscoder->getHcalCompressor().get(),
111  *hbheDigis, *hfDigis, *result, &(*pG), rctlsb);
112 
113  // Step C.1: Run FE Format Error / ZS for real data.
115 
117  eventSetup.get<HcalDbRecord> ().get(pSetup);
118  const HcalElectronicsMap *emap = pSetup->getHcalMapping();
119 
121  iEvent.getByLabel(inputTagFEDRaw_, fedHandle);
122 
123  if (fedHandle.isValid() && emap != 0) {
124  theAlgo_.runFEFormatError(fedHandle.product(), emap, *result);
125  } else {
126  edm::LogInfo("HcalTrigPrimDigiProducer")
127  << "\nWarning: FEDRawDataCollection with input tag "
128  << inputTagFEDRaw_
129  << "\nrequested in configuration, but not found in the event."
130  << "\nQuit returning empty product." << std::endl;
131 
132  // produce empty HcalTrigPrimDigiCollection and put it in the event
133  std::auto_ptr < HcalTrigPrimDigiCollection > emptyResult(
135 
136  iEvent.put(emptyResult);
137 
138  outTranscoder->releaseSetup();
139 
140  return;
141  }
142 
143  }
144 
145  if (runZS_) theAlgo_.runZS(*result);
146 
147  // edm::LogInfo("HcalTrigPrimDigiProducer") << "HcalTrigPrims: " << result->size();
148 
149  // Step D: Put outputs into event
150  iEvent.put(result);
151 
152  outTranscoder->releaseSetup();
153 }
154 
155 
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
HcalTriggerPrimitiveAlgo theAlgo_
void run(const HcalTPGCoder *incoder, const HcalTPGCompressor *outcoder, const HBHEDigiCollection &hbheDigis, const HFDigiCollection &hfDigis, HcalTrigPrimDigiCollection &result, const HcalTrigTowerGeometry *trigTowerGeometry, float rctlsb)
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:94
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:361
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