CMS 3D CMS Logo

GlobalCosmicMuonTrajectoryBuilder Class Reference

#include <RecoMuon/CosmicMuonProducer/interface/GlobalCosmicMuonTrajectoryBuilder.h>

Inheritance diagram for GlobalCosmicMuonTrajectoryBuilder:

MuonTrajectoryBuilder

List of all members.

Public Types

typedef
MuonTransientTrackingRecHit::ConstMuonRecHitContainer 
ConstMuonRecHitContainer
typedef
MuonTransientTrackingRecHit::ConstMuonRecHitPointer 
ConstMuonRecHitPointer
typedef
TransientTrackingRecHit::ConstRecHitContainer 
ConstRecHitContainer
typedef
TransientTrackingRecHit::ConstRecHitPointer 
ConstRecHitPointer
typedef
MuonTransientTrackingRecHit::MuonRecHitContainer 
MuonRecHitContainer
typedef
MuonTransientTrackingRecHit::MuonRecHitPointer 
MuonRecHitPointer
typedef
TransientTrackingRecHit::RecHitContainer 
RecHitContainer
typedef
TransientTrackingRecHit::RecHitPointer 
RecHitPointer
typedef std::pair< const
Trajectory *, reco::TrackRef
TrackCand

Public Member Functions

 GlobalCosmicMuonTrajectoryBuilder (const edm::ParameterSet &, const MuonServiceProxy *service)
 Constructor.
std::vector< TrackCandmatch (const TrackCand &, const edm::Handle< reco::TrackCollection > &)
 check if tk and muon Tracks are matched
const Propagatorpropagator () const
virtual void setEvent (const edm::Event &)
 pass the Event to the algo at each event
virtual CandidateContainer trajectories (const TrackCand &)
 choose tk Track and build combined trajectories
std::vector< Trajectory * > trajectories (const TrajectorySeed &)
 dummy implementation, unused in this class
virtual ~GlobalCosmicMuonTrajectoryBuilder ()
 Destructor.

Private Member Functions

ConstRecHitContainer getTransientRecHits (const reco::Track &) const
bool isTraversing (const reco::Track &tk) const
CosmicMuonSmoothersmoother () const
void sortHits (ConstRecHitContainer &, ConstRecHitContainer &, ConstRecHitContainer &)
CosmicMuonUtilitiesutilities () const

Private Attributes

const std::vector< Trajectory > * allTrackerTrajs
std::string category_
edm::ESHandle
< TransientTrackingRecHitBuilder
theMuonRecHitBuilder
std::string theMuonRecHitBuilderName
std::string thePropagatorName
const MuonServiceProxy * theService
CosmicMuonSmoothertheSmoother
edm::InputTag theTkTrackLabel
edm::ESHandle
< TransientTrackingRecHitBuilder
theTrackerRecHitBuilder
std::string theTrackerRecHitBuilderName
edm::Handle
< reco::TrackCollection
theTrackerTracks
GlobalMuonTrackMatchertheTrackMatcher
bool tkTrajsAvailable


Detailed Description

Definition at line 34 of file GlobalCosmicMuonTrajectoryBuilder.h.


Member Typedef Documentation

typedef MuonTransientTrackingRecHit::ConstMuonRecHitContainer GlobalCosmicMuonTrajectoryBuilder::ConstMuonRecHitContainer

Definition at line 45 of file GlobalCosmicMuonTrajectoryBuilder.h.

typedef MuonTransientTrackingRecHit::ConstMuonRecHitPointer GlobalCosmicMuonTrajectoryBuilder::ConstMuonRecHitPointer

Definition at line 43 of file GlobalCosmicMuonTrajectoryBuilder.h.

typedef TransientTrackingRecHit::ConstRecHitContainer GlobalCosmicMuonTrajectoryBuilder::ConstRecHitContainer

Definition at line 38 of file GlobalCosmicMuonTrajectoryBuilder.h.

typedef TransientTrackingRecHit::ConstRecHitPointer GlobalCosmicMuonTrajectoryBuilder::ConstRecHitPointer

Definition at line 40 of file GlobalCosmicMuonTrajectoryBuilder.h.

typedef MuonTransientTrackingRecHit::MuonRecHitContainer GlobalCosmicMuonTrajectoryBuilder::MuonRecHitContainer

Definition at line 44 of file GlobalCosmicMuonTrajectoryBuilder.h.

typedef MuonTransientTrackingRecHit::MuonRecHitPointer GlobalCosmicMuonTrajectoryBuilder::MuonRecHitPointer

Definition at line 42 of file GlobalCosmicMuonTrajectoryBuilder.h.

typedef TransientTrackingRecHit::RecHitContainer GlobalCosmicMuonTrajectoryBuilder::RecHitContainer

