CMS 3D CMS Logo

JetVertexAssociation.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: JetVertexAssociation
4 // Class: JetVertexAssociation
5 //
13 //
14 // Original Author: Natalia Ilina
15 // Modified by Eduardo Luiggi
16 //
17 // Created: Tue Oct 31 10:52:41 CET 2006
18 //
19 //
20 
32 #include <memory>
33 #include <iostream>
34 #include <iomanip>
35 #include <cmath>
36 
39 
42 
47 
51 
52 using namespace std;
53 using namespace reco;
54 namespace cms {
55 
56  JetVertexAssociation::JetVertexAssociation(const edm::ParameterSet& iConfig)
57  : m_algo(iConfig),
58  jet_token(consumes<CaloJetCollection>(edm::InputTag(iConfig.getParameter<std::string>("JET_ALGO")))),
59  track_token(consumes<TrackCollection>(edm::InputTag(iConfig.getParameter<std::string>("TRACK_ALGO")))),
60  vertex_token(consumes<VertexCollection>(edm::InputTag(iConfig.getParameter<std::string>("VERTEX_ALGO")))) {
61  produces<ResultCollection1>("Var");
62  produces<ResultCollection2>("JetType");
63  }
64 
67  iEvent.getByToken(jet_token, jets);
68 
70  iEvent.getByToken(track_token, tracks);
71 
73  iEvent.getByToken(vertex_token, vertexes);
74 
75  double SIGNAL_V_Z = 0.;
76  double SIGNAL_V_Z_ERROR = 0.;
77  double ptmax = -100.;
78 
79  VertexCollection::const_iterator vert = vertexes->begin();
80  if (!vertexes->empty()) {
81  for (; vert != vertexes->end(); vert++) {
82  SIGNAL_V_Z = vert->z();
83  double pt = 0.;
84  reco::Vertex::trackRef_iterator tr = vert->tracks_begin();
85  for (; tr != vert->tracks_end(); tr++)
86  pt += (*tr)->pt();
87  if (pt >= ptmax) {
88  ptmax = pt;
89  SIGNAL_V_Z = vert->z();
90  SIGNAL_V_Z_ERROR = vert->zError();
91  }
92  }
93  }
94 
95  pair<double, bool> result;
96  std::unique_ptr<ResultCollection1> result1(new ResultCollection1);
97  std::unique_ptr<ResultCollection2> result2(new ResultCollection2);
98 
99  CaloJetCollection::const_iterator jet = jets->begin();
100 
101  if (!jets->empty()) {
102  for (; jet != jets->end(); jet++) {
103  result = m_algo.Main(*jet, tracks, SIGNAL_V_Z, SIGNAL_V_Z_ERROR);
104  result1->push_back(result.first);
105  result2->push_back(result.second);
106  }
107  }
108 
109  iEvent.put(std::move(result1), "Var");
110  iEvent.put(std::move(result2), "JetType");
111  }
112 } // namespace cms
edm::EDGetTokenT< reco::VertexCollection > vertex_token
edm::EDGetTokenT< reco::TrackCollection > track_token
std::vector< double > ResultCollection1
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
edm::EDGetTokenT< reco::CaloJetCollection > jet_token
int iEvent
Definition: GenABIO.cc:224
std::vector< bool > ResultCollection2
void produce(edm::StreamID, edm::Event &e, const edm::EventSetup &c) const override
Namespace of DDCMS conversion namespace.
auto const & tracks
cannot be loose
std::pair< double, bool > Main(const reco::CaloJet &jet, edm::Handle< reco::TrackCollection > tracks, double SIGNAL_V_Z, double SIGNAL_V_Z_Error) const
fixed size matrix
HLT enums.
def move(src, dest)
Definition: eostools.py:511
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
Definition: Vertex.h:38
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects