Skip to content

Commit

Permalink
Merge pull request #18419 from PFCal-dev/hgc-tpg-integration-170420
Browse files Browse the repository at this point in the history
Preliminary HGCAL trigger clustering
  • Loading branch information
davidlange6 authored Apr 27, 2017
2 parents f0824ae + 38f91ba commit d4f8890
Show file tree
Hide file tree
Showing 42 changed files with 2,021 additions and 227 deletions.
53 changes: 13 additions & 40 deletions DataFormats/L1THGCal/interface/HGCalCluster.h
Original file line number Diff line number Diff line change
@@ -1,67 +1,40 @@
#ifndef DataFormats_L1Trigger_HGCalCluster_h
#define DataFormats_L1Trigger_HGCalCluster_h

#include "DataFormats/L1Trigger/interface/L1Candidate.h"
#include "DataFormats/Common/interface/Ptr.h"
#include "DataFormats/L1Trigger/interface/BXVector.h"
#include "DataFormats/L1THGCal/interface/ClusterShapes.h"
#include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h"
#include "DataFormats/L1THGCal/interface/HGCalClusterT.h"

namespace l1t {

class HGCalCluster : public L1Candidate {
namespace l1t {

class HGCalCluster : public HGCalClusterT<l1t::HGCalTriggerCell> {

public:

HGCalCluster(){}
HGCalCluster( const LorentzVector p4,
int pt=0,
int eta=0,
int phi=0
);

HGCalCluster( const edm::Ptr<l1t::HGCalTriggerCell> &tc );

~HGCalCluster();

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 setLayer (uint32_t layer) {layer_ = layer;}
void setModule (uint32_t module) {module_ = module;}
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 layer() const {return layer_;}
uint32_t module() const {return module_;}
void setModule(uint32_t module) {module_ = module;}
uint32_t module() const {return module_;}

uint32_t hOverE() const {return hOverE_;}

ClusterShapes shapes ;

bool operator<(const HGCalCluster& cl) const;
bool operator>(const HGCalCluster& cl) const {return cl<*this;};
bool operator<=(const HGCalCluster& cl) const {return !(cl>*this);};
bool operator>=(const HGCalCluster& cl) const {return !(cl<*this);};

private:
// Energies
uint32_t hwPtEm_;
uint32_t hwPtHad_;
uint32_t hwSeedPt_;

// HGC specific information
uint32_t subDet_;
uint32_t layer_;
uint32_t module_;

// identification variables
uint32_t hOverE_;

};

typedef BXVector<HGCalCluster> HGCalClusterBxCollection;


}

#endif
162 changes: 162 additions & 0 deletions DataFormats/L1THGCal/interface/HGCalClusterT.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
#ifndef DataFormats_L1Trigger_HGCalClusterT_h
#define DataFormats_L1Trigger_HGCalClusterT_h

#include "DataFormats/Common/interface/Ptr.h"
#include "DataFormats/Common/interface/PtrVector.h"
#include "DataFormats/GeometryVector/interface/GlobalPoint.h"
#include "DataFormats/L1Trigger/interface/L1Candidate.h"
#include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h"
#include "DataFormats/L1THGCal/interface/ClusterShapes.h"
#include "Math/Vector3D.h"


namespace l1t
{
template <class C> class HGCalClusterT : public L1Candidate
{

public:
typedef typename edm::PtrVector<C>::const_iterator const_iterator;

public:
HGCalClusterT(){}
HGCalClusterT( const LorentzVector p4,
int pt=0,
int eta=0,
int phi=0
)
: L1Candidate(p4, pt, eta, phi),
valid_(true),
detId_(0),
centre_(0, 0, 0),
centreProj_(0., 0., 0.),
mipPt_(0),
seedMipPt_(0){}

HGCalClusterT( const edm::Ptr<C>& c ):
valid_(true)
{
addConstituent(c);
}

~HGCalClusterT() {};

const edm::PtrVector<C>& constituents() const {return constituents_;}
const_iterator constituents_begin() const {return constituents_.begin();}
const_iterator constituents_end() const {return constituents_.end();}
unsigned size() const { return constituents_.size(); }

void addConstituent( const edm::Ptr<C>& c )
{
if( constituents_.empty() )
{
detId_ = HGCalDetId(c->detId());
seedMipPt_ = c->mipPt();
}

/* update cluster positions */
Basic3DVector<float> constituentCentre( c->position() );
Basic3DVector<float> clusterCentre( centre_ );

clusterCentre = clusterCentre*mipPt_ + constituentCentre*c->mipPt();
if( mipPt_ + c->mipPt()!=0 )
{
clusterCentre /= ( mipPt_ + c->mipPt() ) ;
}
centre_ = GlobalPoint( clusterCentre );

if( clusterCentre.z()!=0 )
{
centreProj_= GlobalPoint( clusterCentre / clusterCentre.z() );
}
/* update cluster energies */
mipPt_ += c->mipPt();

int updatedPt = hwPt() + c->hwPt();
setHwPt(updatedPt);

math::PtEtaPhiMLorentzVector updatedP4 ( p4() );
updatedP4 += c->p4();
setP4( updatedP4 );

constituents_.push_back( c );

}

bool valid() const { return valid_;}
void setValid(bool valid) { valid_ = valid;}

double mipPt() const { return mipPt_; }
double seedMipPt() const { return seedMipPt_; }
uint32_t detId() const { return detId_.rawId(); }

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

const GlobalPoint& position() const { return centre_; }
const GlobalPoint& centre() const { return centre_; }
const GlobalPoint& centreProj() const { return centreProj_; }

// FIXME: will need to fix places where the shapes are directly accessed
// Right now keep shapes() getter as non-const
ClusterShapes& shapes() {return shapes_;}
double hOverE() const
{
double pt_em = 0.;
double pt_had = 0.;
double hOe = 0.;

for(const auto& constituent : constituents())
{
switch( constituent->subdetId() )
{
case HGCEE:
pt_em += constituent->pt();
break;
case HGCHEF:
pt_had += constituent->pt();
break;
case HGCHEB:
pt_had += constituent->pt();
break;
default:
break;
}
}
if(pt_em>0) hOe = pt_had / pt_em ;
else hOe = -1.;
return hOe;
}

uint32_t subdetId() const {return detId_.subdetId();}
uint32_t layer() const {return detId_.layer();}
int32_t zside() const {return detId_.zside();}


/* operators */
bool operator<(const HGCalClusterT<C>& cl) const {return mipPt() < cl.mipPt();}
bool operator>(const HGCalClusterT<C>& cl) const { return cl<*this; }
bool operator<=(const HGCalClusterT<C>& cl) const { return !(cl>*this); }
bool operator>=(const HGCalClusterT<C>& cl) const { return !(cl<*this); }

private:

bool valid_;
HGCalDetId detId_;
edm::PtrVector<C> constituents_;
GlobalPoint centre_;
GlobalPoint centreProj_; // centre projected onto the first HGCal layer

double mipPt_;
double seedMipPt_;

ClusterShapes shapes_;

};

}

#endif
33 changes: 33 additions & 0 deletions DataFormats/L1THGCal/interface/HGCalMulticluster.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef DataFormats_L1Trigger_HGCalMulticluster_h
#define DataFormats_L1Trigger_HGCalMulticluster_h

#include "DataFormats/Common/interface/Ptr.h"
#include "DataFormats/L1Trigger/interface/BXVector.h"
#include "DataFormats/L1THGCal/interface/HGCalClusterT.h"
#include "DataFormats/L1THGCal/interface/HGCalCluster.h"

namespace l1t {

class HGCalMulticluster : public HGCalClusterT<l1t::HGCalCluster> {

public:

HGCalMulticluster(){}
HGCalMulticluster( const LorentzVector p4,
int pt=0,
int eta=0,
int phi=0
);

HGCalMulticluster( const edm::Ptr<l1t::HGCalCluster> &tc );

~HGCalMulticluster();


};

typedef BXVector<HGCalMulticluster> HGCalMulticlusterBxCollection;

}

#endif
22 changes: 18 additions & 4 deletions DataFormats/L1THGCal/interface/HGCalTriggerCell.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "DataFormats/GeometryVector/interface/GlobalPoint.h"
#include "DataFormats/L1Trigger/interface/L1Candidate.h"
#include "DataFormats/L1Trigger/interface/BXVector.h"
#include "DataFormats/ForwardDetId/interface/HGCalDetId.h"

namespace l1t
{
Expand All @@ -28,15 +29,28 @@ namespace l1t

~HGCalTriggerCell();

void setDetId(uint32_t detid) {detid_ = detid;}
void setDetId(uint32_t detid) {detid_ = HGCalDetId(detid);}
void setPosition(const GlobalPoint& position) {position_ = position;}

uint32_t detId() const {return detid_;}
uint32_t detId() const {return detid_.rawId();}
const GlobalPoint& position() const {return position_;}


int zside() const {
return detid_.zside();
}
int layer() const {
return detid_.layer();
}

void setMipPt( double value ) { mipPt_ = value; }
double mipPt() const { return mipPt_; }

private:
uint32_t detid_;

HGCalDetId detid_;
GlobalPoint position_;

double mipPt_;

};

Expand Down
33 changes: 13 additions & 20 deletions DataFormats/L1THGCal/src/HGCalCluster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,24 @@
using namespace l1t;

HGCalCluster::HGCalCluster( const LorentzVector p4,
int pt,
int eta,
int phi)
: L1Candidate(p4, pt, eta, phi)
int pt,
int eta,
int phi )
: HGCalClusterT<l1t::HGCalTriggerCell>(p4, pt, eta, phi),
module_(0)
{

}

HGCalCluster::~HGCalCluster()

HGCalCluster::HGCalCluster( const edm::Ptr<l1t::HGCalTriggerCell> &tcSeed )
: HGCalClusterT<l1t::HGCalTriggerCell>(tcSeed),
module_(0)
{

}

bool HGCalCluster::operator<(const HGCalCluster& cl) const

HGCalCluster::~HGCalCluster()
{
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;
}


24 changes: 24 additions & 0 deletions DataFormats/L1THGCal/src/HGCalMulticluster.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "DataFormats/L1THGCal/interface/HGCalMulticluster.h"

using namespace l1t;

HGCalMulticluster::HGCalMulticluster( const LorentzVector p4,
int pt,
int eta,
int phi )
: HGCalClusterT<l1t::HGCalCluster>(p4, pt, eta, phi)
{
}


HGCalMulticluster::HGCalMulticluster( const edm::Ptr<l1t::HGCalCluster> &clusterSeed )
: HGCalClusterT<l1t::HGCalCluster>(clusterSeed)
{
}


HGCalMulticluster::~HGCalMulticluster()
{
}


Loading

0 comments on commit d4f8890

Please sign in to comment.