Skip to content

Commit

Permalink
Merge pull request #86 from jbsauvan/lucas-clustering-infrastructure
Browse files Browse the repository at this point in the history
Clustering infrastructure
  • Loading branch information
jbsauvan authored Mar 1, 2017
2 parents 0ee4c5f + 00eb89a commit 0abf384
Show file tree
Hide file tree
Showing 16 changed files with 939 additions and 6 deletions.
79 changes: 79 additions & 0 deletions DataFormats/L1THGCal/interface/HGCalMulticluster.h
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
36 changes: 36 additions & 0 deletions DataFormats/L1THGCal/src/HGCalMulticluster.cc
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;
}
4 changes: 4 additions & 0 deletions DataFormats/L1THGCal/src/classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "DataFormats/L1THGCal/interface/HGCFETriggerDigiFwd.h"

#include "DataFormats/L1THGCal/interface/HGCalCluster.h"
#include "DataFormats/L1THGCal/interface/HGCalMulticluster.h"
#include "DataFormats/L1THGCal/interface/HGCalTower.h"
#include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h"

Expand All @@ -24,10 +25,13 @@ namespace DataFormats {

l1t::HGCalTowerBxCollection hgcalTowerBxColl;
l1t::HGCalClusterBxCollection hgcalClusterBxColl;
l1t::HGCalMulticlusterBxCollection hgcalMulticlusterBxColl;

l1t::HGCalTriggerCellBxCollection hgcalTriggerCellBxColl;

edm::Wrapper<l1t::HGCalTowerBxCollection> w_hgcalTowerBxColl;
edm::Wrapper<l1t::HGCalClusterBxCollection> w_hgcalClusterBxColl;
edm::Wrapper<l1t::HGCalMulticlusterBxCollection> w_hgcalMulticlusterBxColl;
edm::Wrapper<l1t::HGCalTriggerCellBxCollection> w_hgcalTriggerCellBxColl;

l1t::ClusterShapes clusterShapes;
Expand Down
6 changes: 6 additions & 0 deletions DataFormats/L1THGCal/src/classes_def.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

<lcgdict>
<class name="l1t::HGCFETriggerDigi" ClassVersion="10">
<version ClassVersion="10" checksum="3197268020"/>
Expand All @@ -24,6 +25,11 @@
<class name="l1t::HGCalClusterBxCollection"/>
<class name="edm::Wrapper<l1t::HGCalClusterBxCollection>"/>

<class name="l1t::HGCalMulticluster" />
<class name="std::vector<l1t::HGCalMulticluster>" />
<class name="l1t::HGCalMulticlusterBxCollection"/>
<class name="edm::Wrapper<l1t::HGCalMulticlusterBxCollection>"/>

<class name="l1t::HGCalTriggerCell" />
<class name="std::vector<l1t::HGCalTriggerCell>" />
<class name="l1t::HGCalTriggerCellBxCollection"/>
Expand Down
24 changes: 24 additions & 0 deletions L1Trigger/L1THGCal/interface/be_algorithms/HGCalClusteringImpl.h
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
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 L1Trigger/L1THGCal/plugins/be_algorithms/HGCClusterAlgo.cc
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");
Loading

0 comments on commit 0abf384

Please sign in to comment.