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