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  };
159  typedef std::map<HcalTrigTowerDetId, std::map<uint32_t, std::array<HFUpgradeDetails, 4>>> HFUpgradeDetailMap;
160  HFUpgradeDetailMap theHFUpgradeDetailMap;
161 
162  typedef std::vector<IntegerCaloSamples> SumFGContainer;
163  typedef std::map< HcalTrigTowerDetId, SumFGContainer > TowerMapFGSum;
164  TowerMapFGSum theTowerMapFGSum;
165 
166  // ==============================
167  // = HF Veto
168  // ==============================
169  // Sum = Long + Short;" // intermediate calculation.
170  // if ((Short < MinSignalThresholdET OR Long < MinSignalThresholdET)
171  // AND Sum > PMTNoiseThresholdET) VetoedSum = 0;
172  // else VetoedSum = Sum;
173  // ==============================
174  // Map from FG id to veto booleans
176  typedef std::map<uint32_t, std::vector<bool> > TowerMapVeto;
177  TowerMapVeto HF_Veto;
178 
179  typedef std::map<HcalTrigTowerDetId, std::vector<bool> > FGbitMap;
180  FGbitMap fgMap_;
181 
182  typedef std::vector<HcalFinegrainBit::Tower> FGUpgradeContainer;
183  typedef std::map<HcalTrigTowerDetId, FGUpgradeContainer> FGUpgradeMap;
184  FGUpgradeMap fgUpgradeMap_;
185 
186  bool upgrade_hb_ = false;
187  bool upgrade_he_ = false;
188  bool upgrade_hf_ = false;
189 
191 
192  bool override_adc_hf_ = false;
194  bool override_tdc_hf_ = false;
195  unsigned long long override_tdc_hf_value_;
196 
197  // HE constants
198  static const int HBHE_OVERLAP_TOWER = 16;
199  static const int LAST_FINEGRAIN_DEPTH = 6;
200  static const int LAST_FINEGRAIN_TOWER = 28;
201 
202  // Fine-grain in HF ignores tower 29, and starts with 30
203  static const int FIRST_FINEGRAIN_TOWER = 30;
204 
208  // Consider CaloTPGTranscoderULUT.h for values
209  static const int QIE10_MAX_LINEARIZATION_ET = 0x7FF;
210  static const int QIE11_MAX_LINEARIZATION_ET = 0x7FF;
211 };
212 
213 template<typename... Digis>
215  const HcalTPGCompressor* outcoder,
216  const HcalDbService* conditions,
218  const HcalTrigTowerGeometry* trigTowerGeometry,
219  float rctlsb, const HcalFeatureBit* LongvrsShortCut,
220  const Digis&... digis) {
221  theTrigTowerGeometry = trigTowerGeometry;
222 
223  incoder_ = dynamic_cast<const HcaluLUTTPGCoder*>(incoder);
224  outcoder_ = outcoder;
225  conditions_ = conditions;
226 
227  theSumMap.clear();
228  theTowerMapFGSum.clear();
229  HF_Veto.clear();
230  fgMap_.clear();
231  fgUpgradeMap_.clear();
232  theHFDetailMap.clear();
233  theHFUpgradeDetailMap.clear();
234 
235  // Add all digi collections
236  addDigis(digis...);
237 
238  // Prepare the fine-grain calculation algorithm for HB/HE
239  int version = 0;
242  if (override_parameters_.exists("FGVersionHBHE"))
243  version = override_parameters_.getParameter<uint32_t>("FGVersionHBHE");
244  HcalFinegrainBit fg_algo(version);
245 
246  // VME produces additional bits on the front used by lumi but not the
247  // trigger, this shift corrects those out by right shifting over them.
248  for (auto& item: theSumMap) {
249  result.push_back(HcalTriggerPrimitiveDigi(item.first));
250  HcalTrigTowerDetId detId(item.second.id());
251  if(detId.ietaAbs() >= theTrigTowerGeometry->firstHFTower(detId.version())) {
252  if (detId.version() == 0) {
253  analyzeHF(item.second, result.back(), RCTScaleShift);
254  } else if (detId.version() == 1) {
255  if (upgrade_hf_)
256  analyzeHF2017(item.second, result.back(), NCTScaleShift, LongvrsShortCut);
257  else
258  analyzeHF2016(item.second, result.back(), NCTScaleShift, LongvrsShortCut);
259  } else {
260  // Things are going to go poorly
261  }
262  }
263  else {
264  // Determine which energy reconstruction path to take based on the
265  // fine-grain availability:
266  // * QIE8 TP add entries into fgMap_
267  // * QIE11 TP add entries into fgUpgradeMap_
268  // (not for tower 16 unless HB is upgraded, too)
269  if (fgMap_.find(item.first) != fgMap_.end()) {
270  analyze(item.second, result.back());
271  } else if (fgUpgradeMap_.find(item.first) != fgUpgradeMap_.end()) {
272  analyze2017(item.second, result.back(), fg_algo);
273  }
274  }
275  }
276 
277  // Free up some memory
278  theSumMap.clear();
279  theTowerMapFGSum.clear();
280  HF_Veto.clear();
281  fgMap_.clear();
282  fgUpgradeMap_.clear();
283  theHFDetailMap.clear();
284  theHFUpgradeDetailMap.clear();
285 
286  return;
287 }
288 
289 #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
FG_HF_threshold
threshold for setting fine grain bit
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