Skip to content

Commit

Permalink
Merge pull request cms-sw#155 from jbsauvan/backport-932-clustershape…
Browse files Browse the repository at this point in the history
…s-ntuples-updates

Backport in 932 cluster shapes and ntuples updates
  • Loading branch information
jbsauvan authored Oct 31, 2017
2 parents 85fe70e + 454ac83 commit 05a3e6b
Show file tree
Hide file tree
Showing 9 changed files with 369 additions and 36 deletions.
9 changes: 9 additions & 0 deletions DataFormats/L1THGCal/interface/HGCalClusterT.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ namespace l1t
//shower shape

int showerLength() const { return showerLength_; }
int coreShowerLength() const { return coreShowerLength_; }
int firstLayer() const { return firstLayer_; }
int maxLayer() const { return maxLayer_; }
float eMax() const { return eMax_; }
float sigmaEtaEtaMax() const { return sigmaEtaEtaMax_; }
float sigmaPhiPhiMax() const { return sigmaPhiPhiMax_; }
Expand All @@ -154,16 +156,20 @@ namespace l1t
float sigmaZZ() const { return sigmaZZ_; }
float sigmaRRTot() const { return sigmaRRTot_; }
float sigmaRRMax() const { return sigmaRRMax_; }
float sigmaRRMean() const { return sigmaRRMean_; }

void set_showerLength(int showerLength) { showerLength_ = showerLength;}
void set_coreShowerLength(int coreShowerLength) { coreShowerLength_ = coreShowerLength;}
void set_firstLayer(int firstLayer) { firstLayer_ = firstLayer;}
void set_maxLayer(int maxLayer) { maxLayer_ = maxLayer;}
void set_eMax(float eMax) { eMax_ = eMax;}
void set_sigmaEtaEtaMax(float sigmaEtaEtaMax) { sigmaEtaEtaMax_ = sigmaEtaEtaMax;}
void set_sigmaEtaEtaTot(float sigmaEtaEtaTot) { sigmaEtaEtaTot_ = sigmaEtaEtaTot;}
void set_sigmaPhiPhiMax(float sigmaPhiPhiMax) { sigmaPhiPhiMax_ = sigmaPhiPhiMax;}
void set_sigmaPhiPhiTot(float sigmaPhiPhiTot) { sigmaPhiPhiTot_ = sigmaPhiPhiTot;}
void set_sigmaRRMax(float sigmaRRMax) { sigmaRRMax_ = sigmaRRMax;}
void set_sigmaRRTot(float sigmaRRTot) { sigmaRRTot_ = sigmaRRTot;}
void set_sigmaRRMean(float sigmaRRMean) { sigmaRRMean_ = sigmaRRMean;}
void set_sigmaZZ(float sigmaZZ) { sigmaZZ_ = sigmaZZ;}

/* operators */
Expand All @@ -186,14 +192,17 @@ namespace l1t
//shower shape

int showerLength_;
int coreShowerLength_;
int firstLayer_;
int maxLayer_;
float eMax_;
float sigmaEtaEtaMax_;
float sigmaPhiPhiMax_;
float sigmaRRMax_;
float sigmaEtaEtaTot_;
float sigmaPhiPhiTot_;
float sigmaRRTot_;
float sigmaRRMean_;
float sigmaZZ_;

ClusterShapes shapes_;
Expand Down
6 changes: 4 additions & 2 deletions DataFormats/L1THGCal/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
<class name="edm::Wrapper<l1t::HGCalTowerBxCollection>"/>

<class name="l1t::HGCalClusterT<l1t::HGCalTriggerCell>" />
<class name="l1t::HGCalCluster" ClassVersion="12">
<class name="l1t::HGCalCluster" ClassVersion="13">
<version ClassVersion="13" checksum="3397489079"/>
<version ClassVersion="12" checksum="623703096"/>
<version ClassVersion="11" checksum="354623225"/>
<version ClassVersion="10" checksum="607544984"/>
Expand All @@ -30,7 +31,8 @@
<class name="edm::Wrapper<l1t::HGCalClusterBxCollection>"/>

