Skip to content

Commit

Permalink
Merge pull request #26266 from PFCal-dev/hgc-tpg-integration-190326
Browse files Browse the repository at this point in the history
[HGCAL trigger] Updates in SuperTCs and 3D clustering
  • Loading branch information
cmsbuild committed Apr 11, 2019
2 parents e084f03 + 0439bf3 commit eaed370
Show file tree
Hide file tree
Showing 56 changed files with 1,912 additions and 670 deletions.
18 changes: 11 additions & 7 deletions DataFormats/L1THGCal/interface/HGCalClusterT.h
Expand Up @@ -37,17 +37,20 @@ namespace l1t
centre_(0, 0, 0),
centreProj_(0., 0., 0.),
mipPt_(0),
seedMipPt_(0){}
seedMipPt_(0),
sumPt_(0){}

HGCalClusterT( const edm::Ptr<C>& c ):

HGCalClusterT( const edm::Ptr<C>& c, float fraction=1. ):
valid_(true),
detId_( c->detId() ),
centre_(0., 0., 0.),
centreProj_(0., 0., 0.),
mipPt_(0.),
seedMipPt_(0.)
seedMipPt_(0.),
sumPt_(0.)
{
addConstituent(c);
addConstituent(c, true, fraction);
}

~HGCalClusterT() override {};
Expand Down Expand Up @@ -105,11 +108,10 @@ namespace l1t
double mipPt() const { return mipPt_; }
double seedMipPt() const { return seedMipPt_; }
uint32_t detId() const { return detId_.rawId(); }

void setPt(double pt) {
setP4( math::PtEtaPhiMLorentzVector(pt, eta(), phi(), mass() ) );
}

double sumPt() const { return sumPt_; }
/* distance in 'cm' */
double distance( const l1t::HGCalTriggerCell &tc ) const { return ( tc.position() - centre_ ).mag(); }

Expand Down Expand Up @@ -203,6 +205,7 @@ namespace l1t

double mipPt_;
double seedMipPt_;
double sumPt_;

//shower shape

