CMS 3D CMS Logo

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

#include <PFlow2DClusterizerWithTime.h>

Inheritance diagram for PFlow2DClusterizerWithTime:
PFClusterBuilderBase

Public Member Functions

void buildClusters (const reco::PFClusterCollection &, const std::vector< bool > &, reco::PFClusterCollection &outclus) override
 
B2DGPFoperator= (const B2DGPF &)=delete
 
 PFlow2DClusterizerWithTime (const edm::ParameterSet &conf)
 
 PFlow2DClusterizerWithTime (const B2DGPF &)=delete
 
void update (const edm::EventSetup &es) override
 
 ~PFlow2DClusterizerWithTime () override=default
 
- 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 ()
 
virtual ~PFClusterBuilderBase ()=default
 

Private Types

typedef PFlow2DClusterizerWithTime B2DGPF
 

Private Member Functions

void clusterTimeResolution (reco::PFCluster &cluster, double &res) const
 
void clusterTimeResolutionFromSeed (reco::PFCluster &cluster, double &res) const
 
double dist2Time (const reco::PFCluster &, const reco::PFRecHitRef &, int cell_layer, double prev_timeres2) const
 
void growPFClusters (const reco::PFCluster &, const std::vector< bool > &, const unsigned toleranceScaling, const unsigned iter, double dist, reco::PFClusterCollection &) const
 
bool passChi2Prob (size_t iCluster, double dist2, std::vector< double > &clus_chi2, std::vector< size_t > &clus_chi2_nhits) const
 
void prunePFClusters (reco::PFClusterCollection &) const
 
void seedPFClustersFromTopo (const reco::PFCluster &, const std::vector< bool > &, reco::PFClusterCollection &) const
 

Private Attributes

std::unique_ptr< PFCPositionCalculatorBase_allCellsPosCalc
 
const bool _clusterTimeResFromSeed
 
std::unique_ptr< PFCPositionCalculatorBase_convergencePosCalc
 
const bool _excludeOtherSeeds
 
const std::unordered_map< std::string, int > _layerMap
 
const unsigned _maxIterations
 
const double _maxNSigmaTime
 
const double _minChi2Prob
 
const double _minFracTot
 
std::unordered_map< int, double > _recHitEnergyNorms
 
const double _showerSigma2
 
const double _stoppingTolerance
 
std::unique_ptr< CaloRecHitResolutionProvider_timeResolutionCalcBarrel
 
std::unique_ptr< CaloRecHitResolutionProvider_timeResolutionCalcEndcap
 
const double _timeSigma_eb
 
const double _timeSigma_ee
 

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 11 of file PFlow2DClusterizerWithTime.h.

Member Typedef Documentation

Definition at line 12 of file PFlow2DClusterizerWithTime.h.

Constructor & Destructor Documentation

PFlow2DClusterizerWithTime::PFlow2DClusterizerWithTime ( const edm::ParameterSet conf)

Definition at line 27 of file PFlow2DClusterizerWithTime.cc.

References _allCellsPosCalc, _convergencePosCalc, _layerMap, _recHitEnergyNorms, _timeResolutionCalcBarrel, _timeResolutionCalcEndcap, buildClusters(), PFLayer::ECAL_BARREL, PFLayer::ECAL_ENDCAP, mps_splice::entry, Exception, reco::get(), edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterSet(), PFLayer::HCAL_BARREL1, PFLayer::HCAL_BARREL2, PFLayer::HCAL_ENDCAP, PFLayer::HF_EM, PFLayer::HF_HAD, createfilelist::int, PFLayer::NONE, PFLayer::PS1, PFLayer::PS2, muonDTDigis_cfi::pset, AlCaHLTBitMon_QueryRunRegistry::string, and particleFlowZeroSuppressionECAL_cff::thresholds.

