CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
40 
43 
48 
52 
53 using namespace std;
54 using namespace reco;
55 namespace cms {
56 
57  JetVertexAssociation::JetVertexAssociation(const edm::ParameterSet& iConfig)
58  : m_algo(iConfig),
59  jet_token(consumes<CaloJetCollection>(edm::InputTag(iConfig.getParameter<std::string>("JET_ALGO")))),
60  track_token(consumes<TrackCollection>(edm::InputTag(iConfig.getParameter<std::string>("TRACK_ALGO")))),
61  vertex_token(consumes<VertexCollection>(edm::InputTag(iConfig.getParameter<std::string>("VERTEX_ALGO")))) {
62  produces<ResultCollection1>("Var");
63  produces<ResultCollection2>("JetType");
64  }
65 
68  iEvent.getByToken(jet_token, jets);
69 
71  iEvent.getByToken(track_token, tracks);
72 
74  iEvent.getByToken(vertex_token, vertexes);
75 
76  double SIGNAL_V_Z = 0.;
77  double SIGNAL_V_Z_ERROR = 0.;
78  double ptmax = -100.;
79 
80  VertexCollection::const_iterator vert = vertexes->begin();
81  if (!vertexes->empty()) {
82  for (; vert != vertexes->end(); vert++) {
83  SIGNAL_V_Z = vert->z();
84  double pt = 0.;
85  reco::Vertex::trackRef_iterator tr = vert->tracks_begin();
86  for (; tr != vert->tracks_end(); tr++)
87  pt += (*tr)->pt();
88  if (pt >= ptmax) {
89  ptmax = pt;
90  SIGNAL_V_Z = vert->z();
91  SIGNAL_V_Z_ERROR = vert->zError();
92  }
93  }
94  }
95 
96  pair<double, bool> result;
97  std::unique_ptr<ResultCollection1> result1(new ResultCollection1);
98  std::unique_ptr<ResultCollection2> result2(new ResultCollection2);
99 
100  CaloJetCollection::const_iterator jet = jets->begin();
101 
102  if (!jets->empty()) {
103  for (; jet != jets->end(); jet++) {
104  result = m_algo.Main(*jet, tracks, SIGNAL_V_Z, SIGNAL_V_Z_ERROR);
105  result1->push_back(result.first);
106  result2->push_back(result.second);
107  }
108  }
109 
110  iEvent.put(std::move(result1), "Var");
111  iEvent.put(std::move(result2), "JetType");
112  }
113 } // namespace cms
std::pair< double, bool > Main(const reco::CaloJet &jet, edm::Handle< reco::TrackCollection > tracks, double SIGNAL_V_Z, double SIGNAL_V_Z_Error)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::EDGetTokenT< reco::VertexCollection > vertex_token
edm::EDGetTokenT< reco::TrackCollection > track_token
std::vector< double > ResultCollection1
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
auto const & tracks
cannot be loose
tuple result
Definition: mps_fire.py:311
edm::EDGetTokenT< reco::CaloJetCollection > jet_token
int iEvent
Definition: GenABIO.cc:224
vector< PseudoJet > jets
def move
Definition: eostools.py:511
std::vector< bool > ResultCollection2
void produce(edm::Event &e, const edm::EventSetup &c) override
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector&lt;TrackRef&gt;
Definition: Vertex.h:38
std::vector< CaloJet > CaloJetCollection
collection of CaloJet objects