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 Types | Private Member Functions | Private Attributes
MTFTrackProducerAlgorithm Class Reference

#include <MTFTrackProducerAlgorithm.h>

Public Member Functions

 MTFTrackProducerAlgorithm (const edm::ParameterSet &pset)
 Constructor. More...
 
void runWithCandidate (const TrackingGeometry *, const MagneticField *, const std::vector< Trajectory > &, const TrajectoryFitter *, const TransientTrackingRecHitBuilder *, const MultiTrackFilterHitCollector *measurementTracker, const SiTrackerMultiRecHitUpdatorMTF *, const reco::BeamSpot &, AlgoProductCollection &) const
 Run the Final Fit taking TrackCandidates as input. More...
 
 ~MTFTrackProducerAlgorithm ()
 Destructor. More...
 

Private Types

typedef std::pair< Trajectory
*, std::pair< reco::Track
*, PropagationDirection > > 
AlgoProduct
 
typedef std::vector< AlgoProductAlgoProductCollection
 
typedef MultiTrajectoryMeasurement MTM
 
typedef TrajectoryStateOnSurface TSOS
 

Private Member Functions

bool buildTrack (const std::vector< Trajectory > &, AlgoProductCollection &algoResults, float, const reco::BeamSpot &) const
 Construct Tracks to be put in the event. More...
 
float calculateNdof (const std::vector< Trajectory > &vtraj) const
 
std::pair
< TransientTrackingRecHit::RecHitContainer,
TrajectoryStateOnSurface
collectHits (const std::map< int, std::vector< TrajectoryMeasurement > > &mapvtm, const MultiTrackFilterHitCollector *measurementCollector, int i) const
 
void filter (const TrajectoryFitter *fitter, std::vector< Trajectory > &input, int minhits, std::vector< Trajectory > &output) const
 
bool fit (const std::pair< TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface > &hits, const TrajectoryFitter *theFitter, std::vector< Trajectory > &vtraj) const
 accomplishes the fitting-smoothing step for each annealing value More...
 
std::pair
< TransientTrackingRecHit::RecHitContainer,
TrajectoryStateOnSurface
updateHits (const std::map< int, std::vector< TrajectoryMeasurement > > &mapvtm, const MultiTrackFilterHitCollector *measurementCollector, const SiTrackerMultiRecHitUpdatorMTF *updator, double annealing, const TransientTrackingRecHitBuilder *builder, int i) const
 

Private Attributes

edm::ParameterSet conf_
 

Detailed Description

Definition at line 26 of file MTFTrackProducerAlgorithm.h.

Member Typedef Documentation

Definition at line 28 of file MTFTrackProducerAlgorithm.h.

Definition at line 29 of file MTFTrackProducerAlgorithm.h.

Definition at line 30 of file MTFTrackProducerAlgorithm.h.

Definition at line 31 of file MTFTrackProducerAlgorithm.h.

Constructor & Destructor Documentation

MTFTrackProducerAlgorithm::MTFTrackProducerAlgorithm ( const edm::ParameterSet pset)
inline

Constructor.

Definition at line 36 of file MTFTrackProducerAlgorithm.h.

36 :conf_(pset){}
MTFTrackProducerAlgorithm::~MTFTrackProducerAlgorithm ( )
inline

Destructor.

Definition at line 39 of file MTFTrackProducerAlgorithm.h.

39 {}

Member Function Documentation

bool MTFTrackProducerAlgorithm::buildTrack ( const std::vector< Trajectory > &  vtraj,
AlgoProductCollection algoResults,
float  ndof,
const reco::BeamSpot bs 
) const
private

Construct Tracks to be put in the event.

Definition at line 403 of file MTFTrackProducerAlgorithm.cc.

