CMS 3D CMS Logo

InOutConversionSeedFinder.cc
Go to the documentation of this file.
4 
6 
7 // Field
8 //
10 // Geometry
11 //
16 
17 //
18 //
19 //
20 
22  : ConversionSeedFinder(conf, iC), conf_(conf) {
23  // std::cout << " InOutConversionSeedFinder CTOR " << "\n";
24 
25  maxNumberOfInOutSeedsPerInputTrack_ = conf_.getParameter<int>("maxNumOfSeedsInOut");
26  //the2ndHitdphi_ = 0.008;
27  the2ndHitdphi_ = 0.01;
28  the2ndHitdzConst_ = 5.;
29  the2ndHitdznSigma_ = 2.;
30 }
31 
33  //std::cout << " InOutConversionSeedFinder DTOR " << "\n";
34 }
35 
37  //std::cout << " InOutConversionSeedFinder::makeSeeds() " << "\n";
38  theSeeds_.clear();
39  //std::cout << " Check Calo cluster collection size " << allBC->size() << "\n";
40  bcCollection_ = allBC;
41 
42  findLayers();
43 
45  //std::cout << "Built vector of seeds of size " << theSeeds_.size() << "\n" ;
46 
47  theOutInTracks_.clear();
48  inputTracks_.clear();
49  theFirstMeasurements_.clear();
50 }
51 
53  std::vector<Trajectory>::const_iterator outInTrackItr;
54 
55  //std::cout << " InOutConversionSeedFinder::fillClusterSeeds outInTracks_.size " << theOutInTracks_.size() << "\n";
56  //Start looking for seeds for both of the 2 best tracks from the inward tracking
57 
59  /*
60  for(outInTrackItr = theOutInTracks_.begin(); outInTrackItr != theOutInTracks_.end(); ++outInTrackItr) {
61 
62 
63  //std::cout << " InOutConversionSeedFinder::fillClusterSeeds out in input track hits " << (*outInTrackItr).foundHits() << "\n";
64  DetId tmpId = DetId( (*outInTrackItr).seed().startingState().detId());
65  const GeomDet* tmpDet = this->getMeasurementTracker()->geomTracker()->idToDet( tmpId );
66  GlobalVector gv = tmpDet->surface().toGlobal( (*outInTrackItr).seed().startingState().parameters().momentum() );
67 
68 
69  //std::cout << " InOutConversionSeedFinder::fillClusterSeed was built from seed position " <<gv << " charge " << (*outInTrackItr).seed().startingState().parameters().charge() << "\n";
70 
71  Trajectory::DataContainer m= outInTrackItr->measurements();
72  int nHit=0;
73  for (Trajectory::DataContainer::iterator itm = m.begin(); itm != m.end(); ++itm) {
74  if ( itm->recHit()->isValid() ) {
75  nHit++;
76  //std::cout << nHit << ") Valid RecHit global position " << itm->recHit()->globalPosition() << " R " << itm->recHit()->globalPosition().perp() << " phi " << itm->recHit()->globalPosition().phi() << " eta " << itm->recHit()->globalPosition().eta() << "\n";
77  }
78 
79  }
80 
81  }
82 
83  */
84 
85  //Start looking for seeds for both of the 2 best tracks from the inward tracking
86  for (outInTrackItr = theOutInTracks_.begin(); outInTrackItr != theOutInTracks_.end(); ++outInTrackItr) {
87  //std::cout << " InOutConversionSeedFinder::fillClusterSeeds out in input track hits " << (*outInTrackItr).foundHits() << "\n";
89 
90  //Find the first valid hit of the track
91  // Measurements are ordered according to the direction in which the trajectories were built
92  std::vector<TrajectoryMeasurement> measurements = (*outInTrackItr).measurements();
93 
94  std::vector<const DetLayer*> allLayers = layerList();
95 
96  //std::cout << " InOutConversionSeedFinder::fill clusterSeed allLayers.size " << allLayers.size() << "\n";
97  for (unsigned int i = 0; i < allLayers.size(); ++i) {
98  //std::cout << " allLayers " << allLayers[i] << "\n";
99  printLayer(i);
100  }
101 
102  std::vector<const DetLayer*> myLayers;
103  myLayers.clear();
104  std::vector<TrajectoryMeasurement>::reverse_iterator measurementItr;
105  std::vector<TrajectoryMeasurement*> myItr;
106  // TrajectoryMeasurement* myPointer=0;
107  myPointer = nullptr;
108  //std::cout << " InOutConversionSeedFinder::fillClusterSeeds measurements.size " << measurements.size() <<"\n";
109 
110  for (measurementItr = measurements.rbegin(); measurementItr != measurements.rend(); ++measurementItr) {
111  if ((*measurementItr).recHit()->isValid()) {
112  //std::cout << " InOutConversionSeedFinder::fillClusterSeeds measurement on layer " << measurementItr->layer() << " " <<&(*measurementItr) << " position " << measurementItr->recHit()->globalPosition() << " R " << sqrt( measurementItr->recHit()->globalPosition().x()*measurementItr->recHit()->globalPosition().x() + measurementItr->recHit()->globalPosition().y()*measurementItr->recHit()->globalPosition().y() ) << " Z " << measurementItr->recHit()->globalPosition().z() << " phi " << measurementItr->recHit()->globalPosition().phi() << "\n";
113 
114  myLayers.push_back(measurementItr->layer());
115  myItr.push_back(&(*measurementItr));
116  }
117  }
118 
119  //std::cout << " InOutConversionSeedFinder::fillClusterSeed myLayers.size " << myLayers.size() << "\n";
120  // for( unsigned int i = 0; i < myLayers.size(); ++i) {
122  // }
123 
124  if (myItr.empty()) {
125  //std::cout << "HORRENDOUS ERROR! No meas on track!" << "\n";
126  }
127  unsigned int ilayer;
128  for (ilayer = 0; ilayer < allLayers.size(); ++ilayer) {
129  //std::cout << " allLayers in the search loop " << allLayers[ilayer] << " " << myLayers[0] << "\n";
130  if (allLayers[ilayer] == myLayers[0]) {
131  myPointer = myItr[0];
132 
133  //std::cout << " allLayers in the search loop allLayers[ilayer] == myLayers[0]) " << allLayers[ilayer] << " " << myLayers[0] << " myPointer " << myPointer << "\n";
134 
135  //std::cout << "Layer " << ilayer << " contains the first valid measurement " << "\n";
136  printLayer(ilayer);
137 
138  if ((myLayers[0])->location() == GeomDetEnumerators::barrel) {
139  // const BarrelDetLayer * barrelLayer = dynamic_cast<const BarrelDetLayer*>(myLayers[0]);
140  //std::cout << " InOutConversionSeedFinder::fillClusterSeeds **** firstHit found in Barrel on layer " << ilayer << " R= " << barrelLayer->specificSurface().radius() << "\n";
141  } else {
142  //const ForwardDetLayer * forwardLayer = dynamic_cast<const ForwardDetLayer*>(myLayers[0]);
143  //std::cout << " InOutwardConversionSeedFinder::fillClusterSeeds **** firstHit found in Forw on layer " << ilayer << " Z= " << forwardLayer->specificSurface().position().z() << "\n";
144  }
145 
146  break;
147 
148  } else if (allLayers[ilayer] == myLayers[1]) {
149  myPointer = myItr[1];
150 
151  //std::cout << " allLayers in the search loop allLayers[ilayer] == myLayers[1]) " << allLayers[ilayer] << " " << myLayers[1] << " myPointer " << myPointer << "\n";
152 
153  //std::cout << "Layer " << ilayer << " contains the first innermost valid measurement " << "\n";
154  if ((myLayers[1])->location() == GeomDetEnumerators::barrel) {
155  // const BarrelDetLayer * barrelLayer = dynamic_cast<const BarrelDetLayer*>(myLayers[1]);
156  //std::cout << " InOutConversionSeedFinder::fillClusterSeeds **** 2ndHit found in Barrel on layer " << ilayer << " R= " << barrelLayer->specificSurface().radius() << "\n";
157  } else {
158  //const ForwardDetLayer * forwardLayer = dynamic_cast<const ForwardDetLayer*>(myLayers[1]);
159  //std::cout << " InOutwardConversionSeedFinder::fillClusterSeeds **** 2ndHitfound on forw layer " << ilayer << " Z= " << forwardLayer->specificSurface().position().z() << "\n";
160  }
161 
162  break;
163  }
164  }
165 
166  if (ilayer == allLayers.size()) {
167  //std::cout << "InOutConversionSeedFinder::fillClusterSeeds ERROR could not find layer on list" << "\n";
168  return;
169  }
170 
171  //PropagatorWithMaterial reversePropagator(oppositeToMomentum, 0.000511, &(*theMF_) );
172  assert(myPointer);
174 
175  //std::cout << " InOutConversionSeedFinder::fillClusterSeeds First FTS charge " << fts->charge() << " Position " << fts->position() << " momentum " << fts->momentum() << " R " << sqrt(fts->position().x()*fts->position().x() + fts->position().y()* fts->position().y() ) << " Z " << fts->position().z() << " phi " << fts->position().phi() << " fts parameters " << fts->parameters() << "\n";
176 
177  while (ilayer > 0) {
178  //std::cout << " InOutConversionSeedFinder::fillClusterSeeds looking for 2nd seed from layer " << ilayer << "\n";
179 
180  // if ( (allLayers[ilayer])->location() == GeomDetEnumerators::barrel ) {const BarrelDetLayer * barrelLayer = dynamic_cast<const BarrelDetLayer*>(allLayers[ilayer]);
181  //std::cout << " InOutConversionSeedFinder::fillClusterSeeds **** Barrel on layer " << ilayer << " R= " << barrelLayer->specificSurface().radius() << "\n";
182  // } else {
183  //const ForwardDetLayer * forwardLayer = dynamic_cast<const ForwardDetLayer*>(allLayers[ilayer]);
184  //std::cout << " InOutConversionSeedFinder::fillClusterSeeds **** Forw on layer " << ilayer << " Z= " << forwardLayer->specificSurface().position().z() << "\n";
185  // }
186 
187  const DetLayer* previousLayer = allLayers[ilayer];
188  TrajectoryStateOnSurface stateAtPreviousLayer;
189  //std::cout << " InOutConversionSeedFinder::fillClusterSeeds previousLayer->surface() position before " <<allLayers[ilayer] << " " << previousLayer->surface().position() << " layer location " << previousLayer->location() << "\n";
190  // Propagate to the previous layer
191  // The present layer is actually included in the loop so that a partner can be searched for
192  // Applying the propagator to the same layer does not do any harm. It simply does nothing
193 
194  // const Propagator& newProp=thePropagatorOppositeToMomentum_;
195  //std::cout << " InOutConversionSeedFinder::fillClusterSeeds reversepropagator direction " << thePropagatorOppositeToMomentum_->propagationDirection() << "\n";
196  if (ilayer - 1 > 0) {
197  if (allLayers[ilayer] == myLayers[0]) {
198  //std::cout << " innermost hit R " << myPointer->recHit()->globalPosition().perp() << " Z " << myPointer->recHit()->globalPosition().z() << " phi " <<myPointer->recHit()->globalPosition().phi() << "\n";
199  //std::cout << " surface R " << theTrackerGeom_->idToDet( myPointer->recHit() ->geographicalId())->surface().position().perp() << " Z " << theTrackerGeom_->idToDet( myPointer->recHit() ->geographicalId())->surface().position().z() << " phi " << theTrackerGeom_->idToDet( myPointer->recHit() ->geographicalId())->surface().position().phi() << "\n";
200 
201  stateAtPreviousLayer = thePropagatorOppositeToMomentum_->propagate(
202  *fts, theTrackerGeom_->idToDet(myPointer->recHit()->geographicalId())->surface());
203 
204  } else {
205  stateAtPreviousLayer = thePropagatorOppositeToMomentum_->propagate(*fts, previousLayer->surface());
206  //std::cout << " InOutConversionSeedFinder::fillClusterSeeds previousLayer->surface() position after " << previousLayer->surface().position() << " layer location " << previousLayer->location() << "\n";
207  }
208 
209  } else if (ilayer - 1 == 0) {
212 
213  //stateAtPreviousLayer= thePropagatorOppositeToMomentum_->propagate(*fts, theTrackerGeom_->idToDet( myPointer->recHit() ->geographicalId())->surface() );
214  stateAtPreviousLayer = thePropagatorOppositeToMomentum_->propagate(*fts, previousLayer->surface());
215  }
216 
217  if (!stateAtPreviousLayer.isValid()) {
218  //std::cout << "InOutConversionSeedFinder::fillClusterSeeds ERROR:could not propagate back to layer " << ilayer << "\n";
220  } else {
221  //std::cout << "InOutConversionSeedFinder::fillClusterSeeds stateAtPreviousLayer is valid. Propagating back to layer " << ilayer << "\n";
222  //std::cout << "InOutConversionSeedFinder::fillClusterSeeds stateAtPreviousLayer R " << stateAtPreviousLayer.globalPosition().perp() << " Z " << stateAtPreviousLayer.globalPosition().z() << " phi " << stateAtPreviousLayer.globalPosition().phi() << "\n";
223 
224  startSeed(fts, stateAtPreviousLayer, -1, ilayer);
225  }
226 
227  --ilayer;
228  }
229 
230  if (ilayer == 0) {
231  // if ( (allLayers[ilayer])->location() == GeomDetEnumerators::barrel ) {const BarrelDetLayer * barrelLayer = dynamic_cast<const BarrelDetLayer*>(allLayers[ilayer]);
232  // //std::cout << " InOutConversionSeedFinder::fillClusterSeeds **** Barrel on layer " << ilayer << " R= " << barrelLayer->specificSurface().radius() << "\n";
233  // } else {
234  //const ForwardDetLayer * forwardLayer = dynamic_cast<const ForwardDetLayer*>(allLayers[ilayer]);
235  //std::cout << " InOutConversionSeedFinder::fillClusterSeeds **** Forw on layer " << ilayer << " Z= " << forwardLayer->specificSurface().position().z() << "\n";
236  // }
237  const DetLayer* previousLayer = allLayers[ilayer];
238  TrajectoryStateOnSurface stateAtPreviousLayer;
239  stateAtPreviousLayer = thePropagatorOppositeToMomentum_->propagate(*fts, previousLayer->surface());
240 
241  if (!stateAtPreviousLayer.isValid()) {
242  //std::cout << "InOutConversionSeedFinder::fillClusterSeeds ERROR:could not propagate back to layer " << ilayer << "\n";
244  } else {
245  //std::cout << "InOutConversionSeedFinder::fillClusterSeeds stateAtPreviousLayer is valid. Propagating back to layer " << ilayer << "\n";
246  //std::cout << "InOutConversionSeedFinder::fillClusterSeeds stateAtPreviousLayer R " << stateAtPreviousLayer.globalPosition().perp() << " Z " << stateAtPreviousLayer.globalPosition().z() << " phi " << stateAtPreviousLayer.globalPosition().phi() << "\n";
247 
248  startSeed(fts, stateAtPreviousLayer, -1, ilayer);
249  }
250  }
251 
252  } // End loop over Out In tracks
253 }
254 
256  const TrajectoryStateOnSurface& stateAtPreviousLayer,
257  int charge,
258  int ilayer) {
259  //std::cout << "InOutConversionSeedFinder::startSeed ilayer " << ilayer << "\n";
260  // Get a list of basic clusters that are consistent with a track
261  // starting at the assumed conversion point with opp. charge to the
262  // inward track. Loop over these basic clusters.
263  track2Charge_ = charge * fts->charge();
264  std::vector<const reco::CaloCluster*> bcVec;
265  //std::cout << "InOutConversionSeedFinder::startSeed charge assumed for the in-out track " << track2Charge_ << "\n";
266 
267  // Geom::Phi<float> theConvPhi( stateAtPreviousLayer.globalPosition().phi());
268  //std::cout << "InOutConversionSeedFinder::startSeed stateAtPreviousLayer phi " << stateAtPreviousLayer.globalPosition().phi() << " R " << stateAtPreviousLayer.globalPosition().perp() << " Z " << stateAtPreviousLayer.globalPosition().z() << "\n";
269 
270  bcVec = getSecondCaloClusters(stateAtPreviousLayer.globalPosition(), track2Charge_);
271 
272  std::vector<const reco::CaloCluster*>::iterator bcItr;
273  //std::cout << "InOutConversionSeedFinder::startSeed bcVec.size " << bcVec.size() << "\n";
274 
275  // debug
276  // for(bcItr = bcVec.begin(); bcItr != bcVec.end(); ++bcItr) {
277  // //std::cout << "InOutConversionSeedFinder::startSeed list of bc eta " << (*bcItr)->position().eta() << " phi " << (*bcItr)->position().phi() << " x " << (*bcItr)->position().x() << " y " << (*bcItr)->position().y() << " z " << (*bcItr)->position().z() << "\n";
278  // }
279 
280  for (bcItr = bcVec.begin(); bcItr != bcVec.end(); ++bcItr) {
281  theSecondBC_ = **bcItr;
283 
284  //std::cout << "InOutConversionSeedFinder::startSeed for bc position x " << bcPos.x() << " y " << bcPos.y() << " z " << bcPos.z() << " eta " << bcPos.eta() << " phi " << bcPos.phi() << "\n";
285  GlobalVector dir = stateAtPreviousLayer.globalDirection();
286  GlobalPoint back1mm = stateAtPreviousLayer.globalPosition();
287  //std::cout << "InOutConversionSeedFinder::startSeed stateAtPreviousLayer.globalPosition() " << back1mm << "\n";
288 
289  back1mm -= dir.unit() * 0.1;
290  //std::cout << " InOutConversionSeedFinder:::startSeed going to make the helix using back1mm " << back1mm <<"\n";
291  ConversionFastHelix helix(bcPos, stateAtPreviousLayer.globalPosition(), back1mm, &(*theMF_));
292  helix.stateAtVertex();
293 
294  //std::cout << " InOutConversionSeedFinder:::startSeed helix status " <<helix.isValid() << std::endl;
295  if (!helix.isValid())
296  continue;
297  findSeeds(stateAtPreviousLayer, helix.stateAtVertex().transverseCurvature(), ilayer);
298  }
299 }
300 
301 std::vector<const reco::CaloCluster*> InOutConversionSeedFinder::getSecondCaloClusters(
302  const GlobalPoint& conversionPosition, float charge) const {
303  std::vector<const reco::CaloCluster*> result;
304 
305  Geom::Phi<float> convPhi(conversionPosition.phi());
306 
307  for (auto const& bc : *bcCollection_) {
308  Geom::Phi<float> bcPhi(bc.position().phi());
309 
310  // Require phi of cluster to be consistent with the conversion position and the track charge
311 
312  if (std::abs(bcPhi - convPhi) < .5 &&
313  ((charge < 0 && bcPhi - convPhi > -.5) || (charge > 0 && bcPhi - convPhi < .5)))
314  result.push_back(&bc);
315  }
316 
317  return result;
318 }
319 
321  float transverseCurvature,
322  unsigned int startingLayer) {
323  std::vector<const DetLayer*> allLayers = layerList();
324  //std::cout << "InOutConversionSeedFinder::findSeeds starting forward propagation from startingLayer " << startingLayer << "\n";
325 
326  // create error matrix
328  m(0, 0) = 0.1;
329  m(1, 1) = 0.0001;
330  m(2, 2) = 0.0001;
331  m(3, 3) = 0.0001;
332  m(4, 4) = 0.001;
333 
334  // Make an FTS consistent with the start point, start direction and curvature
337  startingState.globalPosition(), startingState.globalDirection(), double(transverseCurvature), 0, &(*theMF_)),
339  if (fts.momentum().mag2() == 0) {
340  edm::LogWarning("FailedToInitiateSeeding")
341  << " initial FTS has a zero momentum, probably because of the zero field. ";
342  return;
343  }
344  //std::cout << " InOutConversionSeedFinder::findSeeds startingState R "<< startingState.globalPosition().perp() << " Z " << startingState.globalPosition().z() << " phi " << startingState.globalPosition().phi() << " position " << startingState.globalPosition() << "\n";
345  //std::cout << " InOutConversionSeedFinder::findSeeds Initial FTS charge " << fts.charge() << " curvature " << transverseCurvature << "\n";
346  //std::cout << " InOutConversionSeedFinder::findSeeds Initial FTS parameters " << fts << "\n";
347 
348  //float dphi = 0.01;
349  float dphi = 0.03;
350  float zrange = 5.;
351  for (unsigned int ilayer = startingLayer; ilayer <= startingLayer + 1 && (ilayer < allLayers.size() - 2); ++ilayer) {
352  const DetLayer* layer = allLayers[ilayer];
353 
355  // if ( layer->location() == GeomDetEnumerators::barrel ) {const BarrelDetLayer * barrelLayer = dynamic_cast<const BarrelDetLayer*>(layer);
356  // //std::cout << "InOutConversionSeedFinder::findSeeds **** Barrel on layer " << ilayer << " R= " << barrelLayer->specificSurface().radius() << "\n";
357  // } else {
358  // const ForwardDetLayer * forwardLayer = dynamic_cast<const ForwardDetLayer*>(layer);
360  // }
361  // // end debug
362 
363  MeasurementEstimator* newEstimator = nullptr;
364  if (layer->location() == GeomDetEnumerators::barrel) {
365  //std::cout << "InOutConversionSeedFinder::findSeeds Barrel ilayer " << ilayer << "\n";
366  newEstimator = new ConversionBarrelEstimator(-dphi, dphi, -zrange, zrange);
367  } else {
368  //std::cout << "InOutConversionSeedFinder::findSeeds Forward ilayer " << ilayer << "\n";
369  newEstimator = new ConversionForwardEstimator(-dphi, dphi, 15.);
370  }
371 
372  theFirstMeasurements_.clear();
373  // Get measurements compatible with the FTS and Estimator
374  TSOS tsos(fts, layer->surface());
375 
376  //std::cout << "InOutConversionSeedFinder::findSeed propagationDirection " << int(thePropagatorAlongMomentum_->propagationDirection() ) << "\n";
378  LayerMeasurements theLayerMeasurements_(*this->getMeasurementTracker(), *theTrackerData_);
379 
381  theLayerMeasurements_.measurements(*layer, tsos, *thePropagatorAlongMomentum_, *newEstimator);
382 
383  delete newEstimator;
384  //std::cout << "InOutConversionSeedFinder::findSeeds Found " << theFirstMeasurements_.size() << " first hits" << "\n";
385 
386  if (theFirstMeasurements_.size() ==
387  1) { // only dummy hit found: start finding the seed from the innermost hit of the OutIn track
388 
390  GlobalVector dir = startingState.globalDirection();
391  GlobalPoint back1mm = myPointer->recHit()->globalPosition();
392 
393  back1mm -= dir.unit() * 0.1;
394  //std::cout << " InOutConversionSeedFinder:::findSeeds going to make the helix using back1mm " << back1mm << "\n";
395  ConversionFastHelix helix(bcPos, myPointer->recHit()->globalPosition(), back1mm, &(*theMF_));
396 
397  helix.stateAtVertex();
398  //std::cout << " InOutConversionSeedFinder:::findSeeds helix status " <<helix.isValid() << std::endl;
399  if (!helix.isValid())
400  continue;
401 
402  track2InitialMomentum_ = helix.stateAtVertex().momentum();
403 
404  // Make a new FTS
406  startingState.globalDirection(),
407  helix.stateAtVertex().transverseCurvature(),
408  0,
409  &(*theMF_)),
411 
412  completeSeed(*myPointer, newfts, thePropagatorAlongMomentum_, ilayer + 1);
413  completeSeed(*myPointer, newfts, thePropagatorAlongMomentum_, ilayer + 2);
414 
415  } else {
416  //Loop over compatible hits
417  int mea = 0;
418  for (std::vector<TrajectoryMeasurement>::iterator tmItr = theFirstMeasurements_.begin();
419  tmItr != theFirstMeasurements_.end();
420  ++tmItr) {
421  mea++;
422 
423  if (tmItr->recHit()->isValid()) {
424  // Make a new helix as in fillClusterSeeds() but using the hit position
425  //std::cout << "InOutConversionSeedFinder::findSeeds hit R " << tmItr->recHit()->globalPosition().perp() << " Z " << tmItr->recHit()->globalPosition().z() << " " << tmItr->recHit()->globalPosition() << "\n";
426  GlobalPoint bcPos(
428  GlobalVector dir = startingState.globalDirection();
429  GlobalPoint back1mm = tmItr->recHit()->globalPosition();
430 
431  back1mm -= dir.unit() * 0.1;
432  //std::cout << " InOutConversionSeedFinder:::findSeeds going to make the helix using back1mm " << back1mm << "\n";
433  ConversionFastHelix helix(bcPos, tmItr->recHit()->globalPosition(), back1mm, &(*theMF_));
434 
435  helix.stateAtVertex();
436  //std::cout << " InOutConversionSeedFinder:::findSeeds helix status " <<helix.isValid() << std::endl;
437  if (!helix.isValid())
438  continue;
439 
440  track2InitialMomentum_ = helix.stateAtVertex().momentum();
441 
442  //std::cout << "InOutConversionSeedFinder::findSeeds Updated estimatedPt = " << helix.stateAtVertex().momentum().perp() << " curvature " << helix.stateAtVertex().transverseCurvature() << "\n";
443  // << ", bcet = " << theBc->Et()
444  // << ", estimatedPt/bcet = " << estimatedPt/theBc->Et() << endl;
445 
446  // Make a new FTS
447  FreeTrajectoryState newfts(GlobalTrajectoryParameters(tmItr->recHit()->globalPosition(),
448  startingState.globalDirection(),
449  helix.stateAtVertex().transverseCurvature(),
450  0,
451  &(*theMF_)),
453 
454  //std::cout << "InOutConversionSeedFinder::findSeeds new FTS charge " << newfts.charge() << "\n";
455 
456  /*
457  // Soome diagnostic output
458  // may be useful - comparission of the basic cluster position
459  // with the ecal impact position of the track
460  TrajectoryStateOnSurface stateAtECAL
461  = forwardPropagator.propagate(newfts, ECALSurfaces::barrel());
462  if (!stateAtECAL.isValid() || abs(stateAtECAL.globalPosition().eta())>1.479) {
463  if (startingState.globalDirection().eta() > 0.) {
464  stateAtECAL = forwardPropagator.propagate(newfts,
465  ECALSurfaces::positiveEtaEndcap());
466  } else {
467  stateAtECAL = forwardPropagator.propagate(newfts,
468  ECALSurfaces::negativeEtaEndcap());
469  }
470  }
471  GlobalPoint ecalImpactPosition = stateAtECAL.isValid() ? stateAtECAL.globalPosition() : GlobalPoint(0.,0.,0.);
472  cout << "Projected fts positon at ECAL surface: " <<
473  ecalImpactPosition << " bc position: " << theBc->Position() << endl;
474  */
475 
476  completeSeed(*tmItr, newfts, thePropagatorAlongMomentum_, ilayer + 1);
477  completeSeed(*tmItr, newfts, thePropagatorAlongMomentum_, ilayer + 2);
478  }
479  }
480  }
481  }
482 }
483 
485  const FreeTrajectoryState& fts,
486  const Propagator* propagator,
487  int ilayer) {
488  //std::cout<< "InOutConversionSeedFinder::completeSeed ilayer " << ilayer << "\n";
489  // A seed is made from 2 Trajectory Measuremennts. The 1st is the input
490  // argument m1. This routine looks for the 2nd measurement in layer ilayer
491  // Begin by making a new much stricter MeasurementEstimator based on the
492  // position errors of the 1st hit.
493  printLayer(ilayer);
494 
495  MeasurementEstimator* newEstimator;
496  std::vector<const DetLayer*> allLayers = layerList();
497  const DetLayer* layer = allLayers[ilayer];
498 
500  // if ( layer->location() == GeomDetEnumerators::barrel ) {const BarrelDetLayer * barrelLayer = dynamic_cast<const BarrelDetLayer*>(layer);
501  // //std::cout << "InOutConversionSeedFinder::completeSeed **** Barrel on layer " << ilayer << " R= " << barrelLayer->specificSurface().radius() << "\n";
502  // } else {
503  // const ForwardDetLayer * forwardLayer = dynamic_cast<const ForwardDetLayer*>(layer);
504  // //std::cout << "InOutConversionSeedFinder::completeSeed **** Forw on layer " << ilayer << " Z= " << forwardLayer->specificSurface().position().z() << "\n";
507 
508  if (layer->location() == GeomDetEnumerators::barrel) {
509  float dz = sqrt(the2ndHitdznSigma_ * the2ndHitdznSigma_ * m1.recHit()->globalPositionError().czz() +
512 
513  } else {
514  float m1dr = sqrt(m1.recHit()->localPositionError().yy());
516 
518  }
519 
520  //std::cout << "InOutConversionSeedFinder::completeSeed fts For the TSOS " << fts << "\n";
521 
522  TSOS tsos(fts, layer->surface());
523 
524  if (!tsos.isValid()) {
525  //std::cout << "InOutConversionSeedFinder::completeSeed TSOS is not valid " << "\n";
526  }
527 
528  //std::cout << "InOutConversionSeedFinder::completeSeed TSOS " << tsos << "\n";
529  //std::cout << "InOutConversionSeedFinder::completeSeed propagationDirection " << int(propagator->propagationDirection() ) << "\n";
530  //std::cout << "InOutConversionSeedFinder::completeSeed pointer to estimator " << newEstimator << "\n";
531 
532  LayerMeasurements theLayerMeasurements_(*this->getMeasurementTracker(), *theTrackerData_);
533  std::vector<TrajectoryMeasurement> measurements =
534  theLayerMeasurements_.measurements(*layer, tsos, *propagator, *newEstimator);
535  //std::cout << "InOutConversionSeedFinder::completeSeed Found " << measurements.size() << " second hits " << "\n";
536  delete newEstimator;
537 
538  for (unsigned int i = 0; i < measurements.size(); ++i) {
539  if (measurements[i].recHit()->isValid()) {
540  createSeed(m1, measurements[i]);
541  }
542  }
543 }
544 
546  //std::cout << "InOutConversionSeedFinder::createSeed " << "\n";
547 
548  if (m1.predictedState().isValid()) {
549  GlobalTrajectoryParameters newgtp(m1.recHit()->globalPosition(), track2InitialMomentum_, track2Charge_, &(*theMF_));
551  FreeTrajectoryState fts(newgtp, errors);
552 
553  TrajectoryStateOnSurface state1 = thePropagatorAlongMomentum_->propagate(fts, m1.recHit()->det()->surface());
554 
555  /*
556  //std::cout << "hit surface " << m1.recHit()->det()->surface().position() << "\n";
557  //std::cout << "prop to " << typeid( m1.recHit()->det()->surface() ).name() <<"\n";
558  //std::cout << "prop to first hit " << state1 << "\n";
559  //std::cout << "update to " << m1.recHit()->globalPosition() << "\n";
560  */
561 
562  if (state1.isValid()) {
563  TrajectoryStateOnSurface updatedState1 = theUpdator_.update(state1, *m1.recHit());
564 
565  if (updatedState1.isValid()) {
566  TrajectoryStateOnSurface state2 =
567  thePropagatorAlongMomentum_->propagate(*updatedState1.freeTrajectoryState(), m2.recHit()->det()->surface());
568 
569  if (state2.isValid()) {
570  TrajectoryStateOnSurface updatedState2 = theUpdator_.update(state2, *m2.recHit());
571  TrajectoryMeasurement meas1(state1, updatedState1, m1.recHit(), m1.estimate(), m1.layer());
572  TrajectoryMeasurement meas2(state2, updatedState2, m2.recHit(), m2.estimate(), m2.layer());
573 
575  myHits.push_back(meas1.recHit()->hit()->clone());
576  myHits.push_back(meas2.recHit()->hit()->clone());
577 
578  //std::cout << "InOutConversionSeedFinder::createSeed new seed " << "\n";
580  return;
581 
582  PTrajectoryStateOnDet const& ptsod =
583  trajectoryStateTransform::persistentState(state2, meas2.recHit()->hit()->geographicalId().rawId());
584  //std::cout << " InOutConversionSeedFinder::createSeed New seed parameters " << state2 << "\n";
585 
586  theSeeds_.push_back(TrajectorySeed(ptsod, myHits, alongMomentum));
588 
589  //std::cout << "InOutConversionSeedFinder::createSeed New seed hit 1 R " << m1.recHit()->globalPosition().perp() << "\n";
590  //std::cout << "InOutConversionSeedFinder::createSeed New seed hit 2 R " << m2.recHit()->globalPosition().perp() << "\n";
591  }
592  }
593  }
594  }
595 }
ConversionSeedFinder::layerList
std::vector< const DetLayer * > const & layerList() const
Definition: ConversionSeedFinder.h:61
Vector3DBase
Definition: Vector3DBase.h:8
TrajectoryStateOnSurface::globalDirection
GlobalVector globalDirection() const
Definition: TrajectoryStateOnSurface.h:67
MeasurementEstimator
Definition: MeasurementEstimator.h:19
InOutConversionSeedFinder::the2ndHitdzConst_
float the2ndHitdzConst_
Definition: InOutConversionSeedFinder.h:67
KFUpdator::update
TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TrackingRecHit &) const override
Definition: KFUpdator.cc:177
DDAxes::y
TrajectoryStateOnSurface::freeTrajectoryState
FreeTrajectoryState const * freeTrajectoryState(bool withErrors=true) const
Definition: TrajectoryStateOnSurface.h:60
LayerMeasurements::measurements
std::vector< TrajectoryMeasurement > measurements(const DetLayer &layer, const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
Definition: LayerMeasurements.cc:122
InOutConversionSeedFinder::the2ndHitdphi_
float the2ndHitdphi_
Definition: InOutConversionSeedFinder.h:66
mps_fire.i
i
Definition: mps_fire.py:355
MeasurementTrackerEvent.h
GlobalTrajectoryParameters.h
TkClusParameters_cff.zrange
zrange
Definition: TkClusParameters_cff.py:7
ConversionSeedFinder::findLayers
void findLayers()
Definition: ConversionSeedFinder.cc:58
AlgebraicObjects.h
DetLayer
Definition: DetLayer.h:21
trajectoryStateTransform::persistentState
PTrajectoryStateOnDet persistentState(const TrajectoryStateOnSurface &ts, unsigned int detid)
Definition: TrajectoryStateTransform.cc:14
TrajectoryStateOnSurface::globalPosition
GlobalPoint globalPosition() const
Definition: TrajectoryStateOnSurface.h:65
FreeTrajectoryState::charge
TrackCharge charge() const
Definition: FreeTrajectoryState.h:69
ConversionSeedFinder::theTrackerData_
edm::Handle< MeasurementTrackerEvent > theTrackerData_
Definition: ConversionSeedFinder.h:113
cms::cuda::assert
assert(be >=bs)
TransientTrackingRecHit.h
TrajectoryMeasurement::updatedState
TrajectoryStateOnSurface const & updatedState() const
Definition: TrajectoryMeasurement.h:184
TrajectoryStateOnSurface::transverseCurvature
double transverseCurvature() const
Definition: TrajectoryStateOnSurface.h:70
DDAxes::x
edm::Handle
Definition: AssociativeIterator.h:50
ConversionSeedFinder::thePropagatorOppositeToMomentum_
const Propagator * thePropagatorOppositeToMomentum_
Definition: ConversionSeedFinder.h:110
InOutConversionSeedFinder::~InOutConversionSeedFinder
~InOutConversionSeedFinder() override
Definition: InOutConversionSeedFinder.cc:32
rpcPointValidation_cfi.recHit
recHit
Definition: rpcPointValidation_cfi.py:7
InOutConversionSeedFinder::myPointer
TrajectoryMeasurement * myPointer
Definition: InOutConversionSeedFinder.h:74
ConversionBarrelEstimator
Definition: ConversionBarrelEstimator.h:18
AlgebraicMatrixID
ROOT::Math::SMatrixIdentity AlgebraicMatrixID
Definition: AlgebraicROOTObjects.h:72
GeomDetEnumerators::barrel
Definition: GeomDetEnumerators.h:9
InOutConversionSeedFinder::theFirstMeasurements_
std::vector< TrajectoryMeasurement > theFirstMeasurements_
Definition: InOutConversionSeedFinder.h:78
Propagator
Definition: Propagator.h:44
DetLayer::location
virtual Location location() const =0
Which part of the detector (barrel, endcap)
TrajectoryStateOnSurface
Definition: TrajectoryStateOnSurface.h:16
TrackingGeometry::idToDet
virtual const GeomDet * idToDet(DetId) const =0
LayerMeasurements
Definition: LayerMeasurements.h:18
TrajectoryMeasurement::predictedState
TrajectoryStateOnSurface const & predictedState() const
Definition: TrajectoryMeasurement.h:174
InOutConversionSeedFinder::completeSeed
void completeSeed(const TrajectoryMeasurement &m1, const FreeTrajectoryState &fts, const Propagator *propagator, int ilayer)
Definition: InOutConversionSeedFinder.cc:484
CurvilinearTrajectoryError
Definition: CurvilinearTrajectoryError.h:27
TrackCandidateProducer_cfi.propagator
propagator
Definition: TrackCandidateProducer_cfi.py:17
errors
Definition: errors.py:1
InOutConversionSeedFinder::conf_
edm::ParameterSet conf_
Definition: InOutConversionSeedFinder.h:49
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
InOutConversionSeedFinder::createSeed
void createSeed(const TrajectoryMeasurement &m1, const TrajectoryMeasurement &m2)
Definition: InOutConversionSeedFinder.cc:545
ConversionSeedFinder::theUpdator_
KFUpdator theUpdator_
Definition: ConversionSeedFinder.h:99
DDAxes::z
GlobalTrajectoryParameters
Definition: GlobalTrajectoryParameters.h:15
ConversionSeedFinder::printLayer
void printLayer(int i) const
Definition: ConversionSeedFinder.cc:125
Point3DBase< float, GlobalTag >
InOutConversionSeedFinder::startSeed
void startSeed(const FreeTrajectoryState *fts, const TrajectoryStateOnSurface &stateAtPreviousLayer, int charge, int layer)
Definition: InOutConversionSeedFinder.cc:255
edm::LogWarning
Definition: MessageLogger.h:141
ALCARECOTkAlJpsiMuMu_cff.charge
charge
Definition: ALCARECOTkAlJpsiMuMu_cff.py:47
InOutConversionSeedFinder::makeSeeds
void makeSeeds(const edm::Handle< edm::View< reco::CaloCluster > > &allBc) override
Definition: InOutConversionSeedFinder.cc:36
edm::View
Definition: CaloClusterFwd.h:14
edm::ParameterSet
Definition: ParameterSet.h:36
InOutConversionSeedFinder::getSecondCaloClusters
std::vector< const reco::CaloCluster * > getSecondCaloClusters(const GlobalPoint &conversionPosition, float charge) const
Definition: InOutConversionSeedFinder.cc:301
InOutConversionSeedFinder::the2ndHitdznSigma_
float the2ndHitdznSigma_
Definition: InOutConversionSeedFinder.h:68
InOutConversionSeedFinder.h
ConversionSeedFinder::thePropagatorAlongMomentum_
const Propagator * thePropagatorAlongMomentum_
Definition: ConversionSeedFinder.h:109
InOutConversionSeedFinder::maxNumberOfInOutSeedsPerInputTrack_
int maxNumberOfInOutSeedsPerInputTrack_
Definition: InOutConversionSeedFinder.h:72
InOutConversionSeedFinder::theSecondBC_
reco::CaloCluster theSecondBC_
Definition: InOutConversionSeedFinder.h:80
InOutConversionSeedFinder::track2Charge_
int track2Charge_
Definition: InOutConversionSeedFinder.h:69
Geom::Phi< float >
InOutConversionSeedFinder::InOutConversionSeedFinder
InOutConversionSeedFinder(const edm::ParameterSet &config, edm::ConsumesCollector &&iC)
Definition: InOutConversionSeedFinder.cc:21
ConversionSeedFinder::getMeasurementTracker
const MeasurementTracker * getMeasurementTracker() const
Definition: ConversionSeedFinder.h:64
ConversionSeedFinder::theSeeds_
TrajectorySeedCollection theSeeds_
Definition: ConversionSeedFinder.h:85
Propagator::propagate
TrajectoryStateOnSurface propagate(STA const &state, SUR const &surface) const
Definition: Propagator.h:50
ConversionBarrelEstimator.h
InOutConversionSeedFinder::bcCollection_
edm::Handle< edm::View< reco::CaloCluster > > bcCollection_
Definition: InOutConversionSeedFinder.h:81
ConversionSeedFinder
Definition: ConversionSeedFinder.h:47
reco::CaloCluster::position
const math::XYZPoint & position() const
cluster centroid position
Definition: CaloCluster.h:154
TrajectoryMeasurement::recHit
ConstRecHitPointer const & recHit() const
Definition: TrajectoryMeasurement.h:190
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
ConversionFastHelix
Definition: ConversionFastHelix.h:15
ConversionFastHelix::stateAtVertex
FTS stateAtVertex()
Definition: ConversionFastHelix.cc:32
ConversionSeedFinder::theTrackerGeom_
const TrackingGeometry * theTrackerGeom_
Definition: ConversionSeedFinder.h:90
FreeTrajectoryState
Definition: FreeTrajectoryState.h:27
TrajectoryMeasurement::estimate
float estimate() const
Definition: TrajectoryMeasurement.h:192
PVValHelper::dz
Definition: PVValidationHelpers.h:50
ConversionForwardEstimator.h
InOutConversionSeedFinder::theOutInTracks_
std::vector< Trajectory > theOutInTracks_
Definition: InOutConversionSeedFinder.h:77
flavorHistoryFilter_cfi.dr
dr
Definition: flavorHistoryFilter_cfi.py:37
TrajectoryStateOnSurface::curvilinearError
const CurvilinearTrajectoryError & curvilinearError() const
Definition: TrajectoryStateOnSurface.h:72
InOutConversionSeedFinder::track2InitialMomentum_
GlobalVector track2InitialMomentum_
Definition: InOutConversionSeedFinder.h:70
InOutConversionSeedFinder::fillClusterSeeds
virtual void fillClusterSeeds()
Definition: InOutConversionSeedFinder.cc:52
GeometricSearchDet::surface
virtual const BoundSurface & surface() const =0
The surface of the GeometricSearchDet.
TrajectorySeed
Definition: TrajectorySeed.h:17
TrajectoryStateTransform.h
edm::OwnVector::push_back
void push_back(D *&d)
Definition: OwnVector.h:326
InOutConversionSeedFinder::inputTracks_
std::vector< Trajectory > inputTracks_
Definition: InOutConversionSeedFinder.h:76
EcalCondDBWriter_cfi.location
location
Definition: EcalCondDBWriter_cfi.py:63
mps_fire.result
result
Definition: mps_fire.py:303
ConversionFastHelix.h
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
PTrajectoryStateOnDet
Definition: PTrajectoryStateOnDet.h:10
TrajectoryMeasurement::layer
const DetLayer * layer() const
Definition: TrajectoryMeasurement.h:194
ConversionForwardEstimator
Definition: ConversionForwardEstimator.h:20
AlgebraicSymMatrix55
ROOT::Math::SMatrix< double, 5, 5, ROOT::Math::MatRepSym< double, 5 > > AlgebraicSymMatrix55
Definition: AlgebraicROOTObjects.h:23
TrajectoryMeasurement
Definition: TrajectoryMeasurement.h:25
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
alongMomentum
Definition: PropagationDirection.h:4
PV3DBase::phi
Geom::Phi< T > phi() const
Definition: PV3DBase.h:66
TrajectoryStateOnSurface::isValid
bool isValid() const
Definition: TrajectoryStateOnSurface.h:54
edm::OwnVector< TrackingRecHit >
InOutConversionSeedFinder::findSeeds
virtual void findSeeds(const TrajectoryStateOnSurface &startingState, float signedpt, unsigned int startingLayer)
Definition: InOutConversionSeedFinder.cc:320
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
InOutConversionSeedFinder::nSeedsPerInputTrack_
int nSeedsPerInputTrack_
Definition: InOutConversionSeedFinder.h:71