CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes
PFMultiDepthClusterizer Class Reference

#include <PFMultiDepthClusterizer.h>

Inheritance diagram for PFMultiDepthClusterizer:
PFClusterBuilderBase

Classes

class  ClusterLink
 

Public Member Functions

void buildClusters (const reco::PFClusterCollection &, const std::vector< bool > &, reco::PFClusterCollection &outclus)
 
B2DGPFoperator= (const B2DGPF &)=delete
 
 PFMultiDepthClusterizer (const edm::ParameterSet &conf)
 
 PFMultiDepthClusterizer (const B2DGPF &)=delete
 
void update (const edm::EventSetup &es)
 
virtual ~PFMultiDepthClusterizer ()
 
- Public Member Functions inherited from PFClusterBuilderBase
std::ostream & operator<< (std::ostream &o) const
 
PFCBBoperator= (const PFCBB &)=delete
 
 PFClusterBuilderBase (const edm::ParameterSet &conf)
 
 PFClusterBuilderBase (const PFCBB &)=delete
 
void reset ()
 
 ~PFClusterBuilderBase ()
 

Private Types

typedef PFMultiDepthClusterizer B2DGPF
 

Private Member Functions

void absorbCluster (reco::PFCluster &, const reco::PFCluster &)
 
void calculateShowerShapes (const reco::PFClusterCollection &, std::vector< double > &, std::vector< double > &)
 
void expandCluster (reco::PFCluster &, unsigned int point, std::vector< bool > &mask, const reco::PFClusterCollection &, const std::vector< ClusterLink > &links)
 
std::vector< ClusterLinklink (const reco::PFClusterCollection &, const std::vector< double > &, const std::vector< double > &)
 
std::vector< ClusterLinkprune (std::vector< ClusterLink > &, std::vector< bool > &linkedClusters)
 

Private Attributes

std::unique_ptr
< PFCPositionCalculatorBase
_allCellsPosCalc
 
double nSigmaEta_
 
double nSigmaPhi_
 

Additional Inherited Members

- Public Types inherited from PFClusterBuilderBase
typedef PFCPositionCalculatorBase PosCalc
 
- Protected Attributes inherited from PFClusterBuilderBase
const float _minFractionToKeep
 
unsigned _nClustersFound
 
unsigned _nSeeds
 
std::unique_ptr< PosCalc_positionCalc
 

Detailed Description

Definition at line 9 of file PFMultiDepthClusterizer.h.

Member Typedef Documentation

Definition at line 10 of file PFMultiDepthClusterizer.h.

Constructor & Destructor Documentation

PFMultiDepthClusterizer::PFMultiDepthClusterizer ( const edm::ParameterSet conf)

Definition at line 15 of file PFMultiDepthClusterizer.cc.

References _allCellsPosCalc, edm::ParameterSet::exists(), reco::get(), edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterSet(), nSigmaEta_, nSigmaPhi_, NULL, funct::pow(), and AlCaHLTBitMon_QueryRunRegistry::string.

15  :
17 {
18 
19  _allCellsPosCalc.reset(NULL);
20  if( conf.exists("allCellsPositionCalc") ) {
21  const edm::ParameterSet& acConf =
22  conf.getParameterSet("allCellsPositionCalc");
23  const std::string& algoac =
24  acConf.getParameter<std::string>("algoName");
25  PosCalc* accalc =
26  PFCPositionCalculatorFactory::get()->create(algoac, acConf);
27  _allCellsPosCalc.reset(accalc);
28  }
29 
30  nSigmaEta_ = pow(conf.getParameter<double>("nSigmaEta"),2);
31  nSigmaPhi_ = pow(conf.getParameter<double>("nSigmaPhi"),2);
32 
33 }
T getParameter(std::string const &) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
#define NULL
Definition: scimark2.h:8
std::unique_ptr< PFCPositionCalculatorBase > _allCellsPosCalc
ParameterSet const & getParameterSet(std::string const &) const
PFClusterBuilderBase(const edm::ParameterSet &conf)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
T get(const Candidate &c)
Definition: component.h:55
PFCPositionCalculatorBase PosCalc
virtual PFMultiDepthClusterizer::~PFMultiDepthClusterizer ( )
inlinevirtual