References alongMomentum, FreeTrajectoryState::charge(), Trajectory::chiSquared(), FreeTrajectoryState::curvilinearError(), Trajectory::direction(), Trajectory::firstMeasurement(), TrajectoryStateOnSurface::freeState(), TrajectoryStateClosestToBeamLine::isValid(), Trajectory::lastMeasurement(), LogDebug, FreeTrajectoryState::momentum(), L1TEmulatorMonitor_cff::p, pos, FreeTrajectoryState::position(), TrajectoryStateClosestToBeamLine::trackStateAtPCA(), TrajectoryMeasurement::updatedState(), v, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by runWithCandidate().

406  {
407  //variable declarations
408  reco::Track * theTrack;
409  Trajectory * theTraj;
410 
411  //perform the fit: the result's size is 1 if it succeded, 0 if fails
412 
413 
414  //LogDebug("TrackProducer") <<" FITTER FOUND "<< vtraj.size() << " TRAJECTORIES" <<"\n";
415  LogDebug("MTFTrackProducerAlgorithm") <<" FITTER FOUND "<< vtraj.size() << " TRAJECTORIES" << std::endl;;
416  TrajectoryStateOnSurface innertsos;
417 
418  if (vtraj.size() != 0){
419 
420  theTraj = new Trajectory( vtraj.front() );
421 
422  if (theTraj->direction() == alongMomentum) {
423  //if (theTraj->direction() == oppositeToMomentum) {
424  innertsos = theTraj->firstMeasurement().updatedState();
425  //std::cout << "Inner momentum " << innertsos.globalParameters().momentum().mag() << std::endl;
426  } else {
427  innertsos = theTraj->lastMeasurement().updatedState();
428  }
429 
430  TSCBLBuilderNoMaterial tscblBuilder;
431  TrajectoryStateClosestToBeamLine tscbl = tscblBuilder(*(innertsos.freeState()),bs);
432 
433  if (tscbl.isValid()==false) return false;
434 
436  math::XYZPoint pos( v.x(), v.y(), v.z() );
438  math::XYZVector mom( p.x(), p.y(), p.z() );
439 
440  LogDebug("TrackProducer") <<v<<p<<std::endl;
441 
442  theTrack = new reco::Track(theTraj->chiSquared(),
443  ndof, //in the DAF the ndof is not-integer
444  pos, mom, tscbl.trackStateAtPCA().charge(), tscbl.trackStateAtPCA().curvilinearError());
445 
446 
447  LogDebug("TrackProducer") <<"track done\n";
448 
449  AlgoProduct aProduct(theTraj,std::make_pair(theTrack,theTraj->direction()));
450  LogDebug("TrackProducer") <<"track done1\n";
451  algoResults.push_back(aProduct);
452  LogDebug("TrackProducer") <<"track done2\n";
453 
454  return true;
455  }
456  else return false;
457 }
#define LogDebug(id)
T y() const
Definition: PV3DBase.h:57
std::pair< Trajectory *, std::pair< reco::Track *, PropagationDirection > > AlgoProduct
TrackCharge charge() const
const CurvilinearTrajectoryError & curvilinearError() const
PropagationDirection const & direction() const
Definition: Trajectory.cc:195
FreeTrajectoryState * freeState(bool withErrors=true) const
TrajectoryMeasurement const & lastMeasurement() const
Definition: Trajectory.h:147
T z() const
Definition: PV3DBase.h:58
TrajectoryStateOnSurface updatedState() const
GlobalVector momentum() const
GlobalPoint position() const
TrajectoryMeasurement const & firstMeasurement() const
Definition: Trajectory.h:160
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
T x() const
Definition: PV3DBase.h:56
mathSSE::Vec4< T > v
double chiSquared() const
Definition: Trajectory.h:208
float MTFTrackProducerAlgorithm::calculateNdof ( const std::vector< Trajectory > &  vtraj) const
private

Definition at line 508 of file MTFTrackProducerAlgorithm.cc.

References LogDebug.

Referenced by runWithCandidate().

