CMS 3D CMS Logo

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
14 
21 
25 
32 
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 
52 public:
54  ~GenJetBCEnergyRatio() override;
55 
57 
58 private:
59  void produce(StreamID, edm::Event&, const edm::EventSetup&) const override;
61 };
62 
63 //=========================================================================
64 
66  produces<JetBCEnergyRatioCollection>("bRatioCollection");
67  produces<JetBCEnergyRatioCollection>("cRatioCollection");
68  m_genjetsSrcToken = consumes<View<Jet> >(iConfig.getParameter<edm::InputTag>("genJets"));
69 }
70 
71 //=========================================================================
72 
74 
75 // ------------ method called to produce the data ------------
76 
78  Handle<View<Jet> > genjets;
79  iEvent.getByToken(m_genjetsSrcToken, genjets);
80 
82 
85 
86  if (!genjets.product()->empty()) {
87  const JetRef jj = genjets->refAt(0);
90  } else {
91  jtc1 = new JetBCEnergyRatioCollection();
92  jtc2 = new JetBCEnergyRatioCollection();
93  }
94 
95  std::unique_ptr<JetBCEnergyRatioCollection> bRatioColl(jtc1);
96  std::unique_ptr<JetBCEnergyRatioCollection> cRatioColl(jtc2);
97 
98  for (size_t j = 0; j != genjets->size(); ++j) {
99  float bRatio = EnergyRatioFromBHadrons((*genjets)[j]);
100  float cRatio = EnergyRatioFromCHadrons((*genjets)[j]);
101 
102  const JetRef& aJet = genjets->refAt(j);
103 
104  JetFloatAssociation::setValue(*bRatioColl, aJet, bRatio);
105  JetFloatAssociation::setValue(*cRatioColl, aJet, cRatio);
106  }
107 
108  iEvent.put(std::move(bRatioColl), "bRatioCollection");
109  iEvent.put(std::move(cRatioColl), "cRatioCollection");
110 }
111 
112 //define this as a plug-in
edm::StreamID
Definition: StreamID.h:30
GenJetCollection.h
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
MessageLogger.h
edm::Handle::product
T const * product() const
Definition: Handle.h:70
ESHandle.h
CandMCTag.h
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
JetFloatAssociation.h
Jet.h
reco
fixed size matrix
Definition: AlignmentAlgorithmBase.h:45
edm::Handle
Definition: AssociativeIterator.h:50
CandidateFwd.h
MakerMacros.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
GenJetBCEnergyRatio::GenJetBCEnergyRatio
GenJetBCEnergyRatio(const edm::ParameterSet &)
Definition: GenJetBCEnergyRatio.cc:65
edm::global::EDProducer
Definition: EDProducer.h:32
edm::AssociationVector
Definition: AssociationVector.h:67
edm::ParameterSet
Definition: ParameterSet.h:47
CandMCTagUtils
Definition: CandMCTag.h:6
Event.h
edm::makeRefToBaseProdFrom
RefToBaseProd< T > makeRefToBaseProdFrom(RefToBase< T > const &iRef, Event const &iEvent)
Definition: makeRefToBaseProdFrom.h:34
GenJetBCEnergyRatio::JetBCEnergyRatioCollection
reco::JetFloatAssociation::Container JetBCEnergyRatioCollection
Definition: GenJetBCEnergyRatio.cc:56
JetFlavour.h
GenJetBCEnergyRatio::produce
void produce(StreamID, edm::Event &, const edm::EventSetup &) const override
Definition: GenJetBCEnergyRatio.cc:77
LorentzVector.h
JetMCTagUtils::EnergyRatioFromBHadrons
double EnergyRatioFromBHadrons(const reco::Candidate &c)
Definition: JetMCTag.cc:12
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:58
makeRefToBaseProdFrom.h
l1t::JetRef
edm::Ref< JetBxCollection > JetRef
Definition: Jet.h:12
GenJetBCEnergyRatio
Definition: GenJetBCEnergyRatio.cc:51
InputTag.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
Ref.h
JetMCTagUtils::EnergyRatioFromCHadrons
double EnergyRatioFromCHadrons(const reco::Candidate &c)
Definition: JetMCTag.cc:24
GenJetBCEnergyRatio::~GenJetBCEnergyRatio
~GenJetBCEnergyRatio() override
Definition: GenJetBCEnergyRatio.cc:73
findQualityFiles.jj
string jj
Definition: findQualityFiles.py:188
Point3D.h
ParameterSetfwd.h
EventSetup.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::RefToBase< reco::Jet >
GenJet.h
Candidate.h
ParameterSet.h
JetMCTag.h
JetMCTagUtils
Definition: JetMCTag.h:7
EDProducer.h
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
GenJetBCEnergyRatio::m_genjetsSrcToken
edm::EDGetTokenT< View< Jet > > m_genjetsSrcToken
Definition: GenJetBCEnergyRatio.cc:60
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15