CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
PlotSimTracks Class Reference

#include <PlotSimTracks.h>

Public Member Functions

 PlotSimTracks (const edm::EventSetup &es, std::ofstream &file_)
 
void printSimTracks (const edm::Event &ev, const edm::EventSetup &es)
 
 ~PlotSimTracks ()
 

Private Attributes

std::ofstream & file
 
const CaloGeometrytheCaloGeometry
 
const TrackerGeometrytheTracker
 

Detailed Description

Definition at line 12 of file PlotSimTracks.h.

Constructor & Destructor Documentation

PlotSimTracks::PlotSimTracks ( const edm::EventSetup es,
std::ofstream &  file_ 
)
explicit

Definition at line 53 of file PlotSimTracks.cc.

References edm::EventSetup::get(), and edm::ESHandle< class >::product().

53  : file(file_)
54 {
55  // Get tracker geometry
56  edm::ESHandle<TrackerGeometry> trackerHandle;
57  es.get<TrackerDigiGeometryRecord>().get(trackerHandle);
58  theTracker = trackerHandle.product();
59 
60  // Get calorimetry
62  es.get<CaloGeometryRecord>().get(calo);
63  theCaloGeometry = (const CaloGeometry*)calo.product();
64 }
std::ofstream & file
Definition: PlotSimTracks.h:20
const TrackerGeometry * theTracker
Definition: PlotSimTracks.h:21
const CaloGeometry * theCaloGeometry
Definition: PlotSimTracks.h:22
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
PlotSimTracks::~PlotSimTracks ( )

Definition at line 67 of file PlotSimTracks.cc.

68 {
69 }

Member Function Documentation

void PlotSimTracks::printSimTracks ( const edm::Event ev,
const edm::EventSetup es 
)

Definition at line 72 of file PlotSimTracks.cc.

References DetId::Ecal, EcalBarrel, EcalEndcap, mergeVDriftHistosByStation::file, relativeConstraints::geom, edm::EventSetup::get(), edm::Event::getByLabel(), CaloSubdetectorGeometry::getGeometry(), HitInfo::getInfo(), AlCaHLTBitMon_ParallelJobs::p, p1, p2, GeomDetEnumerators::PixelBarrel, GeomDetEnumerators::PixelEndcap, PlotUtils::printHelix(), edm::Handle< T >::product(), edm::ESHandle< class >::product(), trackerHits::simHits, python.multivaluedict::sort(), x, PV3DBase< T, PVType, FrameType >::x(), detailsBasic3DVector::y, PV3DBase< T, PVType, FrameType >::y(), detailsBasic3DVector::z, and PV3DBase< T, PVType, FrameType >::z().

