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, 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 setPeakFinderAlgorithm (int algo)
 
 ~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

uint32_t FG_threshold_
 
FGbitMap fgMap_
 
TowerMapVeto HF_Veto
 
const HcaluLUTTPGCoderincoder_
 
int latency_
 
HcalFeatureBitLongvrsShortCut
 
uint32_t minSignalThreshold_
 
int numberOfPresamples_
 
int numberOfPresamplesHF_
 
int numberOfSamples_
 
int numberOfSamplesHF_
 
const HcalTPGCompressoroutcoder_
 
int peak_finder_algorithm_
 
bool peakfind_
 
uint32_t PMT_NoiseThreshold_
 
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 121 of file HcalTriggerPrimitiveAlgo.h.

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

Definition at line 101 of file HcalTriggerPrimitiveAlgo.h.

Definition at line 104 of file HcalTriggerPrimitiveAlgo.h.

Definition at line 92 of file HcalTriggerPrimitiveAlgo.h.

Definition at line 105 of file HcalTriggerPrimitiveAlgo.h.

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

Definition at line 118 of file HcalTriggerPrimitiveAlgo.h.

Constructor & Destructor Documentation

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

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

Definition at line 44 of file HcalTriggerPrimitiveAlgo.cc.

44  {
45 }

Member Function Documentation

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

Definition at line 497 of file HcalTriggerPrimitiveAlgo.cc.

References fgMap_, and i.

Referenced by addSignal().

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

adds the signal to the map

Definition at line 115 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().

115  {
116  // TODO: Need to add support for seperate 28, 29 in HE
117  //Hack for 300_pre10, should be removed.
118  if (frame.id().depth()==5) return;
119 
120  std::vector<HcalTrigTowerDetId> ids = theTrigTowerGeometry->towerIds(frame.id());
121  assert(ids.size() == 1 || ids.size() == 2);
122  IntegerCaloSamples samples1(ids[0], int(frame.size()));
123 
124  samples1.setPresamples(frame.presamples());
125  incoder_->adc2Linear(frame, samples1);
126 
127  std::vector<bool> msb;
128  incoder_->lookupMSB(frame, msb);
129 
130  if(ids.size() == 2) {
131  // make a second trigprim for the other one, and split the energy
132  IntegerCaloSamples samples2(ids[1], samples1.size());
133  for(int i = 0; i < samples1.size(); ++i) {
134  samples1[i] = uint32_t(samples1[i]*0.5);
135  samples2[i] = samples1[i];
136  }
137  samples2.setPresamples(frame.presamples());
138  addSignal(samples2);
139  addFG(ids[1], msb);
140  }
141  addSignal(samples1);
142  addFG(ids[0], msb);
143 }
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 146 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().

146  {
147  if(frame.id().depth() == 1 || frame.id().depth() == 2) {
148  std::vector<HcalTrigTowerDetId> ids = theTrigTowerGeometry->towerIds(frame.id());
149  std::vector<HcalTrigTowerDetId>::const_iterator it;
150  for (it = ids.begin(); it != ids.end(); ++it) {
151  HcalTrigTowerDetId trig_tower_id = *it;
152  IntegerCaloSamples samples(trig_tower_id, frame.size());
153  samples.setPresamples(frame.presamples());
154  incoder_->adc2Linear(frame, samples);
155 
156  // Don't add to final collection yet
157  // HF PMT veto sum is calculated in analyzerHF()
158  IntegerCaloSamples zero_samples(trig_tower_id, frame.size());
159  zero_samples.setPresamples(frame.presamples());
160  addSignal(zero_samples);
161 
162  // Pre-LS1 Configuration
163  if (trig_tower_id.version() == 0) {
164  // Mask off depths: fgid is the same for both depths
165  uint32_t fgid = (frame.id().maskDepth());
166 
167  if ( theTowerMapFGSum.find(trig_tower_id) == theTowerMapFGSum.end() ) {
168  SumFGContainer sumFG;
169  theTowerMapFGSum.insert(std::pair<HcalTrigTowerDetId, SumFGContainer>(trig_tower_id, sumFG));
170  }
171 
172  SumFGContainer& sumFG = theTowerMapFGSum[trig_tower_id];
173  SumFGContainer::iterator sumFGItr;
174  for ( sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
175  if (sumFGItr->id() == fgid) { break; }
176  }
177  // If find
178  if (sumFGItr != sumFG.end()) {
179  for (int i=0; i<samples.size(); ++i) {
180  (*sumFGItr)[i] += samples[i];
181  }
182  }
183  else {
184  //Copy samples (change to fgid)
185  IntegerCaloSamples sumFGSamples(DetId(fgid), samples.size());
186  sumFGSamples.setPresamples(samples.presamples());
187  for (int i=0; i<samples.size(); ++i) {
188  sumFGSamples[i] = samples[i];
189  }
190  sumFG.push_back(sumFGSamples);
191  }
192 
193  // set veto to true if Long or Short less than threshold
194  if (HF_Veto.find(fgid) == HF_Veto.end()) {
195  vector<bool> vetoBits(samples.size(), false);
196  HF_Veto[fgid] = vetoBits;
197  }
198  for (int i=0; i<samples.size(); ++i) {
199  if (samples[i] < minSignalThreshold_) {
200  HF_Veto[fgid][i] = true;
201  }
202  }
203  }
204  // HF 1x1
205  else if (trig_tower_id.version() == 1) {
206  uint32_t fgid = (frame.id().maskDepth());
207  HFDetails& details = theHFDetailMap[trig_tower_id][fgid];
208  // Check the frame type to determine long vs short
209  if (frame.id().depth() == 1) { // Long
210  details.long_fiber = samples;
211  details.LongDigi = frame;
212  } else if (frame.id().depth() == 2) { // Short
213  details.short_fiber = samples;
214  details.ShortDigi = frame;
215  } else {
216  // Neither long nor short... So we have no idea what to do
217  edm::LogWarning("HcalTPAlgo") << "Unable to figure out what to do with data frame for " << frame.id();
218  return;
219  }
220  }
221  // Uh oh, we are in a bad/unknown state! Things will start crashing.
222  else {
223  return;
224  }
225  }
226  }
227 }
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 230 of file HcalTriggerPrimitiveAlgo.cc.

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

