CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

SeedFromGenericPairOrTriplet Class Reference

#include <SeedFromGenericPairOrTriplet.h>

List of all members.

Public Member Functions

bool momentumFromPSet ()
std::vector< TrajectorySeed * > seed (const SeedingHitSet &hits, const PropagationDirection &dir, const NavigationDirection &seedDir, const edm::EventSetup &iSetup)
 SeedFromGenericPairOrTriplet (const MagneticField *mf, const TrackerGeometry *geom, const TransientTrackingRecHitBuilder *builder, const Propagator *propagatorAlong, const Propagator *propagatorOpposite, const std::vector< int > &charges, bool momFromPSet, double errorRescaling)
TrajectorySeedseedFromPair (const SeedingHitSet &hits, const PropagationDirection &dir, const NavigationDirection &seedDir, int charge=-1) const
TrajectorySeedseedFromTriplet (const SeedingHitSet &hits, const PropagationDirection &dir, const NavigationDirection &seedDir, const edm::EventSetup &iSetup, int charge=-1) const
void setMomentumTo (double mom)
 ~SeedFromGenericPairOrTriplet ()

Private Member Functions

TrajectorySeedbuildSeed (const GlobalVector &momentum, int charge, std::vector< const TrackingRecHit * > &trHits, const PropagationDirection &dir) const
bool qualityFilter (const GlobalVector &momentum) const
bool qualityFilter (const SeedingHitSet &hits) const

Private Attributes

const
TransientTrackingRecHitBuilder
theBuilder
std::vector< int > theCharges
double theErrorRescaling
const MagneticFieldtheMagfield
float theP
const PropagatorthePropagatorAlong
const PropagatorthePropagatorOpposite
bool theSetMomentum
const TrackerGeometrytheTracker

Detailed Description

Definition at line 30 of file SeedFromGenericPairOrTriplet.h.


Constructor & Destructor Documentation

SeedFromGenericPairOrTriplet::SeedFromGenericPairOrTriplet ( const MagneticField mf,
const TrackerGeometry geom,
const TransientTrackingRecHitBuilder builder,
const Propagator propagatorAlong,
const Propagator propagatorOpposite,
const std::vector< int > &  charges,
bool  momFromPSet,
double  errorRescaling 
)

Definition at line 11 of file SeedFromGenericPairOrTriplet.cc.

                                                                                 :theMagfield(mf), theTracker(geom), theBuilder(builder), thePropagatorAlong(propagatorAlong), thePropagatorOpposite(propagatorOpposite), theSetMomentum(momFromPSet), theCharges(charges), theErrorRescaling(errorRescaling){}
SeedFromGenericPairOrTriplet::~SeedFromGenericPairOrTriplet ( ) [inline]

Definition at line 40 of file SeedFromGenericPairOrTriplet.h.

{};

Member Function Documentation

TrajectorySeed * SeedFromGenericPairOrTriplet::buildSeed ( const GlobalVector momentum,
int  charge,
std::vector< const TrackingRecHit * > &  trHits,
const PropagationDirection dir 
) const [private]

Definition at line 209 of file SeedFromGenericPairOrTriplet.cc.