<class name="l1t::HGCalClusterT<l1t::HGCalCluster>" />
<class name="l1t::HGCalMulticluster" ClassVersion="12">
<class name="l1t::HGCalMulticluster" ClassVersion="13">
<version ClassVersion="13" checksum="816077951"/>
<version ClassVersion="12" checksum="4221677522"/>
<version ClassVersion="11" checksum="1508179045"/>
<version ClassVersion="10" checksum="1878482802"/>
Expand Down
4 changes: 4 additions & 0 deletions L1Trigger/L1THGCal/interface/be_algorithms/HGCalShowerShape.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ class HGCalShowerShape{

int firstLayer(const l1t::HGCalMulticluster& c3d) const;
int lastLayer(const l1t::HGCalMulticluster& c3d) const;
int maxLayer(const l1t::HGCalMulticluster& c3d) const;
int showerLength(const l1t::HGCalMulticluster& c3d) const {return lastLayer(c3d)-firstLayer(c3d)+1; }//in number of layers
// Maximum number of consecutive layers in the cluster
int coreShowerLength(const l1t::HGCalMulticluster& c3d) const;

float eMax(const l1t::HGCalMulticluster& c3d) const;

Expand All @@ -33,6 +36,7 @@ class HGCalShowerShape{
float sigmaRRTot(const l1t::HGCalMulticluster& c3d) const;
float sigmaRRTot(const l1t::HGCalCluster& c2d) const;
float sigmaRRMax(const l1t::HGCalMulticluster& c3d) const;
float sigmaRRMean(const l1t::HGCalMulticluster& c3d, float radius=5.) const;

private:

Expand Down
60 changes: 49 additions & 11 deletions L1Trigger/L1THGCal/plugins/ntuples/HGCalTriggerNtupleHGCClusters.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

#include <algorithm>
#include "DataFormats/L1THGCal/interface/HGCalCluster.h"
#include "DataFormats/L1THGCal/interface/HGCalMulticluster.h"
#include "DataFormats/ForwardDetId/interface/HGCalDetId.h"
#include "Geometry/Records/interface/CaloGeometryRecord.h"
#include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h"
Expand All @@ -20,18 +21,22 @@ class HGCalTriggerNtupleHGCClusters : public HGCalTriggerNtupleBase
private:
virtual void clear() override final;


edm::EDGetToken clusters_token_;
bool filter_clusters_in_multiclusters_;
edm::EDGetToken clusters_token_, multiclusters_token_;

int cl_n_ ;
std::vector<uint32_t> cl_id_;
std::vector<float> cl_mipPt_;
std::vector<float> cl_pt_;
std::vector<float> cl_energy_;
std::vector<float> cl_eta_;
std::vector<float> cl_phi_;
std::vector<int> cl_layer_;
std::vector<int> cl_ncells_;
std::vector<std::vector<unsigned>> cl_cells_;
std::vector<int> cl_subdet_;
std::vector<int> cl_cells_n_;
std::vector<std::vector<uint32_t>> cl_cells_id_;
std::vector<uint32_t> cl_multicluster_id_;
std::vector<float> cl_multicluster_pt_;

};

Expand All @@ -43,23 +48,29 @@ DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory,
HGCalTriggerNtupleHGCClusters::
HGCalTriggerNtupleHGCClusters(const edm::ParameterSet& conf):HGCalTriggerNtupleBase(conf)
{
filter_clusters_in_multiclusters_ = conf.getParameter<bool>("FilterClustersInMulticlusters");
}

void
HGCalTriggerNtupleHGCClusters::
initialize(TTree& tree, const edm::ParameterSet& conf, edm::ConsumesCollector&& collector)
{
clusters_token_ = collector.consumes<l1t::HGCalClusterBxCollection>(conf.getParameter<edm::InputTag>("Clusters"));
multiclusters_token_ = collector.consumes<l1t::HGCalMulticlusterBxCollection>(conf.getParameter<edm::InputTag>("Multiclusters"));

tree.Branch("cl_n", &cl_n_, "cl_n/I");
tree.Branch("cl_id", &cl_id_);
tree.Branch("cl_mipPt", &cl_mipPt_);
tree.Branch("cl_pt", &cl_pt_);
tree.Branch("cl_energy", &cl_energy_);
tree.Branch("cl_eta", &cl_eta_);
tree.Branch("cl_phi", &cl_phi_);
tree.Branch("cl_layer", &cl_layer_);
tree.Branch("cl_ncells", &cl_ncells_);
tree.Branch("cl_cells", &cl_cells_);
tree.Branch("cl_subdet", &cl_subdet_);
tree.Branch("cl_cells_n", &cl_cells_n_);
tree.Branch("cl_cells_id", &cl_cells_id_);
tree.Branch("cl_multicluster_id", &cl_multicluster_id_);
tree.Branch("cl_multicluster_pt", &cl_multicluster_pt_);
}

void
Expand All @@ -71,28 +82,50 @@ fill(const edm::Event& e, const edm::EventSetup& es)
edm::Handle<l1t::HGCalClusterBxCollection> clusters_h;
e.getByToken(clusters_token_, clusters_h);
const l1t::HGCalClusterBxCollection& clusters = *clusters_h;
edm::Handle<l1t::HGCalMulticlusterBxCollection> multiclusters_h;
e.getByToken(multiclusters_token_, multiclusters_h);
const l1t::HGCalMulticlusterBxCollection& multiclusters = *multiclusters_h;

// retrieve geometry
edm::ESHandle<HGCalTriggerGeometryBase> geometry;
es.get<CaloGeometryRecord>().get(geometry);

// Associate cells to clusters
std::unordered_map<uint32_t, l1t::HGCalMulticlusterBxCollection::const_iterator> cluster2multicluster;
for(auto mcl_itr=multiclusters.begin(0); mcl_itr!=multiclusters.end(0); mcl_itr++)
{
// loop on 2D clusters inside 3D clusters
for(const auto& cl_ptr : mcl_itr->constituents())
{
cluster2multicluster.emplace(cl_ptr->detId(), mcl_itr);
}
}

clear();
for(auto cl_itr=clusters.begin(0); cl_itr!=clusters.end(0); cl_itr++)
{
auto mcl_itr = cluster2multicluster.find(cl_itr->detId());
uint32_t mcl_id = (mcl_itr!=cluster2multicluster.end() ? mcl_itr->second->detId() : 0);
float mcl_pt = (mcl_itr!=cluster2multicluster.end() ? mcl_itr->second->pt() : 0.);
if(filter_clusters_in_multiclusters_ && mcl_id==0) continue;
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());
cl_eta_.emplace_back(cl_itr->eta());
cl_phi_.emplace_back(cl_itr->phi());
cl_id_.emplace_back(cl_itr->detId());
cl_layer_.emplace_back(cl_itr->layer());
cl_ncells_.emplace_back(cl_itr->constituents().size());
cl_subdet_.emplace_back(cl_itr->subdetId());
cl_cells_n_.emplace_back(cl_itr->constituents().size());
// Retrieve indices of trigger cells inside cluster
cl_cells_.emplace_back(cl_itr->constituents().size());
cl_cells_id_.emplace_back(cl_itr->constituents().size());
std::transform(cl_itr->constituents_begin(), cl_itr->constituents_end(),
cl_cells_.back().begin(), [](const edm::Ptr<l1t::HGCalTriggerCell>& tc){return tc.key();}
cl_cells_id_.back().begin(), [](const edm::Ptr<l1t::HGCalTriggerCell>& tc){return tc->detId();}
);
cl_multicluster_id_.emplace_back(mcl_id);
cl_multicluster_pt_.emplace_back(mcl_pt);
}
}