27  :
29  _maxIterations(conf.getParameter<unsigned>("maxIterations")),
30  _stoppingTolerance(conf.getParameter<double>("stoppingTolerance")),
31  _showerSigma2(std::pow(conf.getParameter<double>("showerSigma"),2.0)),
32  _timeSigma_eb(std::pow(conf.getParameter<double>("timeSigmaEB"),2.0)),
33  _timeSigma_ee(std::pow(conf.getParameter<double>("timeSigmaEE"),2.0)),
34  _excludeOtherSeeds(conf.getParameter<bool>("excludeOtherSeeds")),
35  _minFracTot(conf.getParameter<double>("minFracTot")),
36  _maxNSigmaTime(std::pow(conf.getParameter<double>("maxNSigmaTime"),2.0)),
37  _minChi2Prob(conf.getParameter<double>("minChi2Prob")),
38  _clusterTimeResFromSeed(conf.getParameter<bool>("clusterTimeResFromSeed")),
39 
40  _layerMap({ {"PS2",(int)PFLayer::PS2},
41  {"PS1",(int)PFLayer::PS1},
42  {"ECAL_ENDCAP",(int)PFLayer::ECAL_ENDCAP},
43  {"ECAL_BARREL",(int)PFLayer::ECAL_BARREL},
44  {"NONE",(int)PFLayer::NONE},
45  {"HCAL_BARREL1",(int)PFLayer::HCAL_BARREL1},
46  {"HCAL_BARREL2_RING0",(int)PFLayer::HCAL_BARREL2},
47  {"HCAL_BARREL2_RING1",100*(int)PFLayer::HCAL_BARREL2},
48  {"HCAL_ENDCAP",(int)PFLayer::HCAL_ENDCAP},
49  {"HF_EM",(int)PFLayer::HF_EM},
50  {"HF_HAD",(int)PFLayer::HF_HAD} }) {
51 
52 
53  const std::vector<edm::ParameterSet>& thresholds =
54  conf.getParameterSetVector("recHitEnergyNorms");
55  for( const auto& pset : thresholds ) {
56  const std::string& det = pset.getParameter<std::string>("detector");
57  const double& rhE_norm = pset.getParameter<double>("recHitEnergyNorm");
58  auto entry = _layerMap.find(det);
59  if( entry == _layerMap.end() ) {
60  throw cms::Exception("InvalidDetectorLayer")
61  << "Detector layer : " << det << " is not in the list of recognized"
62  << " detector layers!";
63  }
64  _recHitEnergyNorms.emplace(_layerMap.find(det)->second,rhE_norm);
65  }
66 
67  _allCellsPosCalc.reset(nullptr);
68  if( conf.exists("allCellsPositionCalc") ) {
69  const edm::ParameterSet& acConf =
70  conf.getParameterSet("allCellsPositionCalc");
71  const std::string& algoac =
72  acConf.getParameter<std::string>("algoName");
73  PosCalc* accalc =
74  PFCPositionCalculatorFactory::get()->create(algoac, acConf);
75  _allCellsPosCalc.reset(accalc);
76  }
77  // if necessary a third pos calc for convergence testing
78  _convergencePosCalc.reset(nullptr);
79  if( conf.exists("positionCalcForConvergence") ) {
80  const edm::ParameterSet& convConf =
81  conf.getParameterSet("positionCalcForConvergence");
82  const std::string& algoconv =
83  convConf.getParameter<std::string>("algoName");
84  PosCalc* convcalc =
85  PFCPositionCalculatorFactory::get()->create(algoconv, convConf);
86  _convergencePosCalc.reset(convcalc);
87  }
88  _timeResolutionCalcBarrel.reset(nullptr);
89  if( conf.exists("timeResolutionCalcBarrel") ) {
90  const edm::ParameterSet& timeResConf =
91  conf.getParameterSet("timeResolutionCalcBarrel");
93  timeResConf));
94  }
95  _timeResolutionCalcEndcap.reset(nullptr);
96  if( conf.exists("timeResolutionCalcEndcap") ) {
97  const edm::ParameterSet& timeResConf =
98  conf.getParameterSet("timeResolutionCalcEndcap");
100  timeResConf));
101  }
102 }
T getParameter(std::string const &) const
VParameterSet const & getParameterSetVector(std::string const &name) const
std::unique_ptr< PFCPositionCalculatorBase > _allCellsPosCalc
bool exists(std::string const &parameterName) const
checks if a parameter exists
std::unique_ptr< CaloRecHitResolutionProvider > _timeResolutionCalcBarrel
std::unique_ptr< CaloRecHitResolutionProvider > _timeResolutionCalcEndcap
ParameterSet const & getParameterSet(std::string const &) const
std::unordered_map< int, double > _recHitEnergyNorms
PFClusterBuilderBase(const edm::ParameterSet &conf)
std::unique_ptr< PFCPositionCalculatorBase > _convergencePosCalc
const std::unordered_map< std::string, int > _layerMap
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
PFlow2DClusterizerWithTime::~PFlow2DClusterizerWithTime ( )
overridedefault
PFlow2DClusterizerWithTime::PFlow2DClusterizerWithTime ( const B2DGPF )
delete

