24 const std::vector<double>&
w,
35 int numberOfSamplesZDC,
36 int numberOfPresamplesZDC,
38 uint32_t minSignalThreshold,
39 uint32_t PMT_NoiseThreshold)
55 numberOfSamplesZDC_(numberOfSamplesZDC),
56 numberOfPresamplesZDC_(numberOfPresamplesZDC),
58 minSignalThreshold_(minSignalThreshold),
59 PMT_NoiseThreshold_(PMT_NoiseThreshold),
62 peak_finder_algorithm_(2),
63 override_parameters_() {
103 if (
frame.id().depth() == 5)
107 assert(ids.size() == 1 || ids.size() == 2);
110 samples1.setPresamples(
frame.presamples());
113 std::vector<bool> msb;
116 if (ids.size() == 2) {
119 for (
int i = 0;
i < samples1.size(); ++
i) {
120 samples1[
i] = uint32_t(samples1[
i] * 0.5);
121 samples2[
i] = samples1[
i];
123 samples2.setPresamples(
frame.presamples());
132 if (
frame.id().depth() == 1 ||
frame.id().depth() == 2) {
134 std::vector<HcalTrigTowerDetId>::const_iterator
it;
135 for (
it = ids.begin();
it != ids.end(); ++
it) {
148 if (trig_tower_id.
version() == 0) {
150 uint32_t fgid = (
frame.id().maskDepth());
154 theTowerMapFGSum.insert(std::pair<HcalTrigTowerDetId, SumFGContainer>(trig_tower_id, sumFG));
158 SumFGContainer::iterator sumFGItr;
159 for (sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
160 if (sumFGItr->id() == fgid) {
165 if (sumFGItr != sumFG.end()) {
176 sumFG.push_back(sumFGSamples);
181 vector<bool> vetoBits(
samples.size(),
false);
191 else if (trig_tower_id.
version() == 1) {
192 uint32_t fgid = (
frame.id().maskDepth());
195 if (
frame.id().depth() == 1) {
198 }
else if (
frame.id().depth() == 2) {
203 edm::LogWarning(
"HcalTPAlgo") <<
"Unable to figure out what to do with data frame for " <<
frame.id();
225 for (
const auto&
id : ids) {
227 edm::LogError(
"HcalTPAlgo") <<
"Encountered QIE10 data frame mapped to TP version 0:" <<
id;
230 int nsamples =
frame.samples();
247 detail.validity.resize(nsamples);
248 detail.passTDC.resize(nsamples);
250 for (
int idx = 0;
idx < nsamples; ++
idx) {
262 for (
const auto&
id : ids) {
263 int nsamples =
frame.samples();
293 assert(ids.size() == 1 || ids.size() == 2);
296 samples1.setPresamples(
frame.presamples());
299 std::vector<std::bitset<2>> msb(
frame.samples(), 0);
302 if (ids.size() == 2) {
305 for (
int i = 0;
i < samples1.size(); ++
i) {
306 samples1[
i] = uint32_t(samples1[
i]);
307 samples2[
i] = samples1[
i];
309 samples2.setPresamples(
frame.presamples());
321 SumMap::iterator itr =
theSumMap.find(
id);
334 SatMap::iterator itr_sat =
theSatMap.find(
id);
339 vector<bool> check_sat;
342 check_sat.push_back(
true);
344 check_sat.push_back(
false);
346 theSatMap.insert(std::make_pair(
id, check_sat));
350 (itr_sat->second)[
i] =
true;
362 for (
int ibin = 0; ibin <
int(
samples.size()) - shrink; ++ibin) {
363 int algosumvalue = 0;
364 for (
unsigned int i = 0;
i <
weights_.size();
i++) {
368 if (algosumvalue < 0)
373 sum[ibin] = algosumvalue;
377 int dgPresamples =
samples.presamples();
379 int shift = dgPresamples - tpPresamples;
380 int dgSamples =
samples.size();
385 <<
"TP presample or size from the configuration file is out of the accessible range. Using digi values from " 388 tpPresamples = dgPresamples - shrink;
393 std::vector<int> finegrain(tpSamples,
false);
396 output.setPresamples(tpPresamples);
398 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
419 finegrain[ibin] = msb[
idx];
426 finegrain[ibin] = msb[
idx];
439 vector<bool> sample_saturation,
445 int theIeta =
detId.ietaAbs();
447 unsigned int dgSamples =
samples.size();
448 unsigned int dgPresamples =
samples.presamples();
458 unsigned int shift = dgPresamples - tpPresamples;
461 unsigned int shrink = filterSamples - 1;
470 bool force_saturation[
samples.size()];
472 force_saturation[
i] =
false;
476 for (
unsigned int ibin = 0; ibin < dgSamples - shrink; ++ibin) {
477 int algosumvalue = 0;
478 bool check_sat =
false;
481 for (
unsigned int i = 0;
i < filterSamples;
i++) {
494 int segmentationFactor = 1;
495 if (ids.size() == 2) {
496 segmentationFactor = 2;
499 algosumvalue +=
int(
sample / segmentationFactor);
501 if (algosumvalue < 0)
506 sum[ibin] = algosumvalue;
509 force_saturation[ibin] =
true;
515 int sampleTS =
samples[ibin + 1];
516 int sampleTSminus1 =
samples[ibin];
528 int segmentationFactor = 1;
529 if (ids.size() == 2) {
530 segmentationFactor = 2;
536 algosumvalue = ((sampleTS << 8) - (sampleTSminus1 * theWeight)) / 256 / segmentationFactor;
538 if (algosumvalue < 0)
543 sum[ibin] = algosumvalue;
546 force_saturation[ibin] =
true;
550 std::vector<int> finegrain(tpSamples,
false);
553 output.setPresamples(tpPresamples);
560 unsigned int actualVetoThreshold = codedVetoThreshold;
561 bool applyVetoThreshold = codedVetoThreshold > 0 && codedVetoThreshold <= 2048;
564 if (codedVetoThreshold > 0) {
565 if (codedVetoThreshold <= 2048) {
567 if (codedVetoThreshold == 2048)
568 actualVetoThreshold = 0;
570 edm::LogWarning(
"HcalTPAlgo") <<
"Specified veto threshold value " << codedVetoThreshold
571 <<
" is not in range (1, 2048) ! Vetoing in PFA1' will not be enabled !";
575 for (
unsigned int ibin = 0; ibin < tpSamples; ++ibin) {
578 int idx = ibin +
shift - filterPresamples;
605 if (applyVetoThreshold && sum[
idx + 1] >= actualVetoThreshold &&
606 (sum[
idx] < sum[
idx + 1] || force_saturation[
idx + 1]) && !force_saturation[
idx])
621 finegrain[ibin] = fg_algo.
compute(timingTDC[
idx + filterPresamples], ids[0]).to_ulong() |
622 fg_algo.
compute(msb[
idx + filterPresamples]).to_ulong() << 4;
623 if (ibin == tpPresamples && (
idx + filterPresamples) != dgPresamples)
625 <<
"TP SOI (tpPresamples = " << tpPresamples
626 <<
") is not aligned with digi SOI (dgPresamples = " << dgPresamples <<
")";
634 unsigned int tpSamples;
635 unsigned int tpPresamples;
638 tpPresamples =
samples.presamples();
639 result.setSize(tpSamples);
640 result.setPresamples(tpPresamples);
643 output.setPresamples(tpPresamples);
651 result.setSample(
i, zdcSample);
657 const int hf_lumi_shift) {
661 int dgPresamples =
samples.presamples();
663 int shift = dgPresamples - tpPresamples;
664 int dgSamples =
samples.size();
666 if (shift < 0 || shift + tpSamples > dgSamples) {
668 <<
"TP presample or size from the configuration file is out of the accessible range. Using digi values from " 670 tpPresamples = dgPresamples;
672 tpSamples = dgSamples;
675 std::vector<int> finegrain(tpSamples,
false);
683 for (SumFGContainer::const_iterator sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
684 const std::vector<bool>&
veto =
HF_Veto[sumFGItr->id().rawId()];
685 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
697 output.setPresamples(tpPresamples);
699 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
703 if (
output[ibin] > MAX_OUTPUT)
704 output[ibin] = MAX_OUTPUT;
711 const int hf_lumi_shift,
732 for (
const auto&
item :
it->second) {
735 const int IDX = ibin + SHIFT;
736 int long_fiber_val = 0;
737 if (IDX <
details.long_fiber.size()) {
738 long_fiber_val =
details.long_fiber[IDX];
740 int short_fiber_val = 0;
741 if (IDX <
details.short_fiber.size()) {
742 short_fiber_val =
details.short_fiber[IDX];
744 output[ibin] += (long_fiber_val + short_fiber_val);
746 uint32_t ADCLong =
details.LongDigi[ibin].adc();
747 uint32_t ADCShort =
details.ShortDigi[ibin].adc();
752 if (embit !=
nullptr)
763 std::vector<int> finegrain_converted;
764 finegrain_converted.reserve(finegrain.size());
765 for (
const auto& fg : finegrain)
766 finegrain_converted.push_back(fg.to_ulong());
772 auto adc_threshold =
parameters->getADCThresholdHF();
780 if (digi[ts].
adc() < adc_threshold)
783 return (1ul << digi[ts].le_tdc()) & tdc_mask;
800 const int hf_lumi_shift,
806 assert(hf_lumi_shift >= 2);
822 for (
const auto&
item :
it->second) {
827 int long_fiber_val = 0;
828 int long_fiber_count = 0;
829 int short_fiber_val = 0;
830 int short_fiber_count = 0;
832 bool saturated =
false;
834 for (
auto i : {0, 2}) {
841 for (
auto i : {1, 3}) {
856 if (long_fiber_count == 2)
857 long_fiber_val >>= 1;
858 if (short_fiber_count == 2)
859 short_fiber_val >>= 1;
861 auto sum = long_fiber_val + short_fiber_val;
865 if (long_fiber_count > 0 and short_fiber_count > 0)
876 finegrain[ibin][1] = finegrain[ibin][1]
or detail.fgbits[
idx][0];
880 finegrain[ibin][0] = finegrain[ibin][0]
or detail.fgbits[
idx][1];
901 std::vector<int> finegrain_converted;
902 finegrain_converted.reserve(finegrain.size());
903 for (
const auto& fg : finegrain)
904 finegrain_converted.push_back(fg.to_ulong());
911 for (
int i = 0;
i <
tp->size(); ++
i) {
918 tp->setZSInfo(
false,
true);
920 tp->setZSInfo(
true,
false);
927 std::set<uint32_t> FrontEndErrors;
947 for (
int fchan = 0; fchan < 3 && !
valid; fchan++) {
948 for (
int fib = 0; fib < 9 && !
valid; fib++) {
958 for (std::vector<HcalTrigTowerDetId>::const_iterator triggerId = ids.begin(); triggerId != ids.end();
960 FrontEndErrors.insert(triggerId->rawId());
973 if (FrontEndErrors.find(
tp->id().rawId()) != FrontEndErrors.end()) {
974 for (
int i = 0;
i <
tp->size(); ++
i)
975 tp->setSample(
i, zeroSample);
981 FGbitMap::iterator itr =
fgMap_.find(
id);
982 if (itr !=
fgMap_.end()) {
983 std::vector<bool>& _msb = itr->second;
984 for (
size_t i = 0;
i < msb.size(); ++
i)
985 _msb[
i] = _msb[
i] || msb[
i];
1013 unsigned int aieta =
id.ietaAbs();
1024 std::vector<bool> pseudo(
bits.size(),
false);
1033 element.resize(
bits.size());
1044 element.resize(
bits.size());
1047 for (
unsigned int i = 0;
i <
bits.size(); ++
i) {
1059 assert(ids.size() == 1 || ids.size() == 2);
1061 samples1.setPresamples(
frame.presamples());
1065 bool is_compressed =
false;
1067 is_compressed = (
frame.flavor() == 3);
1074 element.resize(
frame.samples());
1077 for (
int i = 0;
i <
frame.samples();
i++) {
1079 std::make_pair(std::make_pair(bits12_15[
i], is_compressed), std::make_pair(
frame[
i].tdc(), samples1[
i]));
1085 std::vector<std::string> ietaStrs =
weightsQIE11.getParameterNames();
1086 for (
auto& ietaStr : ietaStrs) {
1088 auto const&
v =
weightsQIE11.getParameter<std::vector<int>>(ietaStr);
1102 for (
auto& ietaStr : ietaStrs) {
1115 if (algo <= 0 || algo > 2)
1116 throw cms::Exception(
"ERROR: Only algo 1 & 2 are supported.") << std::endl;
bool validUpgradeFG(const HcalTrigTowerDetId &id, int depth) const
void addUpgradeTDCFG(const HcalTrigTowerDetId &id, const QIE11DataFrame &frame)
void analyze(IntegerCaloSamples &samples, HcalTriggerPrimitiveDigi &result)
adds the actual digis
bool isHistogramEvent() const
Is this event a histogram event? (do not call standard unpack in this case!!!!!)
void runFEFormatError(const FEDRawDataCollection *rawraw, const HcalElectronicsMap *emap, HcalTrigPrimDigiCollection &result)
T getParameter(std::string const &) const
std::vector< uint32_t > FG_HF_thresholds_
HFUpgradeDetailMap theHFUpgradeDetailMap
constexpr edm::DataFrame::id_type id() const
void analyzeHF(IntegerCaloSamples &samples, HcalTriggerPrimitiveDigi &result, const int hf_lumi_shift)
bool useTDCInMinBiasBits_
static const int QIE10_MAX_LINEARIZATION_ET
uint32_t getMask() const
get mask for channel validity and self trigger information
void analyzeHF2016(const IntegerCaloSamples &SAMPLES, HcalTriggerPrimitiveDigi &result, const int HF_LUMI_SHIFT, const HcalFeatureBit *HCALFEM)
static const int FIRST_DEPTH7_TOWER
int peak_finder_algorithm_
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void analyzeHFQIE10(const IntegerCaloSamples &SAMPLES, HcalTriggerPrimitiveDigi &result, const int HF_LUMI_SHIFT, const HcalFeatureBit *HCALFEM)
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id
static const int LAST_FINEGRAIN_TOWER
bool needLegacyFG(const HcalTrigTowerDetId &id) const
static const int QIE10_LINEARIZATION_ET
const HcalTPGCompressor * outcoder_
size_t size() const
Lenght of the data buffer in bytes.
static const int LAST_FINEGRAIN_DEPTH
void lookupMSB(const HBHEDataFrame &df, std::vector< bool > &msb) const
void setPresamples(int pre)
set presample information
void addFG(const HcalTrigTowerDetId &id, std::vector< bool > &msb)
std::vector< unsigned short > group0FGbits(const QIE11DataFrame &df) const
Log< level::Error, false > LogError
void setCodedVetoThresholds(const edm::ParameterSet &codedVetoThresholds)
static const int QIE10_ZDC_MAX_LINEARIZATION_ET
static const int HBHE_OVERLAP_TOWER
std::array< std::array< int, 2 >, 29 > weightsQIE11_
int numberOfPresamplesZDC_
numberOfFilterPresamplesHEQIE11
TowerMapFGSum theTowerMapFGSum
const HcalTopology & topology() const
uint32_t minSignalThreshold_
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t ietaAbs(uint32_t id)
static const int FIRST_FINEGRAIN_TOWER
std::vector< IntegerCaloSamples > SumFGContainer
std::array< int, 29 > codedVetoThresholds_
void compress(const IntegerCaloSamples &ics, const std::vector< int > &fineGrain, HcalTriggerPrimitiveDigi &digi) const
const HcalTrigTowerGeometry * theTrigTowerGeometry
const HcalDbService * conditions_
weightsQIE11
hardware algo
unsigned int htrSlot() const
HcalElectronicsId-style HTR slot.
unsigned int htrTopBottom() const
HcalElectronicsId-style HTR top/bottom (1=top/0=bottom)
numberOfFilterPresamplesHBQIE11
static const int QIE11_LINEARIZATION_ET
void setWeightQIE11(int aieta, int weight)
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
bool needUpgradeID(const HcalTrigTowerDetId &id, int depth) const
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 numberOfFilterPresamplesHBQIE11, int numberOfFilterPresamplesHEQIE11, int numberOfSamplesHF, int numberOfPresamplesHF, int numberOfSamplesZDC, int numberOfPresamplesZDC, bool useTDCInMinBiasBits, uint32_t minSignalThreshold=0, uint32_t PMT_NoiseThreshold=0)
std::vector< double > weights_
const HcalTPChannelParameter * getHcalTPChannelParameter(const HcalGenericDetId &fId, bool throwOnFail=true) const
int numberOfPresamplesHF_
const HcalTPParameters * getHcalTPParameters() const
void setCodedVetoThreshold(int aieta, int codedVetoThreshold)
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
void runZS(HcalTrigPrimDigiCollection &tp)
std::vector< T >::iterator iterator
constexpr bool linkError() const
void analyzeQIE11(IntegerCaloSamples &samples, std::vector< bool > sample_saturation, HcalTriggerPrimitiveDigi &result, const HcalFinegrainBit &fg_algo)
Log< level::Info, false > LogInfo
std::vector< HcalFinegrainBit::TowerTDC > FGUpgradeTDCContainer
std::vector< HcalFinegrainBit::Tower > FGUpgradeContainer
std::bitset< 2 > compute(const Tower &) const
void setNCTScaleShift(int)
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
uint32_t override_adc_hf_value_
uint32_t PMT_NoiseThreshold_
unsigned long long override_tdc_hf_value_
static const int QIE11_MAX_LINEARIZATION_ET
void adc2Linear(const HBHEDataFrame &df, IntegerCaloSamples &ics) const override
void addUpgradeFG(const HcalTrigTowerDetId &id, int depth, const std::vector< std::bitset< 2 >> &bits)
FGUpgradeTDCMap fgUpgradeTDCMap_
const HcaluLUTTPGCoder * incoder_
unsigned int getErrorsWord() const
Get the errors word.
static const int QIE8_LINEARIZATION_ET
HFDetailMap theHFDetailMap
static unsigned int const shift
bool passTDC(const QIE10DataFrame &digi, int ts) const
codedVetoThresholds
threshold for setting TP zero suppression
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
static constexpr int32_t SubdetectorId
unsigned int readoutVMECrateId() const
HcalElectronicsId-style VME crate number.
bool validChannel(const QIE10DataFrame &digi, int ts) const
Log< level::Warning, false > LogWarning
int version() const
get the version code for the trigger tower
void setRCTScaleShift(int)
void analyzeZDC(IntegerCaloSamples &samples, HcalTriggerPrimitiveDigi &result)
int numberOfFilterPresamplesHEQIE11_
edm::ParameterSet override_parameters_
Readout chain identification for Hcal.
FGUpgradeMap fgUpgradeMap_
void addSignal(const HBHEDataFrame &frame)
adds the signal to the map
std::vector< HcalTrigTowerDetId > towerIds(const HcalDetId &cellId) const
the mapping to and from DetIds
void setUpgradeFlags(bool hb, bool he, bool hf)
void overrideParameters(const edm::ParameterSet &ps)
bool check() const
Check for a good event Requires a minimum length, matching wordcount and length, not an empty event...
void setWeightsQIE11(const edm::ParameterSet &weightsQIE11)
~HcalTriggerPrimitiveAlgo()
constexpr int samples() const
total number of samples in the digi
void setPeakFinderAlgorithm(int algo)
uint16_t *__restrict__ uint16_t const *__restrict__ adc
void setFixSaturationFlag(bool fix_saturation)
std::vector< HcalTrigTowerDetId > towerIds_ZDC(const HcalZDCDetId &cellId) const
int numberOfFilterPresamplesHBQIE11_