Definition at line 37 of file GlobalCosmicMuonTrajectoryBuilder.h.

typedef TransientTrackingRecHit::RecHitPointer GlobalCosmicMuonTrajectoryBuilder::RecHitPointer

Definition at line 39 of file GlobalCosmicMuonTrajectoryBuilder.h.

typedef std::pair<const Trajectory*,reco::TrackRef> GlobalCosmicMuonTrajectoryBuilder::TrackCand

Reimplemented from MuonTrajectoryBuilder.

Definition at line 46 of file GlobalCosmicMuonTrajectoryBuilder.h.


Constructor & Destructor Documentation

GlobalCosmicMuonTrajectoryBuilder::GlobalCosmicMuonTrajectoryBuilder ( const edm::ParameterSet par,
const MuonServiceProxy *  service 
)

Constructor.

Definition at line 33 of file GlobalCosmicMuonTrajectoryBuilder.cc.

References category_, edm::ParameterSet::getParameter(), theMuonRecHitBuilderName, thePropagatorName, theService, theSmoother, theTkTrackLabel, theTrackerRecHitBuilderName, and theTrackMatcher.

00034                                                                                                       : theService(service) {
00035   ParameterSet smootherPSet = par.getParameter<ParameterSet>("SmootherParameters");
00036   theSmoother = new CosmicMuonSmoother(smootherPSet,theService);
00037 
00038   ParameterSet trackMatcherPSet = par.getParameter<ParameterSet>("GlobalMuonTrackMatcher");
00039   theTrackMatcher = new GlobalMuonTrackMatcher(trackMatcherPSet,theService);
00040 
00041   theTkTrackLabel = par.getParameter<InputTag>("TkTrackCollectionLabel");
00042   theTrackerRecHitBuilderName = par.getParameter<string>("TrackerRecHitBuilder");
00043   theMuonRecHitBuilderName = par.getParameter<string>("MuonRecHitBuilder");
00044   thePropagatorName = par.getParameter<string>("Propagator");
00045   category_ = "Muon|RecoMuon|CosmicMuon|GlobalCosmicMuonTrajectoryBuilder";
00046 
00047 }

GlobalCosmicMuonTrajectoryBuilder::~GlobalCosmicMuonTrajectoryBuilder (  )  [virtual]

Destructor.

Definition at line 53 of file GlobalCosmicMuonTrajectoryBuilder.cc.

References theSmoother.

00053                                                                       {
00054 
00055   if (theSmoother) delete theSmoother;
00056 
00057 }


Member Function Documentation

TransientTrackingRecHit::ConstRecHitContainer GlobalCosmicMuonTrajectoryBuilder::getTransientRecHits ( const reco::Track track  )  const [private]

Definition at line 291 of file GlobalCosmicMuonTrajectoryBuilder.cc.

References category_, DetId::det(), TrajectoryStateTransform::innerStateOnSurface(), TrajectoryStateOnSurface::isValid(), LogTrace, DetId::Muon, reco::Track::recHitsBegin(), reco::Track::recHitsEnd(), HLT_VtxMuL3::result, theMuonRecHitBuilder, thePropagatorName, theService, theTrackerRecHitBuilder, and DetId::Tracker.

Referenced by trajectories().

00291                                                                                    {
00292 
00293   TransientTrackingRecHit::ConstRecHitContainer result;
00294 
00295   TrajectoryStateTransform tsTrans;
00296 
00297   TrajectoryStateOnSurface currTsos = tsTrans.innerStateOnSurface(track, *theService->trackingGeometry(), &*theService->magneticField());
00298   for (trackingRecHit_iterator hit = track.recHitsBegin(); hit != track.recHitsEnd(); ++hit) {
00299     if((*hit)->isValid()) {
00300       DetId recoid = (*hit)->geographicalId();
00301       if ( recoid.det() == DetId::Tracker ) {
00302         TransientTrackingRecHit::RecHitPointer ttrhit = theTrackerRecHitBuilder->build(&**hit);
00303         TrajectoryStateOnSurface predTsos =  theService->propagator(thePropagatorName)->propagate(currTsos, theService->trackingGeometry()->idToDet(recoid)->surface());
00304         LogTrace(category_)<<"predtsos "<<predTsos.isValid();
00305         if ( predTsos.isValid() ) {
00306           currTsos = predTsos;
00307           TransientTrackingRecHit::RecHitPointer preciseHit = ttrhit->clone(currTsos);
00308           result.push_back(preciseHit);
00309        }
00310       } else if ( recoid.det() == DetId::Muon ) {
00311         result.push_back(theMuonRecHitBuilder->build(&**hit));
00312       }
00313     }
00314   }
00315   return result;
00316 }

bool GlobalCosmicMuonTrajectoryBuilder::isTraversing ( const reco::Track tk  )  const [private]

