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();
205 for (
const auto&
id: ids) {
207 edm::LogError(
"HcalTPAlgo") <<
"Encountered QIE10 data frame mapped to TP version 0:" <<
id;
223 details[fid.depth() - 1].samples =
samples;
224 details[fid.depth() - 1].digi = frame;
225 details[fid.depth() - 1].validity.resize(frame.
samples());
239 assert(ids.size() == 1 || ids.size() == 2);
245 std::vector<std::bitset<2>> msb(frame.
samples(), 0);
248 if(ids.size() == 2) {
251 for(
int i = 0;
i < samples1.size(); ++
i) {
252 samples1[
i] = uint32_t(samples1[
i]);
253 samples2[
i] = samples1[
i];
265 SumMap::iterator itr =
theSumMap.find(
id);
267 theSumMap.insert(std::make_pair(
id, samples));
271 for(
int i = 0;
i < samples.
size(); ++
i) {
272 (itr->second)[
i] += samples[
i];
280 std::vector<bool>& msb =
fgMap_[samples.
id()];
284 for(
int ibin = 0; ibin <
int(samples.
size())- shrink; ++ibin) {
285 int algosumvalue = 0;
286 for(
unsigned int i = 0;
i <
weights_.size();
i++) {
290 if (algosumvalue<0) sum[ibin]=0;
293 else sum[ibin] = algosumvalue;
299 int shift = dgPresamples - tpPresamples;
300 int dgSamples=samples.
size();
305 "TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
307 tpPresamples=dgPresamples-shrink;
312 std::vector<int> finegrain(tpSamples,
false);
315 output.setPresamples(tpPresamples);
317 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
327 isPeak = (samples[
idx] > samples[idx-1] && samples[
idx] >= samples[idx+1] && samples[
idx] >
theThreshold);
338 finegrain[ibin] = msb[
idx];
345 finegrain[ibin] = msb[
idx];
368 for(
int ibin = 0; ibin <
int(samples.
size())- shrink; ++ibin) {
369 int algosumvalue = 0;
370 for(
unsigned int i = 0;
i <
weights_.size();
i++) {
374 if(ids.size()==2) algosumvalue +=
int(samples[ibin+
i] * 0.5 *
weights_[
i]);
375 else algosumvalue +=
int(samples[ibin+i] *
weights_[i]);
377 if (algosumvalue<0) sum[ibin]=0;
380 else sum[ibin] = algosumvalue;
386 int shift = dgPresamples - tpPresamples;
387 int dgSamples=samples.
size();
392 "TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
394 tpPresamples=dgPresamples-shrink;
398 std::vector<int> finegrain(tpSamples,
false);
401 output.setPresamples(tpPresamples);
403 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
411 finegrain[ibin] = fg_algo.
compute(msb[idx]).to_ulong();
428 int shift = dgPresamples - tpPresamples;
429 int dgSamples=samples.
size();
431 if(shift<0 || shift+tpSamples>dgSamples){
433 "TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
434 tpPresamples=dgPresamples;
439 std::vector<int> finegrain(tpSamples,
false);
447 for (SumFGContainer::const_iterator sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
448 const std::vector<bool>&
veto =
HF_Veto[sumFGItr->id().rawId()];
449 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
452 bool vetoed = idx<
int(veto.size()) && veto[idx];
454 samples[
idx] += (*sumFGItr)[
idx];
461 output.setPresamples(tpPresamples);
463 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
465 output[ibin] = samples[
idx] >> hf_lumi_shift;
467 if (
output[ibin] > MAX_OUTPUT)
output[ibin] = MAX_OUTPUT;
475 const int hf_lumi_shift,
497 for (
const auto& item: it->second) {
500 const int IDX = ibin + SHIFT;
501 int long_fiber_val = 0;
502 if (IDX <
details.long_fiber.size()) {
503 long_fiber_val =
details.long_fiber[IDX];
505 int short_fiber_val = 0;
506 if (IDX <
details.short_fiber.size()) {
507 short_fiber_val =
details.short_fiber[IDX];
509 output[ibin] += (long_fiber_val + short_fiber_val);
511 uint32_t ADCLong =
details.LongDigi[ibin].adc();
512 uint32_t ADCShort =
details.ShortDigi[ibin].adc();
528 std::vector<int> finegrain_converted;
529 for (
const auto& fg: finegrain)
530 finegrain_converted.push_back(fg.to_ulong());
545 auto adc_threshold =
parameters->getADCThresholdHF();
553 if (digi[ts].
adc() < adc_threshold)
556 return (1ul << digi[ts].le_tdc()) & tdc_mask;
567 assert(hf_lumi_shift>=2);
583 for (
const auto& item: it->second) {
588 int long_fiber_val = 0;
589 int long_fiber_count = 0;
590 int short_fiber_val = 0;
591 int short_fiber_count = 0;
593 bool saturated =
false;
595 for (
auto i: {0, 2}) {
602 for (
auto i: {1, 3}) {
617 if (long_fiber_count == 2) long_fiber_val >>=1;
618 if (short_fiber_count == 2) short_fiber_val >>=1;
620 auto sum = long_fiber_val + short_fiber_val;
624 if (long_fiber_count > 0 and short_fiber_count > 0) sum >>=1;
629 for (
const auto& detail:
details) {
637 details[1].digi, details[3].digi,
638 details[0].digi, details[2].digi,
639 details[1].validity[idx], details[3].validity[idx],
640 details[0].validity[idx], details[2].validity[idx],
650 std::vector<int> finegrain_converted;
651 for (
const auto& fg: finegrain)
652 finegrain_converted.push_back(fg.to_ulong());
659 for (
int i=0;
i<tp->size(); ++
i) {
665 if (ZS) tp->setZSInfo(
false,
true);
666 else tp->setZSInfo(
true,
false);
674 std::set<uint32_t> FrontEndErrors;
678 if (raw.
size()<12)
continue;
680 if(!dccHeader)
continue;
691 for(
int fchan=0; fchan<3 && !valid; fchan++) {
692 for(
int fib=0; fib<9 && !valid; fib++) {
696 if(detId.
null())
continue;
702 for (std::vector<HcalTrigTowerDetId>::const_iterator triggerId=ids.begin(); triggerId != ids.end(); ++triggerId) {
703 FrontEndErrors.insert(triggerId->rawId());
716 if (FrontEndErrors.find(tp->id().rawId()) != FrontEndErrors.end()) {
717 for (
int i=0;
i<tp->size(); ++
i) tp->setSample(
i, zeroSample);
723 FGbitMap::iterator itr =
fgMap_.find(
id);
725 std::vector<bool>& _msb = itr->second;
726 for (
size_t i=0;
i<msb.size(); ++
i)
727 _msb[
i] = _msb[
i] || msb[
i];
754 element.resize(
bits.size());
755 it =
fgUpgradeMap_.insert(std::make_pair(
id, element)).first;
757 for (
unsigned int i = 0;
i <
bits.size(); ++
i) {
764 if (algo <=0 && algo>2)
765 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)
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)
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
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 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)