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.

Date:
2011/09/21 15:29:59
Revision:
1.19
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 42 of file DTSegmentUpdator.h.

Constructor & Destructor Documentation

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

Constructor.

Definition at line 49 of file DTSegmentUpdator.cc.

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

49  :
50  theFitter(new DTLinearFit()) ,
51  vdrift_4parfit(config.getParameter<bool>("performT0_vdriftSegCorrection")),
52  T0_hit_resolution(config.getParameter<double>("hit_afterT0_resolution")),
53  perform_delta_rejecting(config.getParameter<bool>("perform_delta_rejecting")),
54  debug(config.getUntrackedParameter<bool>("debug",false))
55 {
56  string theAlgoName = config.getParameter<string>("recAlgo");
57  theAlgo = DTRecHitAlgoFactory::get()->create(theAlgoName,
58  config.getParameter<ParameterSet>("recAlgoConfig"));
59 
60  if(debug)
61  cout << "[DTSegmentUpdator] Constructor called" << endl;
62 }
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:56
DTSegmentUpdator::~DTSegmentUpdator ( )

Destructor.

Definition at line 65 of file DTSegmentUpdator.cc.

References theFitter.

65  {
66  delete theFitter;
67 }
DTLinearFit * theFitter

Member Function Documentation

void DTSegmentUpdator::calculateT0corr ( DTRecSegment2D seg) const

Definition at line 548 of file DTSegmentUpdator.cc.

References Fit4Var(), TrackingRecHit::geographicalId(), DTEnums::Left, pos, 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().

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

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

543  {
544  if(seg->hasPhi()) calculateT0corr(seg->phiSegment());
545  if(seg->hasZed()) calculateT0corr(seg->zSegment());
546 }
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 195 of file DTSegmentUpdator.cc.

References dir, DTSegmentCand::good(), DTSegmentCand::hits(), pos, 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().

195  {
196  if (!seg->good()) return false;
197 
198  vector<float> x;
199  vector<float> y;
200  vector<float> sigy;
201 
202  DTSegmentCand::AssPointCont hits=seg->hits();
203  for (DTSegmentCand::AssPointCont::const_iterator iter=hits.begin();
204  iter!=hits.end(); ++iter) {
205  LocalPoint pos = (*iter).first->localPosition((*iter).second);
206  x.push_back(pos.z());
207  y.push_back(pos.x());
208  sigy.push_back(sqrt((*iter).first->localPositionError().xx()));
209  }
210 
211  LocalPoint pos;
213  AlgebraicSymMatrix covMat(2);
214 
215  double chi2 = 0.;
216  fit(x,y,sigy,pos,dir,covMat,chi2);
217 
218  seg->setPosition(pos);
219  seg->setDirection(dir);
220 
221  //cout << "pos " << segPosition<< endl;
222  //cout << "dir " << segDirection<< endl;
223 
224  seg->setCovMatrix(covMat);
225  // cout << "Mat " << covMat << endl;
226 
227  seg->setChi2(chi2);
228  return true;
229 }
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:41
virtual void setDirection(LocalVector &dir)
set direction
Definition: DTSegmentCand.h:94
CLHEP::HepSymMatrix AlgebraicSymMatrix
dbl *** dir
Definition: mlp_gen.cc:35
virtual void setPosition(LocalPoint &pos)
set position
Definition: DTSegmentCand.h:91
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 231 of file DTSegmentUpdator.cc.

References dir, fit(), TrackingRecHit::geographicalId(), pos, 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().

231  {
232  // WARNING: since this method is called both with a 2D and a 2DPhi as argument
233  // seg->geographicalId() can be a superLayerId or a chamberId
234 
235  vector<float> x;
236  vector<float> y;
237  vector<float> sigy;
238 
239  vector<DTRecHit1D> hits=seg->specificRecHits();
240  for (vector<DTRecHit1D>::const_iterator hit=hits.begin();
241  hit!=hits.end(); ++hit) {
242 
243  // I have to get the hits position (the hit is in the layer rf) in SL frame...
244  GlobalPoint glbPos = ( theGeom->layer( hit->wireId().layerId() ) )->toGlobal(hit->localPosition());
245  LocalPoint pos = ( theGeom->idToDet(seg->geographicalId()) )->toLocal(glbPos);
246 
247  x.push_back(pos.z());
248  y.push_back(pos.x());
249 
250  // Get local error in SL frame
251  //RB: is it right in this way?
253  GlobalError glbErr =
254  tran.transform( hit->localPositionError(),(theGeom->layer( hit->wireId().layerId() ))->surface());
255  LocalError slErr =
256  tran.transform( glbErr, (theGeom->idToDet(seg->geographicalId()))->surface());
257 
258  sigy.push_back(sqrt(slErr.xx()));
259  }
260 
261  LocalPoint pos;
263  AlgebraicSymMatrix covMat(2);
264  double chi2 = 0.;
265 
266  fit(x,y,sigy,pos,dir,covMat,chi2);
267 
268  seg->setPosition(pos);
269  seg->setDirection(dir);
270 
271  //cout << "pos " << segPosition << endl;
272  //cout << "dir " << segDirection << endl;
273 
274  seg->setCovMatrix(covMat);
275  // cout << "Mat " << mat << endl;
276 
277  seg->setChi2(chi2);
278 }
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 110 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().

