Skip to content

Commit

Permalink
Merge pull request #22296 from PFCal-dev/hgc-tpg-integration-171214-b…
Browse files Browse the repository at this point in the history
…ackport93X

[Backport] HGCAL trigger updates
  • Loading branch information
cmsbuild committed Mar 1, 2018
2 parents 30c5767 + 056330a commit 0bd9e37
Show file tree
Hide file tree
Showing 29 changed files with 1,598 additions and 122 deletions.
49 changes: 48 additions & 1 deletion DataFormats/L1THGCal/interface/HGCalClusterT.h
Expand Up @@ -95,6 +95,7 @@ namespace l1t
double seedMipPt() const { return seedMipPt_; }
uint32_t detId() const { return detId_.rawId(); }


/* distance in 'cm' */
double distance( const l1t::HGCalTriggerCell &tc ) const
{
Expand Down Expand Up @@ -139,8 +140,38 @@ namespace l1t
uint32_t subdetId() const {return detId_.subdetId();}
uint32_t layer() const {return detId_.layer();}
int32_t zside() const {return detId_.zside();}



//shower shape

int showerLength() const { return showerLength_; }
int coreShowerLength() const { return coreShowerLength_; }
int firstLayer() const { return firstLayer_; }
int maxLayer() const { return maxLayer_; }
float eMax() const { return eMax_; }
float sigmaEtaEtaMax() const { return sigmaEtaEtaMax_; }
float sigmaPhiPhiMax() const { return sigmaPhiPhiMax_; }
float sigmaEtaEtaTot() const { return sigmaEtaEtaTot_; }
float sigmaPhiPhiTot() const { return sigmaPhiPhiTot_; }
float sigmaZZ() const { return sigmaZZ_; }
float sigmaRRTot() const { return sigmaRRTot_; }
float sigmaRRMax() const { return sigmaRRMax_; }
float sigmaRRMean() const { return sigmaRRMean_; }

void showerLength(int showerLength) { showerLength_ = showerLength;}
void coreShowerLength(int coreShowerLength) { coreShowerLength_ = coreShowerLength;}
void firstLayer(int firstLayer) { firstLayer_ = firstLayer;}
void maxLayer(int maxLayer) { maxLayer_ = maxLayer;}
void eMax(float eMax) { eMax_ = eMax;}
void sigmaEtaEtaMax(float sigmaEtaEtaMax) { sigmaEtaEtaMax_ = sigmaEtaEtaMax;}
void sigmaEtaEtaTot(float sigmaEtaEtaTot) { sigmaEtaEtaTot_ = sigmaEtaEtaTot;}
void sigmaPhiPhiMax(float sigmaPhiPhiMax) { sigmaPhiPhiMax_ = sigmaPhiPhiMax;}
void sigmaPhiPhiTot(float sigmaPhiPhiTot) { sigmaPhiPhiTot_ = sigmaPhiPhiTot;}
void sigmaRRMax(float sigmaRRMax) { sigmaRRMax_ = sigmaRRMax;}
void sigmaRRTot(float sigmaRRTot) { sigmaRRTot_ = sigmaRRTot;}
void sigmaRRMean(float sigmaRRMean) { sigmaRRMean_ = sigmaRRMean;}
void sigmaZZ(float sigmaZZ) { sigmaZZ_ = sigmaZZ;}

/* operators */
bool operator<(const HGCalClusterT<C>& cl) const {return mipPt() < cl.mipPt();}
bool operator>(const HGCalClusterT<C>& cl) const { return cl<*this; }
Expand All @@ -158,6 +189,22 @@ namespace l1t
double mipPt_;
double seedMipPt_;

//shower shape

int showerLength_;
int coreShowerLength_;
int firstLayer_;
int maxLayer_;
float eMax_;
float sigmaEtaEtaMax_;
float sigmaPhiPhiMax_;
float sigmaRRMax_;
float sigmaEtaEtaTot_;
float sigmaPhiPhiTot_;
float sigmaRRTot_;
float sigmaRRMean_;
float sigmaZZ_;

ClusterShapes shapes_;

};
Expand Down
15 changes: 10 additions & 5 deletions DataFormats/L1THGCal/src/classes_def.xml
@@ -1,4 +1,3 @@