Expand All @@ -102,13 +135,18 @@ HGCalTriggerNtupleHGCClusters::
clear()
{
cl_n_ = 0;
cl_id_.clear();
cl_mipPt_.clear();
cl_pt_.clear();
cl_energy_.clear();
cl_eta_.clear();
cl_phi_.clear();
cl_layer_.clear();
cl_ncells_.clear();
cl_cells_.clear();
cl_subdet_.clear();
cl_cells_n_.clear();
cl_cells_id_.clear();
cl_multicluster_id_.clear();
cl_multicluster_pt_.clear();
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,27 @@ class HGCalTriggerNtupleHGCMulticlusters : public HGCalTriggerNtupleBase
edm::EDGetToken multiclusters_token_;

int cl3d_n_ ;
std::vector<uint32_t> cl3d_id_;
std::vector<float> cl3d_pt_;
std::vector<float> cl3d_energy_;
std::vector<float> cl3d_eta_;
std::vector<float> cl3d_phi_;
std::vector<int> cl3d_nclu_;
std::vector<int> cl3d_clusters_n_;
std::vector<std::vector<uint32_t>> cl3d_clusters_id_;
// cluster shower shapes
std::vector<int> cl3d_showerlength_;
std::vector<int> cl3d_coreshowerlength_;
std::vector<int> cl3d_firstlayer_;
std::vector<int> cl3d_maxlayer_;
std::vector<float> cl3d_seetot_;
std::vector<float> cl3d_seemax_;
std::vector<float> cl3d_spptot_;
std::vector<float> cl3d_sppmax_;
std::vector<float> cl3d_szz_;
std::vector<float> cl3d_srrtot_;
std::vector<float> cl3d_srrmax_;
std::vector<float> cl3d_srrmean_;
std::vector<float> cl3d_emaxe_;
std::vector<std::vector<unsigned>> cl3d_clusters_;
};

