17 bool FG_MinimumBias, 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_MinimumBias_(FG_MinimumBias), 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 NCTScaleShift(0), RCTScaleShift(0),
31 peak_finder_algorithm_(2)
69 hbheItr != hbheDigis.
end(); ++hbheItr) {
75 hfItr != hfDigis.
end(); ++hfItr) {
82 for(SumMap::iterator mapItr =
theSumMap.begin(); mapItr !=
theSumMap.end(); ++mapItr) {
86 if (detId.version() == 0) {
88 }
else if (detId.version() == 1) {
113 if (frame.
id().
depth()==5)
return;
116 assert(ids.size() == 1 || ids.size() == 2);
122 std::vector<bool> msb;
125 if(ids.size() == 2) {
128 for(
int i = 0;
i < samples1.size(); ++
i) {
129 samples1[
i] = uint32_t(samples1[
i]*0.5);
130 samples2[
i] = samples1[
i];
144 std::vector<HcalTrigTowerDetId>::const_iterator it;
145 for (it = ids.begin(); it != ids.end(); ++it) {
158 if (trig_tower_id.
version() == 0) {
164 theTowerMapFGSum.insert(std::pair<HcalTrigTowerDetId, SumFGContainer>(trig_tower_id, sumFG));
168 SumFGContainer::iterator sumFGItr;
169 for ( sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
170 if (sumFGItr->id() == fgid) {
break; }
173 if (sumFGItr != sumFG.end()) {
174 for (
int i=0;
i<samples.size(); ++
i) {
175 (*sumFGItr)[
i] += samples[
i];
182 for (
int i=0;
i<samples.size(); ++
i) {
183 sumFGSamples[
i] = samples[
i];
185 sumFG.push_back(sumFGSamples);
190 vector<bool> vetoBits(samples.size(),
false);
193 for (
int i=0;
i<samples.size(); ++
i) {
200 else if (trig_tower_id.
version() == 1) {
207 }
else if (frame.
id().
depth() == 2) {
212 edm::LogWarning(
"HcalTPAlgo") <<
"Unable to figure out what to do with data frame for " << frame.
id();
227 SumMap::iterator itr =
theSumMap.find(
id);
229 theSumMap.insert(std::make_pair(
id, samples));
233 for(
int i = 0;
i < samples.
size(); ++
i) {
234 (itr->second)[
i] += samples[
i];
242 std::vector<bool>& msb =
fgMap_[samples.
id()];
246 for(
int ibin = 0; ibin < int(samples.
size())- shrink; ++ibin) {
247 int algosumvalue = 0;
248 for(
unsigned int i = 0;
i <
weights_.size();
i++) {
250 algosumvalue += int(samples[ibin+
i] *
weights_[
i]);
252 if (algosumvalue<0) sum[ibin]=0;
255 else sum[ibin] = algosumvalue;
261 int shift = dgPresamples - tpPresamples;
262 int dgSamples=samples.
size();
267 "TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
269 tpPresamples=dgPresamples-shrink;
274 std::vector<bool> finegrain(tpSamples,
false);
277 output.setPresamples(tpPresamples);
279 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
289 isPeak = (samples[
idx] > samples[idx-1] && samples[
idx] >= samples[idx+1] && samples[
idx] >
theThreshold);
299 output[ibin] = std::min<unsigned int>(sum[
idx],0x3FF);
300 finegrain[ibin] = msb[
idx];
306 output[ibin] = std::min<unsigned int>(sum[
idx],0x3FF);
307 finegrain[ibin] = msb[
idx];
312 if (samples[idx] >= 0x3FF)
326 int shift = dgPresamples - tpPresamples;
327 int dgSamples=samples.
size();
329 if(shift<0 || shift+tpSamples>dgSamples){
331 "TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
332 tpPresamples=dgPresamples;
337 std::vector<bool> finegrain(tpSamples,
false);
345 for (SumFGContainer::const_iterator sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
346 const std::vector<bool>&
veto =
HF_Veto[sumFGItr->id().rawId()];
347 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
350 bool vetoed = idx<int(veto.size()) && veto[idx];
352 samples[
idx] += (*sumFGItr)[
idx];
359 output.setPresamples(tpPresamples);
361 for (
int ibin = 0; ibin < tpSamples; ++ibin) {
363 output[ibin] = samples[
idx] >> hf_lumi_shift;
364 static const int MAX_OUTPUT = 0x3FF;
365 if (
output[ibin] > MAX_OUTPUT)
output[ibin] = MAX_OUTPUT;
373 const int HF_LUMI_SHIFT,
395 for (
const auto& item: it->second) {
396 auto& details = item.second;
398 const int IDX = ibin + SHIFT;
399 int long_fiber_val = 0;
400 if (IDX < details.long_fiber.size()) {
401 long_fiber_val = details.long_fiber[IDX];
403 int short_fiber_val = 0;
404 if (IDX < details.short_fiber.size()) {
405 short_fiber_val = details.short_fiber[IDX];
407 output[ibin] += (long_fiber_val + short_fiber_val);
409 uint32_t ADCLong = details.LongDigi[ibin].adc();
410 uint32_t ADCShort = details.ShortDigi[ibin].adc();
415 else if(HCALFEM != 0) {
416 finegrain[ibin] = (finegrain[ibin] || HCALFEM->
fineGrainbit(ADCShort, details.ShortDigi.id(), details.ShortDigi[ibin].capid(), ADCLong, details.LongDigi.id(), details.LongDigi[ibin].capid()));
422 static const unsigned int MAX_OUTPUT = 0x3FF;
432 for (
int i=0;
i<tp->size(); ++
i) {
438 if (ZS) tp->setZSInfo(
false,
true);
439 else tp->setZSInfo(
true,
false);
447 std::set<uint32_t> FrontEndErrors;
451 if (raw.
size()<12)
continue;
453 if(!dccHeader)
continue;
464 for(
int fchan=0; fchan<3 && !valid; fchan++) {
465 for(
int fib=0; fib<9 && !valid; fib++) {
469 if(detId.
null())
continue;
475 for (std::vector<HcalTrigTowerDetId>::const_iterator triggerId=ids.begin(); triggerId != ids.end(); ++triggerId) {
476 FrontEndErrors.insert(triggerId->rawId());
489 if (FrontEndErrors.find(tp->id().rawId()) != FrontEndErrors.end()) {
490 for (
int i=0;
i<tp->size(); ++
i) tp->setSample(
i, zeroSample);
496 FGbitMap::iterator itr =
fgMap_.find(
id);
498 std::vector<bool>& _msb = itr->second;
499 for (
size_t i=0;
i<msb.size(); ++
i)
500 _msb[
i] = _msb[
i] || msb[
i];
506 if (algo <=0 && algo>2)
507 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
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)
HcalTriggerPrimitiveAlgo(bool pf, const std::vector< double > &w, int latency, bool FG_MinimumBias, 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)
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)
void setNCTScaleShift(int)
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
void setRCTScaleShift(int)
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