test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes
HcalTriggerPrimitiveAlgo Class Reference

#include <HcalTriggerPrimitiveAlgo.h>

Classes

struct  HFDetails
 

Public Member Functions

 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)
 
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)
 
void runFEFormatError (const FEDRawDataCollection *rawraw, const HcalElectronicsMap *emap, HcalTrigPrimDigiCollection &result)
 
void runZS (HcalTrigPrimDigiCollection &tp)
 
void setNCTScaleShift (int)
 
void setPeakFinderAlgorithm (int algo)
 
void setRCTScaleShift (int)
 
 ~HcalTriggerPrimitiveAlgo ()
 

Private Types

typedef std::map
< HcalTrigTowerDetId,
std::vector< bool > > 
FGbitMap
 
typedef std::map
< HcalTrigTowerDetId, std::map
< uint32_t, HFDetails > > 
HFDetailMap
 
typedef std::vector
< IntegerCaloSamples
SumFGContainer
 
typedef std::map
< HcalTrigTowerDetId,
IntegerCaloSamples
SumMap
 
typedef std::map
< HcalTrigTowerDetId,
SumFGContainer
TowerMapFGSum
 
typedef std::map< uint32_t,
std::vector< bool > > 
TowerMapVeto
 

Private Member Functions

void addFG (const HcalTrigTowerDetId &id, std::vector< bool > &msb)
 
void addSignal (const HBHEDataFrame &frame)
 adds the signal to the map More...
 
void addSignal (const HFDataFrame &frame)
 
void addSignal (const IntegerCaloSamples &samples)
 
void analyze (IntegerCaloSamples &samples, HcalTriggerPrimitiveDigi &result)
 adds the actual RecHits More...
 
void analyzeHF (IntegerCaloSamples &samples, HcalTriggerPrimitiveDigi &result, const int hf_lumi_shift)
 
void analyzeHFV1 (const IntegerCaloSamples &SAMPLES, HcalTriggerPrimitiveDigi &result, const int HF_LUMI_SHIFT, const HcalFeatureBit *HCALFEM)
 

Private Attributes

bool FG_MinimumBias_
 
uint32_t FG_threshold_
 
FGbitMap fgMap_
 
TowerMapVeto HF_Veto
 
const HcaluLUTTPGCoderincoder_
 
int latency_
 
HcalFeatureBitLongvrsShortCut
 
uint32_t minSignalThreshold_
 
int NCTScaleShift
 
int numberOfPresamples_
 
int numberOfPresamplesHF_
 
int numberOfSamples_
 
int numberOfSamplesHF_
 
const HcalTPGCompressoroutcoder_
 
int peak_finder_algorithm_
 
bool peakfind_
 
uint32_t PMT_NoiseThreshold_
 
int RCTScaleShift
 
HFDetailMap theHFDetailMap
 
SumMap theSumMap
 
double theThreshold
 
TowerMapFGSum theTowerMapFGSum
 
const HcalTrigTowerGeometrytheTrigTowerGeometry
 
std::vector< double > weights_
 
uint32_t ZS_threshold_
 
int ZS_threshold_I_
 

Detailed Description

Definition at line 21 of file HcalTriggerPrimitiveAlgo.h.

Member Typedef Documentation

typedef std::map<HcalTrigTowerDetId, std::vector<bool> > HcalTriggerPrimitiveAlgo::FGbitMap
private

Definition at line 127 of file HcalTriggerPrimitiveAlgo.h.

typedef std::map<HcalTrigTowerDetId, std::map<uint32_t, HFDetails> > HcalTriggerPrimitiveAlgo::HFDetailMap
private

Definition at line 107 of file HcalTriggerPrimitiveAlgo.h.

Definition at line 110 of file HcalTriggerPrimitiveAlgo.h.

Definition at line 98 of file HcalTriggerPrimitiveAlgo.h.

Definition at line 111 of file HcalTriggerPrimitiveAlgo.h.

typedef std::map<uint32_t, std::vector<bool> > HcalTriggerPrimitiveAlgo::TowerMapVeto
private

Definition at line 124 of file HcalTriggerPrimitiveAlgo.h.

Constructor & Destructor Documentation

HcalTriggerPrimitiveAlgo::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 
)

Definition at line 16 of file HcalTriggerPrimitiveAlgo.cc.

References numberOfPresamples_, numberOfPresamplesHF_, numberOfSamples_, numberOfSamplesHF_, peakfind_, ZS_threshold_, and ZS_threshold_I_.

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),
32 {
33  //No peak finding setting (for Fastsim)
34  if (!peakfind_){
35  numberOfSamples_ = 1;
37  numberOfSamplesHF_ = 1;
39  }
40  // Switch to integer for comparisons - remove compiler warning
42 }
const double w
Definition: UKUtility.cc:23
const HcalTPGCompressor * outcoder_
std::vector< double > weights_
const HcaluLUTTPGCoder * incoder_
HcalTriggerPrimitiveAlgo::~HcalTriggerPrimitiveAlgo ( )

Definition at line 45 of file HcalTriggerPrimitiveAlgo.cc.

45  {
46 }

Member Function Documentation

void HcalTriggerPrimitiveAlgo::addFG ( const HcalTrigTowerDetId id,
std::vector< bool > &  msb 
)
private

Definition at line 495 of file HcalTriggerPrimitiveAlgo.cc.

References fgMap_, and i.

Referenced by addSignal().

