Go to the documentation of this file.00001
00002
00003
00004
00005
00013
00014
00015
00016
00017
00018
00019
00020
00021
00033 #include <memory>
00034 #include <iostream>
00035 #include <iomanip>
00036 #include <cmath>
00037
00038
00039 #include "FWCore/Framework/interface/Frameworkfwd.h"
00040 #include "FWCore/Framework/interface/EDProducer.h"
00041 #include "FWCore/Framework/interface/Event.h"
00042
00043 #include "FWCore/PluginManager/interface/ModuleDef.h"
00044 #include "FWCore/Framework/interface/MakerMacros.h"
00045
00046 #include "DataFormats/Common/interface/Handle.h"
00047 #include "FWCore/Framework/interface/EventSetup.h"
00048 #include "DataFormats/JetReco/interface/CaloJetCollection.h"
00049 #include "DataFormats/JetReco/interface/CaloJet.h"
00050 #include "DataFormats/TrackReco/interface/Track.h"
00051 #include "DataFormats/VertexReco/interface/Vertex.h"
00052 #include "DataFormats/VertexReco/interface/VertexFwd.h"
00053
00054 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00055 #include "JetMETCorrections/JetVertexAssociation/interface/JetVertexAssociation.h"
00056 #include "JetMETCorrections/JetVertexAssociation/interface/JetVertexMain.h"
00057
00058 using namespace std;
00059 using namespace reco;
00060 namespace cms{
00061
00062 JetVertexAssociation::JetVertexAssociation(const edm::ParameterSet& iConfig): m_algo(iConfig),
00063 jet_algo(iConfig.getParameter<std::string>("JET_ALGO")),
00064 track_algo(iConfig.getParameter<std::string>("TRACK_ALGO")),
00065 vertex_algo(iConfig.getParameter<std::string>("VERTEX_ALGO")) {
00066
00067
00068
00069 produces<ResultCollection1>("Var");
00070 produces<ResultCollection2>("JetType");
00071
00072
00073 }
00074
00075 void JetVertexAssociation::produce(edm::Event& iEvent, const edm::EventSetup& iSetup){
00076
00077 edm::Handle<CaloJetCollection> jets;
00078 iEvent.getByLabel(jet_algo, jets);
00079
00080 edm::Handle<TrackCollection> tracks;
00081 iEvent.getByLabel(track_algo, tracks);
00082
00083 edm::Handle<VertexCollection> vertexes;
00084 iEvent.getByLabel(vertex_algo, vertexes);
00085
00086 double SIGNAL_V_Z = 0.;
00087 double SIGNAL_V_Z_ERROR = 0.;
00088 double ptmax = -100.;
00089
00090 VertexCollection::const_iterator vert = vertexes->begin ();
00091 if(vertexes->size() > 0 ) {
00092 for (; vert != vertexes->end (); vert++) {
00093
00094 SIGNAL_V_Z = vert->z();
00095 double pt = 0.;
00096 reco::Vertex::trackRef_iterator tr = vert->tracks_begin();
00097 for (; tr != vert->tracks_end(); tr++) pt += (*tr)->pt();
00098 if( pt >= ptmax ){
00099
00100 ptmax = pt;
00101 SIGNAL_V_Z = vert->z();
00102 SIGNAL_V_Z_ERROR = vert->zError();
00103
00104 }
00105
00106 }
00107 }
00108
00109 pair<double, bool> result;
00110 std::auto_ptr<ResultCollection1> result1 (new ResultCollection1) ;
00111 std::auto_ptr<ResultCollection2> result2 (new ResultCollection2) ;
00112
00113 CaloJetCollection::const_iterator jet = jets->begin ();
00114
00115 if(jets->size() > 0 ) {
00116 for (; jet != jets->end (); jet++) {
00117 result = m_algo.Main(*jet, tracks, SIGNAL_V_Z, SIGNAL_V_Z_ERROR);
00118 result1->push_back(result.first);
00119 result2->push_back(result.second);
00120
00121 }
00122 }
00123
00124 iEvent.put(result1, "Var");
00125 iEvent.put(result2, "JetType");
00126
00127 }
00128 }