Skip to content
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

Merged
merged 73 commits into from
Mar 10, 2018
Merged
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
0854268
Add panel ntuple
jbsauvan Nov 23, 2017
4bc81f6
This is adding a new clustering method. It consists in a combined dR…
Dec 1, 2017
d3186b8
Update panel ntuple
jbsauvan Dec 6, 2017
d7bb2ad
Add TDR-like panel geometry
jbsauvan Dec 6, 2017
7951a79
Add calibration of sim energies in ntuples and update TC calib coeffs…
jbsauvan Dec 7, 2017
0ec2e5b
Update of the new geoNN 2D cluster algorithm. All the pieces are in p…
Dec 8, 2017
406a126
C2D geoNN is updated and seeds are treated in order to avoid NN seeds…
Dec 8, 2017
e0d24df
NN-geo clustering: sorting of the distance vector done using std::sort()
Dec 8, 2017
6abf4c9
All comments implemnted except the PtrVector to be replaces with vect…
Dec 11, 2017
aeee613
edm::PtrVector<C> has been replaces with std::vector<edm::Ptr<C>>
Dec 12, 2017
51c2dd1
Few style fixes
Dec 14, 2017
149d811
Fix simhit calibration
jbsauvan Dec 16, 2017
d6f4fc9
Reduce TC threshold in frontend
jbsauvan Dec 16, 2017
f4380d8
Indentation fixed in DataFormats/L1THGCal/interface/HGCalClusterT.h; …
Dec 18, 2017
59b51f4
Merge pull request #164 from vpalladi/c2d-dev
jbsauvan Dec 18, 2017
3f9d459
Merge branch 'PFCal-dev/hgc-tpg-devel-CMSSW_9_4_0_pre2' into cc-trigg…
jbsauvan Jan 12, 2018
71e7774
Cleaning
jbsauvan Jan 12, 2018
df242f2
Fix of dRNNC2d
tstreble Jan 13, 2018
d4d3974
Merge pull request #165 from jbsauvan/cc-trigger-sel-study
jbsauvan Jan 14, 2018
8edfa4e
Merge pull request #166 from tstreble/dRNNC2d_update
jbsauvan Jan 15, 2018
33cc5d4
Use TDR panel layout as default
jbsauvan Jan 16, 2018
1b02868
Merge pull request #169 from jbsauvan/default-panel-tdr-layout
jbsauvan Jan 16, 2018
28a5ab0
Fix custom geometries
jbsauvan Jan 16, 2018
584abd2
Merge pull request #172 from jbsauvan/fix-custom-geom
jbsauvan Jan 16, 2018
6d348b1
add quick and dirty implementation of a tool suite, currently mainly …
cerminar Oct 19, 2017
9e6a9b0
make the layer count independent on the subdet
cerminar Oct 19, 2017
7d1f68a
make the layer count independent on the subdet
cerminar Oct 19, 2017
166c705
cleanup
cerminar Oct 23, 2017
454d8d7
switch on sim info
cerminar Oct 23, 2017
c011498
move to the trigger geometry to compute the position. This needs some…
cerminar Jan 16, 2018
fb3d571
expand gen information borrowing the code from CMS-HGCAL/reco-ntuples…
cerminar Jan 17, 2018
c6c076e
support for the new GEN module
cerminar Jan 17, 2018
c8c7a7b
adapt the python config to the new GEN module functionality
cerminar Jan 17, 2018
ae3f772
small fixes after merging conflicts
cerminar Jan 18, 2018
398f593
Fix of dRNNC2D
tstreble Jan 22, 2018
e8d1163
Merge pull request #176 from tstreble/dRNNC2d_update
jbsauvan Jan 23, 2018
a1ce640
make the interface more clear about the fact that some of the methods…
cerminar Jan 23, 2018
607eb79
cosmetics + new more consistent way to retrieve layer z positions
cerminar Jan 23, 2018
9d2421e
change name of particle filter and switch some defaults
cerminar Jan 23, 2018
f467df2
cleanup
cerminar Jan 23, 2018
a99a0b5
Move cluster calibration to the C2Ds
tstreble Jan 23, 2018
529b1f8
Cosmetic changes
tstreble Jan 24, 2018
178fff5
Merge pull request #177 from tstreble/HGC_C2D_calibr
jbsauvan Jan 25, 2018
3062cef
more explicit names to remove magic
cerminar Jan 25, 2018
5dd214f
Merge pull request #175 from cerminar/gc_dev_01_94X
jbsauvan Jan 25, 2018
aa74213
Add clustering and calibration customization functions
jbsauvan Feb 11, 2018
12960a4
Merge pull request #181 from jbsauvan/config-defaults
jbsauvan Feb 12, 2018
85741b6
Merged hgc-tpg-devel-CMSSW_9_4_0_pre2 from repository PFCal-dev with …
tstreble Feb 14, 2018
b555619
New implementation of HGC towers
tstreble Feb 16, 2018
b14aa22
Fixed alignement
tstreble Feb 16, 2018
aa0d156
Updated eta range for warning in HGC towers
tstreble Feb 16, 2018
d678efe
Fix for 2D tower maps
tstreble Feb 16, 2018
97403fc
Fix shower shape filling with DBSCAN
jbsauvan Feb 22, 2018
1e84db6
Add exception if calib coeff = 0 applied
jbsauvan Feb 22, 2018
dc6c300
Improvements of HGC TowerMaps
tstreble Feb 22, 2018
774a4f0
Cleaning
tstreble Feb 22, 2018
3f4e93a
Merge pull request #182 from tstreble/L1THGC_TowerMaps_2.0
jbsauvan Feb 23, 2018
e88d8ce
Merged hgc-tpg-devel-CMSSW_9_4_0_pre2 from repository PFCal-dev with …
jbsauvan Feb 23, 2018
1edf95b
Post 10_1_X merging fixes
jbsauvan Feb 23, 2018
620f898
cleaning
jbsauvan Feb 27, 2018
a881c1d
Fix constness
jbsauvan Feb 28, 2018
99cea22
Merge pull request #187 from jbsauvan/cleaning
jbsauvan Feb 28, 2018
b570b5a
Remove TDR panel mapping from data
jbsauvan Feb 28, 2018
658743f
Use hash table instead of vector to store cluster constituents
jbsauvan Mar 1, 2018
84dfff8
cleaning
jbsauvan Mar 2, 2018
3affe2a
Use configurable input tags
jbsauvan Mar 2, 2018
625c55e
Use ESWatchers in gen ntuplizer
jbsauvan Mar 2, 2018
c3f8207
Remove hardcoded variables
jbsauvan Mar 2, 2018
5bf06db
Switch back default clustering in test cfg
jbsauvan Mar 2, 2018
e3a1c3b
Add HGCAL TPG in standard sequences
jbsauvan Mar 4, 2018
a787a94
Merge branch 'master' into hgc-tpg-integration-180228
jbsauvan Mar 5, 2018
5b5339b
Apply code checks
jbsauvan Mar 5, 2018
764c79b
Add layer tower maps in event
jbsauvan Mar 7, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 107 additions & 37 deletions DataFormats/L1THGCal/interface/HGCalClusterT.h
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(){}
Expand Down Expand Up @@ -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++ )
Copy link
Contributor

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

