27 uint32_t minSignalThreshold, uint32_t PMT_NoiseThreshold
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();
205 for (
const auto&
id:
ids) {
207 edm::LogError(
"HcalTPAlgo") <<
"Encountered QIE10 data frame mapped to TP version 0:" <<
id;
225 auto& detail = details[fid.depth()-1];
228 detail.validity.resize(nsamples);
230 for (
int idx = 0;
idx < nsamples; ++
idx){
244 assert(ids.size() == 1 || ids.size() == 2);
250 std::vector<std::bitset<2>> msb(frame.
samples(), 0);
253 if(ids.size() == 2) {
256 for(
int i = 0;
i < samples1.size(); ++
i) {
257 samples1[
i] = uint32_t(samples1[
i]);
258 samples2[
i] = samples1[
i];
270 SumMap::iterator itr =
theSumMap.find(
id);
272 theSumMap.insert(std::make_pair(
id, samples));
276 for(
int i = 0;
i < samples.
size(); ++
i) {
277 (itr->second)[
i] += samples[
i];
285 std::vector<bool>& msb =
fgMap_[samples.
id()];
289 for(
int ibin = 0; ibin <
int(samples.
size())- shrink; ++ibin) {
290 int algosumvalue = 0;
291 for(
unsigned int i = 0;
i <
weights_.size();
i++) {
295 if (algosumvalue<0) sum[ibin]=0;
298 else sum[ibin] = algosumvalue;
304 int shift = dgPresamples - tpPresamples;
305 int dgSamples=samples.
size();
310 "TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
312 tpPresamples=dgPresamples-shrink;
317 std::vector<int> finegrain(tpSamples,
false);
320 output.setPresamples(tpPresamples);
322 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
332 isPeak = (samples[
idx] > samples[idx-1] && samples[
idx] >= samples[idx+1] && samples[
idx] >
theThreshold);
343 finegrain[ibin] = msb[
idx];
350 finegrain[ibin] = msb[
idx];
373 for(
int ibin = 0; ibin <
int(samples.
size())- shrink; ++ibin) {
374 int algosumvalue = 0;
375 for(
unsigned int i = 0;
i <
weights_.size();
i++) {
379 unsigned int sample = samples[ibin+
i];
381 if(ids.size()==2) algosumvalue +=
int(sample * 0.5 *
weights_[
i]);
384 if (algosumvalue<0) sum[ibin]=0;
387 else sum[ibin] = algosumvalue;
393 int shift = dgPresamples - tpPresamples;
394 int dgSamples=samples.
size();
399 "TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
401 tpPresamples=dgPresamples-shrink;
405 std::vector<int> finegrain(tpSamples,
false);
408 output.setPresamples(tpPresamples);
410 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
418 finegrain[ibin] = fg_algo.
compute(msb[idx]).to_ulong();
435 int shift = dgPresamples - tpPresamples;
436 int dgSamples=samples.
size();
438 if(shift<0 || shift+tpSamples>dgSamples){
440 "TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
441 tpPresamples=dgPresamples;
446 std::vector<int> finegrain(tpSamples,
false);
454 for (SumFGContainer::const_iterator sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
455 const std::vector<bool>&
veto =
HF_Veto[sumFGItr->id().rawId()];
456 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
459 bool vetoed = idx<
int(veto.size()) && veto[idx];
461 samples[
idx] += (*sumFGItr)[
idx];
468 output.setPresamples(tpPresamples);
470 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
472 output[ibin] = samples[
idx] >> hf_lumi_shift;
474 if (
output[ibin] > MAX_OUTPUT)
output[ibin] = MAX_OUTPUT;
482 const int hf_lumi_shift,
504 for (
const auto& item: it->second) {
507 const int IDX = ibin + SHIFT;
508 int long_fiber_val = 0;
509 if (IDX <
details.long_fiber.size()) {
510 long_fiber_val =
details.long_fiber[IDX];
512 int short_fiber_val = 0;
513 if (IDX <
details.short_fiber.size()) {
514 short_fiber_val =
details.short_fiber[IDX];
516 output[ibin] += (long_fiber_val + short_fiber_val);
518 uint32_t ADCLong =
details.LongDigi[ibin].adc();
519 uint32_t ADCShort =
details.ShortDigi[ibin].adc();
524 if (embit !=
nullptr)
535 std::vector<int> finegrain_converted;
536 for (
const auto& fg: finegrain)
537 finegrain_converted.push_back(fg.to_ulong());
560 if (digi[ts].
adc() < adc_threshold)
563 return (1ul << digi[ts].le_tdc()) & tdc_mask;
574 assert(hf_lumi_shift>=2);
590 for (
const auto& item: it->second) {
595 int long_fiber_val = 0;
596 int long_fiber_count = 0;
597 int short_fiber_val = 0;
598 int short_fiber_count = 0;
600 bool saturated =
false;
602 for (
auto i: {0, 2}) {
609 for (
auto i: {1, 3}) {
624 if (long_fiber_count == 2) long_fiber_val >>=1;
625 if (short_fiber_count == 2) short_fiber_val >>=1;
627 auto sum = long_fiber_val + short_fiber_val;
631 if (long_fiber_count > 0 and short_fiber_count > 0) sum >>=1;
636 for (
const auto& detail:
details) {
638 finegrain[ibin][1] = finegrain[ibin][1]
or detail.fgbit[
idx];
642 if (embit !=
nullptr) {
644 details[1].digi, details[3].digi,
645 details[0].digi, details[2].digi,
646 details[1].validity[idx], details[3].validity[idx],
647 details[0].validity[idx], details[2].validity[idx],
657 std::vector<int> finegrain_converted;
658 for (
const auto& fg: finegrain)
659 finegrain_converted.push_back(fg.to_ulong());
666 for (
int i=0;
i<tp->size(); ++
i) {
672 if (ZS) tp->setZSInfo(
false,
true);
673 else tp->setZSInfo(
true,
false);
681 std::set<uint32_t> FrontEndErrors;
685 if (raw.
size()<12)
continue;
687 if(!dccHeader)
continue;
698 for(
int fchan=0; fchan<3 && !valid; fchan++) {
699 for(
int fib=0; fib<9 && !valid; fib++) {
703 if(detId.
null())
continue;
709 for (std::vector<HcalTrigTowerDetId>::const_iterator triggerId=ids.begin(); triggerId != ids.end(); ++triggerId) {
710 FrontEndErrors.insert(triggerId->rawId());
723 if (FrontEndErrors.find(tp->id().rawId()) != FrontEndErrors.end()) {
724 for (
int i=0;
i<tp->size(); ++
i) tp->setSample(
i, zeroSample);
730 FGbitMap::iterator itr =
fgMap_.find(
id);
732 std::vector<bool>& _msb = itr->second;
733 for (
size_t i=0;
i<msb.size(); ++
i)
734 _msb[
i] = _msb[
i] || msb[
i];
767 std::vector<bool> pseudo(
bits.size(),
false);
776 element.resize(
bits.size());
777 it =
fgUpgradeMap_.insert(std::make_pair(
id, element)).first;
779 for (
unsigned int i = 0;
i <
bits.size(); ++
i) {
786 if (algo <=0 && algo>2)
787 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
constexpr void setHTR(int crate, int slot, int tb)
T getParameter(std::string const &) const
void analyze(IntegerCaloSamples &samples, HcalTriggerPrimitiveDigi &result)
adds the actual RecHits
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)
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
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
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)
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_
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< HcalTriggerPrimitiveDigi >::iterator iterator
bin
set the eta bin as selection string.
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
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) ...
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)
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
void analyze2017(IntegerCaloSamples &samples, HcalTriggerPrimitiveDigi &result, const HcalFinegrainBit &fg_algo)
constexpr Detector det() const
get the detector field from this detid