CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTHPDFilter.cc
Go to the documentation of this file.
1 /* \class HLTHPDFilter
2  *
3  *
4  * Fedor Ratnikov (UMd) May 19, 2008
5  */
6 
8 
9 #include <math.h>
10 
11 #include <set>
12 
18 
21 
24 #include "TH1F.h"
25 #include "TH2F.h"
26 
30 
31 namespace {
32  enum Partition {HBM=0, HBP=1, HEM=2, HEP=3};
33  std::pair<Partition,int> hpdId (HcalDetId fId) {
34  int hpd = fId.iphi ();
35  Partition partition = HBM;
36  if (fId.subdet() == HcalBarrel) {
37  partition = fId.ieta() > 0 ? HBP : HBM;
38  }
39  else if (fId.subdet() == HcalEndcap) {
40  partition = fId.ieta() > 0 ? HEP : HEM;
41  if ((fId.iphi ()-1) % 4 < 2) { // 1,2
42  switch (fId.ieta()) { // 1->2
43  case 22:
44  case 24:
45  case 26:
46  case 28:
47  hpd = +1;
48  break;
49  case 29:
50  if (fId.depth () == 1 || fId.depth () == 3) hpd += 1;
51  break;
52  default:
53  break;
54  }
55  }
56  else { // 3,4
57  switch (fId.ieta()) { // 3->4
58  case 21:
59  case 23:
60  case 25:
61  case 27:
62  hpd += 1;
63  break;
64  case 29:
65  if (fId.depth () == 2) hpd += 1;
66  break;
67  default:
68  break;
69  }
70  }
71  }
72  return std::pair<Partition,int> (partition, hpd);
73  }
74 }
75 
77  mInputTag (iConfig.getParameter <edm::InputTag> ("inputTag")),
78  mEnergyThreshold (iConfig.getParameter <double> ("energy")),
79  mHPDSpikeEnergyThreshold (iConfig.getParameter <double> ("hpdSpikeEnergy")),
80  mHPDSpikeIsolationEnergyThreshold (iConfig.getParameter <double> ("hpdSpikeIsolationEnergy")),
81  mRBXSpikeEnergyThreshold (iConfig.getParameter <double> ("rbxSpikeEnergy")),
82  mRBXSpikeUnbalanceThreshold (iConfig.getParameter <double> ("rbxSpikeUnbalance"))
83 {
84  m_theRecHitCollectionToken = consumes<HBHERecHitCollection>(mInputTag);
85 }
86 
88 
89 void
92  desc.add<edm::InputTag>("inputTag",edm::InputTag("hltHbhereco"));
93  desc.add<double>("energy",-99.0);
94  desc.add<double>("hpdSpikeEnergy",10.0);
95  desc.add<double>("hpdSpikeIsolationEnergy",1.0);
96  desc.add<double>("rbxSpikeEnergy",50.0);
97  desc.add<double>("rbxSpikeUnbalance",0.2);
98  descriptions.add("hltHPDFilter",desc);
99 }
100 
102 {
103  if (mHPDSpikeEnergyThreshold <= 0 && mRBXSpikeEnergyThreshold <= 0) return true; // nothing to filter
104  // get hits
107 
108  // collect energies
109  float hpdEnergy[4][73];
110  for (size_t i = 0; i < 4; ++i) for (size_t j = 0; j < 73; ++j) hpdEnergy[i][j] = 0;
111 
112  // select hist above threshold
113  for (unsigned i = 0; i < hbhe->size(); ++i) {
114  if ((*hbhe)[i].energy() > mEnergyThreshold) {
115  std::pair<Partition,int> hpd = hpdId ((*hbhe)[i].id());
116  hpdEnergy[int (hpd.first)][hpd.second] += (*hbhe)[i].energy ();
117  }
118  }
119 
120  // not single HPD spike
121  if (mHPDSpikeEnergyThreshold > 0) {
122  for (size_t partition = 0; partition < 4; ++partition) {
123  for (size_t i = 1; i < 73; ++i) {
124  if (hpdEnergy [partition][i] > mHPDSpikeEnergyThreshold) {
125  int hpdPlus = i + 1;
126  if (hpdPlus == 73) hpdPlus = 1;
127  int hpdMinus = i - 1;
128  if (hpdMinus == 0) hpdMinus = 72;
129  double maxNeighborEnergy = fmax (hpdEnergy[partition][hpdPlus], hpdEnergy[partition][hpdMinus]);
130  if (maxNeighborEnergy < mHPDSpikeIsolationEnergyThreshold) return false; // HPD spike found
131  }
132  }
133  }
134  }
135 
136  // not RBX flash
137  if (mRBXSpikeEnergyThreshold > 0) {
138  for (size_t partition = 0; partition < 4; ++partition) {
139  for (size_t rbx = 1; rbx < 19; ++rbx) {
140  int ifirst = (rbx-1)*4-1;
141  int iend = (rbx-1)*4+3;
142  double minEnergy = 0;
143  double maxEnergy = -1;
144  double totalEnergy = 0;
145  for (int irm = ifirst; irm < iend; ++irm) {
146  int hpd = irm;
147  if (hpd <= 0) hpd = 72 + hpd;
148  totalEnergy += hpdEnergy[partition][hpd];
149  if (minEnergy > maxEnergy) {
150  minEnergy = maxEnergy = hpdEnergy[partition][hpd];
151  }
152  else {
153  if (hpdEnergy[partition][hpd] < minEnergy) minEnergy = hpdEnergy[partition][hpd];
154  if (hpdEnergy[partition][hpd] > maxEnergy) maxEnergy = hpdEnergy[partition][hpd];
155  }
156  }
157  if (totalEnergy > mRBXSpikeEnergyThreshold) {
158  if (minEnergy / maxEnergy > mRBXSpikeUnbalanceThreshold) return false; // likely HPF flash
159  }
160  }
161  }
162  }
163  return true;
164 }
int i
Definition: DBlmapReader.cc:9
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:45
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
edm::EDGetTokenT< HBHERecHitCollection > m_theRecHitCollectionToken
Definition: HLTHPDFilter.h:30
double mEnergyThreshold
Definition: HLTHPDFilter.h:32
HLTHPDFilter(const edm::ParameterSet &)
Definition: HLTHPDFilter.cc:76
double mRBXSpikeEnergyThreshold
Definition: HLTHPDFilter.h:35
virtual bool filter(edm::Event &, const edm::EventSetup &)
Partition
Definition: HLTHPDFilter.cc:32
int depth() const
get the tower depth
Definition: HcalDetId.h:55
int iEvent
Definition: GenABIO.cc:230
int ieta() const
get the cell ieta
Definition: HcalDetId.h:51
double mHPDSpikeIsolationEnergyThreshold
Definition: HLTHPDFilter.h:34
int j
Definition: DBlmapReader.cc:9
ParameterDescriptionBase * add(U const &iLabel, T const &value)
double mRBXSpikeUnbalanceThreshold
Definition: HLTHPDFilter.h:36
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HLTHPDFilter.cc:90
int iphi() const
get the cell iphi
Definition: HcalDetId.h:53
double mHPDSpikeEnergyThreshold
Definition: HLTHPDFilter.h:33
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::InputTag mInputTag
Definition: HLTHPDFilter.h:31