54 |
|
#include "Geometry/CaloGeometry/interface/CaloCellGeometry.h" |
55 |
|
#include "DataFormats/EcalDetId/interface/EcalSubdetector.h" |
56 |
|
|
57 |
+ |
#include "Geometry/CommonDetUnit/interface/TrackingGeometry.h" |
58 |
+ |
#include "Geometry/Records/interface/MuonGeometryRecord.h" |
59 |
+ |
#include "Geometry/DTGeometry/interface/DTGeometry.h" |
60 |
+ |
|
61 |
+ |
|
62 |
|
#include "DataFormats/CaloRecHit/interface/CaloRecHit.h" |
63 |
|
#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h" |
64 |
|
#include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h" |
108 |
|
Geometry* Geom_Tracker; |
109 |
|
Geometry* Geom_ECAL; |
110 |
|
Geometry* Geom_HCAL; |
111 |
+ |
Geometry* Geom_Muon; |
112 |
|
|
113 |
|
|
108 |
– |
std::vector<std::string> SimHitSubdetectors; |
109 |
– |
|
114 |
|
std::string OutputFile; |
115 |
|
|
116 |
+ |
std::vector<InputTag> SimTrackProducers; |
117 |
+ |
std::vector<InputTag> SimVertexProducers; |
118 |
+ |
std::vector<InputTag> SimHitProducers; |
119 |
+ |
|
120 |
+ |
std::vector<InputTag> TrackProducers; |
121 |
+ |
std::vector<InputTag> EcalRecHitProducers; |
122 |
+ |
std::vector<InputTag> HcalHBHERecHitProducers; |
123 |
+ |
std::vector<InputTag> HcalHORecHitProducers; |
124 |
+ |
std::vector<InputTag> HcalHFRecHitProducers; |
125 |
+ |
|
126 |
+ |
|
127 |
+ |
|
128 |
|
|
129 |
|
// ----------member data --------------------------- |
130 |
|
}; |
134 |
|
// |
135 |
|
OpenGLDisplayer::OpenGLDisplayer(const edm::ParameterSet& iConfig) |
136 |
|
{ |
137 |
< |
SimHitSubdetectors = iConfig.getParameter<std::vector<std::string> >("SimHitSubdetectors"); |
137 |
> |
OutputFile = iConfig.getParameter<std::string >("OutputFile"); |
138 |
> |
|
139 |
> |
SimTrackProducers = iConfig.getParameter<std::vector<InputTag> >("SimTrackProducers"); |
140 |
> |
SimVertexProducers = iConfig.getParameter<std::vector<InputTag> >("SimVertexProducers"); |
141 |
> |
SimHitProducers = iConfig.getParameter<std::vector<InputTag> >("SimHitProducers"); |
142 |
> |
|
143 |
> |
TrackProducers = iConfig.getParameter<std::vector<InputTag> >("TrackProducers"); |
144 |
> |
EcalRecHitProducers = iConfig.getParameter<std::vector<InputTag> >("EcalRecHitProducers"); |
145 |
> |
HcalHBHERecHitProducers = iConfig.getParameter<std::vector<InputTag> >("HcalHBHERecHitProducers"); |
146 |
> |
HcalHORecHitProducers = iConfig.getParameter<std::vector<InputTag> >("HcalHORecHitProducers"); |
147 |
> |
HcalHFRecHitProducers = iConfig.getParameter<std::vector<InputTag> >("HcalHFRecHitProducers"); |
148 |
|
|
123 |
– |
OutputFile = iConfig.getParameter<std::string >("OutputFile"); |
149 |
|
} |
150 |
|
|
151 |
|
|
164 |
|
Geom_Tracker = new Geometry(); |
165 |
|
Geom_ECAL = new Geometry(); |
166 |
|
Geom_HCAL = new Geometry(); |
167 |
+ |
Geom_Muon = new Geometry(); |
168 |
+ |
|
169 |
|
|
170 |
+ |
// ### TRACKER GEOMETRY ### |
171 |
|
|
172 |
|
edm::ESHandle<TrackerGeometry> tkGeom; |
173 |
|
iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom ); |
264 |
|
CellCorners[7].x() , CellCorners[7].y() , CellCorners[7].z() ); |
265 |
|
} |
266 |
|
|
267 |
< |
Geom_Tracker->Save("Tracker.geom"); |
268 |
< |
Geom_ECAL->Save("ECAL.geom"); |
269 |
< |
Geom_HCAL->Save("HCAL.geom"); |
267 |
> |
// ### MUON GEOMETRY ### |
268 |
> |
|
269 |
> |
edm::ESHandle<DTGeometry> DtGeom; |
270 |
> |
// iSetup.get<IdealGeometryRecord>().get( DtGeom ); |
271 |
> |
iSetup.get<MuonGeometryRecord>().get( DtGeom ); |
272 |
> |
const vector<GeomDet*> DtDets = DtGeom->dets(); |
273 |
> |
|
274 |
> |
|
275 |
> |
for(unsigned int i=0;i<DtDets.size();i++) |
276 |
> |
{ |
277 |
> |
Detid = DetId(DtDets[i]->geographicalId()); |
278 |
> |
SubDet = Detid.subdetId(); |
279 |
> |
|
280 |
> |
GeomDet* DetUnit = DtDets[i]; |
281 |
> |
if(!DetUnit)continue; |
282 |
> |
const BoundPlane plane = DetUnit->surface(); |
283 |
> |
const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds()))); |
284 |
> |
const RectangularPlaneBounds* rectangularBounds( dynamic_cast<const RectangularPlaneBounds*>(&(plane.bounds()))); |
285 |
> |
|
286 |
> |
float width = 0; |
287 |
> |
float length = 0; |
288 |
> |
float thickness = 0; |
289 |
> |
float TrapezoidalParam = 0; |
290 |
> |
|
291 |
> |
if(trapezoidalBounds) |
292 |
> |
{ |
293 |
> |
std::vector<float> const & parameters = (*trapezoidalBounds).parameters(); |
294 |
> |
width = parameters[0]*2; |
295 |
> |
length = parameters[3]*2; |
296 |
> |
thickness = (*trapezoidalBounds).thickness(); |
297 |
> |
TrapezoidalParam = parameters[1]/parameters[0]; |
298 |
> |
}else if(rectangularBounds){ |
299 |
> |
width = DetUnit->surface().bounds().width(); |
300 |
> |
length = DetUnit->surface().bounds().length(); |
301 |
> |
thickness = DetUnit->surface().bounds().thickness(); |
302 |
> |
TrapezoidalParam = 1; |
303 |
> |
} |
304 |
> |
|
305 |
> |
Surface::GlobalPoint WidthVector = plane.toGlobal( LocalPoint(width/2, 0, 0) ); |
306 |
> |
Surface::GlobalPoint LengthVector = plane.toGlobal( LocalPoint(0, length/2, 0) ); |
307 |
> |
Surface::GlobalPoint ThickVector = plane.toGlobal( LocalPoint(0, 0, thickness/2) ); |
308 |
> |
|
309 |
> |
GlobalVector Pos = GlobalVector(DetUnit->position().basicVector()); |
310 |
> |
|
311 |
> |
printf("Det = %i\n",Detid.det()); |
312 |
> |
Geom_Muon->Add_TrackerDet(Detid.rawId(), TrapezoidalParam, |
313 |
> |
Pos.x(), Pos.y(), Pos.z(), |
314 |
> |
WidthVector.x() -Pos.x(), WidthVector.y() -Pos.y(), WidthVector.z() -Pos.z(), |
315 |
> |
LengthVector.x()-Pos.x(), LengthVector.y()-Pos.y(), LengthVector.z()-Pos.z(), |
316 |
> |
ThickVector.x() -Pos.x(), ThickVector.y() -Pos.y(), ThickVector.z() -Pos.z()); |
317 |
> |
} |
318 |
|
|
319 |
|
|
320 |
+ |
// ### Save .geom ### |
321 |
+ |
|
322 |
+ |
Geom_Tracker->Save("Tracker.geom"); |
323 |
+ |
Geom_ECAL ->Save("Ecal.geom"); |
324 |
+ |
Geom_HCAL ->Save("Hcal.geom"); |
325 |
+ |
Geom_Muon ->Save("Muon.geom"); |
326 |
|
|
327 |
|
} |
328 |
|
|
344 |
|
void |
345 |
|
OpenGLDisplayer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) |
346 |
|
{ |
347 |
< |
|
266 |
< |
edm::Handle<std::vector< SimTrack > > h_SimTracks; |
267 |
< |
iEvent.getByLabel("g4SimHits", h_SimTracks); |
268 |
< |
std::vector< SimTrack > SimTrackColl = *h_SimTracks.product(); |
269 |
< |
|
270 |
< |
edm::Handle<std::vector< SimVertex > > h_Vertex; |
271 |
< |
iEvent.getByLabel("g4SimHits", h_Vertex); |
272 |
< |
std::vector< SimVertex > VertexColl = *h_Vertex.product(); |
347 |
> |
MySimEvent* MyEvent = new MySimEvent; |
348 |
|
|
349 |
|
|
350 |
|
|
357 |
|
TrackingGeometry::DetContainer theDetUnits = theTracker.dets(); |
358 |
|
|
359 |
|
|
360 |
+ |
// Save Data |
361 |
+ |
for(unsigned int i=0;i<SimTrackProducers.size();i++){ |
362 |
+ |
edm::Handle<std::vector< SimTrack > > h_SimTracks; |
363 |
+ |
iEvent.getByLabel(SimTrackProducers[i], h_SimTracks); |
364 |
+ |
std::vector< SimTrack > SimTrackColl = *h_SimTracks.product(); |
365 |
|
|
366 |
< |
|
287 |
< |
// Save the data |
288 |
< |
|
289 |
< |
MySimEvent* MyEvent = new MySimEvent; |
290 |
< |
|
291 |
< |
for ( unsigned int a = 0; a < SimTrackColl.size(); ++a ) { |
366 |
> |
for ( unsigned int a = 0; a < SimTrackColl.size(); ++a ) { |
367 |
|
MySimTrack MysimTrack; |
368 |
|
SimTrack simTrack =SimTrackColl[a]; |
369 |
|
|
377 |
|
MysimTrack.charge =simTrack.charge(); |
378 |
|
|
379 |
|
MyEvent->MySimTrackCollection.push_back(MysimTrack); |
380 |
< |
} |
380 |
> |
} |
381 |
> |
} |
382 |
|
|
383 |
|
|
384 |
< |
for (unsigned int b = 0; b < VertexColl.size(); ++b ) { |
384 |
> |
for(unsigned int i=0;i<SimVertexProducers.size();i++){ |
385 |
> |
edm::Handle<std::vector< SimVertex > > h_Vertex; |
386 |
> |
iEvent.getByLabel(SimVertexProducers[i], h_Vertex); |
387 |
> |
std::vector< SimVertex > VertexColl = *h_Vertex.product(); |
388 |
> |
|
389 |
> |
for (unsigned int b = 0; b < VertexColl.size(); ++b ) { |
390 |
|
MySimVertex MyVertex; |
391 |
|
SimVertex Vertex = VertexColl[b]; |
392 |
|
|
396 |
|
MyVertex.z =Vertex.position().z(); |
397 |
|
|
398 |
|
MyEvent->MySimVertexCollection.push_back(MyVertex); |
399 |
< |
} |
399 |
> |
} |
400 |
> |
} |
401 |
|
|
402 |
< |
for(unsigned int i=0; i<SimHitSubdetectors.size(); i++) |
321 |
< |
{ |
402 |
> |
for(unsigned int i=0;i<SimHitProducers.size();i++){ |
403 |
|
edm::Handle<std::vector< PSimHit > > h_Hits; |
404 |
< |
iEvent.getByLabel("g4SimHits",SimHitSubdetectors[i].c_str(), h_Hits); |
404 |
> |
iEvent.getByLabel(SimHitProducers[i], h_Hits); |
405 |
|
std::vector< PSimHit > Hits = *h_Hits.product(); |
406 |
|
|
407 |
|
for(unsigned int h=0; h<Hits.size(); h++) |
417 |
|
Hit.dEdX = Hits[h].energyLoss(); |
418 |
|
|
419 |
|
MyEvent->MyPSimHitCollection.push_back(Hit); |
339 |
– |
|
420 |
|
} |
421 |
|
} |
422 |
|
|
343 |
– |
edm::Handle<std::vector< reco::Track > > h_Tracks; |
344 |
– |
iEvent.getByLabel("ctfWithMaterialTracks", h_Tracks); |
345 |
– |
std::vector< reco::Track > TrackColl = *h_Tracks.product(); |
423 |
|
|
424 |
< |
for ( unsigned int t = 0; t < TrackColl.size(); ++t ) { |
424 |
> |
for(unsigned int i=0;i<TrackProducers.size();i++){ |
425 |
> |
edm::Handle<std::vector< reco::Track > > h_Tracks; |
426 |
> |
iEvent.getByLabel(TrackProducers[i], h_Tracks); |
427 |
> |
std::vector< reco::Track > TrackColl = *h_Tracks.product(); |
428 |
> |
|
429 |
> |
for ( unsigned int t = 0; t < TrackColl.size(); ++t ) { |
430 |
|
MyRecoTrack MyrecoTrack; |
431 |
|
reco::Track recoTrack =TrackColl[t]; |
432 |
|
|
351 |
– |
// MyrecoTrack.Hits = new MyRecoHit[MyrecoTrack.N]; |
352 |
– |
|
433 |
|
for(unsigned int h=0;h<recoTrack.recHitsSize();h++){ |
434 |
|
TrackingRecHitRef h_it = recoTrack.recHit(h); |
435 |
|
if(!h_it->isValid() )continue; |
444 |
|
hit.DetId = detId.rawId(); |
445 |
|
hit.Charge = -1; |
446 |
|
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()); |
447 |
|
} |
448 |
|
MyEvent->MyRecoTrackCollection.push_back(MyrecoTrack); |
449 |
+ |
} |
450 |
|
} |
451 |
|
|
452 |
|
|
453 |
< |
|
454 |
< |
edm::Handle<EcalRecHitCollection > h_EcalEB_RecHits; |
455 |
< |
iEvent.getByLabel("ecalRecHit","EcalRecHitsEB", h_EcalEB_RecHits); |
456 |
< |
EcalRecHitCollection EcalEB_RecHits = *h_EcalEB_RecHits.product(); |
457 |
< |
|
458 |
< |
for(unsigned int eh=0;eh<EcalEB_RecHits.size();eh++){ |
459 |
< |
MyCaloHit temp_EcalEBHit; |
460 |
< |
temp_EcalEBHit.E = EcalEB_RecHits[eh].energy(); |
461 |
< |
temp_EcalEBHit.t = EcalEB_RecHits[eh].time(); |
462 |
< |
temp_EcalEBHit.DetId = (EcalEB_RecHits[eh].detid()).rawId(); |
463 |
< |
|
464 |
< |
MyEvent->MyEcalCaloHitCollection.push_back(temp_EcalEBHit); |
465 |
< |
} |
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); |
453 |
> |
for(unsigned int i=0;i<EcalRecHitProducers.size();i++){ |
454 |
> |
edm::Handle<EcalRecHitCollection > h_Ecal_RecHits; |
455 |
> |
iEvent.getByLabel(EcalRecHitProducers[i], h_Ecal_RecHits); |
456 |
> |
EcalRecHitCollection Ecal_RecHits = *h_Ecal_RecHits.product(); |
457 |
> |
|
458 |
> |
for(unsigned int eh=0;eh<Ecal_RecHits.size();eh++){ |
459 |
> |
MyCaloHit temp_EcalHit; |
460 |
> |
temp_EcalHit.E = Ecal_RecHits[eh].energy(); |
461 |
> |
temp_EcalHit.t = Ecal_RecHits[eh].time(); |
462 |
> |
temp_EcalHit.DetId = (Ecal_RecHits[eh].detid()).rawId(); |
463 |
> |
|
464 |
> |
MyEvent->MyEcalCaloHitCollection.push_back(temp_EcalHit); |
465 |
> |
} |
466 |
|
} |
467 |
|
|
468 |
|
|
469 |
+ |
for(unsigned int i=0;i<HcalHBHERecHitProducers.size();i++){ |
470 |
+ |
edm::Handle<HBHERecHitCollection > h_HcalHBHE_RecHits; |
471 |
+ |
iEvent.getByLabel(HcalHBHERecHitProducers[i], h_HcalHBHE_RecHits); |
472 |
+ |
HBHERecHitCollection HcalHBHE_RecHits = *h_HcalHBHE_RecHits.product(); |
473 |
|
|
474 |
< |
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++){ |
474 |
> |
for(unsigned int hh=0;hh<HcalHBHE_RecHits.size();hh++){ |
475 |
|
MyCaloHit temp_HcalHBHEHit; |
476 |
|
temp_HcalHBHEHit.E = HcalHBHE_RecHits[hh].energy(); |
477 |
|
temp_HcalHBHEHit.t = HcalHBHE_RecHits[hh].time(); |
478 |
|
temp_HcalHBHEHit.DetId = (HcalHBHE_RecHits[hh].detid()).rawId(); |
479 |
|
|
480 |
|
MyEvent->MyHcalCaloHitCollection.push_back(temp_HcalHBHEHit); |
481 |
+ |
} |
482 |
|
} |
483 |
|
|
484 |
|
|
485 |
< |
edm::Handle<HORecHitCollection > h_HcalHO_RecHits; |
486 |
< |
iEvent.getByLabel("horeco", h_HcalHO_RecHits); |
487 |
< |
HORecHitCollection HcalHO_RecHits = *h_HcalHO_RecHits.product(); |
485 |
> |
for(unsigned int i=0;i<HcalHORecHitProducers.size();i++){ |
486 |
> |
edm::Handle<HORecHitCollection > h_HcalHO_RecHits; |
487 |
> |
iEvent.getByLabel(HcalHORecHitProducers[i], h_HcalHO_RecHits); |
488 |
> |
HORecHitCollection HcalHO_RecHits = *h_HcalHO_RecHits.product(); |
489 |
|
|
490 |
< |
for(unsigned int hh=0;hh<HcalHO_RecHits.size();hh++){ |
490 |
> |
for(unsigned int hh=0;hh<HcalHO_RecHits.size();hh++){ |
491 |
|
MyCaloHit temp_HcalHOHit; |
492 |
|
temp_HcalHOHit.E = HcalHO_RecHits[hh].energy(); |
493 |
|
temp_HcalHOHit.t = HcalHO_RecHits[hh].time(); |
494 |
|
temp_HcalHOHit.DetId = (HcalHO_RecHits[hh].detid()).rawId(); |
495 |
|
|
496 |
|
MyEvent->MyHcalCaloHitCollection.push_back(temp_HcalHOHit); |
497 |
+ |
} |
498 |
|
} |
499 |
|
|
446 |
– |
edm::Handle<HFRecHitCollection > h_HcalHF_RecHits; |
447 |
– |
iEvent.getByLabel("hfreco", h_HcalHF_RecHits); |
448 |
– |
HFRecHitCollection HcalHF_RecHits = *h_HcalHF_RecHits.product(); |
500 |
|
|
501 |
< |
for(unsigned int hh=0;hh<HcalHF_RecHits.size();hh++){ |
501 |
> |
for(unsigned int i=0;i<HcalHFRecHitProducers.size();i++){ |
502 |
> |
edm::Handle<HFRecHitCollection > h_HcalHF_RecHits; |
503 |
> |
iEvent.getByLabel(HcalHFRecHitProducers[i], h_HcalHF_RecHits); |
504 |
> |
HFRecHitCollection HcalHF_RecHits = *h_HcalHF_RecHits.product(); |
505 |
> |
|
506 |
> |
for(unsigned int hh=0;hh<HcalHF_RecHits.size();hh++){ |
507 |
|
MyCaloHit temp_HcalHFHit; |
508 |
|
temp_HcalHFHit.E = HcalHF_RecHits[hh].energy(); |
509 |
|
temp_HcalHFHit.t = HcalHF_RecHits[hh].time(); |
510 |
|
temp_HcalHFHit.DetId = (HcalHF_RecHits[hh].detid()).rawId(); |
511 |
|
|
512 |
|
MyEvent->MyHcalCaloHitCollection.push_back(temp_HcalHFHit); |
513 |
+ |
} |
514 |
|
} |
515 |
|
|
459 |
– |
|
460 |
– |
|
461 |
– |
|
462 |
– |
|
463 |
– |
|
464 |
– |
|
465 |
– |
|
466 |
– |
|
467 |
– |
|
468 |
– |
|
516 |
|
MyEvents->Events.push_back(MyEvent); |
470 |
– |
|
517 |
|
} |
518 |
|
|
519 |
|
|