Skip to content

Commit

Permalink
Merge pull request cms-sw#118 from amarini/hgc_trig_genjets
Browse files Browse the repository at this point in the history
GenJets ntuplizer
  • Loading branch information
jbsauvan authored Jun 30, 2017
2 parents c44ac50 + 64dddbf commit 91aa618
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 0 deletions.
1 change: 1 addition & 0 deletions L1Trigger/L1THGCal/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
<use name="L1Trigger/L1THGCal"/>
<use name="CommonTools/UtilAlgos"/>
<use name="SimDataFormats/CaloTest"/>
<use name="DataFormats/JetReco"/>
<flags EDM_PLUGIN="1"/>
</library>
93 changes: 93 additions & 0 deletions L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleGenJet.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
#include "DataFormats/JetReco/interface/GenJet.h"
#include "DataFormats/JetReco/interface/GenJetCollection.h"

#include "L1Trigger/L1THGCal/interface/HGCalTriggerNtupleBase.h"



class HGCalTriggerNtupleGenJet : public HGCalTriggerNtupleBase
{

public:
HGCalTriggerNtupleGenJet(const edm::ParameterSet& );

virtual void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) override final;
virtual void fill(const edm::Event&, const edm::EventSetup& ) override final;

private:
virtual void clear() override final;

edm::EDGetToken genjet_token_;

int genjet_n_;
std::vector<float> genjet_energy_;
std::vector<float> genjet_pt_;
std::vector<float> genjet_eta_;
std::vector<float> genjet_phi_;

};

DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory,
HGCalTriggerNtupleGenJet,
"HGCalTriggerNtupleGenJet" );


HGCalTriggerNtupleGenJet::
HGCalTriggerNtupleGenJet(const edm::ParameterSet& conf):HGCalTriggerNtupleBase(conf)
{
}

void
HGCalTriggerNtupleGenJet::
initialize(TTree& tree, const edm::ParameterSet& conf, edm::ConsumesCollector&& collector)
{

genjet_token_ = collector.consumes<reco::GenJetCollection>(conf.getParameter<edm::InputTag>("GenJets"));
tree.Branch("genjet_n", &genjet_n_, "genjet_n/I");
tree.Branch("genjet_energy", &genjet_energy_);
tree.Branch("genjet_pt", &genjet_pt_);
tree.Branch("genjet_eta", &genjet_eta_);
tree.Branch("genjet_phi", &genjet_phi_);

}

void
HGCalTriggerNtupleGenJet::
fill(const edm::Event& e, const edm::EventSetup& es)
{
edm::Handle< reco::GenJetCollection > genjets_h;
e.getByToken(genjet_token_, genjets_h);
const reco::GenJetCollection& genjets = *genjets_h;

clear();
genjet_n_ = genjets.size();
genjet_energy_.reserve(genjet_n_);
genjet_pt_.reserve(genjet_n_);
genjet_eta_.reserve(genjet_n_);
genjet_phi_.reserve(genjet_n_);
for(const auto& jet : genjets)
{
genjet_energy_.emplace_back(jet.energy());
genjet_pt_.emplace_back(jet.pt());
genjet_eta_.emplace_back(jet.eta());
genjet_phi_.emplace_back(jet.phi());
}

}


void
HGCalTriggerNtupleGenJet::
clear()
{
genjet_n_ = 0;
genjet_energy_.clear();
genjet_pt_.clear();
genjet_eta_.clear();
genjet_phi_.clear();
}




6 changes: 6 additions & 0 deletions L1Trigger/L1THGCal/python/hgcalTriggerNtuples_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
GenParticles = cms.InputTag('genParticles')
)

ntuple_genjet = cms.PSet(
NtupleName = cms.string('HGCalTriggerNtupleGenJet'),
GenJets = cms.InputTag('ak4GenJetsNoNu')
)

ntuple_digis = cms.PSet(
NtupleName = cms.string('HGCalTriggerNtupleHGCDigis'),
HGCDigisEE = cms.InputTag('mix:HGCDigisEE'),
Expand Down Expand Up @@ -39,6 +44,7 @@
Ntuples = cms.VPSet(
ntuple_event,
ntuple_gen,
ntuple_genjet,
ntuple_digis,
ntuple_triggercells,
ntuple_clusters,
Expand Down

0 comments on commit 91aa618

Please sign in to comment.