Definition at line 14 of file PFMultiDepthClusterizer.h.

14 {}
PFMultiDepthClusterizer::PFMultiDepthClusterizer ( const B2DGPF )
delete

Member Function Documentation

void PFMultiDepthClusterizer::absorbCluster ( reco::PFCluster main,
const reco::PFCluster added 
)
private

Definition at line 217 of file PFMultiDepthClusterizer.cc.

References reco::PFCluster::addRecHitFraction(), reco::e1, reco::e2, HLT_FULL_cff::fraction, reco::PFCluster::recHitFractions(), reco::CaloCluster::seed(), and reco::CaloCluster::setSeed().

Referenced by expandCluster().

217  {
218 
219  double e1=0.0;
220  double e2=0.0;
221 
222  //find seeds
223  for ( const auto& fraction : main.recHitFractions())
224  if (fraction.recHitRef()->detId() == main.seed()) {
225  e1=fraction.recHitRef()->energy();
226  }
227 
228  for ( const auto& fraction : added.recHitFractions()) {
230  if (fraction.recHitRef()->detId() == added.seed()) {
231  e2=fraction.recHitRef()->energy();
232  }
233  }
234  if (e2>e1)
235  main.setSeed(added.seed());
236 
237 }
void setSeed(const DetId &id)
Definition: CaloCluster.h:118
Float e1
Definition: deltaR.h:20
DetId seed() const
return DetId of seed
Definition: CaloCluster.h:202
Float e2
Definition: deltaR.h:21
void addRecHitFraction(const reco::PFRecHitFraction &frac)
add a given fraction of the rechit
Definition: PFCluster.cc:57
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions
Definition: PFCluster.h:72
void PFMultiDepthClusterizer::buildClusters ( const reco::PFClusterCollection input,
const std::vector< bool > &  seedable,
reco::PFClusterCollection outclus 
)
virtual

Implements PFClusterBuilderBase.

Definition at line 36 of file PFMultiDepthClusterizer.cc.

References _allCellsPosCalc, calculateShowerShapes(), expandCluster(), i, link(), electronStore::links, and prune().

38  {
39 
40  std::vector<double> etaRMS(input.size(),0.0);
41  std::vector<double> phiRMS(input.size(),0.0);
42 
43  //We need to sort the clusters for smaller to larger depth
44  // for (unsigned int i=0;i<input.size();++i)
45  // printf(" cluster%f %f \n",input[i].depth(),input[i].energy());
46 
47 
48 
49  //calculate cluster shapes
50  calculateShowerShapes(input,etaRMS,phiRMS);
51 
52  //link
53  std::vector<ClusterLink> links = link(input,etaRMS,phiRMS);
54  // for (const auto& link: links)
55  // printf("link %d %d %f %f\n",link.from(),link.to(),link.dR(),link.dZ());
56 
57 
58 
59  std::vector<bool> mask(input.size(),false);
60  std::vector<bool> linked(input.size(),false);
61 
62  //prune
63  std::vector<ClusterLink> prunedLinks;
64  if (links.size())
65  prunedLinks = prune(links,linked);
66 
67  //printf("Pruned links\n")
68  // for (const auto& link: prunedLinks)
69  // printf("link %d %d %f %f\n",link.from(),link.to(),link.dR(),link.dZ());
70 
71 
72 
73  //now we need to build clusters
74  for (unsigned int i=0;i<input.size();++i) {
75  //if not masked
76  if( mask[i])
77  continue;
78  //if not linked just spit it out
79  if (!linked[i]) {
80  output.push_back(input[i]);
81  // printf("Added single cluster with energy =%f \n",input[i].energy());
82  mask[i] = true;
83  continue;
84  }
85 
86 
87  //now business: if linked and not masked gather clusters
88  reco::PFCluster cluster = input[i];
89  mask[i] = true;
90  expandCluster(cluster,i, mask,input,prunedLinks);
91  _allCellsPosCalc->calculateAndSetPosition(cluster);
92  output.push_back(cluster);
93  // printf("Added linked cluster with energy =%f\n",cluster.energy());
94 
95  }
96 }
void calculateShowerShapes(const reco::PFClusterCollection &, std::vector< double > &, std::vector< double > &)
int i
Definition: DBlmapReader.cc:9
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:47
std::vector< ClusterLink > prune(std::vector< ClusterLink > &, std::vector< bool > &linkedClusters)
static std::string const input
Definition: EdmProvDump.cc:44
std::unique_ptr< PFCPositionCalculatorBase > _allCellsPosCalc
std::vector< ClusterLink > link(const reco::PFClusterCollection &, const std::vector< double > &, const std::vector< double > &)
void expandCluster(reco::PFCluster &, unsigned int point, std::vector< bool > &mask, const reco::PFClusterCollection &, const std::vector< ClusterLink > &links)
void PFMultiDepthClusterizer::calculateShowerShapes ( const reco::PFClusterCollection clusters,
std::vector< double > &  etaRMS,
std::vector< double > &  phiRMS 
)
private