495  {
496  FGbitMap::iterator itr = fgMap_.find(id);
497  if (itr != fgMap_.end()){
498  std::vector<bool>& _msb = itr->second;
499  for (size_t i=0; i<msb.size(); ++i)
500  _msb[i] = _msb[i] || msb[i];
501  }
502  else fgMap_[id] = msb;
503 }
int i
Definition: DBlmapReader.cc:9
void HcalTriggerPrimitiveAlgo::addSignal ( const HBHEDataFrame frame)
private

adds the signal to the map

Definition at line 110 of file HcalTriggerPrimitiveAlgo.cc.

References HcaluLUTTPGCoder::adc2Linear(), addFG(), assert(), HcalDetId::depth(), i, HBHEDataFrame::id(), incoder_, HcaluLUTTPGCoder::lookupMSB(), HBHEDataFrame::presamples(), HBHEDataFrame::size(), theTrigTowerGeometry, and HcalTrigTowerGeometry::towerIds().

Referenced by addSignal(), and run().

110  {
111  // TODO: Need to add support for seperate 28, 29 in HE
112  //Hack for 300_pre10, should be removed.
113  if (frame.id().depth()==5) return;
114 
115  std::vector<HcalTrigTowerDetId> ids = theTrigTowerGeometry->towerIds(frame.id());
116  assert(ids.size() == 1 || ids.size() == 2);
117  IntegerCaloSamples samples1(ids[0], int(frame.size()));
118 
119  samples1.setPresamples(frame.presamples());
120  incoder_->adc2Linear(frame, samples1);
121 
122  std::vector<bool> msb;
123  incoder_->lookupMSB(frame, msb);
124 
125  if(ids.size() == 2) {
126  // make a second trigprim for the other one, and split the energy
127  IntegerCaloSamples samples2(ids[1], samples1.size());
128  for(int i = 0; i < samples1.size(); ++i) {
129  samples1[i] = uint32_t(samples1[i]*0.5);
130  samples2[i] = samples1[i];
131  }
132  samples2.setPresamples(frame.presamples());
133  addSignal(samples2);
134  addFG(ids[1], msb);
135  }
136  addSignal(samples1);
137  addFG(ids[0], msb);
138 }
int i
Definition: DBlmapReader.cc:9
std::vector< HcalTrigTowerDetId > towerIds(const HcalDetId &cellId) const
the mapping to and from DetIds
int size() const
total number of samples in the digi
Definition: HBHEDataFrame.h:26
assert(m_qm.get())
void addFG(const HcalTrigTowerDetId &id, std::vector< bool > &msb)
int depth() const
get the tower depth
Definition: HcalDetId.cc:106
const HcalTrigTowerGeometry * theTrigTowerGeometry
void lookupMSB(const HBHEDataFrame &df, std::vector< bool > &msb) const
int presamples() const
number of samples before the sample from the triggered beam crossing (according to the hardware) ...
Definition: HBHEDataFrame.h:28
const HcaluLUTTPGCoder * incoder_
const HcalDetId & id() const
Definition: HBHEDataFrame.h:22
virtual void adc2Linear(const HBHEDataFrame &df, IntegerCaloSamples &ics) const
void addSignal(const HBHEDataFrame &frame)
adds the signal to the map
void HcalTriggerPrimitiveAlgo::addSignal ( const HFDataFrame frame)
private

Definition at line 141 of file HcalTriggerPrimitiveAlgo.cc.

References HcaluLUTTPGCoder::adc2Linear(), addSignal(), HcalDetId::depth(), HF_Veto, i, HFDataFrame::id(), incoder_, HcalTriggerPrimitiveAlgo::HFDetails::long_fiber, HcalTriggerPrimitiveAlgo::HFDetails::LongDigi, HcalDetId::maskDepth(), minSignalThreshold_, HFDataFrame::presamples(), IntegerCaloSamples::setPresamples(), HcalTriggerPrimitiveAlgo::HFDetails::short_fiber, HcalTriggerPrimitiveAlgo::HFDetails::ShortDigi, HFDataFrame::size(), theHFDetailMap, theTowerMapFGSum, theTrigTowerGeometry, HcalTrigTowerGeometry::towerIds(), and HcalTrigTowerDetId::version().

