CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PlotRecHits.cc
Go to the documentation of this file.
2 
6 
10 
14 
15 #include <vector>
16 
17 using namespace std;
18 
19 /*****************************************************************************/
21  (const edm::EventSetup& es, ofstream& file_) : file(file_)
22 {
23  // Get tracker geometry
24  edm::ESHandle<TrackerGeometry> trackerHandle;
25  es.get<TrackerDigiGeometryRecord>().get(trackerHandle);
26  theTracker = trackerHandle.product();
27 }
28 
29 /*****************************************************************************/
31 {
32 }
33 
34 /*****************************************************************************/
36 {
37  DetId id = recHit->geographicalId();
38 
39  // DetUnit
40  double x = theTracker->idToDet(id)->surface().bounds().width() /2;
41  double y = theTracker->idToDet(id)->surface().bounds().length()/2;
42  double z = 0.;
43 
44  GlobalPoint p00 = theTracker->idToDet(id)->toGlobal(LocalPoint(-x,-y,z));
45  GlobalPoint p01 = theTracker->idToDet(id)->toGlobal(LocalPoint(-x, y,z));
46  GlobalPoint p10 = theTracker->idToDet(id)->toGlobal(LocalPoint( x,-y,z));
47  GlobalPoint p11 = theTracker->idToDet(id)->toGlobal(LocalPoint( x, y,z));
48 
49  file << ", If[sd, {RGBColor[0.4,0.4,0.4], "
50  <<"Line[{{"<<p00.x()<<","<<p00.y()<<",("<<p00.z()<<"-zs)*mz}, "
51  <<"{"<<p01.x()<<","<<p01.y()<<",("<<p01.z()<<"-zs)*mz}, "
52  <<"{"<<p11.x()<<","<<p11.y()<<",("<<p11.z()<<"-zs)*mz}, "
53  <<"{"<<p10.x()<<","<<p10.y()<<",("<<p10.z()<<"-zs)*mz}, "
54  <<"{"<<p00.x()<<","<<p00.y()<<",("<<p00.z()<<"-zs)*mz}}]}]"
55  << std::endl;
56 
57  // RecHit
58  LocalPoint lpos; GlobalPoint p;
59 
60  lpos = LocalPoint(recHit->localPosition().x(),
61  recHit->localPosition().y(),
62  recHit->localPosition().z());
63 
64  p = theTracker->idToDet(id)->toGlobal(lpos);
65  file << ", Point[{"<<p.x()<<","<<p.y()<<",("<<p.z()<<"-zs)*mz}]" << std::endl;
66 
67  // Cluster details
68  SiPixelRecHit::ClusterRef const& cluster = recHit->cluster();
69  std::vector<SiPixelCluster::Pixel> pixels = cluster->pixels();
70 
71  file << ", Text[StyleForm[\"r\", FontFamily->\"Helvetica\", URL -> \"RecHit |";
72  for(std::vector<SiPixelCluster::Pixel>::const_iterator
73  pixel = pixels.begin(); pixel!= pixels.end(); pixel++)
74  {
75  file << " [" << int(pixel->x)
76  << " " << int(pixel->y)
77  << " " << int(pixel->adc/135) << "]";
78  }
79  file << "\"]";
80 
81  file << ", {"<< p.x()<<","<<p.y()<<",("<<p.z()<<"-zs)*mz}"
82  << ", {-1,1}]" << std::endl;
83 }
84 
85 /*****************************************************************************/
86 void PlotRecHits::printStripRecHit(const SiStripRecHit2D * recHit)
87 {
88  DetId id = recHit->geographicalId();
89 
90  // DetUnit
91  double x = theTracker->idToDet(id)->surface().bounds().width() /2;
92  double y = theTracker->idToDet(id)->surface().bounds().length()/2;
93  double z = 0.;
94 
95  GlobalPoint p00 = theTracker->idToDet(id)->toGlobal(LocalPoint(-x,-y,z));
96  GlobalPoint p01 = theTracker->idToDet(id)->toGlobal(LocalPoint(-x, y,z));
97  GlobalPoint p10 = theTracker->idToDet(id)->toGlobal(LocalPoint( x,-y,z));
98  GlobalPoint p11 = theTracker->idToDet(id)->toGlobal(LocalPoint( x, y,z));
99 
100  file << ", If[sd, {RGBColor[0.6,0.6,0.6], "
101  <<"Line[{{"<<p00.x()<<","<<p00.y()<<",("<<p00.z()<<"-zs)*mz}, "
102  <<"{"<<p01.x()<<","<<p01.y()<<",("<<p01.z()<<"-zs)*mz}, "
103  <<"{"<<p11.x()<<","<<p11.y()<<",("<<p11.z()<<"-zs)*mz}, "
104  <<"{"<<p10.x()<<","<<p10.y()<<",("<<p10.z()<<"-zs)*mz}, "
105  <<"{"<<p00.x()<<","<<p00.y()<<",("<<p00.z()<<"-zs)*mz}}]}]"
106  << std::endl;
107 
108  // RecHit
109  LocalPoint lpos; GlobalPoint p;
110 
111  lpos = LocalPoint(recHit->localPosition().x(),
112  y, recHit->localPosition().z());
113  p = theTracker->idToDet(id)->toGlobal(lpos);
114  file << ", Line[{{"<<p.x()<<","<<p.y()<<",("<<p.z()<<"-zs)*mz}, {";
115 
116  lpos = LocalPoint(recHit->localPosition().x(),
117  -y, recHit->localPosition().z());
118  p = theTracker->idToDet(id)->toGlobal(lpos);
119  file << ""<<p.x()<<","<<p.y()<<",("<<p.z()<<"-zs)*mz}}]" << std::endl;
120 }
121 
122 /*****************************************************************************/
124 {
125  // Get pixel hit collections
126 /*
127  std::vector<edm::Handle<SiPixelRecHitCollection> > pixelColls;
128  ev.getManyByType(pixelColls);
129 
130  for(std::vector<edm::Handle<SiPixelRecHitCollection> >::const_iterator
131  pixelColl = pixelColls.begin();
132  pixelColl!= pixelColls.end(); pixelColl++)
133  {
134  const SiPixelRecHitCollection* thePixelHits = (*pixelColl).product();
135 
136  for(SiPixelRecHitCollection::DataContainer::const_iterator
137  recHit = thePixelHits->data().begin();
138  recHit!= thePixelHits->data().end(); recHit++)
139  {
140  if(recHit->isValid())
141  printPixelRecHit(&(*recHit));
142  }
143  }
144 */
145 
147  ev.getByLabel("siPixelRecHits", pixelColl);
148  const SiPixelRecHitCollection* thePixelHits = pixelColl.product();
149 
151  recHit = thePixelHits->data().begin();
152  recHit!= thePixelHits->data().end(); recHit++)
153  {
154  if(recHit->isValid())
155  printPixelRecHit(&(*recHit));
156  }
157 
158 }
159 
160 /*****************************************************************************/
162 {
163  {
164  // Get strip hit collections
165  std::vector<edm::Handle<SiStripRecHit2DCollection> > stripColls;
166  ev.getManyByType(stripColls);
167 
168  for(std::vector<edm::Handle<SiStripRecHit2DCollection> >::const_iterator
169  stripColl = stripColls.begin();
170  stripColl!= stripColls.end(); stripColl++)
171  {
172  const SiStripRecHit2DCollection* theStripHits = (*stripColl).product();
173 
175  recHit = theStripHits->data().begin();
176  recHit!= theStripHits->data().end(); recHit++)
177  {
178  if(recHit->isValid())
179  printStripRecHit(&(*recHit));
180  }
181  }
182  }
183 
184  // Get matched strip hit collections
185  {
186  std::vector<edm::Handle<SiStripMatchedRecHit2DCollection> > stripColls;
187  ev.getManyByType(stripColls);
188 
189  for(std::vector<edm::Handle<SiStripMatchedRecHit2DCollection> >::const_iterator
190  stripColl = stripColls.begin();
191  stripColl!= stripColls.end(); stripColl++)
192  {
193  const SiStripMatchedRecHit2DCollection* theStripHits = (*stripColl).product();
194 
196  recHit = theStripHits->data().begin();
197  recHit!= theStripHits->data().end(); recHit++)
198  {
199  auto m = recHit->monoHit();
200  auto s = recHit->stereoHit();
201  printStripRecHit(&m);
202  printStripRecHit(&s);
203 
204  DetId id = recHit->geographicalId();
205  LocalPoint lpos = recHit->localPosition();
206  GlobalPoint p = theTracker->idToDet(id)->toGlobal(lpos);
207 
208  file << ", Point[{"<< p.x()<<","<<p.y()<<",("<<p.z()<<"-zs)*mz}]" << std::endl;
209  }
210  }
211  }
212 }
213 
214 /*****************************************************************************/
216 {
217  file << "AbsolutePointSize[5]";
218  file << ", If[pr, {RGBColor[0.4,0.4,1.0]";
219  printPixelRecHits(ev);
220  file << "}]";
221 
222  file << ", If[sr, {RGBColor[0.6,0.6,1.0]";
223  printStripRecHits(ev);
224  file << "}]";
225 }
226 
void getManyByType(std::vector< Handle< PROD > > &results) const
Definition: Event.h:395
boost::transform_iterator< IterHelp, const_IdIter > const_iterator
T y() const
Definition: PV3DBase.h:63
PlotRecHits(const edm::EventSetup &es, std::ofstream &file_)
Definition: PlotRecHits.cc:21
float float float z
void printPixelRecHit(const SiPixelRecHit *recHit)
Definition: PlotRecHits.cc:35
T z() const
Definition: PV3DBase.h:64
void printPixelRecHits(const edm::Event &ev)
Definition: PlotRecHits.cc:123
data_type const * data(size_t cell) const
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:361
void printStripRecHit(const SiStripRecHit2D *recHit)
Definition: PlotRecHits.cc:86
Definition: DetId.h:20
const T & get() const
Definition: EventSetup.h:55
void printStripRecHits(const edm::Event &ev)
Definition: PlotRecHits.cc:161
T const * product() const
Definition: ESHandle.h:62
T const * product() const
Definition: Handle.h:74
Local3DPoint LocalPoint
Definition: LocalPoint.h:11
Definition: DDAxes.h:10
T x() const
Definition: PV3DBase.h:62
void printRecHits(const edm::Event &ev)
Definition: PlotRecHits.cc:215
Pixel Reconstructed Hit.