<lcgdict>
<class name="l1t::HGCFETriggerDigi" ClassVersion="10">
<version ClassVersion="10" checksum="3197268020"/>
Expand All @@ -21,16 +20,22 @@
<class name="edm::Wrapper<l1t::HGCalTowerBxCollection>"/>

<class name="l1t::HGCalClusterT<l1t::HGCalTriggerCell>" />
<class name="l1t::HGCalCluster" ClassVersion="10">
<version ClassVersion="10" checksum="607544984"/>
<class name="l1t::HGCalCluster" ClassVersion="13">
<version ClassVersion="13" checksum="3397489079"/>
<version ClassVersion="12" checksum="623703096"/>
<version ClassVersion="11" checksum="354623225"/>
<version ClassVersion="10" checksum="607544984"/>
</class>
<class name="std::vector<l1t::HGCalCluster>" />
<class name="l1t::HGCalClusterBxCollection"/>
<class name="edm::Wrapper<l1t::HGCalClusterBxCollection>"/>

<class name="l1t::HGCalClusterT<l1t::HGCalCluster>" />
<class name="l1t::HGCalMulticluster" ClassVersion="10">
<version ClassVersion="10" checksum="1878482802"/>
<class name="l1t::HGCalMulticluster" ClassVersion="13">
<version ClassVersion="13" checksum="816077951"/>
<version ClassVersion="12" checksum="4221677522"/>
<version ClassVersion="11" checksum="1508179045"/>
<version ClassVersion="10" checksum="1878482802"/>
</class>
<class name="std::vector<l1t::HGCalMulticluster>" />
<class name="l1t::HGCalMulticlusterBxCollection"/>
Expand Down
1 change: 1 addition & 0 deletions L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h
Expand Up @@ -62,6 +62,7 @@ class HGCalTriggerGeometryBase

virtual bool validTriggerCell( const unsigned trigger_cell_id) const = 0;
virtual bool disconnectedModule(const unsigned module_id) const = 0;
virtual unsigned triggerLayer(const unsigned id) const = 0;

