CMS 3D CMS Logo

HcalZSAlgoRealistic.cc
Go to the documentation of this file.
1 #include "HcalZSAlgoRealistic.h"
2 #include <iostream>
3 
4 HcalZSAlgoRealistic::HcalZSAlgoRealistic(bool mp, int levelHB, int levelHE, int levelHO, int levelHF, std::pair<int,int> HBsearchTS, std::pair<int,int> HEsearchTS, std::pair<int,int> HOsearchTS, std::pair<int,int> HFsearchTS) :
6  thresholdHB_(levelHB),
7  thresholdHE_(levelHE),
8  thresholdHO_(levelHO),
9  thresholdHF_(levelHF),
10  HBsearchTS_(HBsearchTS),
11  HEsearchTS_(HEsearchTS),
12  HOsearchTS_(HOsearchTS),
13  HFsearchTS_(HFsearchTS)
14 {
15  usingDBvalues = false;
16 }
17 
18 HcalZSAlgoRealistic::HcalZSAlgoRealistic(bool mp, std::pair<int,int> HBsearchTS, std::pair<int,int> HEsearchTS, std::pair<int,int> HOsearchTS, std::pair<int,int> HFsearchTS) :
20  HBsearchTS_(HBsearchTS),
21  HEsearchTS_(HEsearchTS),
22  HOsearchTS_(HOsearchTS),
23  HFsearchTS_(HFsearchTS)
24 {
25  thresholdHB_ = -1;
26  thresholdHE_ = -1;
27  thresholdHO_ = -1;
28  thresholdHF_ = -1;
29  usingDBvalues = true;
30 
31 }
32 
33 template <class Digi>
34 bool HcalZSAlgoRealistic::keepMe(const Digi& inp, int start, int finish, int threshold, uint32_t zsmask) const{
35  if ((usingDBvalues) && (threshold < 0) && (m_dbService != nullptr)){
36  threshold = (m_dbService->getHcalZSThreshold(inp.id()))->getValue();
37  }
38 
39  //determine the sum of 2 timeslices
40  for (int i = start; i < finish; i++) {
41  if ((zsmask&(1<<i)) !=0) continue;
42  if ((inp[i].adc()+inp[i+1].adc())>=threshold) return true;
43  }
44  return false;
45 }
46 
47 //zs mask not used for QIE10,11
48 
49 template<>
50 bool HcalZSAlgoRealistic::keepMe<QIE10DataFrame>(const QIE10DataFrame& inp, int start, int finish, int threshold, uint32_t zsmask) const{
51  if ((usingDBvalues) && (threshold < 0) && (m_dbService != nullptr)){
52  threshold = (m_dbService->getHcalZSThreshold(inp.id()))->getValue();
53  }
54 
55  //determine the sum of 2 timeslices
56  for (int i = start; i < finish; i++) {
57  if ((inp[i].adc()+inp[i+1].adc())>=threshold) return true;
58  }
59  return false;
60 }
61 
62 template<>
63 bool HcalZSAlgoRealistic::keepMe<QIE11DataFrame>(const QIE11DataFrame& inp, int start, int finish, int threshold, uint32_t zsmask) const{
64  if ((usingDBvalues) && (threshold < 0) && (m_dbService != nullptr)){
65  threshold = (m_dbService->getHcalZSThreshold(inp.id()))->getValue();
66  }
67 
68  //determine the sum of 2 timeslices
69  for (int i = start; i < finish; i++) {
70  if ((inp[i].adc()+inp[i+1].adc())>=threshold) return true;
71  }
72  return false;
73 }
74 
76  if (digi.id().subdet()==HcalBarrel) {
77  int start = std::max(0,HBsearchTS_.first);
78  int finish = std::min(digi.size()-1,HBsearchTS_.second);
79  return keepMe(digi,start,finish,thresholdHB_,digi.zsCrossingMask());
80  } else {
81  int start = std::max(0,HEsearchTS_.first);
82  int finish = std::min(digi.size()-1,HEsearchTS_.second);
83  return keepMe(digi,start,finish,thresholdHE_,digi.zsCrossingMask());
84  }
85 }
86 
88  int start = std::max(0,HOsearchTS_.first);
89  int finish = std::min(digi.size()-1,HOsearchTS_.second);
90  return keepMe(digi,start,finish,thresholdHO_,digi.zsCrossingMask());
91 }
92 
94  int start = std::max(0,HFsearchTS_.first);
95  int finish = std::min(digi.size()-1,HFsearchTS_.second);
96  return keepMe(digi,start,finish,thresholdHF_,digi.zsCrossingMask());
97 }
98 
100  int start = std::max(0,HFsearchTS_.first);
101  int finish = std::min((int)digi.samples()-1,HFsearchTS_.second);
102  return keepMe(digi,start,finish,thresholdHF_,0);
103 }
104 
106  HcalDetId hid(digi.id());
107  if (hid.subdet()==HcalBarrel) {
108  int start = std::max(0,HBsearchTS_.first);
109  int finish = std::min(digi.samples()-1,HBsearchTS_.second);
110  return keepMe(digi,start,finish,thresholdHB_,0);
111  } else {
112  int start = std::max(0,HEsearchTS_.first);
113  int finish = std::min(digi.samples()-1,HEsearchTS_.second);
114  return keepMe(digi,start,finish,thresholdHE_,0);
115  }
116 }
int adc(sample_type sample)
get the ADC sample (12 bits)
int samples() const
total number of samples in the digi
const HcalDbService * m_dbService
Definition: start.py:1
std::pair< int, int > HOsearchTS_
bool keepMe(const Digi &inp, int start, int finish, int threshold, uint32_t zsmask) const
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:49
uint32_t zsCrossingMask() const
zs crossing mask (which sums considered)
Definition: HFDataFrame.h:34
int size() const
total number of samples in the digi
Definition: HBHEDataFrame.h:26
std::tuple< unsigned int, int, int, DigiType, int, int, int, float > Digi
Definition: GenericDigi.h:30
int size() const
total number of samples in the digi
Definition: HODataFrame.h:27
edm::DataFrame::id_type id() const
std::pair< int, int > HEsearchTS_
T min(T a, T b)
Definition: MathUtil.h:58
const HcalZSThreshold * getHcalZSThreshold(const HcalGenericDetId &fId) const
int size() const
total number of samples in the digi
Definition: HFDataFrame.h:26
bool shouldKeep(const HBHEDataFrame &digi) const override
uint32_t zsCrossingMask() const
zs crossing mask (which sums considered)
Definition: HBHEDataFrame.h:34
std::pair< int, int > HFsearchTS_
std::pair< int, int > HBsearchTS_
uint32_t zsCrossingMask() const
zs crossing mask (which sums considered)
Definition: HODataFrame.h:35
const HcalDetId & id() const
Definition: HBHEDataFrame.h:22
int samples() const
total number of samples in the digi
HcalZSAlgoRealistic(bool markAndPass, std::pair< int, int > HBsearchTS, std::pair< int, int > HEsearchTS, std::pair< int, int > HOsearchTS, std::pair< int, int > HFsearchTS)