CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TauJetSelectorForHLTTrackSeeding.cc
Go to the documentation of this file.
2 
10 
11 
13  inputTrackJetTag_(iConfig.getParameter< edm::InputTag > ("inputTrackJetTag")),
14  inputCaloJetTag_(iConfig.getParameter< edm::InputTag > ("inputCaloJetTag")),
15  inputTrackTag_(iConfig.getParameter< edm::InputTag > ("inputTrackTag")),
16  ptMinCaloJet_(iConfig.getParameter< double > ("ptMinCaloJet")),
17  etaMinCaloJet_(iConfig.getParameter< double > ("etaMinCaloJet")),
18  etaMaxCaloJet_(iConfig.getParameter< double > ("etaMaxCaloJet")),
19  tauConeSize_(iConfig.getParameter< double > ("tauConeSize")),
20  isolationConeSize_(iConfig.getParameter< double > ("isolationConeSize")),
21  fractionMinCaloInTauCone_(iConfig.getParameter< double > ("fractionMinCaloInTauCone")),
22  fractionMaxChargedPUInCaloCone_(iConfig.getParameter< double > ("fractionMaxChargedPUInCaloCone")),
23  ptTrkMaxInCaloCone_(iConfig.getParameter< double > ("ptTrkMaxInCaloCone")),
24  nTrkMaxInCaloCone_(iConfig.getParameter< int > ("nTrkMaxInCaloCone"))
25 {
26  //now do what ever initialization is needed
27  produces<reco::TrackJetCollection>();
28 }
29 
30 
32 {
33 
34  // do anything here that needs to be done at desctruction time
35  // (e.g. close files, deallocate resources etc.)
36 
37 }
38 
39 
40 //
41 // member functions
42 //
43 
44 // ------------ method called on each new Event ------------
45 void
47 {
48  std::auto_ptr< reco::TrackJetCollection > augmentedTrackJets (new reco::TrackJetCollection);
49 
51  iEvent.getByLabel(inputTrackJetTag_, trackjets);
52 
53  for (reco::TrackJetCollection::const_iterator trackjet = trackjets->begin();
54  trackjet != trackjets->end(); trackjet++) {
55  augmentedTrackJets->push_back(*trackjet);
56  }
57 
59  iEvent.getByLabel(inputTrackTag_,tracks);
60 
62  iEvent.getByLabel(inputCaloJetTag_,calojets);
63 
64  const double tauConeSize2 = tauConeSize_ * tauConeSize_;
65  const double isolationConeSize2 = isolationConeSize_ * isolationConeSize_;
66 
67  for (reco::CaloJetCollection::const_iterator calojet = calojets->begin();
68  calojet != calojets->end(); calojet++) {
69 
70  if ( calojet->pt() < ptMinCaloJet_ ) continue;
71  double etaJet = calojet->eta();
72  double phiJet = calojet->phi();
73  if ( etaJet < etaMinCaloJet_ ) continue;
74  if ( etaJet > etaMaxCaloJet_ ) continue;
75 
76  std::vector <CaloTowerPtr> const & theTowers = calojet->getCaloConstituents();
77  double ptIn = 0.;
78  double ptOut = 0.;
79  for ( unsigned int itwr = 0; itwr < theTowers.size(); ++itwr ) {
80  double etaTwr = theTowers[itwr]->eta() - etaJet;
81  double phiTwr = deltaPhi(theTowers[itwr]->phi(), phiJet);
82  double deltaR2 = etaTwr*etaTwr + phiTwr*phiTwr;
83  //std::cout << "Tower eta/phi/et : " << etaTwr << " " << phiTwr << " " << theTowers[itwr]->pt() << std::endl;
84  if ( deltaR2 < tauConeSize2 ) {
85  ptIn += theTowers[itwr]->pt();
86  } else if ( deltaR2 < isolationConeSize2 ) {
87  ptOut += theTowers[itwr]->pt();
88  }
89  }
90  double ptTot = ptIn+ptOut;
91  double fracIn = ptIn/ptTot;
92 
93  // We are looking for isolated tracks
94  if ( fracIn < fractionMinCaloInTauCone_) continue;
95 
96  int ntrk = 0;
97  double ptTrk = 0.;
98 
99  for (reco::TrackJetCollection::const_iterator trackjet = trackjets->begin();
100  trackjet != trackjets->end(); trackjet++) {
101  for (unsigned itr=0; itr<trackjet->numberOfTracks(); ++itr) {
102  edm::Ptr<reco::Track> track = trackjet->track(itr);
103  double trackEta = track->eta() - etaJet;
104  double trackPhi = deltaPhi(track->phi(), phiJet);
105  double deltaR2 = trackEta*trackEta + trackPhi*trackPhi;
106  if ( deltaR2 < isolationConeSize2 ) {
107  ntrk++;
108  ptTrk += track->pt();
109  }
110  }
111  }
112  // We are looking for calojets without signal tracks already in
113  if ( ntrk > nTrkMaxInCaloCone_ ) continue;
114  if ( ptTrk > ptTrkMaxInCaloCone_ ) continue;
115 
116  int ntrk2 = 0;
117  double ptTrk2 = 0.;
118 
119  for (reco::TrackCollection::const_iterator track = tracks->begin();
120  track != tracks->end(); track++) {
121  double trackEta = track->eta() - etaJet;
122  double trackPhi = deltaPhi(track->phi(), phiJet);
123  double deltaR2 = trackEta*trackEta + trackPhi*trackPhi;
124  if ( deltaR2 < isolationConeSize2 ) {
125  ntrk2++;
126  ptTrk2 += track->pt();
127  }
128  }
129  // We are looking for signal jets, not PU jets
130  double fractionChargedPU = ptTrk2/calojet->pt();
131  if ( fractionChargedPU > fractionMaxChargedPUInCaloCone_ ) continue;
132  /*
133  std::cout << "Calo Jet " << calojet->pt() << " " << calojet->eta()
134  << " " << ptIn << " " << ptOut << " " << fracIn
135  << " " << ptTrk << " " << ntrk
136  << " " << fractionChargedPU
137  << std::endl;
138  */
139  math::XYZTLorentzVector p4(calojet->p4());
140  math::XYZPoint vertex(calojet->vertex());
141  augmentedTrackJets->push_back(reco::TrackJet(p4,vertex));
142  }
143 
144  iEvent.put(augmentedTrackJets);
145 }
146 
147 // ------------ method called once each job just before starting event loop ------------
148 void
150 
151 // ------------ method called once each job just after ending the event loop ------------
152 void
154 
155 // ------------ method called when starting to processes a run ------------
156 void
158 
159 // ------------ method called when ending the processing of a run ------------
160 void
162 
virtual void produce(edm::Event &, const edm::EventSetup &)
TauJetSelectorForHLTTrackSeeding(const edm::ParameterSet &)
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:30
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
double p4[4]
Definition: TauolaWrapper.h:92
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
double deltaR2(const Vector1 &v1, const Vector2 &v2)
Definition: VectorUtil.h:78
Jets made out of tracks.
Definition: TrackJet.h:28
tuple tracks
Definition: testEve_cfg.py:39
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
virtual void beginRun(edm::Run &, edm::EventSetup const &)
std::vector< TrackJet > TrackJetCollection
collection of TrackJet objects
virtual void endRun(edm::Run &, edm::EventSetup const &)
Definition: Run.h:33
Definition: DDAxes.h:10