CMS 3D CMS Logo

OutInConversionSeedFinder.cc
Go to the documentation of this file.
5 //
7 // Field
9 //
11 // Geometry
12 //
18 //
19 
20 //
21 #include "CLHEP/Units/GlobalPhysicalConstants.h"
22 #include "CLHEP/Geometry/Point3D.h"
23 #include "CLHEP/Geometry/Vector3D.h"
24  #include "CLHEP/Geometry/Transform3D.h"
25 #include <cfloat>
26 
27 namespace {
28  inline double ptFast( const double energy,
29  const math::XYZPoint& position,
30  const math::XYZPoint& origin ) {
31  const auto v = position - origin;
32  return energy*std::sqrt(v.perp2()/v.mag2());
33  }
34 }
35 
36 
38 {
39 
40  LogDebug("OutInConversionSeedFinder") << "OutInConversionSeedFinder CTOR " << "\n";
41 
42  maxNumberOfOutInSeedsPerBC_ = conf_.getParameter<int>("maxNumOfSeedsOutIn");
43  bcEtcut_ = conf_.getParameter<double>("bcEtCut");
44  bcEcut_ = conf_.getParameter<double>("bcECut");
45  useEtCut_ = conf_.getParameter<bool>("useEtCut");
46  //the2ndHitdphi_ = 0.01;
47  the2ndHitdphi_ = 0.03;
48  the2ndHitdzConst_ = 5.;
49  the2ndHitdznSigma_ = 2.;
50 
51 
52 
53 }
54 
55 
56 
57 
59  LogDebug("OutInConversionSeedFinder") << "OutInConversionSeedFinder DTOR " << "\n";
60 
61 }
62 
63 
64 
66 
67  theSeeds_.clear();
68 
69  // std::cout << " OutInConversionSeedFinder::makeSeeds() " << "\n";
70 
71  // debug
72  // std::cout << " OutInConversionSeedFinder::makeSeeds() SC position " << theSCPosition_.x() << " " << theSCPosition_.y() << " " << theSCPosition_.z() << "\n";
73  // std::cout << " SC eta " << theSCPosition_.eta() << " SC phi " << theSCPosition_.phi() << "\n";
74  // std::cout << " OutInConversionSeedFinder::makeSeeds() SC energy " << theSCenergy_ << "\n";
75  //
76 
77  findLayers();
78 
79 
80  // std::cout << " Check Calo cluster collection size " << allBC->size() << "\n";
81 
82  float theSCPhi=theSCPosition_.phi();
83  float theSCEta=theSCPosition_.eta();
84 
85 
86 
87  // Loop over the Calo Clusters in the event looking for seeds
88  LogDebug("OutInConversionSeedFinder") << " OutInConversionSeedFinder::makeSeeds() All BC in the event " << "\n";
89  for (unsigned i = 0; i < allBC->size(); ++i ) {
90 
91  nSeedsPerBC_=0;
92 
93  const reco::CaloCluster& theBC = allBC->at(i);
94  const math::XYZPoint& rawBCpos = theBC.position();
95 
96  theBCPosition_ = GlobalPoint( rawBCpos.x(), rawBCpos.y(), rawBCpos.z() ) ;
97  float theBcEta= theBCPosition_.eta();
98  float theBcPhi= theBCPosition_.phi();
99  // float dPhi= theBcPhi-theSCPhi;
100  theBCEnergy_=theBC.energy();
101 
102  float EtOrECut = bcEcut_;
103  if ( useEtCut_ ) {
105  EtOrECut = bcEtcut_;
106  }
107 
108  if ( theBCEnergy_ < EtOrECut ) continue;
109  // std::cout << " OutInConversionSeedFinder::makeSeeds() BC eta " << theBcEta << " phi " << theBcPhi << " BC transverse energy " << theBCEnergy_ << " dPhi " << fabs(theBcPhi-theSCPhi) << " dEta " << fabs(theBcEta-theSCEta) << "\n";
110 
111  LogDebug("OutInConversionSeedFinder") << " OutInConversionSeedFinder::makeSeeds() Passing the >=1.5 GeV cut BC eta " << theBcEta << " phi " << theBcPhi << " BC energy " << theBCEnergy_ << "\n";
112 
113  if ( fabs(theBcEta-theSCEta) < 0.015 && reco::deltaPhi(theBcPhi,theSCPhi) < 0.3 ) {
114  LogDebug("OutInConversionSeedFinder") << " OutInConversionSeedFinder::makeSeeds() in et and phi range passed to the analysis " << "\n";
115  fillClusterSeeds( allBC->ptrAt(i) );
116  }
117 
118 
119  }
120 
121 
122  // std::cout << "Built vector of seeds of size " << theSeeds_.size() << "\n" ;
123 
125  /*
126  int nSeed=0;
127  for ( std::vector<TrajectorySeed>::const_iterator iSeed= theSeeds_.begin(); iSeed != theSeeds_.end(); ++iSeed) {
128  nSeed++;
129  PTrajectoryStateOnDet ptsod=iSeed->startingState();
130  LogDebug("OutInConversionSeedFinder") << nSeed << ") Direction " << iSeed->direction() << " Num of hits " << iSeed->nHits() << " starting state position " << ptsod.parameters().position() << " R " << ptsod.parameters().position().perp() << " phi " << ptsod.parameters().position().phi() << " eta " << ptsod.parameters().position().eta() << "\n" ;
131 
132 
133  DetId tmpId = DetId( iSeed->startingState().detId());
134  const GeomDet* tmpDet = this->getMeasurementTracker()->geomTracker()->idToDet( tmpId );
135  GlobalVector gv = tmpDet->surface().toGlobal( iSeed->startingState().parameters().momentum() );
136 
137  LogDebug("OutInConversionSeedFinder") << "seed perp,phi,eta : "
138  << gv.perp() << " , "
139  << gv.phi() << " , "
140  << gv.eta() << "\n" ; ;
141 
142 
143 
144 
145  TrajectorySeed::range hitRange = iSeed->recHits();
146  for (TrajectorySeed::const_iterator ihit = hitRange.first; ihit != hitRange.second; ihit++) {
147 
148  if ( ihit->isValid() ) {
149 
150  LogDebug("OutInConversionSeedFinder") << " Valid hit global position " << this->getMeasurementTracker()->geomTracker()->idToDet((ihit)->geographicalId())->surface().toGlobal((ihit)->localPosition()) << " R " << this->getMeasurementTracker()->geomTracker()->idToDet((ihit)->geographicalId())->surface().toGlobal((ihit)->localPosition()).perp() << " phi " << this->getMeasurementTracker()->geomTracker()->idToDet((ihit)->geographicalId())->surface().toGlobal((ihit)->localPosition()).phi() << " eta " << this->getMeasurementTracker()->geomTracker()->idToDet((ihit)->geographicalId())->surface().toGlobal((ihit)->localPosition()).eta() << "\n" ;
151 
152  }
153  }
154  }
155 
156  */
157 
158 
159 
160 }
161 
162 
163 
165 
166  theSeeds_.clear();
167 
168  findLayers();
169 
170  float theSCPhi=theSCPosition_.phi();
171  float theSCEta=theSCPosition_.eta();
172 
173  nSeedsPerBC_=0;
174 
175  // theBCEnergy_=aBC->energy();
176  theBCEnergy_= ptFast(aBC->energy(),aBC->position(),math::XYZPoint(0,0,0));
177  theBCPosition_ = GlobalPoint(aBC->position().x(), aBC->position().y(), aBC->position().z() ) ;
178  float theBcEta= theBCPosition_.eta();
179  float theBcPhi= theBCPosition_.phi();
180  // float dPhi= theBcPhi-theSCPhi;
181 
182  if ( theBCEnergy_ < bcEtcut_ ) return;
183 
184  if ( fabs(theBcEta-theSCEta) < 0.015 && fabs(theBcPhi-theSCPhi) < 0.25 ) {
185  fillClusterSeeds( aBC);
186  }
187 
188 }
189 
190 
191 
192 
193 
195 
196 
197  theFirstMeasurements_.clear();
198  FreeTrajectoryState fts;
199 
201  if ( makeTrackState(-1).second ) {
202  fts = makeTrackState(-1).first;
203  startSeed(fts);
204  }
206 
207  if ( makeTrackState(1).second ) {
208  fts = makeTrackState(1).first;
209  startSeed(fts);
210  }
211  theFirstMeasurements_.clear();
212 }
213 
214 
215 
216 std::pair<FreeTrajectoryState,bool> OutInConversionSeedFinder::makeTrackState(int charge) const {
217 
218  std::pair<FreeTrajectoryState,bool> result;
219  result.second=false;
220 
221 
222  //std::cout << " OutInConversionSeedFinder:makeTrackState " << "\n";
223 
224 
225  // Old GlobalPoint gpOrigine(theBCPosition_.x()*0.3, theBCPosition_.y()*0.3, theBCPosition_.z()*0.3) ;
226  // GlobalPoint gpOrigine(0.,0.,0.);
227 
229  GlobalVector gvBcRadius = theBCPosition_ - gpOrigine ;
230  HepGeom::Point3D<double> radiusBc(gvBcRadius.x(),gvBcRadius.y(),gvBcRadius.z()) ;
231  HepGeom::Point3D<double> momentumWithoutCurvature = radiusBc.unit() * theBCEnergy_ ;
232 
233  // compute momentum direction at calo
234  double curvature = theMF_->inTesla(theBCPosition_).z() * c_light * 1.e-3 / momentumWithoutCurvature.perp() ;
235  curvature /= 100. ; // in cm-1 !!
236 
237  LogDebug("OutInConversionSeedFinder") << "OutInConversionSeedFinder::makeTrackState gpOrigine " << gpOrigine.x() << " " << gpOrigine.y() << " " << gpOrigine.z() << " momentumWithoutCurvature " << momentumWithoutCurvature.mag() << " curvature " << curvature << "\n";
238 
239  // define rotation angle
240  float R = theBCPosition_.perp();
241  float r = gpOrigine.perp();
242  float rho = 1./curvature;
243  // from the formula for the intersection of two circles
244  // turns out to be about 2/3 of the deflection of the old formula
245  float d = sqrt(r*r+rho*rho);
246  float u = rho + rho/d/d*(R*R-rho*rho) - r/d/d*sqrt((R*R-r*r+2*rho*R)*(R*R-r*r+2*rho*R));
247  //float u = rho + rho/d/d*(R*R-rho*rho) ;
248  if ( u <=R ) result.second=true;
249 
250  double sinAlpha = 0.5*u/R;
251  if ( sinAlpha>(1.-10*DBL_EPSILON) ) sinAlpha = 1.-10*DBL_EPSILON;
252  else if ( sinAlpha<-(1.-10*DBL_EPSILON) ) sinAlpha = -(1.-10*DBL_EPSILON);
253 
254  double newdphi = charge * asin( sinAlpha) ;
255 
256  LogDebug("OutInConversionSeedFinder") << "OutInConversionSeedFinder::makeTrackState charge " << charge << " R " << R << " u/R " << u/R << " asin(0.5*u/R) " << asin(sinAlpha) << "\n";
257 
258  HepGeom::Transform3D rotation = HepGeom::Rotate3D(newdphi, HepGeom::Vector3D<double> (0., 0. ,1.));
259 
260 
261  HepGeom::Point3D<double> momentumInTracker = momentumWithoutCurvature.transform(rotation) ;
262  LogDebug("OutInConversionSeedFinder") << "OutInConversionSeedFinder::makeTrackState R " << R << " r " << r << " rho " << rho << " d " << d << " u " << u << " newdphi " << newdphi << " momentumInTracker " << momentumInTracker << "\n";
263 
264  HepGeom::Point3D<double> hepStartingPoint(gpOrigine.x(), gpOrigine.y(), gpOrigine.z()) ;
265 
266  LogDebug("OutInConversionSeedFinder") << "OutInConversionSeedFinder::makeTrackState hepStartingPoint " << hepStartingPoint << "\n";
267 
268  hepStartingPoint.transform(rotation);
269 
270  GlobalPoint startingPoint(hepStartingPoint.x(), hepStartingPoint.y(), hepStartingPoint.z());
271 
272  LogDebug("OutInConversionSeedFinder") << "OutInConversionSeedFinder::makeTrackState startingPoint " << startingPoint << " calo position " << theBCPosition_ << "\n";
273  GlobalVector gvTracker(momentumInTracker.x(), momentumInTracker.y(), momentumInTracker.z());
274  GlobalTrajectoryParameters gtp(startingPoint, gvTracker, charge, &(*theMF_) );
275  // error matrix
277  m(0,0) = 0.1; m(1,1) = 0.1 ; m(2,2) = 0.1 ;
278  m(3,3) = 0.1 ; m(4,4) = 0.1;
279 
280  // std::cout << "OutInConversionSeedFinder::makeTrackState " << FreeTrajectoryState(gtp, CurvilinearTrajectoryError(m) ) << "\n";
281 
282  result.first= FreeTrajectoryState(gtp, CurvilinearTrajectoryError(m) ) ;
283  return result;
284 
285 }
286 
287 
289 
290 
291  // std::cout << "OutInConversionSeedFinder::startSeed layer list " << this->layerList().size() << "\n";
292  //std::cout << "OutInConversionSeedFinder::startSeed fts " << fts << "\n";
293 
294  std::vector<const DetLayer*> myLayers=layerList();
295  if ( myLayers.size() > 3 ) {
296 
297  for(unsigned int ilayer = myLayers.size()-1; ilayer >= myLayers.size()-2; --ilayer) {
298  const DetLayer * layer = myLayers[ilayer];
299 
300 
301  // allow the z of the hit to be within a straight line from a vertex
302  // of +-15 cm to the cluster
303  // float dphi = 0.015;
304  float dphi = 0.030;
305 
306  MeasurementEstimator * newEstimator = makeEstimator(layer, dphi);
307 
308 
309  //std::cout << "OutInSeedFinder::startSeed propagationDirection " << int(thePropagatorAlongMomentum_->propagationDirection() ) << "\n";
310 
311  TSOS tsos(fts, layer->surface() );
312 
313  LogDebug("OutInConversionSeedFinder") << "OutInSeedFinder::startSeed after TSOS tsos(fts, layer->surface() ) " << "\n";
314 
315  LayerMeasurements theLayerMeasurements_( *this->getMeasurementTracker(), *theTrackerData_ );
316  theFirstMeasurements_ = theLayerMeasurements_.measurements( *layer, tsos, *thePropagatorAlongMomentum_, *newEstimator);
317 
318  //std::cout << "OutInSeedFinder::startSeed after theFirstMeasurements_ " << theFirstMeasurements_.size() << "\n";
319 
320  if(theFirstMeasurements_.size() > 1) // always a dummy returned, too
321  LogDebug("OutInConversionSeedFinder") << " Found " << theFirstMeasurements_.size()-1 << " 1st hits in seed" << "\n";
322 
323  delete newEstimator;
324 
325  LogDebug("OutInConversionSeedFinder") << "OutInSeedFinder::startSeed Layer " << ilayer << " theFirstMeasurements_.size " << theFirstMeasurements_.size() << "\n";
326 
327  for(unsigned int i = 0; i < theFirstMeasurements_.size(); ++i) {
329  if(m1.recHit()->isValid()) {
330 
331  // update the fts to start from this point. much better than starting from
332  // extrapolated point along the line
333  GlobalPoint hitPoint = m1.recHit()->globalPosition();
334  LogDebug("OutInConversionSeedFinder") << " Valid hit at R " << m1.recHit()->globalPosition().perp() << " Z " << m1.recHit()->globalPosition().z() << " eta " << m1.recHit()->globalPosition().eta() << " phi " << m1.recHit()->globalPosition().phi() << " xyz " << m1.recHit()->globalPosition() << "\n";
335 
336 
337  FreeTrajectoryState newfts = trackStateFromClusters(fts.charge(), hitPoint, alongMomentum, 0.8);
338  //std::cout << "OutInConversionSeedFinder::startSeed newfts " << newfts << "\n";
339  LogDebug("OutInConversionSeedFinder") << "OutInConversionSeedFinder::startSeed newfts " << newfts << "\n";
340  LogDebug("OutInConversionSeedFinder") << "OutInConversionSeedFinder::startSeed propagationDirection after switching " << int(thePropagatorOppositeToMomentum_->propagationDirection() ) << "\n";
341  // std::cout << "OutInConversionSeedFinder::startSeed propagationDirection after switching " << int(thePropagatorOppositeToMomentum_->propagationDirection() ) << "\n";
342 
343 
344  completeSeed(m1, newfts, thePropagatorOppositeToMomentum_, ilayer-1);
345  // skip a layer, if you haven't already skipped the first layer
346  if(ilayer == myLayers.size()-1) {
347  completeSeed(m1, newfts, thePropagatorOppositeToMomentum_, ilayer-2);
348  }
349  }
350  }
351 
352  } // loop over layers
353  }
354 
355 
356 
357 
358 }
359 
360 
361 
363 
364  //std::cout << "OutInConversionSeedFinder::makeEstimator " << "\n";
365 
366  MeasurementEstimator * newEstimator=nullptr;
367 
368  if (layer->location() == GeomDetEnumerators::barrel ) {
369 
370  const BarrelDetLayer * barrelLayer = dynamic_cast<const BarrelDetLayer*>(layer);
371  LogDebug("OutInConversionSeedFinder") << "OutInConversionSeedFinder::makeEstimator Barrel r = " << barrelLayer->specificSurface().radius() << " " << "\n";
372  float r = barrelLayer->specificSurface().radius();
373  float zrange = 15.* (1.-r/theBCPosition_.perp());
374  newEstimator = new ConversionBarrelEstimator(-dphi, dphi, -zrange, zrange);
375  }
376 
377 
378 
379  if (layer->location() == GeomDetEnumerators::endcap ) {
380 
381  const ForwardDetLayer * forwardLayer = dynamic_cast<const ForwardDetLayer*>(layer);
382  LogDebug("OutInConversionSeedFinder") << "OutInConversionSeedFinder::makeEstimator Endcap r = " << forwardLayer->specificSurface().innerRadius() << " R " << forwardLayer->specificSurface().outerRadius() << " Z " << forwardLayer->specificSurface().position().z() << "\n";
383 
384  float zc = fabs(theBCPosition_.z());
385  float z = fabs(forwardLayer->surface().position().z());
386 
387  float rrange = 15. * theBCPosition_.perp() * (zc - z) / (zc*zc - 15.*zc);
388  newEstimator = new ConversionForwardEstimator(-dphi, dphi, rrange);
389  }
390 
391 
392 
393 
394  return newEstimator;
395 }
396 
397 
398 
399 
401  const FreeTrajectoryState & fts,
402  const Propagator* propagator, int ilayer) {
403 
404  //std::cout << "OutInConversionSeedFinder::completeSeed ilayer " << ilayer << "\n";
405 
406  MeasurementEstimator * newEstimator=nullptr;
407  const DetLayer * layer = theLayerList_[ilayer];
408 
409 
410  if ( layer->location() == GeomDetEnumerators::barrel ) {
411  // z error for 2nd hit is 2 sigma quadded with 5 cm
412  LogDebug("OutInConversionSeedFinder") << " Barrel OutInConversionSeedFinder::completeSeed " << the2ndHitdznSigma_ << " " << the2ndHitdzConst_ << " " << the2ndHitdphi_ << "\n";
413  float dz = sqrt(the2ndHitdznSigma_*the2ndHitdznSigma_*m1.recHit()->globalPositionError().czz()
415  newEstimator =
416  new ConversionBarrelEstimator(-the2ndHitdphi_, the2ndHitdphi_, -dz, dz);
417  }
418  else {
419  LogDebug("OutInConversionSeedFinder") << " EndCap OutInConversionSeedFinder::completeSeed " << the2ndHitdznSigma_ << " " << the2ndHitdzConst_ << " " << the2ndHitdphi_ << "\n";
420  // z error for 2nd hit is 2sigma quadded with 5 cm
421  //float m1dr = m1.recHit().globalPositionError().rerr(m1.recHit().globalPosition());
422  float m1dr = sqrt(m1.recHit()->localPositionError().yy());
423  float dr = sqrt(the2ndHitdznSigma_*the2ndHitdznSigma_*m1dr*m1dr
425  // LogDebug("OutInConversionSeedFinder") << "second hit forward dr " << dr << " this hit " << m1dr << endl;
426  newEstimator =
427  new ConversionForwardEstimator(-the2ndHitdphi_, the2ndHitdphi_, dr);
428  }
429 
430  LogDebug("OutInConversionSeedFinder") << "OutInConversionSeedFinder::completeSeed ilayer " << ilayer << "\n";
431 
432  // Get the measurements consistent with the FTS and the Estimator
433  TSOS tsos(fts, layer->surface() );
434  LogDebug("OutInConversionSeedFinder") << "OutInConversionSeedFinder::completeSeed propagationDirection " << int(propagator->propagationDirection() ) << "\n";
435  LogDebug("OutInConversionSeedFinder") << "OutInConversionSeedFinder::completeSeed pointer to estimator " << newEstimator << "\n";
436 
437  LayerMeasurements theLayerMeasurements_( *this->getMeasurementTracker(), *theTrackerData_ );
438  std::vector<TrajectoryMeasurement> measurements = theLayerMeasurements_.measurements( *layer, tsos, *propagator, *newEstimator);
439  //std::cout << "OutInConversionSeedFinder::completeSeed Found " << measurements.size() << " second hits " << "\n";
440  delete newEstimator;
441 
442  for(unsigned int i = 0; i < measurements.size(); ++i) {
443  if( measurements[i].recHit()->isValid() ) {
444  createSeed(m1, measurements[i]);
445  }
446  }
447 
448 
449 
450  //LogDebug("OutInConversionSeedFinder") << "COMPLETED " << theSeeds_.size() << " SEEDS " << "\n";
451 }
452 
453 
454 
456  const TrajectoryMeasurement & m2) {
457 
458  //std::cout << "OutInConversionSeedFinder::createSeed from hit1 " << m1.recHit()->globalPosition() << " r1 " << m1.recHit()->globalPosition().perp() << " and hit2 " << m2.recHit()->globalPosition() << " r2 " << m2.recHit()->globalPosition().perp() << "\n";
459 
460 
461  FreeTrajectoryState fts = createSeedFTS(m1, m2);
462 
463 
464  //std::cout << "OutInConversionSeedFinder::createSeed First point errors " <<m1.recHit()->parametersError() << "\n";
465  // std::cout << "original cluster FTS " << fts <<"\n";
466  LogDebug("OutInConversionSeedFinder") << "OutInConversionSeedFinder::createSeed First point errors " <<m1.recHit()->parametersError() << "\n";
467  LogDebug("OutInConversionSeedFinder") << "original cluster FTS " << fts <<"\n";
468 
469 
470 
471  //std::cout << "OutInConversionSeedFinder::createSeed propagation dir " << int( thePropagatorOppositeToMomentum_->propagationDirection() ) << "\n";
472  TrajectoryStateOnSurface state1 = thePropagatorOppositeToMomentum_->propagate(fts, m1.recHit()->det()->surface());
473 
474  // LogDebug("OutInConversionSeedFinder") << "hit surface " << h1.det().surface().position() << endl;
475  // LogDebug("OutInConversionSeedFinder") << "prop to " << typeid(h1.det().surface()).name() << endl;
476  // LogDebug("OutInConversionSeedFinder") << "prop to first hit " << state1 << endl;
477  // LogDebug("OutInConversionSeedFinder") << "update to " << h1.globalPosition() << endl;
478 
479  if ( state1.isValid() ) {
480  TrajectoryStateOnSurface updatedState1 = theUpdator_.update(state1, *m1.recHit() );
481 
482  if ( updatedState1.isValid() ) {
483  TrajectoryStateOnSurface state2 = thePropagatorOppositeToMomentum_->propagate(*updatedState1.freeTrajectoryState(), m2.recHit()->det()->surface());
484 
485  if ( state2.isValid() ) {
486 
487  TrajectoryStateOnSurface updatedState2 = theUpdator_.update(state2, *m2.recHit() );
488  TrajectoryMeasurement meas1(state1, updatedState1, m1.recHit() , m1.estimate(), m1.layer());
489  TrajectoryMeasurement meas2(state2, updatedState2, m2.recHit() , m2.estimate(), m2.layer());
490 
492  myHits.push_back(meas1.recHit()->hit()->clone());
493  myHits.push_back(meas2.recHit()->hit()->clone());
494 
495  if ( nSeedsPerBC_ >= maxNumberOfOutInSeedsPerBC_ ) return;
496 
497 
498  PTrajectoryStateOnDet ptsod= trajectoryStateTransform::persistentState(state2, meas2.recHit()->hit()->geographicalId().rawId() );
499 
500  LogDebug("OutInConversionSeedFinder") << "OutInConversionSeedFinder::createSeed new seed from state " << state2.globalPosition() << "\n";
501  LogDebug("OutInConversionSeedFinder") << "OutInConversionSeedFinder::createSeed new seed ptsod " << ptsod.parameters().position() << " R "
502  << ptsod.parameters().position().perp() << " phi " << ptsod.parameters().position().phi() << " eta "
503  << ptsod.parameters().position().eta() << "\n";
504 
505 
506 
507  theSeeds_.push_back(TrajectorySeed( ptsod, myHits, oppositeToMomentum ));
508  nSeedsPerBC_++;
509 
510  }
511  }
512  }
513 
514 
515 
516 
517 
518 }
519 
520 
521 
522 
523 
525  const TrajectoryMeasurement & m2) const {
526 
527 
528 
529  GlobalPoint xmeas = fixPointRadius(m1);
530  GlobalPoint xvert = fixPointRadius(m2);
531 
532 
533  float pt = theSCenergy_ * sin(theSCPosition_.theta());
534  float pz = theSCenergy_ * cos(theSCPosition_.theta());
535 
536 
537 
538  // doesn't work at all for endcap, where r is badly measured
539  //float dphidr = (p1.phi()-p2.phi())/(p1.perp()-p2.perp());
540  //int charge = (dphidr > 0.) ? -1 : 1;
541  int charge = m2.predictedState().charge();
542 
543  double BInTesla = theMF_->inTesla(xmeas).z();
544  GlobalVector xdiff = xmeas -xvert;
545 
546  double phi= xdiff.phi();
547  double pxOld = pt*cos(phi);
548  double pyOld = pt*sin(phi);
549  double RadCurv = 100*pt/(BInTesla*0.29979);
550  double alpha = asin(0.5*xdiff.perp()/RadCurv);
551  float ca = cos(charge*alpha);
552  float sa = sin(charge*alpha);
553  double pxNew = ca*pxOld + sa*pyOld;
554  double pyNew = -sa*pxOld + ca*pyOld;
555  GlobalVector pNew(pxNew, pyNew, pz);
556 
557  GlobalTrajectoryParameters gp(xmeas, pNew, charge, &(*theMF_) );
558 
560  m(0,0) = 0.05; m(1,1) = 0.02 ; m(2,2) = 0.007 ;
561  m(3,3) = 10. ; m(4,4) = 10. ;
562  //std::cout << "OutInConversionSeedFinder::createSeedFTS " << FreeTrajectoryState(gp, CurvilinearTrajectoryError(m)) << "\n";
564 
565 
566 }
567 
568 
569 
570 
572  GlobalPoint p1 = m1.recHit()->globalPosition();
573  GlobalPoint p2;
574  if(m1.layer()->location() == GeomDetEnumerators::barrel) {
575  p2 = p1;
576  } else {
577  float z = p1.z();
578  float phi = p1.phi();
579  float theta = theSCPosition_.theta();
580  float r = p1.z() * tan(theta);
581  p2 = GlobalPoint(r*cos(phi), r*sin(phi), z);
582  // LogDebug("OutInConversionSeedFinder") << "fixing point radius " << p2 << " from " << p1 << endl;
583  }
584  return p2;
585 }
586 
587 
588 
589 
590 
#define LogDebug(id)
constexpr double deltaPhi(double phi1, double phi2)
Definition: deltaPhi.h:22
const Propagator * thePropagatorAlongMomentum_
T getParameter(std::string const &) const
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:131
std::vector< TrajectoryMeasurement > measurements(const DetLayer &layer, const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
std::vector< const DetLayer * > const & layerList() const
float alpha
Definition: AMPTWrapper.h:95
const MeasurementTracker * getMeasurementTracker() const
std::pair< FreeTrajectoryState, bool > makeTrackState(int charge) const
TrajectoryStateOnSurface const & predictedState() const
T perp() const
Definition: PV3DBase.h:72
ConstRecHitPointer const & recHit() const
LocalPoint position() const
Local x and y position coordinates.
ROOT::Math::SMatrixIdentity AlgebraicMatrixID
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
virtual Location location() const =0
Which part of the detector (barrel, endcap)
Geom::Phi< T > phi() const
Definition: PV3DBase.h:69
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
Geom::Theta< T > theta() const
MeasurementEstimator * makeEstimator(const DetLayer *, float dphi) const
GlobalPoint globalPosition() const
virtual const BoundCylinder & specificSurface() const final
Extension of the interface.
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
TrackCharge charge() const
TrajectorySeedCollection theSeeds_
GlobalPoint fixPointRadius(const TrajectoryMeasurement &) const
double ptFast(const double energy, const math::XYZPoint &position, const math::XYZPoint &origin)
void fillClusterSeeds(const reco::CaloClusterPtr &bc)
const Propagator * thePropagatorOppositeToMomentum_
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
U second(std::pair< T, U > const &p)
void makeSeeds(const edm::Handle< edm::View< reco::CaloCluster > > &allBc) override
void push_back(D *&d)
Definition: OwnVector.h:290
TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const override
Definition: KFUpdator.cc:169
T curvature(T InversePt, const edm::EventSetup &iSetup)
virtual PropagationDirection propagationDirection() const final
Definition: Propagator.h:151
FreeTrajectoryState const * freeTrajectoryState(bool withErrors=true) const
T sqrt(T t)
Definition: SSEVec.h:18
T z() const
Definition: PV3DBase.h:64
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
void createSeed(const TrajectoryMeasurement &m1, const TrajectoryMeasurement &m2)
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
const DetLayer * layer() const
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
std::vector< const DetLayer * > theLayerList_
double energy() const
cluster energy
Definition: CaloCluster.h:126
double p2[4]
Definition: TauolaWrapper.h:90
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
virtual const BoundDisk & specificSurface() const final
edm::ESHandle< MagneticField > theMF_
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:12
void startSeed(const FreeTrajectoryState &)
FreeTrajectoryState trackStateFromClusters(int aCharge, const GlobalPoint &gpOrigine, PropagationDirection dir, float scaleFactor) const
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:53
T eta() const
Definition: PV3DBase.h:76
const BoundSurface & surface() const final
The surface of the GeometricSearchDet.
double p1[4]
Definition: TauolaWrapper.h:89
static int position[264][3]
Definition: ReadPGInfo.cc:509
FreeTrajectoryState createSeedFTS(const TrajectoryMeasurement &m1, const TrajectoryMeasurement &m2) const
const Point & position() const
position
Definition: BeamSpot.h:62
void completeSeed(const TrajectoryMeasurement &m1, const FreeTrajectoryState &fts, const Propagator *, int layer)
edm::Handle< MeasurementTrackerEvent > theTrackerData_
const PositionType & position() const
std::vector< TrajectoryMeasurement > theFirstMeasurements_
const LocalTrajectoryParameters & parameters() const
OutInConversionSeedFinder(const edm::ParameterSet &config, edm::ConsumesCollector &&iC)