Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Pages
PhysicsTools
JetMCAlgos
plugins
GenJetBCEnergyRatio.cc
Go to the documentation of this file.
1
//
2
// Plugin to store B and C ratio for a GenJet in the event
3
// Author: Attilio
4
// Date: 05.10.2007
5
//
6
7
//=======================================================================
8
9
// user include files
10
#include "
FWCore/Framework/interface/EDProducer.h
"
11
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
12
#include "
FWCore/ParameterSet/interface/ParameterSetfwd.h
"
13
#include "
FWCore/Utilities/interface/InputTag.h
"
14
15
#include "
FWCore/Framework/interface/Event.h
"
16
#include "
FWCore/Framework/interface/EventSetup.h
"
17
#include "
FWCore/Framework/interface/MakerMacros.h
"
18
#include "
FWCore/Framework/interface/ESHandle.h
"
19
#include "
FWCore/Framework/interface/makeRefToBaseProdFrom.h
"
20
#include "
FWCore/MessageLogger/interface/MessageLogger.h
"
21
22
#include "
DataFormats/JetReco/interface/Jet.h
"
23
#include "
DataFormats/JetReco/interface/GenJetCollection.h
"
24
#include "
SimDataFormats/JetMatching/interface/JetFlavour.h
"
25
26
#include "
DataFormats/Common/interface/Ref.h
"
27
#include "
DataFormats/Candidate/interface/Candidate.h
"
28
#include "
DataFormats/Candidate/interface/CandidateFwd.h
"
29
#include "
DataFormats/JetReco/interface/JetFloatAssociation.h
"
30
#include "
DataFormats/Math/interface/Point3D.h
"
31
#include "
DataFormats/Math/interface/LorentzVector.h
"
32
33
#include "
DataFormats/JetReco/interface/GenJet.h
"
34
#include "
PhysicsTools/JetMCUtils/interface/JetMCTag.h
"
35
#include "
PhysicsTools/JetMCUtils/interface/CandMCTag.h
"
36
37
#include <memory>
38
#include <string>
39
#include <iostream>
40
#include <vector>
41
#include <Math/VectorUtil.h>
42
#include <TMath.h>
43
44
using namespace
std;
45
using namespace
reco
;
46
using namespace
edm;
47
using namespace
ROOT::Math::VectorUtil;
48
using namespace
JetMCTagUtils;
49
using namespace
CandMCTagUtils;
50
51
class
GenJetBCEnergyRatio
:
public
edm::EDProducer
52
{
53
public
:
54
GenJetBCEnergyRatio
(
const
edm::ParameterSet
& );
55
~
GenJetBCEnergyRatio
();
56
57
typedef
reco::JetFloatAssociation::Container
JetBCEnergyRatioCollection
;
58
59
private
:
60
virtual
void
produce(
edm::Event
&,
const
edm::EventSetup
& )
override
;
61
Handle< View <Jet>
>
genjets
;
62
edm::EDGetTokenT< View <Jet>
>
m_genjetsSrcToken
;
63
64
};
65
66
//=========================================================================
67
68
GenJetBCEnergyRatio::GenJetBCEnergyRatio
(
const
edm::ParameterSet
& iConfig )
69
{
70
produces<JetBCEnergyRatioCollection>(
"bRatioCollection"
);
71
produces<JetBCEnergyRatioCollection>(
"cRatioCollection"
);
72
m_genjetsSrcToken = consumes< View <Jet> >(iConfig.
getParameter
<
edm::InputTag
>(
"genJets"
));
73
}
74
75
//=========================================================================
76
77
GenJetBCEnergyRatio::~GenJetBCEnergyRatio
()
78
{
79
}
80
81
// ------------ method called to produce the data ------------
82
83
void
GenJetBCEnergyRatio::produce
(
Event
&
iEvent
,
const
EventSetup
& iEs )
84
{
85
iEvent.
getByToken
(m_genjetsSrcToken, genjets);
86
87
typedef
edm::RefToBase<reco::Jet>
JetRef
;
88
89
JetBCEnergyRatioCollection
* jtc1;
90
JetBCEnergyRatioCollection
* jtc2;
91
92
if
(genjets.product()->size() > 0) {
93
const
JetRef
jj
= genjets->refAt(0);
94
jtc1 =
new
JetBCEnergyRatioCollection
(
edm::makeRefToBaseProdFrom
(jj, iEvent));
95
jtc2 =
new
JetBCEnergyRatioCollection
(
edm::makeRefToBaseProdFrom
(jj, iEvent));
96
}
else
{
97
jtc1 =
new
JetBCEnergyRatioCollection
();
98
jtc2 =
new
JetBCEnergyRatioCollection
();
99
}
100
101
std::auto_ptr<JetBCEnergyRatioCollection> bRatioColl(jtc1);
102
std::auto_ptr<JetBCEnergyRatioCollection> cRatioColl(jtc2);
103
104
for
(
size_t
j
= 0;
j
!= genjets->size(); ++
j
) {
105
106
float
bRatio =
EnergyRatioFromBHadrons
( (*genjets)[
j
] );
107
float
cRatio =
EnergyRatioFromCHadrons
( (*genjets)[j] );
108
109
const
JetRef & aJet = genjets->refAt(j) ;
110
111
JetFloatAssociation::setValue
(*bRatioColl, aJet, bRatio);
112
JetFloatAssociation::setValue
(*cRatioColl, aJet, cRatio);
113
114
}
115
116
117
iEvent.
put
(bRatioColl,
"bRatioCollection"
);
118
iEvent.
put
(cRatioColl,
"cRatioCollection"
);
119
120
}
121
122
//define this as a plug-in
123
DEFINE_FWK_MODULE
(
GenJetBCEnergyRatio
);
124
JetMCTag.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
makeRefToBaseProdFrom.h
MessageLogger.h
JetFloatAssociation.h
GenJetBCEnergyRatio::produce
virtual void produce(edm::Event &, const edm::EventSetup &) override
Definition:
GenJetBCEnergyRatio.cc:83
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition:
Event.h:457
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:17
Event.h
GenJetBCEnergyRatio
Definition:
GenJetBCEnergyRatio.cc:51
MakerMacros.h
edm::Handle
Definition:
AssociativeIterator.h:47
EventSetup.h
CandMCTag.h
JetFlavour.h
pat::JetRef
edm::Ref< JetCollection > JetRef
Definition:
Jet.h:54
dt_dqm_sourceclient_common_cff.reco
tuple reco
Definition:
dt_dqm_sourceclient_common_cff.py:106
edm::EDGetTokenT
Definition:
EDGetToken.h:32
reco::JetExtendedAssociation::setValue
bool setValue(Container &, const reco::JetBaseRef &, const JetExtendedData &)
associate jet with value. Returns false and associate nothing if jet is already associated ...
Definition:
JetExtendedAssociation.cc:44
Point3D.h
edm::RefToBase< reco::Jet >
ParameterSetfwd.h
edm::EDProducer
Definition:
EDProducer.h:35
ParameterSet.h
Candidate.h
iEvent
int iEvent
Definition:
GenABIO.cc:230
edm::Event::put
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition:
Event.h:115
JetMCTagUtils::EnergyRatioFromBHadrons
double EnergyRatioFromBHadrons(const reco::Candidate &c)
Definition:
JetMCTag.cc:12
GenJetCollection.h
ESHandle.h
j
int j
Definition:
DBlmapReader.cc:9
edm::EventSetup
Definition:
EventSetup.h:44
Jet.h
LorentzVector.h
GenJetBCEnergyRatio::GenJetBCEnergyRatio
GenJetBCEnergyRatio(const edm::ParameterSet &)
Definition:
GenJetBCEnergyRatio.cc:68
EDProducer.h
edm::AssociationVector< reco::JetRefBaseProd, Values >
GenJetBCEnergyRatio::m_genjetsSrcToken
edm::EDGetTokenT< View< Jet > > m_genjetsSrcToken
Definition:
GenJetBCEnergyRatio.cc:62
Ref.h
GenJetBCEnergyRatio::~GenJetBCEnergyRatio
~GenJetBCEnergyRatio()
Definition:
GenJetBCEnergyRatio.cc:77
edm::makeRefToBaseProdFrom
RefToBaseProd< T > makeRefToBaseProdFrom(RefToBase< T > const &iRef, Event const &iEvent)
Definition:
makeRefToBaseProdFrom.h:34
edm::InputTag
Definition:
InputTag.h:18
InputTag.h
JetMCTagUtils::EnergyRatioFromCHadrons
double EnergyRatioFromCHadrons(const reco::Candidate &c)
Definition:
JetMCTag.cc:26
GenJetBCEnergyRatio::genjets
Handle< View< Jet > > genjets
Definition:
GenJetBCEnergyRatio.cc:61
edm::ParameterSet
Definition:
ParameterSet.h:36
CandidateFwd.h
edm::Event
Definition:
Event.h:61
findQualityFiles.jj
string jj
Definition:
findQualityFiles.py:186
GenJet.h
GenJetBCEnergyRatio::JetBCEnergyRatioCollection
reco::JetFloatAssociation::Container JetBCEnergyRatioCollection
Definition:
GenJetBCEnergyRatio.cc:57
Generated for CMSSW Reference Manual by
1.8.5