16 uint32_t FG_threshold, 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_threshold_(FG_threshold), 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)
66 hbheItr != hbheDigis.
end(); ++hbheItr) {
72 hfItr != hfDigis.
end(); ++hfItr) {
77 for(SumMap::iterator mapItr =
theSumMap.begin(); mapItr !=
theSumMap.end(); ++mapItr) {
90 if (frame.
id().
depth()==5)
return;
93 assert(ids.size() == 1 || ids.size() == 2);
99 std::vector<bool> msb;
102 if(ids.size() == 2) {
105 for(
int i = 0;
i < samples1.size(); ++
i) {
106 samples1[
i] = uint32_t(samples1[
i]*0.5);
107 samples2[
i] = samples1[
i];
138 theTowerMapFGSum.insert(std::pair<HcalTrigTowerDetId, SumFGContainer >(ids[0], sumFG));
142 SumFGContainer::iterator sumFGItr;
143 for ( sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
144 if (sumFGItr->id() == fgid)
break;
147 if (sumFGItr != sumFG.end()) {
148 for (
int i=0;
i<samples.size(); ++
i) (*sumFGItr)[
i] += samples[
i];
154 for (
int i=0;
i<samples.size(); ++
i) sumFGSamples[
i] = samples[
i];
155 sumFG.push_back(sumFGSamples);
160 vector<bool> vetoBits(samples.size(),
false);
163 for (
int i=0;
i<samples.size(); ++
i)
172 SumMap::iterator itr =
theSumMap.find(
id);
174 theSumMap.insert(std::make_pair(
id, samples));
178 for(
int i = 0;
i < samples.
size(); ++
i) {
179 (itr->second)[
i] += samples[
i];
187 std::vector<bool>& msb =
fgMap_[samples.
id()];
191 for(
int ibin = 0; ibin < int(samples.
size())- shrink; ++ibin) {
192 int algosumvalue = 0;
193 for(
unsigned int i = 0;
i <
weights_.size();
i++) {
195 algosumvalue += int(samples[ibin+
i] *
weights_[
i]);
197 if (algosumvalue<0) sum[ibin]=0;
200 else sum[ibin] = algosumvalue;
206 int shift = dgPresamples - tpPresamples;
207 int dgSamples=samples.
size();
212 "TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
214 tpPresamples=dgPresamples-shrink;
219 std::vector<bool> finegrain(tpSamples,
false);
222 output.setPresamples(tpPresamples);
224 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
234 isPeak = (samples[
idx] > samples[idx-1] && samples[
idx] >= samples[idx+1] && samples[
idx] >
theThreshold);
244 output[ibin] = std::min<unsigned int>(sum[
idx],0x3FF);
245 finegrain[ibin] = msb[
idx];
251 output[ibin] = std::min<unsigned int>(sum[
idx],0x3FF);
252 finegrain[ibin] = msb[
idx];
257 if (samples[idx] >= 0x3FF)
271 int shift = dgPresamples - tpPresamples;
272 int dgSamples=samples.
size();
274 if(shift<0 || shift+tpSamples>dgSamples){
276 "TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
277 tpPresamples=dgPresamples;
282 std::vector<bool> finegrain(tpSamples,
false);
290 for (SumFGContainer::const_iterator sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
291 const std::vector<bool>&
veto =
HF_Veto[sumFGItr->id().rawId()];
292 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
295 bool vetoed = idx<int(veto.size()) && veto[idx];
297 samples[
idx] += (*sumFGItr)[
idx];
304 output.setPresamples(tpPresamples);
306 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
308 output[ibin] = samples[
idx] / (rctlsb == 0.25 ? 4 : 8);
317 for (
int i=0;
i<tp->size(); ++
i) {
323 if (ZS) tp->setZSInfo(
false,
true);
324 else tp->setZSInfo(
true,
false);
332 std::set<uint32_t> FrontEndErrors;
336 if (raw.
size()<12)
continue;
338 if(!dccHeader)
continue;
349 for(
int fchan=0; fchan<3 && !valid; fchan++) {
350 for(
int fib=0; fib<9 && !valid; fib++) {
354 if(detId.
null())
continue;
360 for (std::vector<HcalTrigTowerDetId>::const_iterator triggerId=ids.begin(); triggerId != ids.end(); ++triggerId) {
361 FrontEndErrors.insert(triggerId->rawId());
374 if (FrontEndErrors.find(tp->id().rawId()) != FrontEndErrors.end()) {
375 for (
int i=0;
i<tp->size(); ++
i) tp->setSample(
i, zeroSample);
381 FGbitMap::iterator itr =
fgMap_.find(
id);
383 std::vector<bool>& _msb = itr->second;
384 for (
size_t i=0;
i<msb.size(); ++
i)
385 _msb[
i] = _msb[
i] || msb[
i];
391 if (algo <=0 && algo>2)
392 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
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)
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)
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) ...
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