110  {
111  // after the update must refit the segments
112  if(seg->hasPhi()) fit(seg->phiSegment());
113  if(seg->hasZed()) fit(seg->zSegment());
114 
115  const DTChamber* theChamber = theGeom->chamber(seg->chamberId());
116 
117  if(seg->hasPhi() && seg->hasZed() ) {
118 
119  DTChamberRecSegment2D *segPhi=seg->phiSegment();
120  DTSLRecSegment2D *segZed=seg->zSegment();
121 
122  // NB Phi seg is already in chamber ref
123  LocalPoint posPhiInCh = segPhi->localPosition();
124  LocalVector dirPhiInCh= segPhi->localDirection();
125 
126  // Zed seg is in SL one
127  const DTSuperLayer* zSL = theChamber->superLayer(segZed->superLayerId());
128  LocalPoint zPos(segZed->localPosition().x(),
129  (zSL->toLocal(theChamber->toGlobal(segPhi->localPosition()))).y(),
130  0.);
131 
132  LocalPoint posZInCh = theChamber->toLocal(zSL->toGlobal(zPos));
133 
134  LocalVector dirZInCh = theChamber->toLocal(zSL->toGlobal(segZed->localDirection()));
135 
136  LocalPoint posZAt0 = posZInCh + dirZInCh*(-posZInCh.z())/cos(dirZInCh.theta());
137 
138  // given the actual definition of chamber refFrame, (with z poiniting to IP),
139  // the zed component of direction is negative.
140  LocalVector dir=LocalVector(dirPhiInCh.x()/fabs(dirPhiInCh.z()),dirZInCh.y()/fabs(dirZInCh.z()),-1.);
141 
142  seg->setPosition(LocalPoint(posPhiInCh.x(),posZAt0.y(),0.));
143  seg->setDirection(dir.unit());
144 
145  AlgebraicSymMatrix mat(4);
146 
147  // set cov matrix
148  mat[0][0] = segPhi->parametersError()[0][0]; //sigma (dx/dz)
149  mat[0][2] = segPhi->parametersError()[0][1]; //cov(dx/dz,x)
150  mat[2][2] = segPhi->parametersError()[1][1]; //sigma (x)
151 
152  seg->setCovMatrix(mat);
153  seg->setCovMatrixForZed(posZInCh);
154 
155  }
156 
157  else if (seg->hasPhi()) {
158  DTChamberRecSegment2D *segPhi=seg->phiSegment();
159 
160  seg->setPosition(segPhi->localPosition());
161  seg->setDirection(segPhi->localDirection());
162 
163  AlgebraicSymMatrix mat(4);
164  // set cov matrix
165  mat[0][0] = segPhi->parametersError()[0][0]; //sigma (dx/dz)
166  mat[0][2] = segPhi->parametersError()[0][1]; //cov(dx/dz,x)
167  mat[2][2] = segPhi->parametersError()[1][1]; //sigma (x)
168 
169  seg->setCovMatrix(mat);
170  }
171 
172  else if (seg->hasZed()) {
173  DTSLRecSegment2D *segZed = seg->zSegment();
174 
175  // Zed seg is in SL one
176  GlobalPoint glbPosZ = ( theGeom->superLayer(segZed->superLayerId()) )->toGlobal(segZed->localPosition());
177  LocalPoint posZInCh = ( theGeom->chamber(segZed->superLayerId().chamberId()) )->toLocal(glbPosZ);
178 
179  GlobalVector glbDirZ = (theGeom->superLayer(segZed->superLayerId()) )->toGlobal(segZed->localDirection());
180  LocalVector dirZInCh = (theGeom->chamber(segZed->superLayerId().chamberId()) )->toLocal(glbDirZ);
181 
182  LocalPoint posZAt0 = posZInCh+
183  dirZInCh*(-posZInCh.z())/cos(dirZInCh.theta());
184 
185  seg->setPosition(posZAt0);
186  seg->setDirection(dirZInCh);
187 
188  AlgebraicSymMatrix mat(4);
189  // set cov matrix
190  seg->setCovMatrix(mat);
191  seg->setCovMatrixForZed(posZInCh);
192  }
193 }
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
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:67
void setCovMatrix(AlgebraicSymMatrix mat)
Set covariance matrix.
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 280 of file DTSegmentUpdator.cc.

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

