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;
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 if(ids.size()==2) algosumvalue +=
int(samples[ibin+
i] * 0.5 *
weights_[
i]);
380 else algosumvalue +=
int(samples[ibin+i] *
weights_[i]);
382 if (algosumvalue<0) sum[ibin]=0;
385 else sum[ibin] = algosumvalue;
391 int shift = dgPresamples - tpPresamples;
392 int dgSamples=samples.
size();
397 "TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
399 tpPresamples=dgPresamples-shrink;
403 std::vector<int> finegrain(tpSamples,
false);
406 output.setPresamples(tpPresamples);
408 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
416 finegrain[ibin] = fg_algo.
compute(msb[idx]).to_ulong();
433 int shift = dgPresamples - tpPresamples;
434 int dgSamples=samples.
size();
436 if(shift<0 || shift+tpSamples>dgSamples){
438 "TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
439 tpPresamples=dgPresamples;
444 std::vector<int> finegrain(tpSamples,
false);
452 for (SumFGContainer::const_iterator sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
453 const std::vector<bool>&
veto =
HF_Veto[sumFGItr->id().rawId()];
454 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
457 bool vetoed = idx<
int(veto.size()) && veto[idx];
459 samples[
idx] += (*sumFGItr)[
idx];
466 output.setPresamples(tpPresamples);
468 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
470 output[ibin] = samples[
idx] >> hf_lumi_shift;
472 if (
output[ibin] > MAX_OUTPUT)
output[ibin] = MAX_OUTPUT;
480 const int hf_lumi_shift,
502 for (
const auto& item: it->second) {
505 const int IDX = ibin + SHIFT;
506 int long_fiber_val = 0;
507 if (IDX <
details.long_fiber.size()) {
508 long_fiber_val =
details.long_fiber[IDX];
510 int short_fiber_val = 0;
511 if (IDX <
details.short_fiber.size()) {
512 short_fiber_val =
details.short_fiber[IDX];
514 output[ibin] += (long_fiber_val + short_fiber_val);
516 uint32_t ADCLong =
details.LongDigi[ibin].adc();
517 uint32_t ADCShort =
details.ShortDigi[ibin].adc();
533 std::vector<int> finegrain_converted;
534 for (
const auto& fg: finegrain)
535 finegrain_converted.push_back(fg.to_ulong());
550 auto adc_threshold =
parameters->getADCThresholdHF();
558 if (digi[ts].
adc() < adc_threshold)
561 return (1ul << digi[ts].le_tdc()) & tdc_mask;
572 assert(hf_lumi_shift>=2);
588 for (
const auto& item: it->second) {
593 int long_fiber_val = 0;
594 int long_fiber_count = 0;
595 int short_fiber_val = 0;
596 int short_fiber_count = 0;
598 bool saturated =
false;
600 for (
auto i: {0, 2}) {
607 for (
auto i: {1, 3}) {
622 if (long_fiber_count == 2) long_fiber_val >>=1;
623 if (short_fiber_count == 2) short_fiber_val >>=1;
625 auto sum = long_fiber_val + short_fiber_val;
629 if (long_fiber_count > 0 and short_fiber_count > 0) sum >>=1;
634 for (
const auto& detail:
details) {
636 finegrain[ibin][1] = finegrain[ibin][1]
or detail.fgbit[
idx];
642 details[1].digi, details[3].digi,
643 details[0].digi, details[2].digi,
644 details[1].validity[idx], details[3].validity[idx],
645 details[0].validity[idx], details[2].validity[idx],
655 std::vector<int> finegrain_converted;
656 for (
const auto& fg: finegrain)
657 finegrain_converted.push_back(fg.to_ulong());
664 for (
int i=0;
i<tp->size(); ++
i) {
670 if (ZS) tp->setZSInfo(
false,
true);
671 else tp->setZSInfo(
true,
false);
679 std::set<uint32_t> FrontEndErrors;
683 if (raw.
size()<12)
continue;
685 if(!dccHeader)
continue;
696 for(
int fchan=0; fchan<3 && !valid; fchan++) {
697 for(
int fib=0; fib<9 && !valid; fib++) {
701 if(detId.
null())
continue;
707 for (std::vector<HcalTrigTowerDetId>::const_iterator triggerId=ids.begin(); triggerId != ids.end(); ++triggerId) {
708 FrontEndErrors.insert(triggerId->rawId());
721 if (FrontEndErrors.find(tp->id().rawId()) != FrontEndErrors.end()) {
722 for (
int i=0;
i<tp->size(); ++
i) tp->setSample(
i, zeroSample);
728 FGbitMap::iterator itr =
fgMap_.find(
id);
730 std::vector<bool>& _msb = itr->second;
731 for (
size_t i=0;
i<msb.size(); ++
i)
732 _msb[
i] = _msb[
i] || msb[
i];
759 element.resize(
bits.size());
760 it =
fgUpgradeMap_.insert(std::make_pair(
id, element)).first;
762 for (
unsigned int i = 0;
i <
bits.size(); ++
i) {
769 if (algo <=0 && algo>2)
770 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
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
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)