CMS 3D CMS Logo

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

#include <DTSegmentUpdator.h>

Public Member Functions

void calculateT0corr (DTRecSegment2D *seg) const
 
void calculateT0corr (DTRecSegment4D *seg) const
 
 DTSegmentUpdator (const edm::ParameterSet &config)
 Constructor. More...
 
bool fit (DTSegmentCand *seg) const
 
void fit (DTRecSegment2D *seg) const
 
void fit (DTRecSegment4D *seg) const
 
void setES (const edm::EventSetup &setup)
 set the setup More...
 
void update (DTRecSegment4D *seg, const bool calcT0=false) const
 recompute hits position and refit the segment4D More...
 
void update (DTRecSegment2D *seg) const
 recompute hits position and refit the segment2D More...
 
 ~DTSegmentUpdator ()
 Destructor. More...
 

Private Member Functions

void fit (const std::vector< float > &x, const std::vector< float > &y, const std::vector< float > &sigy, LocalPoint &pos, LocalVector &dir, AlgebraicSymMatrix &covMat, double &chi2) const
 interface to LinearFit More...
 
void Fit4Var (const std::vector< float > &xfit, const std::vector< float > &yfit, const std::vector< int > &lfit, const std::vector< double > &tfit, const int nptfit, float &cminf, double &vminf, double &chi2fit) const
 
void rejectBadHits (DTChamberRecSegment2D *) const
 
void updateHits (DTRecSegment2D *seg, GlobalPoint &gpos, GlobalVector &gdir, const int step=2) const
 

Private Attributes

bool debug
 
bool perform_delta_rejecting
 
double T0_hit_resolution
 
DTRecHitBaseAlgotheAlgo
 
DTLinearFittheFitter
 
edm::ESHandle< DTGeometrytheGeom
 
bool vdrift_4parfit
 

Detailed Description

Perform linear fit and hits update for DT segments. Update a segment by improving the hits thanks to the refined knowledge of impact angle and position (also along the wire) and perform linear fit on improved hits.

Author
Stefano Lacaprara - INFN Legnaro stefa.nosp@m.no.l.nosp@m.acapr.nosp@m.ara@.nosp@m.pd.in.nosp@m.fn.i.nosp@m.t
Riccardo Bellan - INFN TO ricca.nosp@m.rdo..nosp@m.bella.nosp@m.n@ce.nosp@m.rn.ch
M.Meneghelli - INFN BO marco.nosp@m..men.nosp@m.eghel.nosp@m.li@c.nosp@m.ern.c.nosp@m.h

Definition at line 40 of file DTSegmentUpdator.h.

Constructor & Destructor Documentation

DTSegmentUpdator::DTSegmentUpdator ( const edm::ParameterSet config)

Constructor.

Definition at line 47 of file DTSegmentUpdator.cc.

References gather_cfg::cout, debug, reco::get(), edm::ParameterSet::getParameter(), and theAlgo.

