CMS 3D CMS Logo

ConeIsolation.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: ConeIsolation
4 // Class: ConeIsolation
5 //
13 //
14 // Original Author: Simone Gennai
15 // Created: Thu Apr 6 09:56:23 CEST 2006
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
24 #include "ConeIsolation.h"
25 
30 
34 
38 
42 
44 
45 using namespace reco;
46 using namespace edm;
47 using namespace std;
48 
49 //
50 // constructors and destructor
51 //
52 ConeIsolation::ConeIsolation(const edm::ParameterSet& iConfig) : m_algo{iConfig} {
53  jetTrackTag = iConfig.getParameter<InputTag>("JetTrackSrc");
54  jetTrackToken = consumes<reco::JetTracksAssociationCollection>(jetTrackTag);
55  vertexTag = iConfig.getParameter<InputTag>("vertexSrc");
56  vertexToken = consumes<reco::VertexCollection>(vertexTag);
57  beamSpotTag = iConfig.getParameter<edm::InputTag>("BeamSpotProducer");
58  beamSpotToken = consumes<reco::BeamSpot>(beamSpotTag);
59  usingBeamSpot = iConfig.getParameter<bool>("useBeamSpot"); //If false the OfflinePrimaryVertex will be used.
60 
61  produces<reco::JetTagCollection>();
62  produces<reco::IsolatedTauTagInfoCollection>();
63 }
64 
65 //
66 // member functions
67 //
68 
71  desc.add<edm::InputTag>("JetTrackSrc", edm::InputTag("ic5JetTracksAssociatorAtVertex"));
72  desc.add<edm::InputTag>("vertexSrc", edm::InputTag("offlinePrimaryVertices"));
73  desc.add<edm::InputTag>("BeamSpotProducer", edm::InputTag("offlineBeamSpot"));
74  desc.add<bool>("useBeamSpot", false);
76  descriptions.add("coneIsolationTauJetTags", desc);
77 }
78 
79 // ------------ method called to produce the data ------------
81  using namespace edm;
82  //Get jets with tracks
84  iEvent.getByToken(jetTrackToken, jetTracksAssociation);
85 
86  std::unique_ptr<reco::JetTagCollection> tagCollection;
87  std::unique_ptr<reco::IsolatedTauTagInfoCollection> extCollection(new reco::IsolatedTauTagInfoCollection());
88  if (not jetTracksAssociation->empty()) {
89  RefToBaseProd<reco::Jet> prod(edm::makeRefToBaseProdFrom(jetTracksAssociation->begin()->first, iEvent));
90  tagCollection = std::make_unique<reco::JetTagCollection>(prod);
91  } else {
92  tagCollection = std::make_unique<reco::JetTagCollection>();
93  }
94 
96  e(0, 0) = 1;
97  e(1, 1) = 1;
98  e(2, 2) = 1;
99  Vertex::Point p(0, 0, -1000);
100  Vertex myPVtmp(p, e); //Fake vertex to be used in case no vertex is found
101  Vertex myPV;
102 
103  //Get pixel vertices
105  iEvent.getByToken(vertexToken, vertices);
106  const reco::VertexCollection vertCollection = *(vertices.product());
107  //Check if there is the PV!!!!
108  if (vertCollection.begin() != vertCollection.end())
109  myPVtmp = *(vertCollection.begin());
110 
111  //In case the beam spot is used, the Z of the vertex still comes from the PV, while the (x,y) is taken from the beamspot
112  reco::BeamSpot vertexBeamSpot;
113  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
114 
115  if (usingBeamSpot) {
116  //Create a new vertex with the information on x0 and Y0 from the beamspot, to be used in HLT.
117  iEvent.getByToken(beamSpotToken, recoBeamSpotHandle);
118  vertexBeamSpot = *recoBeamSpotHandle;
119  Vertex::Point bspoint(vertexBeamSpot.x0(), vertexBeamSpot.y0(), myPVtmp.z());
120  Vertex combinedVertex = Vertex(bspoint, myPVtmp.error(), myPVtmp.chi2(), myPVtmp.ndof(), myPVtmp.tracksSize());
121  myPV = combinedVertex;
122  } else {
123  myPV = myPVtmp;
124  }
125 
126  for (unsigned int i = 0; i < jetTracksAssociation->size(); ++i) {
127  pair<float, IsolatedTauTagInfo> myPair =
128  m_algo.tag(edm::Ref<JetTracksAssociationCollection>(jetTracksAssociation, i), myPV);
129  tagCollection->setValue(i, myPair.first);
130  extCollection->push_back(myPair.second);
131  }
132 
133  iEvent.put(std::move(extCollection));
134  iEvent.put(std::move(tagCollection));
135 }
136 
137 // declare this class as a framework plugin
138 //DEFINE_FWK_MODULE(ConeIsolation);
static void fillDescription(edm::ParameterSetDescription &desc)
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
size_type size() const
double z() const
z coordinate
Definition: Vertex.h:133
edm::EDGetTokenT< reco::VertexCollection > vertexToken
Definition: ConeIsolation.h:32
edm::EDGetTokenT< reco::BeamSpot > beamSpotToken
Definition: ConeIsolation.h:34
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:44
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
const_iterator begin() const
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
double ndof() const
Definition: Vertex.h:123
size_t tracksSize() const
number of tracks
Definition: Vertex.h:112
std::pair< float, reco::IsolatedTauTagInfo > tag(const reco::JetTracksAssociationRef &jetTracks, const reco::Vertex &pv) const
Error error() const
return SMatrix
Definition: Vertex.h:163
double x0() const
x coordinate
Definition: BeamSpot.h:61
int iEvent
Definition: GenABIO.cc:224
ConeIsolationAlgorithm m_algo
Definition: ConeIsolation.h:36
std::vector< IsolatedTauTagInfo > IsolatedTauTagInfoCollection
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
double y0() const
y coordinate
Definition: BeamSpot.h:63
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
double chi2() const
chi-squares
Definition: Vertex.h:116
RefToBaseProd< T > makeRefToBaseProdFrom(RefToBase< T > const &iRef, Event const &iEvent)
fixed size matrix
HLT enums.
ConeIsolation(const edm::ParameterSet &)
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< reco::JetTracksAssociationCollection > jetTrackToken
Definition: ConeIsolation.h:30