Definition at line 446 of file GlobalCosmicMuonTrajectoryBuilder.cc.

References HLT_VtxMuL3::firstValid, PV3DBase< T, PVType, FrameType >::mag(), middle, reco::Track::recHitsBegin(), reco::Track::recHitsEnd(), theService, PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by match().

00446                                                                                  {
00447 
00448   trackingRecHit_iterator firstValid;
00449   for (trackingRecHit_iterator hit = track.recHitsBegin(); hit != track.recHitsEnd(); ++hit) {
00450     if((*hit)->isValid()) {
00451        firstValid = hit;
00452        break;
00453     }
00454   }
00455 
00456   trackingRecHit_iterator lastValid;
00457   for (trackingRecHit_iterator hit = track.recHitsEnd() - 1; hit != track.recHitsBegin() - 1; --hit) {
00458     if((*hit)->isValid()) {
00459        lastValid = hit;
00460        break;
00461     }
00462   }
00463 
00464   GlobalPoint posFirst = theService->trackingGeometry()->idToDet((*firstValid)->geographicalId())->position();
00465 
00466   GlobalPoint posLast  = theService->trackingGeometry()->idToDet((*lastValid)->geographicalId() )->position();
00467 
00468   GlobalPoint middle((posFirst.x()+posLast.x())/2, (posFirst.y()+posLast.y())/2, (posFirst.z()+posLast.z())/2);
00469 
00470   if ( (middle.mag() < posFirst.mag()) && (middle.mag() < posLast.mag() ) ) {
00471      return true;
00472   }
00473   return false;
00474 
00475 }

std::vector< GlobalCosmicMuonTrajectoryBuilder::TrackCand > GlobalCosmicMuonTrajectoryBuilder::match ( const TrackCand mu,
const edm::Handle< reco::TrackCollection > &  tktracks 
)

check if tk and muon Tracks are matched

Definition at line 318 of file GlobalCosmicMuonTrajectoryBuilder.cc.

References PV3DBase< T, PVType, FrameType >::basicVector(), category_, e, e6, lat::endl(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), i, TrajectoryStateTransform::innerStateOnSurface(), isTraversing(), TrajectoryStateOnSurface::isValid(), iter, keep, LogTrace, PV3DBase< T, PVType, FrameType >::mag(), muonGeometry::mag(), GlobalMuonTrackMatcher::match(), TrajectoryStateTransform::outerStateOnSurface(), propagator(), HLT_VtxMuL3::result, theService, theTrackerTracks, and theTrackMatcher.

Referenced by trajectories().

