16 uint32_t FG_threshold1, uint32_t FG_threshold2, uint32_t ZS_threshold,
17 int numberOfSamples,
int numberOfPresamples,
18 int numberOfSamplesHF,
int numberOfPresamplesHF,
19 uint32_t minSignalThreshold, uint32_t PMT_NoiseThreshold)
20 : incoder_(0), outcoder_(0),
21 theThreshold(0), peakfind_(pf), weights_(w), latency_(latency),
22 FG_threshold1_(FG_threshold1), FG_threshold2_(FG_threshold2), ZS_threshold_(ZS_threshold),
23 numberOfSamples_(numberOfSamples),
24 numberOfPresamples_(numberOfPresamples),
25 numberOfSamplesHF_(numberOfSamplesHF),
26 numberOfPresamplesHF_(numberOfPresamplesHF),
27 minSignalThreshold_(minSignalThreshold),
28 PMT_NoiseThreshold_(PMT_NoiseThreshold),
29 peak_finder_algorithm_(2)
50 if (eta == 29 || eta == 30 || eta == 31)
54 else if (eta == 32 || eta == 33 || eta == 34)
58 else if (eta == 35 || eta == 36 || eta == 37)
62 else if (eta == 38 || eta == 39 || eta == 40 || eta == 41)
66 else if (eta == -29 || eta == -30 || eta == -31)
70 else if (eta == -32 || eta == -33 || eta == -34)
74 else if (eta == -35 || eta == -36 || eta == -37)
78 else if (eta == -38 || eta == -39 || eta == -40 || eta == -41)
90 if (phi == 1 || phi == 71)
94 else if (phi == 3 || phi == 5)
98 else if (phi == 7 || phi == 9)
102 else if (phi == 11 || phi == 13)
106 else if (phi == 15 || phi == 17)
110 else if (phi == 19 || phi == 21)
114 else if (phi == 23 || phi == 25)
118 else if (phi == 27 || phi == 29)
122 else if (phi == 31 || phi == 33)
126 else if (phi == 35 || phi == 37)
130 else if (phi == 39 || phi == 41)
134 else if (phi == 43 || phi == 45)
138 else if (phi == 47 || phi == 49)
142 else if (phi == 51 || phi == 53)
146 else if (phi == 55 || phi == 57)
150 else if (phi == 59 || phi == 61)
154 else if (phi == 63 || phi == 65)
158 else if (phi == 67 || phi == 69)
332 else if (phiTPG == 5 )
336 else if (phiTPG == 9)
340 else if (phiTPG == 13)
344 else if (phiTPG == 17)
348 else if (phiTPG == 21)
352 else if (phiTPG == 25)
356 else if (phiTPG == 29)
360 else if (phiTPG == 33)
364 else if (phiTPG == 37)
368 else if (phiTPG == 41)
372 else if (phiTPG == 45)
376 else if (phiTPG == 49)
380 else if (phiTPG == 53)
384 else if (phiTPG == 57)
388 else if (phiTPG == 61)
392 else if (phiTPG == 65)
396 else if (phiTPG == 69)
421 hbheItr != hbheDigis.
end(); ++hbheItr) {
427 hfItr != hfDigis.
end(); ++hfItr) {
436 int fiberQIEThresh[phiBin][etaBin][thresholds];
439 for (
int i = 0;
i < phiBin;
i++)
441 for (
int j = 0;
j < etaBin;
j++)
444 for (
int k = 0;
k < thresholds;
k++)
446 fiberQIEThresh[
i][
j][
k] = 0;
455 int ieta = hcalid.
ieta();
456 int iphi = hcalid.
iphi();
457 int presample = hfdigi->presamples();
459 double qieval = hfdigi->sample(presample).adc();
466 fiberQIEThresh[GCTphi][GCTeta][0]++;
470 fiberQIEThresh[GCTphi][GCTeta][1]++;
475 for (
int i = 0;
i < phiBin;
i++)
477 for (
int j = 0;
j < etaBin;
j++)
479 if (fiberQIEThresh[
i][
j][0] > 0 &&
j < 4)
484 if (fiberQIEThresh[
i][
j][0] > 0 &&
j > 17)
489 if (fiberQIEThresh[
i][
j][1] > 0 &&
j < 4)
494 if (fiberQIEThresh[
i][
j][1] > 0 &&
j > 17)
503 for(SumMap::iterator mapItr =
theSumMap.begin(); mapItr !=
theSumMap.end(); ++mapItr) {
508 int ietaTow = detId.
ieta();
509 int iphiTow = detId.iphi();
510 analyzeHF(ietaTow, iphiTow, FGBit, mapItr->second, result.
back(), rctlsb);
520 if (frame.
id().
depth()==5)
return;
523 assert(ids.size() == 1 || ids.size() == 2);
529 std::vector<bool> msb;
532 if(ids.size() == 2) {
535 for(
int i = 0;
i < samples1.size(); ++
i) {
536 samples1[
i] = uint32_t(samples1[
i]*0.5);
537 samples2[
i] = samples1[
i];
568 theTowerMapFGSum.insert(std::pair<HcalTrigTowerDetId, SumFGContainer >(ids[0], sumFG));
572 SumFGContainer::iterator sumFGItr;
573 for ( sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
574 if (sumFGItr->id() == fgid)
break;
577 if (sumFGItr != sumFG.end()) {
578 for (
int i=0;
i<samples.size(); ++
i) (*sumFGItr)[
i] += samples[
i];
584 for (
int i=0;
i<samples.size(); ++
i) sumFGSamples[
i] = samples[
i];
585 sumFG.push_back(sumFGSamples);
590 vector<bool> vetoBits(samples.size(),
false);
593 for (
int i=0;
i<samples.size(); ++
i)
602 SumMap::iterator itr =
theSumMap.find(
id);
604 theSumMap.insert(std::make_pair(
id, samples));
608 for(
int i = 0;
i < samples.
size(); ++
i) {
609 (itr->second)[
i] += samples[
i];
617 std::vector<bool>& msb =
fgMap_[samples.
id()];
621 for(
int ibin = 0; ibin < int(samples.
size())- shrink; ++ibin) {
622 int algosumvalue = 0;
623 for(
unsigned int i = 0;
i <
weights_.size();
i++) {
625 algosumvalue += int(samples[ibin+
i] *
weights_[
i]);
627 if (algosumvalue<0) sum[ibin]=0;
630 else sum[ibin] = algosumvalue;
636 int shift = dgPresamples - tpPresamples;
637 int dgSamples=samples.
size();
642 "TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
644 tpPresamples=dgPresamples-shrink;
649 std::vector<bool> finegrain(tpSamples,
false);
652 output.setPresamples(tpPresamples);
654 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
664 isPeak = (samples[
idx] > samples[idx-1] && samples[
idx] >= samples[idx+1] && samples[
idx] >
theThreshold);
674 output[ibin] = std::min<unsigned int>(sum[
idx],0x3FF);
675 finegrain[ibin] = msb[
idx];
681 output[ibin] = std::min<unsigned int>(sum[
idx],0x3FF);
682 finegrain[ibin] = msb[
idx];
687 if (samples[idx] >= 0x3FF)
701 int shift = dgPresamples - tpPresamples;
702 int dgSamples=samples.
size();
704 if(shift<0 || shift+tpSamples>dgSamples){
706 "TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
707 tpPresamples=dgPresamples;
712 std::vector<bool> finegrain(tpSamples,
false);
719 finegrain[
index] = FGBit[iphiGCT][ietaGCT];
728 for (SumFGContainer::const_iterator sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
729 const std::vector<bool>&
veto =
HF_Veto[sumFGItr->id().rawId()];
730 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
733 bool vetoed = idx<int(veto.size()) && veto[idx];
735 samples[
idx] += (*sumFGItr)[
idx];
741 output.setPresamples(tpPresamples);
743 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
745 output[ibin] = samples[
idx] / (rctlsb == 0.25 ? 4 : 8);
754 for (
int i=0;
i<tp->size(); ++
i) {
760 if (ZS) tp->setZSInfo(
false,
true);
761 else tp->setZSInfo(
true,
false);
769 std::set<uint32_t> FrontEndErrors;
773 if (raw.
size()<12)
continue;
775 if(!dccHeader)
continue;
786 for(
int fchan=0; fchan<3 && !valid; fchan++) {
787 for(
int fib=0; fib<9 && !valid; fib++) {
791 if(detId.
null())
continue;
797 for (std::vector<HcalTrigTowerDetId>::const_iterator triggerId=ids.begin(); triggerId != ids.end(); ++triggerId) {
798 FrontEndErrors.insert(triggerId->rawId());
811 if (FrontEndErrors.find(tp->id().rawId()) != FrontEndErrors.end()) {
812 for (
int i=0;
i<tp->size(); ++
i) tp->setSample(
i, zeroSample);
818 FGbitMap::iterator itr =
fgMap_.find(
id);
820 std::vector<bool>& _msb = itr->second;
821 for (
size_t i=0;
i<msb.size(); ++
i)
822 _msb[
i] = _msb[
i] || msb[
i];
828 if (algo <=0 && algo>2)
829 throw cms::Exception(
"ERROR: Only algo 1 & 2 are supported.") << std::endl;
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
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
int converttoGCTetaFromTPG(int &etaTPG)
unsigned int htrTopBottom() const
HcalElectronicsId-style HTR top/bottom (1=top/0=bottom)
void analyzeHF(int ieta, int iphi, int(&FGBit)[18][22], IntegerCaloSamples &samples, HcalTriggerPrimitiveDigi &result, float rctlsb)
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)
void run(const HcalTPGCoder *incoder, const HcalTPGCompressor *outcoder, const HBHEDigiCollection &hbheDigis, const HFDigiCollection &hfDigis, HcalTrigPrimDigiCollection &result, const HcalTrigTowerGeometry *trigTowerGeometry, float rctlsb)
int ieta() const
get the tower ieta
uint32_t maskDepth() const
get the tower depth
size_t size() const
Lenght of the data buffer in bytes.
HcalTriggerPrimitiveAlgo(bool pf, const std::vector< double > &w, int latency, uint32_t FG_threshold1, uint32_t FG_threshold2, uint32_t ZS_threshold, int numberOfSamples, int numberOfPresamples, int numberOfSamplesHF, int numberOfPresamplesHF, uint32_t minSignalThreshold=0, uint32_t PMT_NoiseThreshold=0)
TowerMapFGSum theTowerMapFGSum
uint32_t minSignalThreshold_
int converttoTPGeta(int &GCTeta)
int converttoGCTphiFromTPG(int &phiTPG)
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
int converttoGCTphi(int &phi)
int ieta() const
get the cell ieta
std::vector< double > weights_
int numberOfPresamplesHF_
int converttoTPGphi(int &GCTphi)
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) ...
void runZS(HcalTrigPrimDigiCollection &tp)
std::vector< HcalTriggerPrimitiveDigi >::iterator iterator
const_iterator end() const
int iphi() const
get the cell iphi
void setHTR(int crate, int slot, int tb)
int size() const
total number of samples in the digi
uint32_t PMT_NoiseThreshold_
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
unsigned int getErrorsWord() const
Get the errors word.
bool null() const
is this a null id ?
Geom::Phi< T > phi() const
unsigned int readoutVMECrateId() const
HcalElectronicsId-style VME crate number.
const HcaluLUTTPGCoder * incoder_
int converttoGCTeta(int &eta)
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
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