Member Function Documentation

void PFlow2DClusterizerWithTime::buildClusters ( const reco::PFClusterCollection input,
const std::vector< bool > &  seedable,
reco::PFClusterCollection outclus 
)
overridevirtual

Implements PFClusterBuilderBase.

Definition at line 105 of file PFlow2DClusterizerWithTime.cc.

References _allCellsPosCalc, _convergencePosCalc, PFClusterBuilderBase::_positionCalc, growPFClusters(), SiStripPI::max, eostools::move(), funct::pow(), prunePFClusters(), and seedPFClustersFromTopo().

Referenced by PFlow2DClusterizerWithTime(), and update().

107  {
108  reco::PFClusterCollection clustersInTopo;
109  for( const auto& topocluster : input ) {
110  clustersInTopo.clear();
111  seedPFClustersFromTopo(topocluster,seedable,clustersInTopo);
112  const unsigned tolScal =
113  std::pow(std::max(1.0,clustersInTopo.size()-1.0),2.0);
114  growPFClusters(topocluster,seedable,tolScal,0,tolScal,clustersInTopo);
115  // step added by Josh Bendavid, removes low-fraction clusters
116  // did not impact position resolution with fraction cut of 1e-7
117  // decreases the size of each pf cluster considerably
118  prunePFClusters(clustersInTopo);
119  // recalculate the positions of the pruned clusters
120  if( _convergencePosCalc ) {
121  // if defined, use the special position calculation for convergence tests
122  _convergencePosCalc->calculateAndSetPositions(clustersInTopo);
123  } else {
124  if( clustersInTopo.size() == 1 && _allCellsPosCalc ) {
125  _allCellsPosCalc->calculateAndSetPosition(clustersInTopo.back());
126  } else {
127  _positionCalc->calculateAndSetPositions(clustersInTopo);
128  }
129  }
130  for( auto& clusterout : clustersInTopo ) {
131  output.insert(output.end(),std::move(clusterout));
132  }
133  }
134 }
void prunePFClusters(reco::PFClusterCollection &) const
std::unique_ptr< PFCPositionCalculatorBase > _allCellsPosCalc
std::unique_ptr< PosCalc > _positionCalc
void growPFClusters(const reco::PFCluster &, const std::vector< bool > &, const unsigned toleranceScaling, const unsigned iter, double dist, reco::PFClusterCollection &) const
static std::string const input
Definition: EdmProvDump.cc:44
void seedPFClustersFromTopo(const reco::PFCluster &, const std::vector< bool > &, reco::PFClusterCollection &) const
std::vector< PFCluster > PFClusterCollection
collection of PFCluster objects
Definition: PFClusterFwd.h:9
std::unique_ptr< PFCPositionCalculatorBase > _convergencePosCalc
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
def move(src, dest)
Definition: eostools.py:510
void PFlow2DClusterizerWithTime::clusterTimeResolution ( reco::PFCluster cluster,
double &  res 
) const
private

Definition at line 323 of file PFlow2DClusterizerWithTime.cc.

References _timeResolutionCalcBarrel, _timeResolutionCalcEndcap, PFLayer::ECAL_BARREL, reco::PFRecHit::energy(), PFLayer::HCAL_BARREL1, PFLayer::HCAL_BARREL2, gedGsfElectrons_cfi::isBarrel, reco::PFRecHit::layer(), reco::PFCluster::recHitFractions(), reco::PFCluster::setTime(), reco::PFCluster::setTimeError(), mathSSE::sqrt(), and reco::PFRecHit::time().

Referenced by growPFClusters().

