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 Attributes
DAClusterizerInZ Class Reference

#include <DAClusterizerInZ.h>

Inheritance diagram for DAClusterizerInZ:
TrackClusterizerInZ

Classes

struct  track_t
 
struct  vertex_t
 

Public Member Functions

double beta0 (const double betamax, std::vector< track_t > &tks, std::vector< vertex_t > &y) const
 
std::vector< std::vector
< reco::TransientTrack > > 
clusterize (const std::vector< reco::TransientTrack > &tracks) const
 
 DAClusterizerInZ (const edm::ParameterSet &conf)
 
void dump (const double beta, const std::vector< vertex_t > &y, const std::vector< track_t > &tks, const int verbosity=0) const
 
double Eik (const track_t &t, const vertex_t &k) const
 
std::vector< track_tfill (const std::vector< reco::TransientTrack > &tracks) const
 
bool merge (std::vector< vertex_t > &, int) const
 
bool purge (std::vector< vertex_t > &, std::vector< track_t > &, double &, const double) const
 
void splitAll (std::vector< track_t > &tks, std::vector< vertex_t > &y) const
 
double update (double beta, std::vector< track_t > &tks, std::vector< vertex_t > &y) const
 
double update (double beta, std::vector< track_t > &tks, std::vector< vertex_t > &y, double &) const
 
std::vector< TransientVertexvertices (const std::vector< reco::TransientTrack > &tracks, const int verbosity=0) const
 
- Public Member Functions inherited from TrackClusterizerInZ
 TrackClusterizerInZ ()
 
 TrackClusterizerInZ (const edm::ParameterSet &conf)
 
virtual ~TrackClusterizerInZ ()
 

Private Attributes

float betamax_
 
float betastop_
 
double coolingFactor_
 
double d0CutOff_
 
double dzCutOff_
 
int maxIterations_
 
bool verbose_
 
float vertexSize_
 

Detailed Description

Description: separates event tracks into clusters along the beam line

Definition at line 21 of file DAClusterizerInZ.h.

Constructor & Destructor Documentation

DAClusterizerInZ::DAClusterizerInZ ( const edm::ParameterSet conf)

Definition at line 348 of file DAClusterizerInZ.cc.

References gather_cfg::cout, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), and builder_last_value_cfg::Tmin.

