CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackingRecHitTranslator.cc
Go to the documentation of this file.
1 
10 // SiTracker Gaussian Smearing
12 
13 // Geometry
15 
16 // Data Formats
18 
19 // Framework
22 //#include "FWCore/ParameterSet/interface/ParameterSet.h"
25 
26 // Data Formats
28 
29 // STL
30 #include <memory>
31 #include <string>
32 
34  hitCollectionInputTag_(conf.getParameter<edm::InputTag>("hitCollectionInputTag"))
35 {
36  produces<SiTrackerFullGSRecHit2DCollection>();
37 }
38 
39 // Destructor
41 
42 void
44 
45  // Initialize the Tracker Geometry
47  es.get<TrackerDigiGeometryRecord> ().get (theGeometry);
48  geometry = &(*theGeometry);
49 
50 }
51 
53 {
54  // Step A: Get Inputs (FastGSRecHit's)
56  e.getByLabel(hitCollectionInputTag_, theFastRecHits);
57 
58  // Step B: fill a temporary full RecHit collection from the fast RecHit collection
59  SiTrackerGSRecHit2DCollection::const_iterator aHit = theFastRecHits->begin();
60  SiTrackerGSRecHit2DCollection::const_iterator theLastHit = theFastRecHits->end();
61  std::map< DetId, edm::OwnVector<SiTrackerGSRecHit2D> > temporaryRecHits;
62 
63  // loop on Fast GS Hits
64  for ( ; aHit != theLastHit; ++aHit ) {
65 
66  DetId det = aHit->geographicalId();
67 
68  /*
69  const GeomDet* theDet = geometry->idToDet(det);
70  unsigned trackID = aHit->simtrackId();
71 
72  std::cout << "Track/z/r after : "
73  << trackID << " "
74  << theDet->surface().toGlobal(aHit->localPosition()).z() << " "
75  << theDet->surface().toGlobal(aHit->localPosition()).perp() << std::endl;
76  */
77 
78  // create RecHit
79  // Fill the temporary RecHit on the current DetId collection
80  temporaryRecHits[det].push_back(aHit->clone());
81 
82  }
83 
84  // Step C: from the temporary RecHit collection, create the real one.
85  std::auto_ptr<SiTrackerFullGSRecHit2DCollection>
86  recHitCollection(new SiTrackerFullGSRecHit2DCollection);
87  loadRecHits(temporaryRecHits, *recHitCollection);
88 
89  // Step D: write output to file
90  e.put(recHitCollection);
91 
92 }
93 
94 void
97  SiTrackerFullGSRecHit2DCollection& theRecHitCollection) const
98 {
99  std::map<DetId,edm::OwnVector<SiTrackerGSRecHit2D> >::const_iterator
100  it = theRecHits.begin();
101  std::map<DetId,edm::OwnVector<SiTrackerGSRecHit2D> >::const_iterator
102  lastRecHit = theRecHits.end();
103 
104  for( ; it != lastRecHit ; ++it ) {
105  theRecHitCollection.put(it->first,it->second.begin(),it->second.end());
106  }
107 
108 }
109 
const TrackerGeometry * geometry
void loadRecHits(std::map< DetId, edm::OwnVector< SiTrackerGSRecHit2D > > &theRecHits, SiTrackerFullGSRecHit2DCollection &theRecHitCollection) const
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:43
virtual void beginRun(edm::Run const &run, const edm::EventSetup &es) override
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:113
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:402
tuple conf
Definition: dbtoconf.py:185
void put(ID id, CI begin, CI end)
insert an object range with specified identifier
Definition: RangeMap.h:117
Definition: DetId.h:18
const T & get() const
Definition: EventSetup.h:55
TrackingRecHitTranslator(const edm::ParameterSet &conf)
virtual void produce(edm::Event &e, const edm::EventSetup &c) override
Definition: Run.h:41