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