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 //
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);
ConfigurationDescriptions.h
JetTag.h
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
ESHandle.h
reco::IsolatedTauTagInfoCollection
std::vector< IsolatedTauTagInfo > IsolatedTauTagInfoCollection
Definition: IsolatedTauTagInfo.h:95
reco::Vertex::z
double z() const
z coordinate
Definition: Vertex.h:120
edm
HLT enums.
Definition: AlignableModifier.h:19
reco::Vertex::Error
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:44
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
reco::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89281
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
ConeIsolation::ConeIsolation
ConeIsolation(const edm::ParameterSet &)
Definition: ConeIsolation.cc:52
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::AssociationVector::empty
bool empty() const
Definition: AssociationVector.h:232
edm::Handle
Definition: AssociativeIterator.h:50
edm::Ref
Definition: AssociativeIterator.h:58
MakerMacros.h
ConeIsolation::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: ConeIsolation.cc:84
Track.h
BeamSpot.h
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
ConeIsolation::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: ConeIsolation.cc:73
edm::AssociationVector::begin
const_iterator begin() const
Definition: AssociationVector.h:108
dumpMFGeometry_cfg.prod
prod
Definition: dumpMFGeometry_cfg.py:24
reco::BeamSpot
Definition: BeamSpot.h:21
AlignmentProducer_cff.beamSpotTag
beamSpotTag
Definition: AlignmentProducer_cff.py:50
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
Vertex.h
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
edm::makeRefToBaseProdFrom
RefToBaseProd< T > makeRefToBaseProdFrom(RefToBase< T > const &iRef, Event const &iEvent)
Definition: makeRefToBaseProdFrom.h:34
reco::Vertex::tracksSize
size_t tracksSize() const
number of tracks
Definition: Vertex.cc:69
iEvent
int iEvent
Definition: GenABIO.cc:224
reco::Vertex::error
Error error() const
return SMatrix
Definition: Vertex.h:150
ConeIsolationAlgorithm
Definition: ConeIsolationAlgorithm.h:17
edm::AssociationVector::size
size_type size() const
Definition: AssociationVector.h:227
edm::EventSetup
Definition: EventSetup.h:58
makeRefToBaseProdFrom.h
reco::Vertex::chi2
double chi2() const
chi-squares
Definition: Vertex.h:103
VertexFwd.h
ConeIsolation::~ConeIsolation
~ConeIsolation() override
Definition: ConeIsolation.cc:67
reco::BeamSpot::x0
double x0() const
x coordinate
Definition: BeamSpot.h:61
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
reco::Vertex::Point
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
HltBtagValidation_cff.Vertex
Vertex
Definition: HltBtagValidation_cff.py:32
Frameworkfwd.h
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
pixelTracksMonitoring_cff.vertexTag
vertexTag
Definition: pixelTracksMonitoring_cff.py:35
ParameterSet.h
IsolatedTauTagInfo.h
reco::BeamSpot::y0
double y0() const
y coordinate
Definition: BeamSpot.h:63
edm::Event
Definition: Event.h:73
ConeIsolation.h
reco::Vertex::ndof
double ndof() const
Definition: Vertex.h:110
edm::InputTag
Definition: InputTag.h:15
reco::Vertex
Definition: Vertex.h:35
ConeIsolationAlgorithm::fillDescription
static void fillDescription(edm::ParameterSetDescription &desc)
Definition: ConeIsolationAlgorithm.cc:31
edm::RefToBaseProd
Definition: RefToBase.h:65
pwdgSkimBPark_cfi.vertices
vertices
Definition: pwdgSkimBPark_cfi.py:7
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37