47  :
48  theFitter(new DTLinearFit()) ,
49  vdrift_4parfit(config.getParameter<bool>("performT0_vdriftSegCorrection")),
50  T0_hit_resolution(config.getParameter<double>("hit_afterT0_resolution")),
51  perform_delta_rejecting(config.getParameter<bool>("perform_delta_rejecting")),
52  debug(config.getUntrackedParameter<bool>("debug",false))
53 {
54  string theAlgoName = config.getParameter<string>("recAlgo");
55  theAlgo = DTRecHitAlgoFactory::get()->create(theAlgoName,
56  config.getParameter<ParameterSet>("recAlgoConfig"));
57 
58  if(debug)
59  cout << "[DTSegmentUpdator] Constructor called" << endl;
60 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
DTLinearFit * theFitter
tuple cout
Definition: gather_cfg.py:121
DTRecHitBaseAlgo * theAlgo
T get(const Candidate &c)
Definition: component.h:55
DTSegmentUpdator::~DTSegmentUpdator ( )

Destructor.

Definition at line 63 of file DTSegmentUpdator.cc.

References theFitter.

63  {
64  delete theFitter;
65 }
DTLinearFit * theFitter

Member Function Documentation

void DTSegmentUpdator::calculateT0corr ( DTRecSegment2D seg) const

Definition at line 549 of file DTSegmentUpdator.cc.

References Fit4Var(), TrackingRecHit::geographicalId(), DTEnums::Left, DTRecSegment2D::setT0(), DTRecSegment2D::setVdrift(), DTRecSegment2D::specificRecHits(), DTLayer::specificTopology(), theGeom, DTTopology::wirePosition(), x, PV3DBase< T, PVType, FrameType >::x(), hit::x, detailsBasic3DVector::y, and PV3DBase< T, PVType, FrameType >::z().

Referenced by calculateT0corr(), DTMeantimerPatternReco4D::reconstruct(), DTCombinatorialPatternReco4D::reconstruct(), and update().

549  {
550  // WARNING: since this method is called both with a 2D and a 2DPhi as argument
551  // seg->geographicalId() can be a superLayerId or a chamberId
552 
553  vector<double> d_drift;
554  vector<float> x;
555  vector<float> y;
556  vector<int> lc;
557 
558  vector<DTRecHit1D> hits=seg->specificRecHits();
559 
560  DTWireId wireId;
561  int nptfit = 0;
562 
563  for (vector<DTRecHit1D>::const_iterator hit=hits.begin();
564  hit!=hits.end(); ++hit) {
565 
566  // I have to get the hits position (the hit is in the layer rf) in SL frame...
567  GlobalPoint glbPos = ( theGeom->layer( hit->wireId().layerId() ) )->toGlobal(hit->localPosition());
568  LocalPoint pos = ( theGeom->idToDet(seg->geographicalId()) )->toLocal(glbPos);
569 
570  const DTLayer* layer = theGeom->layer( hit->wireId().layerId() );
571  float xwire = layer->specificTopology().wirePosition(hit->wireId().wire());
572  float distance = fabs(hit->localPosition().x() - xwire);
573 
574  int ilc = ( hit->lrSide() == DTEnums::Left ) ? 1 : -1;
575 
576  nptfit++;
577  x.push_back(pos.z());
578  y.push_back(pos.x());
579  lc.push_back(ilc);
580  d_drift.push_back(distance);
581 
582  // cout << " d_drift "<<distance <<" npt= " <<npt<<endl;
583  }
584 
585  double chi2fit = 0.;
586  float cminf = 0.;
587  double vminf = 0.;
588 
589  if ( nptfit > 2 ) {
590  //NB chi2fit is normalized
591  Fit4Var(x,y,lc,d_drift,nptfit,cminf,vminf,chi2fit);
592 
593  double t0cor = -999.;
594  if(cminf > -998.) t0cor = - cminf/0.00543 ; // in ns
595 
596  //cout << "In calculateT0corr: t0 = " << t0cor << endl;
597  //cout << "In calculateT0corr: vminf = " << vminf << endl;
598  //cout << "In calculateT0corr: cminf = " << cminf << endl;
599  //cout << "In calculateT0corr: chi2 = " << chi2fit << endl;
600 
601  seg->setT0(t0cor); // time and
602  seg->setVdrift(vminf); // vdrift correction are recorded in the segment
603  }
604 }
float wirePosition(int wireNumber) const
Returns the x position in the layer of a given wire number.
Definition: DTTopology.cc:86
void Fit4Var(const std::vector< float > &xfit, const std::vector< float > &yfit, const std::vector< int > &lfit, const std::vector< double > &tfit, const int nptfit, float &cminf, double &vminf, double &chi2fit) const
edm::ESHandle< DTGeometry > theGeom
const DTTopology & specificTopology() const
Definition: DTLayer.cc:42
T z() const
Definition: PV3DBase.h:64
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
void setT0(const double &t0)
void setVdrift(const double &vdrift)
DetId geographicalId() const
Definition: DDAxes.h:10
T x() const
Definition: PV3DBase.h:62
void DTSegmentUpdator::calculateT0corr ( DTRecSegment4D seg) const

Definition at line 544 of file DTSegmentUpdator.cc.

References calculateT0corr(), DTRecSegment4D::hasPhi(), DTRecSegment4D::hasZed(), DTRecSegment4D::phiSegment(), and DTRecSegment4D::zSegment().

544  {
545  if(seg->hasPhi()) calculateT0corr(seg->phiSegment());
546  if(seg->hasZed()) calculateT0corr(seg->zSegment());
547 }
void calculateT0corr(DTRecSegment2D *seg) const
const DTChamberRecSegment2D * phiSegment() const
The superPhi segment: 0 if no phi projection available.
bool hasPhi() const
Does it have the Phi projection?
bool hasZed() const
Does it have the Z projection?
const DTSLRecSegment2D * zSegment() const
The Z segment: 0 if not zed projection available.
bool DTSegmentUpdator::fit ( DTSegmentCand seg) const

do the linear fit on the hits of the segment candidate and update it. Returns false if the segment candidate is not good()

Definition at line 193 of file DTSegmentUpdator.cc.

References dir, DTSegmentCand::good(), DTSegmentCand::hits(), DTSegmentCand::setChi2(), DTSegmentCand::setCovMatrix(), DTSegmentCand::setDirection(), DTSegmentCand::setPosition(), mathSSE::sqrt(), x, PV3DBase< T, PVType, FrameType >::x(), detailsBasic3DVector::y, and PV3DBase< T, PVType, FrameType >::z().

Referenced by DTMeantimerPatternReco::addHits(), DTCombinatorialPatternReco::buildPointsCollection(), DTCombinatorialExtendedPatternReco::buildPointsCollection(), DTCombinatorialExtendedPatternReco::extendCandidates(), fit(), DTRefitAndCombineReco4D::refitSuperSegments(), and update().

193  {
194  if (!seg->good()) return false;
195 
196  vector<float> x;
197  vector<float> y;
198  vector<float> sigy;
199 
200  DTSegmentCand::AssPointCont hits=seg->hits();
201  for (DTSegmentCand::AssPointCont::const_iterator iter=hits.begin();
202  iter!=hits.end(); ++iter) {
203  LocalPoint pos = (*iter).first->localPosition((*iter).second);
204  x.push_back(pos.z());
205  y.push_back(pos.x());
206  sigy.push_back(sqrt((*iter).first->localPositionError().xx()));
207  }
208 
209  LocalPoint pos;
211  AlgebraicSymMatrix covMat(2);
212 
213  double chi2 = 0.;
214  fit(x,y,sigy,pos,dir,covMat,chi2);
215 
216  seg->setPosition(pos);
217  seg->setDirection(dir);
218 
219  //cout << "pos " << segPosition<< endl;
220  //cout << "dir " << segDirection<< endl;
221 
222  seg->setCovMatrix(covMat);
223  // cout << "Mat " << covMat << endl;
224 
225  seg->setChi2(chi2);
226  return true;
227 }
virtual void setChi2(double &chi2)
set chi2
virtual bool good() const
T sqrt(T t)
Definition: SSEVec.h:48
T z() const
Definition: PV3DBase.h:64
virtual void setCovMatrix(AlgebraicSymMatrix &cov)
set the cov matrix
bool fit(DTSegmentCand *seg) const
virtual AssPointCont hits() const
the used hits
std::set< AssPoint, AssPointLessZ > AssPointCont
Definition: DTSegmentCand.h:39
virtual void setDirection(LocalVector &dir)
set direction
Definition: DTSegmentCand.h:92
CLHEP::HepSymMatrix AlgebraicSymMatrix
dbl *** dir
Definition: mlp_gen.cc:35
virtual void setPosition(LocalPoint &pos)
set position
Definition: DTSegmentCand.h:89
Definition: DDAxes.h:10
T x() const
Definition: PV3DBase.h:62
void DTSegmentUpdator::fit ( DTRecSegment2D seg) const

ditto for true segment: since the fit is applied on a true segment, by definition the segment is "good", while it's not the case for just candidates

Definition at line 229 of file DTSegmentUpdator.cc.

References dir, fit(), TrackingRecHit::geographicalId(), DTRecSegment2D::setChi2(), DTRecSegment2D::setCovMatrix(), DTRecSegment2D::setDirection(), DTRecSegment2D::setPosition(), DTRecSegment2D::specificRecHits(), mathSSE::sqrt(), theGeom, ErrorFrameTransformer::transform(), x, PV3DBase< T, PVType, FrameType >::x(), LocalError::xx(), detailsBasic3DVector::y, and PV3DBase< T, PVType, FrameType >::z().

229  {
230  // WARNING: since this method is called both with a 2D and a 2DPhi as argument
231  // seg->geographicalId() can be a superLayerId or a chamberId
232 
233  vector<float> x;
234  vector<float> y;
235  vector<float> sigy;
236 
237  vector<DTRecHit1D> hits=seg->specificRecHits();
238  for (vector<DTRecHit1D>::const_iterator hit=hits.begin();
239  hit!=hits.end(); ++hit) {
240 
241  // I have to get the hits position (the hit is in the layer rf) in SL frame...
242  GlobalPoint glbPos = ( theGeom->layer( hit->wireId().layerId() ) )->toGlobal(hit->localPosition());
243  LocalPoint pos = ( theGeom->idToDet(seg->geographicalId()) )->toLocal(glbPos);
244 
245  x.push_back(pos.z());
246  y.push_back(pos.x());
247 
248  // Get local error in SL frame
249  //RB: is it right in this way?
251  GlobalError glbErr =
252  tran.transform( hit->localPositionError(),(theGeom->layer( hit->wireId().layerId() ))->surface());
253  LocalError slErr =
254  tran.transform( glbErr, (theGeom->idToDet(seg->geographicalId()))->surface());
255 
256  sigy.push_back(sqrt(slErr.xx()));
257  }
258 
259  LocalPoint pos;
261  AlgebraicSymMatrix covMat(2);
262  double chi2 = 0.;
263 
264  fit(x,y,sigy,pos,dir,covMat,chi2);
265 
266  seg->setPosition(pos);
267  seg->setDirection(dir);
268 
269  //cout << "pos " << segPosition << endl;
270  //cout << "dir " << segDirection << endl;
271 
272  seg->setCovMatrix(covMat);
273  // cout << "Mat " << mat << endl;
274 
275  seg->setChi2(chi2);
276 }
static GlobalError transform(const LocalError &le, const Surface &surf)
float xx() const
Definition: LocalError.h:24
void setChi2(const double &chi2)
void setCovMatrix(const AlgebraicSymMatrix &cov)
edm::ESHandle< DTGeometry > theGeom
T sqrt(T t)
Definition: SSEVec.h:48
T z() const
Definition: PV3DBase.h:64
bool fit(DTSegmentCand *seg) const
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
void setPosition(const LocalPoint &pos)
CLHEP::HepSymMatrix AlgebraicSymMatrix
void setDirection(const LocalVector &dir)
DetId geographicalId() const
dbl *** dir
Definition: mlp_gen.cc:35
Definition: DDAxes.h:10
T x() const
Definition: PV3DBase.h:62
void DTSegmentUpdator::fit ( DTRecSegment4D seg) const

ditto for true segment 4D, the fit is done on either projection and then the 4D direction and position is built. Since the fit is applied on a true segment, by definition the segment is "good", while it's not the case for just candidates

Definition at line 108 of file DTSegmentUpdator.cc.

References DTSuperLayerId::chamberId(), DTRecSegment4D::chamberId(), funct::cos(), dir, fit(), DTRecSegment4D::hasPhi(), DTRecSegment4D::hasZed(), DTRecSegment2D::localDirection(), DTRecSegment2D::localPosition(), DTRecSegment2D::parametersError(), DTRecSegment4D::phiSegment(), DTRecSegment4D::setCovMatrix(), DTRecSegment4D::setCovMatrixForZed(), DTRecSegment4D::setDirection(), DTRecSegment4D::setPosition(), DTChamber::superLayer(), DTSLRecSegment2D::superLayerId(), theGeom, PV3DBase< T, PVType, FrameType >::theta(), GeomDet::toGlobal(), GeomDet::toLocal(), PV3DBase< T, PVType, FrameType >::x(), detailsBasic3DVector::y, PV3DBase< T, PVType, FrameType >::y(), PV3DBase< T, PVType, FrameType >::z(), zPos, and DTRecSegment4D::zSegment().

108  {
109  // after the update must refit the segments
110  if(seg->hasPhi()) fit(seg->phiSegment());
111  if(seg->hasZed()) fit(seg->zSegment());
112 
113  const DTChamber* theChamber = theGeom->chamber(seg->chamberId());
114 
115  if(seg->hasPhi() && seg->hasZed() ) {
116 
117  DTChamberRecSegment2D *segPhi=seg->phiSegment();
118  DTSLRecSegment2D *segZed=seg->zSegment();
119 
120  // NB Phi seg is already in chamber ref
121  LocalPoint posPhiInCh = segPhi->localPosition();
122  LocalVector dirPhiInCh= segPhi->localDirection();
123 
124  // Zed seg is in SL one
125  const DTSuperLayer* zSL = theChamber->superLayer(segZed->superLayerId());
126  LocalPoint zPos(segZed->localPosition().x(),
127  (zSL->toLocal(theChamber->toGlobal(segPhi->localPosition()))).y(),
128  0.);
129 
130  LocalPoint posZInCh = theChamber->toLocal(zSL->toGlobal(zPos));
131 
132  LocalVector dirZInCh = theChamber->toLocal(zSL->toGlobal(segZed->localDirection()));
133 
134  LocalPoint posZAt0 = posZInCh + dirZInCh*(-posZInCh.z())/cos(dirZInCh.theta());
135 
136  // given the actual definition of chamber refFrame, (with z poiniting to IP),
137  // the zed component of direction is negative.
138  LocalVector dir=LocalVector(dirPhiInCh.x()/fabs(dirPhiInCh.z()),dirZInCh.y()/fabs(dirZInCh.z()),-1.);
139 
140  seg->setPosition(LocalPoint(posPhiInCh.x(),posZAt0.y(),0.));
141  seg->setDirection(dir.unit());
142 
143  AlgebraicSymMatrix mat(4);
144 
145  // set cov matrix
146  mat[0][0] = segPhi->parametersError()[0][0]; //sigma (dx/dz)
147  mat[0][2] = segPhi->parametersError()[0][1]; //cov(dx/dz,x)
148  mat[2][2] = segPhi->parametersError()[1][1]; //sigma (x)
149 
150  seg->setCovMatrix(mat);
151  seg->setCovMatrixForZed(posZInCh);
152 
153  }
154 
155  else if (seg->hasPhi()) {
156  DTChamberRecSegment2D *segPhi=seg->phiSegment();
157 
158  seg->setPosition(segPhi->localPosition());
159  seg->setDirection(segPhi->localDirection());
160 
161  AlgebraicSymMatrix mat(4);
162  // set cov matrix
163  mat[0][0] = segPhi->parametersError()[0][0]; //sigma (dx/dz)
164  mat[0][2] = segPhi->parametersError()[0][1]; //cov(dx/dz,x)
165  mat[2][2] = segPhi->parametersError()[1][1]; //sigma (x)
166 
167  seg->setCovMatrix(mat);
168  }
169 
170  else if (seg->hasZed()) {
171  DTSLRecSegment2D *segZed = seg->zSegment();
172 
173  // Zed seg is in SL one
174  GlobalPoint glbPosZ = ( theGeom->superLayer(segZed->superLayerId()) )->toGlobal(segZed->localPosition());
175  LocalPoint posZInCh = ( theGeom->chamber(segZed->superLayerId().chamberId()) )->toLocal(glbPosZ);
176 
177  GlobalVector glbDirZ = (theGeom->superLayer(segZed->superLayerId()) )->toGlobal(segZed->localDirection());
178  LocalVector dirZInCh = (theGeom->chamber(segZed->superLayerId().chamberId()) )->toLocal(glbDirZ);
179 
180  LocalPoint posZAt0 = posZInCh+
181  dirZInCh*(-posZInCh.z())/cos(dirZInCh.theta());
182 
183  seg->setPosition(posZAt0);
184  seg->setDirection(dirZInCh);
185 
186  AlgebraicSymMatrix mat(4);
187  // set cov matrix
188  seg->setCovMatrix(mat);
189  seg->setCovMatrixForZed(posZInCh);
190  }
191 }
Local3DVector LocalVector
Definition: LocalVector.h:12
double zPos
DTChamberId chamberId() const
Return the corresponding ChamberId.
const DTChamberRecSegment2D * phiSegment() const
The superPhi segment: 0 if no phi projection available.
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:47
T y() const
Definition: PV3DBase.h:63
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:62
virtual DTChamberId chamberId() const
The (specific) DetId of the chamber on which the segment resides.
void setCovMatrixForZed(const LocalPoint &posZInCh)
edm::ESHandle< DTGeometry > theGeom
void setCovMatrix(const AlgebraicSymMatrix &mat)
Set covariance matrix.
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
T z() const
Definition: PV3DBase.h:64
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
bool fit(DTSegmentCand *seg) const
void setDirection(LocalVector dir)
Set direction.
bool hasPhi() const
Does it have the Phi projection?
DTSuperLayerId superLayerId() const
The id of the superlayer on which reside the segment.
virtual LocalPoint localPosition() const
local position in SL frame
bool hasZed() const
Does it have the Z projection?
const DTSLRecSegment2D * zSegment() const
The Z segment: 0 if not zed projection available.
virtual AlgebraicSymMatrix parametersError() const
virtual LocalVector localDirection() const
the local direction in SL frame
CLHEP::HepSymMatrix AlgebraicSymMatrix
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
void setPosition(LocalPoint pos)
Set position.
dbl *** dir
Definition: mlp_gen.cc:35
T x() const
Definition: PV3DBase.h:62
const DTSuperLayer * superLayer(DTSuperLayerId id) const
Return the superlayer corresponding to the given id.
Definition: DTChamber.cc:65
void DTSegmentUpdator::fit ( const std::vector< float > &  x,
const std::vector< float > &  y,
const std::vector< float > &  sigy,
LocalPoint pos,
LocalVector dir,
AlgebraicSymMatrix covMat,
double &  chi2 
) const
private

interface to LinearFit

Definition at line 278 of file DTSegmentUpdator.cc.

References DTLinearFit::fit(), i, slope, theFitter, and Vector3DBase< T, FrameTag >::unit().

284  {
285 
286  float slope = 0.;
287  float intercept = 0.;
288  float covss = 0.;
289  float covii = 0.;
290  float covsi = 0.;
291 
292  // do the fit
293  theFitter->fit(x,y,x.size(),sigy,slope,intercept,covss,covii,covsi);
294  // cout << "slope " << slope << endl;
295  // cout << "intercept " << intercept << endl;
296 
297  // intercept is the x() in chamber frame when the segment cross the chamber
298  // plane (at z()=0), the y() is not measured, so let's put the center of the
299  // chamber.
300  pos = LocalPoint(intercept,0.,0.);
301 
302  // slope is dx()/dz(), while dy()/dz() is by definition 0, finally I want the
303  // segment to point outward, so opposite to local z
304  dir = LocalVector(-slope,0.,-1.).unit();
305 
306  covMatrix = AlgebraicSymMatrix(2);
307  covMatrix[0][0] = covss; // this is var(dy/dz)
308  covMatrix[1][1] = covii; // this is var(y)
309  covMatrix[1][0] = covsi; // this is cov(dy/dz,y)
310 
311  /* Calculate chi2. */
312  chi2 = 0.;
313  for(unsigned int i=0; i<x.size() ; ++i) {
314  double resid= y[i] - (intercept + slope*x[i]);
315  chi2 += (resid/sigy[i])*(resid/sigy[i]);
316  }
317 }
int i
Definition: DBlmapReader.cc:9
Local3DVector LocalVector
Definition: LocalVector.h:12
static const double slope[3]
DTLinearFit * theFitter
Vector3DBase unit() const
Definition: Vector3DBase.h:57
void fit(const std::vector< float > &x, const std::vector< float > &y, int ndat, const std::vector< float > &sigy, float &slope, float &intercept, float &covss, float &covii, float &covsi) const
Definition: DTLinearFit.cc:26
CLHEP::HepSymMatrix AlgebraicSymMatrix
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
Definition: DDAxes.h:10
void DTSegmentUpdator::Fit4Var ( const std::vector< float > &  xfit,
const std::vector< float > &  yfit,
const std::vector< int > &  lfit,
const std::vector< double > &  tfit,
const int  nptfit,
float &  cminf,
double &  vminf,
double &  chi2fit 
) const
private

Definition at line 607 of file DTSegmentUpdator.cc.

References a, b, alignmentValidation::c1, gather_cfg::cout, debug, delta, j, and vdrift_4parfit.

Referenced by calculateT0corr().

614  {
615 
616  const double sigma = 0.0295;// errors can be inserted .just load them/that is the usual TB resolution value for DT chambers
617  double aminf = 0.;
618  double bminf = 0.;
619  int nppar = 0;
620  double sx = 0.;
621  double sx2 = 0.;
622  double sy = 0.;
623  double sxy = 0.;
624  double sl = 0.;
625  double sl2 = 0.;
626  double sly = 0.;
627  double slx = 0.;
628  double st = 0.;
629  double st2 = 0.;
630  double slt = 0.;
631  double sltx = 0.;
632  double slty = 0.;
633  double chi2fitN2 = -1. ;
634  double chi2fit3 = -1.;
635  double chi2fitN3 = -1. ;
636  double chi2fitN4 = -1.;
637  float bminf3 = bminf;
638  float aminf3 = aminf;
639  float cminf3 = cminf;
640  int nppar2 = 0;
641  int nppar3 = 0;
642  int nppar4 = 0;
643 
644  cminf = -999.;
645  vminf = 0.;
646 
647  for (int j=0; j<nptfit; j++){
648  sx = sx + xfit[j];
649  sy = sy + yfit[j];
650  sx2 = sx2 + xfit[j]*xfit[j];
651  sxy = sxy + xfit[j]*yfit[j];
652  sl = sl + lfit[j];
653  sl2 = sl2 + lfit[j]*lfit[j];
654  sly = sly + lfit[j]*yfit[j];
655  slx = slx + lfit[j]*xfit[j];
656  st = st + tfit[j];
657  st2 = st2 + tfit[j] * tfit[j];
658  slt = slt + lfit[j] * tfit[j];
659  sltx = sltx + lfit[j] * tfit[j]*xfit[j];
660  slty = slty + lfit[j] * tfit[j]*yfit[j];
661 
662  } //end loop
663 
664  const double delta = nptfit*sx2 - sx*sx;
665 
666  double a = 0.;
667  double b = 0.;
668 
669  if (delta!=0){ //
670  a = (sx2*sy - sx*sxy)/delta;
671  b = (nptfit*sxy - sx*sy)/delta;
672 
673  // cout << " NPAR=2 : slope = "<<b<< " intercept = "<<a <<endl;
674  for (int j=0; j<nptfit; j++){
675  const double ypred = a + b*xfit[j];
676  const double dy = (yfit[j] - ypred)/sigma;
677  chi2fit = chi2fit + dy*dy;
678  } //end loop chi2
679  }
680 
681  bminf = b;
682  aminf = a;
683 
684  nppar = 2;
685  nppar2 = nppar;
686 
687  chi2fitN2 = chi2fit/(nptfit-2);
688 
689  // cout << "dt0 = 0chi2fit = " << chi2fit << " slope = "<<b<<endl;
690 
691  if (nptfit >= 3) {
692 
693  const double d1 = sy;
694  const double d2 = sxy;
695  const double d3 = sly;
696  const double c1 = sl;
697  const double c2 = slx;
698  const double c3 = sl2;
699  const double b1 = sx;
700  const double b2 = sx2;
701  const double b3 = slx;
702  const double a1 = nptfit;
703  const double a2 = sx;
704  const double a3 = sl;
705 
706  //these parameters are not used in the 4-variables fit
707  const double b4 = b2*a1-b1*a2;
708  const double c4 = c2*a1-c1*a2;
709  const double d4 = d2*a1-d1*a2;
710  const double b5 = a1*b3-a3*b1;
711  const double c5 = a1*c3-a3*c1;
712  const double d5 = a1*d3-d1*a3;
713  const double a6 = slt;
714  const double b6 = sltx;
715  const double c6 = st;
716  const double v6 = st2;
717  const double d6 = slty;
718 
719  if (((c5*b4-c4*b5)*b4*a1)!=0) {
720  nppar = 3;
721  chi2fit = 0.;
722  cminf = (d5*b4-d4*b5)/(c5*b4-c4*b5);
723  bminf = d4/b4 -cminf *c4/b4;
724  aminf = (d1/a1 -cminf*c1/a1 -bminf*b1/a1);
725 
726  for (int j=0; j<nptfit; j++){
727  const double ypred = aminf + bminf*xfit[j];
728  const double dy = (yfit[j]-cminf*lfit[j] - ypred)/sigma;
729  chi2fit = chi2fit + dy*dy;
730 
731  } //end loop chi2
732  chi2fit3 = chi2fit;
733  if (nptfit>3)
734  chi2fitN3 = chi2fit /(nptfit-3);
735 
736  }
737  else {
738  cminf = -999.;
739  bminf = b;
740  aminf = a;
741  chi2fit3 = chi2fit;
742  chi2fitN3 = chi2fit /(nptfit-2);
743  }
744 
745  bminf3 = bminf;
746  aminf3 = aminf;
747  cminf3 = cminf;
748  nppar3 = nppar;
749 
750  if (debug) {
751  cout << "dt0= 0 : slope 2 = " << b << " pos in = " << a << " chi2fitN2 = " << chi2fitN2
752  << " nppar = " << nppar2 << " nptfit = " << nptfit << endl;
753  cout << "dt0 = 0 : slope 3 = " << bminf << " pos out = " << aminf << " chi2fitN3 = "
754  << chi2fitN3 << " nppar = " << nppar3 << " T0_ev ns = " << cminf/0.00543 << endl;
755  }
756 
757  //***********************************
758  // cout << " vdrift_4parfit "<< vdrift_4parfit<<endl;
759  if( nptfit>=5) {
760  const double det = (a1*a1*(b2*v6 - b6*b6) - a1*(a2*a2*v6 - 2*a2*a6*b6 + a6*a6*b2 + b2*c6*c6 + b3*(b3*v6 - 2*b6*c6))
761  + a2*a2*c6*c6 + 2*a2*(a3*(b3*v6 - b6*c6) - a6*b3*c6) + a3*a3*(b6*b6 - b2*v6)
762  + a6*(2*a3*(b2*c6 - b3*b6) + a6*b3*b3));
763 
764  // the dv/vdrift correction may be computed under vdrift_4parfit request;
765  if (det != 0) {
766  nppar = 4;
767  chi2fit = 0.;
768  // computation of a, b, c e v
769  aminf = (a1*(a2*(b6*d6 - v6*d2) + a6*(b6*d2 - b2*d6) + d1*(b2*v6 - b6*b6)) - a2*(b3*(c6*d6 - v6*d3)
770  + c6*(b6*d3 - c6*d2)) + a3*(b2*(c6*d6 - v6*d3) + b3*(v6*d2 - b6*d6) + b6*(b6*d3 - c6*d2))
771  + a6*(b2*c6*d3 + b3*(b3*d6 - b6*d3 - c6*d2)) - d1*(b2*c6*c6 + b3*(b3*v6 - 2*b6*c6)))/det;
772  bminf = - (a1*a1*(b6*d6 - v6*d2) - a1*(a2*(a6*d6 - v6*d1) - a6*a6*d2 + a6*b6*d1 + b3*(c6*d6 - v6*d3)
773  + c6*(b6*d3 - c6*d2)) + a2*(a3*(c6*d6 - v6*d3) + c6*(a6*d3 - c6*d1)) + a3*a3*(v6*d2 - b6*d6)
774  + a3*(a6*(b3*d6 + b6*d3 - 2*c6*d2) - d1*(b3*v6 - b6*c6)) - a6*b3*(a6*d3 - c6*d1))/det;
775  cminf = -(a1*(b2*(c6*d6 - v6*d3) + b3*(v6*d2 - b6*d6) + b6*(b6*d3 - c6*d2)) + a2*a2*(v6*d3 - c6*d6)
776  + a2*(a3*(b6*d6 - v6*d2) + a6*(b3*d6 - 2*b6*d3 + c6*d2) - d1*(b3*v6 - b6*c6))
777  + a3*(d1*(b2*v6 - b6*b6) - a6*(b2*d6 - b6*d2)) + a6*(a6*(b2*d3 - b3*d2) - d1*(b2*c6 - b3*b6)))/det;
778  vminf = - (a1*a1*(b2*d6 - b6*d2) - a1*(a2*a2*d6 - a2*(a6*d2 + b6*d1) + a6*b2*d1 + b2*c6*d3
779  + b3*(b3*d6 - b6*d3 - c6*d2)) + a2*a2*c6*d3 + a2*(a3*(2*b3*d6 - b6*d3 - c6*d2) - b3*(a6*d3 + c6*d1))
780  + a3*a3*(b6*d2 - b2*d6) + a3*(a6*(b2*d3 - b3*d2) + d1*(b2*c6 - b3*b6)) + a6*b3*b3*d1)/det;
781 
782  // chi 2
783  for (int j=0; j<nptfit; j++) {
784  const double ypred = aminf + bminf*xfit[j];
785  const double dy = (yfit[j]+vminf*lfit[j]*tfit[j]-cminf*lfit[j] -ypred)/sigma;
786  chi2fit = chi2fit + dy*dy;
787 
788  } //end loop chi2
789  if (nptfit<=nppar){
790  chi2fitN4=-1;
791  // cout << "nptfit " << nptfit << " nppar " << nppar << endl;
792  }
793  else{
794  chi2fitN4= chi2fit / (nptfit-nppar);
795  }
796  }
797  else {
798  vminf = 0.;
799 
800  if (nptfit <= nppar) chi2fitN4=-1;
801  else chi2fitN4 = chi2fit / (nptfit-nppar);
802  }
803 
804  if (fabs(vminf) >= 0.29) {
805  // for safety and for code construction..dont accept correction on dv/vdrift greater then 0.09
806  vminf = 0.;
807  cminf = cminf3;
808  aminf = aminf3;
809  bminf = bminf3;
810  nppar = 3;
811  chi2fit = chi2fit3;
812  }
813 
814  } //end if vdrift
815 
816  if(!vdrift_4parfit){ //if not required explicitly leave the t0 and track step as at step 3
817  // just update vdrift value vmin for storing in the segments for monitoring
818  cminf = cminf3;
819  aminf = aminf3;
820  bminf = bminf3;
821  nppar = 3;
822  chi2fit = chi2fit3;
823  }
824 
825  nppar4 = nppar;
826 
827  } //end nptfit >=3
828 
829  if (debug) {
830  cout << " dt0= 0 : slope 4 = " << bminf << " pos out = " << aminf <<" chi2fitN4 = " << chi2fitN4
831  << " nppar= " << nppar4 << " T0_ev ns= " << cminf/0.00543 <<" delta v = " << vminf <<endl;
832  cout << nptfit << " nptfit " << " end chi2fit = " << chi2fit/ (nptfit-nppar ) << " T0_ev ns= " << cminf/0.00543 << " delta v = " << vminf <<endl;
833  }
834 
835  if ( fabs(vminf) >= 0.09 && debug ) { //checks only vdrift less then 10 % accepted
836  cout << "vminf gt 0.09 det= " << endl;
837  cout << "dt0= 0 : slope 4 = "<< bminf << " pos out = " << aminf << " chi2fitN4 = " << chi2fitN4
838  << " T0_ev ns = " << cminf/0.00543 << " delta v = "<< vminf << endl;
839  cout << "dt0 = 0 : slope 2 = "<< b << " pos in = " << a <<" chi2fitN2 = " << chi2fitN2
840  << " nppar = " << nppar-1 << " nptfit = " << nptfit <<endl;
841  cout << "dt0 = 0 : slope 3 = " << bminf << " pos out = " << aminf << " chi2fitN3 = "
842  << chi2fitN3 << " T0_ev ns = " << cminf/0.00543 << endl;
843  cout << nptfit <<" nptfit "<< " end chi2fit = " << chi2fit << "T0_ev ns= " << cminf/0.00543 << "delta v = "<< vminf <<endl;
844  }
845 
846  if (nptfit != nppar) chi2fit = chi2fit / (nptfit-nppar);
847 }
dbl * delta
Definition: mlp_gen.cc:36
int j
Definition: DBlmapReader.cc:9
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
tuple cout
Definition: gather_cfg.py:121
void DTSegmentUpdator::rejectBadHits ( DTChamberRecSegment2D phiSeg) const
private

Definition at line 406 of file DTSegmentUpdator.cc.

References gather_cfg::cout, debug, delta, TrackingRecHit::geographicalId(), i, N, DTRecSegment2D::specificRecHits(), theGeom, DTRecSegment2D::update(), x, PV3DBase< T, PVType, FrameType >::x(), detailsBasic3DVector::y, and PV3DBase< T, PVType, FrameType >::z().

Referenced by update().

406  {
407 
408  vector<float> x;
409  vector<float> y;
410 
411  if(debug) cout << " Inside the segment updator, now loop on hits: ( x == z_loc , y == x_loc) " << endl;
412 
413  vector<DTRecHit1D> hits = phiSeg->specificRecHits();
414  for (vector<DTRecHit1D>::const_iterator hit=hits.begin();
415  hit!=hits.end(); ++hit) {
416 
417  // I have to get the hits position (the hit is in the layer rf) in SL frame...
418  GlobalPoint glbPos = ( theGeom->layer( hit->wireId().layerId() ) )->toGlobal(hit->localPosition());
419  LocalPoint pos = ( theGeom->idToDet(phiSeg->geographicalId()) )->toLocal(glbPos);
420 
421  x.push_back(pos.z());
422  y.push_back(pos.x());
423  }
424 
425  if(debug){
426  cout << " end of segment! " << endl;
427  cout << " size = Number of Hits: " << x.size() << " " << y.size() << endl;
428  }
429 
430  // Perform the 2 par fit:
431  float par[2]={0.,0.}; // q , m
432 
433  //variables to perform the fit:
434  float Sx = 0.;
435  float Sy = 0.;
436  float Sx2 = 0.;
437  float Sy2 = 0.;
438  float Sxy = 0.;
439 
440  size_t N = x.size();
441 
442  if (N == 0)
443  return;
444 
445  for(size_t i = 0; i < N;++i){
446  Sx += x.at(i);
447  Sy += y.at(i);
448  Sx2 += x.at(i)*x.at(i);
449  Sy2 += y.at(i)*y.at(i);
450  Sxy += x.at(i)*y.at(i);
451 
452  }
453 
454  const float delta = N*Sx2 - Sx*Sx;
455  par[0] = ( Sx2*Sy - Sx*Sxy )/delta;
456  par[1] = ( N*Sxy - Sx*Sy )/delta;
457 
458  if(debug) cout << "fit 2 parameters done ----> par0: "<< par[0] << " par1: "<< par[1] << endl;
459 
460  // Calc residuals:
461  float residuals[N];
462 
463  for(size_t i = 0; i < N;++i)
464  residuals[i] = 0;
465 
466  for(size_t i = 0; i < N;++i){
467  residuals[i] = y.at(i) - par[1]*x.at(i) - par[0];
468  if(debug){
469  cout<<" i: "<<i<<" y_i "<<y.at(i)<<" x_i "<<x.at(i)<<" res_i "<<residuals[i];
470  if (i==N-1) cout<<endl;
471  }
472  }
473 
474  if(debug) cout << " Residuals computed! "<< endl;
475 
476 
477  // Perform bad hit rejecting -- update hits
478  vector<DTRecHit1D> updatedRecHits;
479 
480  float mean_residual = 0.; //mean of the absolute values of residuals
481 
482  for (size_t i = 0; i < N; ++i)
483  mean_residual += fabs(residuals[i]);
484 
485  mean_residual = mean_residual/(N - 2);
486 
487  if(debug) cout << " mean_residual: "<< mean_residual << endl;
488 
489  int i = 0;
490 
491  for (vector<DTRecHit1D>::const_iterator hit=hits.begin();
492  hit!=hits.end(); ++hit) {
493 
494  DTRecHit1D newHit1D = (*hit);
495 
496  float normResidual = mean_residual > 0 ? fabs(residuals[i])/mean_residual : 0;
497  if(normResidual < 1.5){
498 
499  updatedRecHits.push_back(newHit1D);
500  if(debug) cout << " accepted "<< i+1 << "th hit" <<" Irej: " << normResidual << endl;
501  ++i;
502  }
503  else {
504  if(debug) cout << " rejected "<< i+1 << "th hit" <<" Irej: " << normResidual << endl;
505  ++i;
506  continue;
507  }
508  }
509 
510  phiSeg->update(updatedRecHits);
511 
512  //final check!
513  if(debug){
514 
515  vector<float> x_upd;
516  vector<float> y_upd;
517 
518  cout << " Check the update action: " << endl;
519 
520  vector<DTRecHit1D> hits_upd = phiSeg->specificRecHits();
521  for (vector<DTRecHit1D>::const_iterator hit=hits_upd.begin();
522  hit!=hits_upd.end(); ++hit) {
523 
524  // I have to get the hits position (the hit is in the layer rf) in SL frame...
525  GlobalPoint glbPos = ( theGeom->layer( hit->wireId().layerId() ) )->toGlobal(hit->localPosition());
526  LocalPoint pos = ( theGeom->idToDet(phiSeg->geographicalId()) )->toLocal(glbPos);
527 
528  x_upd.push_back(pos.z());
529  y_upd.push_back(pos.x());
530 
531  cout << " x_upd: "<< pos.z() << " y_upd: "<< pos.x() << endl;
532 
533 
534  }
535 
536  cout << " end of segment! " << endl;
537  cout << " size = Number of Hits: " << x_upd.size() << " " << y_upd.size() << endl;
538 
539  }// end debug
540 
541  return;
542 } //end DTSegmentUpdator::rejectBadHits
dbl * delta
Definition: mlp_gen.cc:36
int i
Definition: DBlmapReader.cc:9
void update(std::vector< DTRecHit1D > &updatedRecHits)
edm::ESHandle< DTGeometry > theGeom
T z() const
Definition: PV3DBase.h:64
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
#define N
Definition: blowfish.cc:9
tuple cout
Definition: gather_cfg.py:121
DetId geographicalId() const
Definition: DDAxes.h:10
T x() const
Definition: PV3DBase.h:62
void DTSegmentUpdator::setES ( const edm::EventSetup setup)

set the setup

Definition at line 69 of file DTSegmentUpdator.cc.

References edm::EventSetup::get(), DTRecHitBaseAlgo::setES(), theAlgo, and theGeom.

Referenced by DTCombinatorialPatternReco4D::setES(), DTMeantimerPatternReco4D::setES(), DTRefitAndCombineReco4D::setES(), DTCombinatorialPatternReco::setES(), DTCombinatorialExtendedPatternReco::setES(), and DTMeantimerPatternReco::setES().

69  {
70  setup.get<MuonGeometryRecord>().get(theGeom);
71  theAlgo->setES(setup);
72 }
edm::ESHandle< DTGeometry > theGeom
virtual void setES(const edm::EventSetup &setup)=0
Pass the Event Setup to the algo at each event.
const T & get() const
Definition: EventSetup.h:55
DTRecHitBaseAlgo * theAlgo
void DTSegmentUpdator::update ( DTRecSegment4D seg,
const bool  calcT0 = false 
) const

recompute hits position and refit the segment4D

Definition at line 74 of file DTSegmentUpdator.cc.

References calculateT0corr(), gather_cfg::cout, debug, dir, fit(), TrackingRecHit::geographicalId(), DTRecSegment4D::hasPhi(), DTRecSegment4D::hasZed(), DTRecSegment4D::localDirection(), DTRecSegment4D::localPosition(), perform_delta_rejecting, DTRecSegment4D::phiSegment(), rejectBadHits(), relval_parameters_module::step, theGeom, updateHits(), and DTRecSegment4D::zSegment().

Referenced by progressbar.ProgressBar::__next__(), relval_steps.Matrix::__setitem__(), relval_steps.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(), relval_steps.Steps::overwrite(), DTMeantimerPatternReco4D::reconstruct(), DTCombinatorialPatternReco4D::reconstruct(), DTRefitAndCombineReco4D::reconstruct(), DTCombinatorialPatternReco::reconstruct(), DTCombinatorialExtendedPatternReco::reconstruct(), DTMeantimerPatternReco::reconstruct(), 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().

74  {
75 
76  if(debug) cout << "[DTSegmentUpdator] Starting to update the segment" << endl;
77 
78  const bool hasPhi = seg->hasPhi();
79  const bool hasZed = seg->hasZed();
80 
81  //reject the bad hits (due to delta rays)
82  if(perform_delta_rejecting && hasPhi) rejectBadHits(seg->phiSegment());
83 
84  int step = (hasPhi && hasZed) ? 3 : 2;
85  if(calcT0) step = 4;
86 
87  if(debug) cout << "Step of update is " << step << endl;
88 
89  GlobalPoint pos = theGeom->idToDet(seg->geographicalId())->toGlobal(seg->localPosition());
90  GlobalVector dir = theGeom->idToDet(seg->geographicalId())->toGlobal(seg->localDirection());
91 
92  if(calcT0) calculateT0corr(seg);
93 
94  if(hasPhi) updateHits(seg->phiSegment(),pos,dir,step);
95  if(hasZed) updateHits(seg->zSegment() ,pos,dir,step);
96 
97  fit(seg);
98 }
void rejectBadHits(DTChamberRecSegment2D *) const
void updateHits(DTRecSegment2D *seg, GlobalPoint &gpos, GlobalVector &gdir, const int step=2) const
void calculateT0corr(DTRecSegment2D *seg) const
const DTChamberRecSegment2D * phiSegment() const
The superPhi segment: 0 if no phi projection available.
edm::ESHandle< DTGeometry > theGeom
virtual LocalVector localDirection() const
Local direction in Chamber frame.
bool fit(DTSegmentCand *seg) const
bool hasPhi() const
Does it have the Phi projection?
virtual LocalPoint localPosition() const
Local position in Chamber frame.
bool hasZed() const
Does it have the Z projection?
const DTSLRecSegment2D * zSegment() const
The Z segment: 0 if not zed projection available.
tuple cout
Definition: gather_cfg.py:121
DetId geographicalId() const
dbl *** dir
Definition: mlp_gen.cc:35
void DTSegmentUpdator::update ( DTRecSegment2D seg) const

recompute hits position and refit the segment2D

Definition at line 100 of file DTSegmentUpdator.cc.

References dir, fit(), TrackingRecHit::geographicalId(), DTRecSegment2D::localDirection(), DTRecSegment2D::localPosition(), theGeom, and updateHits().

Referenced by progressbar.ProgressBar::__next__(), relval_steps.Matrix::__setitem__(), relval_steps.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(), relval_steps.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().

100  {
101  GlobalPoint pos = (theGeom->idToDet(seg->geographicalId()))->toGlobal(seg->localPosition());
102  GlobalVector dir = (theGeom->idToDet(seg->geographicalId()))->toGlobal(seg->localDirection());
103 
104  updateHits(seg,pos,dir);
105  fit(seg);
106 }
void updateHits(DTRecSegment2D *seg, GlobalPoint &gpos, GlobalVector &gdir, const int step=2) const
edm::ESHandle< DTGeometry > theGeom
bool fit(DTSegmentCand *seg) const
virtual LocalPoint localPosition() const
local position in SL frame
virtual LocalVector localDirection() const
the local direction in SL frame
DetId geographicalId() const
dbl *** dir
Definition: mlp_gen.cc:35
void DTSegmentUpdator::updateHits ( DTRecSegment2D seg,
GlobalPoint gpos,
GlobalVector gdir,
const int  step = 2 
) const
private

Definition at line 321 of file DTSegmentUpdator.cc.

References angle(), DTRecHitBaseAlgo::compute(), funct::cos(), relativeConstraints::error, edm::hlt::Exception, DTRecSegment2D::ist0Valid(), DTEnums::Left, convertSQLiteXML::ok, point, DTRecSegment2D::specificRecHits(), DTLayer::specificTopology(), DTRecSegment2D::t0(), T0_hit_resolution, theAlgo, theGeom, PV3DBase< T, PVType, FrameType >::theta(), GeomDet::toLocal(), DTRecSegment2D::update(), DTRecSegment2D::vDrift(), vdrift_4parfit, DTTopology::wirePosition(), PV3DBase< T, PVType, FrameType >::x(), hit::x, and PV3DBase< T, PVType, FrameType >::z().

Referenced by update().

322  {
323 
324  // it is not necessary to have DTRecHit1D* to modify the obj in the container
325  // but I have to be carefully, since I cannot make a copy before the iteration!
326 
327  vector<DTRecHit1D> toBeUpdatedRecHits = seg->specificRecHits();
328  vector<DTRecHit1D> updatedRecHits;
329 
330  for (vector<DTRecHit1D>::iterator hit= toBeUpdatedRecHits.begin();
331  hit!=toBeUpdatedRecHits.end(); ++hit) {
332 
333  const DTLayer* layer = theGeom->layer( hit->wireId().layerId() );
334 
335  LocalPoint segPos=layer->toLocal(gpos);
336  LocalVector segDir=layer->toLocal(gdir);
337 
338  // define impact angle needed by the step 2
339  const float angle = atan(segDir.x()/-segDir.z());
340 
341  // define the local position (extr.) of the segment. Needed by the third step
342  LocalPoint segPosAtLayer=segPos+segDir*(-segPos.z())/cos(segDir.theta());
343 
344  DTRecHit1D newHit1D = (*hit);
345 
346  bool ok = true;
347 
348  if (step == 2) {
349  ok = theAlgo->compute(layer,*hit,angle,newHit1D);
350 
351  } else if (step == 3) {
352 
353  LocalPoint hitPos(hit->localPosition().x(),+segPosAtLayer.y(),0.);
354 
355  GlobalPoint glbpos= theGeom->layer( hit->wireId().layerId() )->toGlobal(hitPos);
356 
357  newHit1D.setPosition(hitPos);
358 
359  ok = theAlgo->compute(layer,*hit,angle,glbpos,newHit1D);
360 
361  } else if (step == 4) {
362 
363  //const double vminf = seg->vDrift(); // vdrift correction are recorded in the segment
364  double vminf =0.;
365  if(vdrift_4parfit) vminf = seg->vDrift(); // use vdrift recorded in the segment only if vdrift_4parfit=True
366 
367  double cminf = 0.;
368  if(seg->ist0Valid()) cminf = - seg->t0()*0.00543;
369 
370  //cout << "In updateHits: t0 = " << seg->t0() << endl;
371  //cout << "In updateHits: vminf = " << vminf << endl;
372  //cout << "In updateHits: cminf = " << cminf << endl;
373 
374  const float xwire = layer->specificTopology().wirePosition(hit->wireId().wire());
375  const float distance = fabs(hit->localPosition().x() - xwire);
376 
377  const int ilc = ( hit->lrSide() == DTEnums::Left ) ? 1 : -1;
378 
379  const double dy_corr = (vminf*ilc*distance-cminf*ilc );
380 
381  LocalPoint point(hit->localPosition().x() + dy_corr, +segPosAtLayer.y(), 0.);
382 
383  //double final_hit_resol = T0_hit_resolution;
384  //if(newHit1D.wireId().layerId().superlayerId().superLayer() != 2) final_hit_resol = final_hit_resol * 0.8;
385  //LocalError error(final_hit_resol * final_hit_resol,0.,0.);
386 
388 
389  newHit1D.setPositionAndError(point, error);
390 
391  //FIXME: check that the hit is still inside the cell
392  ok = true;
393 
394  } else throw cms::Exception("DTSegmentUpdator")<<" updateHits called with wrong step " << endl;
395 
396  if (ok) updatedRecHits.push_back(newHit1D);
397  else {
398  LogError("DTSegmentUpdator")<<"DTSegmentUpdator::updateHits failed update" << endl;
399  throw cms::Exception("DTSegmentUpdator")<<"updateHits failed update"<<endl;
400  }
401 
402  }
403  seg->update(updatedRecHits);
404 }
float wirePosition(int wireNumber) const
Returns the x position in the layer of a given wire number.
Definition: DTTopology.cc:86
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
Definition: GeomDet.h:62
void update(std::vector< DTRecHit1D > &updatedRecHits)
edm::ESHandle< DTGeometry > theGeom
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
const DTTopology & specificTopology() const
Definition: DTLayer.cc:42
double vDrift() const
T z() const
Definition: PV3DBase.h:64
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
virtual bool compute(const DTLayer *layer, const DTDigi &digi, LocalPoint &leftPoint, LocalPoint &rightPoint, LocalError &error) const =0
std::vector< DTRecHit1D > specificRecHits() const
Access to specific components.
bool ist0Valid() const
double t0() const
Get the segment t0 (if recomputed, 0 is returned otherwise)
T x() const
Definition: PV3DBase.h:62
DTRecHitBaseAlgo * theAlgo
*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
T angle(T x1, T y1, T z1, T x2, T y2, T z2)
Definition: angle.h:11

Member Data Documentation

bool DTSegmentUpdator::debug
private

Definition at line 114 of file DTSegmentUpdator.h.

Referenced by DTSegmentUpdator(), Fit4Var(), rejectBadHits(), and update().

bool DTSegmentUpdator::perform_delta_rejecting
private

Definition at line 113 of file DTSegmentUpdator.h.

Referenced by update().

double DTSegmentUpdator::T0_hit_resolution
private

Definition at line 112 of file DTSegmentUpdator.h.

Referenced by updateHits().

DTRecHitBaseAlgo* DTSegmentUpdator::theAlgo
private

Definition at line 83 of file DTSegmentUpdator.h.

Referenced by DTSegmentUpdator(), setES(), and updateHits().

DTLinearFit* DTSegmentUpdator::theFitter
private

Definition at line 82 of file DTSegmentUpdator.h.

Referenced by fit(), and ~DTSegmentUpdator().

edm::ESHandle<DTGeometry> DTSegmentUpdator::theGeom
private

Definition at line 84 of file DTSegmentUpdator.h.

Referenced by calculateT0corr(), fit(), rejectBadHits(), setES(), update(), and updateHits().

bool DTSegmentUpdator::vdrift_4parfit
private

Definition at line 111 of file DTSegmentUpdator.h.

Referenced by Fit4Var(), and updateHits().