508  {
509  if (vtraj.empty()) return 0;
510  float ndof = 0;
511  int nhits=0;
512  const std::vector<TrajectoryMeasurement>& meas = vtraj.front().measurements();
513  for (std::vector<TrajectoryMeasurement>::const_iterator iter = meas.begin(); iter != meas.end(); iter++){
514  if (iter->recHit()->isValid()){
515  TransientTrackingRecHit::ConstRecHitContainer components = iter->recHit()->transientHits();
516  TransientTrackingRecHit::ConstRecHitContainer::const_iterator iter2;
517  for (iter2 = components.begin(); iter2 != components.end(); iter2++){
518  if ((*iter2)->isValid()){ndof+=((*iter2)->dimension())*(*iter2)->weight();
519  LogDebug("DAFTrackProducerAlgorithm") << "hit dimension: "<<(*iter2)->dimension()
520  <<" and weight: "<<(*iter2)->weight();
521  nhits++;
522  }
523  }
524  }
525  }
526 
527  LogDebug("DAFTrackProducerAlgorithm") <<"nhits: "<<nhits<< " ndof: "<<ndof-5;
528  return ndof-5;
529 }
#define LogDebug(id)
std::vector< ConstRecHitPointer > ConstRecHitContainer
std::pair< TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface > MTFTrackProducerAlgorithm::collectHits ( const std::map< int, std::vector< TrajectoryMeasurement > > &  mapvtm,
const MultiTrackFilterHitCollector measurementCollector,
int  i 
) const
private

Definition at line 266 of file MTFTrackProducerAlgorithm.cc.

References LogDebug, and MultiTrackFilterHitCollector::recHits().

Referenced by runWithCandidate().

268  {
269 
271 
272  //build a vector of recHits with a particular mesurementCollector...in this case the SimpleMTFCollector
273  std::vector<TrajectoryMeasurement> collectedmeas = measurementCollector->recHits(vtm,i,1.);
274  LogDebug("MTFTrackProducerAlgorithm") << "hits collected by the MTF Measurement Collector " << std::endl
275  << "trajectory number " << i << "has measurements" << collectedmeas.size();
276 
277  if (collectedmeas.empty()) {
278  LogDebug("MTFTrackProducerAlgorithm") << "In method collectHits, we had a problem and no measurements were collected "
279  <<"for trajectory number " << i << std::endl;
281  }
282  //put the collected MultiRecHits in a vector
283  for (std::vector<TrajectoryMeasurement>::const_iterator iter = collectedmeas.begin(); iter!=collectedmeas.end(); iter++){
284  hits.push_back(iter->recHit());
285  if(iter->recHit()->isValid())
286  LogDebug("MTFTrackProducerAlgorithm") << "this MultiRecHit has size: " << iter->recHit()->recHits().size();
287  }
288  //make a pair with the infos about tsos and hit, with the tsos with arbitrary error (to do the fit better)
289  return std::make_pair(hits,TrajectoryStateWithArbitraryError()(collectedmeas.front().predictedState()));
290 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
virtual std::vector< TrajectoryMeasurement > recHits(const std::map< int, std::vector< TrajectoryMeasurement > > &, int, double) const =0
std::vector< ConstRecHitPointer > RecHitContainer
void MTFTrackProducerAlgorithm::filter ( const TrajectoryFitter fitter,
std::vector< Trajectory > &  input,
int  minhits,
std::vector< Trajectory > &  output 
) const
private

Definition at line 459 of file MTFTrackProducerAlgorithm.cc.

References InvalidTransientRecHit::build(), ExpressReco_HICollisions_FallBack::e, TrajectoryFitter::fit(), edm::OwnVector< T, P >::front(), LogDebug, and TrackingRecHit::missing.

462  {
463  if (input.empty()) return;
464 
465  int ngoodhits = 0;
466 
467  std::vector<TrajectoryMeasurement> vtm = input[0].measurements();
468 
470 
471  //count the number of non-outlier and non-invalid hits
472  for (std::vector<TrajectoryMeasurement>::reverse_iterator tm=vtm.rbegin(); tm!=vtm.rend();tm++){
473  //if the rechit is valid
474  if (tm->recHit()->isValid()) {
475  TransientTrackingRecHit::ConstRecHitContainer components = tm->recHit()->transientHits();
476  bool isGood = false;
477  for (TransientTrackingRecHit::ConstRecHitContainer::iterator rechit = components.begin(); rechit != components.end(); rechit++){
478  //if there is at least one component with weight higher than 1e-6 then the hit is not an outlier
479  if ((*rechit)->weight()>1e-6) {ngoodhits++; isGood = true; break;}
480  }
481  if (isGood) hits.push_back(tm->recHit()->clone(tm->updatedState()));
482  else hits.push_back(InvalidTransientRecHit::build(tm->recHit()->det(), TrackingRecHit::missing));
483  } else {
484  hits.push_back(tm->recHit()->clone(tm->updatedState()));
485  }
486  }
487 
488 
489  LogDebug("DAFTrackProducerAlgorithm") << "Original number of valid hits " << input[0].foundHits() << "; after filtering " << ngoodhits;
490  //debug
491  if (ngoodhits>input[0].foundHits()) edm::LogError("DAFTrackProducerAlgorithm") << "Something wrong: the number of good hits from DAFTrackProducerAlgorithm::filter " << ngoodhits << " is higher than the original one " << input[0].foundHits();
492 
493  if (ngoodhits < minhits) return;
494 
495  TrajectoryStateOnSurface curstartingTSOS = input.front().lastMeasurement().updatedState();
496  LogDebug("DAFTrackProducerAlgorithm") << "starting tsos for final refitting " << curstartingTSOS ;
497  //curstartingTSOS.rescaleError(100);
498 
501  input.front().seed().direction()),
502  hits,
503  TrajectoryStateWithArbitraryError()(curstartingTSOS));
504  LogDebug("DAFTrackProducerAlgorithm") << "After filtering " << output.size() << " trajectories";
505 
506 }
#define LogDebug(id)
static RecHitPointer build(const GeomDet *geom, Type type=TrackingRecHit::missing, const DetLayer *layer=0)
std::vector< ConstRecHitPointer > RecHitContainer
tuple input
Definition: collect_tpl.py:10
std::vector< ConstRecHitPointer > ConstRecHitContainer
virtual std::vector< Trajectory > fit(const Trajectory &) const =0
bool MTFTrackProducerAlgorithm::fit ( const std::pair< TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface > &  hits,
const TrajectoryFitter theFitter,
std::vector< Trajectory > &  vtraj 
) const
private