Copy link
Contributor Author

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 an unordered_map, the key being the constituent id.

{
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 ){
Copy link
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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_; }
Expand Down Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions DataFormats/L1THGCal/interface/HGCalTower.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ namespace l1t {
int hwEtHad()const;
int hwEtRatio()const;

HGCalTower& operator+=(const HGCalTower& tower);

private:

// additional hardware quantities
Expand Down
66 changes: 66 additions & 0 deletions DataFormats/L1THGCal/interface/HGCalTowerMap.h
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;
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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


23 changes: 23 additions & 0 deletions DataFormats/L1THGCal/src/HGCalTower.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "DataFormats/L1THGCal/interface/HGCalTower.h"
#include "FWCore/Utilities/interface/EDMException.h"

using namespace l1t;

Expand Down Expand Up @@ -76,3 +77,25 @@ int HGCalTower::hwEtRatio()const
{
return hwEtRatio_;
}




HGCalTower& HGCalTower::operator+=(const HGCalTower& tower){

if(this->hwEta()!= tower.hwEta() || this->hwPhi()!= tower.hwPhi()){
throw edm::Exception(edm::errors::StdException, "StdException")
<< "HGCalTower: Trying to add HGCalTowers with different coordinates"<<endl;
}

this->setP4(this->p4() + tower.p4());
this->setEtEm(this->etEm() + tower.etEm());
this->setEtHad(this->etHad() + tower.etHad());

this->setHwPt(this->hwPt() + tower.hwPt());
this->setHwEtEm(this->hwEtEm() + tower.hwEtEm());
this->setHwEtHad(this->hwEtHad() + tower.hwEtHad());

return *this;

}
Loading