00001
00010
00011 #include "FastSimulation/TrackingRecHitProducer/interface/TrackingRecHitTranslator.h"
00012
00013
00014 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00015
00016
00017 #include "DataFormats/Common/interface/Handle.h"
00018
00019
00020 #include "FWCore/Framework/interface/Event.h"
00021 #include "FWCore/Framework/interface/EventSetup.h"
00022
00023 #include "FWCore/Framework/interface/ESHandle.h"
00024
00025
00026 #include "DataFormats/DetId/interface/DetId.h"
00027
00028
00029 #include <memory>
00030 #include <string>
00031
00032 TrackingRecHitTranslator::TrackingRecHitTranslator(edm::ParameterSet const& conf)
00033 {
00034 produces<SiTrackerFullGSRecHit2DCollection>();
00035 }
00036
00037
00038 TrackingRecHitTranslator::~TrackingRecHitTranslator() {}
00039
00040 void
00041 TrackingRecHitTranslator::beginRun(edm::Run & run, const edm::EventSetup & es) {
00042
00043
00044 edm::ESHandle<TrackerGeometry> theGeometry;
00045 es.get<TrackerDigiGeometryRecord> ().get (theGeometry);
00046 geometry = &(*theGeometry);
00047
00048 }
00049
00050 void TrackingRecHitTranslator::produce(edm::Event& e, const edm::EventSetup& es)
00051 {
00052
00053 edm::Handle<SiTrackerGSRecHit2DCollection> theFastRecHits;
00054 e.getByType(theFastRecHits);
00055
00056
00057 SiTrackerGSRecHit2DCollection::const_iterator aHit = theFastRecHits->begin();
00058 SiTrackerGSRecHit2DCollection::const_iterator theLastHit = theFastRecHits->end();
00059 std::map< DetId, edm::OwnVector<SiTrackerGSRecHit2D> > temporaryRecHits;
00060
00061
00062 for ( ; aHit != theLastHit; ++aHit ) {
00063
00064 DetId det = aHit->geographicalId();
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078 temporaryRecHits[det].push_back(aHit->clone());
00079
00080 }
00081
00082
00083 std::auto_ptr<SiTrackerFullGSRecHit2DCollection>
00084 recHitCollection(new SiTrackerFullGSRecHit2DCollection);
00085 loadRecHits(temporaryRecHits, *recHitCollection);
00086
00087
00088 e.put(recHitCollection);
00089
00090 }
00091
00092 void
00093 TrackingRecHitTranslator::loadRecHits(
00094 std::map<DetId,edm::OwnVector<SiTrackerGSRecHit2D> >& theRecHits,
00095 SiTrackerFullGSRecHit2DCollection& theRecHitCollection) const
00096 {
00097 std::map<DetId,edm::OwnVector<SiTrackerGSRecHit2D> >::const_iterator
00098 it = theRecHits.begin();
00099 std::map<DetId,edm::OwnVector<SiTrackerGSRecHit2D> >::const_iterator
00100 lastRecHit = theRecHits.end();
00101
00102 for( ; it != lastRecHit ; ++it ) {
00103 theRecHitCollection.put(it->first,it->second.begin(),it->second.end());
00104 }
00105
00106 }
00107