24 const std::vector<double>&
w,
34 uint32_t minSignalThreshold,
35 uint32_t PMT_NoiseThreshold)
42 FG_threshold_(FG_threshold),
43 FG_HF_thresholds_(FG_HF_thresholds),
44 ZS_threshold_(ZS_threshold),
45 numberOfSamples_(numberOfSamples),
46 numberOfPresamples_(numberOfPresamples),
47 numberOfSamplesHF_(numberOfSamplesHF),
48 numberOfPresamplesHF_(numberOfPresamplesHF),
49 useTDCInMinBiasBits_(useTDCInMinBiasBits),
50 minSignalThreshold_(minSignalThreshold),
51 PMT_NoiseThreshold_(PMT_NoiseThreshold),
54 peak_finder_algorithm_(2),
55 override_parameters_() {
95 assert(ids.size() == 1 || ids.size() == 2);
101 std::vector<bool> msb;
104 if (ids.size() == 2) {
107 for (
int i = 0;
i < samples1.size(); ++
i) {
108 samples1[
i] = uint32_t(samples1[
i] * 0.5);
109 samples2[
i] = samples1[
i];
122 std::vector<HcalTrigTowerDetId>::const_iterator it;
123 for (it = ids.begin(); it != ids.end(); ++it) {
136 if (trig_tower_id.
version() == 0) {
142 theTowerMapFGSum.insert(std::pair<HcalTrigTowerDetId, SumFGContainer>(trig_tower_id, sumFG));
146 SumFGContainer::iterator sumFGItr;
147 for (sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
148 if (sumFGItr->id() == fgid) {
153 if (sumFGItr != sumFG.end()) {
164 sumFG.push_back(sumFGSamples);
169 vector<bool> vetoBits(
samples.size(),
false);
179 else if (trig_tower_id.
version() == 1) {
186 }
else if (frame.
id().
depth() == 2) {
191 edm::LogWarning(
"HcalTPAlgo") <<
"Unable to figure out what to do with data frame for " << frame.
id();
210 for (
const auto&
id :
ids) {
212 edm::LogError(
"HcalTPAlgo") <<
"Encountered QIE10 data frame mapped to TP version 0:" <<
id;
216 int nsamples = frame.
samples();
230 auto& detail = details[fid.depth() - 1];
233 detail.validity.resize(nsamples);
234 detail.passTDC.resize(nsamples);
236 for (
int idx = 0;
idx < nsamples; ++
idx) {
250 assert(ids.size() == 1 || ids.size() == 2);
256 std::vector<std::bitset<2>> msb(frame.
samples(), 0);
259 if (ids.size() == 2) {
262 for (
int i = 0;
i < samples1.size(); ++
i) {
263 samples1[
i] = uint32_t(samples1[
i]);
264 samples2[
i] = samples1[
i];
276 SumMap::iterator itr =
theSumMap.find(
id);
278 theSumMap.insert(std::make_pair(
id, samples));
281 for (
int i = 0;
i < samples.
size(); ++
i) {
282 (itr->second)[
i] += samples[
i];
289 std::vector<bool>& msb =
fgMap_[samples.
id()];
293 for (
int ibin = 0; ibin <
int(samples.
size()) - shrink; ++ibin) {
294 int algosumvalue = 0;
295 for (
unsigned int i = 0;
i <
weights_.size();
i++) {
299 if (algosumvalue < 0)
304 sum[ibin] = algosumvalue;
310 int shift = dgPresamples - tpPresamples;
311 int dgSamples = samples.
size();
316 <<
"TP presample or size from the configuration file is out of the accessible range. Using digi values from " 319 tpPresamples = dgPresamples - shrink;
324 std::vector<int> finegrain(tpSamples,
false);
327 output.setPresamples(tpPresamples);
329 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
339 isPeak = (samples[
idx] > samples[idx - 1] && samples[
idx] >= samples[idx + 1] && samples[
idx] >
theThreshold);
350 finegrain[ibin] = msb[
idx];
357 finegrain[ibin] = msb[
idx];
379 for (
int ibin = 0; ibin <
int(samples.
size()) - shrink; ++ibin) {
380 int algosumvalue = 0;
381 for (
unsigned int i = 0;
i <
weights_.size();
i++) {
385 unsigned int sample = samples[ibin +
i];
389 algosumvalue +=
int(sample * 0.5 *
weights_[
i]);
393 if (algosumvalue < 0)
398 sum[ibin] = algosumvalue;
404 int shift = dgPresamples - tpPresamples;
405 int dgSamples = samples.
size();
409 edm::LogInfo(
"HcalTriggerPrimitiveAlgo::analyze") <<
"TP presample or size from the configuration file is out of " 410 "the accessible range. Using digi values from data instead...";
412 tpPresamples = dgPresamples - shrink;
416 std::vector<int> finegrain(tpSamples,
false);
419 output.setPresamples(tpPresamples);
421 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
434 finegrain[ibin] = fg_algo.
compute(msb[idx]).to_ulong();
441 const int hf_lumi_shift) {
447 int shift = dgPresamples - tpPresamples;
448 int dgSamples = samples.
size();
450 if (shift < 0 || shift + tpSamples > dgSamples) {
452 <<
"TP presample or size from the configuration file is out of the accessible range. Using digi values from " 454 tpPresamples = dgPresamples;
456 tpSamples = dgSamples;
459 std::vector<int> finegrain(tpSamples,
false);
467 for (SumFGContainer::const_iterator sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
468 const std::vector<bool>&
veto =
HF_Veto[sumFGItr->id().rawId()];
469 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
472 bool vetoed = idx <
int(veto.size()) && veto[idx];
474 samples[
idx] += (*sumFGItr)[
idx];
481 output.setPresamples(tpPresamples);
483 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
485 output[ibin] = samples[
idx] >> hf_lumi_shift;
487 if (
output[ibin] > MAX_OUTPUT)
488 output[ibin] = MAX_OUTPUT;
495 const int hf_lumi_shift,
516 for (
const auto&
item : it->second) {
519 const int IDX = ibin + SHIFT;
520 int long_fiber_val = 0;
521 if (IDX <
details.long_fiber.size()) {
522 long_fiber_val =
details.long_fiber[IDX];
524 int short_fiber_val = 0;
525 if (IDX <
details.short_fiber.size()) {
526 short_fiber_val =
details.short_fiber[IDX];
528 output[ibin] += (long_fiber_val + short_fiber_val);
530 uint32_t ADCLong =
details.LongDigi[ibin].adc();
531 uint32_t ADCShort =
details.ShortDigi[ibin].adc();
536 if (embit !=
nullptr)
547 std::vector<int> finegrain_converted;
548 for (
const auto& fg : finegrain)
549 finegrain_converted.push_back(fg.to_ulong());
563 if (digi[ts].
adc() < adc_threshold)
566 return (1ul << digi[ts].le_tdc()) & tdc_mask;
583 const int hf_lumi_shift,
589 assert(hf_lumi_shift >= 2);
605 for (
const auto&
item : it->second) {
610 int long_fiber_val = 0;
611 int long_fiber_count = 0;
612 int short_fiber_val = 0;
613 int short_fiber_count = 0;
615 bool saturated =
false;
617 for (
auto i : {0, 2}) {
624 for (
auto i : {1, 3}) {
639 if (long_fiber_count == 2)
640 long_fiber_val >>= 1;
641 if (short_fiber_count == 2)
642 short_fiber_val >>= 1;
644 auto sum = long_fiber_val + short_fiber_val;
648 if (long_fiber_count > 0 and short_fiber_count > 0)
654 for (
const auto& detail :
details) {
655 if (idx <
int(detail.digi.size()) and detail.validity[idx] and
659 finegrain[ibin][1] = finegrain[ibin][1]
or detail.fgbits[
idx][0];
663 finegrain[ibin][0] = finegrain[ibin][0]
or detail.fgbits[
idx][1];
668 finegrain[ibin][0] = embit->
fineGrainbit(details[1].digi,
672 details[1].validity[idx],
673 details[3].validity[idx],
674 details[0].validity[idx],
675 details[2].validity[idx],
684 std::vector<int> finegrain_converted;
685 for (
const auto& fg : finegrain)
686 finegrain_converted.push_back(fg.to_ulong());
693 for (
int i = 0;
i < tp->size(); ++
i) {
700 tp->setZSInfo(
false,
true);
702 tp->setZSInfo(
true,
false);
709 std::set<uint32_t> FrontEndErrors;
729 for (
int fchan = 0; fchan < 3 && !
valid; fchan++) {
730 for (
int fib = 0; fib < 9 && !
valid; fib++) {
740 for (std::vector<HcalTrigTowerDetId>::const_iterator triggerId = ids.begin(); triggerId != ids.end();
742 FrontEndErrors.insert(triggerId->rawId());
755 if (FrontEndErrors.find(tp->id().rawId()) != FrontEndErrors.end()) {
756 for (
int i = 0;
i < tp->size(); ++
i)
757 tp->setSample(
i, zeroSample);
763 FGbitMap::iterator itr =
fgMap_.find(
id);
764 if (itr !=
fgMap_.end()) {
765 std::vector<bool>& _msb = itr->second;
766 for (
size_t i = 0;
i < msb.size(); ++
i)
767 _msb[
i] = _msb[
i] || msb[
i];
793 const std::vector<std::bitset<2>>&
bits) {
796 std::vector<bool> pseudo(
bits.size(),
false);
805 element.resize(
bits.size());
806 it =
fgUpgradeMap_.insert(std::make_pair(
id, element)).first;
808 for (
unsigned int i = 0;
i <
bits.size(); ++
i) {
809 it->second[
i][0][depth - 1] =
bits[
i][0];
810 it->second[
i][1][depth - 1] =
bits[
i][1];
815 if (algo <= 0 && algo > 2)
816 throw cms::Exception(
"ERROR: Only algo 1 & 2 are supported.") << std::endl;
int samples() const
total number of samples in the digi
constexpr void setHTR(int crate, int slot, int tb)
T getParameter(std::string const &) const
void analyze(IntegerCaloSamples &samples, HcalTriggerPrimitiveDigi &result)
adds the actual digis
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, const std::vector< uint32_t > &FG_HF_thresholds, uint32_t ZS_threshold, int numberOfSamples, int numberOfPresamples, int numberOfSamplesHF, int numberOfPresamplesHF, bool useTDCInMinBiasBits, uint32_t minSignalThreshold=0, uint32_t PMT_NoiseThreshold=0)
int presamples() const
access presample information
std::vector< uint32_t > FG_HF_thresholds_
HFUpgradeDetailMap theHFUpgradeDetailMap
bool passTDC(const QIE10DataFrame &digi, int ts) const
void analyzeHF(IntegerCaloSamples &samples, HcalTriggerPrimitiveDigi &result, const int hf_lumi_shift)
HcalSubdetector subdet() const
get the subdetector
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
bool useTDCInMinBiasBits_
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)
constexpr bool null() const
is this a null id ?
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
void analyzeHFQIE10(const IntegerCaloSamples &SAMPLES, HcalTriggerPrimitiveDigi &result, const int HF_LUMI_SHIFT, const HcalFeatureBit *HCALFEM)
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)
void analyzeQIE11(IntegerCaloSamples &samples, HcalTriggerPrimitiveDigi &result, const HcalFinegrainBit &fg_algo)
bool needLegacyFG(const HcalTrigTowerDetId &id) const
IntegerCaloSamples long_fiber
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
const HcalDbService * conditions_
void lookupMSB(const HBHEDataFrame &df, std::vector< bool > &msb) const
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
HcalDetId const & id() const
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
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
edm::DataFrame::id_type id() const
DetId detid() const
Get the detector id.
std::bitset< 4 > compute(const Tower &) const
std::vector< double > weights_
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
void compress(const IntegerCaloSamples &ics, const std::vector< int > &fineGrain, HcalTriggerPrimitiveDigi &digi) const
int numberOfPresamplesHF_
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< T >::iterator iterator
const_iterator end() const
std::vector< HcalFinegrainBit::Tower > FGUpgradeContainer
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
const HcalTPParameters * getHcalTPParameters() const
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
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) ...
DetId id() const
get the (generic) id
void setRCTScaleShift(int)
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
int getADCThresholdHF() const
get ADC threshold fof TDC mask of HF
~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
constexpr Detector det() const
get the detector field from this detid