CMS 3D CMS Logo

HcalTrigPrimDigiProducer.cc
Go to the documentation of this file.
22 
23 #include <algorithm>
24 
25 
26 
27 
29 :
30  theAlgo_(ps.getParameter<bool>("peakFilter"),
31  ps.getParameter<std::vector<double> >("weights"),
32  ps.getParameter<int>("latency"),
33  ps.getParameter<uint32_t>("FG_threshold"),
34  ps.getParameter<std::vector<uint32_t> >("FG_HF_thresholds"),
35  ps.getParameter<uint32_t>("ZS_threshold"),
36  ps.getParameter<int>("numberOfSamples"),
37  ps.getParameter<int>("numberOfPresamples"),
38  ps.getParameter<int>("numberOfSamplesHF"),
39  ps.getParameter<int>("numberOfPresamplesHF"),
40  ps.getParameter<bool>("useTDCInMinBiasBits"),
41  ps.getParameter<uint32_t>("MinSignalThreshold"),
42  ps.getParameter<uint32_t>("PMTNoiseThreshold")
43  ),
44  inputLabel_(ps.getParameter<std::vector<edm::InputTag> >("inputLabel")),
45  inputUpgradeLabel_(ps.getParameter<std::vector<edm::InputTag> >("inputUpgradeLabel")),
46  inputTagFEDRaw_(ps.getParameter<edm::InputTag> ("InputTagFEDRaw")),
47  runZS_(ps.getParameter<bool>("RunZS")),
48  runFrontEndFormatError_(ps.getParameter<bool>("FrontEndFormatError"))
49 {
50  std::vector<bool> upgrades = {ps.getParameter<bool>("upgradeHB"), ps.getParameter<bool>("upgradeHE"), ps.getParameter<bool>("upgradeHF")};
51  upgrade_ = std::any_of(std::begin(upgrades), std::end(upgrades), [](bool a) { return a; });
52  legacy_ = std::any_of(std::begin(upgrades), std::end(upgrades), [](bool a) { return !a; });
53 
54  if (ps.exists("parameters")) {
55  auto pset = ps.getUntrackedParameter<edm::ParameterSet>("parameters");
57  }
58  theAlgo_.setUpgradeFlags(upgrades[0], upgrades[1], upgrades[2]);
59 
60  HFEMB_ = false;
61  if(ps.exists("LSConfig"))
62  {
64  HFEMB_ = LongShortCut_.getParameter<bool>("HcalFeatureHFEMBit");
65  MinLongEnergy_ = LongShortCut_.getParameter<double>("Min_Long_Energy"); //minimum long energy
66  MinShortEnergy_ = LongShortCut_.getParameter<double>("Min_Short_Energy"); //minimum short energy
67  LongShortSlope_ = LongShortCut_.getParameter<double>("Long_vrs_Short_Slope"); //slope of the line that cuts are based on
68  LongShortOffset_ = LongShortCut_.getParameter<double>("Long_Short_Offset"); //offset of line
69  }
70  // register for data access
72  tok_raw_ = consumes<FEDRawDataCollection>(inputTagFEDRaw_);
73  }
74 
75  if (legacy_) {
76  tok_hbhe_ = consumes<HBHEDigiCollection>(inputLabel_[0]);
77  tok_hf_ = consumes<HFDigiCollection>(inputLabel_[1]);
78  }
79 
80  if (upgrade_) {
81  tok_hbhe_up_ = consumes<QIE11DigiCollection>(inputUpgradeLabel_[0]);
82  tok_hf_up_ = consumes<QIE10DigiCollection>(inputUpgradeLabel_[1]);
83  }
84 
85  produces<HcalTrigPrimDigiCollection>();
86  theAlgo_.setPeakFinderAlgorithm(ps.getParameter<int>("PeakFinderAlgorithm"));
87 
88  edm::ParameterSet hfSS=ps.getParameter<edm::ParameterSet>("tpScales").getParameter<edm::ParameterSet>("HF");
89 
90  theAlgo_.setNCTScaleShift(hfSS.getParameter<int>("NCTShift"));
91  theAlgo_.setRCTScaleShift(hfSS.getParameter<int>("RCTShift"));
92 }
93 
94 
96 
97  // Step A: get the conditions, for the decoding
98  edm::ESHandle<HcalTPGCoder> inputCoder;
99  eventSetup.get<HcalTPGRecord>().get(inputCoder);
100 
101  edm::ESHandle<CaloTPGTranscoder> outTranscoder;
102  eventSetup.get<CaloTPGRecord>().get(outTranscoder);
103 
104  edm::ESHandle<HcalLutMetadata> lutMetadata;
105  eventSetup.get<HcalLutMetadataRcd>().get(lutMetadata);
106  float rctlsb = lutMetadata->getRctLsb();
107 
109  eventSetup.get<CaloGeometryRecord>().get(pG);
110 
111  // Step B: Create empty output
112  std::unique_ptr<HcalTrigPrimDigiCollection> result(new HcalTrigPrimDigiCollection());
113 
116 
119 
120  if (legacy_) {
121  iEvent.getByToken(tok_hbhe_,hbheDigis);
122  iEvent.getByToken(tok_hf_,hfDigis);
123 
124  // protect here against missing input collections
125  // there is no protection in HcalTriggerPrimitiveAlgo
126 
127  if (!hbheDigis.isValid() and legacy_) {
128  edm::LogInfo("HcalTrigPrimDigiProducer")
129  << "\nWarning: HBHEDigiCollection with input tag "
130  << inputLabel_[0]
131  << "\nrequested in configuration, but not found in the event."
132  << "\nQuit returning empty product." << std::endl;
133 
134  // put empty HcalTrigPrimDigiCollection in the event
135  iEvent.put(std::move(result));
136 
137  return;
138  }
139 
140  if (!hfDigis.isValid() and legacy_) {
141  edm::LogInfo("HcalTrigPrimDigiProducer")
142  << "\nWarning: HFDigiCollection with input tag "
143  << inputLabel_[1]
144  << "\nrequested in configuration, but not found in the event."
145  << "\nQuit returning empty product." << std::endl;
146 
147  // put empty HcalTrigPrimDigiCollection in the event
148  iEvent.put(std::move(result));
149 
150  return;
151  }
152  }
153 
154  if (upgrade_) {
155  iEvent.getByToken(tok_hbhe_up_, hbheUpDigis);
156  iEvent.getByToken(tok_hf_up_, hfUpDigis);
157 
158  if (!hbheUpDigis.isValid() and upgrade_) {
159  edm::LogInfo("HcalTrigPrimDigiProducer")
160  << "\nWarning: Upgrade HBHEDigiCollection with input tag "
161  << inputUpgradeLabel_[0]
162  << "\nrequested in configuration, but not found in the event."
163  << "\nQuit returning empty product." << std::endl;
164 
165  // put empty HcalTrigPrimDigiCollection in the event
166  iEvent.put(std::move(result));
167 
168  return;
169  }
170 
171  if (!hfUpDigis.isValid() and upgrade_) {
172  edm::LogInfo("HcalTrigPrimDigiProducer")
173  << "\nWarning: HFDigiCollection with input tag "
174  << inputUpgradeLabel_[1]
175  << "\nrequested in configuration, but not found in the event."
176  << "\nQuit returning empty product." << std::endl;
177 
178  // put empty HcalTrigPrimDigiCollection in the event
179  iEvent.put(std::move(result));
180 
181  return;
182  }
183  }
184 
185 
187  eventSetup.get<HcalDbRecord> ().get(pSetup);
188 
189  HcalFeatureBit* hfembit = nullptr;
190 
191  if(HFEMB_)
192  {
193  hfembit = new HcalFeatureHFEMBit(MinShortEnergy_, MinLongEnergy_, LongShortSlope_, LongShortOffset_, *pSetup); //inputs values that cut will be based on
194  }
195 
196  // Step C: Invoke the algorithm, passing in inputs and getting back outputs.
197  if (legacy_ and not upgrade_) {
198  theAlgo_.run(inputCoder.product(), outTranscoder->getHcalCompressor().get(), pSetup.product(),
199  *result, &(*pG), rctlsb, hfembit, *hbheDigis, *hfDigis);
200  } else if (legacy_ and upgrade_) {
201  theAlgo_.run(inputCoder.product(), outTranscoder->getHcalCompressor().get(), pSetup.product(),
202  *result, &(*pG), rctlsb, hfembit, *hbheDigis, *hfDigis, *hbheUpDigis, *hfUpDigis);
203  } else {
204  theAlgo_.run(inputCoder.product(), outTranscoder->getHcalCompressor().get(), pSetup.product(),
205  *result, &(*pG), rctlsb, hfembit, *hbheUpDigis, *hfUpDigis);
206  }
207 
208 
209  // Step C.1: Run FE Format Error / ZS for real data.
211 
212 
213  const HcalElectronicsMap *emap = pSetup->getHcalMapping();
214 
216  iEvent.getByToken(tok_raw_, fedHandle);
217 
218  if (fedHandle.isValid() && emap != nullptr) {
219  theAlgo_.runFEFormatError(fedHandle.product(), emap, *result);
220  } else {
221  edm::LogInfo("HcalTrigPrimDigiProducer")
222  << "\nWarning: FEDRawDataCollection with input tag "
223  << inputTagFEDRaw_
224  << "\nrequested in configuration, but not found in the event."
225  << "\nQuit returning empty product." << std::endl;
226 
227  // produce empty HcalTrigPrimDigiCollection and put it in the event
228  std::unique_ptr < HcalTrigPrimDigiCollection > emptyResult(
230 
231  iEvent.put(std::move(emptyResult));
232 
233  return;
234  }
235 
236  }
237 
238  if (runZS_) theAlgo_.runZS(*result);
239 
240  // edm::LogInfo("HcalTrigPrimDigiProducer") << "HcalTrigPrims: " << result->size();
241 
242  // Step D: Put outputs into event
243  iEvent.put(std::move(result));
244 }
245 
246 
T getParameter(std::string const &) const
edm::InputTag inputTagFEDRaw_
input tag for FEDRawDataCollection
T getUntrackedParameter(std::string const &, T const &) const
void produce(edm::Event &e, const edm::EventSetup &c) override
void runFEFormatError(const FEDRawDataCollection *rawraw, const HcalElectronicsMap *emap, HcalTrigPrimDigiCollection &result)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
boost::shared_ptr< const HcalTPGCompressor > getHcalCompressor() const
HcalTrigPrimDigiProducer(const edm::ParameterSet &ps)
edm::SortedCollection< HcalTriggerPrimitiveDigi > HcalTrigPrimDigiCollection
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::vector< edm::InputTag > inputUpgradeLabel_
bool exists(std::string const &parameterName) const
checks if a parameter exists
HcalTriggerPrimitiveAlgo theAlgo_
edm::EDGetTokenT< HFDigiCollection > tok_hf_
int iEvent
Definition: GenABIO.cc:224
void run(const HcalTPGCoder *incoder, const HcalTPGCompressor *outcoder, const HcalDbService *conditions, HcalTrigPrimDigiCollection &result, const HcalTrigTowerGeometry *trigTowerGeometry, float rctlsb, const HcalFeatureBit *LongvrsShortCut, const Digis &...digis)
#define end
Definition: vmac.h:39
bool isValid() const
Definition: HandleBase.h:74
void runZS(HcalTrigPrimDigiCollection &tp)
edm::EDGetTokenT< QIE10DigiCollection > tok_hf_up_
edm::EDGetTokenT< QIE11DigiCollection > tok_hbhe_up_
T const * product() const
Definition: Handle.h:74
float getRctLsb() const
#define begin
Definition: vmac.h:32
HLT enums.
double a
Definition: hdecay.h:121
T get() const
Definition: EventSetup.h:71
const HcalElectronicsMap * getHcalMapping() const
edm::EDGetTokenT< FEDRawDataCollection > tok_raw_
std::vector< edm::InputTag > inputLabel_
input tags for HCAL digis
T const * product() const
Definition: ESHandle.h:86
void setUpgradeFlags(bool hb, bool he, bool hf)
void overrideParameters(const edm::ParameterSet &ps)
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< HBHEDigiCollection > tok_hbhe_