42 theRoadEstimator(0),theHitEstimator(0),theUpdator(0),theSmoother(0)
50 theCategory =
"Muon|RecoMuon|MuonRoadTrajectoryBuilder";
58 double chi2R=iConfig.
getParameter<
double>(
"maxChi2Road");
112 if (s1>s2)
return true;
114 if (s1==s2)
return (traj1.
chi2<traj2.
chi2);
115 else return false; }}
131 std::vector<Trajectory>
result;
163 LogDebug(
theCategory) <<
"(detId.rawId()) "<<(detId.rawId())<<
"(detId.subdetId()) "<<(detId.subdetId())
171 bool theFirstlayer=
true;
183 initial.
traj=basicTrajectory;
190 std::vector<ForwardDetLayer*> tidlc[2];
193 std::vector<ForwardDetLayer*> teclc[2];
196 const int Ntib=tiblc.size();
197 const int Ntob=toblc.size();
198 const int Ntid=tidlc[0].size();
201 const int Ntec=teclc[0].size();
203 LogDebug(
theCategory)<<
"(Ntib) "<<(Ntib)<<
"(Ntob) "<<(Ntob)<<
"(Ntid) "<<(Ntid)<<
"(Ntec) "<<(Ntec);
213 PART whichpart = fault;
214 switch(detId.subdetId()){
215 case 1: {whichpart=PXB;
break;}
216 case 2: {whichpart=PXF;
break;}
218 case 3: {whichpart=
TIB;
break;}
219 case 4: {whichpart=
TID;
break;}
220 case 5: {whichpart=
TOB;
break;}
221 case 6: {whichpart=
TEC;
break;}}
224 bool firstRound =
true;
230 if (!
checkStep(Trajectories.
head(),theNumberOfHitPerModule))
break;
241 if (indexinpart==Ntib){whichpart =
TOB; indexinpart=-1;
break; }
252 if (fabs(z) > fabs(tidlc[(z>0)][0]->surface().
position().
z()))
254 LogDebug(
theCategory)<<
"|z| ("<<z<<
") bigger than the TID min z("<<tidlc[(z>0)][0]->surface().position().z()<<
"): go to TID";
255 whichpart =
TID; indexinpart=-1;
break;}
256 else { Nhits+=
GatherHits(TSOS,tiblc[indexinpart],Trajectories,theFirstlayer,theNumberOfHitPerModule);}
261 if (indexinpart==Ntid){ whichpart =
TEC; indexinpart=-1;
break;}
273 sdbounds =
dynamic_cast<const SimpleDiskBounds *
>(&tidlc[(z>0)][indexinpart]->surface().bounds());
277 if (r < sdbounds->innerRadius())
279 LogDebug(
theCategory)<<
"radius ("<<
r<<
") smaller than the TID disk inner radius ("<<sdbounds->innerRadius()<<
"): next disk please";
281 else if (
r >sdbounds->outerRadius())
283 LogDebug(
theCategory)<<
"radius ("<<
r<<
") bigger than the TID disk outer radius("<<sdbounds->outerRadius()<<
"): go to TOB";
284 whichpart =
TOB; indexinpart=-1;
break;}
287 Nhits+=
GatherHits(TSOS,tidlc[(z>0)][indexinpart],Trajectories,theFirstlayer,theNumberOfHitPerModule);}
292 if (indexinpart==Ntob){ inapart=
false;
break;}
303 if (fabs(z) > fabs(teclc[(z>0)][0]->surface().
position().
z()))
305 LogDebug(
theCategory)<<
"|z| ("<<z<<
") bigger than the TOB layer max z ("<< teclc[(z>0)][0]->surface().position().z()<<
"): go to TEC";
306 whichpart =
TEC; indexinpart=-1;
break;}
307 else {Nhits+=
GatherHits(TSOS,toblc[indexinpart],Trajectories,theFirstlayer,theNumberOfHitPerModule);}
312 if (indexinpart==Ntec){inapart=
false;
break;}
324 sdbounds =
dynamic_cast<const SimpleDiskBounds *
>(&teclc[(z>0)][indexinpart]->surface().bounds());
328 if (r < sdbounds->innerRadius())
330 LogDebug(
theCategory)<<
"radius ("<<
r<<
") smaller than the TEC disk inner radius ("<<sdbounds->innerRadius()<<
"): next disk please";
332 else if (
r > sdbounds->outerRadius())
334 LogDebug(
theCategory)<<
"radius ("<<
r<<
") bigger than the TEC disk outer radius ("<<sdbounds->outerRadius()<<
"): I can stop here";
335 inapart=
false;
break;}
336 else {Nhits+=
GatherHits(TSOS,teclc[(z>0)][indexinpart],Trajectories,theFirstlayer,theNumberOfHitPerModule);}
352 <<Nhits<<
" hits in the road for this seed \n"
353 << Trajectories.
head().size()<<
" possible trajectory(ies)";
364 for (TrajectoryCollection::iterator tit = Trajectories.
head().begin(); tit!=Trajectories.
head().end();tit++)
398 Trajectory::DataContainer::iterator mit = meas.begin();
399 while (mit!=meas.end()){
402 LogDebug(
theCategory)<<
"(mit->recHit()->det()->geographicalId().rawId()) "<<(mit->recHit()->det()->geographicalId().rawId())
403 <<
"(detLayer) "<<(detLayer)<<
"(lastDetLayer) "<<(lastDetLayer);
405 if (detLayer==lastDetLayer)
410 lastDetLayer=detLayer;
413 for (Trajectory::DataContainer::iterator mit=meas.begin();mit!=meas.end();++mit)
414 {newTraj.
push(*mit);}
432 for (Trajectory::DataContainer::iterator mit=meas.begin();mit!=meas.end();++mit)
433 {newTraj.
push(*mit);}
454 else{
return (ret.front());}
459 bool & theFirstlayer,
unsigned int theNumberOfHitPerModule)
const
462 bool atleastoneadded=
false;
469 for (std::vector< DetLayer::DetWithState > ::iterator dws = compatible.begin();dws != compatible.end();dws++)
471 const DetId presentdetid = dws->first->geographicalId();
472 restep = dws->second;
475 LogDebug(
theCategory)<<((dws->first->components ().size()!=0) ?
"double sided layer":
"single sided layer")
476 <<
"(presentdetid.rawId()) "<<(presentdetid.
rawId());
480 int additionalHits =0;
484 if (thoseHits.size()>theNumberOfHitPerModule)
486 <<
" compatible hits ("<<thoseHits.size()<<
")on module "<<presentdetid.
rawId()
487 <<
", skip it";
continue; }
490 for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator iTThit = thoseHits.begin();iTThit != thoseHits.end(); iTThit++)
494 LogDebug(
theCategory)<<((
dynamic_cast<const SiStripMatchedRecHit2D *
>((*iTThit)->hit())!=0) ?
"matched rechit" :
" r-phi rechit");
497 const BoundPlane & surface = (*iTThit)->det()->surface();
503 <<
"road step parameters at module: \n"<<restep
504 <<
"(est_road.first) "<<(est_road.first)<<
"(est_road.second) "<<(est_road.second);
511 atleastoneadded=
true;
514 <<
"loop over previous trajectories\n"
515 <<
"(Trajectories.tail().size()) "<<(Trajectories.
tail().size())<<
"(Trajectories.head().size()) "<<(Trajectories.
head().size());
519 for ( TrajectoryCollection::iterator traj =Trajectories.
head().begin();traj != Trajectories.
head().end(); traj++)
530 <<
"predicted state is not valid at trajectory update, rechit surface cannot be reached by the previous updated state.";
continue;}
547 Trajectories.
tail().push_back(*traj);
552 combined.
chi2 += est_road.second;
560 combined.
TSOS = updatedState;
562 combined.
traj.
push(trajMeasurement,est.second);
565 <<
"muon measurement on previous module: \n"<<traj->TSOS
566 <<
"muon measurement before update: \n"<<predictedState
567 <<
"muon measurement after update: \n"<<updatedState;
572 LogDebug(
theCategory)<<
"hit failed chi2 test for trajectories update\n"<<
"(traj->duplicate) "<<(traj->duplicate);
574 if (!traj->duplicate){
575 Trajectories.
tail().push_back(*traj);
580 traj->duplicate =
true;
590 if (!Trajectories.
tail().empty())
603 Trajectories.
tail().push_front(*Trajectories.
head().begin());
605 pushed.
missed+=additionalHits;
612 Trajectories.
head().clear();
623 if(theFirstlayer && atleastoneadded )
625 theFirstlayer =
false;
633 {Trajectories.
tail().push_front(*Trajectories.
head().begin());}
637 Trajectories.
head().clear();
650 Trajectories.
head().pop_front(); }
656 if (Trajectories.
head().size()>=2)
679 unsigned int prevSize=collection.size();
682 <<
" too many possible trajectories ("<<prevSize
693 TrajectoryCollection::iterator traj1 = collection.begin();
694 while(traj1 != collection.end())
699 TrajectoryCollection::iterator traj2 = traj1;
701 bool traj1_removed=
false;
702 while( traj2 != collection.end())
704 if (traj2 == traj1 )
continue;
707 std::list <TrajectoryMeasurement >::const_reverse_iterator h1 = traj1->measurements.rbegin();
708 std::list <TrajectoryMeasurement >::const_reverse_iterator h2 = traj2->measurements.rbegin();
710 bool break_different =
false;
711 while (h1 != traj1->measurements.rend() && h2!=traj2->measurements.rend())
716 LogDebug(
theCategory)<<
"(hit1->geographicalId().rawId()) "<<(hit1->geographicalId().rawId())<<
"(hit1->globalPosition()) "<<(hit1->globalPosition())
717 <<
"(hit2->geographicalId().rawId()) "<<(hit2->geographicalId().rawId())<<
"(hit2->globalPosition()) "<<(hit2->globalPosition());
719 if (hit1 == hit2){ h1++;h2++;
continue;}
720 else{break_different =
true;
726 if (!break_different)
734 if (h1 != traj1->measurements.rend())
738 traj2=collection.erase(traj2);
744 traj1=collection.erase(traj1);
std::vector< Trajectory > Trajectories
T getParameter(std::string const &) const
MeasurementDetWithData idToDet(const DetId &id) const
Previous MeasurementDetSystem interface.
~MuonRoadTrajectoryBuilder()
TrajectoryStateOnSurface const & predictedState() const
bool trajectorymeasurementInverseOrder(const TrajectoryMeasurement &meas_1, const TrajectoryMeasurement &meas_2)
std::vector< unsigned int > theMaxTrajectoriesThreshold
TrajectorySeed const & seed() const
Access to the seed used to reconstruct the Trajectory.
bool theCarriedIPatfirstlayerModule
std::string theCategory
Info/Debug category "Muon|RecoMuon|MuonRoadTrajectoryBuilder".
unsigned int theNumberOfHitPerModuleDefault
virtual TrajectoryStateOnSurface update(const TrajectoryStateOnSurface &, const TransientTrackingRecHit &) const =0
for the trajectory collection
MuonRoadTrajectoryBuilder(const edm::ParameterSet &par, const MeasurementTracker *mt, const MagneticField *f, const Propagator *p)
constructor from PSet and things from record
bool theDynamicMaxNumberOfHitPerModule
std::vector< Trajectory > trajectories(const TrajectorySeed &seed) const
bool theCarriedIPatfirstlayer
bool trajectoryOrder(const MuonRoadTrajectoryBuilder::trajectory &traj1, const MuonRoadTrajectoryBuilder::trajectory &traj2)
GlobalPoint globalPosition() const
void makeTrajectories(const TrajectorySeed &seed, std::vector< Trajectory > &result, int version=0) const
KFTrajectorySmoother * theSmoother
PreciseFloatType< T, U >::Type dot(const Vector3DBase< U, FrameTag > &v) const
Trajectory smooth(Trajectory &) const
std::vector< ForwardDetLayer * > const & posTecLayers() const
std::vector< unsigned int > theNumberOfHitPerModuleThreshold
Chi2MeasurementEstimator * theHitEstimator
bool theBranchonfirstlayer
const Plane & surface() const
The nominal surface of the GeomDet.
virtual std::vector< DetWithState > compatibleDets(const TrajectoryStateOnSurface &startingState, const Propagator &prop, const MeasurementEstimator &est) const
static int position[TOTALCHAMBERS][3]
const MeasurementTrackerEvent * theMeasurementTrackerEvent
void makeTrajectories_0(const TrajectorySeed &seed, std::vector< Trajectory > &result) const
PropagationDirection const & direction() const
uint32_t rawId() const
get the raw id
std::vector< ForwardDetLayer * > const & negTecLayers() const
DataContainer const & measurements() const
void setEvent(const edm::Event &) const
RecHitContainer recHits(const TrajectoryStateOnSurface &tsos) const
std::vector< Trajectory > TrajectoryContainer
std::vector< TrajectoryMeasurement > DataContainer
void cleanTrajectory(Trajectory &traj) const
int GatherHits(const TrajectoryStateOnSurface &step, const DetLayer *thislayer, TrajectoryCollectionFPair &Trajectories, bool &firstLayer, unsigned int theNumberOfHitPerModule) const
FreeTrajectoryState const * freeState(bool withErrors=true) const
unsigned int theMaxTrajectories
TrajectoryStateUpdator * theUpdator
const DetLayer * detLayer(const DetId &id) const
obsolete method. Use idToLayer() instead.
const TrackingGeometry * geomTracker() const
unsigned int detId() const
void makeTrajectories_1(const TrajectorySeed &seed, std::vector< Trajectory > &result) const
tuple Chi2MeasurementEstimator
const MeasurementTracker * theMeasurementTracker
void sortTrajectoryMeasurements(Trajectory &traj)
virtual TrajectoryStateOnSurface propagate(const FreeTrajectoryState &, const Surface &) const
std::list< TrajectoryMeasurement > measurements
std::vector< ConstRecHitPointer > ConstRecHitContainer
Vector3DBase unit() const
std::pair< bool, double > HitReturnType
TrajectoryStateOnSurface TSOS
PTrajectoryStateOnDet const & startingState() const
virtual const GeomDet * idToDet(DetId) const =0
std::list< trajectory > TrajectoryCollection
return(e1-e2)*(e1-e2)+dp *dp
Chi2MeasurementEstimator * theRoadEstimator
unsigned int theMinNumberOfHitOnCandidate
const MagneticField * theField
std::vector< BarrelDetLayer * > const & tibLayers() const
const Propagator * thePropagator
GlobalVector globalMomentum() const
std::vector< ForwardDetLayer * > const & posTidLayers() const
bool trajectorymeasurementOrder(const TrajectoryMeasurement &meas_1, const TrajectoryMeasurement &meas_2)
tuple KFTrajectorySmoother
std::vector< ForwardDetLayer * > const & negTidLayers() const
const GeometricSearchTracker * geometricSearchTracker() const
void push(const TrajectoryMeasurement &tm)
void checkDuplicate(TrajectoryCollection &collection) const
TrajectoryStateOnSurface TSOS
GlobalVector globalDirection() const
std::vector< BarrelDetLayer * > const & tobLayers() const
bool checkStep(TrajectoryCollection &collection, unsigned int &theNumberOfHitPerModule) const