CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTTauDQMPathPlotter.cc
Go to the documentation of this file.
1 
3 #include "Math/GenVector/VectorUtil.h"
4 
6  triggerEventObject_(ps.getUntrackedParameter<edm::InputTag>("triggerEventObject")),
7  triggerTag_(ps.getUntrackedParameter<std::string>("DQMFolder","DoubleTau")),
8  filter_(ps.getUntrackedParameter<std::vector<edm::InputTag> >("Filter")),
9  TauType_(ps.getUntrackedParameter<std::vector<int> >("TauType")),
10  LeptonType_(ps.getUntrackedParameter<std::vector<int> >("LeptonType")),
11  nTriggeredTaus_(ps.getUntrackedParameter<std::vector<unsigned> >("NTriggeredTaus")),
12  nTriggeredLeptons_(ps.getUntrackedParameter<std::vector<unsigned> >("NTriggeredLeptons")),
13  doRefAnalysis_(ref),
14  matchDeltaR_(ps.getUntrackedParameter<std::vector<double> >("MatchDeltaR")),
15  refTauPt_(ps.getUntrackedParameter<double>("refTauPt",20)),
16  refLeptonPt_(ps.getUntrackedParameter<double>("refLeptonPt",15))
17 {
18  //initialize
19 
20  // for(size_t k=0;k<filter_.size();++k)
21  // NEventsPassed.push_back(0);
22 
23  // for(size_t k=0;k<=filter_.size();++k)
24  // NEventsPassedMatched.push_back(0);
25 
26  //Declare DQM Store
27  DQMStore* store = &*edm::Service<DQMStore>();
28 
29  if(store)
30  {
31  //Create the histograms
33  accepted_events = store->book1D("TriggerBits","Accepted Events per path",filter_.size(),0,filter_.size());
34  for(size_t k=0;k<filter_.size();++k)
35  accepted_events->setBinLabel(k+1,filter_[k].label(),1);
36 
37  if(doRefAnalysis_)
38  {
39  accepted_events_matched = store->book1D("MatchedTriggerBits","Accepted +Matched Events per path",filter_.size()+1,0,filter_.size()+1);
40  accepted_events_matched->setBinLabel(1,"RefEvents",1);
41  for(size_t k=0;k<filter_.size();++k)
43  }
44 
45 
46 
47  }
48 
49 }
50 
52 {
53 }
54 
55 //
56 // member functions
57 //
58 
59 void
60 HLTTauDQMPathPlotter::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup,const std::vector<LVColl>& refC )
61 {
62  using namespace std;
63  using namespace edm;
64  using namespace reco;
65  using namespace l1extra;
66  using namespace trigger;
67 
68 
69 
70  bool tau_ok=true;
71  bool lepton_ok=true;
72 
73  bool isGoodReferenceEvent=false;
74 
75  if(doRefAnalysis_)
76  {
77  //Tau reference
78  if(refC.size()>0)
79  {
80  if(refC[0].size()<nTriggeredTaus_[0])
81  {
82  tau_ok = false;
83  }
84  else
85  {
86  unsigned int highPtTaus=0;
87  for(size_t j = 0;j<refC[0].size();++j)
88  {
89  if((refC[0])[j].Et()>refTauPt_)
90  highPtTaus++;
91  }
92  if(highPtTaus<nTriggeredTaus_[0])
93  {
94  tau_ok = false;
95  }
96 
97 
98  }
99  }
100  //lepton reference
101  if(refC.size()>1) {
102  if(refC[1].size()<nTriggeredLeptons_[0])
103  {
104  lepton_ok = false;
105  }
106  else {
107  unsigned int highPtLeptons=0;
108  for(size_t j = 0;j<refC[1].size();++j)
109  {
110  if((refC[1])[j].Et()>refLeptonPt_)
111  highPtLeptons++;
112  }
113  if(highPtLeptons<nTriggeredLeptons_[0])
114  {
115  lepton_ok = false;
116  }
117 
118  }
119 
120  if(lepton_ok&&tau_ok)
121  {
123  isGoodReferenceEvent=true;
124  }
125  }
126 
127  }
128 
129 
131  bool gotTEV=iEvent.getByLabel(triggerEventObject_,trigEv) &&trigEv.isValid();
132 
133  if(gotTEV)
134  {
135 
136  if (trigEv.isValid())
137  {
138 
139 
140  //Loop through the filters
141  for(size_t i=0;i<filter_.size();++i)
142  {
143 
144  size_t ID =trigEv->filterIndex(filter_[i]);
145  if(ID!=trigEv->size())
146  {
148  LVColl taus = getFilterCollection(ID,TauType_[i],*trigEv);
149  //Fired
150 
151  if(leptons.size()>=nTriggeredLeptons_[i+1] && taus.size()>=nTriggeredTaus_[i+1])
152  {
153  accepted_events->Fill(i+0.5);
154  //Now do the matching only though if we have a good reference event
155  if(doRefAnalysis_)
156  if(isGoodReferenceEvent)
157  {
158 
159  size_t nT=0;
160  for(size_t j=0;j<taus.size();++j)
161  {
162  if(match(taus[j],refC[0],matchDeltaR_[i]))
163  nT++;
164 
165  }
166  size_t nL=0;
167  for(size_t j=0;j<leptons.size();++j)
168  {
169  if(match(leptons[j],refC[1],matchDeltaR_[i]))
170  nL++;
171 
172  }
173  if(nT>=nTriggeredTaus_[i+1]&&nL>=nTriggeredLeptons_[i+1])
175  }
176  }
177  }
178  }
179  }
180  }
181 }
182 
183 
184 
185 
186 
187 bool
188 HLTTauDQMPathPlotter::match(const LV& jet,const LVColl& McInfo,double dr)
189 {
190 
191  bool matched=false;
192 
193  if(McInfo.size()>0)
194  for(std::vector<LV>::const_iterator it = McInfo.begin();it!=McInfo.end();++it)
195  {
196  double delta = ROOT::Math::VectorUtil::DeltaR(jet,*it);
197  if(delta<dr)
198  {
199  matched=true;
200  }
201  }
202 
203  return matched;
204 }
205 
206 
207 
209 {
210  using namespace trigger;
211 
212  LVColl out;
213 
214 
216  {
217  VRl1em obj;
218  trigEv.getObjects(filterID,id,obj);
219  for(size_t i=0;i<obj.size();++i)
220  if(obj.at(i).isAvailable())
221  out.push_back(obj[i]->p4());
222  }
223 
224  if(id==trigger::TriggerL1Mu)
225  {
226  VRl1muon obj;
227  trigEv.getObjects(filterID,id,obj);
228  for(size_t i=0;i<obj.size();++i)
229  if(obj.at(i).isAvailable())
230 
231  out.push_back(obj[i]->p4());
232  }
233 
234 
235  if(id==trigger::TriggerMuon)
236  {
237  VRmuon obj;
238  trigEv.getObjects(filterID,id,obj);
239  for(size_t i=0;i<obj.size();++i)
240  if(obj.at(i).isAvailable())
241 
242  out.push_back(obj[i]->p4());
243  }
244 
245  if(id==trigger::TriggerElectron)
246  {
247  VRelectron obj;
248  trigEv.getObjects(filterID,id,obj);
249  for(size_t i=0;i<obj.size();++i)
250  if(obj.at(i).isAvailable())
251  out.push_back(obj[i]->p4());
252  }
253 
254  if(id==trigger::TriggerL1TauJet)
255  {
256  VRl1jet obj;
257  trigEv.getObjects(filterID,id,obj);
258  for(size_t i=0;i<obj.size();++i)
259  if(obj.at(i).isAvailable())
260  out.push_back(obj[i]->p4());
261  trigEv.getObjects(filterID,trigger::TriggerL1CenJet,obj);
262  for(size_t i=0;i<obj.size();++i)
263  if(obj.at(i).isAvailable())
264  out.push_back(obj[i]->p4());
265 
266  }
267 
268  if(id==trigger::TriggerTau)
269  {
270  VRjet obj;
271  trigEv.getObjects(filterID,id,obj);
272  for(size_t i=0;i<obj.size();++i)
273  if(obj.at(i).isAvailable())
274  out.push_back(obj[i]->p4());
275  }
276 
277  return out;
278 }
dbl * delta
Definition: mlp_gen.cc:36
int i
Definition: DBlmapReader.cc:9
HLTTauDQMPathPlotter(const edm::ParameterSet &, bool)
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:519
void analyze(const edm::Event &, const edm::EventSetup &, const std::vector< LVColl > &)
enum start value shifted to 81 so as to avoid clashes with PDG codes
std::vector< edm::InputTag > filter_
uint32_t ID
Definition: Definitions.h:26
std::vector< int > LeptonType_
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
std::vector< l1extra::L1MuonParticleRef > VRl1muon
math::XYZTLorentzVectorD LV
void Fill(long long x)
LVColl getFilterCollection(size_t, int, const trigger::TriggerEventWithRefs &)
int iEvent
Definition: GenABIO.cc:243
tuple obj
Example code starts here #.
Definition: VarParsing.py:655
MonitorElement * accepted_events
bool match(const LV &, const LVColl &, double)
int j
Definition: DBlmapReader.cc:9
std::vector< LV > LVColl
std::vector< l1extra::L1EmParticleRef > VRl1em
std::vector< unsigned > nTriggeredLeptons_
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:359
int k[5][pyjets_maxn]
tuple out
Definition: dbtoconf.py:99
std::vector< double > matchDeltaR_
MonitorElement * accepted_events_matched
std::vector< reco::CaloJetRef > VRjet
std::vector< int > TauType_
void getObjects(size_type filter, Vids &ids, VRphoton &photons) const
extract Ref&lt;C&gt;s for a specific filter and of specific physics type
std::vector< reco::RecoChargedCandidateRef > VRmuon
edm::InputTag triggerEventObject_
InputTag of TriggerEventWithRefs to analyze.
std::vector< reco::ElectronRef > VRelectron
std::vector< l1extra::L1JetParticleRef > VRl1jet
tuple size
Write out results.
std::vector< unsigned > nTriggeredTaus_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:237