141  {
142  if(frame.id().depth() == 1 || frame.id().depth() == 2) {
143  std::vector<HcalTrigTowerDetId> ids = theTrigTowerGeometry->towerIds(frame.id());
144  std::vector<HcalTrigTowerDetId>::const_iterator it;
145  for (it = ids.begin(); it != ids.end(); ++it) {
146  HcalTrigTowerDetId trig_tower_id = *it;
147  IntegerCaloSamples samples(trig_tower_id, frame.size());
148  samples.setPresamples(frame.presamples());
149  incoder_->adc2Linear(frame, samples);
150 
151  // Don't add to final collection yet
152  // HF PMT veto sum is calculated in analyzerHF()
153  IntegerCaloSamples zero_samples(trig_tower_id, frame.size());
154  zero_samples.setPresamples(frame.presamples());
155  addSignal(zero_samples);
156 
157  // Pre-LS1 Configuration
158  if (trig_tower_id.version() == 0) {
159  // Mask off depths: fgid is the same for both depths
160  uint32_t fgid = (frame.id().maskDepth());
161 
162  if ( theTowerMapFGSum.find(trig_tower_id) == theTowerMapFGSum.end() ) {
163  SumFGContainer sumFG;
164  theTowerMapFGSum.insert(std::pair<HcalTrigTowerDetId, SumFGContainer>(trig_tower_id, sumFG));
165  }
166 
167  SumFGContainer& sumFG = theTowerMapFGSum[trig_tower_id];
168  SumFGContainer::iterator sumFGItr;
169  for ( sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
170  if (sumFGItr->id() == fgid) { break; }
171  }
172  // If find
173  if (sumFGItr != sumFG.end()) {
174  for (int i=0; i<samples.size(); ++i) {
175  (*sumFGItr)[i] += samples[i];
176  }
177  }
178  else {
179  //Copy samples (change to fgid)
180  IntegerCaloSamples sumFGSamples(DetId(fgid), samples.size());
181  sumFGSamples.setPresamples(samples.presamples());
182  for (int i=0; i<samples.size(); ++i) {
183  sumFGSamples[i] = samples[i];
184  }
185  sumFG.push_back(sumFGSamples);
186  }
187 
188  // set veto to true if Long or Short less than threshold
189  if (HF_Veto.find(fgid) == HF_Veto.end()) {
190  vector<bool> vetoBits(samples.size(), false);
191  HF_Veto[fgid] = vetoBits;
192  }
193  for (int i=0; i<samples.size(); ++i) {
194  if (samples[i] < minSignalThreshold_) {
195  HF_Veto[fgid][i] = true;
196  }
197  }
198  }
199  // HF 1x1
200  else if (trig_tower_id.version() == 1) {
201  uint32_t fgid = (frame.id().maskDepth());
202  HFDetails& details = theHFDetailMap[trig_tower_id][fgid];
203  // Check the frame type to determine long vs short
204  if (frame.id().depth() == 1) { // Long
205  details.long_fiber = samples;
206  details.LongDigi = frame;
207  } else if (frame.id().depth() == 2) { // Short
208  details.short_fiber = samples;
209  details.ShortDigi = frame;
210  } else {
211  // Neither long nor short... So we have no idea what to do
212  edm::LogWarning("HcalTPAlgo") << "Unable to figure out what to do with data frame for " << frame.id();
213  return;
214  }
215  }
216  // Uh oh, we are in a bad/unknown state! Things will start crashing.
217  else {
218  return;
219  }
220  }
221  }
222 }
int i
Definition: DBlmapReader.cc:9
std::vector< HcalTrigTowerDetId > towerIds(const HcalDetId &cellId) const
the mapping to and from DetIds
void setPresamples(int pre)
set presample information
uint32_t maskDepth() const
get the tower depth
Definition: HcalDetId.cc:119
std::vector< IntegerCaloSamples > SumFGContainer
int depth() const
get the tower depth
Definition: HcalDetId.cc:106
const HcalTrigTowerGeometry * theTrigTowerGeometry
Definition: DetId.h:18
int size() const
total number of samples in the digi
Definition: HFDataFrame.h:26
int version() const
get the version code for the trigger tower
const HcaluLUTTPGCoder * incoder_
virtual void adc2Linear(const HBHEDataFrame &df, IntegerCaloSamples &ics) const
int presamples() const
number of samples before the sample from the triggered beam crossing (according to the hardware) ...
Definition: HFDataFrame.h:28
const HcalDetId & id() const
Definition: HFDataFrame.h:22
void addSignal(const HBHEDataFrame &frame)
adds the signal to the map
void HcalTriggerPrimitiveAlgo::addSignal ( const IntegerCaloSamples samples)
private

Definition at line 225 of file HcalTriggerPrimitiveAlgo.cc.

References i, IntegerCaloSamples::id(), IntegerCaloSamples::size(), and theSumMap.

225  {
226  HcalTrigTowerDetId id(samples.id());
227  SumMap::iterator itr = theSumMap.find(id);
228  if(itr == theSumMap.end()) {
229  theSumMap.insert(std::make_pair(id, samples));
230  }
231  else {
232  // wish CaloSamples had a +=
233  for(int i = 0; i < samples.size(); ++i) {
234  (itr->second)[i] += samples[i];
235  }
236  }
237 }
int i
Definition: DBlmapReader.cc:9
int size() const
get the size
DetId id() const
get the (generic) id
void HcalTriggerPrimitiveAlgo::analyze ( IntegerCaloSamples samples,
HcalTriggerPrimitiveDigi result 
)
private

adds the actual RecHits

Definition at line 240 of file HcalTriggerPrimitiveAlgo.cc.

References HcalTPGCompressor::compress(), fgMap_, i, IntegerCaloSamples::id(), customizeTrackingMonitorSeedNumber::idx, numberOfPresamples_, numberOfSamples_, outcoder_, convertSQLitetoXML_cfg::output, peak_finder_algorithm_, peakfind_, IntegerCaloSamples::presamples(), edm::shift, IntegerCaloSamples::size(), theThreshold, and weights_.

Referenced by run().

