CMS 3D CMS Logo

HcalTriggerPrimitiveAlgo.h
Go to the documentation of this file.
1 #ifndef HcalSimAlgos_HcalTriggerPrimitiveAlgo_h
2 #define HcalSimAlgos_HcalTriggerPrimitiveAlgo_h
3 
6 
11 
13 
15 
18 
19 #include <map>
20 #include <vector>
21 
22 class CaloGeometry;
23 class IntegerCaloSamples;
24 
26 public:
27  HcalTriggerPrimitiveAlgo(bool pf, const std::vector<double>& w, int latency,
28  uint32_t FG_threshold, uint32_t FG_HF_threshold, uint32_t ZS_threshold,
31  uint32_t minSignalThreshold=0, uint32_t PMT_NoiseThreshold=0);
33 
34  template<typename... Digis>
35  void run(const HcalTPGCoder* incoder,
36  const HcalTPGCompressor* outcoder,
37  const HcalDbService* conditions,
39  const HcalTrigTowerGeometry* trigTowerGeometry,
40  float rctlsb, const HcalFeatureBit* LongvrsShortCut,
41  const Digis&... digis);
42 
43  template<typename T, typename... Args>
44  void addDigis(const T& collection, const Args&... digis) {
45  addDigis(collection);
46  addDigis(digis...);
47  };
48 
49  template<typename T>
50  void addDigis(const T& collection) {
51  for (const auto& digi: collection) {
52  addSignal(digi);
53  }
54  };
55 
56  template<typename D>
58  for (auto i = collection.begin(); i != collection.end(); ++i) {
59  D digi(*i);
60  addSignal(digi);
61  }
62  };
63 
65  void runFEFormatError(const FEDRawDataCollection* rawraw,
66  const HcalElectronicsMap* emap,
68  void setPeakFinderAlgorithm(int algo);
69  void setNCTScaleShift(int);
70  void setRCTScaleShift(int);
71 
72  void setUpgradeFlags(bool hb, bool he, bool hf);
73  void overrideParameters(const edm::ParameterSet& ps);
74 
75  private:
76 
78  void addSignal(const HBHEDataFrame & frame);
79  void addSignal(const HFDataFrame & frame);
80  void addSignal(const QIE10DataFrame& frame);
81  void addSignal(const QIE11DataFrame& frame);
82  void addSignal(const IntegerCaloSamples & samples);
83  void addFG(const HcalTrigTowerDetId& id, std::vector<bool>& msb);
84  void addUpgradeFG(const HcalTrigTowerDetId& id, int depth, const std::vector<std::bitset<2>>& bits);
85 
86  bool validUpgradeFG(const HcalTrigTowerDetId& id, int depth) const;
87  bool validChannel(const QIE10DataFrame& digi, int ts) const;
88 
90  void analyze(IntegerCaloSamples & samples, HcalTriggerPrimitiveDigi & result);
91  // 2017: QIE11
92  void analyze2017(IntegerCaloSamples& samples, HcalTriggerPrimitiveDigi& result, const HcalFinegrainBit& fg_algo);
93  // Version 0: RCT
94  void analyzeHF(IntegerCaloSamples & samples, HcalTriggerPrimitiveDigi & result, const int hf_lumi_shift);
95  // Version 1: 1x1
96  void analyzeHF2016(
97  const IntegerCaloSamples& SAMPLES,
99  const int HF_LUMI_SHIFT,
100  const HcalFeatureBit* HCALFEM
101  );
102  // With dual anode readout
103  void analyzeHF2017(
104  const IntegerCaloSamples& SAMPLES,
105  HcalTriggerPrimitiveDigi& result,
106  const int HF_LUMI_SHIFT,
107  const HcalFeatureBit* HCALFEM
108  );
109 
110  // Member initialized by constructor
114  double theThreshold;
115  bool peakfind_;
116  std::vector<double> weights_;
117  int latency_;
118  uint32_t FG_threshold_;
120  uint32_t ZS_threshold_;
130 
131  // Algo1: isPeak = TS[i-1] < TS[i] && TS[i] >= TS[i+1]
132  // Algo2: isPeak = TSS[i-1] < TSS[i] && TSS[i] >= TSS[i+1],
133  // TSS[i] = TS[i] + TS[i+1]
134  // Default: Algo2
136 
137  // Member not initialzed
138  //std::vector<HcalTrigTowerDetId> towerIds(const HcalDetId & id) const;
139 
141 
142  typedef std::map<HcalTrigTowerDetId, IntegerCaloSamples> SumMap;
143  SumMap theSumMap;
144 
145  struct HFDetails {
150  };
151  typedef std::map<HcalTrigTowerDetId, std::map<uint32_t, HFDetails>> HFDetailMap;
152  HFDetailMap theHFDetailMap;
153 
157  std::vector<bool> validity;
158  std::vector<bool> fgbit;
159  };
160  typedef std::map<HcalTrigTowerDetId, std::map<uint32_t, std::array<HFUpgradeDetails, 4>>> HFUpgradeDetailMap;
161  HFUpgradeDetailMap theHFUpgradeDetailMap;
162 
163  typedef std::vector<IntegerCaloSamples> SumFGContainer;
164  typedef std::map< HcalTrigTowerDetId, SumFGContainer > TowerMapFGSum;
165  TowerMapFGSum theTowerMapFGSum;
166 
167  // ==============================
168  // = HF Veto
169  // ==============================
170  // Sum = Long + Short;" // intermediate calculation.
171  // if ((Short < MinSignalThresholdET OR Long < MinSignalThresholdET)
172  // AND Sum > PMTNoiseThresholdET) VetoedSum = 0;
173  // else VetoedSum = Sum;
174  // ==============================
175  // Map from FG id to veto booleans
177  typedef std::map<uint32_t, std::vector<bool> > TowerMapVeto;
178  TowerMapVeto HF_Veto;
179 
180  typedef std::map<HcalTrigTowerDetId, std::vector<bool> > FGbitMap;
181  FGbitMap fgMap_;
182 
183  typedef std::vector<HcalFinegrainBit::Tower> FGUpgradeContainer;
184  typedef std::map<HcalTrigTowerDetId, FGUpgradeContainer> FGUpgradeMap;
185  FGUpgradeMap fgUpgradeMap_;
186 
187  bool upgrade_hb_ = false;
188  bool upgrade_he_ = false;
189  bool upgrade_hf_ = false;
190 
192 
193  bool override_adc_hf_ = false;
195  bool override_tdc_hf_ = false;
196  unsigned long long override_tdc_hf_value_;
197 
198  // HE constants
199  static const int HBHE_OVERLAP_TOWER = 16;
200  static const int LAST_FINEGRAIN_DEPTH = 6;
201  static const int LAST_FINEGRAIN_TOWER = 28;
202 
203  // Fine-grain in HF ignores tower 29, and starts with 30
204  static const int FIRST_FINEGRAIN_TOWER = 30;
205 
209  // Consider CaloTPGTranscoderULUT.h for values
210  static const int QIE10_MAX_LINEARIZATION_ET = 0x7FF;
211  static const int QIE11_MAX_LINEARIZATION_ET = 0x7FF;
212 };
213 
214 template<typename... Digis>
216  const HcalTPGCompressor* outcoder,
217  const HcalDbService* conditions,
219  const HcalTrigTowerGeometry* trigTowerGeometry,
220  float rctlsb, const HcalFeatureBit* LongvrsShortCut,
221  const Digis&... digis) {
222  theTrigTowerGeometry = trigTowerGeometry;
223 
224  incoder_ = dynamic_cast<const HcaluLUTTPGCoder*>(incoder);
225  outcoder_ = outcoder;
226  conditions_ = conditions;
227 
228  theSumMap.clear();
229  theTowerMapFGSum.clear();
230  HF_Veto.clear();
231  fgMap_.clear();
232  fgUpgradeMap_.clear();
233  theHFDetailMap.clear();
234  theHFUpgradeDetailMap.clear();
235 
236  // Add all digi collections
237  addDigis(digis...);
238 
239  // Prepare the fine-grain calculation algorithm for HB/HE
240  int version = 0;
243  if (override_parameters_.exists("FGVersionHBHE"))
244  version = override_parameters_.getParameter<uint32_t>("FGVersionHBHE");
245  HcalFinegrainBit fg_algo(version);
246 
247  // VME produces additional bits on the front used by lumi but not the
248  // trigger, this shift corrects those out by right shifting over them.
249  for (auto& item: theSumMap) {
250  result.push_back(HcalTriggerPrimitiveDigi(item.first));
251  HcalTrigTowerDetId detId(item.second.id());
252  if(detId.ietaAbs() >= theTrigTowerGeometry->firstHFTower(detId.version())) {
253  if (detId.version() == 0) {
254  analyzeHF(item.second, result.back(), RCTScaleShift);
255  } else if (detId.version() == 1) {
256  if (upgrade_hf_)
257  analyzeHF2017(item.second, result.back(), NCTScaleShift, LongvrsShortCut);
258  else
259  analyzeHF2016(item.second, result.back(), NCTScaleShift, LongvrsShortCut);
260  } else {
261  // Things are going to go poorly
262  }
263  }
264  else {
265  // Determine which energy reconstruction path to take based on the
266  // fine-grain availability:
267  // * QIE8 TP add entries into fgMap_
268  // * QIE11 TP add entries into fgUpgradeMap_
269  // (not for tower 16 unless HB is upgraded, too)
270  if (fgMap_.find(item.first) != fgMap_.end()) {
271  analyze(item.second, result.back());
272  } else if (fgUpgradeMap_.find(item.first) != fgUpgradeMap_.end()) {
273  analyze2017(item.second, result.back(), fg_algo);
274  }
275  }
276  }
277 
278  // Free up some memory
279  theSumMap.clear();
280  theTowerMapFGSum.clear();
281  HF_Veto.clear();
282  fgMap_.clear();
283  fgUpgradeMap_.clear();
284  theHFDetailMap.clear();
285  theHFUpgradeDetailMap.clear();
286 
287  return;
288 }
289 
290 #endif
T getParameter(std::string const &) const
void analyze(IntegerCaloSamples &samples, HcalTriggerPrimitiveDigi &result)
adds the actual RecHits
void runFEFormatError(const FEDRawDataCollection *rawraw, const HcalElectronicsMap *emap, HcalTrigPrimDigiCollection &result)
std::map< uint32_t, std::vector< bool > > TowerMapVeto
HcalTriggerPrimitiveAlgo(bool pf, const std::vector< double > &w, int latency, uint32_t FG_threshold, uint32_t FG_HF_threshold, uint32_t ZS_threshold, int numberOfSamples, int numberOfPresamples, int numberOfSamplesHF, int numberOfPresamplesHF, uint32_t minSignalThreshold=0, uint32_t PMT_NoiseThreshold=0)
HFUpgradeDetailMap theHFUpgradeDetailMap
void analyzeHF(IntegerCaloSamples &samples, HcalTriggerPrimitiveDigi &result, const int hf_lumi_shift)
const double w
Definition: UKUtility.cc:23
static const int QIE10_MAX_LINEARIZATION_ET
void analyzeHF2016(const IntegerCaloSamples &SAMPLES, HcalTriggerPrimitiveDigi &result, const int HF_LUMI_SHIFT, const HcalFeatureBit *HCALFEM)
static const int QIE11_LUT_BITMASK
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision bits
bool exists(std::string const &parameterName) const
checks if a parameter exists
void push_back(T const &t)
const HcalTPGCompressor * outcoder_
std::map< HcalTrigTowerDetId, FGUpgradeContainer > FGUpgradeMap
void addFG(const HcalTrigTowerDetId &id, std::vector< bool > &msb)
const_iterator begin() const
static const int QIE8_LUT_BITMASK
numberOfSamples
threshold for setting fine grain bit
bool validChannel(const QIE10DataFrame &digi, int ts) const
std::vector< IntegerCaloSamples > SumFGContainer
const HcalTrigTowerGeometry * theTrigTowerGeometry
const HcalDbService * conditions_
void run(const HcalTPGCoder *incoder, const HcalTPGCompressor *outcoder, const HcalDbService *conditions, HcalTrigPrimDigiCollection &result, const HcalTrigTowerGeometry *trigTowerGeometry, float rctlsb, const HcalFeatureBit *LongvrsShortCut, const Digis &...digis)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
int getFGVersionHBHE() const
get FineGrain Algorithm Version for HBHE
void runZS(HcalTrigPrimDigiCollection &tp)
static const int QIE10_LUT_BITMASK
std::map< HcalTrigTowerDetId, std::vector< bool > > FGbitMap
std::vector< HcalFinegrainBit::Tower > FGUpgradeContainer
void addDigis(const T &collection, const Args &...digis)
void addDigis(const T &collection)
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:151
std::map< HcalTrigTowerDetId, SumFGContainer > TowerMapFGSum
unsigned long long override_tdc_hf_value_
bool validUpgradeFG(const HcalTrigTowerDetId &id, int depth) const
static const int QIE11_MAX_LINEARIZATION_ET
std::map< HcalTrigTowerDetId, IntegerCaloSamples > SumMap
const HcalTPParameters * getHcalTPParameters() const
ZS_threshold
threshold for setting fine grain bit
void addUpgradeFG(const HcalTrigTowerDetId &id, int depth, const std::vector< std::bitset< 2 >> &bits)
const_iterator end() const
std::map< HcalTrigTowerDetId, std::map< uint32_t, std::array< HFUpgradeDetails, 4 > > > HFUpgradeDetailMap
const HcaluLUTTPGCoder * incoder_
void analyzeHF2017(const IntegerCaloSamples &SAMPLES, HcalTriggerPrimitiveDigi &result, const int HF_LUMI_SHIFT, const HcalFeatureBit *HCALFEM)
long double T
latency
hardware algo
void addSignal(const HBHEDataFrame &frame)
adds the signal to the map
std::map< HcalTrigTowerDetId, std::map< uint32_t, HFDetails > > HFDetailMap
void setUpgradeFlags(bool hb, bool he, bool hf)
void addDigis(const HcalDataFrameContainer< D > &collection)
void overrideParameters(const edm::ParameterSet &ps)
const_reference back() const
void analyze2017(IntegerCaloSamples &samples, HcalTriggerPrimitiveDigi &result, const HcalFinegrainBit &fg_algo)
int firstHFTower(int version) const