Skip to content

Commit

Permalink
Merge pull request cms-sw#152 from jbsauvan/backport-layer-cluster-calib
Browse files Browse the repository at this point in the history
Backport layer-by-layer cluster calibration
  • Loading branch information
jbsauvan authored Oct 23, 2017
2 parents eafb824 + 6e27173 commit 73c43bd
Show file tree
Hide file tree
Showing 11 changed files with 226 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,15 @@ class HGCalMulticlusteringImpl{
string multiclusterAlgoType_;
double distDbscan_ = 0.005;
unsigned minNDbscan_ = 3;
std::vector<double> layerWeights_;
bool applyLayerWeights_;

HGCalShowerShape shape_;

static const int kLayersEE_=28;
static const int kLayersFH_=12;
static const int kLayersBH_=12;

};

#endif
1 change: 1 addition & 0 deletions L1Trigger/L1THGCal/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
47 changes: 36 additions & 11 deletions L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleGenTau.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ class HGCalTriggerNtupleGenTau : public HGCalTriggerNtupleBase
bool isStableLepton( const reco::GenParticle & daughter ) const;
bool isElectron( const reco::GenParticle & daughter ) const;
bool isMuon( const reco::GenParticle & daughter ) const;
bool isChargedPion( const reco::GenParticle & daughter ) const;
bool isChargedHadron( const reco::GenParticle & daughter ) const;
bool isChargedHadronFromResonance( const reco::GenParticle & daughter ) const;
bool isNeutralPion( const reco::GenParticle & daughter ) const;
bool isNeutralPionFromResonance( const reco::GenParticle & daughter ) const;
bool isIntermediateResonance( const reco::GenParticle & daughter ) const;
bool isGamma( const reco::GenParticle & daughter ) const;
bool isStableNeutralHadron( const reco::GenParticle & daughter ) const;

edm::EDGetToken gen_token_;
bool isPythia8generator_;
Expand All @@ -44,6 +47,7 @@ class HGCalTriggerNtupleGenTau : public HGCalTriggerNtupleBase
std::vector<int> gentau_decayMode_;
std::vector<int> gentau_totNproducts_;
std::vector<int> gentau_totNgamma_;
std::vector<int> gentau_totNpiZero_;
std::vector<int> gentau_totNcharged_;

std::vector<std::vector<float> > gentau_products_pt_;
Expand Down Expand Up @@ -92,6 +96,7 @@ initialize(TTree& tree, const edm::ParameterSet& conf, edm::ConsumesCollector&&
tree.Branch("gentau_decayMode", &gentau_decayMode_);
tree.Branch("gentau_totNproducts", &gentau_totNproducts_);
tree.Branch("gentau_totNgamma", &gentau_totNgamma_);
tree.Branch("gentau_totNpiZero", &gentau_totNpiZero_);
tree.Branch("gentau_totNcharged", &gentau_totNcharged_);

}
Expand All @@ -101,11 +106,16 @@ bool HGCalTriggerNtupleGenTau::isGoodTau( const reco::GenParticle& candidate ) c
}


