Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-08-26 03:16:21

0001 #include "SimCalorimetry/HcalZeroSuppressionProducers/interface/HcalZSAlgoRealistic.h"
0002 #include <iostream>
0003 
0004 HcalZSAlgoRealistic::HcalZSAlgoRealistic(bool mp,
0005                                          bool use1ts,
0006                                          int levelHB,
0007                                          int levelHE,
0008                                          int levelHO,
0009                                          int levelHF,
0010                                          std::pair<int, int> HBsearchTS,
0011                                          std::pair<int, int> HEsearchTS,
0012                                          std::pair<int, int> HOsearchTS,
0013                                          std::pair<int, int> HFsearchTS)
0014     : HcalZeroSuppressionAlgo(mp),
0015       use1ts_(use1ts),
0016       thresholdHB_(levelHB),
0017       thresholdHE_(levelHE),
0018       thresholdHO_(levelHO),
0019       thresholdHF_(levelHF),
0020       HBsearchTS_(HBsearchTS),
0021       HEsearchTS_(HEsearchTS),
0022       HOsearchTS_(HOsearchTS),
0023       HFsearchTS_(HFsearchTS) {
0024   usingDBvalues = false;
0025 }
0026 
0027 HcalZSAlgoRealistic::HcalZSAlgoRealistic(bool mp,
0028                                          bool use1ts,
0029                                          std::pair<int, int> HBsearchTS,
0030                                          std::pair<int, int> HEsearchTS,
0031                                          std::pair<int, int> HOsearchTS,
0032                                          std::pair<int, int> HFsearchTS)
0033     : HcalZeroSuppressionAlgo(mp),
0034       use1ts_(use1ts),
0035       HBsearchTS_(HBsearchTS),
0036       HEsearchTS_(HEsearchTS),
0037       HOsearchTS_(HOsearchTS),
0038       HFsearchTS_(HFsearchTS) {
0039   thresholdHB_ = -1;
0040   thresholdHE_ = -1;
0041   thresholdHO_ = -1;
0042   thresholdHF_ = -1;
0043   usingDBvalues = true;
0044 }
0045 
0046 template <class Digi>
0047 bool HcalZSAlgoRealistic::keepMe(const Digi &inp, int start, int finish, int threshold, uint32_t zsmask) const {
0048   if ((usingDBvalues) && (threshold < 0) && (m_dbService != nullptr)) {
0049     threshold = (m_dbService->getHcalZSThreshold(inp.id()))->getValue();
0050   }
0051 
0052   // determine the sum of 2 timeslices
0053   for (int i = start; i < finish; i++) {
0054     if ((zsmask & (1 << i)) != 0)
0055       continue;
0056     if ((inp[i].adc() + inp[i + 1].adc()) >= threshold)
0057       return true;
0058   }
0059   return false;
0060 }
0061 
0062 // zs mask not used for QIE10,11
0063 
0064 template <>
0065 bool HcalZSAlgoRealistic::keepMe<QIE10DataFrame>(
0066     const QIE10DataFrame &inp, int start, int finish, int threshold, uint32_t zsmask) const {
0067   if ((usingDBvalues) && (threshold < 0) && (m_dbService != nullptr)) {
0068     threshold = (m_dbService->getHcalZSThreshold(inp.id()))->getValue();
0069   }
0070 
0071   // determine the sum of 2 timeslices
0072   for (int i = start; i < finish; i++) {
0073     if ((inp[i].adc() + inp[i + 1].adc()) >= threshold)
0074       return true;
0075   }
0076   return false;
0077 }
0078 
0079 template <>
0080 bool HcalZSAlgoRealistic::keepMe<QIE11DataFrame>(
0081     const QIE11DataFrame &inp, int start, int finish, int threshold, uint32_t zsmask) const {
0082   if ((usingDBvalues) && (threshold < 0) && (m_dbService != nullptr)) {
0083     threshold = (m_dbService->getHcalZSThreshold(inp.id()))->getValue();
0084   }
0085 
0086   // sum of 2 timeslices or just single one
0087   for (int i = start; i < finish; i++) {
0088     int sum = inp[i].adc();
0089     if (!use1ts_)
0090       sum += inp[i + 1].adc();
0091     if (sum >= threshold)
0092       return true;
0093   }
0094   return false;
0095 }
0096 
0097 bool HcalZSAlgoRealistic::shouldKeep(const HBHEDataFrame &digi) const {
0098   if (digi.id().subdet() == HcalBarrel) {
0099     int start = std::max(0, HBsearchTS_.first);
0100     int finish = std::min(digi.size() - 1, HBsearchTS_.second);
0101     return keepMe(digi, start, finish, thresholdHB_, digi.zsCrossingMask());
0102   } else {
0103     int start = std::max(0, HEsearchTS_.first);
0104     int finish = std::min(digi.size() - 1, HEsearchTS_.second);
0105     return keepMe(digi, start, finish, thresholdHE_, digi.zsCrossingMask());
0106   }
0107 }
0108 
0109 bool HcalZSAlgoRealistic::shouldKeep(const HODataFrame &digi) const {
0110   int start = std::max(0, HOsearchTS_.first);
0111   int finish = std::min(digi.size() - 1, HOsearchTS_.second);
0112   return keepMe(digi, start, finish, thresholdHO_, digi.zsCrossingMask());
0113 }
0114 
0115 bool HcalZSAlgoRealistic::shouldKeep(const HFDataFrame &digi) const {
0116   int start = std::max(0, HFsearchTS_.first);
0117   int finish = std::min(digi.size() - 1, HFsearchTS_.second);
0118   return keepMe(digi, start, finish, thresholdHF_, digi.zsCrossingMask());
0119 }
0120 
0121 bool HcalZSAlgoRealistic::shouldKeep(const QIE10DataFrame &digi) const {
0122   int start = std::max(0, HFsearchTS_.first);
0123   int finish = std::min((int)digi.samples() - 1, HFsearchTS_.second);
0124   return keepMe(digi, start, finish, thresholdHF_, 0);
0125 }
0126 
0127 bool HcalZSAlgoRealistic::shouldKeep(const QIE11DataFrame &digi) const {
0128   HcalDetId hid(digi.id());
0129   if (hid.subdet() == HcalBarrel) {
0130     int start = std::max(0, HBsearchTS_.first);
0131     int finish = std::min(digi.samples() - 1, HBsearchTS_.second);
0132     return keepMe(digi, start, finish, thresholdHB_, 0);
0133   } else {
0134     int start = std::max(0, HEsearchTS_.first);
0135     int finish = std::min(digi.samples() - 1, HEsearchTS_.second);
0136     return keepMe(digi, start, finish, thresholdHE_, 0);
0137   }
0138 }