349 {
350  // some defaults to avoid uninitialized variables
351  verbose_= conf.getUntrackedParameter<bool>("verbose", false);
352  betamax_=0.1;
353  betastop_ =1.0;
354  coolingFactor_=0.8;
355  maxIterations_=100;
356  vertexSize_=0.05; // 0.5 mm
357  dzCutOff_=4.0; // Adaptive Fitter uses 3.0 but that appears to be a bit tight here sometimes
358 
359  // configure
360 
361  double Tmin = conf.getParameter<double>("Tmin");
362  vertexSize_ = conf.getParameter<double>("vertexSize");
363  coolingFactor_ = conf.getParameter<double>("coolingFactor");
364  d0CutOff_ = conf.getParameter<double>("d0CutOff");
365  dzCutOff_ = conf.getParameter<double>("dzCutOff");
366  maxIterations_=100;
367  if (Tmin==0){
368  cout << "DAClusterizerInZ: invalid Tmin" << Tmin << " reset do default " << 1./betamax_ << endl;
369  }else{
370  betamax_ = 1./Tmin;
371  }
372 
373 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
tuple cout
Definition: gather_cfg.py:41

Member Function Documentation

double DAClusterizerInZ::beta0 ( const double  betamax,
std::vector< track_t > &  tks,
std::vector< vertex_t > &  y 
) const

Definition at line 269 of file DAClusterizerInZ.cc.

References a, b, i, gen::k, funct::log(), nt, and funct::pow().

273  {
274 
275  double T0=0; // max Tc for beta=0
276  // estimate critical temperature from beta=0 (T=inf)
277  unsigned int nt=tks.size();
278 
279  for(vector<vertex_t>::iterator k=y.begin(); k!=y.end(); k++){
280 
281  // vertex fit at T=inf
282  double sumwz=0;
283  double sumw=0;
284  for(unsigned int i=0; i<nt; i++){
285  double w=tks[i].pi/tks[i].dz2;
286  sumwz+=w*tks[i].z;
287  sumw +=w;
288  }
289  k->z=sumwz/sumw;
290 
291  // estimate Tcrit, eventually do this in the same loop
292  double a=0, b=0;
293  for(unsigned int i=0; i<nt; i++){
294  double dx=tks[i].z-(k->z);
295  double w=tks[i].pi/tks[i].dz2;
296  a+=w*pow(dx,2)/tks[i].dz2;
297  b+=w;
298  }
299  double Tc= 2.*a/b; // the critical temperature of this vertex
300  if(Tc>T0) T0=Tc;
301  }// vertex loop (normally there should be only one vertex at beta=0)
302 
303  if (T0>1./betamax){
304  return betamax/pow(coolingFactor_, int(log(T0*betamax)/log(coolingFactor_))-1 );
305  }else{
306  // ensure at least one annealing step
307  return betamax/coolingFactor_;
308  }
309 }
int i
Definition: DBlmapReader.cc:9
int nt
Definition: AMPTWrapper.h:32
int k[5][pyjets_maxn]
Log< T >::type log(const T &t)
Definition: Log.h:22
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
vector< vector< reco::TransientTrack > > DAClusterizerInZ::clusterize ( const std::vector< reco::TransientTrack > &  tracks) const
virtual

Implements TrackClusterizerInZ.

Definition at line 556 of file DAClusterizerInZ.cc.

References gather_cfg::cout, i, gen::k, and position.

558 {
559  if(verbose_) {
560  cout << "###################################################" << endl;
561  cout << "# DAClusterizerInZ::clusterize nt="<<tracks.size() << endl;
562  cout << "###################################################" << endl;
563  }
564 
565  vector< vector<reco::TransientTrack> > clusters;
566  vector< TransientVertex > pv=vertices(tracks);
567 
568  if(verbose_){ cout << "# DAClusterizerInZ::clusterize pv.size="<<pv.size() << endl; }
569  if (pv.size()==0){ return clusters;}
570 
571 
572  // fill into clusters and merge
573  vector< reco::TransientTrack> aCluster=pv.begin()->originalTracks();
574 
575  for(vector<TransientVertex>::iterator k=pv.begin()+1; k!=pv.end(); k++){
576  if ( k->position().z() - (k-1)->position().z()> (2*vertexSize_) ){
577  // close a cluster
578  clusters.push_back(aCluster);
579  aCluster.clear();
580  }
581  for(unsigned int i=0; i<k->originalTracks().size(); i++){ aCluster.push_back( k->originalTracks().at(i)); }
582 
583  }
584  clusters.push_back(aCluster);
585 
586 
587  return clusters;
588 
589 }
int i
Definition: DBlmapReader.cc:9
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
int k[5][pyjets_maxn]
tuple tracks
Definition: testEve_cfg.py:39
tuple cout
Definition: gather_cfg.py:41
std::vector< TransientVertex > vertices(const std::vector< reco::TransientTrack > &tracks, const int verbosity=0) const
void DAClusterizerInZ::dump ( const double  beta,
const std::vector< vertex_t > &  y,
const std::vector< track_t > &  tks,
const int  verbosity = 0 
) const

Definition at line 376 of file DAClusterizerInZ.cc.

References beta, gather_cfg::cout, Measurement1D::error(), funct::exp(), reco::TrackBase::highPurity, i, gen::k, funct::log(), L1TEmulatorMonitor_cff::p, pi, mathSSE::sqrt(), matplotRender::t, Measurement1D::value(), and Gflash::Z.

376  {
377 
378  // copy and sort for nicer printout
379  vector<track_t> tks;
380  for(vector<track_t>::const_iterator t=tks0.begin(); t!=tks0.end(); t++){tks.push_back(*t); }
381  stable_sort(tks.begin(), tks.end(), recTrackLessZ1);
382 
383  cout << "-----DAClusterizerInZ::dump ----" << endl;
384  cout << "beta=" << beta << " betamax= " << betamax_ << endl;
385  cout << " z= ";
386  cout.precision(4);
387  for(vector<vertex_t>::const_iterator k=y.begin(); k!=y.end(); k++){
388  cout << setw(8) << fixed << k->z ;
389  }
390  cout << endl << "T=" << setw(15) << 1./beta <<" Tc= ";
391  cout << endl << " pk=";
392  double sumpk=0;
393  for(vector<vertex_t>::const_iterator k=y.begin(); k!=y.end(); k++){
394  cout << setw(8) << setprecision(3) << fixed << k->pk;
395  sumpk+=k->pk;
396  }
397  cout << endl;
398 
399  if(verbosity>0){
400  double E=0, F=0;
401  cout << endl;
402  cout << "---- z +/- dz ip +/-dip pt phi eta weights ----" << endl;
403  cout.precision(4);
404  for(unsigned int i=0; i<tks.size(); i++){
405  if (tks[i].Z>0){ F-=log(tks[i].Z)/beta;}
406  double tz= tks[i].z;
407  cout << setw (3)<< i << ")" << setw (8) << fixed << setprecision(4)<< tz << " +/-" << setw (6)<< sqrt(tks[i].dz2);
408 
409  if(tks[i].tt->track().quality(reco::TrackBase::highPurity)){ cout << " *";}else{cout <<" ";}
410  if(tks[i].tt->track().hitPattern().hasValidHitInFirstPixelBarrel()){cout <<"+";}else{cout << "-";}
411  cout << setw(1) << tks[i].tt->track().hitPattern().pixelBarrelLayersWithMeasurement(); // see DataFormats/TrackReco/interface/HitPattern.h
412  cout << setw(1) << tks[i].tt->track().hitPattern().pixelEndcapLayersWithMeasurement();
413  cout << setw(1) << hex << tks[i].tt->track().hitPattern().trackerLayersWithMeasurement()-tks[i].tt->track().hitPattern().pixelLayersWithMeasurement() <<dec;
414  cout << "=" << setw(1)<<hex <<tks[i].tt->track().trackerExpectedHitsOuter().numberOfHits() << dec;
415 
416  Measurement1D IP=tks[i].tt->stateAtBeamLine().transverseImpactParameter();
417  cout << setw (8) << IP.value() << "+/-" << setw (6) << IP.error();
418  cout << " " << setw(6) << setprecision(2) << tks[i].tt->track().pt()*tks[i].tt->track().charge();
419  cout << " " << setw(5) << setprecision(2) << tks[i].tt->track().phi()
420  << " " << setw(5) << setprecision(2) << tks[i].tt->track().eta() ;
421 
422  double sump=0.;
423  for(vector<vertex_t>::const_iterator k=y.begin(); k!=y.end(); k++){
424  if((tks[i].pi>0)&&(tks[i].Z>0)){
425  //double p=pik(beta,tks[i],*k);
426  double p=k->pk * exp(-beta*Eik(tks[i],*k)) / tks[i].Z;
427  if( p > 0.0001){
428  cout << setw (8) << setprecision(3) << p;
429  }else{
430  cout << " . ";
431  }
432  E+=p*Eik(tks[i],*k);
433  sump+=p;
434  }else{
435  cout << " ";
436  }
437  }
438  cout << endl;
439  }
440  cout << endl << "T=" << 1/beta << " E=" << E << " n="<< y.size() << " F= " << F << endl << "----------" << endl;
441  }
442 }
const double Z[kNumberCalorimeter]
const double beta
int i
Definition: DBlmapReader.cc:9
double error() const
Definition: Measurement1D.h:30
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
T sqrt(T t)
Definition: SSEVec.h:28
int k[5][pyjets_maxn]
const int verbosity
Log< T >::type log(const T &t)
Definition: Log.h:22
double value() const
Definition: Measurement1D.h:28
double Eik(const track_t &t, const vertex_t &k) const
tuple cout
Definition: gather_cfg.py:41
double pi
double DAClusterizerInZ::Eik ( const track_t t,
const vertex_t k 
) const

Definition at line 63 of file DAClusterizerInZ.cc.

References DAClusterizerInZ::track_t::dz2, funct::pow(), DAClusterizerInZ::track_t::z, and DAClusterizerInZ::vertex_t::z.

63  {
64  return pow(t.z-k.z,2)/t.dz2;
65 }
int k[5][pyjets_maxn]
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
vector< DAClusterizerInZ::track_t > DAClusterizerInZ::fill ( const std::vector< reco::TransientTrack > &  tracks) const

Definition at line 20 of file DAClusterizerInZ.cc.

References DAClusterizerInZ::track_t::dz2, Measurement1D::error(), funct::exp(), DAClusterizerInZ::track_t::pi, position, funct::pow(), matplotRender::t, funct::tan(), DAClusterizerInZ::track_t::tt, Measurement1D::value(), DAClusterizerInZ::track_t::z, and DAClusterizerInZ::track_t::Z.

22  {
23  // prepare track data for clustering
24  vector<track_t> tks;
25  for(vector<reco::TransientTrack>::const_iterator it=tracks.begin(); it!=tracks.end(); it++){
26  track_t t;
27  t.z=((*it).stateAtBeamLine().trackStateAtPCA()).position().z();
28  double tantheta=tan(((*it).stateAtBeamLine().trackStateAtPCA()).momentum().theta());
29  // get the beam-spot
30  reco::BeamSpot beamspot=(it->stateAtBeamLine()).beamSpot();
31  t.dz2= pow((*it).track().dzError(),2) // track errror
32  + (pow(beamspot.BeamWidthX(),2)+pow(beamspot.BeamWidthY(),2))/pow(tantheta,2) // beam-width induced
33  + pow(vertexSize_,2); // intrinsic vertex size, safer for outliers and short lived decays
34  if (d0CutOff_>0){
35  Measurement1D IP=(*it).stateAtBeamLine().transverseImpactParameter();// error constains beamspot
36  t.pi=1./(1.+exp(pow(IP.value()/IP.error(),2)-pow(d0CutOff_ ,2))); // reduce weight for high ip tracks
37  }else{
38  t.pi=1.;
39  }
40  t.tt=&(*it);
41  t.Z=1.;
42  tks.push_back(t);
43  }
44  return tks;
45 }
double error() const
Definition: Measurement1D.h:30
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
tuple tracks
Definition: testEve_cfg.py:39
double value() const
Definition: Measurement1D.h:28
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
bool DAClusterizerInZ::merge ( std::vector< vertex_t > &  y,
int  nt 
) const

Definition at line 210 of file DAClusterizerInZ.cc.

References gen::k, and detailsBasic3DVector::z.

210  {
211  // merge clusters that collapsed or never separated, return true if vertices were merged, false otherwise
212 
213  if(y.size()<2) return false;
214 
215  for(vector<vertex_t>::iterator k=y.begin(); (k+1)!=y.end(); k++){
216  //if ((k+1)->z - k->z<1.e-2){ // note, no fabs here, maintains z-ordering (with split()+merge() at every temperature)
217  if (fabs((k+1)->z - k->z)<1.e-2){ // with fabs if only called after freeze-out (splitAll() at highter T)
218  k->pk += (k+1)->pk;
219  k->z=0.5*(k->z+(k+1)->z);
220  y.erase(k+1);
221  return true;
222  }
223  }
224 
225  return false;
226 }
double double double z
int k[5][pyjets_maxn]
bool DAClusterizerInZ::purge ( std::vector< vertex_t > &  y,
std::vector< track_t > &  tks,
double &  rho0,
const double  beta 
) const

Definition at line 230 of file DAClusterizerInZ.cc.

References gather_cfg::cout, funct::exp(), i, gen::k, reco::ParticleMasses::k0, nt, L1TEmulatorMonitor_cff::p, pi, and Gflash::Z.

230  {
231  // eliminate clusters with only one significant/unique track
232  if(y.size()<2) return false;
233 
234  unsigned int nt=tks.size();
235  double sumpmin=nt;
236  vector<vertex_t>::iterator k0=y.end();
237  for(vector<vertex_t>::iterator k=y.begin(); k!=y.end(); k++){
238  int nUnique=0;
239  double sump=0;
240  double pmax=k->pk/(k->pk+rho0*exp(-beta*dzCutOff_*dzCutOff_));
241  for(unsigned int i=0; i<nt; i++){
242  if(tks[i].Z>0){
243  //double p=pik(beta,tks[i],*k);
244  double p=k->pk * exp(-beta*Eik(tks[i],*k)) / tks[i].Z;
245  sump+=p;
246  if( (p > 0.9*pmax) && (tks[i].pi>0) ){ nUnique++; }
247  }
248  }
249 
250  if((nUnique<2)&&(sump<sumpmin)){
251  sumpmin=sump;
252  k0=k;
253  }
254  }
255 
256  if(k0!=y.end()){
257  if(verbose_){cout << "eliminating prototype at " << k0->z << " with sump=" << sumpmin << endl;}
258  //rho0+=k0->pk;
259  y.erase(k0);
260  return true;
261  }else{
262  return false;
263  }
264 }
const double Z[kNumberCalorimeter]
const double beta
int i
Definition: DBlmapReader.cc:9
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
int nt
Definition: AMPTWrapper.h:32
int k[5][pyjets_maxn]
double Eik(const track_t &t, const vertex_t &k) const
tuple cout
Definition: gather_cfg.py:41
double pi
void DAClusterizerInZ::splitAll ( std::vector< track_t > &  tks,
std::vector< vertex_t > &  y 
) const

Definition at line 314 of file DAClusterizerInZ.cc.

References epsilon, gen::k, DAClusterizerInZ::vertex_t::pk, and DAClusterizerInZ::vertex_t::z.

317  {
318 
319 
320  double epsilon=1e-3; // split all single vertices by 10 um
321  double zsep=2*epsilon; // split vertices that are isolated by at least zsep (vertices that haven't collapsed)
322  vector<vertex_t> y1;
323 
324  for(vector<vertex_t>::iterator k=y.begin(); k!=y.end(); k++){
325  if ( ( (k==y.begin())|| (k-1)->z < k->z - zsep) && (((k+1)==y.end() )|| (k+1)->z > k->z + zsep)) {
326  // isolated prototype, split
327  vertex_t vnew;
328  vnew.z = k->z -epsilon;
329  (*k).z = k->z+epsilon;
330  vnew.pk= 0.5* (*k).pk;
331  (*k).pk= 0.5* (*k).pk;
332  y1.push_back(vnew);
333  y1.push_back(*k);
334 
335  }else if( y1.empty() || (y1.back().z < k->z -zsep)){
336  y1.push_back(*k);
337  }else{
338  y1.back().z -=epsilon;
339  k->z+=epsilon;
340  y1.push_back(*k);
341  }
342  }// vertex loop
343 
344  y=y1;
345 }
int k[5][pyjets_maxn]
const double epsilon
double DAClusterizerInZ::update ( double  beta,
std::vector< track_t > &  tks,
std::vector< vertex_t > &  y 
) const

Definition at line 70 of file DAClusterizerInZ.cc.

References gather_cfg::cout, delta, funct::exp(), i, gen::k, nt, funct::pow(), and Gflash::Z.

Referenced by python.Vispa.Gui.VispaWidget.VispaWidget::autosize(), python.Vispa.Views.LineDecayView.LineDecayContainer::createObject(), python.Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), python.Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), python.Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), python.Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), python.Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), python.Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), python.Vispa.Gui.FindDialog.FindDialog::reset(), python.Vispa.Gui.PortConnection.PointToPointConnection::select(), python.Vispa.Gui.VispaWidget.VispaWidget::select(), python.Vispa.Views.LineDecayView.LineDecayContainer::select(), python.Vispa.Gui.VispaWidget.VispaWidget::setText(), python.Vispa.Gui.VispaWidget.VispaWidget::setTitle(), python.Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), python.Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and python.Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