240  {
241  int shrink = weights_.size() - 1;
242  std::vector<bool>& msb = fgMap_[samples.id()];
243  IntegerCaloSamples sum(samples.id(), samples.size());
244 
245  //slide algo window
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++) {
249  //add up value * scale factor
250  algosumvalue += int(samples[ibin+i] * weights_[i]);
251  }
252  if (algosumvalue<0) sum[ibin]=0; // low-side
253  //high-side
254  //else if (algosumvalue>0x3FF) sum[ibin]=0x3FF;
255  else sum[ibin] = algosumvalue; //assign value to sum[]
256  }
257 
258  // Align digis and TP
259  int dgPresamples=samples.presamples();
260  int tpPresamples=numberOfPresamples_;
261  int shift = dgPresamples - tpPresamples;
262  int dgSamples=samples.size();
263  int tpSamples=numberOfSamples_;
264  if(peakfind_){
265  if((shift<shrink) || (shift + tpSamples + shrink > dgSamples - (peak_finder_algorithm_ - 1) ) ){
266  edm::LogInfo("HcalTriggerPrimitiveAlgo::analyze") <<
267  "TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
268  shift=shrink;
269  tpPresamples=dgPresamples-shrink;
270  tpSamples=dgSamples-(peak_finder_algorithm_-1)-shrink-shift;
271  }
272  }
273 
274  std::vector<bool> finegrain(tpSamples,false);
275 
276  IntegerCaloSamples output(samples.id(), tpSamples);
277  output.setPresamples(tpPresamples);
278 
279  for (int ibin = 0; ibin < tpSamples; ++ibin) {
280  // ibin - index for output TP
281  // idx - index for samples + shift
282  int idx = ibin + shift;
283 
284  //Peak finding
285  if (peakfind_) {
286  bool isPeak = false;
287  switch (peak_finder_algorithm_) {
288  case 1 :
289  isPeak = (samples[idx] > samples[idx-1] && samples[idx] >= samples[idx+1] && samples[idx] > theThreshold);
290  break;
291  case 2:
292  isPeak = (sum[idx] > sum[idx-1] && sum[idx] >= sum[idx+1] && sum[idx] > theThreshold);
293  break;
294  default:
295  break;
296  }
297 
298  if (isPeak){
299  output[ibin] = std::min<unsigned int>(sum[idx],0x3FF);
300  finegrain[ibin] = msb[idx];
301  }
302  // Not a peak
303  else output[ibin] = 0;
304  }
305  else { // No peak finding, just output running sum
306  output[ibin] = std::min<unsigned int>(sum[idx],0x3FF);
307  finegrain[ibin] = msb[idx];
308  }
309 
310  // Only Pegged for 1-TS algo.
311  if (peak_finder_algorithm_ == 1) {
312  if (samples[idx] >= 0x3FF)
313  output[ibin] = 0x3FF;
314  }
315  }
316  outcoder_->compress(output, finegrain, result);
317 }
int i
Definition: DBlmapReader.cc:9
int presamples() const
access presample information
const HcalTPGCompressor * outcoder_
int size() const
get the size
std::vector< double > weights_
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
static unsigned int const shift
void compress(const IntegerCaloSamples &ics, const std::vector< bool > &fineGrain, HcalTriggerPrimitiveDigi &digi) const
DetId id() const
get the (generic) id
void HcalTriggerPrimitiveAlgo::analyzeHF ( IntegerCaloSamples samples,
HcalTriggerPrimitiveDigi result,
const int  hf_lumi_shift 
)
private

Definition at line 320 of file HcalTriggerPrimitiveAlgo.cc.

References assert(), HcalTPGCompressor::compress(), FG_threshold_, HF_Veto, IntegerCaloSamples::id(), customizeTrackingMonitorSeedNumber::idx, numberOfPresamplesHF_, numberOfSamplesHF_, outcoder_, convertSQLitetoXML_cfg::output, PMT_NoiseThreshold_, IntegerCaloSamples::presamples(), edm::shift, IntegerCaloSamples::size(), theTowerMapFGSum, and TriggerAnalyzer::veto.

Referenced by run().

320  {
321  HcalTrigTowerDetId detId(samples.id());
322 
323  // Align digis and TP
324  int dgPresamples=samples.presamples();
325  int tpPresamples=numberOfPresamplesHF_;
326  int shift = dgPresamples - tpPresamples;
327  int dgSamples=samples.size();
328  int tpSamples=numberOfSamplesHF_;
329  if(shift<0 || shift+tpSamples>dgSamples){
330  edm::LogInfo("HcalTriggerPrimitiveAlgo::analyzeHF") <<
331  "TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
332  tpPresamples=dgPresamples;
333  shift=0;
334  tpSamples=dgSamples;
335  }
336 
337  std::vector<bool> finegrain(tpSamples, false);
338 
339  TowerMapFGSum::const_iterator tower2fg = theTowerMapFGSum.find(detId);
340  assert(tower2fg != theTowerMapFGSum.end());
341 
342  const SumFGContainer& sumFG = tower2fg->second;
343  // Loop over all L+S pairs that mapped from samples.id()
344  // Note: 1 samples.id() = 6 x (L+S) without noZS
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) {
348  int idx = ibin + shift;
349  // if not vetod, add L+S to total sum and calculate FG
350  bool vetoed = idx<int(veto.size()) && veto[idx];
351  if (!(vetoed && (*sumFGItr)[idx] > PMT_NoiseThreshold_)) {
352  samples[idx] += (*sumFGItr)[idx];
353  finegrain[ibin] = (finegrain[ibin] || (*sumFGItr)[idx] >= FG_threshold_);
354  }
355  }
356  }
357 
358  IntegerCaloSamples output(samples.id(), tpSamples);
359  output.setPresamples(tpPresamples);
360 
361  for (int ibin = 0; ibin < tpSamples; ++ibin) {
362  int idx = ibin + shift;
363  output[ibin] = samples[idx] >> hf_lumi_shift;
364  static const int MAX_OUTPUT = 0x3FF; // 0x3FF = 1023
365  if (output[ibin] > MAX_OUTPUT) output[ibin] = MAX_OUTPUT;
366  }
367  outcoder_->compress(output, finegrain, result);
368 }
int presamples() const
access presample information
assert(m_qm.get())
const HcalTPGCompressor * outcoder_
std::vector< IntegerCaloSamples > SumFGContainer
int size() const
get the size
tuple idx
DEBUGGING if hasattr(process,&quot;trackMonIterativeTracking2012&quot;): print &quot;trackMonIterativeTracking2012 D...
static unsigned int const shift
void compress(const IntegerCaloSamples &ics, const std::vector< bool > &fineGrain, HcalTriggerPrimitiveDigi &digi) const
DetId id() const
get the (generic) id
void HcalTriggerPrimitiveAlgo::analyzeHFV1 ( const IntegerCaloSamples SAMPLES,
HcalTriggerPrimitiveDigi result,
const int  HF_LUMI_SHIFT,
const HcalFeatureBit HCALFEM 
)
private