Definition at line 100 of file PFMultiDepthClusterizer.cc.

References funct::abs(), SiPixelRawToDigiRegional_cfi::deltaPhi, reco::PFCluster::energy(), cropTnPTrees::frac, h, i, bookConverter::max, reco::PFCluster::positionREP(), reco::PFCluster::recHitFractions(), and cuy::rep.

Referenced by buildClusters().

100  {
101  float etaSum;
102  float phiSum;
103 
104  //shower shapes. here do not use the fractions
105 
106  for( unsigned int i=0;i<clusters.size();++i ) {
107  const reco::PFCluster& cluster = clusters[i];
108  etaSum=0.0;phiSum=0.0;
109  auto const & crep = cluster.positionREP();
110  for (const auto& frac : cluster.recHitFractions()) {
111  auto const & h = *frac.recHitRef();
112  auto const & rep = h.positionREP();
113  etaSum += (frac.fraction()*h.energy())*std::abs(rep.eta()-crep.eta());
114  phiSum += (frac.fraction()*h.energy())*std::abs(deltaPhi(rep.phi(),crep.phi()));
115  }
116  //protection for single line : assign ~ tower
117  etaRMS[i] = std::max(etaSum/cluster.energy(),0.1);
118  phiRMS[i] = std::max(phiSum/cluster.energy(),0.1);
119 
120  }
121 
122 }
int i
Definition: DBlmapReader.cc:9
string rep
Definition: cuy.py:1188
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:47
const REPPoint & positionREP() const
cluster position: rho, eta, phi
Definition: PFCluster.h:93
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double energy() const
cluster energy
Definition: PFCluster.h:82
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions
Definition: PFCluster.h:72
void PFMultiDepthClusterizer::expandCluster ( reco::PFCluster cluster,
unsigned int  point,
std::vector< bool > &  mask,
const reco::PFClusterCollection clusters,
const std::vector< ClusterLink > &  links 
)
private

Definition at line 242 of file PFMultiDepthClusterizer.cc.

References absorbCluster(), HLT_FULL_cff::clusters, link(), electronStore::links, and point.

Referenced by buildClusters().

