Skip to content

Commit

Permalink
Merge pull request #161 from jbsauvan/activate-halflayers
Browse files Browse the repository at this point in the history
Half layers in the EE by default
  • Loading branch information
jbsauvan committed Nov 17, 2017
2 parents 118cd2e + 88f5e7c commit b23167d
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 26 deletions.
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 @@ -139,6 +139,7 @@ class HGCalTriggerGeometryGenericMapping : public HGCalTriggerGeometryBase {

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

protected:
geom_map cells_to_trigger_cells_;
Expand Down
Expand Up @@ -6,6 +6,7 @@
#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"

class HGCalMulticlusteringImpl{
Expand All @@ -19,10 +20,14 @@ class HGCalMulticlusteringImpl{
double dR ) const;

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

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

private:

Expand Down
Expand Up @@ -4,6 +4,7 @@
#include <cmath>
#include "DataFormats/L1THGCal/interface/HGCalMulticluster.h"
#include "DataFormats/Math/interface/LorentzVector.h"
#include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryBase.h"

class HGCalShowerShape{

Expand All @@ -19,7 +20,7 @@ class HGCalShowerShape{
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;
int coreShowerLength(const l1t::HGCalMulticluster& c3d, const HGCalTriggerGeometryBase& triggerGeometry) const;

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

Expand Down
4 changes: 2 additions & 2 deletions L1Trigger/L1THGCal/plugins/be_algorithms/HGCClusterAlgo.cc
Expand Up @@ -187,10 +187,10 @@ void HGCClusterAlgo<FECODEC,DATA>::run(const l1t::HGCFETriggerDigiCollection & c
/* call to multiclustering and compute shower shape*/
switch(multiclusteringAlgoType_){
case dRC3d :
multiclustering_.clusterizeDR( clustersPtrs, *multicluster_product_ );
multiclustering_.clusterizeDR( clustersPtrs, *multicluster_product_, *triggerGeometry_);
break;
case DBSCANC3d:
multiclustering_.clusterizeDBSCAN( clustersPtrs, *multicluster_product_ );
multiclustering_.clusterizeDBSCAN( clustersPtrs, *multicluster_product_, *triggerGeometry_);
break;
default:
// Should not happen, clustering type checked in constructor
Expand Down
Expand Up @@ -36,6 +36,7 @@ class HGCalTriggerGeometryHexImp2 : public HGCalTriggerGeometryBase

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

private:
edm::FileInPath l1tCellsMapping_;
Expand Down Expand Up @@ -773,6 +774,14 @@ disconnectedModule(const unsigned module_id) const
return false;
}


unsigned
HGCalTriggerGeometryHexImp2::
triggerLayer(const unsigned id) const
{
return HGCalDetId(id).layer();
}

bool
HGCalTriggerGeometryHexImp2::
validTriggerCellFromCells(const unsigned trigger_cell_id) const
Expand Down
Expand Up @@ -37,6 +37,7 @@ class HGCalTriggerGeometryHexLayerBasedImp1 : public HGCalTriggerGeometryBase

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

private:
edm::FileInPath l1tCellsMapping_;
Expand Down Expand Up @@ -68,10 +69,12 @@ class HGCalTriggerGeometryHexLayerBasedImp1 : public HGCalTriggerGeometryBase
// Disconnected modules and layers
std::unordered_set<unsigned> disconnected_modules_;
std::unordered_set<unsigned> disconnected_layers_;
std::vector<unsigned> trigger_layers_;

// layer offsets
unsigned fhOffset_;
unsigned bhOffset_;
unsigned totalLayers_;

void fillMaps();
void fillNeighborMaps(const edm::FileInPath&, std::unordered_map<int, std::set<std::pair<short,short>>>&);
Expand Down Expand Up @@ -129,6 +132,22 @@ initialize(const edm::ESHandle<CaloGeometry>& calo_geometry)
setCaloGeometry(calo_geometry);
fhOffset_ = eeTopology().dddConstants().layers(true);
bhOffset_ = fhOffset_ + fhTopology().dddConstants().layers(true);
totalLayers_ = bhOffset_ + bhTopology().dddConstants()->getMaxDepth(1);
trigger_layers_.resize(totalLayers_+1);
unsigned trigger_layer = 0;
for(unsigned layer=0; layer<trigger_layers_.size(); layer++)
{
if(disconnected_layers_.find(layer)==disconnected_layers_.end())
{
// Increase trigger layer number if the layer is not disconnected
trigger_layers_[layer] = trigger_layer;
trigger_layer++;
}
else
{
trigger_layers_[layer] = 0;
}
}
fillMaps();
fillNeighborMaps(l1tCellNeighborsMapping_, trigger_cell_neighbors_);
fillNeighborMaps(l1tCellNeighborsBHMapping_, trigger_cell_neighbors_bh_);
Expand Down Expand Up @@ -698,6 +717,15 @@ disconnectedModule(const unsigned module_id) const
return disconnected;
}

unsigned
HGCalTriggerGeometryHexLayerBasedImp1::
triggerLayer(const unsigned id) const
{
unsigned layer = layerWithOffset(id);
if(layer>=trigger_layers_.size()) return 0;
return trigger_layers_[layer];
}

bool
HGCalTriggerGeometryHexLayerBasedImp1::
validTriggerCellFromCells(const unsigned trigger_cell_id) const
Expand Down
30 changes: 15 additions & 15 deletions L1Trigger/L1THGCal/python/hgcalTriggerGeometryESProducer_cfi.py
@@ -1,20 +1,20 @@
import FWCore.ParameterSet.Config as cms

disconnectedTriggerLayers = [
1,
3,
5,
7,
9,
11,
13,
15,
17,
19,
21,
23,
25,
27
2,
4,
6,
8,
10,
12,
14,
16,
18,
20,
22,
24,
26,
28
]


Expand All @@ -25,7 +25,7 @@
L1TCellsBHMapping = cms.FileInPath("L1Trigger/L1THGCal/data/triggercell_mapping_BH_3x3_30deg_0.txt"),
L1TCellNeighborsBHMapping = cms.FileInPath("L1Trigger/L1THGCal/data/triggercell_neighbor_mapping_BH_3x3_30deg_0.txt"),
DisconnectedModules = cms.vuint32(0),
DisconnectedLayers = cms.vuint32([])
DisconnectedLayers = cms.vuint32(disconnectedTriggerLayers)
)

hgcalTriggerGeometryESProducer = cms.ESProducer(
Expand Down
Expand Up @@ -70,7 +70,7 @@
calibSF_multicluster = cms.double(1.084),
type_multicluster = cms.string('dRC3d'), #'DBSCANC3d' for the DBSCAN algorithm
applyLayerCalibration = cms.bool(True),
layerWeights = layercalibparam.AllLayer_weights,
layerWeights = layercalibparam.TrgLayer_weights,
dist_dbscan_multicluster = cms.double(0.005),
minN_dbscan_multicluster = cms.uint32(3)
)
Expand Down
8 changes: 8 additions & 0 deletions L1Trigger/L1THGCal/src/HGCalTriggerGeometryGenericMapping.cc
@@ -1,5 +1,6 @@
#include "L1Trigger/L1THGCal/interface/HGCalTriggerGeometryGenericMapping.h"


using namespace HGCalTriggerGeometry;

namespace {
Expand Down Expand Up @@ -131,3 +132,10 @@ disconnectedModule(const unsigned module_id) const {
return false;
}


unsigned
HGCalTriggerGeometryGenericMapping::
triggerLayer(const unsigned id) const {
return HGCalDetId(id).layer();
}

Expand Up @@ -73,7 +73,8 @@ void HGCalMulticlusteringImpl::findNeighbor( const std::vector<std::pair<unsigne


void HGCalMulticlusteringImpl::clusterizeDR( const edm::PtrVector<l1t::HGCalCluster> & clustersPtrs,
l1t::HGCalMulticlusterBxCollection & multiclusters)
l1t::HGCalMulticlusterBxCollection & multiclusters,
const HGCalTriggerGeometryBase & triggerGeometry)
{

std::vector<l1t::HGCalMulticluster> multiclustersTmp;
Expand Down Expand Up @@ -145,7 +146,7 @@ void HGCalMulticlusteringImpl::clusterizeDR( const edm::PtrVector<l1t::HGCalClus

//compute shower shape
multiclustersTmp.at(i).set_showerLength(shape_.showerLength(multiclustersTmp.at(i)));
multiclustersTmp.at(i).set_coreShowerLength(shape_.coreShowerLength(multiclustersTmp.at(i)));
multiclustersTmp.at(i).set_coreShowerLength(shape_.coreShowerLength(multiclustersTmp.at(i), triggerGeometry));
multiclustersTmp.at(i).set_firstLayer(shape_.firstLayer(multiclustersTmp.at(i)));
multiclustersTmp.at(i).set_maxLayer(shape_.maxLayer(multiclustersTmp.at(i)));
multiclustersTmp.at(i).set_sigmaEtaEtaTot(shape_.sigmaEtaEtaTot(multiclustersTmp.at(i)));
Expand All @@ -157,13 +158,15 @@ void HGCalMulticlusteringImpl::clusterizeDR( const edm::PtrVector<l1t::HGCalClus
multiclustersTmp.at(i).set_sigmaRRMax(shape_.sigmaRRMax(multiclustersTmp.at(i)));
multiclustersTmp.at(i).set_sigmaRRMean(shape_.sigmaRRMean(multiclustersTmp.at(i)));
multiclustersTmp.at(i).set_eMax(shape_.eMax(multiclustersTmp.at(i)));

multiclusters.push_back( 0, multiclustersTmp.at(i));
}
}

}
void HGCalMulticlusteringImpl::clusterizeDBSCAN( const edm::PtrVector<l1t::HGCalCluster> & clustersPtrs,
l1t::HGCalMulticlusterBxCollection & multiclusters)
l1t::HGCalMulticlusterBxCollection & multiclusters,
const HGCalTriggerGeometryBase & triggerGeometry)
{

std::vector<l1t::HGCalMulticluster> multiclustersTmp;
Expand Down
4 changes: 2 additions & 2 deletions L1Trigger/L1THGCal/src/be_algorithms/HGCalShowerShape.cc
Expand Up @@ -144,13 +144,13 @@ int HGCalShowerShape::lastLayer(const l1t::HGCalMulticluster& c3d) const {

}

int HGCalShowerShape::coreShowerLength(const l1t::HGCalMulticluster& c3d) const
int HGCalShowerShape::coreShowerLength(const l1t::HGCalMulticluster& c3d, const HGCalTriggerGeometryBase& triggerGeometry) const
{
const edm::PtrVector<l1t::HGCalCluster>& clustersPtrs = c3d.constituents();
std::vector<bool> layers(kLayersEE_+kLayersFH_+kLayersBH_);
for(const auto& cluster_ptr : clustersPtrs)
{
int layer = HGC_layer(cluster_ptr->subdetId(), cluster_ptr->layer());
int layer = triggerGeometry.triggerLayer(cluster_ptr->detId());
layers[layer-1] = true;
}
int length = 0;
Expand Down

0 comments on commit b23167d

Please sign in to comment.