Definition at line 370 of file HcalTriggerPrimitiveAlgo.cc.

References assert(), newFWLiteAna::bin, HcalTPGCompressor::compress(), FG_MinimumBias_, FG_threshold_, HcalFeatureBit::fineGrainbit(), IntegerCaloSamples::id(), min(), numberOfPresamples_, numberOfSamples_, outcoder_, convertSQLitetoXML_cfg::output, IntegerCaloSamples::presamples(), IntegerCaloSamples::size(), and theHFDetailMap.

Referenced by run().

375  {
376  // Align digis and TP
377  const int SHIFT = SAMPLES.presamples() - numberOfPresamples_;
378  assert(SHIFT >= 0);
379  assert((SHIFT + numberOfSamples_) <= SAMPLES.size());
380 
381  // Try to find the HFDetails from the map corresponding to our samples
382  const HcalTrigTowerDetId detId(SAMPLES.id());
383  HFDetailMap::const_iterator it = theHFDetailMap.find(detId);
384  // Missing values will give an empty digi
385  if (it == theHFDetailMap.end()) {
386  return;
387  }
388 
389  std::vector<bool> finegrain(numberOfSamples_, false);
390 
391  // Set up out output of IntergerCaloSamples
393  output.setPresamples(numberOfPresamples_);
394 
395  for (const auto& item: it->second) {
396  auto& details = item.second;
397  for (int ibin = 0; ibin < numberOfSamples_; ++ibin) {
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];
402  }
403  int short_fiber_val = 0;
404  if (IDX < details.short_fiber.size()) {
405  short_fiber_val = details.short_fiber[IDX];
406  }
407  output[ibin] += (long_fiber_val + short_fiber_val);
408 
409  uint32_t ADCLong = details.LongDigi[ibin].adc();
410  uint32_t ADCShort = details.ShortDigi[ibin].adc();
411 
412  if(FG_MinimumBias_) {
413  finegrain[ibin] = (finegrain[ibin] || ADCLong > FG_threshold_ || ADCShort > FG_threshold_);
414  }
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()));
417  }
418  }
419  }
420 
421  for (int bin = 0; bin < numberOfSamples_; ++bin) {
422  static const unsigned int MAX_OUTPUT = 0x3FF; // 0x3FF = 1023
423  output[bin] = min({MAX_OUTPUT, output[bin] >> HF_LUMI_SHIFT});
424  }
425  outcoder_->compress(output, finegrain, result);
426 
427 }
int presamples() const
access presample information
assert(m_qm.get())
const HcalTPGCompressor * outcoder_
int size() const
get the size
T min(T a, T b)
Definition: MathUtil.h:58
virtual bool fineGrainbit(int ADCShort, HcalDetId Sid, int CapIdS, int ADCLong, HcalDetId Lid, int CapIdL) const
void compress(const IntegerCaloSamples &ics, const std::vector< bool > &fineGrain, HcalTriggerPrimitiveDigi &digi) const
DetId id() const
get the (generic) id
void HcalTriggerPrimitiveAlgo::run ( const HcalTPGCoder incoder,
const HcalTPGCompressor outcoder,
const HBHEDigiCollection hbheDigis,
const HFDigiCollection hfDigis,
HcalTrigPrimDigiCollection result,
const HcalTrigTowerGeometry trigTowerGeometry,
float  rctlsb,
const HcalFeatureBit LongvrsShortCut = 0 
)

Definition at line 49 of file HcalTriggerPrimitiveAlgo.cc.

References addSignal(), analyze(), analyzeHF(), analyzeHFV1(), edm::SortedCollection< T, SORT >::back(), edm::SortedCollection< T, SORT >::begin(), edm::SortedCollection< T, SORT >::end(), fgMap_, HcalTrigTowerGeometry::firstHFTower(), HF_Veto, incoder_, LongvrsShortCut, NCTScaleShift, outcoder_, edm::SortedCollection< T, SORT >::push_back(), RCTScaleShift, theHFDetailMap, theSumMap, theTowerMapFGSum, and theTrigTowerGeometry.

Referenced by HcalTrigPrimDigiProducer::produce().