References TransientTrackingRecHitBuilder::build(), first, TrackerGeometry::idToDet(), TrajectoryStateOnSurface::isValid(), LogDebug, PV3DBase< T, PVType, FrameType >::mag(), oppositeToMomentum, PV3DBase< T, PVType, FrameType >::perp(), trajectoryStateTransform::persistentState(), PV3DBase< T, PVType, FrameType >::phi(), Propagator::propagate(), LargeD0_PixelPairStep_cff::propagator, edm::OwnVector< T, P >::push_back(), TrajectoryStateOnSurface::rescaleError(), edm::second(), seed(), GeomDet::surface(), theBuilder, theErrorRescaling, thePropagatorAlong, thePropagatorOpposite, PV3DBase< T, PVType, FrameType >::theta(), theTracker, Surface::toGlobal(), TrajectoryStateOnSurface::update(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by seedFromPair(), and seedFromTriplet().

                                                                                               {
        const Propagator* propagator = thePropagatorAlong;
        if (dir == oppositeToMomentum) propagator = thePropagatorOpposite;

        //debug
        GlobalPoint first = theTracker->idToDet(trHits[0]->geographicalId() )->surface().toGlobal(trHits[0]->localPosition() );
        GlobalPoint second  = theTracker->idToDet(trHits[1]->geographicalId() )->surface().toGlobal(trHits[1]->localPosition() );
        LogDebug("SeedFromGenericPairOrTriplet") <<
                        "Using the following hits: first(r, phi, theta) (" << first.perp()
                        << ", " << first.phi()
                        << "," << first.theta()
                        <<")    second ("
                        << second.perp()
                        << ", " << second.phi()
                        << "," << second.theta() <<")";
        //build an initial trajectory state with big errors, 
        //then update it with the first hit
        TransientTrackingRecHit::RecHitPointer transHit = theBuilder->build(trHits[0]);
        LocalVector lmom = transHit->surface()->toLocal(momentum);
        LocalTrajectoryParameters ltp(charge/momentum.mag(),
                                      lmom.x()/lmom.z(),lmom.y()/lmom.z(),
                                      transHit->localPosition().x(),
                                      transHit->localPosition().y(),
                                      lmom.z()>0.?1.:-1.); 

        LocalTrajectoryError lte(100.,100.,
                                (1.+(lmom.x()/lmom.z())*(lmom.x()/lmom.z())),
                                (1.+(lmom.y()/lmom.z())*(lmom.y()/lmom.z())),
                                1./momentum.mag());
        
        TrajectoryStateOnSurface initialState(ltp,lte,*transHit->surface(),&(*theMagfield));
        KFUpdator updator;
        TrajectoryStateOnSurface startingState = updator.update(initialState,*transHit);

        TransientTrackingRecHit::RecHitPointer transHit2 = theBuilder->build(trHits[1]);

        //TrajectoryStateOnSurface seedTSOS(*startingState, *plane);
        const TrajectoryStateOnSurface propTSOS = propagator->propagate(startingState,*(transHit2->surface()));
        if (!propTSOS.isValid()){
                LogDebug("SeedFromGenericPairOrTriplet") << "first propagation failed";
                return 0;
        }
        TrajectoryStateOnSurface seedTSOS = updator.update(propTSOS, *transHit2);
        if (!seedTSOS.isValid()){
                LogDebug("SeedFromGenericPairOrTriplet") << "first update failed";
                return 0;
        }       
        LogDebug("SeedFromGenericPairOrTriplet") << "starting TSOS " << seedTSOS ;
        seedTSOS.rescaleError(theErrorRescaling);
        PTrajectoryStateOnDet PTraj=
                trajectoryStateTransform::persistentState(seedTSOS, trHits[1]->geographicalId().rawId());
        edm::OwnVector<TrackingRecHit> seed_hits;
        //build the transientTrackingRecHit for the starting hit, then call the method clone to rematch if needed
        std::vector<const TrackingRecHit*>::const_iterator ihits;
        for (ihits = trHits.begin(); ihits != trHits.end(); ihits++){
                seed_hits.push_back((*ihits)->clone());
        }
        TrajectorySeed* seed = new TrajectorySeed(PTraj,seed_hits,dir);
        return seed;
}
bool SeedFromGenericPairOrTriplet::momentumFromPSet ( ) [inline]

Definition at line 42 of file SeedFromGenericPairOrTriplet.h.

References theSetMomentum.

Referenced by CtfSpecialSeedGenerator::run().

{return theSetMomentum;}; 
bool SeedFromGenericPairOrTriplet::qualityFilter ( const GlobalVector momentum) const [private]

Definition at line 326 of file SeedFromGenericPairOrTriplet.cc.

References PV3DBase< T, PVType, FrameType >::perp(), theP, and theSetMomentum.

                                                                                  {
        if (!theSetMomentum){
                if (momentum.perp() < theP) return false;
        }
        return true; 
}
bool SeedFromGenericPairOrTriplet::qualityFilter ( const SeedingHitSet hits) const [private]

Definition at line 299 of file SeedFromGenericPairOrTriplet.cc.

References LogDebug, FastCircle::rho(), SeedingHitSet::size(), StripSubdetector::TEC, theSetMomentum, and StripSubdetector::TID.

Referenced by seedFromTriplet().

                                                                               {
        //if we are setting the momentum with the PSet we look for aligned hits
        if (theSetMomentum){
                if (hits.size()==3){
                        std::vector<GlobalPoint> gPoints;
                        unsigned int nHits = hits.size();
                        for (unsigned int iHit = 0; iHit < nHits; ++iHit) gPoints.push_back(hits[iHit]->globalPosition());
                        unsigned int subid=(*hits[0]).geographicalId().subdetId();
                        if(subid == StripSubdetector::TEC || subid == StripSubdetector::TID){
                                LogDebug("SeedFromGenericPairOrTriplet") 
                                        << "In the endcaps we cannot decide if hits are aligned with only phi and z";
                                return true;
                        }
                        FastCircle circle(gPoints[0],
                                          gPoints[1],
                                          gPoints[2]);
                        if (circle.rho() < 500 && circle.rho() != 0) {
                                LogDebug("SeedFromGenericPairOrTriplet") <<
                                        "Seed qualityFilter rejected because rho = " << circle.rho();
                                return false;
                        }

                }
        }
        return true;
}
std::vector< TrajectorySeed * > SeedFromGenericPairOrTriplet::seed ( const SeedingHitSet hits,
const PropagationDirection dir,
const NavigationDirection seedDir,
const edm::EventSetup iSetup 
)

Definition at line 21 of file SeedFromGenericPairOrTriplet.cc.

References Exception, seedFromPair(), seedFromTriplet(), SeedingHitSet::size(), theCharges, and theSetMomentum.

Referenced by buildSeed(), CtfSpecialSeedGenerator::buildSeeds(), seedFromPair(), and seedFromTriplet().

                                                                                            {
        std::vector<TrajectorySeed*> seeds;
        if (hits.size() == 3) {
                if(!theSetMomentum){
                        TrajectorySeed* seed = seedFromTriplet(hits, dir, seedDir, iSetup);
                        if (seed) seeds.push_back(seed);
                } else {
                        for (std::vector<int>::const_iterator iCh = theCharges.begin(); iCh != theCharges.end(); iCh++){
                                TrajectorySeed* seed = seedFromTriplet(hits, dir, seedDir, iSetup, *iCh);
                                if(seed) seeds.push_back(seed);
                        }
                } 
                
        } else if (hits.size() == 2){
                if(!theSetMomentum){
                        TrajectorySeed* seed = seedFromPair(hits, dir, seedDir);
                        if (seed) seeds.push_back(seed);
                } else {
                        for (std::vector<int>::const_iterator iCh = theCharges.begin(); iCh != theCharges.end(); iCh++){
                                TrajectorySeed* seed = seedFromPair(hits, dir, seedDir, *iCh);
                                if (seed) seeds.push_back(seed);
                        }
                }
        } else {
                throw cms::Exception("CombinatorialSeedGeneratorForCosmics") << " Wrong number of hits in Set: "
                                                        << hits.size() << ", should be 2 or 3 ";        
        }
        return seeds;
}
TrajectorySeed * SeedFromGenericPairOrTriplet::seedFromPair ( const SeedingHitSet hits,
const PropagationDirection dir,
const NavigationDirection seedDir,
int  charge = -1 
) const

Definition at line 148 of file SeedFromGenericPairOrTriplet.cc.

References buildSeed(), Exception, TrackingRecHit::geographicalId(), TrackerGeometry::idToDet(), SurfaceOrientation::inner, TrackingRecHit::localPosition(), LogDebug, oppositeToMomentum, SurfaceOrientation::outer, outsideIn, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), seed(), SeedingHitSet::size(), theP, PV3DBase< T, PVType, FrameType >::theta(), theTracker, GeomDet::toGlobal(), and csvLumiCalc::unit.

