CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HcalZSAlgoRealistic.cc
Go to the documentation of this file.
1 #include "HcalZSAlgoRealistic.h"
3 #include <iostream>
4 
5 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) :
7  thresholdHB_(levelHB),
8  thresholdHE_(levelHE),
9  thresholdHO_(levelHO),
10  thresholdHF_(levelHF),
11  HBsearchTS_(HBsearchTS),
12  HEsearchTS_(HEsearchTS),
13  HOsearchTS_(HOsearchTS),
14  HFsearchTS_(HFsearchTS)
15 {
16  usingDBvalues = false;
17 }
18 
19 HcalZSAlgoRealistic::HcalZSAlgoRealistic(bool mp, std::pair<int,int> HBsearchTS, std::pair<int,int> HEsearchTS, std::pair<int,int> HOsearchTS, std::pair<int,int> HFsearchTS) :
21  HBsearchTS_(HBsearchTS),
22  HEsearchTS_(HEsearchTS),
23  HOsearchTS_(HOsearchTS),
24  HFsearchTS_(HFsearchTS)
25 {
26  thresholdHB_ = -1;
27  thresholdHE_ = -1;
28  thresholdHO_ = -1;
29  thresholdHF_ = -1;
30  usingDBvalues = true;
31 
32 }
33 
34 
35 
36 //template <class DIGI>
37 //For HBHE Data Frame
38 bool HcalZSAlgoRealistic::keepMe(const HBHEDataFrame& inp, int start, int finish, int threshold, uint32_t hbhezsmask) const{
39 
40  bool keepIt=false;
41  //int mask = 999;
42  if ((usingDBvalues) && (threshold < 0) && (m_dbService != 0)){
43  threshold = (m_dbService->getHcalZSThreshold(inp.id()))->getValue();
44  }
45 
46  //determine the sum of 2 timeslices
47  for (int i = start; i < finish && !keepIt; i++) {
48  int sum=0;
49 
50  for (int j = i; j < (i+2); j++){
51  sum+=inp[j].adc();
52  //pedsum+=pedave;
53  }
54  if ((hbhezsmask&(1<<i)) !=0) continue;
55  else if (sum>=threshold) keepIt=true;
56  }
57  return keepIt;
58 }
59 
60 //For HO Data Frame
61 bool HcalZSAlgoRealistic::keepMe(const HODataFrame& inp, int start, int finish, int threshold, uint32_t hozsmask) const{
62 
63  bool keepIt=false;
64  // int mask = 999;
65  if ((usingDBvalues) && (threshold < 0) && (m_dbService != 0)){
66  threshold = (m_dbService->getHcalZSThreshold(inp.id()))->getValue();
67  }
68 
69  //determine the sum of 2 timeslices
70  for (int i = start; i < finish && !keepIt; i++) {
71  int sum=0;
72 
73  for (int j = i; j < (i+2); j++){
74  sum+=inp[j].adc();
75  //pedsum+=pedave;
76  }
77  if ((hozsmask&(1<<i)) !=0) continue;
78  else if (sum>=threshold) keepIt=true;
79  }
80  return keepIt;
81 }
82 
83 //For HF Data Frame
84 bool HcalZSAlgoRealistic::keepMe(const HFDataFrame& inp, int start, int finish, int threshold, uint32_t hfzsmask) const{
85 
86  bool keepIt=false;
87  // int mask = 999;
88  if ((usingDBvalues) && (threshold < 0) && (m_dbService != 0)){
89  threshold = (m_dbService->getHcalZSThreshold(inp.id()))->getValue();
90  }
91 
92  //determine the sum of 2 timeslices
93  for (int i = start; i < finish && !keepIt; i++) {
94  int sum=0;
95 
96  for (int j = i; j < (i+2); j++){
97  sum+=inp[j].adc();
98  //pedsum+=pedave;
99  }
100  if ((hfzsmask&(1<<i)) !=0) continue;
101  else if (sum>=threshold) keepIt=true;
102  }
103  return keepIt;
104 }
105 
106 bool HcalZSAlgoRealistic::keepMe(const QIE10DataFrame& inp, int start, int finish, int threshold) const{
107 
108  bool keepIt=false;
109  // int mask = 999;
110  if ((usingDBvalues) && (threshold < 0) && (m_dbService != 0)){
111  threshold = (m_dbService->getHcalZSThreshold(inp.id()))->getValue();
112  }
113 
114  //determine the sum of 2 timeslices
115  for (int i = start; i < finish && !keepIt; i++) {
116  int sum=0;
117 
118  for (int j = i; j < (i+2); j++){
119  sum+=inp[j].adc();
120  //pedsum+=pedave;
121  }
122  if (sum>=threshold) keepIt=true;
123  }
124  return keepIt;
125 }
126 
127 bool HcalZSAlgoRealistic::keepMe(const HcalUpgradeDataFrame& inp, int start, int finish, int threshold, uint32_t zsmask) const{
128 
129  bool keepIt=false;
130  //int mask = 999;
131  if ((usingDBvalues) && (threshold < 0) && (m_dbService != 0)){
132  threshold = (m_dbService->getHcalZSThreshold(inp.id()))->getValue();
133  }
134 
135  //determine the sum of 2 timeslices
136  for (int i = start; i < finish && !keepIt; i++) {
137  int sum=0;
138  for (int j = i; j < (i+2); j++){
139  sum+=inp[j].adc();
140  }
141  if ((zsmask&(1<<i)) !=0) continue;
142  else if (sum>=threshold) keepIt=true;
143  }
144  return keepIt;
145 }
146 
148 
149  if (digi.id().subdet()==HcalBarrel) {
150  int start = std::max(0,HBsearchTS_.first);
151  int finish = std::min(digi.size()-1,HBsearchTS_.second);
152  /*
153  std::cout << " HBsearchTS_ : " << HBsearchTS_.first
154  << ", " << HBsearchTS_.second << std::endl;
155  std::cout << " HB start, finish = " << start << ", "
156  << finish << std::endl;
157  */
158  return keepMe(digi,start,finish,thresholdHB_,digi.zsCrossingMask());
159  } else {
160  int start = std::max(0,HEsearchTS_.first);
161  int finish = std::min(digi.size()-1,HEsearchTS_.second);
162  return keepMe(digi,start,finish,thresholdHE_,digi.zsCrossingMask());
163 
164  }
165 }
166 
168 
169  int start = std::max(0,HOsearchTS_.first);
170  int finish = std::min(digi.size()-1,HOsearchTS_.second);
171  return keepMe(digi,start,finish,thresholdHO_,digi.zsCrossingMask());
172 }
173 
175 
176  int start = std::max(0,HFsearchTS_.first);
177  int finish = std::min(digi.size()-1,HFsearchTS_.second);
178  return keepMe(digi,start,finish,thresholdHF_,digi.zsCrossingMask());
179 }
180 
182 
183  int start = std::max(0,HFsearchTS_.first);
184  int finish = std::min((int)digi.size()-1,HFsearchTS_.second);
185  return keepMe(digi,start,finish,thresholdHF_);
186 }
187 
189 
190  if (digi.id().subdet()==HcalForward) {
191  int start = std::max(0,HFsearchTS_.first);
192  int finish = std::min(digi.size()-1,HFsearchTS_.second);
193  return keepMe(digi,start,finish,thresholdHF_,digi.zsCrossingMask());
194  } else if (digi.id().subdet()==HcalBarrel) {
195  int start = std::max(0,HBsearchTS_.first);
196  int finish = std::min(digi.size()-1,HBsearchTS_.second);
197  return keepMe(digi,start,finish,thresholdHB_,digi.zsCrossingMask());
198  } else {
199  int start = std::max(0,HEsearchTS_.first);
200  int finish = std::min(digi.size()-1,HEsearchTS_.second);
201  return keepMe(digi,start,finish,thresholdHE_,digi.zsCrossingMask());
202  }
203 }
const HcalDbService * m_dbService
int i
Definition: DBlmapReader.cc:9
std::pair< int, int > HOsearchTS_
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
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
edm::DataFrame::id_type id() const
edm::DataFrame::size_type size() const
more accessors
const HcalDetId & id() const
Definition: HODataFrame.h:23
uint32_t zsCrossingMask() const
virtual bool shouldKeep(const HBHEDataFrame &digi) const
int size() const
total number of samples in the digi
Definition: HODataFrame.h:27
std::pair< int, int > HEsearchTS_
int j
Definition: DBlmapReader.cc:9
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
uint32_t zsCrossingMask() const
zs crossing mask (which sums considered)
Definition: HBHEDataFrame.h:34
std::pair< int, int > HFsearchTS_
const HcalDetId & id() const
std::pair< int, int > HBsearchTS_
uint32_t zsCrossingMask() const
zs crossing mask (which sums considered)
Definition: HODataFrame.h:35
uint16_t adc(int iSample=0) const
const HcalDetId & id() const
Definition: HBHEDataFrame.h:22
bool keepMe(const HBHEDataFrame &inp, int start, int finish, int threshold, uint32_t hbhezsmask) const
const HcalDetId & id() const
Definition: HFDataFrame.h:22
HcalZSAlgoRealistic(bool markAndPass, std::pair< int, int > HBsearchTS, std::pair< int, int > HEsearchTS, std::pair< int, int > HOsearchTS, std::pair< int, int > HFsearchTS)