17 uint32_t FG_threshold, uint32_t ZS_threshold,
18 int numberOfSamples,
int numberOfPresamples,
19 int numberOfSamplesHF,
int numberOfPresamplesHF,
20 uint32_t minSignalThreshold, uint32_t PMT_NoiseThreshold)
21 : incoder_(0), outcoder_(0),
22 theThreshold(0), peakfind_(pf), weights_(w), latency_(latency),
23 FG_threshold_(FG_threshold), ZS_threshold_(ZS_threshold),
24 numberOfSamples_(numberOfSamples),
25 numberOfPresamples_(numberOfPresamples),
26 numberOfSamplesHF_(numberOfSamplesHF),
27 numberOfPresamplesHF_(numberOfPresamplesHF),
28 minSignalThreshold_(minSignalThreshold),
29 PMT_NoiseThreshold_(PMT_NoiseThreshold),
30 peak_finder_algorithm_(2)
68 hbheItr != hbheDigis.
end(); ++hbheItr) {
74 hfItr != hfDigis.
end(); ++hfItr) {
81 int hf_lumi_shift = 0;
82 if (0.2 <= rctlsb && rctlsb < 0.3) {
84 }
else if (0.3 <= rctlsb) {
87 for(SumMap::iterator mapItr =
theSumMap.begin(); mapItr !=
theSumMap.end(); ++mapItr) {
91 if (detId.version() == 0) {
93 }
else if (detId.version() == 1) {
118 if (frame.
id().
depth()==5)
return;
121 assert(ids.size() == 1 || ids.size() == 2);
127 std::vector<bool> msb;
130 if(ids.size() == 2) {
133 for(
int i = 0;
i < samples1.size(); ++
i) {
134 samples1[
i] = uint32_t(samples1[
i]*0.5);
135 samples2[
i] = samples1[
i];
149 std::vector<HcalTrigTowerDetId>::const_iterator it;
150 for (it = ids.begin(); it != ids.end(); ++it) {
163 if (trig_tower_id.
version() == 0) {
169 theTowerMapFGSum.insert(std::pair<HcalTrigTowerDetId, SumFGContainer>(trig_tower_id, sumFG));
173 SumFGContainer::iterator sumFGItr;
174 for ( sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
175 if (sumFGItr->id() == fgid) {
break; }
178 if (sumFGItr != sumFG.end()) {
179 for (
int i=0;
i<samples.size(); ++
i) {
180 (*sumFGItr)[
i] += samples[
i];
187 for (
int i=0;
i<samples.size(); ++
i) {
188 sumFGSamples[
i] = samples[
i];
190 sumFG.push_back(sumFGSamples);
195 vector<bool> vetoBits(samples.size(),
false);
198 for (
int i=0;
i<samples.size(); ++
i) {
205 else if (trig_tower_id.
version() == 1) {
212 }
else if (frame.
id().
depth() == 2) {
217 edm::LogWarning(
"HcalTPAlgo") <<
"Unable to figure out what to do with data frame for " << frame.
id();
232 SumMap::iterator itr =
theSumMap.find(
id);
234 theSumMap.insert(std::make_pair(
id, samples));
238 for(
int i = 0;
i < samples.
size(); ++
i) {
239 (itr->second)[
i] += samples[
i];
247 std::vector<bool>& msb =
fgMap_[samples.
id()];
251 for(
int ibin = 0; ibin < int(samples.
size())- shrink; ++ibin) {
252 int algosumvalue = 0;
253 for(
unsigned int i = 0;
i <
weights_.size();
i++) {
255 algosumvalue += int(samples[ibin+
i] *
weights_[
i]);
257 if (algosumvalue<0) sum[ibin]=0;
260 else sum[ibin] = algosumvalue;
266 int shift = dgPresamples - tpPresamples;
267 int dgSamples=samples.
size();
272 "TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
274 tpPresamples=dgPresamples-shrink;
279 std::vector<bool> finegrain(tpSamples,
false);
282 output.setPresamples(tpPresamples);
284 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
294 isPeak = (samples[
idx] > samples[idx-1] && samples[
idx] >= samples[idx+1] && samples[
idx] >
theThreshold);
304 output[ibin] = std::min<unsigned int>(sum[
idx],0x3FF);
305 finegrain[ibin] = msb[
idx];
311 output[ibin] = std::min<unsigned int>(sum[
idx],0x3FF);
312 finegrain[ibin] = msb[
idx];
317 if (samples[idx] >= 0x3FF)
331 int shift = dgPresamples - tpPresamples;
332 int dgSamples=samples.
size();
334 if(shift<0 || shift+tpSamples>dgSamples){
336 "TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
337 tpPresamples=dgPresamples;
342 std::vector<bool> finegrain(tpSamples,
false);
350 for (SumFGContainer::const_iterator sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
351 const std::vector<bool>&
veto =
HF_Veto[sumFGItr->id().rawId()];
352 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
355 bool vetoed = idx<int(veto.size()) && veto[idx];
357 samples[
idx] += (*sumFGItr)[
idx];
364 output.setPresamples(tpPresamples);
366 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
368 output[ibin] = samples[
idx] >> hf_lumi_shift;
369 static const int MAX_OUTPUT = 0x3FF;
370 if (
output[ibin] > MAX_OUTPUT)
output[ibin] = MAX_OUTPUT;
378 const int HF_LUMI_SHIFT,
400 for (
const auto& item: it->second) {
401 auto& details = item.second;
403 const int IDX = ibin + SHIFT;
404 int long_fiber_val = 0;
405 if (IDX < details.long_fiber.size()) {
406 long_fiber_val = details.long_fiber[IDX];
408 int short_fiber_val = 0;
409 if (IDX < details.short_fiber.size()) {
410 short_fiber_val = details.short_fiber[IDX];
412 output[ibin] += (long_fiber_val + short_fiber_val);
414 int ADCLong = details.LongDigi[ibin].adc();
415 int ADCShort = details.ShortDigi[ibin].adc();
418 finegrain[ibin] = (finegrain[ibin] || HCALFEM->
fineGrainbit(ADCShort, details.ShortDigi.id(), details.ShortDigi[ibin].capid(), ADCLong, details.LongDigi.id(), details.LongDigi[ibin].capid()));
424 static const unsigned int MAX_OUTPUT = 0x3FF;
434 for (
int i=0;
i<tp->size(); ++
i) {
440 if (ZS) tp->setZSInfo(
false,
true);
441 else tp->setZSInfo(
true,
false);
449 std::set<uint32_t> FrontEndErrors;
453 if (raw.
size()<12)
continue;
455 if(!dccHeader)
continue;
466 for(
int fchan=0; fchan<3 && !valid; fchan++) {
467 for(
int fib=0; fib<9 && !valid; fib++) {
471 if(detId.
null())
continue;
477 for (std::vector<HcalTrigTowerDetId>::const_iterator triggerId=ids.begin(); triggerId != ids.end(); ++triggerId) {
478 FrontEndErrors.insert(triggerId->rawId());
491 if (FrontEndErrors.find(tp->id().rawId()) != FrontEndErrors.end()) {
492 for (
int i=0;
i<tp->size(); ++
i) tp->setSample(
i, zeroSample);
498 FGbitMap::iterator itr =
fgMap_.find(
id);
500 std::vector<bool>& _msb = itr->second;
501 for (
size_t i=0;
i<msb.size(); ++
i)
502 _msb[
i] = _msb[
i] || msb[
i];
508 if (algo <=0 && algo>2)
509 throw cms::Exception(
"ERROR: Only algo 1 & 2 are supported.") << std::endl;
void analyzeHFV1(const IntegerCaloSamples &SAMPLES, HcalTriggerPrimitiveDigi &result, const int HF_LUMI_SHIFT, const HcalFeatureBit *HCALFEM)
void analyze(IntegerCaloSamples &samples, HcalTriggerPrimitiveDigi &result)
adds the actual RecHits
void runFEFormatError(const FEDRawDataCollection *rawraw, const HcalElectronicsMap *emap, HcalTrigPrimDigiCollection &result)
int presamples() const
access presample information
HcalTriggerPrimitiveAlgo(bool pf, const std::vector< double > &w, int latency, uint32_t FG_threshold, uint32_t ZS_threshold, int numberOfSamples, int numberOfPresamples, int numberOfSamplesHF, int numberOfPresamplesHF, uint32_t minSignalThreshold=0, uint32_t PMT_NoiseThreshold=0)
void analyzeHF(IntegerCaloSamples &samples, HcalTriggerPrimitiveDigi &result, const int hf_lumi_shift)
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
unsigned int htrTopBottom() const
HcalElectronicsId-style HTR top/bottom (1=top/0=bottom)
int peak_finder_algorithm_
int size() const
total number of samples in the digi
std::vector< HBHEDataFrame >::const_iterator const_iterator
void push_back(T const &t)
const HcalTPGCompressor * outcoder_
void setPresamples(int pre)
set presample information
void addFG(const HcalTrigTowerDetId &id, std::vector< bool > &msb)
IntegerCaloSamples long_fiber
uint32_t maskDepth() const
get the tower depth
size_t size() const
Lenght of the data buffer in bytes.
TowerMapFGSum theTowerMapFGSum
uint32_t minSignalThreshold_
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
void lookupMSB(const HBHEDataFrame &df, std::vector< bool > &msb) const
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
std::vector< double > weights_
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
const_iterator end() const
void setHTR(int crate, int slot, int tb)
int size() const
total number of samples in the digi
uint32_t PMT_NoiseThreshold_
virtual bool fineGrainbit(int ADCShort, HcalDetId Sid, int CapIdS, int ADCLong, HcalDetId Lid, int CapIdL) const
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
unsigned int getErrorsWord() const
Get the errors word.
int version() const
get the version code for the trigger tower
bool null() const
is this a null id ?
unsigned int readoutVMECrateId() const
HcalElectronicsId-style VME crate number.
HcalFeatureBit * LongvrsShortCut
const HcaluLUTTPGCoder * incoder_
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
HFDetailMap theHFDetailMap
static unsigned int const shift
const HcalDetId & id() const
virtual void adc2Linear(const HBHEDataFrame &df, IntegerCaloSamples &ics) const
void compress(const IntegerCaloSamples &ics, const std::vector< bool > &fineGrain, HcalTriggerPrimitiveDigi &digi) const
int presamples() const
number of samples before the sample from the triggered beam crossing (according to the hardware) ...
const HcalDetId & id() const
DetId id() const
get the (generic) id
Detector det() const
get the detector field from this detid
Readout chain identification for Hcal.
void addSignal(const HBHEDataFrame &frame)
adds the signal to the map
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
const_reference back() const
void run(const HcalTPGCoder *incoder, const HcalTPGCompressor *outcoder, const HBHEDigiCollection &hbheDigis, const HFDigiCollection &hfDigis, HcalTrigPrimDigiCollection &result, const HcalTrigTowerGeometry *trigTowerGeometry, float rctlsb, const HcalFeatureBit *LongvrsShortCut=0)
int firstHFTower(int version) const