45 |
|
#include "DataFormats/GeometrySurface/interface/BoundSurface.h" |
46 |
|
#include "DataFormats/DetId/interface/DetId.h" |
47 |
|
|
48 |
+ |
#include "Geometry/CaloEventSetup/interface/CaloTopologyRecord.h" |
49 |
+ |
#include "Geometry/Records/interface/IdealGeometryRecord.h" |
50 |
+ |
#include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h" |
51 |
+ |
#include "Geometry/CaloGeometry/interface/CaloGeometry.h" |
52 |
+ |
#include "Geometry/EcalBarrelAlgo/interface/EcalBarrelGeometry.h" |
53 |
+ |
#include "Geometry/EcalEndcapAlgo/interface/EcalEndcapGeometry.h" |
54 |
+ |
#include "Geometry/CaloGeometry/interface/CaloCellGeometry.h" |
55 |
+ |
#include "DataFormats/EcalDetId/interface/EcalSubdetector.h" |
56 |
+ |
|
57 |
+ |
#include "DataFormats/CaloRecHit/interface/CaloRecHit.h" |
58 |
+ |
#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" |
59 |
+ |
#include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h" |
60 |
+ |
|
61 |
|
#include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" |
62 |
|
#include "SimDataFormats/TrackingHit/interface/PSimHit.h" |
63 |
|
#include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h" |
74 |
|
#include "DataFormats/TrackReco/interface/Track.h" |
75 |
|
|
76 |
|
#include "DataFormats/Math/interface/Point3D.h" |
77 |
< |
|
77 |
> |
#include "DataFormats/GeometrySurface/interface/TrapezoidalPlaneBounds.h" |
78 |
> |
#include "DataFormats/GeometrySurface/interface/RectangularPlaneBounds.h" |
79 |
|
|
80 |
|
#include "Visualisation/OpenGLDisplayer/interface/SimEvent.h" |
81 |
< |
//#include "Visualisation/OpenGLDisplayer/interface/SimEvent.cpp" |
68 |
< |
|
69 |
< |
|
81 |
> |
#include "Visualisation/OpenGLDisplayer/interface/Geometry.h" |
82 |
|
|
83 |
|
using namespace edm; |
84 |
|
using namespace std; |
94 |
|
|
95 |
|
|
96 |
|
private: |
97 |
< |
virtual void beginJob(const edm::EventSetup&) ; |
98 |
< |
virtual void analyze(const edm::Event&, const edm::EventSetup&); |
99 |
< |
virtual void endJob() ; |
97 |
> |
virtual void beginJob(const edm::EventSetup& iSetup); |
98 |
> |
virtual void analyze (const edm::Event&, const edm::EventSetup&); |
99 |
> |
virtual void endJob (); |
100 |
|
|
101 |
|
|
102 |
|
MySimEvents* MyEvents; |
103 |
+ |
Geometry* Geom_Tracker; |
104 |
+ |
Geometry* Geom_ECAL; |
105 |
+ |
Geometry* Geom_HCAL; |
106 |
|
|
107 |
|
|
108 |
|
std::vector<std::string> SimHitSubdetectors; |
130 |
|
|
131 |
|
// ------------ method called once each job just before starting event loop ------------ |
132 |
|
void |
133 |
< |
OpenGLDisplayer::beginJob(const edm::EventSetup&) |
133 |
> |
OpenGLDisplayer::beginJob(const edm::EventSetup& iSetup) |
134 |
|
{ |
135 |
+ |
DetId Detid; |
136 |
+ |
int SubDet; |
137 |
+ |
|
138 |
+ |
MyEvents = new MySimEvents(); |
139 |
+ |
Geom_Tracker = new Geometry(); |
140 |
+ |
Geom_ECAL = new Geometry(); |
141 |
+ |
Geom_HCAL = new Geometry(); |
142 |
+ |
|
143 |
+ |
|
144 |
+ |
edm::ESHandle<TrackerGeometry> tkGeom; |
145 |
+ |
iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom ); |
146 |
+ |
vector<GeomDet*> TrackerDets = tkGeom->dets(); |
147 |
+ |
|
148 |
+ |
for(unsigned int i=0;i<TrackerDets.size();i++){ |
149 |
+ |
Detid = TrackerDets[i]->geographicalId(); |
150 |
+ |
// SubDet = Detid.subdetId(); |
151 |
+ |
|
152 |
+ |
GeomDet* DetUnit = TrackerDets[i]; |
153 |
+ |
if(!DetUnit)continue; |
154 |
+ |
const BoundPlane plane = DetUnit->surface(); |
155 |
+ |
const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds()))); |
156 |
+ |
const RectangularPlaneBounds* rectangularBounds( dynamic_cast<const RectangularPlaneBounds*>(&(plane.bounds()))); |
157 |
+ |
|
158 |
+ |
float width = 0; |
159 |
+ |
float length = 0; |
160 |
+ |
float thickness = 0; |
161 |
+ |
float TrapezoidalParam = 0; |
162 |
+ |
|
163 |
+ |
if(trapezoidalBounds) |
164 |
+ |
{ |
165 |
+ |
std::vector<float> const & parameters = (*trapezoidalBounds).parameters(); |
166 |
+ |
width = parameters[0]*2; |
167 |
+ |
length = parameters[3]*2; |
168 |
+ |
thickness = (*trapezoidalBounds).thickness(); |
169 |
+ |
TrapezoidalParam = parameters[1]/parameters[0]; |
170 |
+ |
}else if(rectangularBounds){ |
171 |
+ |
width = DetUnit->surface().bounds().width(); |
172 |
+ |
length = DetUnit->surface().bounds().length(); |
173 |
+ |
thickness = DetUnit->surface().bounds().thickness(); |
174 |
+ |
TrapezoidalParam = 1; |
175 |
+ |
} |
176 |
+ |
|
177 |
+ |
Surface::GlobalPoint WidthVector = plane.toGlobal( LocalPoint(width/2, 0, 0) ); |
178 |
+ |
Surface::GlobalPoint LengthVector = plane.toGlobal( LocalPoint(0, length/2, 0) ); |
179 |
+ |
Surface::GlobalPoint ThickVector = plane.toGlobal( LocalPoint(0, 0, thickness/2) ); |
180 |
+ |
|
181 |
+ |
GlobalVector Pos = GlobalVector(DetUnit->position().basicVector()); |
182 |
+ |
|
183 |
+ |
Geom_Tracker->Add_TrackerDet(Detid.rawId(), TrapezoidalParam, |
184 |
+ |
Pos.x(), Pos.y(), Pos.z(), |
185 |
+ |
WidthVector.x() -Pos.x(), WidthVector.y() -Pos.y(), WidthVector.z() -Pos.z(), |
186 |
+ |
LengthVector.x()-Pos.x(), LengthVector.y()-Pos.y(), LengthVector.z()-Pos.z(), |
187 |
+ |
ThickVector.x() -Pos.x(), ThickVector.y() -Pos.y(), ThickVector.z() -Pos.z()); |
188 |
+ |
|
189 |
+ |
|
190 |
+ |
} |
191 |
+ |
|
192 |
+ |
|
193 |
+ |
// ### CALO GEOMETRY ### |
194 |
+ |
|
195 |
+ |
edm::ESHandle<CaloGeometry> CaloGeom; |
196 |
+ |
iSetup.get<IdealGeometryRecord>().get( CaloGeom ); |
197 |
+ |
const vector<DetId> CaloDets = CaloGeom->getValidDetIds(); |
198 |
+ |
|
199 |
+ |
for(unsigned int i=0;i<CaloDets.size();i++) |
200 |
+ |
{ |
201 |
+ |
Detid = CaloDets[i]; |
202 |
+ |
SubDet = Detid.subdetId(); |
203 |
+ |
|
204 |
+ |
Geometry* Geom_temp = NULL; |
205 |
+ |
if(Detid.det()==DetId::Ecal){ |
206 |
+ |
Geom_temp = Geom_ECAL; |
207 |
+ |
|
208 |
+ |
if(SubDet<1 || SubDet>3){ |
209 |
+ |
printf("Don't Save EcalTriggerTower or EcalLaserPnDiode\n"); |
210 |
+ |
continue; |
211 |
+ |
} |
212 |
+ |
}else if(Detid.det()==DetId::Hcal){ |
213 |
+ |
Geom_temp = Geom_HCAL; |
214 |
+ |
|
215 |
+ |
if(SubDet<1 || SubDet>4){ |
216 |
+ |
printf("Don't Save HcalEmpty, HcalTriggerTower, HcalOther\n"); |
217 |
+ |
continue; |
218 |
+ |
} |
219 |
+ |
}else{ |
220 |
+ |
continue; |
221 |
+ |
} |
222 |
+ |
|
223 |
+ |
const CaloCellGeometry* CellGeom = CaloGeom->getGeometry(Detid); |
224 |
+ |
GlobalPoint CellPos = CellGeom->getPosition(); |
225 |
+ |
const CaloCellGeometry::CornersVec CellCorners = CellGeom->getCorners(); |
226 |
+ |
|
227 |
+ |
Geom_temp->Add_CaloDet(Detid.rawId(), |
228 |
+ |
CellPos.x() , CellPos.y() , CellPos.z(), |
229 |
+ |
CellCorners[0].x() , CellCorners[0].y() , CellCorners[0].z() , |
230 |
+ |
CellCorners[1].x() , CellCorners[1].y() , CellCorners[1].z() , |
231 |
+ |
CellCorners[2].x() , CellCorners[2].y() , CellCorners[2].z() , |
232 |
+ |
CellCorners[3].x() , CellCorners[3].y() , CellCorners[3].z() , |
233 |
+ |
CellCorners[4].x() , CellCorners[4].y() , CellCorners[4].z() , |
234 |
+ |
CellCorners[5].x() , CellCorners[5].y() , CellCorners[5].z() , |
235 |
+ |
CellCorners[6].x() , CellCorners[6].y() , CellCorners[6].z() , |
236 |
+ |
CellCorners[7].x() , CellCorners[7].y() , CellCorners[7].z() ); |
237 |
+ |
} |
238 |
+ |
|
239 |
+ |
Geom_Tracker->Save("Tracker.geom"); |
240 |
+ |
Geom_ECAL->Save("ECAL.geom"); |
241 |
+ |
Geom_HCAL->Save("HCAL.geom"); |
242 |
|
|
243 |
|
|
122 |
– |
MyEvents = new MySimEvents(); |
244 |
|
|
245 |
|
} |
246 |
|
|
249 |
|
OpenGLDisplayer::endJob() { |
250 |
|
|
251 |
|
MyEvents->Save((char*) OutputFile.c_str()); |
252 |
< |
MyEvents->Load((char*) OutputFile.c_str()); |
252 |
> |
// MyEvents->Load((char*) OutputFile.c_str()); |
253 |
|
} |
254 |
|
|
255 |
|
|
340 |
|
} |
341 |
|
} |
342 |
|
|
222 |
– |
|
223 |
– |
|
224 |
– |
|
343 |
|
edm::Handle<std::vector< reco::Track > > h_Tracks; |
344 |
|
iEvent.getByLabel("ctfWithMaterialTracks", h_Tracks); |
345 |
|
std::vector< reco::Track > TrackColl = *h_Tracks.product(); |
348 |
|
MyRecoTrack MyrecoTrack; |
349 |
|
reco::Track recoTrack =TrackColl[t]; |
350 |
|
|
351 |
< |
MyrecoTrack.N = recoTrack.recHitsSize(); |
234 |
< |
MyrecoTrack.Hits = new MyRecoHit[MyrecoTrack.N]; |
351 |
> |
// MyrecoTrack.Hits = new MyRecoHit[MyrecoTrack.N]; |
352 |
|
|
353 |
< |
// for(int h=0;h<MyrecoTrack.N;h++){ |
237 |
< |
// MyrecoTrack.Hits[h].x = 1; |
238 |
< |
// MyrecoTrack.Hits[h].y = 2; |
239 |
< |
// MyrecoTrack.Hits[h].z = 3; |
240 |
< |
// MyrecoTrack.Hits[h].DetId = 4; |
241 |
< |
// MyrecoTrack.Hits[h].Charge = 5; |
242 |
< |
// } |
243 |
< |
|
244 |
< |
// unsigned int h=0; |
245 |
< |
// for(trackingRecHit_iterator h_it = recoTrack.recHitsBegin();h_it!=recoTrack.recHitsEnd();h_it++){ |
246 |
< |
for(int h=0;h<MyrecoTrack.N;h++){ |
353 |
> |
for(unsigned int h=0;h<recoTrack.recHitsSize();h++){ |
354 |
|
TrackingRecHitRef h_it = recoTrack.recHit(h); |
355 |
|
if(!h_it->isValid() )continue; |
356 |
|
DetId detId = h_it->geographicalId(); |
357 |
|
const GeomDet * theDet = theTracker.idToDet(detId); |
358 |
|
LocalPoint localPos = h_it->localPosition(); |
252 |
– |
|
253 |
– |
MyrecoTrack.Hits[h].x = theDet->surface().toGlobal(localPos).x(); |
254 |
– |
MyrecoTrack.Hits[h].y = theDet->surface().toGlobal(localPos).y(); |
255 |
– |
MyrecoTrack.Hits[h].z = theDet->surface().toGlobal(localPos).z(); |
256 |
– |
MyrecoTrack.Hits[h].DetId = detId.rawId(); |
257 |
– |
MyrecoTrack.Hits[h].Charge = -1; |
258 |
– |
} |
359 |
|
|
360 |
+ |
MyRecoHit hit; |
361 |
+ |
hit.x = theDet->surface().toGlobal(localPos).x(); |
362 |
+ |
hit.y = theDet->surface().toGlobal(localPos).y(); |
363 |
+ |
hit.z = theDet->surface().toGlobal(localPos).z(); |
364 |
+ |
hit.DetId = detId.rawId(); |
365 |
+ |
hit.Charge = -1; |
366 |
+ |
MyrecoTrack.Hits.push_back(hit); |
367 |
+ |
|
368 |
+ |
|
369 |
+ |
// printf("%8.2f %8.2f %8.2f\n",theDet->surface().toGlobal(localPos).x(),theDet->surface().toGlobal(localPos).y(),theDet->surface().toGlobal(localPos).z()); |
370 |
+ |
} |
371 |
|
MyEvent->MyRecoTrackCollection.push_back(MyrecoTrack); |
372 |
|
} |
373 |
|
|
374 |
+ |
|
375 |
+ |
|
376 |
+ |
edm::Handle<EcalRecHitCollection > h_EcalEB_RecHits; |
377 |
+ |
iEvent.getByLabel("ecalRecHit","EcalRecHitsEB", h_EcalEB_RecHits); |
378 |
+ |
EcalRecHitCollection EcalEB_RecHits = *h_EcalEB_RecHits.product(); |
379 |
+ |
|
380 |
+ |
for(unsigned int eh=0;eh<EcalEB_RecHits.size();eh++){ |
381 |
+ |
MyCaloHit temp_EcalEBHit; |
382 |
+ |
temp_EcalEBHit.E = EcalEB_RecHits[eh].energy(); |
383 |
+ |
temp_EcalEBHit.t = EcalEB_RecHits[eh].time(); |
384 |
+ |
temp_EcalEBHit.DetId = (EcalEB_RecHits[eh].detid()).rawId(); |
385 |
|
|
386 |
+ |
MyEvent->MyEcalCaloHitCollection.push_back(temp_EcalEBHit); |
387 |
+ |
} |
388 |
+ |
|
389 |
+ |
|
390 |
+ |
edm::Handle<EcalRecHitCollection > h_EcalEE_RecHits; |
391 |
+ |
iEvent.getByLabel("ecalRecHit","EcalRecHitsEE", h_EcalEE_RecHits); |
392 |
+ |
EcalRecHitCollection EcalEE_RecHits = *h_EcalEE_RecHits.product(); |
393 |
+ |
|
394 |
+ |
for(unsigned int eh=0;eh<EcalEE_RecHits.size();eh++){ |
395 |
+ |
MyCaloHit temp_EcalEEHit; |
396 |
+ |
temp_EcalEEHit.E = EcalEE_RecHits[eh].energy(); |
397 |
+ |
temp_EcalEEHit.t = EcalEE_RecHits[eh].time(); |
398 |
+ |
temp_EcalEEHit.DetId = (EcalEE_RecHits[eh].detid()).rawId(); |
399 |
+ |
|
400 |
+ |
MyEvent->MyEcalCaloHitCollection.push_back(temp_EcalEEHit); |
401 |
+ |
} |
402 |
+ |
|
403 |
+ |
|
404 |
+ |
edm::Handle<EcalRecHitCollection > h_EcalES_RecHits; |
405 |
+ |
iEvent.getByLabel("ecalPreshowerRecHit","EcalRecHitsES", h_EcalES_RecHits); |
406 |
+ |
EcalRecHitCollection EcalES_RecHits = *h_EcalES_RecHits.product(); |
407 |
+ |
|
408 |
+ |
for(unsigned int eh=0;eh<EcalES_RecHits.size();eh++){ |
409 |
+ |
MyCaloHit temp_EcalESHit; |
410 |
+ |
temp_EcalESHit.E = EcalES_RecHits[eh].energy(); |
411 |
+ |
temp_EcalESHit.t = EcalES_RecHits[eh].time(); |
412 |
+ |
temp_EcalESHit.DetId = (EcalES_RecHits[eh].detid()).rawId(); |
413 |
+ |
|
414 |
+ |
MyEvent->MyEcalCaloHitCollection.push_back(temp_EcalESHit); |
415 |
+ |
} |
416 |
+ |
|
417 |
+ |
|
418 |
+ |
|
419 |
+ |
edm::Handle<HBHERecHitCollection > h_HcalHBHE_RecHits; |
420 |
+ |
iEvent.getByLabel("hbhereco", h_HcalHBHE_RecHits); |
421 |
+ |
HBHERecHitCollection HcalHBHE_RecHits = *h_HcalHBHE_RecHits.product(); |
422 |
+ |
|
423 |
+ |
for(unsigned int hh=0;hh<HcalHBHE_RecHits.size();hh++){ |
424 |
+ |
MyCaloHit temp_HcalHBHEHit; |
425 |
+ |
temp_HcalHBHEHit.E = HcalHBHE_RecHits[hh].energy(); |
426 |
+ |
temp_HcalHBHEHit.t = HcalHBHE_RecHits[hh].time(); |
427 |
+ |
temp_HcalHBHEHit.DetId = (HcalHBHE_RecHits[hh].detid()).rawId(); |
428 |
+ |
|
429 |
+ |
MyEvent->MyHcalCaloHitCollection.push_back(temp_HcalHBHEHit); |
430 |
+ |
} |
431 |
+ |
|
432 |
+ |
|
433 |
+ |
edm::Handle<HORecHitCollection > h_HcalHO_RecHits; |
434 |
+ |
iEvent.getByLabel("horeco", h_HcalHO_RecHits); |
435 |
+ |
HORecHitCollection HcalHO_RecHits = *h_HcalHO_RecHits.product(); |
436 |
+ |
|
437 |
+ |
for(unsigned int hh=0;hh<HcalHO_RecHits.size();hh++){ |
438 |
+ |
MyCaloHit temp_HcalHOHit; |
439 |
+ |
temp_HcalHOHit.E = HcalHO_RecHits[hh].energy(); |
440 |
+ |
temp_HcalHOHit.t = HcalHO_RecHits[hh].time(); |
441 |
+ |
temp_HcalHOHit.DetId = (HcalHO_RecHits[hh].detid()).rawId(); |
442 |
+ |
|
443 |
+ |
MyEvent->MyHcalCaloHitCollection.push_back(temp_HcalHOHit); |
444 |
+ |
} |
445 |
+ |
|
446 |
+ |
edm::Handle<HFRecHitCollection > h_HcalHF_RecHits; |
447 |
+ |
iEvent.getByLabel("hfreco", h_HcalHF_RecHits); |
448 |
+ |
HFRecHitCollection HcalHF_RecHits = *h_HcalHF_RecHits.product(); |
449 |
+ |
|
450 |
+ |
for(unsigned int hh=0;hh<HcalHF_RecHits.size();hh++){ |
451 |
+ |
MyCaloHit temp_HcalHFHit; |
452 |
+ |
temp_HcalHFHit.E = HcalHF_RecHits[hh].energy(); |
453 |
+ |
temp_HcalHFHit.t = HcalHF_RecHits[hh].time(); |
454 |
+ |
temp_HcalHFHit.DetId = (HcalHF_RecHits[hh].detid()).rawId(); |
455 |
+ |
|
456 |
+ |
MyEvent->MyHcalCaloHitCollection.push_back(temp_HcalHFHit); |
457 |
+ |
} |
458 |
+ |
|
459 |
+ |
|
460 |
+ |
|
461 |
+ |
|
462 |
+ |
|
463 |
+ |
|
464 |
+ |
|
465 |
+ |
|
466 |
+ |
|
467 |
+ |
|
468 |
|
|
469 |
|
MyEvents->Events.push_back(MyEvent); |
470 |
|
|