CMS 3D CMS Logo

Public Member Functions | Private Types | Private Attributes

cms::CosmicTrackFinder Class Reference

#include <CosmicTrackFinder.h>

Inheritance diagram for cms::CosmicTrackFinder:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 CosmicTrackFinder (const edm::ParameterSet &conf)
virtual void produce (edm::Event &e, const edm::EventSetup &c)
virtual ~CosmicTrackFinder ()

Private Types

typedef TrajectoryStateOnSurface TSOS

Private Attributes

edm::ParameterSet conf_
CosmicTrajectoryBuilder cosmicTrajectoryBuilder_
CRackTrajectoryBuilder crackTrajectoryBuilder_
std::string geometry
bool trinevents
bool useHitsSplitting_

Detailed Description

Definition at line 68 of file CosmicTrackFinder.h.


Member Typedef Documentation

Definition at line 71 of file CosmicTrackFinder.h.


Constructor & Destructor Documentation

cms::CosmicTrackFinder::CosmicTrackFinder ( const edm::ParameterSet conf) [explicit]

Definition at line 28 of file CosmicTrackFinder.cc.

References conf_, geometry, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), and useHitsSplitting_.

                                                                  : 
    cosmicTrajectoryBuilder_(conf) ,
    crackTrajectoryBuilder_(conf) ,
    conf_(conf)
  {
    geometry=conf_.getUntrackedParameter<std::string>("GeometricStructure","STANDARD");
    useHitsSplitting_=conf.getParameter<bool>("useHitsSplitting");
    produces<TrackCandidateCollection>();
  }
cms::CosmicTrackFinder::~CosmicTrackFinder ( ) [virtual]

Definition at line 40 of file CosmicTrackFinder.cc.

{ }  

Member Function Documentation

void cms::CosmicTrackFinder::produce ( edm::Event e,
const edm::EventSetup c 
) [virtual]

Implements edm::EDProducer.

Definition at line 43 of file CosmicTrackFinder.cc.