00318                                                                                                                                                                   {
00319    
00320    std::vector<TrackCand> result;
00321 
00322    if ( fabs(mu.second->dxy()) > 200 ) return result;
00323 
00324    //no tracker tracks for muons that do not cross tracker
00325    TrajectoryStateTransform tsTrans;
00326    TrajectoryStateOnSurface innerTsos = tsTrans.innerStateOnSurface(*(mu.second), *theService->trackingGeometry(), &*theService->magneticField());
00327 
00328    TrajectoryStateOnSurface outerTsos = tsTrans.outerStateOnSurface(*(mu.second), *theService->trackingGeometry(), &*theService->magneticField());
00329 
00330    StateOnTrackerBound toTrackerBound(propagator());
00331 
00332    TrajectoryStateOnSurface tkState = toTrackerBound(innerTsos);
00333    if ( !tkState.isValid() ) tkState = toTrackerBound(outerTsos);
00334    if ( !tkState.isValid() ) return result;
00335 
00336    //build tracker TrackCands and pick the best match if size greater than 2
00337    vector<TrackCand> tkTrackCands;
00338    for(reco::TrackCollection::size_type i=0; i<theTrackerTracks->size(); ++i){
00339      reco::TrackRef tkTrack(theTrackerTracks,i);
00340      TrackCand tkCand = TrackCand(0,tkTrack);
00341      tkTrackCands.push_back(tkCand);
00342      LogTrace(category_) << "chisq is " << theTrackMatcher->match(mu,tkCand,0,0);
00343      LogTrace(category_) << "d is " << theTrackMatcher->match(mu,tkCand,1,0);
00344      LogTrace(category_) << "r_pos is " << theTrackMatcher->match(mu,tkCand,2,0);
00345    }
00346 
00347    // now if only 1 tracker tracks, return it
00348    if (tkTrackCands.size() <= 1 ) {
00349       return tkTrackCands;
00350    }
00351  
00352    // if there're many tracker tracks
00353 
00354    // if muon is only on one side
00355    GlobalPoint innerPos = innerTsos.globalPosition();
00356    GlobalPoint outerPos = outerTsos.globalPosition();
00357 
00358    if ( ( innerPos.basicVector().dot( innerTsos.globalMomentum().basicVector() ) *
00359        outerPos.basicVector().dot(outerTsos.globalMomentum().basicVector() ) > 0 ) ) {
00360 
00361       GlobalPoint geoInnerPos = (innerPos.mag() < outerPos.mag()) ? innerPos : outerPos;
00362      LogTrace(category_) <<"geoInnerPos Mu "<<geoInnerPos<<endl;
00363 
00364      // if there're tracker tracks totally on the other half
00365      // and there're tracker tracks on the same half
00366      // remove the tracks on the other half
00367      for(vector<TrackCand>::const_iterator itkCand = tkTrackCands.begin(); itkCand != tkTrackCands.end(); ++itkCand) {
00368 
00369         reco::TrackRef tkTrack = itkCand->second;
00370 
00371         GlobalPoint tkInnerPos(tkTrack->innerPosition().x(), tkTrack->innerPosition().y(), tkTrack->innerPosition().z());
00372         GlobalPoint tkOuterPos(tkTrack->outerPosition().x(), tkTrack->outerPosition().y(), tkTrack->outerPosition().z());
00373         LogTrace(category_) <<"tkTrack "<<tkInnerPos<<" "<<tkOuterPos<<endl;
00374 
00375         float closetDistance11 =  (geoInnerPos - tkInnerPos).mag() ; 
00376         float closetDistance12 =  (geoInnerPos - tkOuterPos).mag() ;
00377         float closetDistance1 = (closetDistance11 < closetDistance12) ? closetDistance11 : closetDistance12;
00378         LogTrace(category_) <<"closetDistance1 "<<closetDistance1<<endl;
00379 
00380         if (true || !isTraversing(*tkTrack) ) {
00381             bool keep = true;
00382             for(vector<TrackCand>::const_iterator itkCand2 = tkTrackCands.begin(); itkCand2 != tkTrackCands.end(); ++itkCand2) {
00383                 if (itkCand2 == itkCand ) continue;
00384                 reco::TrackRef tkTrack2 = itkCand2->second;
00385 
00386                 GlobalPoint tkInnerPos2(tkTrack2->innerPosition().x(), tkTrack2->innerPosition().y(), tkTrack2->innerPosition().z());
00387                 GlobalPoint tkOuterPos2(tkTrack2->outerPosition().x(), tkTrack2->outerPosition().y(), tkTrack2->outerPosition().z());
00388                 LogTrace(category_) <<"tkTrack2 "<< tkInnerPos2 <<" "<<tkOuterPos2 <<endl;
00389 
00390                 float farthestDistance21 =  (geoInnerPos - tkInnerPos2).mag() ;
00391                 float farthestDistance22 =  (geoInnerPos - tkOuterPos2).mag() ;
00392                 float farthestDistance2 = (farthestDistance21 > farthestDistance22) ? farthestDistance21 : farthestDistance22;
00393                 LogTrace(category_) <<"farthestDistance2 "<<farthestDistance2<<endl;
00394 
00395                 if (closetDistance1 > farthestDistance2 - 1e-3) {
00396                      keep = false;
00397                      break;
00398                 } 
00399             }
00400             if (keep) result.push_back(*itkCand);
00401             else LogTrace(category_) <<"The Track is on different hemisphere"<<endl;
00402         } else {
00403           result.push_back(*itkCand);
00404         } 
00405      }
00406      if ( result.empty() ) { 
00407         //if all tk tracks on the other side, still keep them
00408         result = tkTrackCands;
00409      }
00410    } else { // muon is traversing
00411        result = tkTrackCands;
00412    }
00413 
00414   // match muCand to tkTrackCands
00415   vector<TrackCand> matched_trackerTracks = theTrackMatcher->match(mu, result);
00416 
00417   LogTrace(category_) <<"TrackMatcher found " << matched_trackerTracks.size() << "tracker tracks matched";
00418   
00419   //now pick the best matched one
00420   if(  matched_trackerTracks.size() < 2 ) {
00421     return matched_trackerTracks;
00422   } else {
00423     // in case of more than 1 tkTrack,
00424     // select the best-one based on distance (matchOption==1)
00425     // at innermost Mu hit surface. (surfaceOption == 0)
00426     result.clear();
00427     TrackCand bestMatch;
00428 
00429     double quality = 1e6;
00430     double max_quality = 1e6;
00431     for( vector<TrackCand>::const_iterator iter = matched_trackerTracks.begin(); iter != matched_trackerTracks.end(); iter++) {
00432       quality = theTrackMatcher->match(mu,*iter, 1, 0);
00433       LogTrace(category_) <<" quality of tracker track is " << quality;
00434       if( quality < max_quality ) {
00435         max_quality=quality;
00436         bestMatch = (*iter);
00437       }
00438     }
00439     LogTrace(category_) <<" Picked tracker track with quality " << max_quality;
00440     result.push_back(bestMatch);
00441     return result;
00442   }  
00443 }