230  {
231  HcalTrigTowerDetId id(samples.id());
232  SumMap::iterator itr = theSumMap.find(id);
233  if(itr == theSumMap.end()) {
234  theSumMap.insert(std::make_pair(id, samples));
235  }
236  else {
237  // wish CaloSamples had a +=
238  for(int i = 0; i < samples.size(); ++i) {
239  (itr->second)[i] += samples[i];
240  }
241  }
242 }
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 245 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().

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

325  {
326  HcalTrigTowerDetId detId(samples.id());
327 
328  // Align digis and TP
329  int dgPresamples=samples.presamples();
330  int tpPresamples=numberOfPresamplesHF_;
331  int shift = dgPresamples - tpPresamples;
332  int dgSamples=samples.size();
333  int tpSamples=numberOfSamplesHF_;
334  if(shift<0 || shift+tpSamples>dgSamples){
335  edm::LogInfo("HcalTriggerPrimitiveAlgo::analyzeHF") <<
336  "TP presample or size from the configuration file is out of the accessible range. Using digi values from data instead...";
337  tpPresamples=dgPresamples;
338  shift=0;
339  tpSamples=dgSamples;
340  }
341 
342  std::vector<bool> finegrain(tpSamples, false);
343 
344  TowerMapFGSum::const_iterator tower2fg = theTowerMapFGSum.find(detId);
345  assert(tower2fg != theTowerMapFGSum.end());
346 
347  const SumFGContainer& sumFG = tower2fg->second;
348  // Loop over all L+S pairs that mapped from samples.id()
349  // Note: 1 samples.id() = 6 x (L+S) without noZS
350  for (SumFGContainer::const_iterator sumFGItr = sumFG.begin(); sumFGItr != sumFG.end(); ++sumFGItr) {
351  const std::vector<bool>& veto = HF_Veto[sumFGItr->id().rawId()];
352  for (int ibin = 0; ibin < tpSamples; ++ibin) {
353  int idx = ibin + shift;
354  // if not vetod, add L+S to total sum and calculate FG
355  bool vetoed = idx<int(veto.size()) && veto[idx];
356  if (!(vetoed && (*sumFGItr)[idx] > PMT_NoiseThreshold_)) {
357  samples[idx] += (*sumFGItr)[idx];
358  finegrain[ibin] = (finegrain[ibin] || (*sumFGItr)[idx] >= FG_threshold_);
359  }
360  }
361  }
362 
363  IntegerCaloSamples output(samples.id(), tpSamples);
364  output.setPresamples(tpPresamples);
365 
366  for (int ibin = 0; ibin < tpSamples; ++ibin) {
367  int idx = ibin + shift;
368  output[ibin] = samples[idx] >> hf_lumi_shift;
369  static const int MAX_OUTPUT = 0x3FF; // 0x3FF = 1023
370  if (output[ibin] > MAX_OUTPUT) output[ibin] = MAX_OUTPUT;
371  }
372  outcoder_->compress(output, finegrain, result);
373 }
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 375 of file HcalTriggerPrimitiveAlgo.cc.

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

Referenced by run().