325 {
326  double sumTimeSigma2 = 0.;
327  double sumSigma2 = 0.;
328 
329  for (auto& rhf : cluster.recHitFractions())
330  {
331  const reco::PFRecHit& rh = *(rhf.recHitRef());
332  const double rhf_f = rhf.fraction();
333 
334  if (rhf_f == 0.)
335  continue;
336 
337  bool isBarrel = (rh.layer() == PFLayer::HCAL_BARREL1 ||
338  rh.layer() == PFLayer::HCAL_BARREL2 ||
339  rh.layer() == PFLayer::ECAL_BARREL);
340  double res2 = 10000.;
341  if (isBarrel)
342  res2 = _timeResolutionCalcBarrel->timeResolution2(rh.energy());
343  else
344  res2 = _timeResolutionCalcEndcap->timeResolution2(rh.energy());
345 
346  sumTimeSigma2 += rhf_f * rh.time()/res2;
347  sumSigma2 += rhf_f/res2;
348  }
349  if (sumSigma2 > 0.) {
350  clusterRes2 = 1./sumSigma2;
351  cluster.setTime(sumTimeSigma2/sumSigma2);
352  cluster.setTimeError(std::sqrt(float(clusterRes2)));
353  } else {
354  clusterRes2 = 999999.;
355  }
356 }
float time() const
timing for cleaned hits
Definition: PFRecHit.h:118
void setTime(float time, float timeError=0)
Definition: PFCluster.h:92
PFLayer::Layer layer() const
rechit layer
Definition: PFRecHit.h:111
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:32
T sqrt(T t)
Definition: SSEVec.h:18
float energy() const
rechit energy
Definition: PFRecHit.h:114
void setTimeError(float timeError)
Definition: PFCluster.h:93
std::unique_ptr< CaloRecHitResolutionProvider > _timeResolutionCalcBarrel
std::unique_ptr< CaloRecHitResolutionProvider > _timeResolutionCalcEndcap
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions
Definition: PFCluster.h:72
void PFlow2DClusterizerWithTime::clusterTimeResolutionFromSeed ( reco::PFCluster cluster,
double &  res 
) const
private

Definition at line 301 of file PFlow2DClusterizerWithTime.cc.

References _timeResolutionCalcBarrel, _timeResolutionCalcEndcap, reco::PFRecHit::detId(), PFLayer::ECAL_BARREL, reco::PFRecHit::energy(), PFLayer::HCAL_BARREL1, PFLayer::HCAL_BARREL2, gedGsfElectrons_cfi::isBarrel, reco::PFRecHit::layer(), reco::PFCluster::recHitFractions(), reco::CaloCluster::seed(), reco::PFCluster::setTime(), reco::PFCluster::setTimeError(), mathSSE::sqrt(), and reco::PFRecHit::time().

Referenced by growPFClusters().

303 {
304  clusterRes2 = 10000.;
305  for (auto& rhf : cluster.recHitFractions())
306  {
307  const reco::PFRecHit& rh = *(rhf.recHitRef());
308  if (rh.detId() == cluster.seed())
309  {
310  cluster.setTime(rh.time());
311  bool isBarrel = (rh.layer() == PFLayer::HCAL_BARREL1 ||
312  rh.layer() == PFLayer::HCAL_BARREL2 ||
313  rh.layer() == PFLayer::ECAL_BARREL);
314  if (isBarrel)
315  clusterRes2 = _timeResolutionCalcBarrel->timeResolution2(rh.energy());
316  else
317  clusterRes2 = _timeResolutionCalcEndcap->timeResolution2(rh.energy());
318  cluster.setTimeError(std::sqrt(float(clusterRes2)));
319  }
320  }
321 }
float time() const
timing for cleaned hits
Definition: PFRecHit.h:118
unsigned detId() const
rechit detId
Definition: PFRecHit.h:108
void setTime(float time, float timeError=0)
Definition: PFCluster.h:92
PFLayer::Layer layer() const
rechit layer
Definition: PFRecHit.h:111
Particle flow rechit (rechit + geometry and topology information). See clustering algorithm in PFClus...
Definition: PFRecHit.h:32
T sqrt(T t)
Definition: SSEVec.h:18
float energy() const
rechit energy
Definition: PFRecHit.h:114
void setTimeError(float timeError)
Definition: PFCluster.h:93
DetId seed() const
return DetId of seed
Definition: CaloCluster.h:207
std::unique_ptr< CaloRecHitResolutionProvider > _timeResolutionCalcBarrel
std::unique_ptr< CaloRecHitResolutionProvider > _timeResolutionCalcEndcap
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions
Definition: PFCluster.h:72
double PFlow2DClusterizerWithTime::dist2Time ( const reco::PFCluster cluster,
const reco::PFRecHitRef refhit,
int  cell_layer,
double  prev_timeres2 
) const
private

Definition at line 358 of file PFlow2DClusterizerWithTime.cc.

References _maxNSigmaTime, _timeResolutionCalcBarrel, _timeResolutionCalcEndcap, _timeSigma_eb, _timeSigma_ee, PFLayer::ECAL_BARREL, PFLayer::ECAL_ENDCAP, PFLayer::HCAL_BARREL1, PFLayer::HCAL_BARREL2, PFLayer::HCAL_ENDCAP, PFLayer::HF_EM, PFLayer::HF_HAD, and reco::PFCluster::time().

Referenced by growPFClusters().

