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