DEFINE_EDM_PLUGIN(HGCalTriggerNtupleFactory,
Expand All @@ -56,22 +61,26 @@ initialize(TTree& tree, const edm::ParameterSet& conf, edm::ConsumesCollector&&
multiclusters_token_ = collector.consumes<l1t::HGCalMulticlusterBxCollection>(conf.getParameter<edm::InputTag>("Multiclusters"));

tree.Branch("cl3d_n", &cl3d_n_, "cl3d_n/I");
tree.Branch("cl3d_id", &cl3d_id_);
tree.Branch("cl3d_pt", &cl3d_pt_);
tree.Branch("cl3d_energy", &cl3d_energy_);
tree.Branch("cl3d_eta", &cl3d_eta_);
tree.Branch("cl3d_phi", &cl3d_phi_);
tree.Branch("cl3d_nclu", &cl3d_nclu_);
tree.Branch("cl3d_clusters_n", &cl3d_clusters_n_);
tree.Branch("cl3d_clusters_id", &cl3d_clusters_id_);
tree.Branch("cl3d_showerlength", &cl3d_showerlength_);
tree.Branch("cl3d_coreshowerlength", &cl3d_coreshowerlength_);
tree.Branch("cl3d_firstlayer", &cl3d_firstlayer_);
tree.Branch("cl3d_maxlayer", &cl3d_maxlayer_);
tree.Branch("cl3d_seetot", &cl3d_seetot_);
tree.Branch("cl3d_seemax", &cl3d_seemax_);
tree.Branch("cl3d_spptot", &cl3d_spptot_);
tree.Branch("cl3d_sppmax", &cl3d_sppmax_);
tree.Branch("cl3d_szz", &cl3d_szz_);
tree.Branch("cl3d_srrtot", &cl3d_srrtot_);
tree.Branch("cl3d_srrmax", &cl3d_srrmax_);
tree.Branch("cl3d_emaxe", &cl3d_emaxe_);
tree.Branch("cl3d_clusters", &cl3d_clusters_);
tree.Branch("cl3d_srrmean", &cl3d_srrmean_);
tree.Branch("cl3d_emaxe", &cl3d_emaxe_);

}

Expand All @@ -93,27 +102,31 @@ fill(const edm::Event& e, const edm::EventSetup& es)
for(auto cl3d_itr=multiclusters.begin(0); cl3d_itr!=multiclusters.end(0); cl3d_itr++)
{
cl3d_n_++;
cl3d_id_.emplace_back(cl3d_itr->detId());
// physical values
cl3d_pt_.emplace_back(cl3d_itr->pt());
cl3d_energy_.emplace_back(cl3d_itr->energy());
cl3d_eta_.emplace_back(cl3d_itr->eta());
cl3d_phi_.emplace_back(cl3d_itr->phi());
cl3d_nclu_.emplace_back(cl3d_itr->constituents().size());
cl3d_clusters_n_.emplace_back(cl3d_itr->constituents().size());
cl3d_showerlength_.emplace_back(cl3d_itr->showerLength());
cl3d_coreshowerlength_.emplace_back(cl3d_itr->coreShowerLength());
cl3d_firstlayer_.emplace_back(cl3d_itr->firstLayer());
cl3d_maxlayer_.emplace_back(cl3d_itr->maxLayer());
cl3d_seetot_.emplace_back(cl3d_itr->sigmaEtaEtaTot());
cl3d_seemax_.emplace_back(cl3d_itr->sigmaEtaEtaMax());
cl3d_spptot_.emplace_back(cl3d_itr->sigmaPhiPhiTot());
cl3d_sppmax_.emplace_back(cl3d_itr->sigmaPhiPhiMax());
cl3d_szz_.emplace_back(cl3d_itr->sigmaZZ());
cl3d_srrtot_.emplace_back(cl3d_itr->sigmaRRTot());
cl3d_srrmax_.emplace_back(cl3d_itr->sigmaRRMax());
cl3d_srrmean_.emplace_back(cl3d_itr->sigmaRRMean());
cl3d_emaxe_.emplace_back(cl3d_itr->eMax()/cl3d_itr->energy());

// Retrieve indices of trigger cells inside cluster
cl3d_clusters_.emplace_back(cl3d_itr->constituents().size());
cl3d_clusters_id_.emplace_back(cl3d_itr->constituents().size());
std::transform(cl3d_itr->constituents_begin(), cl3d_itr->constituents_end(),
cl3d_clusters_.back().begin(), [](const edm::Ptr<l1t::HGCalCluster>& cl){return cl.key();}
cl3d_clusters_id_.back().begin(), [](const edm::Ptr<l1t::HGCalCluster>& cl){return cl->detId();}
);
}
}
Expand All @@ -124,23 +137,26 @@ HGCalTriggerNtupleHGCMulticlusters::
clear()
{
cl3d_n_ = 0;
cl3d_id_.clear();
cl3d_pt_.clear();
cl3d_energy_.clear();
cl3d_eta_.clear();
cl3d_phi_.clear();
cl3d_nclu_.clear();
cl3d_clusters_n_.clear();
cl3d_clusters_id_.clear();
cl3d_showerlength_.clear();
cl3d_coreshowerlength_.clear();
cl3d_firstlayer_.clear();
cl3d_maxlayer_.clear();
cl3d_seetot_.clear();
cl3d_seemax_.clear();
cl3d_spptot_.clear();
cl3d_sppmax_.clear();
cl3d_szz_.clear();
cl3d_srrtot_.clear();
cl3d_srrmax_.clear();
cl3d_srrmean_.clear();
cl3d_emaxe_.clear();
cl3d_clusters_.clear();

}


Expand Down
Loading

0 comments on commit 05a3e6b

Please sign in to comment.