CMS 3D CMS Logo

HLTHcalMETNoiseFilter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Class: HLTHcalMETNoiseFilter
4 //
12 //
13 // Original Author: Leonard Apanasevich
14 // Created: Wed Mar 25 16:01:27 CDT 2009
15 //
16 //
17 
19 
25 
27 
31 
32 #include <iostream>
33 
35  HcalNoiseRBXCollectionTag_(iConfig.getParameter<edm::InputTag>("HcalNoiseRBXCollection")),
36  severity_(iConfig.getParameter<int> ("severity")),
37  maxNumRBXs_(iConfig.getParameter<int>("maxNumRBXs")),
38  numRBXsToConsider_(iConfig.getParameter<int>("numRBXsToConsider")),
39  needEMFCoincidence_(iConfig.getParameter<bool>("needEMFCoincidence")),
40  minRBXEnergy_(iConfig.getParameter<double>("minRBXEnergy")),
41  minRatio_(iConfig.getParameter<double>("minRatio")),
42  maxRatio_(iConfig.getParameter<double>("maxRatio")),
43  minHPDHits_(iConfig.getParameter<int>("minHPDHits")),
44  minRBXHits_(iConfig.getParameter<int>("minRBXHits")),
45  minHPDNoOtherHits_(iConfig.getParameter<int>("minHPDNoOtherHits")),
46  minZeros_(iConfig.getParameter<int>("minZeros")),
47  minHighEHitTime_(iConfig.getParameter<double>("minHighEHitTime")),
48  maxHighEHitTime_(iConfig.getParameter<double>("maxHighEHitTime")),
49  maxRBXEMF_(iConfig.getParameter<double>("maxRBXEMF")),
50  minRecHitE_(iConfig.getParameter<double>("minRecHitE")),
51  minLowHitE_(iConfig.getParameter<double>("minLowHitE")),
52  minHighHitE_(iConfig.getParameter<double>("minHighHitE")),
53  minR45HitE_(5.0),
54  TS4TS5EnergyThreshold_(iConfig.getParameter<double>("TS4TS5EnergyThreshold"))
55 {
56 
57  std::vector<double> TS4TS5UpperThresholdTemp = iConfig.getParameter<std::vector<double> >("TS4TS5UpperThreshold");
58  std::vector<double> TS4TS5UpperCutTemp = iConfig.getParameter<std::vector<double> >("TS4TS5UpperCut");
59  std::vector<double> TS4TS5LowerThresholdTemp = iConfig.getParameter<std::vector<double> >("TS4TS5LowerThreshold");
60  std::vector<double> TS4TS5LowerCutTemp = iConfig.getParameter<std::vector<double> >("TS4TS5LowerCut");
61 
62  for(int i = 0; i < (int)TS4TS5UpperThresholdTemp.size() && i < (int)TS4TS5UpperCutTemp.size(); i++)
63  TS4TS5UpperCut_.push_back(std::pair<double, double>(TS4TS5UpperThresholdTemp[i], TS4TS5UpperCutTemp[i]));
64  sort(TS4TS5UpperCut_.begin(), TS4TS5UpperCut_.end());
65 
66  for(int i = 0; i < (int)TS4TS5LowerThresholdTemp.size() && i < (int)TS4TS5LowerCutTemp.size(); i++)
67  TS4TS5LowerCut_.push_back(std::pair<double, double>(TS4TS5LowerThresholdTemp[i], TS4TS5LowerCutTemp[i]));
68  sort(TS4TS5LowerCut_.begin(), TS4TS5LowerCut_.end());
69 
70  if(iConfig.existsAs<double>("minR45HitE"))
71  minR45HitE_ = iConfig.getParameter<double>("minR45HitE");
72 
73  m_theHcalNoiseToken = consumes<reco::HcalNoiseRBXCollection>(HcalNoiseRBXCollectionTag_);
74 }
75 
76 
78 
79 void
82  desc.add<edm::InputTag>("HcalNoiseRBXCollection",edm::InputTag("hltHcalNoiseInfoProducer"));
83  desc.add<int>("severity",1);
84  desc.add<int>("maxNumRBXs",2);
85  desc.add<int>("numRBXsToConsider",2);
86  desc.add<bool>("needEMFCoincidence",true);
87  desc.add<double>("minRBXEnergy",50.0);
88  desc.add<double>("minRatio",-999.);
89  desc.add<double>("maxRatio",999.);
90  desc.add<int>("minHPDHits",17);
91  desc.add<int>("minRBXHits",999);
92  desc.add<int>("minHPDNoOtherHits",10);
93  desc.add<int>("minZeros",10);
94  desc.add<double>("minHighEHitTime",-9999.0);
95  desc.add<double>("maxHighEHitTime",9999.0);
96  desc.add<double>("maxRBXEMF",0.02);
97  desc.add<double>("minRecHitE",1.5);
98  desc.add<double>("minLowHitE",10.0);
99  desc.add<double>("minHighHitE",25.0);
100  desc.add<double>("minR45HitE",5.0);
101  desc.add<double>("TS4TS5EnergyThreshold",50.0);
102 
103  double TS4TS5UpperThresholdArray[5] = {70, 90, 100, 400, 4000 };
104  double TS4TS5UpperCutArray[5] = {1, 0.8, 0.75, 0.72, 0.72};
105  double TS4TS5LowerThresholdArray[7] = {100, 120, 150, 200, 300, 400, 500};
106  double TS4TS5LowerCutArray[7] = {-1, -0.7, -0.4, -0.2, -0.08, 0, 0.1};
107  std::vector<double> TS4TS5UpperThreshold(TS4TS5UpperThresholdArray, TS4TS5UpperThresholdArray+5);
108  std::vector<double> TS4TS5UpperCut(TS4TS5UpperCutArray, TS4TS5UpperCutArray+5);
109  std::vector<double> TS4TS5LowerThreshold(TS4TS5LowerThresholdArray, TS4TS5LowerThresholdArray+7);
110  std::vector<double> TS4TS5LowerCut(TS4TS5LowerCutArray, TS4TS5LowerCutArray+7);
111 
112  desc.add<std::vector<double> >("TS4TS5UpperThreshold", TS4TS5UpperThreshold);
113  desc.add<std::vector<double> >("TS4TS5UpperCut", TS4TS5UpperCut);
114  desc.add<std::vector<double> >("TS4TS5LowerThreshold", TS4TS5LowerThreshold);
115  desc.add<std::vector<double> >("TS4TS5LowerCut", TS4TS5LowerCut);
116  descriptions.add("hltHcalMETNoiseFilter",desc);
117 }
118 
119 //
120 // member functions
121 //
122 
124 {
125  using namespace reco;
126 
127  // in this case, do not filter anything
128  if(severity_==0) return true;
129 
130  // get the RBXs produced by RecoMET/METProducers/HcalNoiseInfoProducer
132  iEvent.getByToken(m_theHcalNoiseToken,rbxs_h);
133  if(!rbxs_h.isValid()) {
134  edm::LogError("DataNotFound") << "HLTHcalMETNoiseFilter: Could not find HcalNoiseRBXCollection product named "
135  << HcalNoiseRBXCollectionTag_ << "." << std::endl;
136  return true;
137  }
138 
139  // reject events with too many RBXs
140  if(static_cast<int>(rbxs_h->size())>maxNumRBXs_) return true;
141 
142  // create a sorted set of the RBXs, ordered by energy
144  for(auto const & rbx : *rbxs_h) {
147  data.insert(d);
148  }
149 
150  // data is now sorted by RBX energy
151  // only consider top N=numRBXsToConsider_ energy RBXs
152  int cntr=0;
153  for(auto it=data.begin();
154  it!=data.end() && cntr<numRBXsToConsider_;
155  ++it, ++cntr) {
156 
157  bool passFilter=true;
158  bool passEMF=true;
159  if(it->energy()>minRBXEnergy_) {
160  if(it->validRatio() && it->ratio()<minRatio_) passFilter=false;
161  else if(it->validRatio() && it->ratio()>maxRatio_) passFilter=false;
162  else if(it->numHPDHits()>=minHPDHits_) passFilter=false;
163  else if(it->numRBXHits()>=minRBXHits_) passFilter=false;
164  else if(it->numHPDNoOtherHits()>=minHPDNoOtherHits_) passFilter=false;
165  else if(it->numZeros()>=minZeros_) passFilter=false;
166  else if(it->minHighEHitTime()<minHighEHitTime_) passFilter=false;
167  else if(it->maxHighEHitTime()>maxHighEHitTime_) passFilter=false;
168  else if(!it->PassTS4TS5()) passFilter=false;
169 
170  if(it->RBXEMF()<maxRBXEMF_) passEMF=false;
171  }
172 
173  if((needEMFCoincidence_ && !passEMF && !passFilter) ||
174  (!needEMFCoincidence_ && !passFilter)) {
175  LogDebug("") << "HLTHcalMETNoiseFilter debug: Found a noisy RBX: "
176  << "energy=" << it->energy() << "; "
177  << "ratio=" << it->ratio() << "; "
178  << "# RBX hits=" << it->numRBXHits() << "; "
179  << "# HPD hits=" << it->numHPDHits() << "; "
180  << "# Zeros=" << it->numZeros() << "; "
181  << "min time=" << it->minHighEHitTime() << "; "
182  << "max time=" << it->maxHighEHitTime() << "; "
183  << "passTS4TS5=" << it->PassTS4TS5() << "; "
184  << "RBX EMF=" << it->RBXEMF()
185  << std::endl;
186  return false;
187  }
188  }
189 
190  // no problems found
191  return true;
192 }
#define LogDebug(id)
std::vector< std::pair< double, double > > TS4TS5LowerCut_
T getParameter(std::string const &) const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:161
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::vector< std::pair< double, double > > TS4TS5UpperCut_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
~HLTHcalMETNoiseFilter() override
int iEvent
Definition: GenABIO.cc:224
edm::EDGetTokenT< reco::HcalNoiseRBXCollection > m_theHcalNoiseToken
edm::InputTag HcalNoiseRBXCollectionTag_
bool filter(edm::Event &, const edm::EventSetup &) override
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:74
std::set< CommonHcalNoiseRBXData, noisedatacomp > noisedataset_t
HLTHcalMETNoiseFilter(const edm::ParameterSet &)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
fixed size matrix
HLT enums.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82