16 uint32_t FG_threshold, uint32_t ZS_threshold,
17 int numberOfSamples,
int numberOfPresamples,
18 uint32_t minSignalThreshold, uint32_t PMT_NoiseThreshold)
19 : incoder_(0), outcoder_(0),
20 theThreshold(0), peakfind_(pf), weights_(w), latency_(latency),
21 FG_threshold_(FG_threshold), ZS_threshold_(ZS_threshold),
22 numberOfSamples_(numberOfSamples),
23 numberOfPresamples_(numberOfPresamples),
24 minSignalThreshold_(minSignalThreshold),
25 PMT_NoiseThreshold_(PMT_NoiseThreshold),
26 peak_finder_algorithm_(2)
61 hbheItr != hbheDigis.
end(); ++hbheItr) {
67 hfItr != hfDigis.
end(); ++hfItr) {
72 for(SumMap::iterator mapItr =
theSumMap.begin(); mapItr !=
theSumMap.end(); ++mapItr) {
85 if (frame.
id().
depth()==5)
return;
88 assert(ids.size() == 1 || ids.size() == 2);
94 std::vector<bool> msb;
100 for(
int i = 0;
i < samples1.size(); ++
i) {
101 samples1[
i] = uint32_t(samples1[
i]*0.5);
102 samples2[
i] = samples1[
i];
117 assert(ids.size() == 1);
129 uint32_t fgid = (frame.
id().
rawId() | 0x1c000) ;
133 theTowerMapFGSum.insert(std::pair<HcalTrigTowerDetId, SumFGContainer >(ids[0], sumFG));
137 SumFGContainer::iterator sumFGItr;
138 for ( sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
139 if (sumFGItr->id() == fgid)
break;
142 if (sumFGItr != sumFG.end()) {
143 for (
int i=0;
i<samples.size(); ++
i) (*sumFGItr)[
i] += samples[
i];
149 for (
int i=0;
i<samples.size(); ++
i) sumFGSamples[
i] = samples[
i];
150 sumFG.push_back(sumFGSamples);
155 vector<bool> vetoBits(samples.size(),
false);
158 for (
int i=0;
i<samples.size(); ++
i)
167 SumMap::iterator itr =
theSumMap.find(
id);
169 theSumMap.insert(std::make_pair(
id, samples));
173 for(
int i = 0;
i < samples.
size(); ++
i) {
174 (itr->second)[
i] += samples[
i];
183 std::vector<bool>& msb =
fgMap_[samples.
id()];
187 for(
int ibin = 0; ibin < int(samples.
size())- shrink; ++ibin) {
188 int algosumvalue = 0;
189 for(
unsigned int i = 0;
i <
weights_.size();
i++) {
191 algosumvalue += int(samples[ibin+
i] *
weights_[
i]);
193 if (algosumvalue<0) sum[ibin]=0;
196 else sum[ibin] = algosumvalue;
205 assert (shift >= (
peakfind_ ? shrink : 0));
220 isPeak = (samples[
idx] > samples[idx-1] && samples[
idx] >= samples[idx+1] && samples[
idx] >
theThreshold);
230 output[ibin] = std::min<unsigned int>(sum[
idx],0x3FF);
231 finegrain[ibin] = msb[
idx];
237 output[ibin] = std::min<unsigned int>(sum[
idx],0x3FF);
238 finegrain[ibin] = msb[
idx];
243 if (samples[idx] >= 0x3FF)
266 for (SumFGContainer::const_iterator sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
267 const std::vector<bool>& veto =
HF_Veto[sumFGItr->id().rawId()];
272 samples[
idx] += (*sumFGItr)[
idx];
283 output[ibin] = samples[
idx] / (rctlsb == 0.25 ? 4 : 8);
292 for (
int i=0;
i<tp->size(); ++
i) {
298 if (ZS) tp->setZSInfo(
false,
true);
299 else tp->setZSInfo(
true,
false);
307 std::set<uint32_t> FrontEndErrors;
311 if (raw.
size()<12)
continue;
313 if(!dccHeader)
continue;
324 for(
int fchan=0; fchan<3 && !
valid; fchan++) {
325 for(
int fib=0; fib<9 && !
valid; fib++) {
329 if(detId.
null())
continue;
335 for (std::vector<HcalTrigTowerDetId>::const_iterator triggerId=ids.begin(); triggerId != ids.end(); ++triggerId) {
336 FrontEndErrors.insert(triggerId->rawId());
349 if (FrontEndErrors.find(tp->id().rawId()) != FrontEndErrors.end()) {
350 for (
int i=0;
i<tp->size(); ++
i) tp->setSample(
i, zeroSample);
356 FGbitMap::iterator itr =
fgMap_.find(
id);
358 std::vector<bool>& _msb = itr->second;
359 for (
size_t i=0;
i<msb.size(); ++
i)
360 _msb[
i] = _msb[
i] || msb[
i];
366 if (algo <=0 && algo>2)
367 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
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)
void run(const HcalTPGCoder *incoder, const HcalTPGCompressor *outcoder, const HBHEDigiCollection &hbheDigis, const HFDigiCollection &hfDigis, HcalTrigPrimDigiCollection &result, const HcalTrigTowerGeometry *trigTowerGeometry, float rctlsb)
void analyzeHF(IntegerCaloSamples &samples, HcalTriggerPrimitiveDigi &result, float rctlsb)
size_t size() const
Lenght of the data buffer in bytes.
TowerMapFGSum theTowerMapFGSum
uint32_t minSignalThreshold_
uint32_t rawId() const
get the raw id
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
HcalTriggerPrimitiveAlgo(bool pf, const std::vector< double > &w, int latency, uint32_t FG_threshold, uint32_t ZS_threshold, int numberOfSamples, int numberOfPresamples, uint32_t minSignalThreshold=0, uint32_t PMT_NoiseThreshold=0)
std::vector< double > weights_
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
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 ?
unsigned int readoutVMECrateId() const
HcalElectronicsId-style VME crate number.
const HcaluLUTTPGCoder * incoder_
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 [31:26] Unused (so far) [25] Trigger-chain id flag [24:20] Read...
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