CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L25TauAnalyzer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L25TauAnalyzer
4 // Class: L25TauAnalyzer
5 //
13 //
14 // Original Author: Eduardo Luiggi
15 // Created: Mon Apr 19 16:09:13 CDT 2010
16 // $Id: L25TauAnalyzer.cc,v 1.11 2011/03/01 22:54:26 eluiggi Exp $
17 //
18 //
19 
20 
22 #include "Math/GenVector/VectorUtil.h"
26 
27 using namespace edm;
28 using namespace reco;
29 using namespace std;
30 
32  //now do what ever initialization is needed
33 
34  _l25JetSource = iConfig.getParameter<InputTag>("L25JetSource");
35  _l2TauInfoAssoc = iConfig.getParameter<InputTag>("L2TauSource");
36  _pfTauSource = iConfig.getParameter<InputTag>("PFTauSource");
37  _pfTauIsoSource = iConfig.getParameter<InputTag>("PFTauIsoSource");
38  _pfTauMuonDiscSource = iConfig.getParameter<InputTag>("PFTauMuonDiscSource");
39  _pVtxSource = iConfig.getParameter<InputTag>("PrimaryVtxSource");
40  _l2l25MatchingCone = iConfig.getParameter<double>("L2L25MatchingCone");
41 
42  _l25JetLeadTkMacthingCone = iConfig.getParameter<double>("L25JetLeadTkMatchingCone");
43  _minTrackPt = iConfig.getParameter<double>("MinTrackPt");
44  _signalCone = iConfig.getParameter<double>("SignalCone");
45  _isolationCone = iConfig.getParameter<double>("IsolationCone");
46  _l25Dz = iConfig.getParameter<double>("L25DzCut");
47  _nTrkIso = iConfig.getParameter<int>("NTrkIso");
48  _l25LeadTkPtMin = iConfig.getParameter<double>("L25LeadTkMinPt");
49 
50 
51  l25JetEt=0.;
52  l25JetEta=10.;
53  l25JetPhi=10.;
54  hasLeadTrk=0;
55  leadSignalTrackPt = 0.;
56  leadTrkJetDeltaR = 0.;
57  numPixTrkInJet = 0;
58  numQPixTrkInJet = 0;
59  numQPixTrkInSignalCone = 0;
60  numQPixTrkInAnnulus = 10;
61 
62  pfTauPt = 0.;
63  pfTauEt = 0.;
64  pfTauEta = 10.;
65  pfTauPhi = 10.;
66  pfTauLTPt = 0.;
67  pfTauTrkIso = 100.;
68  pfTauGammaIso = 100.;
69 
70  l2JetEt = 0;
71  l2JetEta = 10;
72  l2JetPhi = 10;
73 
74  l25MatchedToPFTau = 0;
75  L2MatchedToPFtau = 0;
76  L25MatchedToL2 = 0;
77 
78  initializeVectors();
80  l25tree = fs->make<TTree>("l25tree","Level 2.5 Tau Tree");
81 
82  l25tree->Branch("pfTauHasLeadTrk", &pfTauHasLeadTrk, "pfTauHasLeadTrk/B");
83  l25tree->Branch("pfTauInBounds", &pfTauInBounds, "pfTauInBounds/B");
84  l25tree->Branch("pfTauPt", &pfTauPt, "pfTauPt/F");
85  l25tree->Branch("pfTauEt", &pfTauEt, "pfTauEt/F");
86  l25tree->Branch("pfTauEta", &pfTauEta, "pfTauEta/F");
87  l25tree->Branch("pfTauphi", &pfTauPhi, "pfTauPhi/F");
88  l25tree->Branch("pfTauLTPt", &pfTauLTPt, "pfTauLTPt/F");
89  l25tree->Branch("pfTauIsoDisc", &pfTauIsoDisc, "pfTauIsoDisc/F");
90  l25tree->Branch("pfTauMuonDisc", &pfTauMuonDisc, "pfTauMuonDisc/F");
91  l25tree->Branch("pfTauNProngs", &pfTauNProngs, "pfTauNProngs/I");
92  l25tree->Branch("pfTauTrkIso", &pfTauTrkIso, "pfTauTrkIso/F");
93  l25tree->Branch("pfTauNTrkIso", &pfTauNTrkIso, "pfTauNTrkIso/I");
94  l25tree->Branch("pfTauIsoTrkPt", &pfTauIsoTrkPt, "pfTauIsoTrkPt/F");
95  l25tree->Branch("pfTauGammaIso", &pfTauGammaIso, "pfTauGammaIso/F");
96 
97  l25tree->Branch("pftauL25DeltaR", &pftauL25DeltaR, "pftauL25DeltaR/F");
98  l25tree->Branch("pftauSignalTrkDeltaR", &pftauSignalTrkDeltaR, "pftauSignalTrkDeltaR/F");
99  l25tree->Branch("pftauIsoTrkDeltaR", &pftauIsoTrkDeltaR, "pftauIsoTrkDeltaR/F");
100  l25tree->Branch("leadTrkPtRes", &leadTrkPtRes, "leadTrkPtRes/F");
101  l25tree->Branch("leadTrkDeltaR", &leadTrkDeltaR, "leadTrkDeltaR/F");
102  l25tree->Branch("leadIsoTrkPtRes", &leadIsoTrkPtRes, "leadIsoTrkPtRes/F");
103  l25tree->Branch("leadIsoTrkDeltaR", &leadIsoTrkDeltaR, "leadIsoTrkDeltaR/F");
104  l25tree->Branch("l25Disc_LeadTkDir", &l25Disc_LeadTkDir, "l25Disc_LeadTkDir/B");
105  l25tree->Branch("l25Disc_JetDir", &l25Disc_JetDir, "l25Disc_JetDir/B");
106 
107  l25tree->Branch("l2JetEt", &l2JetEt, "l2JetEt/F");
108  l25tree->Branch("l2JetEta", &l2JetEta, "l2JetEta/F");
109  l25tree->Branch("l2JetPhi", &l2JetPhi, "l2JetPhi/F");
110 
111  l25tree->Branch("l25MatchedToPFTau", &l25MatchedToPFTau, "l25MatchedToPFTau/B");
112  l25tree->Branch("L2MatchedToPFtau", &L2MatchedToPFtau, "L2MatchedToPFtau/B");
113  l25tree->Branch("L25MatchedToL2", &L25MatchedToL2, "L25MatchedToL2/B");
114 
115  l25tree->Branch("l25JetEt", &l25JetEt, "l25JetEt/F");
116  l25tree->Branch("l25JetEta", &l25JetEta, "l25JetEta/F");
117  l25tree->Branch("l25JetPhi", &l25JetPhi, "l25JetPhi/F");
118  l25tree->Branch("hasLeadTrack", &hasLeadTrk, "hasLeadTrack/B");
119  l25tree->Branch("leadTrackPt", &leadSignalTrackPt, "leadTrackPt/F");
120  l25tree->Branch("nTracks", &numPixTrkInJet, "nTracks/I");
121  l25tree->Branch("nQTracks", &numQPixTrkInJet, "nQTracks/I");
122  l25tree->Branch("nQTracksInSignal", &numQPixTrkInSignalCone, "nQTracksInSignal/I");
123  l25tree->Branch("nQTracksInAnnulus", &numQPixTrkInAnnulus, "nQTracksInAnnulus/I");
124 
125  l25tree->Branch("l25TrkPt", &l25TrkPt);
126  l25tree->Branch("l25TrkEta", &l25TrkEta);
127  l25tree->Branch("l25TrkPhi", &l25TrkPhi);
128  l25tree->Branch("l25TrkDz", &l25TrkDz);
129  l25tree->Branch("l25TrkDxy", &l25TrkDxy);
130  l25tree->Branch("l25TrkChi2", &l25TrkChi2);
131  l25tree->Branch("l25TrkChi2NdF", &l25TrkChi2NdF);
132  l25tree->Branch("l25TrkNRecHits", &l25TrkNRecHits);
133  l25tree->Branch("l25TrkNValidPixelHits", &l25TrkNValidPixelHits);
134 
135  l25tree->Branch("l25SignalTrkPt", &l25SignalTrkPt);
136  l25tree->Branch("l25SignalTrkEta", &l25SignalTrkEta);
137  l25tree->Branch("l25SignalTrkPhi", &l25SignalTrkPhi);
138  l25tree->Branch("l25SignalTrkDz", &l25SignalTrkDz);
139  l25tree->Branch("l25SignalTrkDxy", &l25SignalTrkDxy);
140  l25tree->Branch("l25SignalTrkChi2", &l25SignalTrkChi2);
141  l25tree->Branch("l25SignalTrkChi2NdF", &l25SignalTrkChi2NdF);
142  l25tree->Branch("l25SignalTrkNRecHits", &l25SignalTrkNRecHits);
143  l25tree->Branch("l25SignalTrkNValidHits", &l25SignalTrkNValidHits);
144  l25tree->Branch("l25SignalTrkNValidPixelHits", &l25SignalTrkNValidPixelHits);
145  l25tree->Branch("l25SignalTrkNLostHits", &l25SignalTrkNLostHits);
146 
147  l25tree->Branch("l25IsoTrkPt", &l25IsoTrkPt);
148  l25tree->Branch("l25IsoTrkEta", &l25IsoTrkEta);
149  l25tree->Branch("l25IsoTrkPhi", &l25IsoTrkPhi);
150  l25tree->Branch("l25IsoTrkDz", &l25IsoTrkDz);
151  l25tree->Branch("l25IsoTrkDxy", &l25IsoTrkDxy);
152  l25tree->Branch("l25IsoTrkChi2", &l25IsoTrkChi2);
153  l25tree->Branch("l25IsoTrkChi2NdF", &l25IsoTrkChi2NdF);
154  l25tree->Branch("l25IsoTrkNRecHits", &l25IsoTrkNRecHits);
155  l25tree->Branch("l25IsoTrkNValidHits", &l25IsoTrkNValidHits);
156  l25tree->Branch("l25IsoTrkNValidPixelHits", &l25IsoTrkNValidPixelHits);
157  l25tree->Branch("l25IsoTrkNLostHits", &l25IsoTrkNLostHits);
158 
159  l25tree->Branch("myNtrkIso", &myNtrkIso, "myNtrkIso/I");
160 }
161 
162 
164 
165  // do anything here that needs to be done at desctruction time
166  // (e.g. close files, deallocate resources etc.)
167 
168 }
169 
170 
171 //
172 // member functions
173 //
174 
175 // ------------ method called to for each event ------------
177  using namespace edm;
178 
179  //get l2 jet; match to pftau
180  Handle<PFTauCollection> thePFTaus;
181  iEvent.getByLabel(_pfTauSource,thePFTaus);
182 
183  Handle<PFTauDiscriminator> thePFTauDiscriminatorByIsolation;
184  iEvent.getByLabel(_pfTauIsoSource,thePFTauDiscriminatorByIsolation);
185 
186  Handle<PFTauDiscriminator> thePFTauDiscriminatorAgainstMuon;
187  iEvent.getByLabel(_pfTauMuonDiscSource, thePFTauDiscriminatorAgainstMuon);
188 
189  Handle<VertexCollection> thePrimaryVertices;
190  iEvent.getByLabel(_pVtxSource, thePrimaryVertices);
191  const reco::Vertex& theHltPrimaryVertex = (*thePrimaryVertices->begin());
192  theVertexPosition = math::XYZPoint(0.,0.,0.);
193  if(thePrimaryVertices->size() > 0) theVertexPosition = math::XYZPoint(theHltPrimaryVertex.position().x(),
194  theHltPrimaryVertex.position().y(),
195  theHltPrimaryVertex.position().z());
196 
197  //Loop over PFtaus
198  if(thePFTaus.isValid()){
199  edm::LogInfo("L25Analysis") << "Inside PFTau\n";
200  for(unsigned int pfTauIt = 0; pfTauIt < thePFTaus->size(); ++pfTauIt){
201  const PFTauRef thisTauRef(thePFTaus,pfTauIt);
202  pfTauIsoDisc = 0;
203  pfTauMuonDisc = 0;
204  if(thePFTauDiscriminatorByIsolation.isValid()){
205  const PFTauDiscriminator& disc = *(thePFTauDiscriminatorByIsolation.product());
206  pfTauIsoDisc = disc[thisTauRef];
207  }
208  if(thePFTauDiscriminatorAgainstMuon.isValid()){
209  const PFTauDiscriminator& disc = *(thePFTauDiscriminatorAgainstMuon.product());
210  pfTauMuonDisc = disc[thisTauRef];
211  }
212 
213  L2MatchedToPFtau = false;
214  pfTauHasLeadTrk = false;
215  pfTauInBounds = true;
216 
217  pfTauPt = thePFTaus->at(pfTauIt).pt();
218  pfTauEt = thePFTaus->at(pfTauIt).et();
219  pfTauEta = thePFTaus->at(pfTauIt).eta();
220  pfTauPhi = thePFTaus->at(pfTauIt).eta();
221 
222  const PFCandidateRef& thePFTauLeadTrack = thePFTaus->at(pfTauIt).leadPFChargedHadrCand();
223  if(thePFTauLeadTrack.isNonnull()){
224  pfTauHasLeadTrk = true;
225  pfTauNProngs = thePFTaus->at(pfTauIt).signalPFChargedHadrCands().size();
226  pfTauLTPt = thePFTaus->at(pfTauIt).leadPFChargedHadrCand()->pt();
227  pfTauTrkIso = thePFTaus->at(pfTauIt).isolationPFChargedHadrCandsPtSum();
228  pfTauGammaIso = thePFTaus->at(pfTauIt).isolationPFGammaCandsEtSum();
229  }
230 
231  const PFCandidateRefVector& theSignalCands = thePFTaus->at(pfTauIt).signalPFChargedHadrCands();
232  for(PFCandidateRefVector::const_iterator vIt = theSignalCands.begin(); vIt != theSignalCands.end(); ++vIt){
233  pftauSignalTrkDeltaR = ROOT::Math::VectorUtil::DeltaR((*vIt)->trackRef()->momentum(), thePFTauLeadTrack->momentum());
234  if(pftauSignalTrkDeltaR > _signalCone) pfTauInBounds = false;
235  }
236 
237  const PFCandidateRefVector& theIsoCands = thePFTaus->at(pfTauIt).isolationPFChargedHadrCands();
238  pfTauNTrkIso = theIsoCands.size();
239  float PFTauLeadIsoPt = 0.;
240  Track thePFTauLeadIsoTrk;
241  for(PFCandidateRefVector::const_iterator vIt = theIsoCands.begin(); vIt != theIsoCands.end(); ++vIt){
242  pftauIsoTrkDeltaR = ROOT::Math::VectorUtil::DeltaR((*vIt)->trackRef()->momentum(), thePFTauLeadTrack->momentum());
243  if(pftauIsoTrkDeltaR < _isolationCone) pfTauInBounds = false;
244  pfTauIsoTrkPt = (*vIt)->trackRef()->pt();
245  if((*vIt)->trackRef()->pt() > PFTauLeadIsoPt){
246  thePFTauLeadIsoTrk = *((*vIt)->trackRef());
247  PFTauLeadIsoPt = (*vIt)->trackRef()->pt();
248  }
249  }
250 
251  // matched PFtau to l2 Jet with Et > 5 ... originially 15 but to strong for min bias
252  Handle<L2TauInfoAssociation> l2TauInfoAssoc; //Handle to the input (L2 Tau Info Association)
253  iEvent.getByLabel(_l2TauInfoAssoc,l2TauInfoAssoc);
254  reco::CaloJet theMatchedL2Jet;
255  IsolatedTauTagInfo theMatchedL25TauTagInfo;
256  if(iEvent.getByLabel(_l2TauInfoAssoc,l2TauInfoAssoc) && l2TauInfoAssoc->size()>0){
257  double matchDr = _l2l25MatchingCone;
258  for(L2TauInfoAssociation::const_iterator it = l2TauInfoAssoc->begin(); it != l2TauInfoAssoc->end(); ++it){
259  const reco::CaloJet& l2Jet =*(it->key);
260  if(l2Jet.et() < 15.) continue;
261  double delta = ROOT::Math::VectorUtil::DeltaR(thePFTaus->at(pfTauIt).p4(),l2Jet.p4());
262  if(delta < matchDr){
263  matchDr = delta;
264  L2MatchedToPFtau = true;
265  theMatchedL2Jet = l2Jet;
266  }
267  }
268  }
269 
270  //if(L2MatchedToPFtau) match to l25 and fill l25 variables
272  if(L2MatchedToPFtau){
273  l2JetEt = theMatchedL2Jet.et();
274  l2JetEta = theMatchedL2Jet.eta();
275  l2JetPhi = theMatchedL2Jet.phi();
276  if(iEvent.getByLabel(_l25JetSource, tauTagInfo) && tauTagInfo->size()>0){
277  L25MatchedToL2 = false;
278  double minDeltaR = _l2l25MatchingCone;
279  //declare l25 tauTagInfo ...
280  //IsolatedTauTagInfo theMatchedL25TauTagInfo;
281  for(IsolatedTauTagInfoCollection::const_iterator i = tauTagInfo->begin();i!=tauTagInfo->end();++i){
282  double delta = ROOT::Math::VectorUtil::DeltaR(theMatchedL2Jet.p4(), i->jet()->p4());
283  if(delta < minDeltaR){
284  minDeltaR = delta;
285  L25MatchedToL2 = true;
286  theMatchedL25TauTagInfo = *i;
287  }
288  }
289  }
290 
291  pftauL25DeltaR = ROOT::Math::VectorUtil::DeltaR(thePFTaus->at(pfTauIt).p4(), theMatchedL25TauTagInfo.jet()->p4());
292  if(pftauL25DeltaR < _l2l25MatchingCone)l25MatchedToPFTau = true;
293 
294  const TrackRefVector theTauTagTracks = theMatchedL25TauTagInfo.allTracks();
295 
296  l25JetEt = theMatchedL25TauTagInfo.jet()->et();
297  l25JetEta = theMatchedL25TauTagInfo.jet()->eta();
298  l25JetPhi = theMatchedL25TauTagInfo.jet()->phi();
299  numPixTrkInJet = theTauTagTracks.size();
300  numQPixTrkInJet = theMatchedL25TauTagInfo.selectedTracks().size();
301  //get info for all tracks in tauTagInfo
302  for(TrackRefVector::const_iterator trkIt = theTauTagTracks.begin(); trkIt != theTauTagTracks.end(); ++trkIt){
303  l25TrkPt->push_back((*trkIt)->pt());
304  l25TrkEta->push_back((*trkIt)->eta());
305  l25TrkPhi->push_back((*trkIt)->phi());
306  l25TrkDz->push_back((*trkIt)->dz(theVertexPosition));
307  l25TrkDxy->push_back((*trkIt)->dxy(theVertexPosition));
308  l25TrkChi2->push_back((*trkIt)->chi2());
309  l25TrkChi2NdF->push_back((*trkIt)->normalizedChi2());
310  l25TrkNRecHits->push_back((*trkIt)->recHitsSize());
311  l25TrkNValidPixelHits->push_back((*trkIt)->hitPattern().numberOfValidPixelHits());
312  }
313  const TrackRef leadTk = theMatchedL25TauTagInfo.leadingSignalTrack(_l25JetLeadTkMacthingCone, _minTrackPt);
314  if(!leadTk){
315  hasLeadTrk=false;
316  numQPixTrkInSignalCone=0;
317  numQPixTrkInAnnulus=0;
318  leadSignalTrackPt=0;
319  leadTrkJetDeltaR=10;
320  leadTrkDeltaR=10;
321  }
322  else{
323  hasLeadTrk=true;
324  leadTrkJetDeltaR = ROOT::Math::VectorUtil::DeltaR(theMatchedL25TauTagInfo.jet()->p4().Vect(), leadTk->momentum());
325  leadSignalTrackPt=leadTk->pt();
326  if(pfTauLTPt != 0)leadTrkPtRes = (leadTk->pt() - pfTauLTPt) / pfTauLTPt;
327  leadTrkDeltaR = ROOT::Math::VectorUtil::DeltaR(thePFTauLeadTrack->momentum(), leadTk->momentum());
328 
329  //print info in the case where the pftau is isolated but the tauTag is not
330  bool l25IsoDisc = theMatchedL25TauTagInfo.discriminator(0.2,0.15,0.5,5.,1.,0,0.2);
331  if(pfTauTrkIso <= 1. && l25MatchedToPFTau && !l25IsoDisc) printInfo(thePFTaus->at(pfTauIt), theMatchedL25TauTagInfo);
332 
333  const TrackRefVector theSignalTracks = theMatchedL25TauTagInfo.tracksInCone(leadTk->momentum(), _signalCone, _minTrackPt);
334  const TrackRefVector theIsoTracks = theMatchedL25TauTagInfo.tracksInCone(leadTk->momentum(), _isolationCone, _minTrackPt);
335  numQPixTrkInSignalCone = theSignalTracks.size();
336  if(numQPixTrkInSignalCone > 0) numQPixTrkInAnnulus = theIsoTracks.size() - theSignalTracks.size();
337  //get the lead track in isolation
338  float l25LeadIsoPt = 0.;
339  Track theL25LeadIsoTrk;
340 
341  myNtrkIso = 0;
342  for(TrackRefVector::const_iterator isoIt = theIsoTracks.begin(); isoIt != theIsoTracks.end(); ++isoIt){
343  if(ROOT::Math::VectorUtil::DeltaR(leadTk->momentum(), (*isoIt)->momentum()) <= _signalCone){
344 
345  l25SignalTrkPt->push_back((*isoIt)->pt());
346  l25SignalTrkEta->push_back((*isoIt)->eta());
347  l25SignalTrkPhi->push_back((*isoIt)->phi());
348  l25SignalTrkDz->push_back((*isoIt)->dz(theVertexPosition));
349  l25SignalTrkDxy->push_back((*isoIt)->dxy(theVertexPosition));
350  l25SignalTrkChi2->push_back((*isoIt)->chi2());
351  l25SignalTrkChi2NdF->push_back((*isoIt)->normalizedChi2());
352  l25SignalTrkNRecHits->push_back((*isoIt)->recHitsSize());
353  l25SignalTrkNValidHits->push_back((*isoIt)->numberOfValidHits());
354  l25SignalTrkNValidPixelHits->push_back((*isoIt)->hitPattern().numberOfValidPixelHits());
355  l25SignalTrkNLostHits->push_back((*isoIt)->lost());
356 
357  }
358  else{
359  myNtrkIso++;
360 
361  l25IsoTrkPt->push_back((*isoIt)->pt());
362  l25IsoTrkChi2NdF->push_back((*isoIt)->normalizedChi2());
363  l25IsoTrkChi2->push_back((*isoIt)->chi2());
364  l25IsoTrkNValidHits->push_back((*isoIt)->numberOfValidHits());
365  l25IsoTrkNRecHits->push_back((*isoIt)->recHitsSize());
366  l25IsoTrkNValidPixelHits->push_back((*isoIt)->hitPattern().numberOfValidPixelHits());
367  l25IsoTrkNLostHits->push_back((*isoIt)->lost());
368  l25IsoTrkDxy->push_back((*isoIt)->dxy(theVertexPosition));
369  l25IsoTrkDz->push_back((*isoIt)->dz(theVertexPosition));
370  l25IsoTrkEta->push_back((*isoIt)->eta());
371  l25IsoTrkPhi->push_back((*isoIt)->phi());
372  if((*isoIt)->pt() > l25LeadIsoPt){
373  theL25LeadIsoTrk = **isoIt;
374  l25LeadIsoPt = (*isoIt)->pt();
375  }
376  }
377  }
378  //if((nIsoTraks > numQPixTrkInAnnulus) ? std::cout << "FUCK \n" : std::cout << "GREAT\n" );
379  if(thePFTauLeadIsoTrk.pt() != 0) leadIsoTrkPtRes = (theL25LeadIsoTrk.pt() - thePFTauLeadIsoTrk.pt()) /thePFTauLeadIsoTrk.pt();
380  leadIsoTrkDeltaR = ROOT::Math::VectorUtil::DeltaR(theL25LeadIsoTrk.momentum(), thePFTauLeadIsoTrk.momentum());
381  l25Disc_LeadTkDir = theMatchedL25TauTagInfo.discriminator(leadTk->momentum(), _l25JetLeadTkMacthingCone, _signalCone, _isolationCone, _l25LeadTkPtMin, _minTrackPt, _nTrkIso, _l25Dz);
382  l25Disc_JetDir = theMatchedL25TauTagInfo.discriminator(theMatchedL25TauTagInfo.jet()->momentum(), _l25JetLeadTkMacthingCone, _signalCone, _isolationCone, _l25LeadTkPtMin, _minTrackPt, _nTrkIso, _l25Dz);
383  }
384  }
385  //Fill here per pfTau ...
386  l25tree->Fill();
387  clearVectors();
388  }
389  }
390  else std::cout << "Invalid PFTau Collection\n";
391 }
392 
393 
394 
396 
397  //Loop On the Collection and see if your tau jet is matched to one there
398  //Also find the nearest Matched MC Particle to your Jet (to be complete)
399  // switch reference collection to pftau; match to this.
400 
401  reco::PFTau theMatchedPFTau;
402  double matchDr=0.3;
403 
404  if(thePFTauColl.size()>0)
405  for(reco::PFTauCollection::const_iterator it = thePFTauColl.begin(); it != thePFTauColl.end(); ++it){
406  double delta = ROOT::Math::VectorUtil::DeltaR(jet.p4(),(*it).p4());
407  if(delta<matchDr){
408  matchDr = delta;
409  theMatchedPFTau = *it;
410  }
411  }
412  return theMatchedPFTau;
413 }
414 
416  double matchDr = 0.5;
417  reco::CaloJet theMatchedJet;
418  for(L2TauInfoAssociation::const_iterator it = theL2Info.begin(); it != theL2Info.end(); ++it){
419  const reco::CaloJet& l2Jet =*(it->key);
420  if(l2Jet.et() < 15.) continue;
421  double delta = ROOT::Math::VectorUtil::DeltaR(thePFTau.p4(),l2Jet.p4());
422  if(delta < matchDr){
423  matchDr = delta;
424  theMatchedJet = l2Jet;
425  }
426  }
427  return theMatchedJet;
428 }
429 
430 void L25TauAnalyzer::printInfo(const reco::PFTau& thePFTau, const reco::IsolatedTauTagInfo& theTauTagInfo){
431  const TrackRef theLeadTrack = theTauTagInfo.leadingSignalTrack(_l25JetLeadTkMacthingCone, _minTrackPt);
432  const TrackRefVector theSignalTracks = theTauTagInfo.tracksInCone(theLeadTrack->momentum(), _signalCone, _minTrackPt);
433  const TrackRefVector theIsoTracks = theTauTagInfo.tracksInCone(theLeadTrack->momentum(), _isolationCone, _minTrackPt);
434 
435  std::cout << " Isolated PFTau Matched to Non-Isolated L25 Object( PFTau:L25)"
436  << "\n Et\t" << thePFTau.et() << "\t" << theTauTagInfo.jet()->et()
437  << "\n Eta\t" << thePFTau.eta() << "\t" << theTauTagInfo.jet()->eta()
438  << "\n Phi\t" << thePFTau.phi() << "\t" << theTauTagInfo.jet()->phi()
439  << "\n LTPt\t" << thePFTau.leadPFChargedHadrCand()->pt() << "\t" << theLeadTrack->pt()
440  << "\n LTEta\t" << thePFTau.leadPFChargedHadrCand()->eta() << "\t" << theLeadTrack->eta()
441  << "\n LTPhi\t" << thePFTau.leadPFChargedHadrCand()->phi() << "\t" << theLeadTrack->phi()
442  << "\n NIso\t" << thePFTau.isolationPFChargedHadrCands().size() << "\t" << theIsoTracks.size() - theSignalTracks.size()
443  <<"\n";
444 
445  unsigned int nIsoTrk = 0;
446  std::cout << " Tracks in L2.5 Iso: (Pt:Eta:Phi:DR:Chi2:Chi2/NdF:PxlHits:dxy:dz)\n";
447  for(TrackRefVector::const_iterator isoIt = theIsoTracks.begin(); isoIt != theIsoTracks.end(); ++isoIt){
448  double isoTrackLeadTrkDeltaR = deltaR(theLeadTrack->eta(), theLeadTrack->phi(), (*isoIt)->eta(), (*isoIt)->phi());
449  if(isoTrackLeadTrkDeltaR > _signalCone){
450  nIsoTrk++;
451  cout << nIsoTrk
452  << "\t" << (*isoIt)->pt()
453  << "\t" << (*isoIt)->eta()
454  << "\t" << (*isoIt)->phi()
455  << "\t" << isoTrackLeadTrkDeltaR
456  << "\t" << (*isoIt)->chi2()
457  << "\t" << (*isoIt)->normalizedChi2()
458  << "\t" << (*isoIt)->hitPattern().numberOfValidPixelHits()
459  << "\t" << (*isoIt)->dxy(theVertexPosition)
460  << "\t" << (*isoIt)->dz(theVertexPosition)
461  << "\t" << theVertexPosition
462  << "\n";
463  }
464  }
465  nIsoTrk = 0;
466  std::cout << "Tracks in PFTau Iso: (Pt:Eta:Phi)\n";
468  isoIt != thePFTau.isolationPFChargedHadrCands().end(); ++isoIt){
469  nIsoTrk++;
470  cout << nIsoTrk << "\t"
471  << (*isoIt)->pt() << "\t"
472  << (*isoIt)->eta() << "\t"
473  << (*isoIt)->phi() << "\n";
474  }
475 }
476 
478  l25TrkPt->clear();
479  l25TrkEta->clear();
480  l25TrkPhi->clear();
481  l25TrkDz->clear();
482  l25TrkDxy->clear();
483  l25TrkChi2->clear();
484  l25TrkChi2NdF->clear();
485  l25TrkNRecHits->clear();
486  l25TrkNValidPixelHits->clear();
487 
488  l25SignalTrkPt->clear();
489  l25SignalTrkEta->clear();
490  l25SignalTrkPhi->clear();
491  l25SignalTrkDz->clear();
492  l25SignalTrkDxy->clear();
493  l25SignalTrkChi2NdF->clear();
494  l25SignalTrkChi2->clear();
495  l25SignalTrkNRecHits->clear();
496  l25SignalTrkNValidHits->clear();
497  l25SignalTrkNValidPixelHits->clear();
498  l25SignalTrkNLostHits->clear();
499 
500  l25IsoTrkPt->clear();
501  l25IsoTrkEta->clear();
502  l25IsoTrkPhi->clear();
503  l25IsoTrkDz->clear();
504  l25IsoTrkDxy->clear();
505  l25IsoTrkChi2->clear();
506  l25IsoTrkChi2NdF->clear();
507  l25IsoTrkNRecHits->clear();
508  l25IsoTrkNValidHits->clear();
509  l25IsoTrkNValidPixelHits->clear();
510  l25IsoTrkNLostHits->clear();
511 }
512 
514  l25TrkPt = NULL;
515  l25TrkEta= NULL;
516  l25TrkPhi= NULL;
517  l25TrkDz= NULL;
518  l25TrkDxy= NULL;
519  l25TrkChi2= NULL;
520  l25TrkChi2NdF= NULL;
521  l25TrkNRecHits= NULL;
522  l25TrkNValidPixelHits= NULL;
523 
524  l25SignalTrkPt= NULL;
525  l25SignalTrkEta= NULL;
526  l25SignalTrkPhi= NULL;
527  l25SignalTrkDz= NULL;
528  l25SignalTrkDxy= NULL;
529  l25SignalTrkChi2= NULL;
530  l25SignalTrkChi2NdF= NULL;
531  l25SignalTrkNRecHits= NULL;
532  l25SignalTrkNValidHits= NULL;
533  l25SignalTrkNValidPixelHits= NULL;
534  l25SignalTrkNLostHits= NULL;
535 
536  l25IsoTrkPt= NULL;
537  l25IsoTrkChi2NdF= NULL;
538  l25IsoTrkChi2= NULL;
539  l25IsoTrkNValidHits= NULL;
540  l25IsoTrkNRecHits= NULL;
541  l25IsoTrkNValidPixelHits= NULL;
542  l25IsoTrkNLostHits= NULL;
543  l25IsoTrkDxy= NULL;
544  l25IsoTrkDz= NULL;
545  l25IsoTrkEta= NULL;
546  l25IsoTrkPhi= NULL;
547 }
548 
549 // ------------ method called once each job just before starting event loop ------------
551 }
552 
553 // ------------ method called once each job just after ending the event loop ------------
555 }
556 
557 //define this as a plug-in
558 //DEFINE_FWK_MODULE(L25TauAnalyzer);
dbl * delta
Definition: mlp_gen.cc:36
T getParameter(std::string const &) const
virtual double et() const GCC11_FINAL
transverse energy
int i
Definition: DBlmapReader.cc:9
std::vector< PFTau > PFTauCollection
collection of PFTau objects
Definition: PFTauFwd.h:9
Jets made from CaloTowers.
Definition: CaloJet.h:30
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:150
virtual const LorentzVector & p4() const GCC11_FINAL
four-momentum Lorentz vector
const_iterator end() const
last iterator over the map (read only)
Base class for all types of Jets.
Definition: Jet.h:21
#define NULL
Definition: scimark2.h:8
const_iterator end() const
Termination of iteration.
Definition: RefVector.h:249
void printInfo(const reco::PFTau &thePFTau, const reco::IsolatedTauTagInfo &theTauTagInfo)
const_iterator begin() const
Initialize an iterator over the RefVector.
Definition: RefVector.h:244
virtual void beginJob()
const TrackRefVector selectedTracks() const
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
virtual void analyze(const edm::Event &, const edm::EventSetup &)
int iEvent
Definition: GenABIO.cc:243
void initializeVectors()
double pt() const
track transverse momentum
Definition: TrackBase.h:131
reco::PFTau match(const reco::Jet &, const reco::PFTauCollection &)
L25TauAnalyzer(const edm::ParameterSet &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
virtual edm::RefToBase< Jet > jet(void) const
returns a polymorphic reference to the tagged jet
Definition: JTATagInfo.h:20
virtual float eta() const GCC11_FINAL
momentum pseudorapidity
double deltaR(double eta1, double eta2, double phi1, double phi2)
Definition: TreeUtility.cc:17
virtual void endJob()
const PFCandidateRef & leadPFChargedHadrCand() const
Definition: PFTau.cc:62
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
virtual Vector momentum() const GCC11_FINAL
spatial momentum vector
const TrackRef leadingSignalTrack() const
value_type const at(size_type idx) const
Retrieve an element of the RefVector.
Definition: RefVector.h:76
T * make() const
make new ROOT object
size_type size() const
Size of the RefVector.
Definition: RefVector.h:89
const TrackRefVector tracksInCone(const math::XYZVector myVector, const float size, const float pt_min) const
tuple cout
Definition: gather_cfg.py:121
const_iterator begin() const
first iterator over the map (read only)
const TrackRefVector allTracks() const
reco::CaloJet matchedToPFTau(const reco::PFTau &, const reco::L2TauInfoAssociation &)
const PFCandidateRefVector & isolationPFChargedHadrCands() const
Charged candidates in isolation region.
Definition: PFTau.cc:84