accomplishes the fitting-smoothing step for each annealing value

Definition at line 370 of file MTFTrackProducerAlgorithm.cc.

References TrajectoryFitter::fit(), edm::OwnVector< T, P >::front(), and LogDebug.

Referenced by runWithCandidate().

372  {
373 
374  std::vector<Trajectory> newVec = theFitter->fit(TrajectorySeed(PTrajectoryStateOnDet(),
376  vtraj.front().seed().direction()),
377  hits.first,
378  hits.second);
379 
380  //here we control if the fit-smooth round doesn't return an empty trajectory; if not we store the trajectory in vtraj
381  if(newVec.size())
382  {
383  vtraj.reserve(newVec.size());
384  vtraj.swap(newVec);
385  LogDebug("MTFTrackProducerAlgorithm") << "swapped!" << std::endl;
386  }
387 
388  //if the size of the trajectory is 0 we don't do anything leaving the old trajectory
389  else
390  {
391  LogDebug("MTFTrackProducerAlgorithm") <<" somewhwere, something went terribly wrong...in fitting or smoothing trajectory with measurements:"
392  << vtraj.front().measurements().size()
393  <<" was broken\n. We keep the old trajectory"
394  << std::endl;
395  return false;
396  }
397 
398  return true;
399 
400 }
#define LogDebug(id)
virtual std::vector< Trajectory > fit(const Trajectory &) const =0
reference front()
Definition: OwnVector.h:371
void MTFTrackProducerAlgorithm::runWithCandidate ( const TrackingGeometry theG,
const MagneticField theMF,
const std::vector< Trajectory > &  theTrajectoryCollection,
const TrajectoryFitter theFitter,
const TransientTrackingRecHitBuilder builder,
const MultiTrackFilterHitCollector measurementTracker,
const SiTrackerMultiRecHitUpdatorMTF updator,
const reco::BeamSpot bs,
AlgoProductCollection algoResults 
) const