242  {
243  for (const auto& link : links) {
244  if (link.from() == point) {
245  //found link that starts from this guy if not masked absorb
246  if (!mask[link.from()]) {
247  absorbCluster(cluster,clusters[link.from()]);
248  mask[link.from()] = true;
249  }
250 
251  if (!mask[link.to()]) {
252  absorbCluster(cluster,clusters[link.to()]);
253  mask[link.to()]=true;
254  expandCluster(cluster,link.to(),mask,clusters,links);
255  }
256  }
257  if (link.to() == point) {
258  //found link that starts from this guy if not masked absorb
259  if (!mask[link.to()]) {
260  absorbCluster(cluster,clusters[link.to()]);
261  mask[link.to()] = true;
262  }
263 
264  if (!mask[link.from()]) {
265  absorbCluster(cluster,clusters[link.from()]);
266  mask[link.from()]=true;
267  expandCluster(cluster,link.from(),mask,clusters,links);
268  }
269  }
270 
271 
272 
273  }
274 
275 }
void absorbCluster(reco::PFCluster &, const reco::PFCluster &)
std::vector< ClusterLink > link(const reco::PFClusterCollection &, const std::vector< double > &, const std::vector< double > &)
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
void expandCluster(reco::PFCluster &, unsigned int point, std::vector< bool > &mask, const reco::PFClusterCollection &, const std::vector< ClusterLink > &links)
std::vector< PFMultiDepthClusterizer::ClusterLink > PFMultiDepthClusterizer::link ( const reco::PFClusterCollection clusters,
const std::vector< double > &  etaRMS,
const std::vector< double > &  phiRMS 
)
private

Definition at line 126 of file PFMultiDepthClusterizer.cc.

References SiPixelRawToDigiRegional_cfi::deltaPhi, reco::PFCluster::depth(), reco::PFCluster::energy(), i, j, electronStore::links, nSigmaEta_, nSigmaPhi_, and reco::PFCluster::positionREP().

Referenced by buildClusters(), and expandCluster().

126  {
127 
128  std::vector<ClusterLink> links;
129  //loop on all pairs
130  for (unsigned int i=0;i<clusters.size();++i)
131  for (unsigned int j=0;j<clusters.size();++j) {
132  if (i==j )
133  continue;
134 
135  const reco::PFCluster& cluster1 = clusters[i];
136  const reco::PFCluster& cluster2 = clusters[j];
137 
138  float dz = (cluster2.depth() - cluster1.depth());
139 
140  //Do not link at the same layer and only link inside out!
141  if (dz<0.0 || fabs(dz)<0.2)
142  continue;
143  auto const & crep1 = cluster1.positionREP();
144  auto const & crep2 = cluster2.positionREP();
145 
146  float deta =(crep1.eta()-crep2.eta())*(crep1.eta()-crep2.eta())/(etaRMS[i]*etaRMS[i]+etaRMS[j]*etaRMS[j]);
147  float dphi = deltaPhi(crep1.phi(),crep2.phi())*deltaPhi(crep1.phi(),crep2.phi())/(phiRMS[i]*phiRMS[i]+phiRMS[j]*phiRMS[j]);
148 
149  // printf("Testing Link %d -> %d (%f %f %f %f ) \n",i,j,deta,dphi,cluster1.position().Eta()-cluster2.position().Eta(),deltaPhi(cluster1.position().Phi(),cluster2.position().Phi()));
150 
151  if (deta<nSigmaEta_ && dphi<nSigmaPhi_ )
152  links.push_back(ClusterLink(i,j,deta+dphi,fabs(dz),cluster1.energy()+cluster2.energy()));
153  }
154 
155  return links;
156 }
int i
Definition: DBlmapReader.cc:9
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:47
const REPPoint & positionREP() const
cluster position: rho, eta, phi
Definition: PFCluster.h:93
int j
Definition: DBlmapReader.cc:9
double energy() const
cluster energy
Definition: PFCluster.h:82
double depth() const
cluster depth
Definition: PFCluster.h:87
B2DGPF& PFMultiDepthClusterizer::operator= ( const B2DGPF )
delete
std::vector< PFMultiDepthClusterizer::ClusterLink > PFMultiDepthClusterizer::prune ( std::vector< ClusterLink > &  links,
std::vector< bool > &  linkedClusters 
)
private

Definition at line 159 of file PFMultiDepthClusterizer.cc.