74  {
75  //update weights and vertex positions
76  // mass constrained annealing without noise
77  // returns the squared sum of changes of vertex positions
78 
79  //cout << endl << endl << "DAClusterizerInZ::update" << endl;
80  unsigned int nt=tks.size();
81 
82  //initialize sums
83  double sumpi=0;
84  for(vector<vertex_t>::iterator k=y.begin(); k!=y.end(); k++){
85  k->se=0; k->sw=0; k->swz=0;
86  }
87 
88 
89  // loop over tracks
90  for(unsigned int i=0; i<nt; i++){
91 
92  // update pik and Zi
93  double Zi=0.;
94  for(vector<vertex_t>::iterator k=y.begin(); k!=y.end(); k++){
95  k->ei=exp(-beta*Eik(tks[i],*k));// cache exponential for one track at a time
96  Zi += k->pk * k->ei;
97  }
98  tks[i].Z=Zi;
99 
100  // normalization for pk
101  if (tks[i].Z>0){
102  sumpi += tks[i].pi;
103  // accumulate weighted z and weights for vertex update
104  for(vector<vertex_t>::iterator k=y.begin(); k!=y.end(); k++){
105  k->se += tks[i].pi* k->ei / Zi;
106  double w = k->pk * tks[i].pi* k->ei / Zi / tks[i].dz2;
107  k->sw += w;
108  k->swz += w * tks[i].z;
109  }
110  }else{
111  sumpi += tks[i].pi;
112  }
113 
114 
115  } // end of track loop
116 
117 
118  // now update z and pk
119  double delta=0;
120  for(vector<vertex_t>::iterator k=y.begin(); k!=y.end(); k++){
121  if ( k->sw > 0){
122  double znew=k->swz/k->sw;
123  delta+=pow(k->z-znew,2);
124  k->z=znew;
125  }else{
126  edm::LogInfo("sumw") << "invalid sum of weights in fit: " << k->sw << endl;
127  if(verbose_){cout << " a cluster melted away ? pk=" << k->pk << " sumw=" << k->sw << endl;}
128  }
129 
130  k->pk = k->pk * k->se / sumpi;
131  }
132 
133  // return how much the prototypes moved
134  return delta;
135 }
const double Z[kNumberCalorimeter]
const double beta
dbl * delta
Definition: mlp_gen.cc:36
int i
Definition: DBlmapReader.cc:9
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
int nt
Definition: AMPTWrapper.h:32
int k[5][pyjets_maxn]
double Eik(const track_t &t, const vertex_t &k) const
tuple cout
Definition: gather_cfg.py:41
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
double DAClusterizerInZ::update ( double  beta,
std::vector< track_t > &  tks,
std::vector< vertex_t > &  y,
double &  rho0 
) const