380  {
381  // Align digis and TP
382  const int SHIFT = SAMPLES.presamples() - numberOfPresamples_;
383  assert(SHIFT >= 0);
384  assert((SHIFT + numberOfSamples_) <= SAMPLES.size());
385 
386  // Try to find the HFDetails from the map corresponding to our samples
387  const HcalTrigTowerDetId detId(SAMPLES.id());
388  HFDetailMap::const_iterator it = theHFDetailMap.find(detId);
389  // Missing values will give an empty digi
390  if (it == theHFDetailMap.end()) {
391  return;
392  }
393 
394  std::vector<bool> finegrain(numberOfSamples_, false);
395 
396  // Set up out output of IntergerCaloSamples
398  output.setPresamples(numberOfPresamples_);
399 
400  for (const auto& item: it->second) {
401  auto& details = item.second;
402  for (int ibin = 0; ibin < numberOfSamples_; ++ibin) {
403  const int IDX = ibin + SHIFT;
404  int long_fiber_val = 0;
405  if (IDX < details.long_fiber.size()) {
406  long_fiber_val = details.long_fiber[IDX];
407  }
408  int short_fiber_val = 0;
409  if (IDX < details.short_fiber.size()) {
410  short_fiber_val = details.short_fiber[IDX];
411  }
412  output[ibin] += (long_fiber_val + short_fiber_val);
413 
414  int ADCLong = details.LongDigi[ibin].adc();
415  int ADCShort = details.ShortDigi[ibin].adc();
416  if(HCALFEM != 0)
417  {
418  finegrain[ibin] = (finegrain[ibin] || HCALFEM->fineGrainbit(ADCShort, details.ShortDigi.id(), details.ShortDigi[ibin].capid(), ADCLong, details.LongDigi.id(), details.LongDigi[ibin].capid()));
419  }
420  }
421  }
422 
423  for (int bin = 0; bin < numberOfSamples_; ++bin) {
424  static const unsigned int MAX_OUTPUT = 0x3FF; // 0x3FF = 1023
425  output[bin] = min({MAX_OUTPUT, output[bin] >> HF_LUMI_SHIFT});
426  }
427  outcoder_->compress(output, finegrain, result);
428 
429 }
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 48 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, outcoder_, edm::SortedCollection< T, SORT >::push_back(), theHFDetailMap, theSumMap, theTowerMapFGSum, and theTrigTowerGeometry.

Referenced by HcalTrigPrimDigiProducer::produce().

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

448  {
449  std::set<uint32_t> FrontEndErrors;
450 
452  const FEDRawData& raw = rawraw->FEDData(i);
453  if (raw.size()<12) continue;
454  const HcalDCCHeader* dccHeader=(const HcalDCCHeader*)(raw.data());
455  if(!dccHeader) continue;
456  HcalHTRData htr;
457  for (int spigot=0; spigot<HcalDCCHeader::SPIGOT_COUNT; spigot++) {
458  if (!dccHeader->getSpigotPresent(spigot)) continue;
459  dccHeader->getSpigotData(spigot,htr,raw.size());
460  int dccid = dccHeader->getSourceId();
461  int errWord = htr.getErrorsWord() & 0x1FFFF;
462  bool HTRError = (!htr.check() || htr.isHistogramEvent() || (errWord & 0x800)!=0);
463 
464  if(HTRError) {
465  bool valid =false;
466  for(int fchan=0; fchan<3 && !valid; fchan++) {
467  for(int fib=0; fib<9 && !valid; fib++) {
468  HcalElectronicsId eid(fchan,fib,spigot,dccid-FEDNumbering::MINHCALFEDID);
469  eid.setHTR(htr.readoutVMECrateId(),htr.htrSlot(),htr.htrTopBottom());
470  DetId detId = emap->lookup(eid);
471  if(detId.null()) continue;
472  HcalSubdetector subdet=(HcalSubdetector(detId.subdetId()));
473  if (detId.det()!=4||
474  (subdet!=HcalBarrel && subdet!=HcalEndcap &&
475  subdet!=HcalForward )) continue;
476  std::vector<HcalTrigTowerDetId> ids = theTrigTowerGeometry->towerIds(detId);
477  for (std::vector<HcalTrigTowerDetId>::const_iterator triggerId=ids.begin(); triggerId != ids.end(); ++triggerId) {
478  FrontEndErrors.insert(triggerId->rawId());
479  }
480  //valid = true;
481  }
482  }
483  }
484  }
485  }
486 
487  // Loop over TP collection
488  // Set TP to zero if there is FE Format Error
489  HcalTriggerPrimitiveSample zeroSample(0);
490  for (HcalTrigPrimDigiCollection::iterator tp = result.begin(); tp != result.end(); ++tp){
491  if (FrontEndErrors.find(tp->id().rawId()) != FrontEndErrors.end()) {
492  for (int i=0; i<tp->size(); ++i) tp->setSample(i, zeroSample);
493  }
494  }
495 }
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 431 of file HcalTriggerPrimitiveAlgo.cc.

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

