CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 //
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  m_algo = new ConeIsolationAlgorithm(iConfig);
62 
63  produces<reco::JetTagCollection>();
64  produces<reco::IsolatedTauTagInfoCollection>();
65 }
66 
67 ConeIsolation::~ConeIsolation() { delete m_algo; }
68 
69 //
70 // member functions
71 //
72 
75  desc.add<edm::InputTag>("JetTrackSrc", edm::InputTag("ic5JetTracksAssociatorAtVertex"));
76  desc.add<edm::InputTag>("vertexSrc", edm::InputTag("offlinePrimaryVertices"));
77  desc.add<edm::InputTag>("BeamSpotProducer", edm::InputTag("offlineBeamSpot"));
78  desc.add<bool>("useBeamSpot", false);
80  descriptions.add("coneIsolationTauJetTags", desc);
81 }
82 
83 // ------------ method called to produce the data ------------
85  using namespace edm;
86  //Get jets with tracks
88  iEvent.getByToken(jetTrackToken, jetTracksAssociation);
89 
90  std::unique_ptr<reco::JetTagCollection> tagCollection;
91  std::unique_ptr<reco::IsolatedTauTagInfoCollection> extCollection(new reco::IsolatedTauTagInfoCollection());
92  if (not jetTracksAssociation->empty()) {
93  RefToBaseProd<reco::Jet> prod(edm::makeRefToBaseProdFrom(jetTracksAssociation->begin()->first, iEvent));
94  tagCollection = std::make_unique<reco::JetTagCollection>(prod);
95  } else {
96  tagCollection = std::make_unique<reco::JetTagCollection>();
97  }
98 
100  e(0, 0) = 1;
101  e(1, 1) = 1;
102  e(2, 2) = 1;
103  Vertex::Point p(0, 0, -1000);
104  Vertex myPVtmp(p, e); //Fake vertex to be used in case no vertex is found
105  Vertex myPV;
106 
107  //Get pixel vertices
109  iEvent.getByToken(vertexToken, vertices);
110  const reco::VertexCollection vertCollection = *(vertices.product());
111  //Check if there is the PV!!!!
112  if (vertCollection.begin() != vertCollection.end())
113  myPVtmp = *(vertCollection.begin());
114 
115  //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
116  reco::BeamSpot vertexBeamSpot;
117  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
118 
119  if (usingBeamSpot) {
120  //Create a new vertex with the information on x0 and Y0 from the beamspot, to be used in HLT.
121  iEvent.getByToken(beamSpotToken, recoBeamSpotHandle);
122  vertexBeamSpot = *recoBeamSpotHandle;
123  Vertex::Point bspoint(vertexBeamSpot.x0(), vertexBeamSpot.y0(), myPVtmp.z());
124  Vertex combinedVertex = Vertex(bspoint, myPVtmp.error(), myPVtmp.chi2(), myPVtmp.ndof(), myPVtmp.tracksSize());
125  myPV = combinedVertex;
126  } else {
127  myPV = myPVtmp;
128  }
129 
130  for (unsigned int i = 0; i < jetTracksAssociation->size(); ++i) {
131  pair<float, IsolatedTauTagInfo> myPair =
132  m_algo->tag(edm::Ref<JetTracksAssociationCollection>(jetTracksAssociation, i), myPV);
133  tagCollection->setValue(i, myPair.first);
134  extCollection->push_back(myPair.second);
135  }
136 
137  iEvent.put(std::move(extCollection));
138  iEvent.put(std::move(tagCollection));
139 }
140 
141 // declare this class as a framework plugin
142 //DEFINE_FWK_MODULE(ConeIsolation);
static void fillDescription(edm::ParameterSetDescription &desc)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
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
int iEvent
Definition: GenABIO.cc:224
~ConeIsolation() override
std::vector< IsolatedTauTagInfo > IsolatedTauTagInfoCollection
def move
Definition: eostools.py:511
double chi2() const
chi-squares
Definition: Vertex.h:116
double z() const
z coordinate
Definition: Vertex.h:133
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
ParameterDescriptionBase * add(U const &iLabel, T const &value)
size_t tracksSize() const
number of tracks
Definition: Vertex.h:112
double ndof() const
Definition: Vertex.h:123
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Error error() const
return SMatrix
Definition: Vertex.h:163
RefToBaseProd< T > makeRefToBaseProdFrom(RefToBase< T > const &iRef, Event const &iEvent)
void produce(edm::Event &, const edm::EventSetup &) override
ConeIsolation(const edm::ParameterSet &)