#include <Alignment/CSCOverlapsTrackPreparation/src/CSCOverlapsTrackPreparation.cc>
Public Member Functions | |
CSCOverlapsTrackPreparation (const edm::ParameterSet &) | |
~CSCOverlapsTrackPreparation () | |
Private Types | |
enum | { kNothing, kSimpleFit, kAllButOne, kExtrapolate } |
Private Member Functions | |
virtual void | beginJob () |
virtual void | endJob () |
virtual void | produce (edm::Event &, const edm::EventSetup &) |
Private Attributes | |
edm::InputTag | m_src |
Description: <one line="" class="" summary>="">
Implementation: <Notes on="" implementation>="">
Definition at line 62 of file CSCOverlapsTrackPreparation.cc.
anonymous enum [private] |
Definition at line 68 of file CSCOverlapsTrackPreparation.cc.
CSCOverlapsTrackPreparation::CSCOverlapsTrackPreparation | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 89 of file CSCOverlapsTrackPreparation.cc.
: m_src(iConfig.getParameter<edm::InputTag>("src")) { produces<std::vector<Trajectory> >(); produces<TrajTrackAssociationCollection>(); }
CSCOverlapsTrackPreparation::~CSCOverlapsTrackPreparation | ( | ) |
Definition at line 97 of file CSCOverlapsTrackPreparation.cc.
{ // do anything here that needs to be done at desctruction time // (e.g. close files, deallocate resources etc.) }
void CSCOverlapsTrackPreparation::beginJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDProducer.
Definition at line 208 of file CSCOverlapsTrackPreparation.cc.
{}
void CSCOverlapsTrackPreparation::endJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::EDProducer.
Definition at line 211 of file CSCOverlapsTrackPreparation.cc.
{}
void CSCOverlapsTrackPreparation::produce | ( | edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) | [private, virtual] |
Implements edm::EDProducer.
Definition at line 110 of file CSCOverlapsTrackPreparation.cc.
References alongMomentum, edm::OwnVector< T, P >::begin(), MuonTransientTrackingRecHitBuilder::build(), MuonSubdetId::CSC, edm::OwnVector< T, P >::end(), edm::EventSetup::get(), edm::Event::getByLabel(), m_src, DetId::Muon, TrajectoryStateTransform::persistentState(), Trajectory::push(), edm::OwnVector< T, P >::push_back(), edm::Event::put(), edm::OwnVector< T, P >::size(), and testEve_cfg::tracks.
{ edm::Handle<reco::TrackCollection> tracks; iEvent.getByLabel(m_src, tracks); edm::ESHandle<CSCGeometry> cscGeometry; iSetup.get<MuonGeometryRecord>().get(cscGeometry); edm::ESHandle<MagneticField> magneticField; iSetup.get<IdealMagneticFieldRecord>().get(magneticField); edm::ESHandle<GlobalTrackingGeometry> globalGeometry; iSetup.get<GlobalTrackingGeometryRecord>().get(globalGeometry); TrajectoryStateTransform transformer; MuonTransientTrackingRecHitBuilder muonTransBuilder; // Create a collection of Trajectories, to put in the Event std::auto_ptr<std::vector<Trajectory> > trajectoryCollection(new std::vector<Trajectory>); // Remember which trajectory is associated with which track std::map<edm::Ref<std::vector<Trajectory> >::key_type, edm::Ref<reco::TrackCollection>::key_type> reference_map; edm::Ref<std::vector<Trajectory> >::key_type trajCounter = 0; edm::Ref<reco::TrackCollection>::key_type trackCounter = 0; for (reco::TrackCollection::const_iterator track = tracks->begin(); track != tracks->end(); ++track) { trackCounter++; // now we'll actually put hits on the new trajectory // these must be in lock-step edm::OwnVector<TrackingRecHit> clonedHits; std::vector<TrajectoryMeasurement::ConstRecHitPointer> transHits; std::vector<TrajectoryStateOnSurface> TSOSes; for (trackingRecHit_iterator hit = track->recHitsBegin(); hit != track->recHitsEnd(); ++hit) { DetId id = (*hit)->geographicalId(); if (id.det() == DetId::Muon && id.subdetId() == MuonSubdetId::CSC) { const Surface &layerSurface = cscGeometry->idToDet(id)->surface(); TrajectoryMeasurement::ConstRecHitPointer hitPtr(muonTransBuilder.build(&**hit, globalGeometry)); AlgebraicVector5 params; // meaningless, CSCOverlapsAlignmentAlgorithm does the fit internally params[0] = 1.; // straight-forward direction params[1] = 0.; params[2] = 0.; params[3] = 0.; // center of the chamber params[4] = 0.; LocalTrajectoryParameters localTrajectoryParameters(params, 1., false); LocalTrajectoryError localTrajectoryError(0.001, 0.001, 0.001, 0.001, 0.001); // these must be in lock-step clonedHits.push_back((*hit)->clone()); transHits.push_back(hitPtr); TSOSes.push_back(TrajectoryStateOnSurface(localTrajectoryParameters, localTrajectoryError, layerSurface, &*magneticField)); } // end if CSC } // end loop over hits assert(clonedHits.size() == transHits.size()); assert(transHits.size() == TSOSes.size()); // build the trajectory if (clonedHits.size() > 0) { PTrajectoryStateOnDet *PTraj = transformer.persistentState(*(TSOSes.begin()), clonedHits.begin()->geographicalId().rawId()); TrajectorySeed trajectorySeed(*PTraj, clonedHits, alongMomentum); Trajectory trajectory(trajectorySeed, alongMomentum); edm::OwnVector<TrackingRecHit>::const_iterator clonedHit = clonedHits.begin(); std::vector<TrajectoryMeasurement::ConstRecHitPointer>::const_iterator transHitPtr = transHits.begin(); std::vector<TrajectoryStateOnSurface>::const_iterator TSOS = TSOSes.begin(); for (; clonedHit != clonedHits.end(); ++clonedHit, ++transHitPtr, ++TSOS) { trajectory.push(TrajectoryMeasurement(*TSOS, *TSOS, *TSOS, (*transHitPtr))); } trajectoryCollection->push_back(trajectory); // Remember which Trajectory is associated with which Track trajCounter++; reference_map[trajCounter] = trackCounter; } // end if there are any clonedHits/TSOSes to work with } // end loop over tracks unsigned int numTrajectories = trajectoryCollection->size(); // insert the trajectories into the Event edm::OrphanHandle<std::vector<Trajectory> > ohTrajs = iEvent.put(trajectoryCollection); // create the trajectory <-> track association map std::auto_ptr<TrajTrackAssociationCollection> trajTrackMap(new TrajTrackAssociationCollection()); for (trajCounter = 0; trajCounter < numTrajectories; trajCounter++) { edm::Ref<reco::TrackCollection>::key_type trackCounter = reference_map[trajCounter]; trajTrackMap->insert(edm::Ref<std::vector<Trajectory> >(ohTrajs, trajCounter), edm::Ref<reco::TrackCollection>(tracks, trackCounter)); } // and put it in the Event, also iEvent.put(trajTrackMap); }
Definition at line 75 of file CSCOverlapsTrackPreparation.cc.
Referenced by produce().