forked from cms-sw/cmssw
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from jbsauvan/lucas-clustering-infrastructure
Clustering infrastructure
- Loading branch information
Showing
16 changed files
with
939 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#ifndef DataFormats_L1Trigger_HGCalMulticluster_h | ||
#define DataFormats_L1Trigger_HGCalMulticluster_h | ||
|
||
#include "DataFormats/L1Trigger/interface/L1Candidate.h" | ||
#include "DataFormats/L1Trigger/interface/BXVector.h" | ||
#include "DataFormats/L1THGCal/interface/HGCalCluster.h" | ||
|
||
namespace l1t { | ||
|
||
class HGCalMulticluster : public L1Candidate { | ||
public: | ||
|
||
typedef edm::PtrVector<l1t::HGCalCluster>::const_iterator component_iterator; | ||
typedef edm::PtrVector<l1t::HGCalCluster> ClusterCollection; | ||
|
||
HGCalMulticluster(){} | ||
HGCalMulticluster( const LorentzVector p4, | ||
int pt, | ||
int eta, | ||
int phi, | ||
ClusterCollection &thecls | ||
); | ||
|
||
~HGCalMulticluster(); | ||
|
||
void push_back(const edm::Ptr<l1t::HGCalCluster> &b) { | ||
myclusters_.push_back(b); | ||
} | ||
|
||
const edm::PtrVector<l1t::HGCalCluster> & clusters() const { return myclusters_; } | ||
|
||
unsigned int size() const { return myclusters_.size(); } | ||
component_iterator begin() const { return myclusters_.begin(); } | ||
component_iterator end() const { return myclusters_.end(); } | ||
|
||
void setHwPtEm (uint32_t pt) {hwPtEm_= pt;} | ||
void setHwPtHad (uint32_t pt) {hwPtHad_ = pt;} | ||
void setHwSeedPt(uint32_t pt) {hwSeedPt_ = pt;} | ||
void setSubDet (uint32_t subdet){subDet_ = subdet;} | ||
void setNtotLayer (uint32_t nTotLayer) {nTotLayer_ = nTotLayer;} | ||
void setHOverE (uint32_t hOverE){hOverE_ = hOverE;} | ||
|
||
bool isValid() const {return true;} | ||
uint32_t hwPtEm() const {return hwPtEm_;} | ||
uint32_t hwPtHad() const {return hwPtHad_;} | ||
uint32_t hwSeedPt() const {return hwSeedPt_;} | ||
|
||
uint32_t subDet() const {return subDet_;} | ||
uint32_t nTotLayer() const {return nTotLayer_;} | ||
|
||
uint32_t hOverE() const {return hOverE_;} | ||
|
||
bool operator<(const HGCalMulticluster& cl) const; | ||
bool operator>(const HGCalMulticluster& cl) const {return cl<*this;}; | ||
bool operator<=(const HGCalMulticluster& cl) const {return !(cl>*this);}; | ||
bool operator>=(const HGCalMulticluster& cl) const {return !(cl<*this);}; | ||
|
||
private: | ||
edm::PtrVector<l1t::HGCalCluster> myclusters_; | ||
|
||
// Energies | ||
uint32_t hwPtEm_; | ||
uint32_t hwPtHad_; | ||
uint32_t hwSeedPt_; | ||
|
||
// HGC specific information | ||
uint32_t subDet_; | ||
uint32_t nTotLayer_; | ||
|
||
// identification variables | ||
uint32_t hOverE_; | ||
}; | ||
|
||
typedef BXVector<HGCalMulticluster> HGCalMulticlusterBxCollection; | ||
|
||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include "DataFormats/L1THGCal/interface/HGCalMulticluster.h" | ||
|
||
using namespace l1t; | ||
|
||
HGCalMulticluster::HGCalMulticluster( const LorentzVector p4, | ||
int pt, | ||
int eta, | ||
int phi, | ||
ClusterCollection &basic_clusters | ||
) : | ||
L1Candidate(p4, pt, eta, phi), | ||
myclusters_(basic_clusters){ | ||
} | ||
|
||
|
||
|
||
HGCalMulticluster::~HGCalMulticluster() | ||
{ | ||
|
||
} | ||
|
||
bool HGCalMulticluster::operator<(const HGCalMulticluster& cl) const | ||
{ | ||
bool res = false; | ||
// Favour high pT | ||
if(hwPt()<cl.hwPt()) res = true; | ||
else if(hwPt()==cl.hwPt()) { | ||
// Favour central clusters | ||
if( abs(hwEta())>abs(cl.hwEta()) ) res = true; | ||
else if( abs(hwEta())==abs(cl.hwEta()) ){ | ||
// Favour small phi (arbitrary) | ||
if(hwPhi()>cl.hwPhi()) res = true; | ||
} | ||
} | ||
return res; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
L1Trigger/L1THGCal/interface/be_algorithms/HGCalClusteringImpl.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#ifndef __L1Trigger_L1THGCal_HGCalClusteringImpl_h__ | ||
#define __L1Trigger_L1THGCal_HGCalClusteringImpl_h__ | ||
|
||
#include <stdint.h> | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h" | ||
#include "DataFormats/ForwardDetId/interface/HGCalDetId.h" | ||
#include "DataFormats/L1THGCal/interface/HGCalCluster.h" | ||
|
||
|
||
class HGCalClusteringImpl{ | ||
|
||
public: | ||
|
||
HGCalClusteringImpl(const edm::ParameterSet &conf); | ||
void clusterizeBase(const l1t::HGCalTriggerCellBxCollection&, l1t::HGCalClusterBxCollection&); | ||
|
||
private: | ||
|
||
double seed_CUT_; | ||
double tc_CUT_; | ||
}; | ||
|
||
#endif |
22 changes: 22 additions & 0 deletions
22
L1Trigger/L1THGCal/interface/be_algorithms/HGCalMulticlusteringImpl.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#ifndef __L1Trigger_L1THGCal_HGCalMulticlusteringImpl_h__ | ||
#define __L1Trigger_L1THGCal_HGCalMulticlusteringImpl_h__ | ||
|
||
#include <stdint.h> | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "DataFormats/L1THGCal/interface/HGCalCluster.h" | ||
#include "DataFormats/L1THGCal/interface/HGCalMulticluster.h" | ||
|
||
|
||
class HGCalMulticlusteringImpl{ | ||
|
||
public: | ||
|
||
HGCalMulticlusteringImpl(const edm::ParameterSet &conf); | ||
void clusterizeMultiple(const l1t::HGCalClusterBxCollection&, l1t::HGCalMulticlusterBxCollection&); | ||
|
||
private: | ||
|
||
double dR_forC3d_; | ||
}; | ||
|
||
#endif |
132 changes: 132 additions & 0 deletions
132
L1Trigger/L1THGCal/plugins/be_algorithms/HGCClusterAlgo.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
#include "L1Trigger/L1THGCal/interface/HGCalTriggerBackendAlgorithmBase.h" | ||
#include "L1Trigger/L1THGCal/interface/fe_codecs/HGCalTriggerCellBestChoiceCodec.h" | ||
#include "L1Trigger/L1THGCal/interface/fe_codecs/HGCalTriggerCellThresholdCodec.h" | ||
#include "DataFormats/ForwardDetId/interface/HGCalDetId.h" | ||
#include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h" | ||
#include "L1Trigger/L1THGCal/interface/be_algorithms/HGCalTriggerCellCalibration.h" | ||
#include "DataFormats/L1THGCal/interface/HGCalCluster.h" | ||
#include "DataFormats/L1THGCal/interface/HGCalMulticluster.h" | ||
#include "L1Trigger/L1THGCal/interface/be_algorithms/HGCalClusteringImpl.h" | ||
#include "L1Trigger/L1THGCal/interface/be_algorithms/HGCalMulticlusteringImpl.h" | ||
|
||
using namespace HGCalTriggerBackend; | ||
|
||
template<typename FECODEC, typename DATA> | ||
class HGCClusterAlgo : public Algorithm<FECODEC> | ||
{ | ||
public: | ||
using Algorithm<FECODEC>::name; | ||
|
||
protected: | ||
using Algorithm<FECODEC>::codec_; | ||
|
||
public: | ||
HGCClusterAlgo(const edm::ParameterSet& conf, edm::ConsumesCollector& cc): | ||
Algorithm<FECODEC>(conf,cc), | ||
trgcell_product_( new l1t::HGCalTriggerCellBxCollection), | ||
cluster_product_( new l1t::HGCalClusterBxCollection ), | ||
multicluster_product_( new l1t::HGCalMulticlusterBxCollection ), | ||
HGCalEESensitive_(conf.getParameter<std::string>("HGCalEESensitive_tag")), | ||
HGCalHESiliconSensitive_(conf.getParameter<std::string>("HGCalHESiliconSensitive_tag")), | ||
calibration_(conf.getParameterSet("calib_parameters")), | ||
clustering_(conf.getParameterSet("C2d_parameters")), | ||
multiclustering_(conf.getParameterSet("C3d_parameters")){} | ||
|
||
typedef std::unique_ptr<HGCalTriggerGeometryBase> ReturnType; | ||
|
||
virtual void setProduces(edm::EDProducer& prod) const override final | ||
{ | ||
prod.produces<l1t::HGCalClusterBxCollection>(name()); | ||
prod.produces<l1t::HGCalMulticlusterBxCollection>("cluster3D"); | ||
|
||
} | ||
|
||
virtual void run(const l1t::HGCFETriggerDigiCollection& coll, const edm::EventSetup& es, const edm::Event&evt ) override final; | ||
virtual void putInEvent(edm::Event& evt) override final | ||
{ | ||
evt.put(std::move(cluster_product_),name()); | ||
evt.put(std::move(multicluster_product_),"cluster3D"); | ||
} | ||
|
||
virtual void reset() override final | ||
{ | ||
trgcell_product_.reset( new l1t::HGCalTriggerCellBxCollection); | ||
cluster_product_.reset( new l1t::HGCalClusterBxCollection ); | ||
multicluster_product_.reset( new l1t::HGCalMulticlusterBxCollection ); | ||
} | ||
|
||
private: | ||
|
||
std::unique_ptr<l1t::HGCalTriggerCellBxCollection> trgcell_product_; | ||
std::unique_ptr<l1t::HGCalClusterBxCollection> cluster_product_; | ||
std::unique_ptr<l1t::HGCalMulticlusterBxCollection> multicluster_product_; | ||
std::string HGCalEESensitive_; | ||
std::string HGCalHESiliconSensitive_; | ||
|
||
edm::ESHandle<HGCalTopology> hgceeTopoHandle_; | ||
edm::ESHandle<HGCalTopology> hgchefTopoHandle_; | ||
HGCalTriggerCellCalibration calibration_; | ||
double seed_CUT_; | ||
double tc_CUT_; | ||
HGCalClusteringImpl clustering_; | ||
HGCalMulticlusteringImpl multiclustering_; | ||
double dR_forC3d_; | ||
|
||
}; | ||
|
||
|
||
/*****************************************************************/ | ||
template<typename FECODEC, typename DATA> | ||
void HGCClusterAlgo<FECODEC,DATA>::run(const l1t::HGCFETriggerDigiCollection& coll, | ||
const edm::EventSetup& es, | ||
const edm::Event&evt | ||
) | ||
/*****************************************************************/ | ||
{ | ||
es.get<IdealGeometryRecord>().get(HGCalEESensitive_, hgceeTopoHandle_); | ||
es.get<IdealGeometryRecord>().get(HGCalHESiliconSensitive_, hgchefTopoHandle_); | ||
|
||
for( const auto& digi : coll ) | ||
{ | ||
HGCalDetId module_id(digi.id()); | ||
DATA data; | ||
data.reset(); | ||
digi.decode(codec_, data); | ||
for(const auto& triggercell : data.payload) | ||
{ | ||
if(triggercell.hwPt()>0) | ||
{ | ||
|
||
HGCalDetId detid(triggercell.detId()); | ||
int subdet = detid.subdetId(); | ||
int cellThickness = 0; | ||
|
||
if( subdet == HGCEE ){ | ||
cellThickness = (hgceeTopoHandle_)->dddConstants().waferTypeL((unsigned int)detid.wafer() ); | ||
}else if( subdet == HGCHEF ){ | ||
cellThickness = (hgchefTopoHandle_)->dddConstants().waferTypeL((unsigned int)detid.wafer() ); | ||
}else if( subdet == HGCHEB ){ | ||
edm::LogWarning("DataNotFound") << "ATTENTION: the BH trgCells are not yet implemented !! "; | ||
} | ||
l1t::HGCalTriggerCell calibratedtriggercell(triggercell); | ||
calibration_.calibrate(calibratedtriggercell, cellThickness); | ||
trgcell_product_->push_back(0,calibratedtriggercell); | ||
} | ||
} | ||
} | ||
clustering_.clusterizeBase(*trgcell_product_, *cluster_product_); | ||
multiclustering_.clusterizeMultiple(*cluster_product_, *multicluster_product_); | ||
} | ||
|
||
|
||
|
||
typedef HGCClusterAlgo<HGCalTriggerCellBestChoiceCodec, HGCalTriggerCellBestChoiceCodec::data_type> HGCClusterAlgoBestChoice; | ||
typedef HGCClusterAlgo<HGCalTriggerCellThresholdCodec, HGCalTriggerCellThresholdCodec::data_type> HGCClusterAlgoThreshold; | ||
|
||
DEFINE_EDM_PLUGIN(HGCalTriggerBackendAlgorithmFactory, | ||
HGCClusterAlgoBestChoice, | ||
"HGCClusterAlgoBestChoice"); | ||
|
||
DEFINE_EDM_PLUGIN(HGCalTriggerBackendAlgorithmFactory, | ||
HGCClusterAlgoThreshold, | ||
"HGCClusterAlgoThreshold"); |
Oops, something went wrong.