|
|
Go to the documentation of this file.
24 const std::vector<double>&
w,
36 uint32_t minSignalThreshold,
37 uint32_t PMT_NoiseThreshold)
54 minSignalThreshold_(minSignalThreshold),
55 PMT_NoiseThreshold_(PMT_NoiseThreshold),
58 peak_finder_algorithm_(2),
59 override_parameters_() {
95 if (
frame.id().depth() == 5)
99 assert(ids.size() == 1 || ids.size() == 2);
102 samples1.setPresamples(
frame.presamples());
105 std::vector<bool> msb;
108 if (ids.size() == 2) {
111 for (
int i = 0;
i < samples1.size(); ++
i) {
112 samples1[
i] = uint32_t(samples1[
i] * 0.5);
113 samples2[
i] = samples1[
i];
115 samples2.setPresamples(
frame.presamples());
124 if (
frame.id().depth() == 1 ||
frame.id().depth() == 2) {
126 std::vector<HcalTrigTowerDetId>::const_iterator it;
127 for (it = ids.begin(); it != ids.end(); ++it) {
140 if (trig_tower_id.
version() == 0) {
142 uint32_t fgid = (
frame.id().maskDepth());
146 theTowerMapFGSum.insert(std::pair<HcalTrigTowerDetId, SumFGContainer>(trig_tower_id, sumFG));
150 SumFGContainer::iterator sumFGItr;
151 for (sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
152 if (sumFGItr->id() == fgid) {
157 if (sumFGItr != sumFG.end()) {
168 sumFG.push_back(sumFGSamples);
173 vector<bool> vetoBits(
samples.size(),
false);
183 else if (trig_tower_id.
version() == 1) {
184 uint32_t fgid = (
frame.id().maskDepth());
187 if (
frame.id().depth() == 1) {
190 }
else if (
frame.id().depth() == 2) {
195 edm::LogWarning(
"HcalTPAlgo") <<
"Unable to figure out what to do with data frame for " <<
frame.id();
214 for (
const auto&
id : ids) {
216 edm::LogError(
"HcalTPAlgo") <<
"Encountered QIE10 data frame mapped to TP version 0:" <<
id;
220 int nsamples =
frame.samples();
237 detail.validity.resize(nsamples);
238 detail.passTDC.resize(nsamples);
240 for (
int idx = 0;
idx < nsamples; ++
idx) {
254 assert(ids.size() == 1 || ids.size() == 2);
257 samples1.setPresamples(
frame.presamples());
260 std::vector<std::bitset<2>> msb(
frame.samples(), 0);
263 if (ids.size() == 2) {
266 for (
int i = 0;
i < samples1.size(); ++
i) {
267 samples1[
i] = uint32_t(samples1[
i]);
268 samples2[
i] = samples1[
i];
270 samples2.setPresamples(
frame.presamples());
297 for (
int ibin = 0; ibin <
int(
samples.size()) - shrink; ++ibin) {
298 int algosumvalue = 0;
299 for (
unsigned int i = 0;
i <
weights_.size();
i++) {
303 if (algosumvalue < 0)
308 sum[ibin] = algosumvalue;
312 int dgPresamples =
samples.presamples();
314 int shift = dgPresamples - tpPresamples;
315 int dgSamples =
samples.size();
320 <<
"TP presample or size from the configuration file is out of the accessible range. Using digi values from "
323 tpPresamples = dgPresamples - shrink;
328 std::vector<int> finegrain(tpSamples,
false);
331 output.setPresamples(tpPresamples);
333 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
354 finegrain[ibin] = msb[
idx];
361 finegrain[ibin] = msb[
idx];
381 unsigned int dgSamples =
samples.size();
382 unsigned int dgPresamples =
samples.presamples();
392 unsigned int shift = dgPresamples - tpPresamples;
395 unsigned int shrink = filterSamples - 1;
402 for (
unsigned int ibin = 0; ibin < dgSamples - shrink; ++ibin) {
403 int algosumvalue = 0;
404 for (
unsigned int i = 0;
i < filterSamples;
i++) {
413 double segmentationFactor = 1.0;
414 if (ids.size() == 2) {
415 segmentationFactor = 0.5;
421 algosumvalue +=
int(
sample * segmentationFactor * theWeight);
423 if (algosumvalue < 0)
428 sum[ibin] = algosumvalue;
431 std::vector<int> finegrain(tpSamples,
false);
434 output.setPresamples(tpPresamples);
436 for (
unsigned int ibin = 0; ibin < tpSamples; ++ibin) {
439 int idx = ibin +
shift - filterPresamples;
456 finegrain[ibin] = fg_algo.
compute(msb[
idx]).to_ulong();
463 const int hf_lumi_shift) {
467 int dgPresamples =
samples.presamples();
469 int shift = dgPresamples - tpPresamples;
470 int dgSamples =
samples.size();
472 if (shift < 0 || shift + tpSamples > dgSamples) {
474 <<
"TP presample or size from the configuration file is out of the accessible range. Using digi values from "
476 tpPresamples = dgPresamples;
478 tpSamples = dgSamples;
481 std::vector<int> finegrain(tpSamples,
false);
489 for (SumFGContainer::const_iterator sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
490 const std::vector<bool>&
veto =
HF_Veto[sumFGItr->id().rawId()];
491 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
503 output.setPresamples(tpPresamples);
505 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
509 if (
output[ibin] > MAX_OUTPUT)
510 output[ibin] = MAX_OUTPUT;
517 const int hf_lumi_shift,
538 for (
const auto&
item : it->second) {
541 const int IDX = ibin + SHIFT;
542 int long_fiber_val = 0;
543 if (IDX <
details.long_fiber.size()) {
544 long_fiber_val =
details.long_fiber[IDX];
546 int short_fiber_val = 0;
547 if (IDX <
details.short_fiber.size()) {
548 short_fiber_val =
details.short_fiber[IDX];
550 output[ibin] += (long_fiber_val + short_fiber_val);
552 uint32_t ADCLong =
details.LongDigi[ibin].adc();
553 uint32_t ADCShort =
details.ShortDigi[ibin].adc();
558 if (embit !=
nullptr)
569 std::vector<int> finegrain_converted;
570 finegrain_converted.reserve(finegrain.size());
571 for (
const auto& fg : finegrain)
572 finegrain_converted.push_back(fg.to_ulong());
578 auto adc_threshold =
parameters->getADCThresholdHF();
586 if (digi[ts].
adc() < adc_threshold)
589 return (1ul << digi[ts].le_tdc()) & tdc_mask;
606 const int hf_lumi_shift,
612 assert(hf_lumi_shift >= 2);
628 for (
const auto&
item : it->second) {
633 int long_fiber_val = 0;
634 int long_fiber_count = 0;
635 int short_fiber_val = 0;
636 int short_fiber_count = 0;
638 bool saturated =
false;
640 for (
auto i : {0, 2}) {
647 for (
auto i : {1, 3}) {
662 if (long_fiber_count == 2)
663 long_fiber_val >>= 1;
664 if (short_fiber_count == 2)
665 short_fiber_val >>= 1;
667 auto sum = long_fiber_val + short_fiber_val;
671 if (long_fiber_count > 0 and short_fiber_count > 0)
682 finegrain[ibin][1] = finegrain[ibin][1]
or detail.fgbits[
idx][0];
686 finegrain[ibin][0] = finegrain[ibin][0]
or detail.fgbits[
idx][1];
707 std::vector<int> finegrain_converted;
708 finegrain_converted.reserve(finegrain.size());
709 for (
const auto& fg : finegrain)
710 finegrain_converted.push_back(fg.to_ulong());
717 for (
int i = 0;
i <
tp->size(); ++
i) {
724 tp->setZSInfo(
false,
true);
726 tp->setZSInfo(
true,
false);
733 std::set<uint32_t> FrontEndErrors;
753 for (
int fchan = 0; fchan < 3 && !
valid; fchan++) {
754 for (
int fib = 0; fib < 9 && !
valid; fib++) {
764 for (std::vector<HcalTrigTowerDetId>::const_iterator triggerId = ids.begin(); triggerId != ids.end();
766 FrontEndErrors.insert(triggerId->rawId());
779 if (FrontEndErrors.find(
tp->id().rawId()) != FrontEndErrors.end()) {
780 for (
int i = 0;
i <
tp->size(); ++
i)
781 tp->setSample(
i, zeroSample);
787 FGbitMap::iterator
itr =
fgMap_.find(
id);
789 std::vector<bool>& _msb =
itr->second;
790 for (
size_t i = 0;
i < msb.size(); ++
i)
791 _msb[
i] = _msb[
i] || msb[
i];
819 unsigned int aieta =
id.ietaAbs();
830 std::vector<bool> pseudo(bits.size(),
false);
839 element.resize(bits.size());
850 element.resize(bits.size());
851 it =
fgUpgradeMap_.insert(std::make_pair(
id, element)).first;
853 for (
unsigned int i = 0;
i < bits.size(); ++
i) {
854 it->second[
i][0][
depth - 1] = bits[
i][0];
855 it->second[
i][1][
depth - 1] = bits[
i][1];
861 std::vector<std::string> ietaStrs =
weightsQIE11.getParameterNames();
862 for (
auto& ietaStr : ietaStrs) {
864 auto const&
v =
weightsQIE11.getParameter<std::vector<double>>(ietaStr);
870 if (algo <= 0 || algo > 2)
871 throw cms::Exception(
"ERROR: Only algo 1 & 2 are supported.") << std::endl;
unsigned int readoutVMECrateId() const
HcalElectronicsId-style VME crate number.
void addFG(const HcalTrigTowerDetId &id, std::vector< bool > &msb)
std::vector< HcalTrigTowerDetId > towerIds(const HcalDetId &cellId) const
the mapping to and from DetIds
std::array< std::array< double, 2 >, 29 > weightsQIE11_
bool isHistogramEvent() const
Is this event a histogram event? (do not call standard unpack in this case!!!!!)
void overrideParameters(const edm::ParameterSet &ps)
uint32_t override_adc_hf_value_
constexpr int samples() const
total number of samples in the digi
void setUpgradeFlags(bool hb, bool he, bool hf)
constexpr bool linkError() const
void setWeightsQIE11(const edm::ParameterSet &weightsQIE11)
constexpr Detector det() const
get the detector field from this detid
static const int FIRST_FINEGRAIN_TOWER
void addUpgradeFG(const HcalTrigTowerDetId &id, int depth, const std::vector< std::bitset< 2 >> &bits)
const HcalDbService * conditions_
uint32_t getMask() const
get mask for channel validity and self trigger information
std::vector< HcalFinegrainBit::Tower > FGUpgradeContainer
constexpr bool null() const
is this a null id ?
void setNCTScaleShift(int)
void compress(const IntegerCaloSamples &ics, const std::vector< int > &fineGrain, HcalTriggerPrimitiveDigi &digi) const
Log< level::Info, false > LogInfo
unsigned long long override_tdc_hf_value_
unsigned int htrSlot() const
HcalElectronicsId-style HTR slot.
static const int QIE11_MAX_LINEARIZATION_ET
Log< level::Warning, false > LogWarning
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
constexpr int adc(sample_type sample)
get the ADC sample (12 bits)
void setRCTScaleShift(int)
weightsQIE11
hardware algo
static const int QIE10_MAX_LINEARIZATION_ET
static const int LAST_FINEGRAIN_TOWER
bool passTDC(const QIE10DataFrame &digi, int ts) const
void addSignal(const HBHEDataFrame &frame)
adds the signal to the map
unsigned int htrTopBottom() const
HcalElectronicsId-style HTR top/bottom (1=top/0=bottom)
int numberOfFilterPresamplesHEQIE11_
static const int QIE10_LINEARIZATION_ET
Readout chain identification for Hcal.
FGUpgradeMap fgUpgradeMap_
void runZS(HcalTrigPrimDigiCollection &tp)
int version() const
get the version code for the trigger tower
const HcalTPParameters * getHcalTPParameters() const
~HcalTriggerPrimitiveAlgo()
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
bool validUpgradeFG(const HcalTrigTowerDetId &id, int depth) const
edm::ParameterSet override_parameters_
int numberOfFilterPresamplesHBQIE11_
uint32_t minSignalThreshold_
static const int HBHE_OVERLAP_TOWER
bool exists(std::string const ¶meterName) const
checks if a parameter exists
uint32_t PMT_NoiseThreshold_
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
HFUpgradeDetailMap theHFUpgradeDetailMap
const HcalTrigTowerGeometry * theTrigTowerGeometry
std::vector< T >::iterator iterator
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, bool useTDCInMinBiasBits, uint32_t minSignalThreshold=0, uint32_t PMT_NoiseThreshold=0)
void analyzeHF(IntegerCaloSamples &samples, HcalTriggerPrimitiveDigi &result, const int hf_lumi_shift)
const HcalTopology & topology() const
constexpr HcalSubdetector subdet() const
get the subdetector
void lookupMSB(const HBHEDataFrame &df, std::vector< bool > &msb) const
numberOfFilterPresamplesHBQIE11
void analyzeHFQIE10(const IntegerCaloSamples &SAMPLES, HcalTriggerPrimitiveDigi &result, const int HF_LUMI_SHIFT, const HcalFeatureBit *HCALFEM)
bool needLegacyFG(const HcalTrigTowerDetId &id) const
bool needUpgradeID(const HcalTrigTowerDetId &id, int depth) const
static const int FIRST_DEPTH7_TOWER
HFDetailMap theHFDetailMap
std::bitset< 4 > compute(const Tower &) const
numberOfFilterPresamplesHEQIE11
Log< level::Error, false > LogError
std::vector< std::pair< float, float > >::iterator itr
bool validChannel(const QIE10DataFrame &digi, int ts) const
size_t size() const
Lenght of the data buffer in bytes.
static const int LAST_FINEGRAIN_DEPTH
int numberOfPresamplesHF_
void analyzeQIE11(IntegerCaloSamples &samples, HcalTriggerPrimitiveDigi &result, const HcalFinegrainBit &fg_algo)
int peak_finder_algorithm_
void setPeakFinderAlgorithm(int algo)
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id
static unsigned const int shift
const HcalTPGCompressor * outcoder_
void setPresamples(int pre)
set presample information
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
T getParameter(std::string const &) const
void runFEFormatError(const FEDRawDataCollection *rawraw, const HcalElectronicsMap *emap, HcalTrigPrimDigiCollection &result)
void analyze(IntegerCaloSamples &samples, HcalTriggerPrimitiveDigi &result)
adds the actual digis
constexpr int ietaAbs() const
get the absolute value of the cell ieta
TowerMapFGSum theTowerMapFGSum
bool useTDCInMinBiasBits_
std::vector< uint32_t > FG_HF_thresholds_
constexpr edm::DataFrame::id_type id() const
const HcalTPChannelParameter * getHcalTPChannelParameter(const HcalGenericDetId &fId) const
void analyzeHF2016(const IntegerCaloSamples &SAMPLES, HcalTriggerPrimitiveDigi &result, const int HF_LUMI_SHIFT, const HcalFeatureBit *HCALFEM)
unsigned int getErrorsWord() const
Get the errors word.
std::vector< IntegerCaloSamples > SumFGContainer
void adc2Linear(const HBHEDataFrame &df, IntegerCaloSamples &ics) const override
static const int QIE8_LINEARIZATION_ET
std::vector< double > weights_
const HcaluLUTTPGCoder * incoder_
bool check() const
Check for a good event Requires a minimum length, matching wordcount and length, not an empty event.