References PFMultiDepthClusterizer::ClusterLink::dR(), PFMultiDepthClusterizer::ClusterLink::dZ(), PFMultiDepthClusterizer::ClusterLink::energy(), i, j, and PFMultiDepthClusterizer::ClusterLink::to().

Referenced by buildClusters(), and dirstructure.Directory::prune().

159  {
160  std::vector<ClusterLink> goodLinks ;
161  std::vector<bool> mask(links.size(),false);
162 
163  for (unsigned int i=0;i<links.size()-1;++i) {
164  if (mask[i])
165  continue;
166  for (unsigned int j=i+1;j<links.size();++j) {
167 
168  if (mask[j])
169  continue;
170 
171  const ClusterLink& link1 = links[i];
172  const ClusterLink& link2 = links[j];
173 
174  if (link1.to() == link2.to()) {//found two links going to the same spot,kill one
175  //first prefer nearby layers
176  if (link1.dZ() < link2.dZ()) {
177  mask[j]=true;
178  }
179  else if (link1.dZ() > link2.dZ()) {
180  mask[i] = true;
181  }
182  else if (fabs(link1.dZ()-link2.dZ())<0.2) { //if same layer-pick based on transverse compatibility
183  if (link1.dR()<link2.dR()) {
184  mask[j]=true;
185  }
186  else if (link1.dR()>link2.dR()) {
187  mask[i] = true;
188  }
189  else {
190  //same distance as well -> can happen !!!!! Pick the highest SUME
191  if (link1.energy()<link2.energy())
192  mask[i] = true;
193  else
194  mask[j] = true;
195 
196  }
197  }
198  }
199  }
200  }
201 
202  for (unsigned int i=0;i<links.size();++i) {
203  if (mask[i])
204  continue;
205  goodLinks.push_back(links[i]);
206  linkedClusters[links[i].from()]=true;
207  linkedClusters[links[i].to()]=true;
208  }
209 
210 
211  return goodLinks;
212 }
int i
Definition: DBlmapReader.cc:9
int j
Definition: DBlmapReader.cc:9
void PFMultiDepthClusterizer::update ( const edm::EventSetup es)
inlinevirtual

Reimplemented from PFClusterBuilderBase.

Definition at line 18 of file PFMultiDepthClusterizer.h.

References _allCellsPosCalc.

Referenced by progressbar.ProgressBar::__next__(), MatrixUtil.Matrix::__setitem__(), MatrixUtil.Steps::__setitem__(), Vispa.Gui.VispaWidget.VispaWidget::autosize(), Vispa.Views.LineDecayView.LineDecayContainer::createObject(), Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), progressbar.ProgressBar::finish(), Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), MatrixUtil.Steps::overwrite(), Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), Vispa.Gui.FindDialog.FindDialog::reset(), Vispa.Gui.PortConnection.PointToPointConnection::select(), Vispa.Gui.VispaWidget.VispaWidget::select(), Vispa.Views.LineDecayView.LineDecayContainer::select(), Vispa.Gui.VispaWidget.VispaWidget::setText(), Vispa.Gui.VispaWidget.VispaWidget::setTitle(), Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

18  {
19  _allCellsPosCalc->update(es);
20  }
std::unique_ptr< PFCPositionCalculatorBase > _allCellsPosCalc

Member Data Documentation

std::unique_ptr<PFCPositionCalculatorBase> PFMultiDepthClusterizer::_allCellsPosCalc
private

Definition at line 27 of file PFMultiDepthClusterizer.h.

Referenced by buildClusters(), PFMultiDepthClusterizer(), and update().

double PFMultiDepthClusterizer::nSigmaEta_
private

Definition at line 28 of file PFMultiDepthClusterizer.h.

Referenced by link(), and PFMultiDepthClusterizer().

double PFMultiDepthClusterizer::nSigmaPhi_
private

Definition at line 29 of file PFMultiDepthClusterizer.h.

Referenced by link(), and PFMultiDepthClusterizer().