Referenced by seed(), and seedFromTriplet().

                                                                                                                 {
        if (hits.size() != 2) {
                throw cms::Exception("CombinatorialSeedGeneratorForCosmics") <<
                        "call to SeedFromGenericPairOrTriplet::seedFromPair with " << hits.size() << " hits ";
        }
        const TrackingRecHit* innerHit = hits[0]->hit();
        const TrackingRecHit* outerHit = hits[1]->hit();
        GlobalPoint inner  = theTracker->idToDet(innerHit->geographicalId() )->surface().toGlobal(innerHit->localPosition() );
        GlobalPoint outer  = theTracker->idToDet(outerHit->geographicalId() )->surface().toGlobal(outerHit->localPosition() );
        LogDebug("SeedFromGenericPairOrTriplet") <<
                        "Using the following hits: outer(r, phi, theta) (" << outer.perp()
                        << ", " << outer.phi()
                        << "," << outer.theta()
                        <<")    inner ("
                        << inner.perp()
                        << ", " << inner.phi()
                        << "," << inner.theta() <<")";
        GlobalPoint* firstPoint  = 0;
        GlobalPoint* secondPoint = 0;
        int momentumSign         = 1;
        //const TrackingRecHit* firstHit  = 0;
        //const TrackingRecHit* secondHit = 0;
        std::vector<const TrackingRecHit*> trHits;
        //choose the prop dir and hit order accordingly to where the seed is made
        if (seedDir == outsideIn){
                LogDebug("SeedFromGenericPairOrTriplet")
                        << "Seed from outsideIn alongMomentum OR insideOut oppositeToMomentum";
                firstPoint = &outer;
                secondPoint = &inner;
                //firstHit  = outerHit;
                //secondHit = innerHit;
                trHits.push_back(outerHit);
                trHits.push_back(innerHit);
        } else {
                LogDebug("SeedFromGenericPairOrTriplet")
                        << "Seed from outsideIn oppositeToMomentum OR insideOut alongMomentum";
                firstPoint = &inner;
                secondPoint = &outer;
                momentumSign = -1;
                //firstHit  = innerHit;
                //secondHit = outerHit;
                trHits.push_back(innerHit);
                trHits.push_back(outerHit);
        }
        if (dir == oppositeToMomentum) momentumSign = -1;
        GlobalVector momentum = momentumSign*theP*(*secondPoint-*firstPoint).unit();
        /*GlobalTrajectoryParameters gtp(*firstPoint, 
                                       momentum,
                                       charge,
                                       &(*theMagfield));*/
        //FreeTrajectoryState* startingState = new FreeTrajectoryState(gtp,initialError(trHits[0]));//trHits[1]));
        //if (!qualityFilter(startingState, hits)) return 0;
        //TrajectorySeed* seed = buildSeed(startingState, firstHit, dir);
        //TrajectorySeed* seed = buildSeed(startingState, trHits, dir);
        TrajectorySeed* seed = buildSeed(momentum, charge, trHits, dir);
        return seed;
}
TrajectorySeed * SeedFromGenericPairOrTriplet::seedFromTriplet ( const SeedingHitSet hits,
const PropagationDirection dir,
const NavigationDirection seedDir,
const edm::EventSetup iSetup,
int  charge = -1 
) const