Expand All @@ -226,6 +229,7 @@ namespace l1t
void updateP4AndPosition(const edm::Ptr<C>& c, bool updateCentre=true, float fraction=1.)
{
double cMipt = c->mipPt()*fraction;
double cPt = c->pt()*fraction;
/* update cluster positions (IF requested) */
if( updateCentre ){
Basic3DVector<float> constituentCentre( c->position() );
Expand All @@ -246,7 +250,7 @@ namespace l1t

/* update cluster energies */
mipPt_ += cMipt;

sumPt_ += cPt;
int updatedPt = hwPt() + (int)(c->hwPt()*fraction);
setHwPt( updatedPt );

Expand Down
2 changes: 1 addition & 1 deletion DataFormats/L1THGCal/interface/HGCalMulticluster.h
Expand Up @@ -19,7 +19,7 @@ namespace l1t {
int phi=0
);

HGCalMulticluster( const edm::Ptr<l1t::HGCalCluster> &tc );
HGCalMulticluster( const edm::Ptr<l1t::HGCalCluster> &tc, float fraction=1);

~HGCalMulticluster() override;

Expand Down
4 changes: 2 additions & 2 deletions DataFormats/L1THGCal/src/HGCalMulticluster.cc
Expand Up @@ -13,8 +13,8 @@ HGCalMulticluster::HGCalMulticluster( const LorentzVector p4,
}


HGCalMulticluster::HGCalMulticluster( const edm::Ptr<l1t::HGCalCluster> &clusterSeed )
: HGCalClusterT<l1t::HGCalCluster>(clusterSeed),
HGCalMulticluster::HGCalMulticluster( const edm::Ptr<l1t::HGCalCluster> &clusterSeed, float fraction )
: HGCalClusterT<l1t::HGCalCluster>(clusterSeed, fraction),
hOverE_(-99),
hOverEValid_(false)
{
Expand Down
2 changes: 1 addition & 1 deletion DataFormats/L1THGCal/src/HGCalTriggerCell.cc
Expand Up @@ -10,7 +10,7 @@ HGCalTriggerCell( const LorentzVector& p4,
int qual,
uint32_t detid):
L1Candidate(p4, pt, eta, phi, qual),
detid_(detid)
detid_(detid), position_(), mipPt_(0)
{
}

Expand Down
13 changes: 8 additions & 5 deletions DataFormats/L1THGCal/src/classes_def.xml
Expand Up @@ -30,8 +30,9 @@

<class name="l1t::HGCalClusterT<l1t::HGCalTriggerCell>" />
<class name="l1t::HGCalClusterT<l1t::HGCalTriggerSums>" />
<class name="l1t::HGCalCluster" ClassVersion="15">
<version ClassVersion="15" checksum="2522149132"/>
<class name="l1t::HGCalCluster" ClassVersion="16">
<version ClassVersion="16" checksum="1572558185"/>
<version ClassVersion="15" checksum="2522149132"/>
<version ClassVersion="14" checksum="3289642235"/>
<version ClassVersion="13" checksum="3397489079"/>
<version ClassVersion="12" checksum="623703096"/>
Expand All @@ -43,9 +44,11 @@
<class name="edm::Wrapper<l1t::HGCalClusterBxCollection>"/>

<class name="l1t::HGCalClusterT<l1t::HGCalCluster>" />
<class name="l1t::HGCalMulticluster" ClassVersion="16">
<version ClassVersion="16" checksum="1276395758"/>
<version ClassVersion="15" checksum="777879934"/>

<class name="l1t::HGCalMulticluster" ClassVersion="17">
<version ClassVersion="17" checksum="460658789"/>
<version ClassVersion="16" checksum="1276395758"/>
<version ClassVersion="15" checksum="777879934"/>
<version ClassVersion="14" checksum="2315302819"/>
<version ClassVersion="13" checksum="816077951"/>
<version ClassVersion="12" checksum="4221677522"/>
Expand Down
73 changes: 73 additions & 0 deletions L1Trigger/L1THGCal/interface/backend/HGCalHistoClusteringImpl.h
@@ -0,0 +1,73 @@
#ifndef __L1Trigger_L1THGCal_HGCalHistoClusteringImpl_h__
#define __L1Trigger_L1THGCal_HGCalHistoClusteringImpl_h__

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "DataFormats/L1THGCal/interface/HGCalCluster.h"
#include "DataFormats/L1THGCal/interface/HGCalMulticluster.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h"
#include "L1Trigger/L1THGCal/interface/backend/HGCalShowerShape.h"
#include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h"
#include "L1Trigger/L1THGCal/interface/backend/HGCalTriggerClusterIdentificationBase.h"


class HGCalHistoClusteringImpl{

public:

HGCalHistoClusteringImpl( const edm::ParameterSet &conf);

void eventSetup(const edm::EventSetup& es)
{
triggerTools_.eventSetup(es);
shape_.eventSetup(es);
if ( (!dr_byLayer_coefficientA_.empty() && (dr_byLayer_coefficientA_.size()-1) < triggerTools_.lastLayerBH())
|| (!dr_byLayer_coefficientB_.empty() && (dr_byLayer_coefficientB_.size()-1) < triggerTools_.lastLayerBH())
) {
throw cms::Exception("Configuration") <<
"The per-layer dR values go up to " << (dr_byLayer_coefficientA_.size()-1) <<
"(A) and " << (dr_byLayer_coefficientB_.size()-1) << "(B), while layers go up to " << triggerTools_.lastLayerBH() << "\n";
}
}

float dR( const l1t::HGCalCluster & clu,
const GlobalPoint & seed ) const;

void clusterizeHisto( const std::vector<edm::Ptr<l1t::HGCalCluster>> & clustersPtr,
const std::vector<std::pair<GlobalPoint, double> > & seedPositionsEnergy,
const HGCalTriggerGeometryBase & triggerGeometry,
l1t::HGCalMulticlusterBxCollection & multiclusters
) const;


private:
enum ClusterAssociationStrategy{
NearestNeighbour,
EnergySplit
};

std::vector<l1t::HGCalMulticluster> clusterSeedMulticluster(const std::vector<edm::Ptr<l1t::HGCalCluster>> & clustersPtrs,
const std::vector<std::pair<GlobalPoint, double> > & seeds) const;

void finalizeClusters(std::vector<l1t::HGCalMulticluster>&,
l1t::HGCalMulticlusterBxCollection&,
const HGCalTriggerGeometryBase&) const;

double dr_;
std::vector<double> dr_byLayer_coefficientA_;
std::vector<double> dr_byLayer_coefficientB_;
double ptC3dThreshold_;

std::string cluster_association_input_;
ClusterAssociationStrategy cluster_association_strategy_;

HGCalShowerShape shape_;
HGCalTriggerTools triggerTools_;
std::unique_ptr<HGCalTriggerClusterIdentificationBase> id_;

static constexpr double kMidRadius_ = 2.3;

};

#endif
@@ -1,5 +1,5 @@
#ifndef __L1Trigger_L1THGCal_HGCalMulticlusteringHistoImpl_h__
#define __L1Trigger_L1THGCal_HGCalMulticlusteringHistoImpl_h__
#ifndef __L1Trigger_L1THGCal_HGCalHistoSeedingImpl_h__
#define __L1Trigger_L1THGCal_HGCalHistoSeedingImpl_h__

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "DataFormats/L1THGCal/interface/HGCalCluster.h"
Expand All @@ -12,30 +12,28 @@
#include "L1Trigger/L1THGCal/interface/backend/HGCalTriggerClusterIdentificationBase.h"


class HGCalMulticlusteringHistoImpl{
class HGCalHistoSeedingImpl{

public:

HGCalMulticlusteringHistoImpl( const edm::ParameterSet &conf);
HGCalHistoSeedingImpl( const edm::ParameterSet &conf);

void eventSetup(const edm::EventSetup& es)
{
triggerTools_.eventSetup(es);
shape_.eventSetup(es);
}

float dR( const l1t::HGCalCluster & clu,
const GlobalPoint & seed ) const;
const GlobalPoint & seed ) const;

void clusterizeHisto( const std::vector<edm::Ptr<l1t::HGCalCluster>> & clustersPtr,
l1t::HGCalMulticlusterBxCollection & multiclusters,
const HGCalTriggerGeometryBase & triggerGeometry
);
void findHistoSeeds( const std::vector<edm::Ptr<l1t::HGCalCluster>> & clustersPtr,
std::vector<std::pair<GlobalPoint, double> > & seedPositionsEnergy);


private:
enum MulticlusterType{
enum SeedingType{
HistoMaxC3d,
HistoSecondaryMaxC3d,
HistoThresholdC3d,
HistoInterpolatedMaxC3d
};
Expand All @@ -45,36 +43,29 @@ class HGCalMulticlusteringHistoImpl{
Histogram fillHistoClusters( const std::vector<edm::Ptr<l1t::HGCalCluster>> & clustersPtrs );

Histogram fillSmoothPhiHistoClusters( const Histogram & histoClusters,
const vector<unsigned> & binSums );
const vector<unsigned> & binSums );

Histogram fillSmoothRPhiHistoClusters( const Histogram & histoClusters );

std::vector<GlobalPoint> computeMaxSeeds( const Histogram & histoClusters );
std::vector<std::pair<GlobalPoint, double> > computeMaxSeeds( const Histogram & histoClusters );

std::vector<GlobalPoint> computeInterpolatedMaxSeeds( const Histogram & histoClusters );
std::vector<std::pair<GlobalPoint, double> > computeSecondaryMaxSeeds( const Histogram & histoClusters );

std::vector<std::pair<GlobalPoint, double> > computeInterpolatedMaxSeeds( const Histogram & histoClusters );

std::vector<std::pair<GlobalPoint, double> > computeThresholdSeeds( const Histogram & histoClusters );

std::vector<GlobalPoint> computeThresholdSeeds( const Histogram & histoClusters );

std::vector<l1t::HGCalMulticluster> clusterSeedMulticluster(const std::vector<edm::Ptr<l1t::HGCalCluster>> & clustersPtrs,
const std::vector<GlobalPoint> & seeds);
std::string seedingAlgoType_;
SeedingType seedingType_;

void finalizeClusters(std::vector<l1t::HGCalMulticluster>&,
l1t::HGCalMulticlusterBxCollection&,
const HGCalTriggerGeometryBase&);

double dr_;
double ptC3dThreshold_;
MulticlusterType multiclusteringAlgoType_;
std::string multiclusterAlgoType_;
unsigned nBinsRHisto_ = 36;
unsigned nBinsPhiHisto_ = 216;
std::vector<unsigned> binsSumsHisto_;
double histoThreshold_ = 20.;
std::vector<double> neighbour_weights_;

HGCalShowerShape shape_;
HGCalTriggerTools triggerTools_;
std::unique_ptr<HGCalTriggerClusterIdentificationBase> id_;

static constexpr unsigned neighbour_weights_size_ = 9;
static constexpr double kROverZMin_ = 0.09;
Expand Down
2 changes: 2 additions & 0 deletions L1Trigger/L1THGCal/interface/backend/HGCalShowerShape.h
Expand Up @@ -44,6 +44,8 @@ class HGCalShowerShape{
float sigmaRRMax(const l1t::HGCalMulticluster& c3d) const;
float sigmaRRMean(const l1t::HGCalMulticluster& c3d, float radius=5.) const;

void fillShapes(l1t::HGCalMulticluster&, const HGCalTriggerGeometryBase&) const;

private:

float meanX(const std::vector<pair<float,float> >& energy_X_tc) const;
Expand Down
Expand Up @@ -6,9 +6,12 @@

#include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h"
#include "DataFormats/L1THGCal/interface/HGCalTriggerSums.h"
#include "DataFormats/ForwardDetId/interface/HGCSiliconDetIdToROC.h"

#include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h"



#include <array>
#include <vector>

Expand All @@ -18,20 +21,36 @@ class HGCalConcentratorSuperTriggerCellImpl
HGCalConcentratorSuperTriggerCellImpl(const edm::ParameterSet& conf);

void superTriggerCellSelectImpl(const std::vector<l1t::HGCalTriggerCell>& trigCellVecInput, std::vector<l1t::HGCalTriggerCell>& trigCellVecOutput);
void eventSetup(const edm::EventSetup& es) {triggerTools_.eventSetup(es);}

private:

int getSuperTriggerCellId(int detid) const ;
static const int kSplit_ = 0x3a;
static std::map<int,int> kSplit_;
static const int kWafer_offset_ = 6;
static const int kSTCsizeCoarse_ = 16;
static const int kSTCsizeFine_ = 4;
static const int kSplit_v8_Coarse_ = 0x30;
static const int kSplit_v8_Fine_ = 0x3a;
static const int kNLayers_ = 3;
static const int kSplit_v9_ = 0x36;

static const int kRocShift_ = 6;
static const int kRotate4_ = 4;
static const int kUShift_ = 3;


HGCalTriggerTools triggerTools_;
HGCSiliconDetIdToROC detIdToROC_;
std::vector<unsigned> stcSize_;

class SuperTriggerCell {

private:
float sumPt_, sumMipPt_;
int sumHwPt_, maxHwPt_;
unsigned maxId_;

public:
SuperTriggerCell(){ sumPt_=0, sumMipPt_=0, sumHwPt_=0, maxHwPt_=0, maxId_=0 ;}
void add(const l1t::HGCalTriggerCell &c) {
Expand Down
15 changes: 0 additions & 15 deletions L1Trigger/L1THGCal/plugins/BuildFile.xml
Expand Up @@ -29,18 +29,3 @@
<flags EDM_PLUGIN="1"/>
</library>

<library name="L1TriggerL1THGCalPlugins_ntuples" file="ntuples/*.cc">
<use name="L1Trigger/L1THGCal"/>
<use name="CommonTools/UtilAlgos"/>
<use name="SimDataFormats/CaloTest"/>
<use name="DataFormats/JetReco"/>
<use name="Geometry/HcalTowerAlgo"/>
<use name="SimDataFormats/PileupSummaryInfo"/>
<use name="SimDataFormats/GeneratorProducts"/>
<use name="TrackPropagation/RungeKutta"/>
<use name="FastSimulation/Event"/>
<use name="MagneticField/Engine"/>
<use name="MagneticField/Records"/>
<use name="heppdt"/>
<flags EDM_PLUGIN="1"/>
</library>

0 comments on commit eaed370

Please sign in to comment.