286  {
287 
288  float slope = 0.;
289  float intercept = 0.;
290  float covss = 0.;
291  float covii = 0.;
292  float covsi = 0.;
293 
294  // do the fit
295  theFitter->fit(x,y,x.size(),sigy,slope,intercept,covss,covii,covsi);
296  // cout << "slope " << slope << endl;
297  // cout << "intercept " << intercept << endl;
298 
299  // intercept is the x() in chamber frame when the segment cross the chamber
300  // plane (at z()=0), the y() is not measured, so let's put the center of the
301  // chamber.
302  pos = LocalPoint(intercept,0.,0.);
303 
304  // slope is dx()/dz(), while dy()/dz() is by definition 0, finally I want the
305  // segment to point outward, so opposite to local z
306  dir = LocalVector(-slope,0.,-1.).unit();
307 
308  covMatrix = AlgebraicSymMatrix(2);
309  covMatrix[0][0] = covss; // this is var(dy/dz)
310  covMatrix[1][1] = covii; // this is var(y)
311  covMatrix[1][0] = covsi; // this is cov(dy/dz,y)
312 
313  /* Calculate chi2. */
314  chi2 = 0.;
315  for(unsigned int i=0; i<x.size() ; ++i) {
316  double resid= y[i] - (intercept + slope*x[i]);
317  chi2 += (resid/sigy[i])*(resid/sigy[i]);
318  }
319 }
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:28
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 606 of file DTSegmentUpdator.cc.

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

Referenced by calculateT0corr().

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

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

Referenced by update().

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

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

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

71  {
72  setup.get<MuonGeometryRecord>().get(theGeom);
73  theAlgo->setES(setup);
74 }
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 76 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(), pos, 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(), DTRefitAndCombineReco4D::reconstruct(), DTCombinatorialPatternReco4D::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().

76  {
77 
78  if(debug) cout << "[DTSegmentUpdator] Starting to update the segment" << endl;
79 
80  const bool hasPhi = seg->hasPhi();
81  const bool hasZed = seg->hasZed();
82 
83  //reject the bad hits (due to delta rays)
84  if(perform_delta_rejecting && hasPhi) rejectBadHits(seg->phiSegment());
85 
86  int step = (hasPhi && hasZed) ? 3 : 2;
87  if(calcT0) step = 4;
88 
89  if(debug) cout << "Step of update is " << step << endl;
90 
91  GlobalPoint pos = theGeom->idToDet(seg->geographicalId())->toGlobal(seg->localPosition());
92  GlobalVector dir = theGeom->idToDet(seg->geographicalId())->toGlobal(seg->localDirection());
93 
94  if(calcT0) calculateT0corr(seg);
95 
96  if(hasPhi) updateHits(seg->phiSegment(),pos,dir,step);
97  if(hasZed) updateHits(seg->zSegment() ,pos,dir,step);
98 
99  fit(seg);
100 }
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 102 of file DTSegmentUpdator.cc.

References dir, fit(), TrackingRecHit::geographicalId(), DTRecSegment2D::localDirection(), DTRecSegment2D::localPosition(), pos, 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().

102  {
103  GlobalPoint pos = (theGeom->idToDet(seg->geographicalId()))->toGlobal(seg->localPosition());
104  GlobalVector dir = (theGeom->idToDet(seg->geographicalId()))->toGlobal(seg->localDirection());
105 
106  updateHits(seg,pos,dir);
107  fit(seg);
108 }
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 323 of file DTSegmentUpdator.cc.

References angle(), DTRecHitBaseAlgo::compute(), funct::cos(), 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().

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

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

bool DTSegmentUpdator::perform_delta_rejecting
private

Definition at line 115 of file DTSegmentUpdator.h.

Referenced by update().

double DTSegmentUpdator::T0_hit_resolution
private

Definition at line 114 of file DTSegmentUpdator.h.

Referenced by updateHits().

DTRecHitBaseAlgo* DTSegmentUpdator::theAlgo
private

Definition at line 85 of file DTSegmentUpdator.h.

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

DTLinearFit* DTSegmentUpdator::theFitter
private

Definition at line 84 of file DTSegmentUpdator.h.

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

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

Definition at line 86 of file DTSegmentUpdator.h.

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

bool DTSegmentUpdator::vdrift_4parfit
private

Definition at line 113 of file DTSegmentUpdator.h.

Referenced by Fit4Var(), and updateHits().