Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #include <memory>
00008
00009
00010 #include "FWCore/Framework/interface/Frameworkfwd.h"
00011 #include "FWCore/Framework/interface/EDProducer.h"
00012 #include "FWCore/Framework/interface/Event.h"
00013 #include "FWCore/Framework/interface/ESHandle.h"
00014 #include "FWCore/Framework/interface/EventSetup.h"
00015 #include "FWCore/Framework/interface/MakerMacros.h"
00016 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00017
00018
00019 #include "DataFormats/TrackReco/interface/Track.h"
00020 #include "DataFormats/TrackReco/interface/TrackFwd.h"
00021
00022
00023 #include "DataFormats/MuonReco/interface/Muon.h"
00024 #include "DataFormats/MuonReco/interface/MuonFwd.h"
00025
00026
00027 #include "DataFormats/TrajectorySeed/interface/TrajectorySeed.h"
00028 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
00029 #include "DataFormats/TrajectorySeed/interface/PropagationDirection.h"
00030
00031
00032 #include "DataFormats/TrajectorySeed/interface/TrajectorySeed.h"
00033 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
00034 #include "DataFormats/TrajectorySeed/interface/PropagationDirection.h"
00035 #include "MagneticField/Engine/interface/MagneticField.h"
00036 #include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
00037 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateTransform.h"
00038 #include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
00039 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00040
00041 #include "Geometry/CommonDetUnit/interface/GlobalTrackingGeometry.h"
00042 #include "Geometry/Records/interface/GlobalTrackingGeometryRecord.h"
00043 #include "TrackingTools/PatternTools/interface/TrajectoryMeasurement.h"
00044 #include "DataFormats/TrajectorySeed/interface/PropagationDirection.h"
00045
00046 #include "RecoMuon/MuonIdentification/interface/MuonCosmicsId.h"
00047
00048 class TrajectorySeedFromMuonProducer : public edm::EDProducer
00049 {
00050
00051 public:
00052 explicit TrajectorySeedFromMuonProducer( const edm::ParameterSet & );
00053 virtual void produce(edm::Event&, const edm::EventSetup&);
00054
00055 private:
00056 edm::InputTag muonCollectionTag_;
00057 edm::InputTag trackCollectionTag_;
00058 bool skipMatchedMuons_;
00059 };
00060
00061 TrajectorySeedFromMuonProducer::TrajectorySeedFromMuonProducer(const edm::ParameterSet & iConfig)
00062 {
00063 muonCollectionTag_ = iConfig.getParameter<edm::InputTag>("muonCollectionTag");
00064 trackCollectionTag_ = iConfig.getParameter<edm::InputTag>("trackCollectionTag");
00065 skipMatchedMuons_ = iConfig.getParameter<bool>("skipMatchedMuons");
00066 produces<TrajectorySeedCollection>();
00067 }
00068
00069
00070 void TrajectorySeedFromMuonProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00071 {
00072 using namespace edm;
00073 using namespace reco;
00074 using namespace std;
00075
00076
00077 std::auto_ptr<TrajectorySeedCollection> result(new TrajectorySeedCollection());
00078
00079 edm::ESHandle<MagneticField> magneticField;
00080 iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
00081
00082 edm::ESHandle<TrackerGeometry> trackerGeometry;
00083 iSetup.get<TrackerDigiGeometryRecord>().get(trackerGeometry);
00084
00085
00086
00087 edm::Handle<edm::View<Muon> > muonCollectionHandle;
00088 iEvent.getByLabel(muonCollectionTag_, muonCollectionHandle);
00089
00090 edm::Handle<reco::TrackCollection> trackCollectionHandle;
00091 iEvent.getByLabel(trackCollectionTag_, trackCollectionHandle);
00092
00093
00094 for (edm::View<Muon>::const_iterator muon = muonCollectionHandle->begin(); muon != muonCollectionHandle->end(); ++muon) {
00095
00096 if( muon->innerTrack().isNull() ) continue;
00097 edm::RefToBase<reco::Track> track(muon->innerTrack());
00098
00099 if( skipMatchedMuons_ &&
00100 muonid::findOppositeTrack(trackCollectionHandle, *track).isNonnull() ) continue;
00101 if( (!track->innerOk()) || (!track->recHit(0)->isValid())) continue;
00102 GlobalPoint innerPosition(track->innerPosition().x(), track->innerPosition().y(), track->innerPosition().z());
00103 GlobalVector innerMomentum(track->innerMomentum().x(), track->innerMomentum().y(), track->innerMomentum().z());
00104 int charge = track->charge();
00105 const reco::Track::CovarianceMatrix innerStateCovariance = track->innerStateCovariance();
00106 DetId innerDetId = DetId(track->innerDetId());
00107
00108 GlobalTrajectoryParameters globalTrajParams(innerPosition, innerMomentum, charge, &(*magneticField));
00109 CurvilinearTrajectoryError curviError(innerStateCovariance);
00110 FreeTrajectoryState tracker_state(globalTrajParams, curviError);
00111 LogTrace("MuonIdentification") << "Track Inner FTS: "<<tracker_state;
00112
00113 TrajectoryStateOnSurface tracker_tsos = TrajectoryStateOnSurface(globalTrajParams, curviError, trackerGeometry->idToDet(innerDetId)->surface());
00114
00115
00116 edm::OwnVector<TrackingRecHit> trackHits;
00117 trackHits.push_back(track->recHit(0)->clone() );
00118
00119
00120 PTrajectoryStateOnDet const & PTraj = trajectoryStateTransform::persistentState(tracker_tsos, innerDetId.rawId());
00121 TrajectorySeed trajectorySeed(PTraj, trackHits, oppositeToMomentum);
00122 LogTrace("MuonIdentification")<<"Trajectory Seed Direction: "<< trajectorySeed.direction()<<endl;
00123 result->push_back(trajectorySeed);
00124 }
00125
00126 iEvent.put(result);
00127
00128 }
00129
00130 DEFINE_FWK_MODULE(TrajectorySeedFromMuonProducer);