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

[Backport] HGCAL trigger updates - 1 #22480

Merged
Merged
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
5650c07
Add panel ntuple
jbsauvan Nov 23, 2017
8c196e8
This is adding a new clustering method. It consists in a combined dR…
Dec 1, 2017
c123d01
Update panel ntuple
jbsauvan Dec 6, 2017
f49c5d5
Add TDR-like panel geometry
jbsauvan Dec 6, 2017
9a0c64d
Add calibration of sim energies in ntuples and update TC calib coeffs…
jbsauvan Dec 7, 2017
1461625
Update of the new geoNN 2D cluster algorithm. All the pieces are in p…
Dec 8, 2017
a6ef753
C2D geoNN is updated and seeds are treated in order to avoid NN seeds…
Dec 8, 2017
3fb1a01
NN-geo clustering: sorting of the distance vector done using std::sort()
Dec 8, 2017
66158dc
All comments implemnted except the PtrVector to be replaces with vect…
Dec 11, 2017
5af6c71
edm::PtrVector<C> has been replaces with std::vector<edm::Ptr<C>>
Dec 12, 2017
2b2a53e
Few style fixes
Dec 14, 2017
b678280
Fix simhit calibration
jbsauvan Dec 16, 2017
34461d2
Reduce TC threshold in frontend
jbsauvan Dec 16, 2017
574a1bd
Indentation fixed in DataFormats/L1THGCal/interface/HGCalClusterT.h; …
Dec 18, 2017
60ad731
Cleaning
jbsauvan Jan 12, 2018
26b6ff8
Fix of dRNNC2d
tstreble Jan 13, 2018
db81cc1
Use TDR panel layout as default
jbsauvan Jan 16, 2018
771d443
Fix custom geometries
jbsauvan Jan 16, 2018
a1bbf4d
add quick and dirty implementation of a tool suite, currently mainly …
cerminar Oct 19, 2017
7c8c524
make the layer count independent on the subdet
cerminar Oct 19, 2017
525c781
make the layer count independent on the subdet
cerminar Oct 19, 2017
4bdc47f
cleanup
cerminar Oct 23, 2017
38f41d3
switch on sim info
cerminar Oct 23, 2017
bc212d6
move to the trigger geometry to compute the position. This needs some…
cerminar Jan 16, 2018
8f9e09f
expand gen information borrowing the code from CMS-HGCAL/reco-ntuples…
cerminar Jan 17, 2018
9a0b5a1
support for the new GEN module
cerminar Jan 17, 2018
b7fdba1
adapt the python config to the new GEN module functionality
cerminar Jan 17, 2018
f52298d
small fixes after merging conflicts
cerminar Jan 18, 2018
ad4d725
Fix of dRNNC2D
tstreble Jan 22, 2018
867ca72
make the interface more clear about the fact that some of the methods…
cerminar Jan 23, 2018
ca78a1c
cosmetics + new more consistent way to retrieve layer z positions
cerminar Jan 23, 2018
4076f4c
change name of particle filter and switch some defaults
cerminar Jan 23, 2018
463552d
cleanup
cerminar Jan 23, 2018
cf1ef4a
Move cluster calibration to the C2Ds
tstreble Jan 23, 2018
b8ab791
Cosmetic changes
tstreble Jan 24, 2018
cafb5f4
more explicit names to remove magic
cerminar Jan 25, 2018
245c72c
Add clustering and calibration customization functions
jbsauvan Feb 11, 2018
586fc2c
New implementation of HGC towers
tstreble Feb 16, 2018
3f67551
Fixed alignement
tstreble Feb 16, 2018
7f03d4a
Updated eta range for warning in HGC towers
tstreble Feb 16, 2018
67814ff
Fix for 2D tower maps
tstreble Feb 16, 2018
91c8ac9
Fix shower shape filling with DBSCAN
jbsauvan Feb 22, 2018
5b96a77
Add exception if calib coeff = 0 applied
jbsauvan Feb 22, 2018
b7295ef
Improvements of HGC TowerMaps
tstreble Feb 22, 2018
17cb3c6
Cleaning
tstreble Feb 22, 2018
9a2b9fe
Post 10_1_X merging fixes
jbsauvan Feb 23, 2018
928f281
cleaning
jbsauvan Feb 27, 2018
a494c85
Fix constness
jbsauvan Feb 28, 2018
2f2bb96
Remove TDR panel mapping from data
jbsauvan Feb 28, 2018
2a3bc03
Use hash table instead of vector to store cluster constituents
jbsauvan Mar 1, 2018
78d86b0
cleaning
jbsauvan Mar 2, 2018
8642078
Use configurable input tags
jbsauvan Mar 2, 2018
71f4ac6
Use ESWatchers in gen ntuplizer
jbsauvan Mar 2, 2018
d4ed6a5
Remove hardcoded variables
jbsauvan Mar 2, 2018
52fcd15
Switch back default clustering in test cfg
jbsauvan Mar 2, 2018
58f8836
Apply code checks
jbsauvan Mar 5, 2018
a098ccd
Post-rebase fixes
jbsauvan Mar 6, 2018
fd91c93
Change default 2D clustering + event content
jbsauvan Mar 6, 2018
d928245
Add layer tower maps in event
jbsauvan Mar 7, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
126 changes: 84 additions & 42 deletions DataFormats/L1THGCal/interface/HGCalClusterT.h
@@ -1,22 +1,25 @@
#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"

/* ROOT */
#include "Math/Vector3D.h"

#include <unordered_map>

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

public:
typedef typename edm::PtrVector<C>::const_iterator const_iterator;
typedef typename std::unordered_map<uint32_t, edm::Ptr<C>>::const_iterator const_iterator;

public:
HGCalClusterT(){}
Expand Down Expand Up @@ -44,63 +47,65 @@ namespace l1t
addConstituent(c);
}

~HGCalClusterT() {};
~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::unordered_map<uint32_t, 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 );
updateP4AndPosition(c, updateCentre, fraction);

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

int updatedPt = hwPt() + c->hwPt();
setHwPt(updatedPt);
constituents_.emplace( c->detId(), c );
constituentsFraction_.emplace( c->detId(), fraction );

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

constituents_.push_back( c );
void removeConstituent( const edm::Ptr<C>& c, bool updateCentre=true ){

/* remove the pointer to c from the std::vector */
double fraction=0;
const auto& constituent_itr = constituents_.find(c->detId());
const auto& fraction_itr = constituentsFraction_.find(c->detId());
if(constituent_itr!=constituents_.end())
{
// remove constituent and get its fraction in the cluster
fraction = fraction_itr->second;
constituents_.erase(constituent_itr);
constituentsFraction_.erase(fraction_itr);

updateP4AndPosition(c, updateCentre, -fraction);
}
}
bool valid() const { return valid_;}
void setValid(bool valid) { valid_ = valid;}

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 +183,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::unordered_map<uint32_t, edm::Ptr<C>> constituents_;
std::unordered_map<uint32_t, double> constituentsFraction_;

GlobalPoint centre_;
GlobalPoint centreProj_; // centre projected onto the first HGCal layer

Expand All @@ -207,6 +216,39 @@ namespace l1t

ClusterShapes shapes_;


void updateP4AndPosition(const edm::Ptr<C>& c, bool updateCentre=true, float fraction=1.)
{
double cMipt = c->mipPt()*fraction;
/* 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_ += cMipt;

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

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

};

}
Expand Down
2 changes: 2 additions & 0 deletions DataFormats/L1THGCal/interface/HGCalTower.h
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
@@ -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;
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
@@ -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;

}