27 uint32_t minSignalThreshold, uint32_t PMT_NoiseThreshold
29 : incoder_(0), outcoder_(0),
30 theThreshold(0), peakfind_(pf), weights_(w), latency_(latency),
31 FG_threshold_(FG_threshold), FG_HF_threshold_(FG_HF_threshold), ZS_threshold_(ZS_threshold),
32 numberOfSamples_(numberOfSamples),
33 numberOfPresamples_(numberOfPresamples),
34 numberOfSamplesHF_(numberOfSamplesHF),
35 numberOfPresamplesHF_(numberOfPresamplesHF),
36 minSignalThreshold_(minSignalThreshold),
37 PMT_NoiseThreshold_(PMT_NoiseThreshold),
38 NCTScaleShift(0), RCTScaleShift(0),
39 peak_finder_algorithm_(2),
40 override_parameters_()
86 if (frame.
id().
depth()==5)
return;
89 assert(ids.size() == 1 || ids.size() == 2);
95 std::vector<bool> msb;
101 for(
int i = 0;
i < samples1.size(); ++
i) {
102 samples1[
i] = uint32_t(samples1[
i]*0.5);
103 samples2[
i] = samples1[
i];
117 std::vector<HcalTrigTowerDetId>::const_iterator it;
118 for (it = ids.begin(); it != ids.end(); ++it) {
131 if (trig_tower_id.
version() == 0) {
137 theTowerMapFGSum.insert(std::pair<HcalTrigTowerDetId, SumFGContainer>(trig_tower_id, sumFG));
141 SumFGContainer::iterator sumFGItr;
142 for ( sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
143 if (sumFGItr->id() == fgid) {
break; }
146 if (sumFGItr != sumFG.end()) {
158 sumFG.push_back(sumFGSamples);
163 vector<bool> vetoBits(
samples.size(),
false);
173 else if (trig_tower_id.
version() == 1) {
180 }
else if (frame.
id().
depth() == 2) {
185 edm::LogWarning(
"HcalTPAlgo") <<
"Unable to figure out what to do with data frame for " << frame.
id();
201 for (
const auto&
id: ids) {
203 edm::LogError(
"HcalTPAlgo") <<
"Encountered QIE10 data frame mapped to TP version 0:" <<
id;
219 details[fid.depth() - 1].samples =
samples;
220 details[fid.depth() - 1].digi = frame;
221 details[fid.depth() - 1].validity.resize(frame.
samples());
232 assert(ids.size() == 1 || ids.size() == 2);
238 std::vector<std::bitset<2>> msb(frame.
samples(), 0);
241 if(ids.size() == 2) {
244 for(
int i = 0;
i < samples1.size(); ++
i) {
245 samples1[
i] = uint32_t(samples1[
i]*0.5);
246 samples2[
i] = samples1[
i];
258 SumMap::iterator itr =
theSumMap.find(
id);
260 theSumMap.insert(std::make_pair(
id, samples));
264 for(
int i = 0;
i < samples.
size(); ++
i) {
265 (itr->second)[
i] += samples[
i];
273 std::vector<bool>& msb =
fgMap_[samples.
id()];
277 for(
int ibin = 0; ibin <
int(samples.
size())- shrink; ++ibin) {
278 int algosumvalue = 0;
279 for(
unsigned int i = 0;
i <
weights_.size();
i++) {
283 if (algosumvalue<0) sum[ibin]=0;
286 else sum[ibin] = algosumvalue;
292 int shift = dgPresamples - tpPresamples;
293 int dgSamples=samples.
size();
298 "TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
300 tpPresamples=dgPresamples-shrink;
305 std::vector<int> finegrain(tpSamples,
false);
308 output.setPresamples(tpPresamples);
310 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
320 isPeak = (samples[
idx] > samples[idx-1] && samples[
idx] >= samples[idx+1] && samples[
idx] >
theThreshold);
331 finegrain[ibin] = msb[
idx];
338 finegrain[ibin] = msb[
idx];
359 for(
int ibin = 0; ibin <
int(samples.
size())- shrink; ++ibin) {
360 int algosumvalue = 0;
361 for(
unsigned int i = 0;
i <
weights_.size();
i++) {
365 if (algosumvalue<0) sum[ibin]=0;
368 else sum[ibin] = algosumvalue;
374 int shift = dgPresamples - tpPresamples;
375 int dgSamples=samples.
size();
380 "TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
382 tpPresamples=dgPresamples-shrink;
386 std::vector<int> finegrain(tpSamples,
false);
389 output.setPresamples(tpPresamples);
391 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
399 finegrain[ibin] = fg_algo.
compute(msb[idx]).to_ulong();
416 int shift = dgPresamples - tpPresamples;
417 int dgSamples=samples.
size();
419 if(shift<0 || shift+tpSamples>dgSamples){
421 "TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
422 tpPresamples=dgPresamples;
427 std::vector<int> finegrain(tpSamples,
false);
435 for (SumFGContainer::const_iterator sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
436 const std::vector<bool>&
veto =
HF_Veto[sumFGItr->id().rawId()];
437 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
440 bool vetoed = idx<
int(veto.size()) && veto[idx];
442 samples[
idx] += (*sumFGItr)[
idx];
449 output.setPresamples(tpPresamples);
451 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
453 output[ibin] = samples[
idx] >> hf_lumi_shift;
455 if (
output[ibin] > MAX_OUTPUT)
output[ibin] = MAX_OUTPUT;
463 const int HF_LUMI_SHIFT,
485 for (
const auto& item: it->second) {
488 const int IDX = ibin + SHIFT;
489 int long_fiber_val = 0;
490 if (IDX <
details.long_fiber.size()) {
491 long_fiber_val =
details.long_fiber[IDX];
493 int short_fiber_val = 0;
494 if (IDX <
details.short_fiber.size()) {
495 short_fiber_val =
details.short_fiber[IDX];
497 output[ibin] += (long_fiber_val + short_fiber_val);
499 uint32_t ADCLong =
details.LongDigi[ibin].adc();
500 uint32_t ADCShort =
details.ShortDigi[ibin].adc();
516 std::vector<int> finegrain_converted;
517 for (
const auto& fg: finegrain)
518 finegrain_converted.push_back(fg.to_ulong());
531 auto adc_threshold =
parameters->getADCThresholdHF();
539 if (digi[ts].
adc() < adc_threshold)
542 return (1ul << digi[ts].le_tdc()) & tdc_mask;
568 for (
const auto& item: it->second) {
573 int long_fiber_val = 0;
574 int long_fiber_count = 0;
575 int short_fiber_val = 0;
576 int short_fiber_count = 0;
578 bool saturated =
false;
580 for (
auto i: {0, 2}) {
587 for (
auto i: {1, 3}) {
604 if (long_fiber_count == 1)
606 if (short_fiber_count == 1)
607 short_fiber_val *= 2;
609 auto sum = long_fiber_val + short_fiber_val;
613 if (long_fiber_count == 0
or short_fiber_count == 0)
619 for (
const auto& detail:
details) {
627 details[1].digi, details[3].digi,
628 details[0].digi, details[2].digi,
629 details[1].validity[idx], details[3].validity[idx],
630 details[0].validity[idx], details[2].validity[idx],
640 std::vector<int> finegrain_converted;
641 for (
const auto& fg: finegrain)
642 finegrain_converted.push_back(fg.to_ulong());
649 for (
int i=0;
i<tp->size(); ++
i) {
655 if (ZS) tp->setZSInfo(
false,
true);
656 else tp->setZSInfo(
true,
false);
664 std::set<uint32_t> FrontEndErrors;
668 if (raw.
size()<12)
continue;
670 if(!dccHeader)
continue;
681 for(
int fchan=0; fchan<3 && !valid; fchan++) {
682 for(
int fib=0; fib<9 && !valid; fib++) {
686 if(detId.
null())
continue;
692 for (std::vector<HcalTrigTowerDetId>::const_iterator triggerId=ids.begin(); triggerId != ids.end(); ++triggerId) {
693 FrontEndErrors.insert(triggerId->rawId());
706 if (FrontEndErrors.find(tp->id().rawId()) != FrontEndErrors.end()) {
707 for (
int i=0;
i<tp->size(); ++
i) tp->setSample(
i, zeroSample);
713 FGbitMap::iterator itr =
fgMap_.find(
id);
715 std::vector<bool>& _msb = itr->second;
716 for (
size_t i=0;
i<msb.size(); ++
i)
717 _msb[
i] = _msb[
i] || msb[
i];
744 element.resize(
bits.size());
745 it =
fgUpgradeMap_.insert(std::make_pair(
id, element)).first;
747 for (
unsigned int i = 0;
i <
bits.size(); ++
i) {
754 if (algo <=0 && algo>2)
755 throw cms::Exception(
"ERROR: Only algo 1 & 2 are supported.") << std::endl;
int adc(sample_type sample)
get the ADC sample (12 bits)
int samples() const
total number of samples in the digi
T getParameter(std::string const &) const
void analyze(IntegerCaloSamples &samples, HcalTriggerPrimitiveDigi &result)
adds the actual RecHits
virtual void adc2Linear(const HBHEDataFrame &df, IntegerCaloSamples &ics) const override
void runFEFormatError(const FEDRawDataCollection *rawraw, const HcalElectronicsMap *emap, HcalTrigPrimDigiCollection &result)
HcalTriggerPrimitiveAlgo(bool pf, const std::vector< double > &w, int latency, uint32_t FG_threshold, uint32_t FG_HF_threshold, uint32_t ZS_threshold, int numberOfSamples, int numberOfPresamples, int numberOfSamplesHF, int numberOfPresamplesHF, uint32_t minSignalThreshold=0, uint32_t PMT_NoiseThreshold=0)
int presamples() const
access presample information
HFUpgradeDetailMap theHFUpgradeDetailMap
void analyzeHF(IntegerCaloSamples &samples, HcalTriggerPrimitiveDigi &result, const int hf_lumi_shift)
bool check() const
Check for a good event Requires a minimum length, matching wordcount and length, not an empty event...
std::vector< HcalTrigTowerDetId > towerIds(const HcalDetId &cellId) const
the mapping to and from DetIds
const HcalTPChannelParameter * getHcalTPChannelParameter(const HcalGenericDetId &fId) const
unsigned int htrTopBottom() const
HcalElectronicsId-style HTR top/bottom (1=top/0=bottom)
static const int QIE10_MAX_LINEARIZATION_ET
void analyzeHF2016(const IntegerCaloSamples &SAMPLES, HcalTriggerPrimitiveDigi &result, const int HF_LUMI_SHIFT, const HcalFeatureBit *HCALFEM)
int presamples() const
for backward compatibility
int peak_finder_algorithm_
int size() const
total number of samples in the digi
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision bits
static const int LAST_FINEGRAIN_TOWER
bool exists(std::string const ¶meterName) const
checks if a parameter exists
static const int QIE10_LINEARIZATION_ET
edm::DataFrame::id_type id() const
const HcalTPGCompressor * outcoder_
static const int LAST_FINEGRAIN_DEPTH
void setPresamples(int pre)
set presample information
void addFG(const HcalTrigTowerDetId &id, std::vector< bool > &msb)
IntegerCaloSamples long_fiber
numberOfSamples
threshold for setting fine grain bit
uint32_t maskDepth() const
get the tower depth
static const int HBHE_OVERLAP_TOWER
size_t size() const
Lenght of the data buffer in bytes.
TowerMapFGSum theTowerMapFGSum
bool validChannel(const QIE10DataFrame &digi, int ts) const
uint32_t minSignalThreshold_
static const int FIRST_FINEGRAIN_TOWER
std::vector< IntegerCaloSamples > SumFGContainer
int size() const
get the size
unsigned int htrSlot() const
HcalElectronicsId-style HTR slot.
int depth() const
get the tower depth
const HcalTrigTowerGeometry * theTrigTowerGeometry
FG_HF_threshold
threshold for setting fine grain bit
const HcalDbService * conditions_
void lookupMSB(const HBHEDataFrame &df, std::vector< bool > &msb) const
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
edm::DataFrame::id_type id() const
std::bitset< 4 > compute(const Tower &) const
std::vector< double > weights_
void compress(const IntegerCaloSamples &ics, const std::vector< int > &fineGrain, HcalTriggerPrimitiveDigi &digi) const
int numberOfPresamplesHF_
int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
int presamples() const
number of samples before the sample from the triggered beam crossing (according to the hardware) ...
IntegerCaloSamples short_fiber
void runZS(HcalTrigPrimDigiCollection &tp)
std::vector< HcalTriggerPrimitiveDigi >::iterator iterator
bin
set the eta bin as selection string.
const_iterator end() const
std::vector< HcalFinegrainBit::Tower > FGUpgradeContainer
void setHTR(int crate, int slot, int tb)
void setNCTScaleShift(int)
int size() const
total number of samples in the digi
uint32_t override_adc_hf_value_
uint32_t PMT_NoiseThreshold_
unsigned long long override_tdc_hf_value_
bool validUpgradeFG(const HcalTrigTowerDetId &id, int depth) const
unsigned int getErrorsWord() const
Get the errors word.
static const int QIE11_MAX_LINEARIZATION_ET
int version() const
get the version code for the trigger tower
bool null() const
is this a null id ?
const HcalTPParameters * getHcalTPParameters() const
ZS_threshold
threshold for setting fine grain bit
void addUpgradeFG(const HcalTrigTowerDetId &id, int depth, const std::vector< std::bitset< 2 >> &bits)
unsigned int readoutVMECrateId() const
HcalElectronicsId-style VME crate number.
int presamples() const
for backward compatibility
const HcaluLUTTPGCoder * incoder_
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
static const int QIE8_LINEARIZATION_ET
HFDetailMap theHFDetailMap
static unsigned int const shift
uint32_t FG_HF_threshold_
const HcalDetId & id() const
virtual bool fineGrainbit(const QIE10DataFrame &short1, const QIE10DataFrame &short2, const QIE10DataFrame &long1, const QIE10DataFrame &long2, bool validShort1, bool validShort2, bool validLong1, bool validLong2, int idx) const =0
int presamples() const
number of samples before the sample from the triggered beam crossing (according to the hardware) ...
const HcalDetId & id() const
void analyzeHF2017(const IntegerCaloSamples &SAMPLES, HcalTriggerPrimitiveDigi &result, const int HF_LUMI_SHIFT, const HcalFeatureBit *HCALFEM)
DetId id() const
get the (generic) id
void setRCTScaleShift(int)
Detector det() const
get the detector field from this detid
int samples() const
total number of samples in the digi
edm::ParameterSet override_parameters_
Readout chain identification for Hcal.
FGUpgradeMap fgUpgradeMap_
void addSignal(const HBHEDataFrame &frame)
adds the signal to the map
void setUpgradeFlags(bool hb, bool he, bool hf)
void overrideParameters(const edm::ParameterSet &ps)
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id
~HcalTriggerPrimitiveAlgo()
bool isHistogramEvent() const
Is this event a histogram event? (do not call standard unpack in this case!!!!!)
void setPeakFinderAlgorithm(int algo)
const_iterator begin() const
uint32_t getMask() const
get mask for channel validity and self trigger information
void analyze2017(IntegerCaloSamples &samples, HcalTriggerPrimitiveDigi &result, const HcalFinegrainBit &fg_algo)