Referenced by HcalTrigPrimDigiProducer::produce().

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

Definition at line 507 of file HcalTriggerPrimitiveAlgo.cc.

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

Referenced by HcalTrigPrimDigiProducer::HcalTrigPrimDigiProducer().

507  {
508  if (algo <=0 && algo>2)
509  throw cms::Exception("ERROR: Only algo 1 & 2 are supported.") << std::endl;
511 }

Member Data Documentation

uint32_t HcalTriggerPrimitiveAlgo::FG_threshold_
private

Definition at line 71 of file HcalTriggerPrimitiveAlgo.h.

Referenced by analyzeHF().

FGbitMap HcalTriggerPrimitiveAlgo::fgMap_
private

Definition at line 122 of file HcalTriggerPrimitiveAlgo.h.

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

TowerMapVeto HcalTriggerPrimitiveAlgo::HF_Veto
private

Definition at line 119 of file HcalTriggerPrimitiveAlgo.h.

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

const HcaluLUTTPGCoder* HcalTriggerPrimitiveAlgo::incoder_
private

Definition at line 65 of file HcalTriggerPrimitiveAlgo.h.

Referenced by addSignal(), and run().

int HcalTriggerPrimitiveAlgo::latency_
private

Definition at line 70 of file HcalTriggerPrimitiveAlgo.h.

HcalFeatureBit* HcalTriggerPrimitiveAlgo::LongvrsShortCut
private

Definition at line 117 of file HcalTriggerPrimitiveAlgo.h.

Referenced by run().

uint32_t HcalTriggerPrimitiveAlgo::minSignalThreshold_
private

Definition at line 78 of file HcalTriggerPrimitiveAlgo.h.

Referenced by addSignal().

int HcalTriggerPrimitiveAlgo::numberOfPresamples_
private

Definition at line 75 of file HcalTriggerPrimitiveAlgo.h.

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

int HcalTriggerPrimitiveAlgo::numberOfPresamplesHF_
private

Definition at line 77 of file HcalTriggerPrimitiveAlgo.h.

Referenced by analyzeHF(), and HcalTriggerPrimitiveAlgo().

int HcalTriggerPrimitiveAlgo::numberOfSamples_
private

Definition at line 74 of file HcalTriggerPrimitiveAlgo.h.

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

int HcalTriggerPrimitiveAlgo::numberOfSamplesHF_
private

Definition at line 76 of file HcalTriggerPrimitiveAlgo.h.

Referenced by analyzeHF(), and HcalTriggerPrimitiveAlgo().

const HcalTPGCompressor* HcalTriggerPrimitiveAlgo::outcoder_
private

Definition at line 66 of file HcalTriggerPrimitiveAlgo.h.

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

int HcalTriggerPrimitiveAlgo::peak_finder_algorithm_
private

Definition at line 85 of file HcalTriggerPrimitiveAlgo.h.

Referenced by analyze(), and setPeakFinderAlgorithm().

bool HcalTriggerPrimitiveAlgo::peakfind_
private

Definition at line 68 of file HcalTriggerPrimitiveAlgo.h.

Referenced by analyze(), and HcalTriggerPrimitiveAlgo().

uint32_t HcalTriggerPrimitiveAlgo::PMT_NoiseThreshold_
private

Definition at line 79 of file HcalTriggerPrimitiveAlgo.h.

Referenced by analyzeHF().

HFDetailMap HcalTriggerPrimitiveAlgo::theHFDetailMap
private

Definition at line 102 of file HcalTriggerPrimitiveAlgo.h.

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

SumMap HcalTriggerPrimitiveAlgo::theSumMap
private

Definition at line 93 of file HcalTriggerPrimitiveAlgo.h.

Referenced by addSignal(), and run().

double HcalTriggerPrimitiveAlgo::theThreshold
private

Definition at line 67 of file HcalTriggerPrimitiveAlgo.h.

Referenced by analyze().

TowerMapFGSum HcalTriggerPrimitiveAlgo::theTowerMapFGSum
private

Definition at line 106 of file HcalTriggerPrimitiveAlgo.h.

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

const HcalTrigTowerGeometry* HcalTriggerPrimitiveAlgo::theTrigTowerGeometry
private

Definition at line 90 of file HcalTriggerPrimitiveAlgo.h.

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

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

Definition at line 69 of file HcalTriggerPrimitiveAlgo.h.

Referenced by analyze().

uint32_t HcalTriggerPrimitiveAlgo::ZS_threshold_
private

Definition at line 72 of file HcalTriggerPrimitiveAlgo.h.

Referenced by HcalTriggerPrimitiveAlgo().

int HcalTriggerPrimitiveAlgo::ZS_threshold_I_
private

Definition at line 73 of file HcalTriggerPrimitiveAlgo.h.

Referenced by HcalTriggerPrimitiveAlgo(), and runZS().