Skip to content

Commit

Permalink
Merge pull request #151 from tstreble/HGC_L1Ntuple_update
Browse files Browse the repository at this point in the history
HGCalTriggerNtuple update
  • Loading branch information
jbsauvan committed Oct 22, 2017
2 parents a0a50f5 + 9aad5af commit 23ba449
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
1 change: 1 addition & 0 deletions L1Trigger/L1THGCal/plugins/BuildFile.xml
Expand Up @@ -32,5 +32,6 @@
<use name="SimDataFormats/CaloTest"/>
<use name="DataFormats/JetReco"/>
<use name="Geometry/HcalTowerAlgo"/>
<use name="SimDataFormats/PileupSummaryInfo"/>
<flags EDM_PLUGIN="1"/>
</library>
23 changes: 23 additions & 0 deletions L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleGen.cc
@@ -1,4 +1,5 @@
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
#include "SimDataFormats/PileupSummaryInfo/interface/PileupSummaryInfo.h"
#include "L1Trigger/L1THGCal/interface/HGCalTriggerNtupleBase.h"


Expand All @@ -16,13 +17,17 @@ class HGCalTriggerNtupleGen : public HGCalTriggerNtupleBase
virtual void clear() override final;

edm::EDGetToken gen_token_;
edm::EDGetToken gen_PU_token_;

int gen_n_;
std::vector<int> gen_id_;
std::vector<int> gen_status_;
std::vector<float> gen_energy_;
std::vector<float> gen_pt_;
std::vector<float> gen_eta_;
std::vector<float> gen_phi_;
int gen_PUNumInt_;
float gen_TrueNumInt_;
};

DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory,
Expand All @@ -41,13 +46,16 @@ initialize(TTree& tree, const edm::ParameterSet& conf, edm::ConsumesCollector&&
{

gen_token_ = collector.consumes<reco::GenParticleCollection>(conf.getParameter<edm::InputTag>("GenParticles"));
gen_PU_token_ = collector.consumes<std::vector<PileupSummaryInfo>>(conf.getParameter<edm::InputTag>("GenPU"));
tree.Branch("gen_n", &gen_n_, "gen_n/I");
tree.Branch("gen_id", &gen_id_);
tree.Branch("gen_status", &gen_status_);
tree.Branch("gen_energy", &gen_energy_);
tree.Branch("gen_pt", &gen_pt_);
tree.Branch("gen_eta", &gen_eta_);
tree.Branch("gen_phi", &gen_phi_);
tree.Branch("gen_PUNumInt", &gen_PUNumInt_ ,"gen_PUNumInt/I");
tree.Branch("gen_TrueNumInt", &gen_TrueNumInt_ ,"gen_TrueNumInt/F");

}

Expand All @@ -59,6 +67,10 @@ fill(const edm::Event& e, const edm::EventSetup& es)
e.getByToken(gen_token_, gen_particles_h);
const reco::GenParticleCollection& gen_particles = *gen_particles_h;

edm::Handle<std::vector< PileupSummaryInfo > > PupInfo_h;
e.getByToken(gen_PU_token_, PupInfo_h);
const std::vector< PileupSummaryInfo >& PupInfo = *PupInfo_h;

clear();
gen_n_ = gen_particles.size();
gen_id_.reserve(gen_n_);
Expand All @@ -77,6 +89,15 @@ fill(const edm::Event& e, const edm::EventSetup& es)
gen_phi_.emplace_back(particle.phi());
}

for(const auto& PVI : PupInfo)
{
if(PVI.getBunchCrossing() == 0)
{
gen_PUNumInt_ = PVI.getPU_NumInteractions();
gen_TrueNumInt_ = PVI.getTrueNumInteractions();
}
}

}


Expand All @@ -91,6 +112,8 @@ clear()
gen_pt_.clear();
gen_eta_.clear();
gen_phi_.clear();
gen_PUNumInt_ = 0;
gen_TrueNumInt_ = 0.;
}


Expand Down
Expand Up @@ -24,6 +24,7 @@ class HGCalTriggerNtupleHGCClusters : public HGCalTriggerNtupleBase
edm::EDGetToken clusters_token_;