Run the Final Fit taking TrackCandidates as input.

Definition at line 25 of file MTFTrackProducerAlgorithm.cc.

References a, b, buildTrack(), calculateNdof(), collectHits(), cont, fit(), SiTrackerMultiRecHitUpdatorMTF::getAnnealingProgram(), j, LogDebug, Trajectory::measurements(), n, convertSQLiteXML::ok, and updateHits().

Referenced by MTFTrackProducer::produce().

36 {
37  edm::LogInfo("MTFTrackProducer") << "Number of Trajectories: " << theTrajectoryCollection.size() << "\n";
38 
39  int cont = 0;
40  float ndof = 0;
41  //a for cicle to get a vector of trajectories, for building the vector<MTM>
42  std::vector<Trajectory> mvtraj=theTrajectoryCollection;
43 
44 
45 
46  //now we create a map, in which we store a vector<TrajMeas> for each trajectory in the event
47  std::map<int, std::vector<TrajectoryMeasurement> > mvtm;
48  int a=0;
49 
50  for(std::vector<Trajectory>::iterator imvtraj=mvtraj.begin(); imvtraj!=mvtraj.end(); imvtraj++)
51  //for(int a=1; a<=mvtraj.size(); a++)
52  {
53 
54  Trajectory *traj = &(*imvtraj);
55  mvtm.insert( make_pair(a, traj->measurements()) );
56  a++;
57  }
58 
59  LogDebug("MTFTrackProducerAlgorithm") << "after the cicle found " << mvtraj.size() << " trajectories" << std::endl;
60  LogDebug("MTFTrackProducerAlgorithm") << "built a map of " << mvtm.size() << " elements (trajectories, yeah)" << std::endl;
61 
62  //here we do a first fit with annealing factor 1, and we collect the hits for the first time
63  std::vector<std::pair<TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface> > vecmrhits;
64  std::vector<Trajectory> transientmvtraj;
65  int b=0;
66  for(std::vector<Trajectory>::const_iterator im=mvtraj.begin(); im!=mvtraj.end(); im++)
67 
68  {
69 
70  LogDebug("MTFTrackProducerAlgorithm") << "about to collect hits for the trajectory number " << b << std::endl;
71 
72  //collect hits and put in the vector vecmrhits to initialize it
73  std::pair<TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface> hits = collectHits(mvtm, measurementCollector, b);
74  vecmrhits.push_back(hits);
75 
76  LogDebug("MTFTrackProducerAlgorithm") << "hits collected";
77 
78  //build a vector of 1 element, to re-use the same method of DAF
79  std::vector<Trajectory> vtraj(1,(*im));
80 
81  //do the fit, taking a vector of trajectories with only an element
82  bool fitresult = fit(hits, theFitter, vtraj);
83  LogDebug("MTFTrackProducerAlgorithm") << "fit done";
84 
85  //extract the element trajectory from the vector,if it's not empty
86  if(fitresult == true)
87  {
88  LogDebug("MTFTrackProducerAlgorithm") << "fit was good for trajectory number" << b << "\n"
89  << "the trajectory has size" << vtraj.size() << "\n"
90  << "and its number of measurements is: " << vtraj.front().measurements().size() << "\n";
91  Trajectory thetraj = vtraj.front();
92 
93  //put this trajectory in the vector of trajectories that will become the new mvtraj after the for cicle
94  transientmvtraj.push_back(thetraj);
95  }
96 
97  //else
98  //{
99  // LogDebug("MTFTrackProducerAlgorithm") << "KFSmoother returned a broken trajectory, keeping the old one" << b << "\n";
100  // transientmvtraj.push_back(*im);
101  //}
102 
103  b++;
104  }
105 
106  LogDebug("MTFTrackProducerAlgorithm") << "cicle finished";
107 
108  //replace the mvtraj with a new one done with MultiRecHits...
109  mvtraj.swap(transientmvtraj);
110  LogDebug("MTFTrackProducerAlgorithm") << " with " << mvtraj.size() << "trajectories\n";
111 
112 
113 
114 
115  //for cicle upon the annealing factor, with an update of the MRH every annealing step
116  for(std::vector<double>::const_iterator ian = updator->getAnnealingProgram().begin(); ian != updator->getAnnealingProgram().end(); ian++)
117 
118  {
119 
120  //creates a transientmvtm taking infos from the mvtraj vector
121  std::map<int, std::vector<TrajectoryMeasurement> > transientmvtm1;
122  int b=0;
123 
124  for(std::vector<Trajectory>::iterator imv=mvtraj.begin(); imv!=mvtraj.end(); imv++)
125  {
126  Trajectory *traj = &(*imv);
127  transientmvtm1.insert( make_pair(b,traj->measurements()) );
128  b++;
129  }
130 
131  //subs the old mvtm with a new one which takes into account infos from the previous iteration step
132  mvtm.swap(transientmvtm1);
133 
134  //update the vector with the hits to be used at succesive annealing step
135  vecmrhits.clear();
136 
137 
138  for (unsigned int d=0; d<mvtraj.size(); d++)
139  {
140 
141  std::pair<TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface>
142  curiterationhits = updateHits(mvtm, measurementCollector, updator, *ian, builder, d);
143 
144  vecmrhits.push_back(curiterationhits);
145 
146  }
147 
148 
149 
150  LogDebug("MTFTrackProducerAlgorithm") << "vector vecmrhits has size "
151  << vecmrhits.size() << std::endl;
152 
153 
154 
155 
156 
157  //define a transient vector to replace the original mvmtraj with
158  std::vector<Trajectory> transientmvtrajone;
159 
160  int n=0;
161  //for cicle on the trajectories of the vector mvtraj
162  for(std::vector<Trajectory>::const_iterator j=mvtraj.begin(); j!=mvtraj.end(); j++)
163  {
164 
165  //create a vector of 1 element vtraj
166  std::vector<Trajectory> vtraj(1,(*j));
167 
168  if(vtraj.size()){
169 
170  LogDebug("MTFTrackProducerAlgorithm") << "Seed direction is " << vtraj.front().seed().direction()
171  << "Traj direction is " << vtraj.front().direction();
172 
173 
174 
175  //~~~~update with annealing factor (updator modified with respect to the DAF)~~~~
176  //std::pair<TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface>
177  // curiterationhits = updateHits(mvtm, measurementCollector, updator, *ian, builder, n);
178 
179  //fit with multirechits
180  fit(vecmrhits[n], theFitter, vtraj);
181 
182  //std::pair<TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface>
183  // curiterationhits = updateHits(mvtm, measurementCollector, updator, *ian, builder, n);
184 
185  //LogDebug("MTFTrackProducerAlgorithm") << "done annealing value " << (*ian) << " with " << vtraj.size() << " trajectories";
186  }
187 
188  else
189 
190  {
191  LogDebug("MTFTrackProducerAlgorithm") << "in map making skipping trajectory number: " << n <<"\n";
192  continue;
193  }
194 
195  //extract the trajectory from the vector vtraj
196  Trajectory thetraj = vtraj.front();
197 
198  //check if the fit has succeded
199  //if(!vtraj.empty())
200  //{
201  // LogDebug("MTFTrackProducerAlgorithm") << "Size correct " << "\n";
202 
203  //if the vector vtraj is not empty add a trajectory to the vector
204  transientmvtrajone.push_back(thetraj);
205  // }
206  //if vtraj is empty fill the vector with the trajectory coming from the previous annealing step
207  //else
208  //{
209  //LogDebug("MTFTrackProducerAlgorithm") << "trajectory broken by the smoother, keeping the old one " <<"\n";
210  //transientmvtrajone.push_back(*j);
211  //}
212 
213  n++;
214  }
215 
216  //substitute the vector mvtraj with the transient one
217  mvtraj.swap(transientmvtrajone);
218 
219 
220 
221  LogDebug("MTFTrackProducerAlgorithm") << "number of trajectories after annealing value "
222  << (*ian)
223  << " annealing step "
224  << mvtraj.size() << std::endl;
225  }
226 
227  //std::pair<TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface>
228  // curiterationhits = updateHits(mvtm, measurementCollector, updator, *ian, builder, n);
229 
230  LogDebug("MTFTrackProducerAlgorithm") << "Ended annealing program with " << mvtraj.size() << " trajectories" << std::endl;
231 
232 
233  //define a transient vector to replace the original mvmtm with
234 //std::vector<Trajectory> transientmvtm1;
235 
236 //for on the trajectories of the vector mvtraj
237  for(std::vector<Trajectory>::iterator it=mvtraj.begin(); it!=mvtraj.end();it++){
238 
239  std::vector<Trajectory> vtraj(1,(*it));
240 
241  //check the trajectory to see that the number of valid hits with
242  //reasonable weight (>1e-6) is higher than the minimum set in the DAFTrackProducer.
243  //This is a kind of filter to remove tracks with too many outliers.
244  //Outliers are mrhits with all components with weight less than 1e-6
245 
246  //std::vector<Trajectory> filtered;
247  //filter(theFitter, vtraj, conf_.getParameter<int>("MinHits"), filtered);
248  //ndof = calculateNdof(filtered);
249  ndof = calculateNdof(vtraj);
250  //bool ok = buildTrack(filtered, algoResults, ndof, bs);
251  bool ok = buildTrack(vtraj, algoResults, ndof, bs);
252  if(ok) cont++;
253 
254  }
255 
256  edm::LogInfo("TrackProducer") << "Number of Tracks found: " << cont << "\n";
257 
258 }
#define LogDebug(id)
const std::vector< double > & getAnnealingProgram() const
float calculateNdof(const std::vector< Trajectory > &vtraj) const
DataContainer const & measurements() const
Definition: Trajectory.h:169
int j
Definition: DBlmapReader.cc:9
std::pair< TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface > updateHits(const std::map< int, std::vector< TrajectoryMeasurement > > &mapvtm, const MultiTrackFilterHitCollector *measurementCollector, const SiTrackerMultiRecHitUpdatorMTF *updator, double annealing, const TransientTrackingRecHitBuilder *builder, int i) const
std::pair< TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface > collectHits(const std::map< int, std::vector< TrajectoryMeasurement > > &mapvtm, const MultiTrackFilterHitCollector *measurementCollector, int i) const
bool buildTrack(const std::vector< Trajectory > &, AlgoProductCollection &algoResults, float, const reco::BeamSpot &) const
Construct Tracks to be put in the event.
double b
Definition: hdecay.h:120
int cont
bool fit(const std::pair< TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface > &hits, const TrajectoryFitter *theFitter, std::vector< Trajectory > &vtraj) const
accomplishes the fitting-smoothing step for each annealing value
double a
Definition: hdecay.h:121
std::pair< TransientTrackingRecHit::RecHitContainer, TrajectoryStateOnSurface > MTFTrackProducerAlgorithm::updateHits ( const std::map< int, std::vector< TrajectoryMeasurement > > &  mapvtm,
const MultiTrackFilterHitCollector measurementCollector,
const SiTrackerMultiRecHitUpdatorMTF updator,
double  annealing,
const TransientTrackingRecHitBuilder builder,
int  i 
) const
private

