CMS 3D CMS Logo

L2TauPixelTrackMatch.cc
Go to the documentation of this file.
1 
10 
12  m_jetSrc = consumes<trigger::TriggerFilterObjectWithRefs>(conf.getParameter<edm::InputTag>("JetSrc"));
13  m_jetMinPt = conf.getParameter<double>("JetMinPt");
14  m_jetMaxEta = conf.getParameter<double>("JetMaxEta");
15  //m_jetMinN = conf.getParameter<int>("JetMinN");
16  m_trackSrc = consumes<reco::TrackCollection>(conf.getParameter<edm::InputTag>("TrackSrc"));
17  m_trackMinPt = conf.getParameter<double>("TrackMinPt");
18  m_deltaR = conf.getParameter<double>("deltaR");
19  m_beamSpotTag = consumes<reco::BeamSpot>(conf.getParameter<edm::InputTag>("BeamSpotSrc"));
20 
21  produces<reco::CaloJetCollection>();
22 }
23 
25 
27  using namespace std;
28  using namespace reco;
29 
30  // *** Pick up beam spot ***
31 
32  // use beam spot for vertex x,y
33  edm::Handle<BeamSpot> bsHandle;
34  ev.getByToken(m_beamSpotTag, bsHandle);
35  const reco::BeamSpot& bs = *bsHandle;
36  math::XYZPoint beam_spot(bs.x0(), bs.y0(), bs.z0());
37 
38  // *** Pick up pixel tracks ***
39 
40  edm::Handle<TrackCollection> tracksHandle;
41  ev.getByToken(m_trackSrc, tracksHandle);
42 
43  // *** Pick up L2 tau jets that were previously selected by some other filter ***
44 
45  // first, get L2 object refs by the label
47  ev.getByToken(m_jetSrc, jetsHandle);
48 
49  // now we can get pre-selected L2 tau jets
50  std::vector<CaloJetRef> tau_jets;
51  jetsHandle->getObjects(trigger::TriggerTau, tau_jets);
52  const size_t n_jets = tau_jets.size();
53 
54  // *** Selects interesting tracks ***
55 
56  vector<TinyTrack> good_tracks;
57  for (TrackCollection::const_iterator itrk = tracksHandle->begin(); itrk != tracksHandle->end(); ++itrk) {
58  if (itrk->pt() < m_trackMinPt)
59  continue;
60  if (std::abs(itrk->eta()) > m_jetMaxEta + m_deltaR)
61  continue;
62 
63  TinyTrack trk;
64  trk.pt = itrk->pt();
65  trk.phi = itrk->phi();
66  trk.eta = itrk->eta();
67  double dz = itrk->dz(beam_spot);
68  trk.vtx = math::XYZPoint(bs.x(dz), bs.y(dz), dz);
69  good_tracks.push_back(trk);
70  }
71 
72  // *** Match tau jets to intertesting tracks and assign them new vertices ***
73 
74  // the new product
75  std::unique_ptr<CaloJetCollection> new_tau_jets(new CaloJetCollection);
76  if (!good_tracks.empty())
77  for (size_t i = 0; i < n_jets; ++i) {
78  reco::CaloJetRef jet = tau_jets[i];
79  if (jet->pt() < m_jetMinPt || std::abs(jet->eta()) > m_jetMaxEta)
80  continue;
81 
82  for (vector<TinyTrack>::const_iterator itrk = good_tracks.begin(); itrk != good_tracks.end(); ++itrk) {
83  math::XYZTLorentzVector new_jet_dir = Jet::physicsP4(itrk->vtx, *jet, itrk->vtx);
84  float dphi = reco::deltaPhi(new_jet_dir.phi(), itrk->phi);
85  float deta = new_jet_dir.eta() - itrk->eta;
86 
87  if (dphi * dphi + deta * deta > m_deltaR * m_deltaR)
88  continue;
89 
90  // create a jet copy and assign a new vertex to it
91  CaloJet new_jet = *jet;
92  new_jet.setVertex(itrk->vtx);
93  new_tau_jets->push_back(new_jet);
94  }
96  }
97 
98  // store the result
99  ev.put(std::move(new_tau_jets));
100 }
L2TauPixelTrackMatch(const edm::ParameterSet &)
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:26
void getObjects(Vids &ids, VRphoton &refs) const
various physics-level getters:
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Jets made from CaloTowers.
Definition: CaloJet.h:27
edm::EDGetTokenT< trigger::TriggerFilterObjectWithRefs > m_jetSrc
void setVertex(const Point &vertex) override
set vertex
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
edm::EDGetTokenT< reco::TrackCollection > m_trackSrc
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
edm::EDGetTokenT< reco::BeamSpot > m_beamSpotTag
fixed size matrix
def move(src, dest)
Definition: eostools.py:511
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects