CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
HGCalMulticlusteringImpl Class Reference

#include <HGCalMulticlusteringImpl.h>

Public Member Functions

void clusterizeDBSCAN (const std::vector< edm::Ptr< l1t::HGCalCluster >> &clustersPtr, l1t::HGCalMulticlusterBxCollection &multiclusters, const HGCalTriggerGeometryBase &triggerGeometry)
 
void clusterizeDR (const std::vector< edm::Ptr< l1t::HGCalCluster >> &clustersPtr, l1t::HGCalMulticlusterBxCollection &multiclusters, const HGCalTriggerGeometryBase &triggerGeometry)
 
void eventSetup (const edm::EventSetup &es)
 
 HGCalMulticlusteringImpl (const edm::ParameterSet &conf)
 
bool isPertinent (const l1t::HGCalCluster &clu, const l1t::HGCalMulticluster &mclu, double dR) const
 

Private Member Functions

void finalizeClusters (std::vector< l1t::HGCalMulticluster > &, l1t::HGCalMulticlusterBxCollection &, const HGCalTriggerGeometryBase &)
 
void findNeighbor (const std::vector< std::pair< unsigned int, double >> &rankedList, unsigned int searchInd, const std::vector< edm::Ptr< l1t::HGCalCluster >> &clustersPtr, std::vector< unsigned int > &neigbors)
 

Private Attributes

double distDbscan_ = 0.005
 
double dr_
 
std::unique_ptr< HGCalTriggerClusterIdentificationBaseid_
 
unsigned minNDbscan_ = 3
 
std::string multiclusterAlgoType_
 
double ptC3dThreshold_
 
HGCalShowerShape shape_
 
HGCalTriggerTools triggerTools_
 

Detailed Description

Definition at line 15 of file HGCalMulticlusteringImpl.h.

Constructor & Destructor Documentation

HGCalMulticlusteringImpl::HGCalMulticlusteringImpl ( const edm::ParameterSet conf)

Definition at line 6 of file HGCalMulticlusteringImpl.cc.

References beamerCreator::create(), distDbscan_, dr_, reco::get(), edm::ParameterSet::getParameter(), id_, minNDbscan_, multiclusterAlgoType_, and ptC3dThreshold_.

6  :
7  dr_(conf.getParameter<double>("dR_multicluster")),
8  ptC3dThreshold_(conf.getParameter<double>("minPt_multicluster")),
9  multiclusterAlgoType_(conf.getParameter<string>("type_multicluster")),
10  distDbscan_(conf.getParameter<double>("dist_dbscan_multicluster")),
11  minNDbscan_(conf.getParameter<unsigned>("minN_dbscan_multicluster"))
12 {
13  edm::LogInfo("HGCalMulticlusterParameters") << "Multicluster dR for Near Neighbour search: " << dr_;
14  edm::LogInfo("HGCalMulticlusterParameters") << "Multicluster minimum transverse-momentum: " << ptC3dThreshold_;
15  edm::LogInfo("HGCalMulticlusterParameters") << "Multicluster DBSCAN Clustering distance: " << distDbscan_;
16  edm::LogInfo("HGCalMulticlusterParameters") << "Multicluster clustering min number of subclusters: " << minNDbscan_;
17  edm::LogInfo("HGCalMulticlusterParameters") << "Multicluster type of multiclustering algortihm: " << multiclusterAlgoType_;
18  id_.reset( HGCalTriggerClusterIdentificationFactory::get()->create("HGCalTriggerClusterIdentificationBDT") );
19  id_->initialize(conf.getParameter<edm::ParameterSet>("EGIdentification"));
20 }
T getParameter(std::string const &) const
def create(alignables, pedeDump, additionalData, outputFile, config)
std::unique_ptr< HGCalTriggerClusterIdentificationBase > id_
T get(const Candidate &c)
Definition: component.h:55

Member Function Documentation

void HGCalMulticlusteringImpl::clusterizeDBSCAN ( const std::vector< edm::Ptr< l1t::HGCalCluster >> &  clustersPtr,
l1t::HGCalMulticlusterBxCollection multiclusters,
const HGCalTriggerGeometryBase triggerGeometry 
)

Definition at line 106 of file HGCalMulticlusteringImpl.cc.

References finalizeClusters(), findNeighbor(), minNDbscan_, eostools::move(), class-composition::visited, and ecaldqm::zside().

Referenced by eventSetup(), and HGCalBackendLayer2Processor3DClustering::run().

109 {
110 
111  std::vector<l1t::HGCalMulticluster> multiclustersTmp;
112  l1t::HGCalMulticluster mcluTmp;
113  std::vector<bool> visited(clustersPtrs.size(),false);
114  std::vector<bool> merged (clustersPtrs.size(),false);
115  std::vector<std::pair<unsigned int,double>> rankedList;
116  rankedList.reserve(clustersPtrs.size());
117  std::vector<std::vector<unsigned int>> neighborList;
118  neighborList.reserve(clustersPtrs.size());
119 
120  int iclu = 0, imclu = 0, neighNo;
121  double dist = 0.;
122 
123  for(std::vector<edm::Ptr<l1t::HGCalCluster>>::const_iterator clu = clustersPtrs.begin(); clu != clustersPtrs.end(); ++clu, ++iclu){
124  dist = (*clu)->centreProj().mag()*HGCalDetId((*clu)->detId()).zside();
125  rankedList.push_back(std::make_pair(iclu,dist));
126  }
127  iclu = 0;
128  std::sort(rankedList.begin(), rankedList.end(), [](auto &left, auto &right) {
129  return left.second < right.second;
130  });
131 
132  for(const auto& cluRanked: rankedList){
133  std::vector<unsigned int> neighbors;
134 
135  if(!visited.at(iclu)){
136  visited.at(iclu) = true;
137  findNeighbor(rankedList, iclu, clustersPtrs, neighbors);
138  neighborList.push_back(std::move(neighbors));
139 
140  if(neighborList.at(iclu).size() >= minNDbscan_) {
141  multiclustersTmp.emplace_back( clustersPtrs[cluRanked.first] );
142  merged.at(iclu) = true;
143  /* dynamic range loop: range-based loop syntax cannot be employed */
144  for(unsigned int neighInd = 0; neighInd < neighborList.at(iclu).size(); neighInd++){
145  neighNo = neighborList.at(iclu).at(neighInd);
146  /* This condition also ensures merging of clusters visited by other clusters but not merged. */
147  if(!merged.at(neighNo) ){
148  merged.at(neighNo) = true;
149  multiclustersTmp.at(imclu).addConstituent( clustersPtrs[rankedList.at(neighNo).first] );
150 
151  if(!visited.at(neighNo)){
152  visited.at(neighNo) = true;
153  std::vector<unsigned int> secNeighbors;
154  findNeighbor(rankedList, neighNo,clustersPtrs, secNeighbors);
155 
156  if(secNeighbors.size() >= minNDbscan_){
157  neighborList.at(iclu).insert(neighborList.at(iclu).end(), secNeighbors.begin(), secNeighbors.end());
158  }
159  }
160  }
161  }
162  imclu++;
163  }
164  }
165  else neighborList.push_back(std::move(neighbors));
166  iclu++;
167  }
168  /* making the collection of multiclusters */
169  finalizeClusters(multiclustersTmp, multiclusters, triggerGeometry);
170 }
int zside(DetId const &)
void findNeighbor(const std::vector< std::pair< unsigned int, double >> &rankedList, unsigned int searchInd, const std::vector< edm::Ptr< l1t::HGCalCluster >> &clustersPtr, std::vector< unsigned int > &neigbors)
void finalizeClusters(std::vector< l1t::HGCalMulticluster > &, l1t::HGCalMulticlusterBxCollection &, const HGCalTriggerGeometryBase &)
def move(src, dest)
Definition: eostools.py:511
void HGCalMulticlusteringImpl::clusterizeDR ( const std::vector< edm::Ptr< l1t::HGCalCluster >> &  clustersPtr,
l1t::HGCalMulticlusterBxCollection multiclusters,
const HGCalTriggerGeometryBase triggerGeometry 
)

Definition at line 73 of file HGCalMulticlusteringImpl.cc.

References edmIntegrityCheck::d, dr_, finalizeClusters(), createfilelist::int, isPertinent(), and mag().

Referenced by eventSetup(), and HGCalBackendLayer2Processor3DClustering::run().

76 {
77 
78  std::vector<l1t::HGCalMulticluster> multiclustersTmp;
79 
80  int iclu = 0;
81  for(std::vector<edm::Ptr<l1t::HGCalCluster>>::const_iterator clu = clustersPtrs.begin(); clu != clustersPtrs.end(); ++clu, ++iclu){
82 
83  double minDist = dr_;
84  int targetMulticlu = -1;
85 
86  for(unsigned imclu=0; imclu<multiclustersTmp.size(); imclu++){
87 
88  if(!this->isPertinent(**clu, multiclustersTmp.at(imclu), dr_)) continue;
89 
90  double d = ( multiclustersTmp.at(imclu).centreProj() - (*clu)->centreProj() ).mag() ;
91  if(d<minDist){
92  minDist = d;
93  targetMulticlu = int(imclu);
94  }
95  }
96 
97  if(targetMulticlu<0) multiclustersTmp.emplace_back( *clu );
98  else multiclustersTmp.at( targetMulticlu ).addConstituent( *clu );
99 
100  }
101 
102  /* making the collection of multiclusters */
103  finalizeClusters(multiclustersTmp, multiclusters, triggerGeometry);
104 
105 }
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
bool isPertinent(const l1t::HGCalCluster &clu, const l1t::HGCalMulticluster &mclu, double dR) const
void finalizeClusters(std::vector< l1t::HGCalMulticluster > &, l1t::HGCalMulticlusterBxCollection &, const HGCalTriggerGeometryBase &)
void HGCalMulticlusteringImpl::eventSetup ( const edm::EventSetup es)
inline
void HGCalMulticlusteringImpl::finalizeClusters ( std::vector< l1t::HGCalMulticluster > &  multiclusters_in,
l1t::HGCalMulticlusterBxCollection multiclusters_out,
const HGCalTriggerGeometryBase triggerGeometry 
)
private

Definition at line 175 of file HGCalMulticlusteringImpl.cc.

References fastPrimaryVertexProducer_cfi::clusters, HGCalShowerShape::coreShowerLength(), HGCalShowerShape::eMax(), HGCalShowerShape::firstLayer(), id_, HGCalShowerShape::maxLayer(), ptC3dThreshold_, BXVector< T >::push_back(), shape_, HGCalShowerShape::showerLength(), HGCalShowerShape::sigmaEtaEtaMax(), HGCalShowerShape::sigmaEtaEtaTot(), HGCalShowerShape::sigmaPhiPhiMax(), HGCalShowerShape::sigmaPhiPhiTot(), HGCalShowerShape::sigmaRRMax(), HGCalShowerShape::sigmaRRMean(), HGCalShowerShape::sigmaRRTot(), HGCalShowerShape::sigmaZZ(), and TtFullHadEvtBuilder_cfi::sumPt.

Referenced by clusterizeDBSCAN(), clusterizeDR(), and eventSetup().

