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];
182 std::vector<bool>& msb =
fgMap_[samples.
id()];
186 for(
int ibin = 0; ibin < int(samples.
size())- shrink; ++ibin) {
187 int algosumvalue = 0;
188 for(
unsigned int i = 0;
i <
weights_.size();
i++) {
190 algosumvalue += int(samples[ibin+
i] *
weights_[
i]);
192 if (algosumvalue<0) sum[ibin]=0;
195 else sum[ibin] = algosumvalue;
201 int shift = dgPresamples - tpPresamples;
202 int dgSamples=samples.
size();
207 "TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
209 tpPresamples=dgPresamples-shrink;
214 std::vector<bool> finegrain(tpSamples,
false);
217 output.setPresamples(tpPresamples);
219 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
229 isPeak = (samples[
idx] > samples[idx-1] && samples[
idx] >= samples[idx+1] && samples[
idx] >
theThreshold);
239 output[ibin] = std::min<unsigned int>(sum[
idx],0x3FF);
240 finegrain[ibin] = msb[
idx];
246 output[ibin] = std::min<unsigned int>(sum[
idx],0x3FF);
247 finegrain[ibin] = msb[
idx];
252 if (samples[idx] >= 0x3FF)
266 int shift = dgPresamples - tpPresamples;
267 int dgSamples=samples.
size();
269 if(shift<0 || shift+tpSamples>dgSamples){
271 "TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
272 tpPresamples=dgPresamples;
277 std::vector<bool> finegrain(tpSamples,
false);
285 for (SumFGContainer::const_iterator sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
286 const std::vector<bool>&
veto =
HF_Veto[sumFGItr->id().rawId()];
287 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
290 bool vetoed = idx<int(veto.size()) && veto[idx];
292 samples[
idx] += (*sumFGItr)[
idx];
299 output.setPresamples(tpPresamples);
301 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
303 output[ibin] = samples[
idx] / (rctlsb == 0.25 ? 4 : 8);
312 for (
int i=0;
i<tp->size(); ++
i) {
318 if (ZS) tp->setZSInfo(
false,
true);
319 else tp->setZSInfo(
true,
false);
327 std::set<uint32_t> FrontEndErrors;
331 if (raw.
size()<12)
continue;
333 if(!dccHeader)
continue;
344 for(
int fchan=0; fchan<3 && !
valid; fchan++) {
345 for(
int fib=0; fib<9 && !
valid; fib++) {
349 if(detId.
null())
continue;
355 for (std::vector<HcalTrigTowerDetId>::const_iterator triggerId=ids.begin(); triggerId != ids.end(); ++triggerId) {
356 FrontEndErrors.insert(triggerId->rawId());
369 if (FrontEndErrors.find(tp->id().rawId()) != FrontEndErrors.end()) {
370 for (
int i=0;
i<tp->size(); ++
i) tp->setSample(
i, zeroSample);
376 FGbitMap::iterator itr =
fgMap_.find(
id);
378 std::vector<bool>& _msb = itr->second;
379 for (
size_t i=0;
i<msb.size(); ++
i)
380 _msb[
i] = _msb[
i] || msb[
i];
386 if (algo <=0 && algo>2)
387 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.
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