-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HGCAL trigger updates (including new 2D clustering + towers implementation) #22387
Changes from 63 commits
0854268
4bc81f6
d3186b8
d7bb2ad
7951a79
0ec2e5b
406a126
e0d24df
6abf4c9
aeee613
51c2dd1
149d811
d6f4fc9
f4380d8
59b51f4
3f9d459
71e7774
df242f2
d4d3974
8edfa4e
33cc5d4
1b02868
28a5ab0
584abd2
6d348b1
9e6a9b0
7d1f68a
166c705
454d8d7
c011498
fb3d571
c6c076e
c8c7a7b
ae3f772
398f593
e8d1163
a1ce640
607eb79
9d2421e
f467df2
a99a0b5
529b1f8
178fff5
3062cef
5dd214f
aa74213
12960a4
85741b6
b555619
b14aa22
aa0d156
d678efe
97403fc
1e84db6
dc6c300
774a4f0
3f4e93a
e88d8ce
1edf95b
620f898
a881c1d
99cea22
b570b5a
658743f
84dfff8
3affe2a
625c55e
c3f8207
5bf06db
e3a1c3b
a787a94
5b5339b
764c79b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,23 @@ | ||
#ifndef DataFormats_L1Trigger_HGCalClusterT_h | ||
#define DataFormats_L1Trigger_HGCalClusterT_h | ||
|
||
/* CMSSW */ | ||
#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" | ||
|
||
/* ROOT */ | ||
#include "Math/Vector3D.h" | ||
|
||
namespace l1t | ||
{ | ||
template <class C> class HGCalClusterT : public L1Candidate | ||
{ | ||
|
||
public: | ||
typedef typename edm::PtrVector<C>::const_iterator const_iterator; | ||
typedef typename std::vector<edm::Ptr<C>>::const_iterator const_iterator; | ||
|
||
public: | ||
HGCalClusterT(){} | ||
|
@@ -46,61 +47,126 @@ namespace l1t | |
|
||
~HGCalClusterT() override {}; | ||
|
||
const edm::PtrVector<C>& constituents() const {return constituents_;} | ||
const_iterator constituents_begin() const {return constituents_.begin();} | ||
const_iterator constituents_end() const {return constituents_.end();} | ||
const std::vector<edm::Ptr<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 ) | ||
void addConstituent( const edm::Ptr<C>& c, bool updateCentre=true, float fraction=1. ) | ||
{ | ||
if( constituents_.empty() ) | ||
{ | ||
detId_ = HGCalDetId(c->detId()); | ||
seedMipPt_ = c->mipPt(); | ||
} | ||
|
||
/* update cluster positions */ | ||
Basic3DVector<float> constituentCentre( c->position() ); | ||
Basic3DVector<float> clusterCentre( centre_ ); | ||
double cMipt = c->mipPt()*fraction; | ||
|
||
clusterCentre = clusterCentre*mipPt_ + constituentCentre*c->mipPt(); | ||
if( mipPt_ + c->mipPt()!=0 ) | ||
if( constituents_.empty() ) | ||
{ | ||
clusterCentre /= ( mipPt_ + c->mipPt() ) ; | ||
detId_ = HGCalDetId( c->detId() ); | ||
seedMipPt_ = cMipt; | ||
/* if the centre will not be dynamically calculated | ||
the seed centre is considere as cluster centre */ | ||
if( !updateCentre ) | ||
{ | ||
centre_ = c->position(); | ||
} | ||
} | ||
centre_ = GlobalPoint( clusterCentre ); | ||
|
||
if( clusterCentre.z()!=0 ) | ||
{ | ||
centreProj_= GlobalPoint( clusterCentre / clusterCentre.z() ); | ||
/* update cluster positions (IF requested) */ | ||
if( updateCentre ){ | ||
Basic3DVector<float> constituentCentre( c->position() ); | ||
Basic3DVector<float> clusterCentre( centre_ ); | ||
|
||
clusterCentre = clusterCentre*mipPt_ + constituentCentre*cMipt; | ||
if( (mipPt_ + cMipt ) > 0 ) | ||
{ | ||
clusterCentre /= ( mipPt_ + cMipt ); | ||
} | ||
centre_ = GlobalPoint( clusterCentre ); | ||
|
||
if( clusterCentre.z()!=0 ) | ||
{ | ||
centreProj_= GlobalPoint( clusterCentre / clusterCentre.z() ); | ||
} | ||
} | ||
|
||
/* update cluster energies */ | ||
mipPt_ += c->mipPt(); | ||
mipPt_ += cMipt; | ||
|
||
int updatedPt = hwPt() + c->hwPt(); | ||
setHwPt(updatedPt); | ||
int updatedPt = hwPt() + (int)(c->hwPt()*fraction); | ||
setHwPt( updatedPt ); | ||
|
||
math::PtEtaPhiMLorentzVector updatedP4 ( p4() ); | ||
updatedP4 += c->p4(); | ||
updatedP4 += (c->p4()*fraction); | ||
setP4( updatedP4 ); | ||
|
||
constituents_.push_back( c ); | ||
constituentsFraction_.push_back( fraction ); | ||
|
||
} | ||
|
||
bool valid() const { return valid_;} | ||
void setValid(bool valid) { valid_ = valid;} | ||
|
||
|
||
void removeConstituent( const edm::Ptr<C>& c, bool updateCentre=true ){ | ||
|
||
/* remove the pointer to c from the std::vector */ | ||
double fraction=0; | ||
bool constituentRemoved=false; | ||
for( unsigned i=0; i<constituents_.size(); i++ ) | ||
{ | ||
if( constituents_[i] == c ) | ||
{ | ||
// remove constituent and get its fraction in the cluster | ||
constituents_.erase( constituents_.begin()+i ); | ||
fraction = constituentsFraction_.at(i); | ||
constituentsFraction_.erase( constituentsFraction_.begin()+i ); | ||
constituentRemoved=true; | ||
break; | ||
} | ||
} | ||
|
||
/* if a constituent has been removed update cluster info */ | ||
if( constituentRemoved ) { | ||
|
||
/* update cluster positions (IF requested) */ | ||
double cMipt = c->mipPt()*fraction; | ||
if( updateCentre ){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this code block is duplicated from above - make it into a separate function that can be called whenever needed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done |
||
Basic3DVector<float> constituentCentre( c->position() ); | ||
Basic3DVector<float> clusterCentre( centre_ ); | ||
|
||
clusterCentre = clusterCentre*mipPt_ - constituentCentre*cMipt; | ||
if( (mipPt_ - cMipt ) > 0 ) | ||
{ | ||
clusterCentre /= ( mipPt_ - cMipt ) ; | ||
} | ||
centre_ = GlobalPoint( clusterCentre ); | ||
|
||
if( clusterCentre.z() != 0 ) | ||
{ | ||
centreProj_= GlobalPoint( clusterCentre / clusterCentre.z() ); | ||
} | ||
|
||
} | ||
|
||
/* update cluster energies */ | ||
mipPt_ -= cMipt; | ||
|
||
int updatedPt = hwPt() - ( c->hwPt()*fraction ); | ||
setHwPt( updatedPt ); | ||
|
||
math::PtEtaPhiMLorentzVector updatedP4 ( p4() ); | ||
updatedP4 -= ( c->p4()*fraction ); | ||
setP4( updatedP4 ); | ||
|
||
} | ||
|
||
} | ||
|
||
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(); | ||
} | ||
double distance( const l1t::HGCalTriggerCell &tc ) const { return ( tc.position() - centre_ ).mag(); } | ||
|
||
const GlobalPoint& position() const { return centre_; } | ||
const GlobalPoint& centre() const { return centre_; } | ||
|
@@ -178,11 +244,15 @@ namespace l1t | |
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_; | ||
HGCalDetId detId_; | ||
|
||
std::vector<edm::Ptr<C>> constituents_; /* ???? possibly change this in something like */ | ||
std::vector<double> constituentsFraction_; /* vector<pair<edm::Ptr<C>,float>> ???? */ | ||
|
||
GlobalPoint centre_; | ||
GlobalPoint centreProj_; // centre projected onto the first HGCal layer | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#ifndef DataFormats_L1TCalorimeter_HGCalTowerMap_h | ||
#define DataFormats_L1TCalorimeter_HGCalTowerMap_h | ||
|
||
#include "DataFormats/L1THGCal/interface/HGCalTower.h" | ||
#include "DataFormats/L1Trigger/interface/BXVector.h" | ||
|
||
#include <unordered_map> | ||
|
||
namespace l1t { | ||
|
||
class HGCalTowerMap; | ||
typedef BXVector<HGCalTowerMap> HGCalTowerMapBxCollection; | ||
|
||
class HGCalTowerMap { | ||
|
||
public: | ||
|
||
HGCalTowerMap(): nEtaBins_(0), nPhiBins_(0), layer_(0) {} | ||
|
||
HGCalTowerMap( int nEtaBins, int nPhiBins ); | ||
|
||
HGCalTowerMap( const std::vector<double>& etaBins, const std::vector<double>& phiBins ); | ||
|
||
~HGCalTowerMap(); | ||
|
||
void setLayer( const unsigned layer ) { layer_ = layer; } | ||
|
||
|
||
int nEtaBins() const { return nEtaBins_; } | ||
int nPhiBins() const { return nPhiBins_; } | ||
const vector<double>& etaBins() const { return etaBins_; } | ||
const vector<double>& phiBins() const { return phiBins_; } | ||
const l1t::HGCalTower& tower(int iEta, int iPhi) const { return towerMap_.at(bin_id(iEta,iPhi)); } | ||
|
||
int iEta(const double eta) const; | ||
int iPhi(const double phi) const; | ||
int layer() const { return layer_;} | ||
|
||
HGCalTowerMap& operator+=(const HGCalTowerMap& map); | ||
void addTower(int iEta, int iPhi, const l1t::HGCalTower& tower) { towerMap_[bin_id(iEta,iPhi)] += tower; } | ||
|
||
private: | ||
|
||
static constexpr double kEtaMin_ = 1.479; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a way to get these numbers from geometry info rather than hardcoding them? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really, each HGCAL layer has different eta limits. Here what has been chosen is the standard value used to separate the barrel and endcaps. |
||
static constexpr double kEtaMax_ = 3.; | ||
static constexpr double kEtaMinLoose_ = 1.401; //BH has some TC below 1.479 | ||
static constexpr double kEtaMaxLoose_ = 3.085; //FH has some TC above 3.0 | ||
static constexpr double kPhiMin_ = -M_PI; | ||
static constexpr double kPhiMax_ = +M_PI; | ||
|
||
int nEtaBins_; | ||
int nPhiBins_; | ||
vector<double> etaBins_; | ||
vector<double> phiBins_; | ||
std::unordered_map<int,l1t::HGCalTower> towerMap_; | ||
unsigned layer_; | ||
|
||
int bin_id(int iEta,int iPhi) const; | ||
|
||
}; | ||
|
||
} | ||
|
||
#endif | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
depending on how often this is used and how many constituents there are on average, may want to consider keeping the constituents in a sorted (or hashed) collection, so they can be located faster than linear search
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The constituent
vector
has been replaced by anunordered_map
, the key being the constituent id.