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 
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 {
53  public:
56 
58 
59  private:
60  virtual void produce(edm::Event&, const edm::EventSetup& ) override;
63 
64 };
65 
66 //=========================================================================
67 
69 {
70  produces<JetBCEnergyRatioCollection>("bRatioCollection");
71  produces<JetBCEnergyRatioCollection>("cRatioCollection");
72  m_genjetsSrcToken = consumes< View <Jet> >(iConfig.getParameter<edm::InputTag>("genJets"));
73 }
74 
75 //=========================================================================
76 
78 {
79 }
80 
81 // ------------ method called to produce the data ------------
82 
84 {
85  iEvent.getByToken(m_genjetsSrcToken, genjets);
86 
88 
91 
92  if (genjets.product()->size() > 0) {
93  const JetRef jj = genjets->refAt(0);
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
124 
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:464
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
edm::Ref< JetCollection > JetRef
Definition: Jet.h:54
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:120
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
RefToBaseProd< T > makeRefToBaseProdFrom(RefToBase< T > const &iRef, Event const &iEvent)
double EnergyRatioFromCHadrons(const reco::Candidate &c)
Definition: JetMCTag.cc:26
Handle< View< Jet > > genjets
reco::JetFloatAssociation::Container JetBCEnergyRatioCollection