55  {
56  theTrigTowerGeometry = trigTowerGeometry;
57 
58  incoder_=dynamic_cast<const HcaluLUTTPGCoder*>(incoder);
59  outcoder_=outcoder;
60 
61  theSumMap.clear();
62  theTowerMapFGSum.clear();
63  HF_Veto.clear();
64  fgMap_.clear();
65  theHFDetailMap.clear();
66 
67  // do the HB/HE digis
68  for(HBHEDigiCollection::const_iterator hbheItr = hbheDigis.begin();
69  hbheItr != hbheDigis.end(); ++hbheItr) {
70  addSignal(*hbheItr);
71  }
72 
73  // and the HF digis
74  for(HFDigiCollection::const_iterator hfItr = hfDigis.begin();
75  hfItr != hfDigis.end(); ++hfItr) {
76  addSignal(*hfItr);
77 
78  }
79 
80  // VME produces additional bits on the front used by lumi but not the
81  // trigger, this shift corrects those out by right shifting over them.
82  for(SumMap::iterator mapItr = theSumMap.begin(); mapItr != theSumMap.end(); ++mapItr) {
83  result.push_back(HcalTriggerPrimitiveDigi(mapItr->first));
84  HcalTrigTowerDetId detId(mapItr->second.id());
85  if(detId.ietaAbs() >= theTrigTowerGeometry->firstHFTower(detId.version())) {
86  if (detId.version() == 0) {
87  analyzeHF(mapItr->second, result.back(), RCTScaleShift);
88  } else if (detId.version() == 1) {
89  analyzeHFV1(mapItr->second, result.back(), NCTScaleShift, LongvrsShortCut);
90  } else {
91  // Things are going to go poorly
92  }
93  }
94  else {
95  analyze(mapItr->second, result.back());
96  }
97  }
98 
99  // Free up some memory
100  theSumMap.clear();
101  theTowerMapFGSum.clear();
102  HF_Veto.clear();
103  fgMap_.clear();
104  theHFDetailMap.clear();
105 
106  return;
107 }
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 analyzeHF(IntegerCaloSamples &samples, HcalTriggerPrimitiveDigi &result, const int hf_lumi_shift)
std::vector< HBHEDataFrame >::const_iterator const_iterator
void push_back(T const &t)
const HcalTPGCompressor * outcoder_
const HcalTrigTowerGeometry * theTrigTowerGeometry
const_iterator end() const
const HcaluLUTTPGCoder * incoder_
void addSignal(const HBHEDataFrame &frame)
adds the signal to the map
const_iterator begin() const
const_reference back() const
int firstHFTower(int version) const
void HcalTriggerPrimitiveAlgo::runFEFormatError ( const FEDRawDataCollection rawraw,
const HcalElectronicsMap emap,
HcalTrigPrimDigiCollection result 
)

Definition at line 443 of file HcalTriggerPrimitiveAlgo.cc.

References edm::SortedCollection< T, SORT >::begin(), HcalHTRData::check(), FEDRawData::data(), DetId::det(), edm::SortedCollection< T, SORT >::end(), FEDRawDataCollection::FEDData(), HcalHTRData::getErrorsWord(), HcalDCCHeader::getSourceId(), HcalDCCHeader::getSpigotData(), HcalDCCHeader::getSpigotPresent(), HcalBarrel, HcalEndcap, HcalForward, HcalHTRData::htrSlot(), HcalHTRData::htrTopBottom(), i, HcalHTRData::isHistogramEvent(), HcalElectronicsMap::lookup(), FEDNumbering::MAXHCALFEDID, FEDNumbering::MINHCALFEDID, DetId::null(), HcalHTRData::readoutVMECrateId(), HcalElectronicsId::setHTR(), FEDRawData::size(), HcalDCCHeader::SPIGOT_COUNT, DetId::subdetId(), theTrigTowerGeometry, and HcalTrigTowerGeometry::towerIds().

Referenced by HcalTrigPrimDigiProducer::produce().