73 {
74  //Retrieve tracker topology from geometry
76  es.get<IdealGeometryRecord>().get(tTopoHandle);
77  const TrackerTopology* const tTopo = tTopoHandle.product();
78 
79  // Tracker
81  ev.getByLabel("mix", simTrackHandle);
82  const TrackingParticleCollection* simTracks = simTrackHandle.product();
83 
84  // Ecal
86  ev.getByLabel("g4SimHits", "EcalHitsEB", simHitsBarrel);
87 
88 // edm::Handle<edm::PCaloHitContainer> simHitsPreshower;
89 // ev.getByLabel("g4SimHits", "EcalHitsES", simHitsPreshower);
90 
92  ev.getByLabel("g4SimHits", "EcalHitsEE", simHitsEndcap);
93 
94 // FIXME
95 /*
96  {
97  edm::Handle<edm::SimTrackContainer> simTracks;
98  ev.getByType<edm::SimTrackContainer>(simTracks);
99  std::cerr << " SSSSS " << simTracks.product()->size() << std::endl;
100 
101  for(edm::SimTrackContainer::const_iterator t = simTracks.product()->begin();
102  t!= simTracks.product()->end(); t++)
103  {
104  std::cerr << " simTrack " << t - simTracks.product()->begin()
105  << " " << t->type()
106  << " " << t->charge()
107  << " " << t->vertIndex()
108  << " " << t->genpartIndex()
109  << " " << t->momentum().x()
110  << " " << t->momentum().y()
111  << " " << t->momentum().z()
112  << std::endl;
113  }
114 
115  }
116 */
117 
119 
120  // Utilities
121  PlotUtils plotUtils;
122 
123  file << ", If[st, {RGBColor[0.5,0.5,0.5]";
124 
125  for(TrackingParticleCollection::const_iterator simTrack = simTracks->begin();
126  simTrack!= simTracks->end();
127  simTrack++)
128  {
129  std::vector<PSimHit> simHits;
130 
131 #warning "This file has been modified just to get it to compile without any regard as to whether it still functions as intended"
132 #ifdef REMOVED_JUST_TO_GET_IT_TO_COMPILE__THIS_CODE_NEEDS_TO_BE_CHECKED
133  simHits = simTrack->trackPSimHit();
134 #endif
135 
136  // reorder with help of momentum
137  sort(simHits.begin(), simHits.end(), sortByPabs());
138 
139  for(std::vector<PSimHit>::const_iterator simHit = simHits.begin();
140  simHit!= simHits.end(); simHit++)
141  {
142  DetId id = DetId(simHit->detUnitId());
143 
144  if(theTracker->idToDetUnit(id) != 0)
145  {
146  GlobalPoint p1 =
147  theTracker->idToDetUnit(id)->toGlobal(simHit->localPosition());
148  GlobalVector v1 =
149  theTracker->idToDetUnit(id)->toGlobal(simHit->localDirection());
150 
151  // simHit
152  file << ", Point[{" << p1.x() << "," << p1.y() << ",(" << p1.z() << "-zs)*mz}]"
153  << std::endl;
154  file << ", Text[StyleForm[\"s\", URL->\"SimHit | Ekin="
155  << simTrack->energy() - simTrack->mass()
156  << " GeV | parent: source="
157  << simTrack->parentVertex()->nSourceTracks()
158  << " daughter=" << simTrack->parentVertex()->nDaughterTracks()
159  << HitInfo::getInfo(*simHit, tTopo) << "\"], {"
160  << p1.x() << "," << p1.y() << ",(" << p1.z() << "-zs)*mz}, {1,1}]"
161  << std::endl;
162 
163  // det
164  double x = theTracker->idToDet(id)->surface().bounds().width() /2;
165  double y = theTracker->idToDet(id)->surface().bounds().length()/2;
166  double z = 0.;
167 
168  GlobalPoint p00 = theTracker->idToDet(id)->toGlobal(LocalPoint(-x,-y,z));
169  GlobalPoint p01 = theTracker->idToDet(id)->toGlobal(LocalPoint(-x, y,z));
170  GlobalPoint p10 = theTracker->idToDet(id)->toGlobal(LocalPoint( x,-y,z));
171  GlobalPoint p11 = theTracker->idToDet(id)->toGlobal(LocalPoint( x, y,z));
172 
173  if(theTracker->idToDet(id)->subDetector() ==
175  theTracker->idToDet(id)->subDetector() ==
177  file << ", If[sd, {RGBColor[0.6,0.6,0.6], ";
178  else
179  file << ", If[sd, {RGBColor[0.8,0.8,0.8], ";
180 
181  file <<"Line[{{"<< p00.x()<<","<<p00.y()<<",("<<p00.z()<<"-zs)*mz}, "
182  <<"{"<< p01.x()<<","<<p01.y()<<",("<<p01.z()<<"-zs)*mz}, "
183  <<"{"<< p11.x()<<","<<p11.y()<<",("<<p11.z()<<"-zs)*mz}, "
184  <<"{"<< p10.x()<<","<<p10.y()<<",("<<p10.z()<<"-zs)*mz}, "
185  <<"{"<< p00.x()<<","<<p00.y()<<",("<<p00.z()<<"-zs)*mz}}]}]"
186  << std::endl;
187 
188  if(simHit == simHits.begin()) // vertex to first point
189  {
190  GlobalPoint p0(simTrack->vertex().x(),
191  simTrack->vertex().y(),
192  simTrack->vertex().z());
193  plotUtils.printHelix(p0,p1,v1, file, simTrack->charge());
194  }
195 
196  if(simHit+1 != simHits.end()) // if not last
197  {
198  DetId id = DetId((simHit+1)->detUnitId());
199  GlobalPoint p2 =
200  theTracker->idToDetUnit(id)->toGlobal((simHit+1)->localPosition());
201  GlobalVector v2 =
202  theTracker->idToDetUnit(id)->toGlobal((simHit+1)->localDirection());
203 
204  plotUtils.printHelix(p1,p2,v2, file, simTrack->charge());
205  }
206 
207  // Continue to Ecal
208  if(simHit+1 == simHits.end()) // if last
209  {
210  DetId id = DetId(simHit->detUnitId());
211  GlobalPoint p =
212  theTracker->idToDetUnit(id)->toGlobal(simHit->localPosition());
213 
214  // EB
216 
217  for(edm::PCaloHitContainer::const_iterator
218  simHit = simHitsBarrel->begin();
219  simHit!= simHitsBarrel->end(); simHit++)
220  if(simHit->geantTrackId() == static_cast<int>(simTrack->g4Track_begin()->trackId()) && //the sign of trackId tells whether there was a match
221  simHit->energy() > 0.060)
222  {
223  EBDetId detId(simHit->id());
224  const CaloCellGeometry* cell = geom->getGeometry(detId);
225 
226  if(cell != 0)
227  file << ", Line[{{" << p.x()
228  << "," << p.y()
229  << ",(" << p.z() <<"-zs)*mz}"
230  << ", {" << cell->getPosition().x() << ","
231  << cell->getPosition().y() << ",("
232  << cell->getPosition().z() << "-zs)*mz}}]" << std::endl;
233  }
234 
235  // ES
236 
237  // EE
239 
240  for(edm::PCaloHitContainer::const_iterator
241  simHit = simHitsEndcap->begin();
242  simHit!= simHitsEndcap->end(); simHit++)
243  if(simHit->geantTrackId() == static_cast<int>(simTrack->g4Track_begin()->trackId()) && //the sign of trackId tells whether there was a match
244  simHit->energy() > 0.060)
245  {
246  EEDetId detId(simHit->id());
247  const CaloCellGeometry* cell = geom->getGeometry(detId);
248 
249  if(cell != 0)
250  file << ", Line[{{" << p.x()
251  << "," << p.y()
252  << ",(" << p.z() << "-zs)*mz}"
253  << ", {" << cell->getPosition().x() << ","
254  << cell->getPosition().y() << ",("
255  << cell->getPosition().z() << "-zs)*mz}}]" << std::endl;
256  }
257  }
258  }
259  }
260  }
261 
262  file << "}]";
263 }
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
Definition: CaloGeometry.cc:43
void printHelix(const GlobalPoint &p1, const GlobalPoint &p2, const GlobalVector &n2, std::ofstream &outFile, int charge)
Definition: PlotUtils.cc:7
virtual float length() const =0
std::vector< TrackingParticle > TrackingParticleCollection
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:47
T y() const
Definition: PV3DBase.h:63
virtual SubDetector subDetector() const =0
Which subdetector.
std::ofstream & file
Definition: PlotSimTracks.h:20
const Bounds & bounds() const
Definition: Surface.h:128
const Plane & surface() const
The nominal surface of the GeomDet.
Definition: GeomDet.h:35
float float float z
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
T z() const
Definition: PV3DBase.h:64
const TrackerGeometry * theTracker
Definition: PlotSimTracks.h:21
const CaloGeometry * theCaloGeometry
Definition: PlotSimTracks.h:22
double p2[4]
Definition: TauolaWrapper.h:90
virtual const GeomDet * idToDet(DetId) const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
Definition: DetId.h:20
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
tuple simHits
Definition: trackerHits.py:16
T const * product() const
Definition: Handle.h:74
virtual const GeomDetUnit * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
double p1[4]
Definition: TauolaWrapper.h:89
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
Definition: DDAxes.h:10
static std::string getInfo(const DetId &id, const TrackerTopology *tTopo)
Definition: HitInfo.cc:25
T x() const
Definition: PV3DBase.h:62
virtual float width() const =0

Member Data Documentation

std::ofstream& PlotSimTracks::file
private

Definition at line 20 of file PlotSimTracks.h.

const CaloGeometry* PlotSimTracks::theCaloGeometry
private

Definition at line 22 of file PlotSimTracks.h.

const TrackerGeometry* PlotSimTracks::theTracker
private

Definition at line 21 of file PlotSimTracks.h.