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