const Propagator* GlobalCosmicMuonTrajectoryBuilder::propagator ( void   )  const [inline]

Definition at line 57 of file GlobalCosmicMuonTrajectoryBuilder.h.

References thePropagatorName, and theService.

Referenced by match().

00057 {return &*theService->propagator(thePropagatorName);}

void GlobalCosmicMuonTrajectoryBuilder::setEvent ( const edm::Event event  )  [virtual]

pass the Event to the algo at each event

Implements MuonTrajectoryBuilder.

Definition at line 62 of file GlobalCosmicMuonTrajectoryBuilder.cc.

References theMuonRecHitBuilder, theMuonRecHitBuilderName, theService, theTkTrackLabel, theTrackerRecHitBuilder, theTrackerRecHitBuilderName, and theTrackerTracks.

00062                                                                       {
00063   event.getByLabel(theTkTrackLabel,theTrackerTracks);
00064 
00065 //  edm::Handle<std::vector<Trajectory> > handleTrackerTrajs;
00066 //  if ( event.getByLabel(theTkTrackLabel,handleTrackerTrajs) && handleTrackerTrajs.isValid() ) {
00067 //      tkTrajsAvailable = true;
00068 //      allTrackerTrajs = &*handleTrackerTrajs;   
00069 //      LogInfo("GlobalCosmicMuonTrajectoryBuilder") 
00070 //      << "Tk Trajectories Found! " << endl;
00071 //  } else {
00072 //      LogInfo("GlobalCosmicMuonTrajectoryBuilder") 
00073 //      << "No Tk Trajectories Found! " << endl;
00074 //      tkTrajsAvailable = false;
00075 //  }
00076 
00077    theService->eventSetup().get<TransientRecHitRecord>().get(theTrackerRecHitBuilderName,theTrackerRecHitBuilder);
00078     theService->eventSetup().get<TransientRecHitRecord>().get(theMuonRecHitBuilderName,theMuonRecHitBuilder);
00079 
00080 }

CosmicMuonSmoother* GlobalCosmicMuonTrajectoryBuilder::smoother (  )  const [inline, private]

Definition at line 73 of file GlobalCosmicMuonTrajectoryBuilder.h.

References theSmoother.

Referenced by utilities().

00073 {return theSmoother;}

void GlobalCosmicMuonTrajectoryBuilder::sortHits ( ConstRecHitContainer hits,
ConstRecHitContainer muonHits,
ConstRecHitContainer tkHits 
) [private]

Definition at line 195 of file GlobalCosmicMuonTrajectoryBuilder.cc.

References category_, lat::endl(), LogTrace, muonGeometry::mag(), middle, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by trajectories().

