27 uint32_t minSignalThreshold, uint32_t PMT_NoiseThreshold
30 theThreshold(0), peakfind_(pf), weights_(w), latency_(latency),
31 FG_threshold_(FG_threshold), FG_HF_thresholds_(FG_HF_thresholds), ZS_threshold_(ZS_threshold),
32 numberOfSamples_(numberOfSamples),
33 numberOfPresamples_(numberOfPresamples),
34 numberOfSamplesHF_(numberOfSamplesHF),
35 numberOfPresamplesHF_(numberOfPresamplesHF),
36 useTDCInMinBiasBits_(useTDCInMinBiasBits),
37 minSignalThreshold_(minSignalThreshold),
38 PMT_NoiseThreshold_(PMT_NoiseThreshold),
39 NCTScaleShift(0), RCTScaleShift(0),
40 peak_finder_algorithm_(2),
41 override_parameters_()
87 if (frame.
id().
depth()==5)
return;
90 assert(ids.size() == 1 || ids.size() == 2);
96 std::vector<bool> msb;
102 for(
int i = 0;
i < samples1.size(); ++
i) {
103 samples1[
i] = uint32_t(samples1[
i]*0.5);
104 samples2[
i] = samples1[
i];
118 std::vector<HcalTrigTowerDetId>::const_iterator it;
119 for (it = ids.begin(); it != ids.end(); ++it) {
132 if (trig_tower_id.
version() == 0) {
138 theTowerMapFGSum.insert(std::pair<HcalTrigTowerDetId, SumFGContainer>(trig_tower_id, sumFG));
142 SumFGContainer::iterator sumFGItr;
143 for ( sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
144 if (sumFGItr->id() == fgid) {
break; }
147 if (sumFGItr != sumFG.end()) {
159 sumFG.push_back(sumFGSamples);
164 vector<bool> vetoBits(
samples.size(),
false);
174 else if (trig_tower_id.
version() == 1) {
181 }
else if (frame.
id().
depth() == 2) {
186 edm::LogWarning(
"HcalTPAlgo") <<
"Unable to figure out what to do with data frame for " << frame.
id();
206 for (
const auto&
id: ids) {
208 edm::LogError(
"HcalTPAlgo") <<
"Encountered QIE10 data frame mapped to TP version 0:" <<
id;
226 auto& detail = details[fid.depth()-1];
229 detail.validity.resize(nsamples);
230 detail.passTDC.resize(nsamples);
232 for (
int idx = 0;
idx < nsamples; ++
idx){
247 assert(ids.size() == 1 || ids.size() == 2);
253 std::vector<std::bitset<2>> msb(frame.
samples(), 0);
256 if(ids.size() == 2) {
259 for(
int i = 0;
i < samples1.size(); ++
i) {
260 samples1[
i] = uint32_t(samples1[
i]);
261 samples2[
i] = samples1[
i];
273 SumMap::iterator itr =
theSumMap.find(
id);
275 theSumMap.insert(std::make_pair(
id, samples));
279 for(
int i = 0;
i < samples.
size(); ++
i) {
280 (itr->second)[
i] += samples[
i];
288 std::vector<bool>& msb =
fgMap_[samples.
id()];
292 for(
int ibin = 0; ibin <
int(samples.
size())- shrink; ++ibin) {
293 int algosumvalue = 0;
294 for(
unsigned int i = 0;
i <
weights_.size();
i++) {
298 if (algosumvalue<0) sum[ibin]=0;
301 else sum[ibin] = algosumvalue;
307 int shift = dgPresamples - tpPresamples;
308 int dgSamples=samples.
size();
313 "TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
315 tpPresamples=dgPresamples-shrink;
320 std::vector<int> finegrain(tpSamples,
false);
323 output.setPresamples(tpPresamples);
325 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
335 isPeak = (samples[
idx] > samples[idx-1] && samples[
idx] >= samples[idx+1] && samples[
idx] >
theThreshold);
346 finegrain[ibin] = msb[
idx];
353 finegrain[ibin] = msb[
idx];
376 for(
int ibin = 0; ibin <
int(samples.
size())- shrink; ++ibin) {
377 int algosumvalue = 0;
378 for(
unsigned int i = 0;
i <
weights_.size();
i++) {
382 unsigned int sample = samples[ibin+
i];
384 if(ids.size()==2) algosumvalue +=
int(sample * 0.5 *
weights_[
i]);
387 if (algosumvalue<0) sum[ibin]=0;
390 else sum[ibin] = algosumvalue;
396 int shift = dgPresamples - tpPresamples;
397 int dgSamples=samples.
size();
402 "TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
404 tpPresamples=dgPresamples-shrink;
408 std::vector<int> finegrain(tpSamples,
false);
411 output.setPresamples(tpPresamples);
413 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
426 finegrain[ibin] = fg_algo.
compute(msb[idx]).to_ulong();
438 int shift = dgPresamples - tpPresamples;
439 int dgSamples=samples.
size();
441 if(shift<0 || shift+tpSamples>dgSamples){
443 "TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
444 tpPresamples=dgPresamples;
449 std::vector<int> finegrain(tpSamples,
false);
457 for (SumFGContainer::const_iterator sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
458 const std::vector<bool>&
veto =
HF_Veto[sumFGItr->id().rawId()];
459 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
462 bool vetoed = idx<
int(veto.size()) && veto[idx];
464 samples[
idx] += (*sumFGItr)[
idx];
471 output.setPresamples(tpPresamples);
473 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
475 output[ibin] = samples[
idx] >> hf_lumi_shift;
477 if (
output[ibin] > MAX_OUTPUT)
output[ibin] = MAX_OUTPUT;
485 const int hf_lumi_shift,
507 for (
const auto& item: it->second) {
510 const int IDX = ibin + SHIFT;
511 int long_fiber_val = 0;
512 if (IDX <
details.long_fiber.size()) {
513 long_fiber_val =
details.long_fiber[IDX];
515 int short_fiber_val = 0;
516 if (IDX <
details.short_fiber.size()) {
517 short_fiber_val =
details.short_fiber[IDX];
519 output[ibin] += (long_fiber_val + short_fiber_val);
521 uint32_t ADCLong =
details.LongDigi[ibin].adc();
522 uint32_t ADCShort =
details.ShortDigi[ibin].adc();
527 if (embit !=
nullptr)
538 std::vector<int> finegrain_converted;
539 for (
const auto& fg: finegrain)
540 finegrain_converted.push_back(fg.to_ulong());
556 if (digi[ts].
adc() < adc_threshold)
559 return (1ul << digi[ts].le_tdc()) & tdc_mask;
583 assert(hf_lumi_shift>=2);
599 for (
const auto& item: it->second) {
604 int long_fiber_val = 0;
605 int long_fiber_count = 0;
606 int short_fiber_val = 0;
607 int short_fiber_count = 0;
609 bool saturated =
false;
611 for (
auto i: {0, 2}) {
618 for (
auto i: {1, 3}) {
633 if (long_fiber_count == 2) long_fiber_val >>=1;
634 if (short_fiber_count == 2) short_fiber_val >>=1;
636 auto sum = long_fiber_val + short_fiber_val;
640 if (long_fiber_count > 0 and short_fiber_count > 0) sum >>=1;
645 for (
const auto& detail:
details) {
648 finegrain[ibin][1] = finegrain[ibin][1]
or detail.fgbits[
idx][0];
652 finegrain[ibin][0] = finegrain[ibin][0]
or detail.fgbits[
idx][1];
658 details[1].digi, details[3].digi,
659 details[0].digi, details[2].digi,
660 details[1].validity[idx], details[3].validity[idx],
661 details[0].validity[idx], details[2].validity[idx],
671 std::vector<int> finegrain_converted;
672 for (
const auto& fg: finegrain)
673 finegrain_converted.push_back(fg.to_ulong());
680 for (
int i=0;
i<tp->size(); ++
i) {
686 if (ZS) tp->setZSInfo(
false,
true);
687 else tp->setZSInfo(
true,
false);
695 std::set<uint32_t> FrontEndErrors;
699 if (raw.
size()<12)
continue;
701 if(!dccHeader)
continue;
712 for(
int fchan=0; fchan<3 && !valid; fchan++) {
713 for(
int fib=0; fib<9 && !valid; fib++) {
717 if(detId.
null())
continue;
723 for (std::vector<HcalTrigTowerDetId>::const_iterator triggerId=ids.begin(); triggerId != ids.end(); ++triggerId) {
724 FrontEndErrors.insert(triggerId->rawId());
737 if (FrontEndErrors.find(tp->id().rawId()) != FrontEndErrors.end()) {
738 for (
int i=0;
i<tp->size(); ++
i) tp->setSample(
i, zeroSample);
744 FGbitMap::iterator itr =
fgMap_.find(
id);
746 std::vector<bool>& _msb = itr->second;
747 for (
size_t i=0;
i<msb.size(); ++
i)
748 _msb[
i] = _msb[
i] || msb[
i];
781 std::vector<bool> pseudo(
bits.size(),
false);
790 element.resize(
bits.size());
791 it =
fgUpgradeMap_.insert(std::make_pair(
id, element)).first;
793 for (
unsigned int i = 0;
i <
bits.size(); ++
i) {
794 it->second[
i][0][depth-1] =
bits[
i][0];
795 it->second[
i][1][depth-1] =
bits[
i][1];
800 if (algo <=0 && algo>2)
801 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
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
thresholds 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
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