Definition at line 54 of file SeedFromGenericPairOrTriplet.cc.

References buildSeed(), FreeTrajectoryState::charge(), dir, Exception, TrackingRecHit::geographicalId(), TrackerGeometry::idToDet(), SurfaceOrientation::inner, TrackingRecHit::localPosition(), LogDebug, FreeTrajectoryState::momentum(), oppositeToMomentum, SurfaceOrientation::outer, outsideIn, PV3DBase< T, PVType, FrameType >::perp(), PV3DBase< T, PVType, FrameType >::phi(), qualityFilter(), seed(), seedFromPair(), SeedingHitSet::size(), FastHelix::stateAtVertex(), DetId::subdetId(), theSetMomentum, PV3DBase< T, PVType, FrameType >::theta(), theTracker, GeomDet::toGlobal(), PV3DBase< T, PVType, FrameType >::x(), PV3DBase< T, PVType, FrameType >::y(), and PV3DBase< T, PVType, FrameType >::z().

Referenced by seed().

                                                                                                            {
        if (hits.size() != 3) {
                throw cms::Exception("CombinatorialSeedGeneratorForCosmics") <<
                        "call to SeedFromGenericPairOrTriplet::seedFromTriplet with " << hits.size() << " hits ";
        }

        const TrackingRecHit* innerHit  = hits[0]->hit();
        const TrackingRecHit* middleHit = hits[1]->hit();
        const TrackingRecHit* outerHit  = hits[2]->hit();
        GlobalPoint inner  = theTracker->idToDet(innerHit->geographicalId() )->surface().toGlobal(innerHit->localPosition() );
        GlobalPoint middle = theTracker->idToDet(middleHit->geographicalId())->surface().toGlobal(middleHit->localPosition());
        GlobalPoint outer  = theTracker->idToDet(outerHit->geographicalId() )->surface().toGlobal(outerHit->localPosition() );
        if (theSetMomentum){
                LogDebug("SeedFromGenericPairOrTriplet") << 
                        "Using the following hits: outer(r, phi, theta) " << outerHit->geographicalId().subdetId()<< " (" << outer.perp() 
                        << ", " << outer.phi() 
                        << "," << outer.theta() 
                        << ")    " << middleHit->geographicalId().subdetId() << " middle (" 
                        << middle.perp() << ", " 
                        << middle.phi() << "," 
                        << middle.theta() << ")    " 
                        <<innerHit->geographicalId().subdetId() <<" inner (" 
                        << inner.perp() 
                        << ", " << inner.phi() 
                        << "," << inner.theta() <<")   "
                        << "   (x, y, z)   outer ("  
                        << inner.x() << ", " 
                        << inner.y() << ", " 
                        << inner.z() << ")    middle ("  
                        << middle.x() << ", " 
                        << middle.y() << ", " 
                        << middle.z() << ")";
                if (!qualityFilter(hits)) return 0;
                bool sdir = (seedDir == outsideIn);
                SeedingHitSet newSet(sdir ? hits[1] : hits[0], sdir ? hits[2] : hits[1]); 
                TrajectorySeed* seed = seedFromPair(newSet, dir, seedDir, charge);
                return seed;
                                                
        }
        GlobalPoint* firstPoint  = 0;
        GlobalPoint* secondPoint = 0;
        GlobalPoint* thirdPoint  = 0;
        int momentumSign         = 1;
        //const TrackingRecHit* firstHit  = 0;
        //const TrackingRecHit* secondHit = 0;
        //choose the prop dir and hit order accordingly to where the seed is made
        std::vector<const TrackingRecHit*> trHits;
        if (seedDir == outsideIn){
                LogDebug("SeedFromGenericPairOrTriplet") 
                        << "Seed from outsideIn alongMomentum OR insideOut oppositeToMomentum";
                firstPoint = &outer;
                secondPoint = &middle;
                thirdPoint = &inner;
                trHits.push_back(outerHit);
                trHits.push_back(middleHit);
                //firstHit  = outerHit;
                //secondHit = middleHit;
        } else {
                LogDebug("SeedFromGenericPairOrTriplet") 
                        << "Seed from outsideIn oppositeToMomentum OR insideOut alongMomentum";
                firstPoint = &inner;
                secondPoint = &middle;
                thirdPoint = &outer;
                trHits.push_back(innerHit);
                trHits.push_back(middleHit);
                //firstHit  = innerHit;
                //secondHit = middleHit;
        }
        if (dir == oppositeToMomentum) momentumSign = -1; 
        FastHelix helix(*thirdPoint, *secondPoint, *firstPoint, iSetup);
        FreeTrajectoryState originalStartingState = helix.stateAtVertex();
        LogDebug("SeedFromGenericPairOrTriplet") << "originalStartingState " << originalStartingState;
        /*GlobalTrajectoryParameters originalPar = originalStartingState.parameters();
        GlobalTrajectoryParameters newPar = GlobalTrajectoryParameters(originalPar.position(), 
                                                                       momentumSign*originalPar.momentum(),
                                                                       originalPar.charge(),
                                                                       &originalPar.magneticField());
        */
        
        /*FastCircle helix(*thirdPoint, *secondPoint, *firstPoint);
        GlobalTrajectoryParameters newPar = GlobalTrajectoryParameters(*secondPoint,
                                                                       momentumSign*originalPar.momentum(),
                                                                       originalPar.charge(),
                                                                       &originalPar.magneticField());*/
        //FreeTrajectoryState* startingState = new FreeTrajectoryState(newPar, initialError(trHits[0]));//trHits[1]));
        if (!qualityFilter(momentumSign*originalStartingState.momentum())) return 0;
        //TrajectorySeed* seed = buildSeed(startingState, trHits, dir);
        TrajectorySeed* seed = buildSeed(momentumSign*originalStartingState.momentum(),originalStartingState.charge(), trHits, dir);
        return seed;    
}
void SeedFromGenericPairOrTriplet::setMomentumTo ( double  mom) [inline]

Definition at line 41 of file SeedFromGenericPairOrTriplet.h.

References theP.

Referenced by CtfSpecialSeedGenerator::beginRun(), and CtfSpecialSeedGenerator::run().

{theP = mom;};

Member Data Documentation

Definition at line 71 of file SeedFromGenericPairOrTriplet.h.

Referenced by buildSeed().

std::vector<int> SeedFromGenericPairOrTriplet::theCharges [private]

Definition at line 77 of file SeedFromGenericPairOrTriplet.h.

Referenced by seed().

Definition at line 78 of file SeedFromGenericPairOrTriplet.h.

Referenced by buildSeed().

Definition at line 69 of file SeedFromGenericPairOrTriplet.h.

Definition at line 75 of file SeedFromGenericPairOrTriplet.h.

Referenced by qualityFilter(), seedFromPair(), and setMomentumTo().

Definition at line 72 of file SeedFromGenericPairOrTriplet.h.

Referenced by buildSeed().

Definition at line 73 of file SeedFromGenericPairOrTriplet.h.

Referenced by buildSeed().

Definition at line 70 of file SeedFromGenericPairOrTriplet.h.

Referenced by buildSeed(), seedFromPair(), and seedFromTriplet().