00195                                                                                                                                          {
00196 
00197    if ( tkHits.empty() ) {
00198       LogTrace(category_) << "No valid tracker hits";
00199       return;
00200    }
00201    if ( muonHits.empty() ) {
00202       LogTrace(category_) << "No valid muon hits";
00203       return;
00204    }
00205 
00206    ConstRecHitContainer::const_iterator frontTkHit = tkHits.begin();
00207    ConstRecHitContainer::const_iterator backTkHit  = tkHits.end() - 1;
00208    while ( !(*frontTkHit)->isValid() && frontTkHit != backTkHit) {frontTkHit++;}
00209    while ( !(*backTkHit)->isValid() && backTkHit != frontTkHit)  {backTkHit--;}
00210 
00211    ConstRecHitContainer::const_iterator frontMuHit = muonHits.begin();
00212    ConstRecHitContainer::const_iterator backMuHit  = muonHits.end() - 1;
00213    while ( !(*frontMuHit)->isValid() && frontMuHit != backMuHit) {frontMuHit++;}
00214    while ( !(*backMuHit)->isValid() && backMuHit != frontMuHit)  {backMuHit--;}
00215 
00216    if ( frontTkHit == backTkHit ) {
00217       LogTrace(category_) << "No valid tracker hits";
00218       return;
00219    }
00220    if ( frontMuHit == backMuHit ) {
00221       LogTrace(category_) << "No valid muon hits";
00222       return;
00223    }
00224 
00225   GlobalPoint frontTkPos = (*frontTkHit)->globalPosition();
00226   GlobalPoint backTkPos = (*backTkHit)->globalPosition();
00227 
00228   GlobalPoint frontMuPos = (*frontMuHit)->globalPosition();
00229   GlobalPoint backMuPos = (*backMuHit)->globalPosition();
00230 
00231   //sort hits going from higher to lower positions
00232   if ( frontTkPos.y() < backTkPos.y() )  {//check if tk hits order same direction
00233     reverse(tkHits.begin(), tkHits.end());
00234   }
00235 
00236   if ( frontMuPos.y() < backMuPos.y() )  {
00237     reverse(muonHits.begin(), muonHits.end());
00238   }
00239 
00240 //  LogTrace(category_)<< "tkHits after sort: "<<tkHits.size()<<endl;;
00241 //  LogTrace(category_) <<utilities()->print(tkHits)<<endl;
00242 //  LogTrace(category_) << "== End of tkHits == "<<endl;
00243 
00244 //  LogTrace(category_)<< "muonHits after sort: "<<muonHits.size()<<endl;;
00245 //  LogTrace(category_) <<utilities()->print(muonHits)<<endl;
00246 //  LogTrace(category_)<< "== End of muonHits == "<<endl;
00247 
00248   //separate muon hits into 2 different hemisphere
00249   ConstRecHitContainer::iterator middlepoint = muonHits.begin();
00250   bool insertInMiddle = false;
00251 
00252   for (ConstRecHitContainer::iterator ihit = muonHits.begin(); 
00253        ihit != muonHits.end() - 1; ihit++ ) {
00254     GlobalPoint ipos = (*ihit)->globalPosition();
00255     GlobalPoint nextpos = (*(ihit+1))->globalPosition();
00256     GlobalPoint middle((ipos.x()+nextpos.x())/2, (ipos.y()+nextpos.y())/2, (ipos.z()+nextpos.z())/2);
00257     LogTrace(category_)<<"ipos "<<ipos<<"nextpos"<<nextpos<<" middle "<<middle<<endl;
00258     if ( (middle.perp() < ipos.perp()) && (middle.perp() < nextpos.perp() ) ) {
00259       LogTrace(category_)<<"found middlepoint"<<endl;
00260       middlepoint = ihit;
00261       insertInMiddle = true;
00262       break;
00263     }
00264   }
00265 
00266   //insert track hits in correct order
00267   if ( insertInMiddle ) { //if tk hits should be sandwich
00268     GlobalPoint jointpointpos = (*middlepoint)->globalPosition();
00269     LogTrace(category_)<<"jointpoint "<<jointpointpos<<endl;
00270     if ((frontTkPos - jointpointpos).mag() > (backTkPos - jointpointpos).mag() ) {//check if tk hits order same direction
00271       reverse(tkHits.begin(), tkHits.end());
00272     }
00273     muonHits.insert(middlepoint+1, tkHits.begin(), tkHits.end());
00274     hits = muonHits; 
00275   } else { // append at one end
00276     if ( frontTkPos.y() < frontMuPos.y() ) { //insert at the end
00277       LogTrace(category_)<<"insert at the end "<<frontTkPos << frontMuPos <<endl;
00278 
00279       hits = muonHits; 
00280       hits.insert(hits.end(), tkHits.begin(), tkHits.end());
00281     } else { //insert at the beginning
00282       LogTrace(category_)<<"insert at the beginning "<<frontTkPos << frontMuPos <<endl;
00283       hits = tkHits;
00284       hits.insert(hits.end(), muonHits.begin(), muonHits.end());
00285     }
00286   }
00287 }

MuonCandidate::CandidateContainer GlobalCosmicMuonTrajectoryBuilder::trajectories ( const TrackCand muCand  )  [virtual]

choose tk Track and build combined trajectories

Implements MuonTrajectoryBuilder.

Definition at line 85 of file GlobalCosmicMuonTrajectoryBuilder.cc.

References category_, CosmicMuonSmoother::fit(), getTransientRecHits(), TrajectoryStateOnSurface::globalMomentum(), TrajectoryStateOnSurface::globalPosition(), TrajectoryStateTransform::innerStateOnSurface(), edm::Ref< C, T, F >::isNull(), TrajectoryStateOnSurface::isValid(), LogTrace, match(), Trajectory::measurements(), TrajectoryStateTransform::outerStateOnSurface(), HLT_VtxMuL3::result, sortHits(), theService, theSmoother, theTrackerTracks, CosmicMuonSmoother::trajectories(), and PV3DBase< T, PVType, FrameType >::y().

