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 HcalUpgradeDataFrame& inp, int start, int finish, int threshold, uint32_t zsmask) 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  for (int j = i; j < (i+2); j++){
118  sum+=inp[j].adc();
119  }
120  if ((zsmask&(1<<i)) !=0) continue;
121  else if (sum>=threshold) keepIt=true;
122  }
123  return keepIt;
124 }
125 
127 
128  if (digi.id().subdet()==HcalBarrel) {
129  int start = std::max(0,HBsearchTS_.first);
130  int finish = std::min(digi.size()-1,HBsearchTS_.second);
131  /*
132  std::cout << " HBsearchTS_ : " << HBsearchTS_.first
133  << ", " << HBsearchTS_.second << std::endl;
134  std::cout << " HB start, finish = " << start << ", "
135  << finish << std::endl;
136  */
137  return keepMe(digi,start,finish,thresholdHB_,digi.zsCrossingMask());
138  } else {
139  int start = std::max(0,HEsearchTS_.first);
140  int finish = std::min(digi.size()-1,HEsearchTS_.second);
141  return keepMe(digi,start,finish,thresholdHE_,digi.zsCrossingMask());
142 
143  }
144 }
145 
147 
148  int start = std::max(0,HOsearchTS_.first);
149  int finish = std::min(digi.size()-1,HOsearchTS_.second);
150  return keepMe(digi,start,finish,thresholdHO_,digi.zsCrossingMask());
151 }
152 
154 
155  int start = std::max(0,HFsearchTS_.first);
156  int finish = std::min(digi.size()-1,HFsearchTS_.second);
157  return keepMe(digi,start,finish,thresholdHF_,digi.zsCrossingMask());
158 }
159 
161 
162  if (digi.id().subdet()==HcalForward) {
163  int start = std::max(0,HFsearchTS_.first);
164  int finish = std::min(digi.size()-1,HFsearchTS_.second);
165  return keepMe(digi,start,finish,thresholdHF_,digi.zsCrossingMask());
166  } else if (digi.id().subdet()==HcalBarrel) {
167  int start = std::max(0,HBsearchTS_.first);
168  int finish = std::min(digi.size()-1,HBsearchTS_.second);
169  return keepMe(digi,start,finish,thresholdHB_,digi.zsCrossingMask());
170  } else {
171  int start = std::max(0,HEsearchTS_.first);
172  int finish = std::min(digi.size()-1,HEsearchTS_.second);
173  return keepMe(digi,start,finish,thresholdHE_,digi.zsCrossingMask());
174  }
175 }
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:45
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
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)