360 {
361  const double deltaT = cluster.time()-refhit->time();
362  const double t2 = deltaT*deltaT;
363  double res2 = 100.;
364 
365  if (cell_layer == PFLayer::HCAL_BARREL1 ||
366  cell_layer == PFLayer::HCAL_BARREL2 ||
367  cell_layer == PFLayer::ECAL_BARREL) {
369  const double resCluster2 = prev_timeres2;
370  res2 = resCluster2 + _timeResolutionCalcBarrel->timeResolution2(
371  refhit->energy());
372  }
373  else {
374  return t2/_timeSigma_eb;
375  }
376  }
377  else if (cell_layer == PFLayer::HCAL_ENDCAP ||
378  cell_layer == PFLayer::HF_EM ||
379  cell_layer == PFLayer::HF_HAD ||
380  cell_layer == PFLayer::ECAL_ENDCAP) {
382  const double resCluster2 = prev_timeres2;
383  res2 = resCluster2 + _timeResolutionCalcEndcap->timeResolution2(
384  refhit->energy());
385  }
386  else {
387  return t2/_timeSigma_ee;
388  }
389  }
390 
391  double distTime2 = t2/res2;
392  if (distTime2 > _maxNSigmaTime)
393  return 999.; // reject hit
394 
395  return distTime2;
396 }
float time() const
Definition: PFCluster.h:85
std::unique_ptr< CaloRecHitResolutionProvider > _timeResolutionCalcBarrel
std::unique_ptr< CaloRecHitResolutionProvider > _timeResolutionCalcEndcap
void PFlow2DClusterizerWithTime::growPFClusters ( const reco::PFCluster topo,
const std::vector< bool > &  seedable,
const unsigned  toleranceScaling,
const unsigned  iter,
double  dist,
reco::PFClusterCollection clusters 
) const
private

Definition at line 156 of file PFlow2DClusterizerWithTime.cc.

References _allCellsPosCalc, _clusterTimeResFromSeed, _convergencePosCalc, _excludeOtherSeeds, _maxIterations, _minChi2Prob, _minFracTot, PFClusterBuilderBase::_positionCalc, _recHitEnergyNorms, _showerSigma2, _stoppingTolerance, funct::abs(), clusterTimeResolution(), clusterTimeResolutionFromSeed(), reco::deltaR2(), diffTreeTool::diff, dist2Time(), reco::PFCluster::energy(), myMath::fast_expf(), cropTnPTrees::frac, dedxEstimators_cff::fraction, PFLayer::HCAL_BARREL2, mps_fire::i, createfilelist::int, edm::Ref< C, T, F >::key(), LOGDRESSED, passChi2Prob(), reco::CaloCluster::position(), prunePFClusters(), particleFlowClusterECALUncorrected_cfi::recHitEnergyNorm, reco::PFCluster::recHitFractions(), reco::CaloCluster::seed(), and mathSSE::sqrt().

Referenced by buildClusters(), and seedPFClustersFromTopo().

