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