446  {
447  std::set<uint32_t> FrontEndErrors;
448 
450  const FEDRawData& raw = rawraw->FEDData(i);
451  if (raw.size()<12) continue;
452  const HcalDCCHeader* dccHeader=(const HcalDCCHeader*)(raw.data());
453  if(!dccHeader) continue;
454  HcalHTRData htr;
455  for (int spigot=0; spigot<HcalDCCHeader::SPIGOT_COUNT; spigot++) {
456  if (!dccHeader->getSpigotPresent(spigot)) continue;
457  dccHeader->getSpigotData(spigot,htr,raw.size());
458  int dccid = dccHeader->getSourceId();
459  int errWord = htr.getErrorsWord() & 0x1FFFF;
460  bool HTRError = (!htr.check() || htr.isHistogramEvent() || (errWord & 0x800)!=0);
461 
462  if(HTRError) {
463  bool valid =false;
464  for(int fchan=0; fchan<3 && !valid; fchan++) {
465  for(int fib=0; fib<9 && !valid; fib++) {
466  HcalElectronicsId eid(fchan,fib,spigot,dccid-FEDNumbering::MINHCALFEDID);
467  eid.setHTR(htr.readoutVMECrateId(),htr.htrSlot(),htr.htrTopBottom());
468  DetId detId = emap->lookup(eid);
469  if(detId.null()) continue;
470  HcalSubdetector subdet=(HcalSubdetector(detId.subdetId()));
471  if (detId.det()!=4||
472  (subdet!=HcalBarrel && subdet!=HcalEndcap &&
473  subdet!=HcalForward )) continue;
474  std::vector<HcalTrigTowerDetId> ids = theTrigTowerGeometry->towerIds(detId);
475  for (std::vector<HcalTrigTowerDetId>::const_iterator triggerId=ids.begin(); triggerId != ids.end(); ++triggerId) {
476  FrontEndErrors.insert(triggerId->rawId());
477  }
478  //valid = true;
479  }
480  }
481  }
482  }
483  }
484 
485  // Loop over TP collection
486  // Set TP to zero if there is FE Format Error
487  HcalTriggerPrimitiveSample zeroSample(0);
488  for (HcalTrigPrimDigiCollection::iterator tp = result.begin(); tp != result.end(); ++tp){
489  if (FrontEndErrors.find(tp->id().rawId()) != FrontEndErrors.end()) {
490  for (int i=0; i<tp->size(); ++i) tp->setSample(i, zeroSample);
491  }
492  }
493 }
int i
Definition: DBlmapReader.cc:9
bool check() const
Check for a good event Requires a minimum length, matching wordcount and length, not an empty event...
Definition: HcalHTRData.cc:62
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)
Definition: HcalHTRData.cc:342
int getSpigotData(int nspigot, HcalHTRData &decodeTool, int validSize) const
size_t size() const
Lenght of the data buffer in bytes.
Definition: FEDRawData.h:47
unsigned int htrSlot() const
HcalElectronicsId-style HTR slot.
Definition: HcalHTRData.cc:338
const HcalTrigTowerGeometry * theTrigTowerGeometry
const FEDRawData & FEDData(int fedid) const
retrieve data for fed
HcalSubdetector
Definition: HcalAssistant.h:31
bool getSpigotPresent(unsigned int nspigot) const
Read the &quot;PRESENT&quot; bit for this spigot.
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
std::vector< HcalTriggerPrimitiveDigi >::iterator iterator
const_iterator end() const
int getSourceId() const
Definition: HcalDCCHeader.h:32
Definition: DetId.h:18
unsigned int getErrorsWord() const
Get the errors word.
Definition: HcalHTRData.h:157
bool null() const
is this a null id ?
Definition: DetId.h:45
unsigned int readoutVMECrateId() const
HcalElectronicsId-style VME crate number.
Definition: HcalHTRData.cc:346
static const int SPIGOT_COUNT
Definition: HcalDCCHeader.h:19
const unsigned char * data() const
Return a const pointer to the beginning of the data buffer.
Definition: FEDRawData.cc:28
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
Readout chain identification for Hcal.
const DetId lookup(HcalElectronicsId fId) const
lookup the logical detid associated with the given electronics id
bool isHistogramEvent() const
Is this event a histogram event? (do not call standard unpack in this case!!!!!)
Definition: HcalHTRData.cc:385
const_iterator begin() const
void HcalTriggerPrimitiveAlgo::runZS ( HcalTrigPrimDigiCollection tp)

Definition at line 429 of file HcalTriggerPrimitiveAlgo.cc.

References edm::SortedCollection< T, SORT >::begin(), edm::SortedCollection< T, SORT >::end(), i, and ZS_threshold_I_.

Referenced by HcalTrigPrimDigiProducer::produce().

429  {
430  for (HcalTrigPrimDigiCollection::iterator tp = result.begin(); tp != result.end(); ++tp){
431  bool ZS = true;
432  for (int i=0; i<tp->size(); ++i) {
433  if (tp->sample(i).compressedEt() > ZS_threshold_I_) {
434  ZS=false;
435  break;
436  }
437  }
438  if (ZS) tp->setZSInfo(false,true);
439  else tp->setZSInfo(true,false);
440  }
441 }
int i
Definition: DBlmapReader.cc:9
tuple result
Definition: mps_fire.py:83
std::vector< HcalTriggerPrimitiveDigi >::iterator iterator
size_type size() const
void HcalTriggerPrimitiveAlgo::setNCTScaleShift ( int  shift)

Definition at line 511 of file HcalTriggerPrimitiveAlgo.cc.

References NCTScaleShift, and edm::shift.

Referenced by HcalTrigPrimDigiProducer::HcalTrigPrimDigiProducer().

511  {
513 }
static unsigned int const shift
void HcalTriggerPrimitiveAlgo::setPeakFinderAlgorithm ( int  algo)

Definition at line 505 of file HcalTriggerPrimitiveAlgo.cc.

References ecalcalib_dqm_sourceclient-live_cfg::algo, Exception, and peak_finder_algorithm_.

Referenced by HcalTrigPrimDigiProducer::HcalTrigPrimDigiProducer().

505  {
506  if (algo <=0 && algo>2)
507  throw cms::Exception("ERROR: Only algo 1 & 2 are supported.") << std::endl;
509 }
void HcalTriggerPrimitiveAlgo::setRCTScaleShift ( int  shift)

Definition at line 515 of file HcalTriggerPrimitiveAlgo.cc.

References RCTScaleShift, and edm::shift.

Referenced by HcalTrigPrimDigiProducer::HcalTrigPrimDigiProducer().

515  {
517 }
static unsigned int const shift

Member Data Documentation

bool HcalTriggerPrimitiveAlgo::FG_MinimumBias_
private

Definition at line 74 of file HcalTriggerPrimitiveAlgo.h.

Referenced by analyzeHFV1().