161  {
162  if( iter >= _maxIterations ) {
163  LOGDRESSED("PFlow2DClusterizerWithTime:growAndStabilizePFClusters")
164  <<"reached " << _maxIterations << " iterations, terminated position "
165  << "fit with diff = " << diff;
166  }
167  if( iter >= _maxIterations ||
168  diff <= _stoppingTolerance*toleranceScaling) return;
169  // reset the rechits in this cluster, keeping the previous position
170  std::vector<reco::PFCluster::REPPoint> clus_prev_pos;
171  // also calculate and keep the previous time resolution
172  std::vector<double> clus_prev_timeres2;
173 
174  for( auto& cluster : clusters) {
175  const reco::PFCluster::REPPoint& repp = cluster.positionREP();
176  clus_prev_pos.emplace_back(repp.rho(),repp.eta(),repp.phi());
177  if( _convergencePosCalc ) {
178  if( clusters.size() == 1 && _allCellsPosCalc ) {
179  _allCellsPosCalc->calculateAndSetPosition(cluster);
180  } else {
181  _positionCalc->calculateAndSetPosition(cluster);
182  }
183  }
184  double resCluster2;
186  clusterTimeResolutionFromSeed(cluster, resCluster2);
187  else
188  clusterTimeResolution(cluster, resCluster2);
189  clus_prev_timeres2.push_back(resCluster2);
190  cluster.resetHitsAndFractions();
191  }
192  // loop over topo cluster and grow current PFCluster hypothesis
193  std::vector<double> dist2, frac;
194 
195  // Store chi2 values and nhits to calculate chi2 prob. inline
196  std::vector<double> clus_chi2;
197  std::vector<size_t> clus_chi2_nhits;
198 
199  double fractot = 0;
200  for( const reco::PFRecHitFraction& rhf : topo.recHitFractions() ) {
201  const reco::PFRecHitRef& refhit = rhf.recHitRef();
202  int cell_layer = (int)refhit->layer();
203  if( cell_layer == PFLayer::HCAL_BARREL2 &&
204  std::abs(refhit->positionREP().eta()) > 0.34 ) {
205  cell_layer *= 100;
206  }
207  const double recHitEnergyNorm =
208  _recHitEnergyNorms.find(cell_layer)->second;
209  math::XYZPoint topocellpos_xyz(refhit->position());
210  dist2.clear(); frac.clear(); fractot = 0;
211 
212  // add rechits to clusters, calculating fraction based on distance
213  // need position in vector to get cluster time resolution
214  for (size_t iCluster = 0; iCluster < clusters.size(); ++iCluster) {
215  reco::PFCluster& cluster = clusters[iCluster];
216  const math::XYZPoint& clusterpos_xyz = cluster.position();
217  const math::XYZVector deltav = clusterpos_xyz - topocellpos_xyz;
218  double d2 = deltav.Mag2()/_showerSigma2;
219 
220  double d2time = dist2Time(cluster, refhit, cell_layer,
221  clus_prev_timeres2[iCluster]);
222  d2 += d2time;
223 
224  if (_minChi2Prob > 0. && !passChi2Prob(iCluster, d2time, clus_chi2,
225  clus_chi2_nhits))
226  d2 = 999.;
227 
228  dist2.emplace_back( d2);
229 
230  if( d2 > 100 ) {
231  LOGDRESSED("PFlow2DClusterizerWithTime:growAndStabilizePFClusters")
232  << "Warning! :: pfcluster-topocell distance is too large! d= "
233  << d2;
234  }
235  // fraction assignment logic
236  double fraction;
237  if( refhit->detId() == cluster.seed() && _excludeOtherSeeds ) {
238  fraction = 1.0;
239  } else if ( seedable[refhit.key()] && _excludeOtherSeeds ) {
240  fraction = 0.0;
241  } else {
242  fraction = cluster.energy()/recHitEnergyNorm * vdt::fast_expf( -0.5*d2 );
243  }
244  fractot += fraction;
245  frac.emplace_back(fraction);
246  }
247  for( unsigned i = 0; i < clusters.size(); ++i ) {
248  if( fractot > _minFracTot ||
249  ( refhit->detId() == clusters[i].seed() && fractot > 0.0 ) ) {
250  frac[i]/=fractot;
251  } else {
252  continue;
253  }
254  // if the fraction has been set to 0, the cell
255  // is now added to the cluster - careful ! (PJ, 19/07/08)
256  // BUT KEEP ONLY CLOSE CELLS OTHERWISE MEMORY JUST EXPLOSES
257  // (PJ, 15/09/08 <- similar to what existed before the
258  // previous bug fix, but keeps the close seeds inside,
259  // even if their fraction was set to zero.)
260  // Also add a protection to keep the seed in the cluster
261  // when the latter gets far from the former. These cases
262  // (about 1% of the clusters) need to be studied, as
263  // they create fake photons, in general.
264  // (PJ, 16/09/08)
265  if( dist2[i] < 100.0 || frac[i] > 0.9999 ) {
266  clusters[i].addRecHitFraction(reco::PFRecHitFraction(refhit,frac[i]));
267  }
268  }
269  }
270  // recalculate positions and calculate convergence parameter
271  double diff2 = 0.0;
272  for( unsigned i = 0; i < clusters.size(); ++i ) {
273  if( _convergencePosCalc ) {
274  _convergencePosCalc->calculateAndSetPosition(clusters[i]);
275  } else {
276  if( clusters.size() == 1 && _allCellsPosCalc ) {
277  _allCellsPosCalc->calculateAndSetPosition(clusters[i]);
278  } else {
279  _positionCalc->calculateAndSetPosition(clusters[i]);
280  }
281  }
282  const double delta2 =
283  reco::deltaR2(clusters[i].positionREP(),clus_prev_pos[i]);
284  if( delta2 > diff2 ) diff2 = delta2;
285  }
286  diff = std::sqrt(diff2);
287  dist2.clear(); frac.clear(); clus_prev_pos.clear();// avoid badness
288  clus_chi2.clear(); clus_chi2_nhits.clear(); clus_prev_timeres2.clear();
289  growPFClusters(topo,seedable,toleranceScaling,iter+1,diff,clusters);
290 }
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:131
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:47
std::unique_ptr< PFCPositionCalculatorBase > _allCellsPosCalc
bool passChi2Prob(size_t iCluster, double dist2, std::vector< double > &clus_chi2, std::vector< size_t > &clus_chi2_nhits) const
std::unique_ptr< PosCalc > _positionCalc
Fraction of a PFRecHit (rechits can be shared between several PFCluster&#39;s)
#define LOGDRESSED(x)
key_type key() const
Accessor for product key.
Definition: Ref.h:265
void growPFClusters(const reco::PFCluster &, const std::vector< bool > &, const unsigned toleranceScaling, const unsigned iter, double dist, reco::PFClusterCollection &) const
void clusterTimeResolution(reco::PFCluster &cluster, double &res) const
T sqrt(T t)
Definition: SSEVec.h:18
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double dist2Time(const reco::PFCluster &, const reco::PFRecHitRef &, int cell_layer, double prev_timeres2) const
double energy() const
cluster energy
Definition: PFCluster.h:82
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
DetId seed() const
return DetId of seed
Definition: CaloCluster.h:207
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:30
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
std::unordered_map< int, double > _recHitEnergyNorms
float fast_expf(float x)
ROOT::Math::PositionVector3D< ROOT::Math::CylindricalEta3D< double > > REPPoint
Definition: PFCluster.h:54
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions
Definition: PFCluster.h:72
void clusterTimeResolutionFromSeed(reco::PFCluster &cluster, double &res) const
std::unique_ptr< PFCPositionCalculatorBase > _convergencePosCalc
B2DGPF& PFlow2DClusterizerWithTime::operator= ( const B2DGPF )
delete
bool PFlow2DClusterizerWithTime::passChi2Prob ( size_t  iCluster,
double  dist2,
std::vector< double > &  clus_chi2,
std::vector< size_t > &  clus_chi2_nhits 
) const
private

Definition at line 398 of file PFlow2DClusterizerWithTime.cc.

References _minChi2Prob, and vertices_cff::chi2.

Referenced by growPFClusters().

400 {
401  if (iCluster >= clus_chi2.size()) { // first hit
402  clus_chi2.push_back(dist2);
403  clus_chi2_nhits.push_back(1);
404  return true;
405  }
406  else {
407  double chi2 = clus_chi2[iCluster];
408  size_t nhitsCluster = clus_chi2_nhits[iCluster];
409  chi2 += dist2;
410  if (TMath::Prob(chi2, nhitsCluster) >= _minChi2Prob) {
411  clus_chi2[iCluster] = chi2;
412  clus_chi2_nhits[iCluster] = nhitsCluster + 1;
413  return true;
414  }
415  }
416  return false;
417 }
void PFlow2DClusterizerWithTime::prunePFClusters ( reco::PFClusterCollection clusters) const
private

Definition at line 293 of file PFlow2DClusterizerWithTime.cc.

References PFClusterBuilderBase::_minFractionToKeep, and reco::PFRecHitFraction::fraction().

Referenced by buildClusters(), and growPFClusters().

293  {
294  for( auto& cluster : clusters ) {
295  cluster.pruneUsing( [&](const reco::PFRecHitFraction& rhf)
296  {return rhf.fraction() > _minFractionToKeep;}
297  );
298  }
299 }
Fraction of a PFRecHit (rechits can be shared between several PFCluster&#39;s)
double fraction() const
void PFlow2DClusterizerWithTime::seedPFClustersFromTopo ( const reco::PFCluster topo,
const std::vector< bool > &  seedable,
reco::PFClusterCollection initialPFClusters 
) const
private

Definition at line 137 of file PFlow2DClusterizerWithTime.cc.

References _convergencePosCalc, PFClusterBuilderBase::_positionCalc, reco::PFCluster::addRecHitFraction(), growPFClusters(), reco::PFCluster::recHitFractions(), and reco::CaloCluster::setSeed().

Referenced by buildClusters().

139  {
140  const auto& recHitFractions = topo.recHitFractions();
141  for( const auto& rhf : recHitFractions ) {
142  if( !seedable[rhf.recHitRef().key()] ) continue;
143  initialPFClusters.push_back(reco::PFCluster());
144  reco::PFCluster& current = initialPFClusters.back();
145  current.addRecHitFraction(rhf);
146  current.setSeed(rhf.recHitRef()->detId());
147  if( _convergencePosCalc ) {
148  _convergencePosCalc->calculateAndSetPosition(current);
149  } else {
150  _positionCalc->calculateAndSetPosition(current);
151  }
152  }
153 }
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:47
std::unique_ptr< PosCalc > _positionCalc
void setSeed(const DetId &id)
Definition: CaloCluster.h:123
void addRecHitFraction(const reco::PFRecHitFraction &frac)
add a given fraction of the rechit
Definition: PFCluster.cc:99
const std::vector< reco::PFRecHitFraction > & recHitFractions() const
vector of rechit fractions
Definition: PFCluster.h:72
std::unique_ptr< PFCPositionCalculatorBase > _convergencePosCalc
void PFlow2DClusterizerWithTime::update ( const edm::EventSetup es)
inlineoverridevirtual

Reimplemented from PFClusterBuilderBase.

Definition at line 20 of file PFlow2DClusterizerWithTime.h.

References _allCellsPosCalc, _convergencePosCalc, PFClusterBuilderBase::_positionCalc, and buildClusters().

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().

20  {
21  _positionCalc->update(es);
22  if( _allCellsPosCalc ) _allCellsPosCalc->update(es);
23  if( _convergencePosCalc ) _convergencePosCalc->update(es);
24  }
std::unique_ptr< PFCPositionCalculatorBase > _allCellsPosCalc
std::unique_ptr< PosCalc > _positionCalc
std::unique_ptr< PFCPositionCalculatorBase > _convergencePosCalc

Member Data Documentation

std::unique_ptr<PFCPositionCalculatorBase> PFlow2DClusterizerWithTime::_allCellsPosCalc
private
const bool PFlow2DClusterizerWithTime::_clusterTimeResFromSeed
private

Definition at line 40 of file PFlow2DClusterizerWithTime.h.

Referenced by growPFClusters().

std::unique_ptr<PFCPositionCalculatorBase> PFlow2DClusterizerWithTime::_convergencePosCalc
private
const bool PFlow2DClusterizerWithTime::_excludeOtherSeeds
private

Definition at line 36 of file PFlow2DClusterizerWithTime.h.

Referenced by growPFClusters().

const std::unordered_map<std::string,int> PFlow2DClusterizerWithTime::_layerMap
private

Definition at line 42 of file PFlow2DClusterizerWithTime.h.

Referenced by PFlow2DClusterizerWithTime().

const unsigned PFlow2DClusterizerWithTime::_maxIterations
private

Definition at line 31 of file PFlow2DClusterizerWithTime.h.

Referenced by growPFClusters().

const double PFlow2DClusterizerWithTime::_maxNSigmaTime
private

Definition at line 38 of file PFlow2DClusterizerWithTime.h.

Referenced by dist2Time().

const double PFlow2DClusterizerWithTime::_minChi2Prob
private

Definition at line 39 of file PFlow2DClusterizerWithTime.h.

Referenced by growPFClusters(), and passChi2Prob().

const double PFlow2DClusterizerWithTime::_minFracTot
private

Definition at line 37 of file PFlow2DClusterizerWithTime.h.

Referenced by growPFClusters().

std::unordered_map<int,double> PFlow2DClusterizerWithTime::_recHitEnergyNorms
private

Definition at line 43 of file PFlow2DClusterizerWithTime.h.

Referenced by growPFClusters(), and PFlow2DClusterizerWithTime().

const double PFlow2DClusterizerWithTime::_showerSigma2
private

Definition at line 33 of file PFlow2DClusterizerWithTime.h.

Referenced by growPFClusters().

const double PFlow2DClusterizerWithTime::_stoppingTolerance
private

Definition at line 32 of file PFlow2DClusterizerWithTime.h.

Referenced by growPFClusters().

std::unique_ptr<CaloRecHitResolutionProvider> PFlow2DClusterizerWithTime::_timeResolutionCalcBarrel
private
std::unique_ptr<CaloRecHitResolutionProvider> PFlow2DClusterizerWithTime::_timeResolutionCalcEndcap
private
const double PFlow2DClusterizerWithTime::_timeSigma_eb
private

Definition at line 34 of file PFlow2DClusterizerWithTime.h.

Referenced by dist2Time().

const double PFlow2DClusterizerWithTime::_timeSigma_ee
private

Definition at line 35 of file PFlow2DClusterizerWithTime.h.

Referenced by dist2Time().