test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
20 
24 
31 
35 
36 #include <memory>
37 #include <string>
38 #include <iostream>
39 #include <vector>
40 #include <Math/VectorUtil.h>
41 #include <TMath.h>
42 
43 using namespace std;
44 using namespace reco;
45 using namespace edm;
46 using namespace ROOT::Math::VectorUtil;
47 using namespace JetMCTagUtils;
48 using namespace CandMCTagUtils;
49 
51 {
52  public:
55 
57 
58  private:
59  virtual void produce(edm::Event&, const edm::EventSetup& ) override;
62 
63 };
64 
65 //=========================================================================
66 
68 {
69  produces<JetBCEnergyRatioCollection>("bRatioCollection");
70  produces<JetBCEnergyRatioCollection>("cRatioCollection");
71  m_genjetsSrcToken = consumes< View <Jet> >(iConfig.getParameter<edm::InputTag>("genJets"));
72 }
73 
74 //=========================================================================
75 
77 {
78 }
79 
80 // ------------ method called to produce the data ------------
81 
83 {
84  iEvent.getByToken(m_genjetsSrcToken, genjets);
85 
87 
90 
91  if (genjets.product()->size() > 0) {
92  const JetRef jj = genjets->refAt(0);
95  } else {
96  jtc1 = new JetBCEnergyRatioCollection();
97  jtc2 = new JetBCEnergyRatioCollection();
98  }
99 
100  std::auto_ptr<JetBCEnergyRatioCollection> bRatioColl(jtc1);
101  std::auto_ptr<JetBCEnergyRatioCollection> cRatioColl(jtc2);
102 
103  for( size_t j = 0; j != genjets->size(); ++j ) {
104 
105  float bRatio = EnergyRatioFromBHadrons( (*genjets)[j] );
106  float cRatio = EnergyRatioFromCHadrons( (*genjets)[j] );
107 
108  const JetRef & aJet = genjets->refAt(j) ;
109 
110  JetFloatAssociation::setValue(*bRatioColl, aJet, bRatio);
111  JetFloatAssociation::setValue(*cRatioColl, aJet, cRatio);
112 
113  }
114 
115 
116  iEvent.put(bRatioColl, "bRatioCollection");
117  iEvent.put(cRatioColl, "cRatioCollection");
118 
119 }
120 
121 //define this as a plug-in
123 
T getParameter(std::string const &) const
virtual void produce(edm::Event &, const edm::EventSetup &) override
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::Ref< JetCollection > JetRef
Definition: Jet.h:51
bool setValue(Container &, const reco::JetBaseRef &, const JetExtendedData &)
associate jet with value. Returns false and associate nothing if jet is already associated ...
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:116
double EnergyRatioFromBHadrons(const reco::Candidate &c)
Definition: JetMCTag.cc:12
int j
Definition: DBlmapReader.cc:9
GenJetBCEnergyRatio(const edm::ParameterSet &)
edm::EDGetTokenT< View< Jet > > m_genjetsSrcToken
double EnergyRatioFromCHadrons(const reco::Candidate &c)
Definition: JetMCTag.cc:26
Handle< View< Jet > > genjets
reco::JetFloatAssociation::Container JetBCEnergyRatioCollection