int cl_n_ ;
std::vector<float> cl_mipPt_;
std::vector<float> cl_pt_;
std::vector<float> cl_energy_;
std::vector<float> cl_eta_;
Expand Down Expand Up @@ -51,6 +52,7 @@ initialize(TTree& tree, const edm::ParameterSet& conf, edm::ConsumesCollector&&
clusters_token_ = collector.consumes<l1t::HGCalClusterBxCollection>(conf.getParameter<edm::InputTag>("Clusters"));

tree.Branch("cl_n", &cl_n_, "cl_n/I");
tree.Branch("cl_mipPt", &cl_mipPt_);
tree.Branch("cl_pt", &cl_pt_);
tree.Branch("cl_energy", &cl_energy_);
tree.Branch("cl_eta", &cl_eta_);
Expand Down Expand Up @@ -78,6 +80,7 @@ fill(const edm::Event& e, const edm::EventSetup& es)
for(auto cl_itr=clusters.begin(0); cl_itr!=clusters.end(0); cl_itr++)
{
cl_n_++;
cl_mipPt_.emplace_back(cl_itr->mipPt());
// physical values
cl_pt_.emplace_back(cl_itr->pt());
cl_energy_.emplace_back(cl_itr->energy());
Expand Down
Expand Up @@ -31,9 +31,11 @@ class HGCalTriggerNtupleHGCTriggerCells : public HGCalTriggerNtupleBase
std::vector<int> tc_wafertype_ ;
std::vector<int> tc_cell_;
std::vector<uint32_t> tc_data_;
std::vector<float> tc_mipPt_;
std::vector<float> tc_energy_;
std::vector<float> tc_eta_;
std::vector<float> tc_phi_;
std::vector<float> tc_pt_;
std::vector<float> tc_z_;

};
Expand Down Expand Up @@ -63,9 +65,11 @@ initialize(TTree& tree, const edm::ParameterSet& conf, edm::ConsumesCollector&&
tree.Branch("tc_wafertype", &tc_wafertype_);
tree.Branch("tc_cell", &tc_cell_);
tree.Branch("tc_data", &tc_data_);
tree.Branch("tc_mipPt", &tc_mipPt_);
tree.Branch("tc_energy", &tc_energy_);
tree.Branch("tc_eta", &tc_eta_);
tree.Branch("tc_phi", &tc_phi_);
tree.Branch("tc_pt", &tc_pt_);
tree.Branch("tc_z", &tc_z_);

}
Expand Down Expand Up @@ -100,10 +104,12 @@ fill(const edm::Event& e, const edm::EventSetup& es)
tc_wafertype_.emplace_back(id.waferType());
tc_cell_.emplace_back(id.cell());
tc_data_.emplace_back(tc_itr->hwPt());
tc_mipPt_.emplace_back(tc_itr->mipPt());
// physical values
tc_energy_.emplace_back(tc_itr->energy());
tc_eta_.emplace_back(tc_itr->eta());
tc_phi_.emplace_back(tc_itr->phi());
tc_pt_.emplace_back(tc_itr->pt());
tc_z_.emplace_back(tc_itr->position().z());
}
}
Expand All @@ -123,9 +129,11 @@ clear()
tc_wafertype_.clear();
tc_cell_.clear();
tc_data_.clear();
tc_mipPt_.clear();
tc_energy_.clear();
tc_eta_.clear();
tc_phi_.clear();
tc_pt_.clear();
tc_z_.clear();
}

Expand Down
3 changes: 2 additions & 1 deletion L1Trigger/L1THGCal/python/hgcalTriggerNtuples_cfi.py
Expand Up @@ -7,7 +7,8 @@

ntuple_gen = cms.PSet(
NtupleName = cms.string('HGCalTriggerNtupleGen'),
GenParticles = cms.InputTag('genParticles')
GenParticles = cms.InputTag('genParticles'),
GenPU = cms.InputTag('addPileupInfo')
)

ntuple_gentau = cms.PSet(
Expand Down

0 comments on commit 23ba449

Please sign in to comment.