Definition at line 294 of file MTFTrackProducerAlgorithm.cc.

References TransientTrackingRecHitBuilder::build(), SiTrackerMultiRecHitUpdatorMTF::buildMultiRecHit(), TrajectoryStateCombiner::combine(), LogDebug, and MultiTrackFilterHitCollector::TSOSfinder().

Referenced by runWithCandidate().

299  {
300  using namespace std;
301 
302  std::map< int, std::vector<TrajectoryMeasurement> >::const_iterator itmeas = mapvtm.find(i);
303  LogDebug("SimpleMTFHitCollector") << "found the element "<< i
304  << "in the map" << std::endl;
305 
306  std::vector<TrajectoryMeasurement> meas = itmeas->second;
308 
309  if (meas.empty()) {LogDebug("MTFTrackProducerAlgorithm::updateHits") << "Warning!!!The trajectory measurement vector is empty" << "\n";}
310 
311  for(vector<TrajectoryMeasurement>::reverse_iterator imeas = meas.rbegin(); imeas != meas.rend(); imeas++)
312 
313  {
314  if( imeas->recHit()->isValid() ) //&& imeas->recHit()->recHits().size() )
315 
316  {
317 
318 
319  std::vector<const TrackingRecHit*> trechit = imeas->recHit()->recHits();
320  // if ( typeid( *(imeas->recHit()) ) == typeid(TSiTrackerMultiRecHit) )
321  // LogDebug("SimpleMTFHitCollector") << "Hi, I am a MultiRecHit, and you? "<< "\n";
322  // else LogDebug("MTFTrackProducerAlgorithm::updateHits") << "rechit type: " << imeas->recHit()->getType() << "\n";
323 
324  LogDebug("MTFTrackProducerAlgorithm::updateHits") << "multirechit vector size: " << trechit.size() << "\n";
325 
327 
328  for (vector<const TrackingRecHit*>::iterator itrechit=trechit.begin(); itrechit!=trechit.end(); itrechit++)
329  {
330 
331  hits.push_back( builder->build(*itrechit));
332  // LogDebug("MTFTrackProducerAlgorithm") << "In updateHits method: RecHits transformed from tracking to transient "
333  // << "in the detector with detid: " << (*itrechit)->geographicalId().rawId() << "\n";
334  }
335 
336  MultiTrajectoryMeasurement multitm = measurementCollector->TSOSfinder(mapvtm, *imeas, i);
337 
338  TrajectoryStateCombiner statecombiner;
339  TrajectoryStateOnSurface combinedtsos = statecombiner.combine(imeas->predictedState(), imeas->backwardPredictedState());
340  TrajectoryStateOnSurface predictedtsos = imeas->predictedState();
341 
342  //the method is the same of collectHits, but with an annealing factor, different from 1.0
343  //TransientTrackingRecHit::RecHitContainer hits;
344  TransientTrackingRecHit::RecHitPointer mrh = updator->buildMultiRecHit(combinedtsos, hits, &multitm, annealing);
345 
346  //passing the predicted state, should be the combined one (to be modified)
347  //TransientTrackingRecHit::RecHitPointer mrh = updator->buildMultiRecHit(predictedtsos, hits, &multitm, annealing);
348 
349  multirechits.push_back(mrh);
350 
351 
352  }
353  else
354  {
355 
356  multirechits.push_back(imeas->recHit());
357 
358  }
359 
360 
361  }
362 
363 
364  return std::make_pair(multirechits,TrajectoryStateWithArbitraryError()(itmeas->second.back().predictedState()));
365 
366 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
TSOS combine(const TSOS &pTsos1, const TSOS &pTsos2) const
std::vector< ConstRecHitPointer > RecHitContainer
virtual TransientTrackingRecHit::RecHitPointer buildMultiRecHit(TrajectoryStateOnSurface &tsos, TransientTrackingRecHit::ConstRecHitContainer &hits, MultiTrajectoryMeasurement *mtm, float annealing=1.) const
virtual RecHitPointer build(const TrackingRecHit *p) const =0
build a tracking rechit from an existing rechit
virtual MultiTrajectoryMeasurement TSOSfinder(const std::map< int, std::vector< TrajectoryMeasurement > > &tmmap, TrajectoryMeasurement &pmeas, int i) const =0

Member Data Documentation

edm::ParameterSet MTFTrackProducerAlgorithm::conf_
private

Definition at line 88 of file MTFTrackProducerAlgorithm.h.