uint32_t HcalTriggerPrimitiveAlgo::FG_threshold_
private

Definition at line 75 of file HcalTriggerPrimitiveAlgo.h.

Referenced by analyzeHF(), and analyzeHFV1().

FGbitMap HcalTriggerPrimitiveAlgo::fgMap_
private

Definition at line 128 of file HcalTriggerPrimitiveAlgo.h.

Referenced by addFG(), analyze(), and run().

TowerMapVeto HcalTriggerPrimitiveAlgo::HF_Veto
private

Definition at line 125 of file HcalTriggerPrimitiveAlgo.h.

Referenced by addSignal(), analyzeHF(), and run().

const HcaluLUTTPGCoder* HcalTriggerPrimitiveAlgo::incoder_
private

Definition at line 68 of file HcalTriggerPrimitiveAlgo.h.

Referenced by addSignal(), and run().

int HcalTriggerPrimitiveAlgo::latency_
private

Definition at line 73 of file HcalTriggerPrimitiveAlgo.h.

HcalFeatureBit* HcalTriggerPrimitiveAlgo::LongvrsShortCut
private

Definition at line 123 of file HcalTriggerPrimitiveAlgo.h.

Referenced by run().

uint32_t HcalTriggerPrimitiveAlgo::minSignalThreshold_
private

Definition at line 82 of file HcalTriggerPrimitiveAlgo.h.

Referenced by addSignal().

int HcalTriggerPrimitiveAlgo::NCTScaleShift
private

Definition at line 84 of file HcalTriggerPrimitiveAlgo.h.

Referenced by run(), and setNCTScaleShift().

int HcalTriggerPrimitiveAlgo::numberOfPresamples_
private

Definition at line 79 of file HcalTriggerPrimitiveAlgo.h.

Referenced by analyze(), analyzeHFV1(), and HcalTriggerPrimitiveAlgo().

int HcalTriggerPrimitiveAlgo::numberOfPresamplesHF_
private

Definition at line 81 of file HcalTriggerPrimitiveAlgo.h.

Referenced by analyzeHF(), and HcalTriggerPrimitiveAlgo().

int HcalTriggerPrimitiveAlgo::numberOfSamples_
private

Definition at line 78 of file HcalTriggerPrimitiveAlgo.h.

Referenced by analyze(), analyzeHFV1(), and HcalTriggerPrimitiveAlgo().

int HcalTriggerPrimitiveAlgo::numberOfSamplesHF_
private

Definition at line 80 of file HcalTriggerPrimitiveAlgo.h.

Referenced by analyzeHF(), and HcalTriggerPrimitiveAlgo().

const HcalTPGCompressor* HcalTriggerPrimitiveAlgo::outcoder_
private

Definition at line 69 of file HcalTriggerPrimitiveAlgo.h.

Referenced by analyze(), analyzeHF(), analyzeHFV1(), and run().

int HcalTriggerPrimitiveAlgo::peak_finder_algorithm_
private

Definition at line 91 of file HcalTriggerPrimitiveAlgo.h.

Referenced by analyze(), and setPeakFinderAlgorithm().

bool HcalTriggerPrimitiveAlgo::peakfind_
private

Definition at line 71 of file HcalTriggerPrimitiveAlgo.h.

Referenced by analyze(), and HcalTriggerPrimitiveAlgo().

uint32_t HcalTriggerPrimitiveAlgo::PMT_NoiseThreshold_
private

Definition at line 83 of file HcalTriggerPrimitiveAlgo.h.

Referenced by analyzeHF().

int HcalTriggerPrimitiveAlgo::RCTScaleShift
private

Definition at line 85 of file HcalTriggerPrimitiveAlgo.h.

Referenced by run(), and setRCTScaleShift().

HFDetailMap HcalTriggerPrimitiveAlgo::theHFDetailMap
private

Definition at line 108 of file HcalTriggerPrimitiveAlgo.h.

Referenced by addSignal(), analyzeHFV1(), and run().

SumMap HcalTriggerPrimitiveAlgo::theSumMap
private

Definition at line 99 of file HcalTriggerPrimitiveAlgo.h.

Referenced by addSignal(), and run().

double HcalTriggerPrimitiveAlgo::theThreshold
private

Definition at line 70 of file HcalTriggerPrimitiveAlgo.h.

Referenced by analyze().

TowerMapFGSum HcalTriggerPrimitiveAlgo::theTowerMapFGSum
private

Definition at line 112 of file HcalTriggerPrimitiveAlgo.h.

Referenced by addSignal(), analyzeHF(), and run().

const HcalTrigTowerGeometry* HcalTriggerPrimitiveAlgo::theTrigTowerGeometry
private

Definition at line 96 of file HcalTriggerPrimitiveAlgo.h.

Referenced by addSignal(), run(), and runFEFormatError().

std::vector<double> HcalTriggerPrimitiveAlgo::weights_
private

Definition at line 72 of file HcalTriggerPrimitiveAlgo.h.

Referenced by analyze().

uint32_t HcalTriggerPrimitiveAlgo::ZS_threshold_
private

Definition at line 76 of file HcalTriggerPrimitiveAlgo.h.

Referenced by HcalTriggerPrimitiveAlgo().

int HcalTriggerPrimitiveAlgo::ZS_threshold_I_
private

Definition at line 77 of file HcalTriggerPrimitiveAlgo.h.

Referenced by HcalTriggerPrimitiveAlgo(), and runZS().