177  {
178  for(auto& multicluster : multiclusters_in) {
179  // compute the eta, phi from its barycenter
180  // + pT as scalar sum of pT of constituents
181  double sumPt=0.;
182  const std::unordered_map<uint32_t, edm::Ptr<l1t::HGCalCluster>>& clusters = multicluster.constituents();
183  for(const auto& id_cluster : clusters) sumPt += id_cluster.second->pt();
184 
185  math::PtEtaPhiMLorentzVector multiclusterP4( sumPt,
186  multicluster.centre().eta(),
187  multicluster.centre().phi(),
188  0. );
189  multicluster.setP4( multiclusterP4 );
190 
191  if( multicluster.pt() > ptC3dThreshold_ ){
192  //compute shower shapes
193  multicluster.showerLength(shape_.showerLength(multicluster));
194  multicluster.coreShowerLength(shape_.coreShowerLength(multicluster, triggerGeometry));
195  multicluster.firstLayer(shape_.firstLayer(multicluster));
196  multicluster.maxLayer(shape_.maxLayer(multicluster));
197  multicluster.sigmaEtaEtaTot(shape_.sigmaEtaEtaTot(multicluster));
198  multicluster.sigmaEtaEtaMax(shape_.sigmaEtaEtaMax(multicluster));
199  multicluster.sigmaPhiPhiTot(shape_.sigmaPhiPhiTot(multicluster));
200  multicluster.sigmaPhiPhiMax(shape_.sigmaPhiPhiMax(multicluster));
201  multicluster.sigmaZZ(shape_.sigmaZZ(multicluster));
202  multicluster.sigmaRRTot(shape_.sigmaRRTot(multicluster));
203  multicluster.sigmaRRMax(shape_.sigmaRRMax(multicluster));
204  multicluster.sigmaRRMean(shape_.sigmaRRMean(multicluster));
205  multicluster.eMax(shape_.eMax(multicluster));
206  // fill quality flag
207  multicluster.setHwQual(id_->decision(multicluster));
208 
209  multiclusters_out.push_back( 0, multicluster);
210  }
211  }
212 }
float sigmaRRMax(const l1t::HGCalMulticluster &c3d) const
int coreShowerLength(const l1t::HGCalMulticluster &c3d, const HGCalTriggerGeometryBase &triggerGeometry) const
float sigmaRRTot(const l1t::HGCalMulticluster &c3d) const
float sigmaPhiPhiTot(const l1t::HGCalMulticluster &c3d) const
int firstLayer(const l1t::HGCalMulticluster &c3d) const
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
float sigmaRRMean(const l1t::HGCalMulticluster &c3d, float radius=5.) const
float sigmaEtaEtaMax(const l1t::HGCalMulticluster &c3d) const
std::unique_ptr< HGCalTriggerClusterIdentificationBase > id_
int showerLength(const l1t::HGCalMulticluster &c3d) const
float sigmaZZ(const l1t::HGCalMulticluster &c3d) const
float sigmaPhiPhiMax(const l1t::HGCalMulticluster &c3d) const
int maxLayer(const l1t::HGCalMulticluster &c3d) const
float eMax(const l1t::HGCalMulticluster &c3d) const
float sigmaEtaEtaTot(const l1t::HGCalMulticluster &c3d) const
void push_back(int bx, T object)
void HGCalMulticlusteringImpl::findNeighbor ( const std::vector< std::pair< unsigned int, double >> &  rankedList,
unsigned int  searchInd,
const std::vector< edm::Ptr< l1t::HGCalCluster >> &  clustersPtr,
std::vector< unsigned int > &  neigbors 
)
private

Definition at line 41 of file HGCalMulticlusteringImpl.cc.

References distDbscan_, Exception, and mag().

Referenced by clusterizeDBSCAN(), and eventSetup().

45  {
46 
47  if(clustersPtrs.size() <= searchInd || clustersPtrs.size() < rankedList.size()){
48  throw cms::Exception("IndexOutOfBound: clustersPtrs in 'findNeighbor'");
49  }
50 
51  for(unsigned int ind = searchInd+1; ind < rankedList.size() && fabs(rankedList.at(ind).second - rankedList.at(searchInd).second) < distDbscan_ ; ind++){
52 
53  if(clustersPtrs.size() <= rankedList.at(ind).first){
54  throw cms::Exception("IndexOutOfBound: clustersPtrs in 'findNeighbor'");
55 
56  } else if(((*(clustersPtrs[rankedList.at(ind).first])).centreProj() - (*(clustersPtrs[rankedList.at(searchInd).first])).centreProj()).mag() < distDbscan_){
57  neighbors.push_back(ind);
58  }
59  }
60 
61  for(unsigned int ind = 0; ind < searchInd && fabs(rankedList.at(searchInd).second - rankedList.at(ind).second) < distDbscan_ ; ind++){
62 
63  if(clustersPtrs.size() <= rankedList.at(ind).first){
64  throw cms::Exception("IndexOutOfBound: clustersPtrs in 'findNeighbor'");
65 
66  } else if(((*(clustersPtrs[rankedList.at(ind).first])).centreProj() - (*(clustersPtrs[rankedList.at(searchInd).first])).centreProj()).mag() < distDbscan_){
67  neighbors.push_back(ind);
68  }
69  }
70 }
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
bool HGCalMulticlusteringImpl::isPertinent ( const l1t::HGCalCluster clu,
const l1t::HGCalMulticluster mclu,
double  dR 
) const

Definition at line 23 of file HGCalMulticlusteringImpl.cc.

References l1t::HGCalClusterT< C >::centreProj(), l1t::HGCalClusterT< C >::detId(), PFRecoTauDiscriminationAgainstElectronDeadECAL_cfi::dR, and mag().

Referenced by clusterizeDR(), and eventSetup().

26 {
27  HGCalDetId cluDetId( clu.detId() );
28  HGCalDetId firstClusterDetId( mclu.detId() );
29 
30  if( cluDetId.zside() != firstClusterDetId.zside() ){
31  return false;
32  }
33  if( ( mclu.centreProj() - clu.centreProj() ).mag() < dR ){
34  return true;
35  }
36  return false;
37 
38 }
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
const GlobalPoint & centreProj() const
uint32_t detId() const

Member Data Documentation

double HGCalMulticlusteringImpl::distDbscan_ = 0.005
private

Definition at line 54 of file HGCalMulticlusteringImpl.h.

Referenced by findNeighbor(), and HGCalMulticlusteringImpl().

double HGCalMulticlusteringImpl::dr_
private

Definition at line 51 of file HGCalMulticlusteringImpl.h.

Referenced by clusterizeDR(), and HGCalMulticlusteringImpl().

std::unique_ptr<HGCalTriggerClusterIdentificationBase> HGCalMulticlusteringImpl::id_
private

Definition at line 59 of file HGCalMulticlusteringImpl.h.

Referenced by finalizeClusters(), and HGCalMulticlusteringImpl().

unsigned HGCalMulticlusteringImpl::minNDbscan_ = 3
private

Definition at line 55 of file HGCalMulticlusteringImpl.h.

Referenced by clusterizeDBSCAN(), and HGCalMulticlusteringImpl().

std::string HGCalMulticlusteringImpl::multiclusterAlgoType_
private

Definition at line 53 of file HGCalMulticlusteringImpl.h.

Referenced by HGCalMulticlusteringImpl().

double HGCalMulticlusteringImpl::ptC3dThreshold_
private

Definition at line 52 of file HGCalMulticlusteringImpl.h.

Referenced by finalizeClusters(), and HGCalMulticlusteringImpl().

HGCalShowerShape HGCalMulticlusteringImpl::shape_
private

Definition at line 57 of file HGCalMulticlusteringImpl.h.

Referenced by eventSetup(), and finalizeClusters().

HGCalTriggerTools HGCalMulticlusteringImpl::triggerTools_
private

Definition at line 58 of file HGCalMulticlusteringImpl.h.

Referenced by eventSetup().