CMS 3D CMS Logo

Public Member Functions | Private Attributes

TrajectorySeedFromMuonProducer Class Reference

Inheritance diagram for TrajectorySeedFromMuonProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

virtual void produce (edm::Event &, const edm::EventSetup &)
 TrajectorySeedFromMuonProducer (const edm::ParameterSet &)

Private Attributes

edm::InputTag muonCollectionTag_
bool skipMatchedMuons_
edm::InputTag trackCollectionTag_

Detailed Description

Definition at line 48 of file TrajectorySeedFromMuonProducer.cc.


Constructor & Destructor Documentation

TrajectorySeedFromMuonProducer::TrajectorySeedFromMuonProducer ( const edm::ParameterSet iConfig) [explicit]

Definition at line 61 of file TrajectorySeedFromMuonProducer.cc.

References edm::ParameterSet::getParameter(), muonCollectionTag_, skipMatchedMuons_, and trackCollectionTag_.

{
  muonCollectionTag_  = iConfig.getParameter<edm::InputTag>("muonCollectionTag");
  trackCollectionTag_ = iConfig.getParameter<edm::InputTag>("trackCollectionTag");
  skipMatchedMuons_   = iConfig.getParameter<bool>("skipMatchedMuons");
  produces<TrajectorySeedCollection>();
}

Member Function Documentation

void TrajectorySeedFromMuonProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

Implements edm::EDProducer.

Definition at line 70 of file TrajectorySeedFromMuonProducer.cc.

References DeDxDiscriminatorTools::charge(), TrajectorySeed::direction(), muonid::findOppositeTrack(), edm::EventSetup::get(), edm::Event::getByLabel(), edm::Ref< C, T, F >::isNonnull(), LogTrace, metsig::muon, muonCollectionTag_, oppositeToMomentum, edm::OwnVector< T, P >::push_back(), edm::Event::put(), DetId::rawId(), dt_dqm_sourceclient_common_cff::reco, query::result, skipMatchedMuons_, and trackCollectionTag_.

{
  using namespace edm;
  using namespace reco;
  using namespace std;

  // Product
  std::auto_ptr<TrajectorySeedCollection> result(new TrajectorySeedCollection());
  
  edm::ESHandle<MagneticField> magneticField;
  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
  
  edm::ESHandle<TrackerGeometry> trackerGeometry;
  iSetup.get<TrackerDigiGeometryRecord>().get(trackerGeometry);
  
  TrajectoryStateTransform transformer;
  
  edm::Handle<edm::View<Muon> > muonCollectionHandle;
  iEvent.getByLabel(muonCollectionTag_, muonCollectionHandle);
  
  edm::Handle<reco::TrackCollection> trackCollectionHandle;
  iEvent.getByLabel(trackCollectionTag_, trackCollectionHandle);

  // Loop over the muon track
  for (edm::View<Muon>::const_iterator muon = muonCollectionHandle->begin();  muon != muonCollectionHandle->end(); ++muon) {
    // muon must have a tracker track
    if( muon->innerTrack().isNull() ) continue;
    edm::RefToBase<reco::Track> track(muon->innerTrack());
    // check if there is a back-to-back track
    if( skipMatchedMuons_ &&
        muonid::findOppositeTrack(trackCollectionHandle, *track).isNonnull() ) continue;
    if( (!track->innerOk()) || (!track->recHit(0)->isValid())) continue;
    GlobalPoint innerPosition(track->innerPosition().x(), track->innerPosition().y(), track->innerPosition().z());
    GlobalVector innerMomentum(track->innerMomentum().x(), track->innerMomentum().y(), track->innerMomentum().z());
    int charge = track->charge();
    const reco::Track::CovarianceMatrix innerStateCovariance = track->innerStateCovariance();
    DetId innerDetId = DetId(track->innerDetId());
    // Construct the information necessary to make a TrajectoryStateOnSurface
    GlobalTrajectoryParameters globalTrajParams(innerPosition, innerMomentum, charge, &(*magneticField));
    CurvilinearTrajectoryError curviError(innerStateCovariance);
    FreeTrajectoryState tracker_state(globalTrajParams, curviError);
    LogTrace("MuonIdentification") << "Track Inner FTS: "<<tracker_state;
    
    TrajectoryStateOnSurface tracker_tsos  = TrajectoryStateOnSurface(globalTrajParams, curviError, trackerGeometry->idToDet(innerDetId)->surface());
    
    // Make Hits, push back the innermost Hit
    edm::OwnVector<TrackingRecHit> trackHits;
    trackHits.push_back(track->recHit(0)->clone() );
    
    // Make TrajectorySeed
    PTrajectoryStateOnDet *PTraj = transformer.persistentState(tracker_tsos, innerDetId.rawId());
    TrajectorySeed trajectorySeed(*PTraj, trackHits, oppositeToMomentum);
    LogTrace("MuonIdentification")<<"Trajectory Seed Direction: "<< trajectorySeed.direction()<<endl;
    result->push_back(trajectorySeed);
  }
  
  iEvent.put(result);

}

Member Data Documentation

Definition at line 56 of file TrajectorySeedFromMuonProducer.cc.

Referenced by produce(), and TrajectorySeedFromMuonProducer().

Definition at line 58 of file TrajectorySeedFromMuonProducer.cc.

Referenced by produce(), and TrajectorySeedFromMuonProducer().

Definition at line 57 of file TrajectorySeedFromMuonProducer.cc.

Referenced by produce(), and TrajectorySeedFromMuonProducer().