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<uint32_t>("FG_HF_threshold"),
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<uint32_t>("MinSignalThreshold"),
41  ps.getParameter<uint32_t>("PMTNoiseThreshold")
42  ),
43  inputLabel_(ps.getParameter<std::vector<edm::InputTag> >("inputLabel")),
44  inputUpgradeLabel_(ps.getParameter<std::vector<edm::InputTag> >("inputUpgradeLabel")),
45  inputTagFEDRaw_(ps.getParameter<edm::InputTag> ("InputTagFEDRaw")),
46  runZS_(ps.getParameter<bool>("RunZS")),
47  runFrontEndFormatError_(ps.getParameter<bool>("FrontEndFormatError"))
48 {
49  std::vector<bool> upgrades = {ps.getParameter<bool>("upgradeHB"), ps.getParameter<bool>("upgradeHE"), ps.getParameter<bool>("upgradeHF")};
50  upgrade_ = std::any_of(std::begin(upgrades), std::end(upgrades), [](bool a) { return a; });
51  legacy_ = std::any_of(std::begin(upgrades), std::end(upgrades), [](bool a) { return !a; });
52 
53  if (ps.exists("parameters")) {
54  auto pset = ps.getUntrackedParameter<edm::ParameterSet>("parameters");
56  }
57  theAlgo_.setUpgradeFlags(upgrades[0], upgrades[1], upgrades[2]);
58 
59  HFEMB_ = false;
60  if(ps.exists("LSConfig"))
61  {
63  HFEMB_ = LongShortCut_.getParameter<bool>("HcalFeatureHFEMBit");
64  MinLongEnergy_ = LongShortCut_.getParameter<double>("Min_Long_Energy"); //minimum long energy
65  MinShortEnergy_ = LongShortCut_.getParameter<double>("Min_Short_Energy"); //minimum short energy
66  LongShortSlope_ = LongShortCut_.getParameter<double>("Long_vrs_Short_Slope"); //slope of the line that cuts are based on
67  LongShortOffset_ = LongShortCut_.getParameter<double>("Long_Short_Offset"); //offset of line
68  }
69  // register for data access
71  tok_raw_ = consumes<FEDRawDataCollection>(inputTagFEDRaw_);
72  }
73 
74  if (legacy_) {
75  tok_hbhe_ = consumes<HBHEDigiCollection>(inputLabel_[0]);
76  tok_hf_ = consumes<HFDigiCollection>(inputLabel_[1]);
77  }
78 
79  if (upgrade_) {
80  tok_hbhe_up_ = consumes<QIE11DigiCollection>(inputUpgradeLabel_[0]);
81  tok_hf_up_ = consumes<QIE10DigiCollection>(inputUpgradeLabel_[1]);
82  }
83 
84  produces<HcalTrigPrimDigiCollection>();
85  theAlgo_.setPeakFinderAlgorithm(ps.getParameter<int>("PeakFinderAlgorithm"));
86 
87  edm::ParameterSet hfSS=ps.getParameter<edm::ParameterSet>("HFTPScaleShift");
88 
89  theAlgo_.setNCTScaleShift(hfSS.getParameter<int>("NCT"));
90  theAlgo_.setRCTScaleShift(hfSS.getParameter<int>("RCT"));
91 }
92 
93 
95 
96  // Step A: get the conditions, for the decoding
97  edm::ESHandle<HcalTPGCoder> inputCoder;
98  eventSetup.get<HcalTPGRecord>().get(inputCoder);
99 
100  edm::ESHandle<CaloTPGTranscoder> outTranscoder;
101  eventSetup.get<CaloTPGRecord>().get(outTranscoder);
102 
103  edm::ESHandle<HcalLutMetadata> lutMetadata;
104  eventSetup.get<HcalLutMetadataRcd>().get(lutMetadata);
105  float rctlsb = lutMetadata->getRctLsb();
106 
108  eventSetup.get<CaloGeometryRecord>().get(pG);
109 
110  // Step B: Create empty output
111  std::unique_ptr<HcalTrigPrimDigiCollection> result(new HcalTrigPrimDigiCollection());
112 
115 
118 
119  if (legacy_) {
120  iEvent.getByToken(tok_hbhe_,hbheDigis);
121  iEvent.getByToken(tok_hf_,hfDigis);
122 
123  // protect here against missing input collections
124  // there is no protection in HcalTriggerPrimitiveAlgo
125 
126  if (!hbheDigis.isValid() and legacy_) {
127  edm::LogInfo("HcalTrigPrimDigiProducer")
128  << "\nWarning: HBHEDigiCollection with input tag "
129  << inputLabel_[0]
130  << "\nrequested in configuration, but not found in the event."
131  << "\nQuit returning empty product." << std::endl;
132 
133  // put empty HcalTrigPrimDigiCollection in the event
134  iEvent.put(std::move(result));
135 
136  return;
137  }
138 
139  if (!hfDigis.isValid() and legacy_) {
140  edm::LogInfo("HcalTrigPrimDigiProducer")
141  << "\nWarning: HFDigiCollection with input tag "
142  << inputLabel_[1]
143  << "\nrequested in configuration, but not found in the event."
144  << "\nQuit returning empty product." << std::endl;
145 
146  // put empty HcalTrigPrimDigiCollection in the event
147  iEvent.put(std::move(result));
148 
149  return;
150  }
151  }
152 
153  if (upgrade_) {
154  iEvent.getByToken(tok_hbhe_up_, hbheUpDigis);
155  iEvent.getByToken(tok_hf_up_, hfUpDigis);
156 
157  if (!hbheUpDigis.isValid() and upgrade_) {
158  edm::LogInfo("HcalTrigPrimDigiProducer")
159  << "\nWarning: Upgrade HBHEDigiCollection with input tag "
160  << inputUpgradeLabel_[0]
161  << "\nrequested in configuration, but not found in the event."
162  << "\nQuit returning empty product." << std::endl;
163 
164  // put empty HcalTrigPrimDigiCollection in the event
165  iEvent.put(std::move(result));
166 
167  return;
168  }
169 
170  if (!hfUpDigis.isValid() and upgrade_) {
171  edm::LogInfo("HcalTrigPrimDigiProducer")
172  << "\nWarning: HFDigiCollection with input tag "
173  << inputUpgradeLabel_[1]
174  << "\nrequested in configuration, but not found in the event."
175  << "\nQuit returning empty product." << std::endl;
176 
177  // put empty HcalTrigPrimDigiCollection in the event
178  iEvent.put(std::move(result));
179 
180  return;
181  }
182  }
183 
184 
186  eventSetup.get<HcalDbRecord> ().get(pSetup);
187 
188  HcalFeatureBit* hfembit = nullptr;
189 
190  if(HFEMB_)
191  {
192  hfembit = new HcalFeatureHFEMBit(MinShortEnergy_, MinLongEnergy_, LongShortSlope_, LongShortOffset_, *pSetup); //inputs values that cut will be based on
193  }
194 
195  // Step C: Invoke the algorithm, passing in inputs and getting back outputs.
196  if (legacy_ and not upgrade_) {
197  theAlgo_.run(inputCoder.product(), outTranscoder->getHcalCompressor().get(), pSetup.product(),
198  *result, &(*pG), rctlsb, hfembit, *hbheDigis, *hfDigis);
199  } else if (legacy_ and upgrade_) {
200  theAlgo_.run(inputCoder.product(), outTranscoder->getHcalCompressor().get(), pSetup.product(),
201  *result, &(*pG), rctlsb, hfembit, *hbheDigis, *hfDigis, *hbheUpDigis, *hfUpDigis);
202  } else {
203  theAlgo_.run(inputCoder.product(), outTranscoder->getHcalCompressor().get(), pSetup.product(),
204  *result, &(*pG), rctlsb, hfembit, *hbheUpDigis, *hfUpDigis);
205  }
206 
207 
208  // Step C.1: Run FE Format Error / ZS for real data.
210 
211 
212  const HcalElectronicsMap *emap = pSetup->getHcalMapping();
213 
215  iEvent.getByToken(tok_raw_, fedHandle);
216 
217  if (fedHandle.isValid() && emap != nullptr) {
218  theAlgo_.runFEFormatError(fedHandle.product(), emap, *result);
219  } else {
220  edm::LogInfo("HcalTrigPrimDigiProducer")
221  << "\nWarning: FEDRawDataCollection with input tag "
222  << inputTagFEDRaw_
223  << "\nrequested in configuration, but not found in the event."
224  << "\nQuit returning empty product." << std::endl;
225 
226  // produce empty HcalTrigPrimDigiCollection and put it in the event
227  std::unique_ptr < HcalTrigPrimDigiCollection > emptyResult(
229 
230  iEvent.put(std::move(emptyResult));
231 
232  return;
233  }
234 
235  }
236 
237  if (runZS_) theAlgo_.runZS(*result);
238 
239  // edm::LogInfo("HcalTrigPrimDigiProducer") << "HcalTrigPrims: " << result->size();
240 
241  // Step D: Put outputs into event
242  iEvent.put(std::move(result));
243 }
244 
245 
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:127
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:508
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:230
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:37
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:81
const T & get() const
Definition: EventSetup.h:55
float getRctLsb() const
#define begin
Definition: vmac.h:30
HLT enums.
double a
Definition: hdecay.h:121
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:510
edm::EDGetTokenT< HBHEDigiCollection > tok_hbhe_