protected:
void setCaloGeometry(const edm::ESHandle<CaloGeometry>& geom) {calo_geometry_=geom;}
Expand Down
Expand Up @@ -137,8 +137,9 @@ class HGCalTriggerGeometryGenericMapping : public HGCalTriggerGeometryBase {
virtual GlobalPoint getTriggerCellPosition(const unsigned trigger_cell_det_id) const override final;
virtual GlobalPoint getModulePosition(const unsigned module_det_id) const override final;

virtual bool validTriggerCell( const unsigned trigger_cell_det_id ) const override final;
virtual bool disconnectedModule(const unsigned module_id) const override final;
bool validTriggerCell( const unsigned trigger_cell_det_id ) const final;
bool disconnectedModule(const unsigned module_id) const final;
unsigned triggerLayer(const unsigned id) const final;

protected:
geom_map cells_to_trigger_cells_;
Expand Down
26 changes: 26 additions & 0 deletions L1Trigger/L1THGCal/interface/HGCalTriggerTools.h
@@ -0,0 +1,26 @@
#ifndef __L1Trigger_L1THGCal_HGCalTriggerTools_h__
#define __L1Trigger_L1THGCal_HGCalTriggerTools_h__

#include "DataFormats/ForwardDetId/interface/ForwardSubdetector.h"
#include "FWCore/Framework/interface/EventSetup.h"

class HGCalTriggerTools
{
public:
HGCalTriggerTools():
eeLayers_(0), fhLayers_(0), bhLayers_(0), totalLayers_(0){}
~HGCalTriggerTools() {};

void eventSetup(const edm::EventSetup&);
unsigned layers(ForwardSubdetector type) const;
unsigned layerWithOffset(unsigned) const;

private:
unsigned eeLayers_;
unsigned fhLayers_;
unsigned bhLayers_;
unsigned totalLayers_;
};


#endif
11 changes: 4 additions & 7 deletions L1Trigger/L1THGCal/interface/be_algorithms/HGCalClusteringImpl.h
Expand Up @@ -9,22 +9,18 @@
#include "DataFormats/ForwardDetId/interface/HGCalDetId.h"
#include "DataFormats/L1THGCal/interface/HGCalCluster.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h"

class HGCalClusteringImpl{

private:
static const unsigned kNSides_ = 2;
// FIXME: currently there is no access to the HGCal DDDConstants
// So cannot retrieve the following constants.
static const unsigned kLayersEE_ = 28;
static const unsigned kLayersFH_ = 12;
static const unsigned kLayersBH_ = 12;
static const unsigned kLayers_ = kLayersEE_+kLayersFH_+kLayersBH_;

public:

HGCalClusteringImpl( const edm::ParameterSet & conf);

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

/* dR-algorithms */
bool isPertinent( const l1t::HGCalTriggerCell & tc,
Expand Down Expand Up @@ -59,8 +55,9 @@ class HGCalClusteringImpl{
double dr_;
std::string clusteringAlgorithmType_;
void triggerCellReshuffling( const edm::PtrVector<l1t::HGCalTriggerCell> & triggerCellsPtrs,
std::array<std::array<std::vector<edm::Ptr<l1t::HGCalTriggerCell>>, kLayers_>, kNSides_> & reshuffledTriggerCells );
std::array<std::vector<std::vector<edm::Ptr<l1t::HGCalTriggerCell>>>, kNSides_> & reshuffledTriggerCells );

HGCalTriggerTools triggerTools_;

};

Expand Down
Expand Up @@ -6,24 +6,55 @@
#include "DataFormats/L1THGCal/interface/HGCalMulticluster.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

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

class HGCalMulticlusteringImpl{

public:

HGCalMulticlusteringImpl( const edm::ParameterSet &conf);

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

bool isPertinent( const l1t::HGCalCluster & clu,
const l1t::HGCalMulticluster & mclu,
double dR ) const;

void clusterize( const edm::PtrVector<l1t::HGCalCluster> & clustersPtr,
l1t::HGCalMulticlusterBxCollection & multiclusters);
void clusterizeDR( const edm::PtrVector<l1t::HGCalCluster> & clustersPtr,
l1t::HGCalMulticlusterBxCollection & multiclusters,
const HGCalTriggerGeometryBase & triggerGeometry
);

void clusterizeDBSCAN( const edm::PtrVector<l1t::HGCalCluster> & clustersPtr,
l1t::HGCalMulticlusterBxCollection & multiclusters,
const HGCalTriggerGeometryBase & triggerGeometry
);

private:

void findNeighbor( const std::vector<std::pair<unsigned int,double>>& rankedList,
unsigned int searchInd,
const edm::PtrVector<l1t::HGCalCluster> & clustersPtr,
std::vector<unsigned int>& neigbors);

double dr_;
double ptC3dThreshold_;
double calibSF_;
std::string multiclusterAlgoType_;
double distDbscan_ = 0.005;
unsigned minNDbscan_ = 3;
std::vector<double> layerWeights_;
bool applyLayerWeights_;

HGCalShowerShape shape_;
HGCalTriggerTools triggerTools_;

};

#endif
84 changes: 84 additions & 0 deletions L1Trigger/L1THGCal/interface/be_algorithms/HGCalShowerShape.h
@@ -0,0 +1,84 @@
#ifndef __L1Trigger_L1THGCal_HGCalShowerShape_h__
#define __L1Trigger_L1THGCal_HGCalShowerShape_h__
#include <vector>
#include <functional>
#include <cmath>
#include "DataFormats/L1THGCal/interface/HGCalMulticluster.h"
#include "DataFormats/Math/interface/LorentzVector.h"
#include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h"
#include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h"
#include "DataFormats/Math/interface/deltaPhi.h"

class HGCalShowerShape{

public:
typedef math::XYZTLorentzVector LorentzVector;

HGCalShowerShape(){}

~HGCalShowerShape(){}

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

int firstLayer(const l1t::HGCalMulticluster& c3d) const;
int lastLayer(const l1t::HGCalMulticluster& c3d) const;
int maxLayer(const l1t::HGCalMulticluster& c3d) const;
int showerLength(const l1t::HGCalMulticluster& c3d) const {return lastLayer(c3d)-firstLayer(c3d)+1; }//in number of layers
// Maximum number of consecutive layers in the cluster
int coreShowerLength(const l1t::HGCalMulticluster& c3d, const HGCalTriggerGeometryBase& triggerGeometry) const;

float eMax(const l1t::HGCalMulticluster& c3d) const;

float sigmaZZ(const l1t::HGCalMulticluster& c3d) const;

float sigmaEtaEtaTot(const l1t::HGCalMulticluster& c3d) const;
float sigmaEtaEtaTot(const l1t::HGCalCluster& c2d) const;
float sigmaEtaEtaMax(const l1t::HGCalMulticluster& c3d) const;

float sigmaPhiPhiTot(const l1t::HGCalMulticluster& c3d) const;
float sigmaPhiPhiTot(const l1t::HGCalCluster& c2d) const;
float sigmaPhiPhiMax(const l1t::HGCalMulticluster& c3d) const;

float sigmaRRTot(const l1t::HGCalMulticluster& c3d) const;
float sigmaRRTot(const l1t::HGCalCluster& c2d) const;
float sigmaRRMax(const l1t::HGCalMulticluster& c3d) const;
float sigmaRRMean(const l1t::HGCalMulticluster& c3d, float radius=5.) const;

private:

float meanX(const std::vector<pair<float,float> >& energy_X_tc) const;
// Compute energy-weighted RMS of any variable X in the cluster
// Delta(a,b) functor as template argument. Default is (a-b)
template<typename Delta=std::minus<float>> float sigmaXX(
const std::vector<pair<float,float> >& energy_X_tc,
const float X_cluster) const {

Delta delta;
float Etot = 0;
float deltaX2_sum = 0;
for(const auto& energy_X : energy_X_tc){
deltaX2_sum += energy_X.first * pow(delta(energy_X.second, X_cluster),2);
Etot += energy_X.first;
}
float X_MSE = 0;
if (Etot>0) X_MSE=deltaX2_sum/Etot;
float X_RMS=sqrt(X_MSE);
return X_RMS;
}
// Special case of delta for phi
template <class T> struct DeltaPhi {
T operator() (const T& x, const T& y) const {return deltaPhi(x,y);}
};
float sigmaPhiPhi(
const std::vector<pair<float,float> >& energy_phi_tc,
const float phi_cluster) const {
return sigmaXX<DeltaPhi<float>>(energy_phi_tc,phi_cluster);
}

HGCalTriggerTools triggerTools_;

};


#endif

Expand Up @@ -13,20 +13,14 @@
#include "DataFormats/ForwardDetId/interface/HGCHEDetId.h"
#include "DataFormats/ForwardDetId/interface/HGCalDetId.h"
#include "DataFormats/L1THGCal/interface/HGCalTriggerCell.h"
#include "L1Trigger/L1THGCal/interface/HGCalTriggerTools.h"

class HGCalTriggerCellCalibration{

private:
// FIXME: currently there is no access to the HGCal DDDConstants
// So cannot retrieve the following constants.
static const unsigned kLayersEE_ = 28;
static const unsigned kLayersFH_ = 12;
static const unsigned kLayersBH_ = 12;
static const unsigned kLayers_ = kLayersEE_+kLayersFH_+kLayersBH_;

public:

HGCalTriggerCellCalibration(const edm::ParameterSet &conf);
void eventSetup(const edm::EventSetup& es) {triggerTools_.eventSetup(es);}
void calibrateInMipT(l1t::HGCalTriggerCell&);
void calibrateMipTinGeV(l1t::HGCalTriggerCell&);
void calibrateInGeV(l1t::HGCalTriggerCell&);
Expand All @@ -40,6 +34,8 @@ class HGCalTriggerCellCalibration{
double thickCorr_;
std::vector<double> dEdX_weights_;

HGCalTriggerTools triggerTools_;

};

#endif
1 change: 1 addition & 0 deletions L1Trigger/L1THGCal/plugins/BuildFile.xml
Expand Up @@ -32,5 +32,6 @@
<use name="SimDataFormats/CaloTest"/>
<use name="DataFormats/JetReco"/>
<use name="Geometry/HcalTowerAlgo"/>
<use name="SimDataFormats/PileupSummaryInfo"/>
<flags EDM_PLUGIN="1"/>
</library>

0 comments on commit 0bd9e37

Please sign in to comment.