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"
24 
25 // Data Formats
27 
28 // STL
29 #include <memory>
30 #include <string>
31 
33 {
34  produces<SiTrackerFullGSRecHit2DCollection>();
35 }
36 
37 // Destructor
39 
40 void
42 
43  // Initialize the Tracker Geometry
45  es.get<TrackerDigiGeometryRecord> ().get (theGeometry);
46  geometry = &(*theGeometry);
47 
48 }
49 
51 {
52  // Step A: Get Inputs (FastGSRecHit's)
54  e.getByType(theFastRecHits);
55 
56  // Step B: fill a temporary full RecHit collection from the fast RecHit collection
57  SiTrackerGSRecHit2DCollection::const_iterator aHit = theFastRecHits->begin();
58  SiTrackerGSRecHit2DCollection::const_iterator theLastHit = theFastRecHits->end();
59  std::map< DetId, edm::OwnVector<SiTrackerGSRecHit2D> > temporaryRecHits;
60 
61  // loop on Fast GS Hits
62  for ( ; aHit != theLastHit; ++aHit ) {
63 
64  DetId det = aHit->geographicalId();
65 
66  /*
67  const GeomDet* theDet = geometry->idToDet(det);
68  unsigned trackID = aHit->simtrackId();
69 
70  std::cout << "Track/z/r after : "
71  << trackID << " "
72  << theDet->surface().toGlobal(aHit->localPosition()).z() << " "
73  << theDet->surface().toGlobal(aHit->localPosition()).perp() << std::endl;
74  */
75 
76  // create RecHit
77  // Fill the temporary RecHit on the current DetId collection
78  temporaryRecHits[det].push_back(aHit->clone());
79 
80  }
81 
82  // Step C: from the temporary RecHit collection, create the real one.
83  std::auto_ptr<SiTrackerFullGSRecHit2DCollection>
84  recHitCollection(new SiTrackerFullGSRecHit2DCollection);
85  loadRecHits(temporaryRecHits, *recHitCollection);
86 
87  // Step D: write output to file
88  e.put(recHitCollection);
89 
90 }
91 
92 void
95  SiTrackerFullGSRecHit2DCollection& theRecHitCollection) const
96 {
97  std::map<DetId,edm::OwnVector<SiTrackerGSRecHit2D> >::const_iterator
98  it = theRecHits.begin();
99  std::map<DetId,edm::OwnVector<SiTrackerGSRecHit2D> >::const_iterator
100  lastRecHit = theRecHits.end();
101 
102  for( ; it != lastRecHit ; ++it ) {
103  theRecHitCollection.put(it->first,it->second.begin(),it->second.end());
104  }
105 
106 }
107 
virtual void produce(edm::Event &e, const edm::EventSetup &c)
const TrackerGeometry * geometry
void loadRecHits(std::map< DetId, edm::OwnVector< SiTrackerGSRecHit2D > > &theRecHits, SiTrackerFullGSRecHit2DCollection &theRecHitCollection) const
bool getByType(Handle< PROD > &result) const
Definition: Event.h:398
C::const_iterator const_iterator
constant access iterator type
Definition: RangeMap.h:45
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
tuple conf
Definition: dbtoconf.py:185
void put(ID id, CI begin, CI end)
insert an object range with specified identifier
Definition: RangeMap.h:119
Definition: DetId.h:20
const T & get() const
Definition: EventSetup.h:55
TrackingRecHitTranslator(const edm::ParameterSet &conf)
virtual void beginRun(edm::Run &run, const edm::EventSetup &es)
Definition: Run.h:33