Definition at line 141 of file DAClusterizerInZ.cc.

References gather_cfg::cout, delta, funct::exp(), i, gen::k, nt, funct::pow(), and Gflash::Z.

Referenced by python.Vispa.Gui.VispaWidget.VispaWidget::autosize(), python.Vispa.Views.LineDecayView.LineDecayContainer::createObject(), python.Vispa.Views.LineDecayView.LineDecayContainer::deselectAllObjects(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::deselectAllWidgets(), python.Vispa.Gui.VispaWidget.VispaWidget::enableAutosizing(), python.Vispa.Gui.MenuWidget.MenuWidget::leaveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseMoveEvent(), python.Vispa.Gui.MenuWidget.MenuWidget::mouseMoveEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::mouseMoveEvent(), python.Vispa.Gui.VispaWidgetOwner.VispaWidgetOwner::mouseReleaseEvent(), python.Vispa.Views.LineDecayView.LineDecayContainer::objectMoved(), python.Vispa.Views.LineDecayView.LineDecayContainer::removeObject(), python.Vispa.Gui.ConnectableWidget.ConnectableWidget::removePorts(), python.Vispa.Gui.FindDialog.FindDialog::reset(), python.Vispa.Gui.PortConnection.PointToPointConnection::select(), python.Vispa.Gui.VispaWidget.VispaWidget::select(), python.Vispa.Views.LineDecayView.LineDecayContainer::select(), python.Vispa.Gui.VispaWidget.VispaWidget::setText(), python.Vispa.Gui.VispaWidget.VispaWidget::setTitle(), python.Vispa.Gui.ZoomableWidget.ZoomableWidget::setZoom(), python.Vispa.Views.LineDecayView.LineDecayContainer::setZoom(), and python.Vispa.Gui.PortConnection.PointToPointConnection::updateConnection().

146  {
147  // MVF style, no more vertex weights, update tracks weights and vertex positions, with noise
148  // returns the squared sum of changes of vertex positions
149 
150  unsigned int nt=tks.size();
151 
152  //initialize sums
153  for(vector<vertex_t>::iterator k=y.begin(); k!=y.end(); k++){
154  k->se=0; k->sw=0; k->swz=0;
155  }
156 
157 
158  // loop over tracks
159  for(unsigned int i=0; i<nt; i++){
160 
161  // update pik and Zi
162  double Zi=rho0*exp(-beta*dzCutOff_*dzCutOff_);// cut-off
163  for(vector<vertex_t>::iterator k=y.begin(); k!=y.end(); k++){
164  k->ei=exp(-beta*Eik(tks[i],*k));// cache exponential for one track at a time
165  Zi += k->pk * k->ei;
166  }
167  tks[i].Z=Zi;
168 
169  // normalization
170  if (tks[i].Z>0){
171  //double pi0=exp(-beta*dzCutOff_*dzCutOff_)/tks[i].Z;
172  //sumpi += tks[i].pi*(1.-pi0*rho0); // exclude rho0 from the normalization of the cluster "mass"
173  // accumulate weighted z and weights for vertex update
174  for(vector<vertex_t>::iterator k=y.begin(); k!=y.end(); k++){
175  k->se += tks[i].pi* k->ei / Zi;
176  double w = k->pk * tks[i].pi* k->ei / Zi / tks[i].dz2;
177  k->sw += w;
178  k->swz += w * tks[i].z;
179  }
180  }
181  //else{ sumpi += tks[i].pi; }
182 
183 
184  } // end of track loop
185 
186 
187  // now update z and pk
188  double delta=0;
189  for(vector<vertex_t>::iterator k=y.begin(); k!=y.end(); k++){
190  if ( k->sw > 0){
191  double znew=k->swz/k->sw;
192  delta+=pow(k->z-znew,2);
193  k->z=znew;
194  }else{
195  edm::LogInfo("sumw") << "invalid sum of weights in fit: " << k->sw << endl;
196  if(verbose_){cout << " a cluster melted away ? pk=" << k->pk << " sumw=" << k->sw << endl;}
197  }
198 
199  //k->pk *= k->se / sumpi;
200  }
201 
202  // return how much the prototypes moved
203  return delta;
204 }
const double Z[kNumberCalorimeter]
const double beta
dbl * delta
Definition: mlp_gen.cc:36
int i
Definition: DBlmapReader.cc:9
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
int nt
Definition: AMPTWrapper.h:32
int k[5][pyjets_maxn]
double Eik(const track_t &t, const vertex_t &k) const
tuple cout
Definition: gather_cfg.py:41
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
vector< TransientVertex > DAClusterizerInZ::vertices ( const std::vector< reco::TransientTrack > &  tracks,
const int  verbosity = 0 
) const

Definition at line 449 of file DAClusterizerInZ.cc.

References beta, gather_cfg::cout, hcal_timing_source_file_cfg::dump, funct::exp(), i, gen::k, relval_steps::merge(), nt, L1TEmulatorMonitor_cff::p, pi, DAClusterizerInZ::vertex_t::pk, pos, update, v, detailsBasic3DVector::y, DAClusterizerInZ::vertex_t::z, and Gflash::Z.

451 {
452 
453  vector<track_t> tks=fill(tracks);
454  unsigned int nt=tracks.size();
455  double rho0=0.0; // start with no outlier rejection
456 
457  vector< TransientVertex > clusters;
458  if (tks.empty()) return clusters;
459 
460  vector<vertex_t> y; // the vertex prototypes
461 
462  // initialize:single vertex at infinite temperature
463  vertex_t vstart;
464  vstart.z=0.;
465  vstart.pk=1.;
466  y.push_back(vstart);
467  int niter=0; // number of iterations
468 
469 
470  // estimate first critical temperature
471  double beta=beta0(betamax_, tks, y);
472  niter=0; while((update(beta, tks,y)>1.e-6) && (niter++ < maxIterations_)){ }
473 
474 
475  // annealing loop, stop when T<Tmin (i.e. beta>1/Tmin)
476  while(beta<betamax_){
477 
478  beta=beta/coolingFactor_;
479  splitAll(tks,y);
480 
481  // make sure we are not too far from equilibrium before cooling further
482  niter=0; while((update(beta, tks,y)>1.e-6) && (niter++ < maxIterations_)){ }
483 
484  }
485 
486 
487  // merge collapsed clusters
488  while(merge(y,tks.size())){}
489  if(verbose_ ){ cout << "dump after 1st merging " << endl; dump(beta,y,tks,2);}
490 
491 
492 
493  // switch on outlier rejection
494  //rho0=exp(beta*dzCutOff_*dzCutOff_)/nt; if(rho0>0.1) rho0=0.1;
495  rho0=1./nt; for(vector<vertex_t>::iterator k=y.begin(); k!=y.end(); k++){ k->pk =1.; } // democratic
496  niter=0; while((update(beta, tks,y,rho0) > 1.e-8) && (niter++ < maxIterations_)){ }
497  if(verbose_ ){ cout << "rho0=" << rho0 << " niter=" << niter << endl; dump(beta,y,tks,2);}
498 
499 
500  // merge again (some cluster split by outliers collapse here)
501  while(merge(y,tks.size())){}
502  if(verbose_ ){ cout << "dump after 2nd merging " << endl; dump(beta,y,tks,2);}
503 
504 
505  // continue from freeze-out to Tstop (=1) without splitting, eliminate insignificant vertices
506  while(beta<=betastop_){
507  while(purge(y,tks,rho0, beta)){
508  niter=0; while((update(beta, tks,y,rho0) > 1.e-6) && (niter++ < maxIterations_)){ }
509  }
510  beta/=coolingFactor_;
511  niter=0; while((update(beta, tks,y,rho0) > 1.e-6) && (niter++ < maxIterations_)){ }
512  }
513 
514  if(verbose_){
515  cout << "Final result, rho0=" << rho0 << endl;
516  dump(beta,y,tks,2);
517  }
518 
519 
520  // select significant tracks and use a TransientVertex as a container
521  GlobalError dummyError;
522 
523 
524  // ensure correct normalization of probabilities, should makes double assginment reasonably impossible
525  for(unsigned int i=0; i<nt; i++){
526  tks[i].Z=rho0*exp(-beta*dzCutOff_*dzCutOff_);
527  for(vector<vertex_t>::iterator k=y.begin(); k!=y.end(); k++){
528  tks[i].Z+=k->pk * exp(-beta*Eik(tks[i],*k));
529  }
530  }
531 
532 
533  for(vector<vertex_t>::iterator k=y.begin(); k!=y.end(); k++){
534  GlobalPoint pos(0, 0, k->z);
535  vector< reco::TransientTrack > vertexTracks;
536  for(unsigned int i=0; i<nt; i++){
537  if(tks[i].Z>0){
538  double p=k->pk * exp(-beta*Eik(tks[i],*k)) / tks[i].Z;
539  if( (tks[i].pi>0) && ( p > 0.5 ) ){ vertexTracks.push_back(*(tks[i].tt)); tks[i].Z=0; } // setting Z=0 excludes double assignment
540  }
541  }
542  TransientVertex v(pos, dummyError, vertexTracks, 0);
543  clusters.push_back(v);
544  }
545 
546 
547  return clusters;
548 
549 }
const double Z[kNumberCalorimeter]
const double beta
int i
Definition: DBlmapReader.cc:9
std::vector< track_t > fill(const std::vector< reco::TransientTrack > &tracks) const
Exp< T >::type exp(const T &t)
Definition: Exp.h:22
bool merge(std::vector< vertex_t > &, int) const
void splitAll(std::vector< track_t > &tks, std::vector< vertex_t > &y) const
int nt
Definition: AMPTWrapper.h:32
int k[5][pyjets_maxn]
tuple tracks
Definition: testEve_cfg.py:39
void dump(const double beta, const std::vector< vertex_t > &y, const std::vector< track_t > &tks, const int verbosity=0) const
double update(double beta, std::vector< track_t > &tks, std::vector< vertex_t > &y) const
double Eik(const track_t &t, const vertex_t &k) const
tuple cout
Definition: gather_cfg.py:41
double pi
double beta0(const double betamax, std::vector< track_t > &tks, std::vector< vertex_t > &y) const
bool purge(std::vector< vertex_t > &, std::vector< track_t > &, double &, const double) const
mathSSE::Vec4< T > v

Member Data Documentation

float DAClusterizerInZ::betamax_
private

Definition at line 96 of file DAClusterizerInZ.h.

float DAClusterizerInZ::betastop_
private

Definition at line 97 of file DAClusterizerInZ.h.

double DAClusterizerInZ::coolingFactor_
private

Definition at line 95 of file DAClusterizerInZ.h.

double DAClusterizerInZ::d0CutOff_
private

Definition at line 99 of file DAClusterizerInZ.h.

double DAClusterizerInZ::dzCutOff_
private

Definition at line 98 of file DAClusterizerInZ.h.

int DAClusterizerInZ::maxIterations_
private

Definition at line 94 of file DAClusterizerInZ.h.

bool DAClusterizerInZ::verbose_
private

Definition at line 92 of file DAClusterizerInZ.h.

float DAClusterizerInZ::vertexSize_
private

Definition at line 93 of file DAClusterizerInZ.h.