00085                                                                                                        {
00086 
00087   MuonCandidate::CandidateContainer result;
00088 
00089   if (!theTrackerTracks.isValid()) {
00090     LogTrace(category_)<< "Tracker Track collection is invalid!!!";
00091     return result;
00092   }
00093 
00094   LogTrace(category_) <<"Found "<<theTrackerTracks->size()<<" tracker Tracks";
00095   if (theTrackerTracks->empty()) return result;
00096 
00097   vector<TrackCand> matched = match(muCand, theTrackerTracks);
00098 
00099   LogTrace(category_) <<"TrackMatcher found " << matched.size() << "tracker tracks matched";
00100   
00101   if ( matched.empty()) return result;
00102   reco::TrackRef tkTrack = matched.front().second;
00103   
00104   if ( tkTrack.isNull() ) return result;
00105   reco::TrackRef muTrack = muCand.second;
00106 
00107   ConstRecHitContainer muRecHits;
00108 
00109   if (muCand.first == 0 || !muCand.first->isValid()) { 
00110      muRecHits = getTransientRecHits(*muTrack);
00111   } else {
00112      muRecHits = muCand.first->recHits();
00113   }
00114 
00115   LogTrace(category_)<<"mu RecHits: "<<muRecHits.size();
00116 
00117   ConstRecHitContainer tkRecHits = getTransientRecHits(*tkTrack);
00118 
00119 //  if ( !tkTrajsAvailable ) {
00120 //     tkRecHits = getTransientRecHits(*tkTrack);
00121 //  } else {
00122 //     tkRecHits = allTrackerTrajs->front().recHits();
00123 //  }
00124 
00125   ConstRecHitContainer hits; //= tkRecHits;
00126   LogTrace(category_)<<"tk RecHits: "<<tkRecHits.size();
00127 
00128 //  hits.insert(hits.end(), muRecHits.begin(), muRecHits.end());
00129 //  stable_sort(hits.begin(), hits.end(), DecreasingGlobalY());
00130 
00131   sortHits(hits, muRecHits, tkRecHits);
00132 
00133 //  LogTrace(category_)<< "Used RecHits after sort: "<<hits.size()<<endl;;
00134 //  LogTrace(category_) <<utilities()->print(hits)<<endl;
00135 //  LogTrace(category_) << "== End of Used RecHits == "<<endl;
00136 
00137   TrajectoryStateTransform tsTrans;
00138 
00139   TrajectoryStateOnSurface muonState1 = tsTrans.innerStateOnSurface(*muTrack, *theService->trackingGeometry(), &*theService->magneticField());
00140   TrajectoryStateOnSurface tkState1 = tsTrans.innerStateOnSurface(*tkTrack, *theService->trackingGeometry(), &*theService->magneticField());
00141 
00142   TrajectoryStateOnSurface muonState2 = tsTrans.outerStateOnSurface(*muTrack, *theService->trackingGeometry(), &*theService->magneticField());
00143   TrajectoryStateOnSurface tkState2 = tsTrans.outerStateOnSurface(*tkTrack, *theService->trackingGeometry(), &*theService->magneticField());
00144 
00145   TrajectoryStateOnSurface firstState1 =
00146    ( muonState1.globalPosition().y() > tkState1.globalPosition().y() )? muonState1 : tkState1;
00147   TrajectoryStateOnSurface firstState2 =
00148    ( muonState2.globalPosition().y() > tkState2.globalPosition().y() )? muonState2 : tkState2;
00149 
00150   TrajectoryStateOnSurface firstState =
00151    ( firstState1.globalPosition().y() > firstState2.globalPosition().y() )? firstState1 : firstState2;
00152 
00153   if (!firstState.isValid()) return result;
00154   
00155   LogTrace(category_) <<"firstTSOS pos: "<<firstState.globalPosition()<<"mom: "<<firstState.globalMomentum();
00156 
00157   // begin refitting
00158 
00159   TrajectorySeed seed;
00160   vector<Trajectory> refitted = theSmoother->trajectories(seed,hits,firstState);
00161 
00162   if ( refitted.empty() ) {
00163     LogTrace(category_)<<"smoothing trajectories fail";
00164 
00165     refitted = theSmoother->fit(seed,hits,firstState); //FIXME
00166   }
00167 
00168   if (refitted.empty()) {
00169      LogTrace(category_)<<"refit fail";
00170      return result;
00171   }
00172 
00173   Trajectory* myTraj = new Trajectory(refitted.front());
00174 
00175   const std::vector<TrajectoryMeasurement>& mytms = myTraj->measurements(); 
00176   LogTrace(category_)<<"measurements in final trajectory "<<mytms.size();
00177   LogTrace(category_) <<"Orignally there are "<<tkTrack->found()<<" tk rhs and "<<muTrack->found()<<" mu rhs.";
00178 
00179   if ( mytms.size() <= tkTrack->found() ) {
00180      LogTrace(category_)<<"insufficient measurements. skip... ";
00181      return result;
00182   }
00183 
00184   MuonCandidate* myCand = new MuonCandidate(myTraj,muTrack,tkTrack);
00185   result.push_back(myCand);
00186   LogTrace(category_)<<"final global cosmic muon: ";
00187   for (std::vector<TrajectoryMeasurement>::const_iterator itm = mytms.begin();
00188        itm != mytms.end(); ++itm ) {
00189        LogTrace(category_)<<"updated pos "<<itm->updatedState().globalPosition()
00190                        <<"mom "<<itm->updatedState().globalMomentum();
00191    }
00192   return result;
00193 }