References alongMomentum, funct::C, conf_, cosmicTrajectoryBuilder_, crackTrajectoryBuilder_, edm::OwnVector< T, P >::front(), geometry, edm::EventSetup::get(), edm::Event::getByLabel(), edm::ParameterSet::getParameter(), TrajectoryStateOnSurface::isValid(), TrajectoryStateOnSurface::localParameters(), LogDebug, TrajectoryStateOnSurface::magneticField(), convertSQLitetoXML_cfg::output, trajectoryStateTransform::persistentState(), edm::Handle< T >::product(), edm::OwnVector< T, P >::push_back(), edm::Event::put(), edm::OwnVector< T, P >::reserve(), CRackTrajectoryBuilder::run(), CosmicTrajectoryBuilder::run(), evf::utils::state, TrajectoryStateOnSurface::surface(), patCandidatesForDimuonsSequences_cff::tracker, and useHitsSplitting_.

  {
    using namespace std  ;
    edm::InputTag matchedrecHitsTag = conf_.getParameter<edm::InputTag>("matchedRecHits");
    edm::InputTag rphirecHitsTag = conf_.getParameter<edm::InputTag>("rphirecHits");
    edm::InputTag stereorecHitsTag = conf_.getParameter<edm::InputTag>("stereorecHits");
    edm::InputTag pixelRecHitsTag = conf_.getParameter<edm::InputTag>("pixelRecHits");  


    edm::InputTag seedTag = conf_.getParameter<edm::InputTag>("cosmicSeeds");
    // retrieve seeds
    edm::Handle<TrajectorySeedCollection> seed;
    e.getByLabel(seedTag,seed);  

  //retrieve PixelRecHits
    static const SiPixelRecHitCollection s_empty;
    const SiPixelRecHitCollection *pixelHitCollection = &s_empty;
    edm::Handle<SiPixelRecHitCollection> pixelHits;
    if (geometry!="MTCC" && (geometry!="CRACK" )) {
      if( e.getByLabel(pixelRecHitsTag, pixelHits)) {
        pixelHitCollection = pixelHits.product();
      } else {
        edm::LogWarning("CosmicTrackFinder") << "Collection SiPixelRecHitCollection with InputTag " << pixelRecHitsTag << " cannot be found, using empty collection of same type.";
      }
    }
    
   


 //retrieve StripRecHits
    edm::Handle<SiStripMatchedRecHit2DCollection> matchedrecHits;
    e.getByLabel( matchedrecHitsTag ,matchedrecHits);
    edm::Handle<SiStripRecHit2DCollection> rphirecHits;
    e.getByLabel( rphirecHitsTag ,rphirecHits);
    edm::Handle<SiStripRecHit2DCollection> stereorecHits;
    e.getByLabel( stereorecHitsTag, stereorecHits);

    // Step B: create empty output collection
    std::auto_ptr<TrackCandidateCollection> output(new TrackCandidateCollection);

    edm::ESHandle<TrackerGeometry> tracker;
    es.get<TrackerDigiGeometryRecord>().get(tracker);
    edm::LogVerbatim("CosmicTrackFinder") << "========== Cosmic Track Finder Info ==========";
    edm::LogVerbatim("CosmicTrackFinder") << " Numbers of Seeds " << (*seed).size();
    if((*seed).size()>0){

      std::vector<Trajectory> trajoutput;
      
      if(geometry!="CRACK" ) {
        cosmicTrajectoryBuilder_.run(*seed,
                                   *stereorecHits,
                                   *rphirecHits,
                                   *matchedrecHits,
                                   *pixelHitCollection,
                                   es,
                                   e,
                                   trajoutput);
      } else {
        crackTrajectoryBuilder_.run(*seed,
                                   *stereorecHits,
                                   *rphirecHits,
                                   *matchedrecHits,
                                   *pixelHitCollection,
                                   es,
                                   e,
                                   trajoutput);
      }

      edm::LogVerbatim("CosmicTrackFinder") << " Numbers of Temp Trajectories " << trajoutput.size();
      edm::LogVerbatim("CosmicTrackFinder") << "========== END Info ==========";
      if(trajoutput.size()>0){
        std::vector<Trajectory*> tmpTraj;
        std::vector<Trajectory>::iterator itr;
        for (itr=trajoutput.begin();itr!=trajoutput.end();itr++)tmpTraj.push_back(&(*itr));

        //The best track is selected
        //FOR MTCC the criteria are:
        //1)# of layers,2) # of Hits,3)Chi2
        if (geometry=="MTCC")  stable_sort(tmpTraj.begin(),tmpTraj.end(),CompareTrajLay());
        else  stable_sort(tmpTraj.begin(),tmpTraj.end(),CompareTrajChi());



        const Trajectory  theTraj = *(*tmpTraj.begin());
        bool seedplus=(theTraj.seed().direction()==alongMomentum);
        //PropagationDirection seedDir =theTraj.seed().direction();

        if (seedplus)
          LogDebug("CosmicTrackFinder")<<"Reconstruction along momentum ";
        else
          LogDebug("CosmicTrackFinder")<<"Reconstruction opposite to momentum";

        /*
        // === the convention is to save always final tracks with hits sorted *along* momentum  
        */

        Trajectory::RecHitContainer thits;
        //it->recHitsV(thits);
        theTraj.recHitsV(thits,useHitsSplitting_);
        edm::OwnVector<TrackingRecHit> recHits;
        recHits.reserve(thits.size());

        // reverse hit order
        for (Trajectory::RecHitContainer::const_iterator hitIt = thits.end()-1;
             hitIt >= thits.begin(); hitIt--) {
          recHits.push_back( (**hitIt).hit()->clone());
        }

        TSOS firstState;
        unsigned int firstId;

        firstState=theTraj.lastMeasurement().updatedState();
        firstId = theTraj.lastMeasurement().recHit()->geographicalId().rawId();

        /*
        cout << "firstState y, z: " << firstState.globalPosition().y() 
             << " , " << firstState.globalPosition().z() <<  endl;

        */

        AlgebraicSymMatrix55 C = AlgebraicMatrixID();
        TSOS startingState( firstState.localParameters(), LocalTrajectoryError(C),
                            firstState.surface(),
                            firstState.magneticField() );

        // protection againt invalid initial states
        if (! firstState.isValid()) {
          edm::LogWarning("CosmicTrackFinder") << "invalid innerState, will not make TrackCandidate";
          edm::OrphanHandle<TrackCandidateCollection> rTrackCand = e.put(output);  
          return;
        }

        if(firstId != recHits.front().geographicalId().rawId()){
          edm::LogWarning("CosmicTrackFinder") <<"Mismatch in DetID of first hit: firstID= " <<firstId
                                               << "   DetId= " << recHits.front().geographicalId().rawId();
          edm::OrphanHandle<TrackCandidateCollection> rTrackCand = e.put(output);  
          return;
        }

        PTrajectoryStateOnDet const &  state = trajectoryStateTransform::persistentState( startingState, firstId);
        
        
        output->push_back(TrackCandidate(recHits,theTraj.seed(),state,theTraj.seedRef() ) );
        
      }

    }
    edm::OrphanHandle<TrackCandidateCollection> rTrackCand = e.put(output);  
  }

Member Data Documentation

Definition at line 83 of file CosmicTrackFinder.h.

Referenced by CosmicTrackFinder(), and produce().

Definition at line 81 of file CosmicTrackFinder.h.

Referenced by produce().

Definition at line 82 of file CosmicTrackFinder.h.

Referenced by produce().

std::string cms::CosmicTrackFinder::geometry [private]

Definition at line 84 of file CosmicTrackFinder.h.

Referenced by CosmicTrackFinder(), and produce().

Definition at line 85 of file CosmicTrackFinder.h.

Definition at line 86 of file CosmicTrackFinder.h.

Referenced by CosmicTrackFinder(), and produce().