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.
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 
34 
35 //template <class DIGI>
36 //For HBHE Data Frame
37 bool HcalZSAlgoRealistic::keepMe(const HBHEDataFrame& inp, int start, int finish, int threshold, uint32_t hbhezsmask) const{
38 
39  bool keepIt=false;
40  //int mask = 999;
41  if ((usingDBvalues) && (threshold < 0) && (m_dbService != 0)){
42  threshold = (m_dbService->getHcalZSThreshold(inp.id()))->getValue();
43  }
44 
45  //determine the sum of 2 timeslices
46  for (int i = start; i < finish && !keepIt; i++) {
47  int sum=0;
48 
49  for (int j = i; j < (i+2); j++){
50  sum+=inp[j].adc();
51  //pedsum+=pedave;
52  }
53  if ((hbhezsmask&(1<<i)) !=0) continue;
54  else if (sum>=threshold) keepIt=true;
55  }
56  return keepIt;
57 }
58 
59 //For HO Data Frame
60 bool HcalZSAlgoRealistic::keepMe(const HODataFrame& inp, int start, int finish, int threshold, uint32_t hozsmask) const{
61 
62  bool keepIt=false;
63  // int mask = 999;
64  if ((usingDBvalues) && (threshold < 0) && (m_dbService != 0)){
65  threshold = (m_dbService->getHcalZSThreshold(inp.id()))->getValue();
66  }
67 
68  //determine the sum of 2 timeslices
69  for (int i = start; i < finish && !keepIt; i++) {
70  int sum=0;
71 
72  for (int j = i; j < (i+2); j++){
73  sum+=inp[j].adc();
74  //pedsum+=pedave;
75  }
76  if ((hozsmask&(1<<i)) !=0) continue;
77  else if (sum>=threshold) keepIt=true;
78  }
79  return keepIt;
80 }
81 
82 //For HF Data Frame
83 bool HcalZSAlgoRealistic::keepMe(const HFDataFrame& inp, int start, int finish, int threshold, uint32_t hfzsmask) const{
84 
85  bool keepIt=false;
86  // int mask = 999;
87  if ((usingDBvalues) && (threshold < 0) && (m_dbService != 0)){
88  threshold = (m_dbService->getHcalZSThreshold(inp.id()))->getValue();
89  }
90 
91  //determine the sum of 2 timeslices
92  for (int i = start; i < finish && !keepIt; i++) {
93  int sum=0;
94 
95  for (int j = i; j < (i+2); j++){
96  sum+=inp[j].adc();
97  //pedsum+=pedave;
98  }
99  if ((hfzsmask&(1<<i)) !=0) continue;
100  else if (sum>=threshold) keepIt=true;
101  }
102  return keepIt;
103 }
104 
105 
107  // uint32_t hbhezsmask = digi.zsCrossingMask();
108  if (digi.id().subdet()==HcalBarrel) {
109 
110  int start = std::max(0,HBsearchTS_.first);
111  int finish = std::min(digi.size()-1,HBsearchTS_.second);
112 
113  /*
114  std::cout << " HBsearchTS_ : " << HBsearchTS_.first
115  << ", " << HBsearchTS_.second << std::endl;
116  std::cout << " HB start, finish = " << start << ", "
117  << finish << std::endl;
118  */
119 
120  return keepMe(digi,start,finish,thresholdHB_,digi.zsCrossingMask());
121 
122 
123  }
124  else {
125 
126  int start = std::max(0,HEsearchTS_.first);
127  int finish = std::min(digi.size()-1,HEsearchTS_.second);
128  return keepMe(digi,start,finish,thresholdHE_,digi.zsCrossingMask());
129 
130  }
131 }
132 
134 
135  int start = std::max(0,HOsearchTS_.first);
136  int finish = std::min(digi.size()-1,HOsearchTS_.second);
137  return keepMe(digi,start,finish,thresholdHO_,digi.zsCrossingMask());
138 }
139 
141 
142  int start = std::max(0,HFsearchTS_.first);
143  int finish = std::min(digi.size()-1,HFsearchTS_.second);
144  return keepMe(digi,start,finish,thresholdHF_,digi.zsCrossingMask());
145 }
const HcalDbService * m_dbService
int i
Definition: DBlmapReader.cc:9
std::pair< int, int > HOsearchTS_
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:32
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
#define min(a, b)
Definition: mlp_lapack.h:161
const HcalDetId & id() const
Definition: HODataFrame.h:23
const T & max(const T &a, const T &b)
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
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_
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
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)