std::vector<Trajectory*> GlobalCosmicMuonTrajectoryBuilder::trajectories ( const TrajectorySeed  )  [inline, virtual]

dummy implementation, unused in this class

Implements MuonTrajectoryBuilder.

Definition at line 55 of file GlobalCosmicMuonTrajectoryBuilder.h.

00055 {return std::vector<Trajectory*>();}

CosmicMuonUtilities* GlobalCosmicMuonTrajectoryBuilder::utilities (  )  const [inline, private]

Definition at line 75 of file GlobalCosmicMuonTrajectoryBuilder.h.

References smoother(), and CosmicMuonSmoother::utilities().

00075 {return smoother()->utilities();}


Member Data Documentation

const std::vector<Trajectory>* GlobalCosmicMuonTrajectoryBuilder::allTrackerTrajs [private]

Definition at line 98 of file GlobalCosmicMuonTrajectoryBuilder.h.

std::string GlobalCosmicMuonTrajectoryBuilder::category_ [private]

Definition at line 100 of file GlobalCosmicMuonTrajectoryBuilder.h.

Referenced by getTransientRecHits(), GlobalCosmicMuonTrajectoryBuilder(), match(), sortHits(), and trajectories().

edm::ESHandle<TransientTrackingRecHitBuilder> GlobalCosmicMuonTrajectoryBuilder::theMuonRecHitBuilder [private]

Definition at line 92 of file GlobalCosmicMuonTrajectoryBuilder.h.

Referenced by getTransientRecHits(), and setEvent().

std::string GlobalCosmicMuonTrajectoryBuilder::theMuonRecHitBuilderName [private]

Definition at line 91 of file GlobalCosmicMuonTrajectoryBuilder.h.

Referenced by GlobalCosmicMuonTrajectoryBuilder(), and setEvent().

std::string GlobalCosmicMuonTrajectoryBuilder::thePropagatorName [private]

Definition at line 85 of file GlobalCosmicMuonTrajectoryBuilder.h.

Referenced by getTransientRecHits(), GlobalCosmicMuonTrajectoryBuilder(), and propagator().

const MuonServiceProxy* GlobalCosmicMuonTrajectoryBuilder::theService [private]

Definition at line 79 of file GlobalCosmicMuonTrajectoryBuilder.h.

Referenced by getTransientRecHits(), GlobalCosmicMuonTrajectoryBuilder(), isTraversing(), match(), propagator(), setEvent(), and trajectories().

CosmicMuonSmoother* GlobalCosmicMuonTrajectoryBuilder::theSmoother [private]

Definition at line 81 of file GlobalCosmicMuonTrajectoryBuilder.h.

Referenced by GlobalCosmicMuonTrajectoryBuilder(), smoother(), trajectories(), and ~GlobalCosmicMuonTrajectoryBuilder().

edm::InputTag GlobalCosmicMuonTrajectoryBuilder::theTkTrackLabel [private]

Definition at line 86 of file GlobalCosmicMuonTrajectoryBuilder.h.

Referenced by GlobalCosmicMuonTrajectoryBuilder(), and setEvent().

edm::ESHandle<TransientTrackingRecHitBuilder> GlobalCosmicMuonTrajectoryBuilder::theTrackerRecHitBuilder [private]

Definition at line 89 of file GlobalCosmicMuonTrajectoryBuilder.h.

Referenced by getTransientRecHits(), and setEvent().

std::string GlobalCosmicMuonTrajectoryBuilder::theTrackerRecHitBuilderName [private]

Definition at line 88 of file GlobalCosmicMuonTrajectoryBuilder.h.

Referenced by GlobalCosmicMuonTrajectoryBuilder(), and setEvent().

edm::Handle<reco::TrackCollection> GlobalCosmicMuonTrajectoryBuilder::theTrackerTracks [private]

Definition at line 94 of file GlobalCosmicMuonTrajectoryBuilder.h.

Referenced by match(), setEvent(), and trajectories().

GlobalMuonTrackMatcher* GlobalCosmicMuonTrajectoryBuilder::theTrackMatcher [private]

Definition at line 83 of file GlobalCosmicMuonTrajectoryBuilder.h.

Referenced by GlobalCosmicMuonTrajectoryBuilder(), and match().

bool GlobalCosmicMuonTrajectoryBuilder::tkTrajsAvailable [private]

Definition at line 96 of file GlobalCosmicMuonTrajectoryBuilder.h.


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:21:26 2009 for CMSSW by  doxygen 1.5.4