bool HGCalTriggerNtupleGenTau::isChargedPion( const reco::GenParticle& candidate ) const {
return ( std::abs(candidate.pdgId()) == 211 && candidate.status()==1
bool HGCalTriggerNtupleGenTau::isChargedHadron( const reco::GenParticle& candidate ) const {
return ( (std::abs(candidate.pdgId()) == 211 || std::abs(candidate.pdgId()) == 321 ) && candidate.status()==1
&& candidate.isDirectPromptTauDecayProductFinalState() && candidate.isLastCopy() );
}

bool HGCalTriggerNtupleGenTau::isChargedHadronFromResonance( const reco::GenParticle& candidate ) const {
return ( (std::abs(candidate.pdgId()) == 211 || std::abs(candidate.pdgId()) == 321 ) && candidate.status()==1
&& candidate.isLastCopy() );
}


bool HGCalTriggerNtupleGenTau::isStableLepton( const reco::GenParticle& candidate ) const
{
Expand Down Expand Up @@ -133,17 +143,29 @@ bool HGCalTriggerNtupleGenTau::isNeutralPion( const reco::GenParticle& candidate
}


bool HGCalTriggerNtupleGenTau::isNeutralPionFromResonance( const reco::GenParticle& candidate ) const
{
return ( std::abs(candidate.pdgId()) == 111 && candidate.status()==2 && candidate.statusFlags().isTauDecayProduct() );
}


bool HGCalTriggerNtupleGenTau::isGamma( const reco::GenParticle& candidate ) const
{
return ( std::abs(candidate.pdgId()) == 22 && candidate.status()==1 && candidate.statusFlags().isTauDecayProduct()
&& !candidate.isDirectPromptTauDecayProductFinalState() && candidate.isLastCopy() );
}


bool HGCalTriggerNtupleGenTau::isIntermediateResonance( const reco::GenParticle& candidate ) const
{
return ( ( std::abs(candidate.pdgId()) == 213 || std::abs(candidate.pdgId()) == 20213 || std::abs(candidate.pdgId()) == 24 )
&& candidate.isDirectPromptTauDecayProductFinalState() && candidate.status() == 2 );
&& candidate.status() == 2 );
}


bool HGCalTriggerNtupleGenTau::isStableNeutralHadron( const reco::GenParticle& candidate ) const
{
return ( !( std::abs(candidate.pdgId())>10 && std::abs(candidate.pdgId())<17) && !isChargedHadron(candidate)
&& candidate.isDirectPromptTauDecayProductFinalState() && candidate.status() == 1 );
}


Expand All @@ -159,10 +181,8 @@ fill(const edm::Event& e, const edm::EventSetup& es)

for(const auto& particle : gen_particles)
{

/* select good taus */
if( isGoodTau( particle ) ){

LorentzVector tau_p4vis(0.,0.,0.,0.);
gentau_pt_.emplace_back( particle.pt() );
gentau_eta_.emplace_back( particle.eta() );
Expand Down Expand Up @@ -201,13 +221,13 @@ fill(const edm::Event& e, const edm::EventSetup& es)
finalProds.push_back( daughter );
}

if( isChargedPion( *daughter ) ){
else if( isChargedHadron( *daughter ) ){
n_pi++;
tau_p4vis+=(daughter->p4());
finalProds.push_back( daughter );
}

if( isNeutralPion( *daughter ) ){
else if( isNeutralPion( *daughter ) ){
n_piZero++;
const reco::GenParticleRefVector& grandaughters = daughter->daughterRefVector();
for( const auto& grandaughter : grandaughters ){
Expand All @@ -219,17 +239,21 @@ fill(const edm::Event& e, const edm::EventSetup& es)
}
}

else if( isStableNeutralHadron( *daughter ) ){
tau_p4vis+=(daughter->p4());
finalProds.push_back( daughter );
}
/* Here the selection of the decay product according to the Pythia6 decayTree */
if( !isPythia8generator_ ){
if( isIntermediateResonance( *daughter ) ){
const reco::GenParticleRefVector& grandaughters = daughter->daughterRefVector();
for( const auto& grandaughter : grandaughters ){
if( isChargedPion( *grandaughter ) ){
if( isChargedHadron( *grandaughter ) || isChargedHadronFromResonance( *grandaughter ) ){
n_pi++;
tau_p4vis+=(grandaughter->p4());
finalProds.push_back( daughter );
}
if( isNeutralPion( *grandaughter ) ){
else if( isNeutralPion( *grandaughter ) || isNeutralPionFromResonance( *grandaughter ) ){
n_piZero++;
const reco::GenParticleRefVector& descendants = grandaughter->daughterRefVector();
for( const auto& descendant : descendants ){
Expand Down Expand Up @@ -264,6 +288,7 @@ fill(const edm::Event& e, const edm::EventSetup& es)
gentau_vis_mass_.emplace_back(tau_p4vis.M());
gentau_totNproducts_.emplace_back(n_pi + n_gamma);
gentau_totNgamma_.emplace_back(n_gamma);
gentau_totNpiZero_.emplace_back(n_piZero);
gentau_totNcharged_.emplace_back(n_pi);

gentau_products_pt_.emplace_back(tau_products_pt);
Expand Down
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Loading

0 comments on commit 73c43bd

Please sign in to comment.