ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/FastOpenGlDisplayer/src/OpenGLDisplayer.cc
(Generate patch)

Comparing UserCode/FastOpenGlDisplayer/src/OpenGLDisplayer.cc (file contents):
Revision 1.11 by querten, Sun Mar 23 09:45:19 2008 UTC vs.
Revision 1.19 by querten, Fri Apr 18 13:08:34 2008 UTC

# Line 54 | Line 54
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 + #include "Geometry/CSCGeometry/interface/CSCGeometry.h"
61 + #include "Geometry/RPCGeometry/interface/RPCGeometry.h"
62  
63  
64 +
65 + #include "DataFormats/CaloRecHit/interface/CaloRecHit.h"
66 + #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
67 + #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
68 +
69   #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
70   #include "SimDataFormats/TrackingHit/interface/PSimHit.h"
71   #include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h"
# Line 101 | Line 111 | class OpenGLDisplayer : public edm::EDAn
111        Geometry*    Geom_Tracker;
112        Geometry*    Geom_ECAL;
113        Geometry*    Geom_HCAL;
114 +      Geometry*    Geom_Muon;
115  
116  
106      std::vector<std::string> SimHitSubdetectors;
107
117        std::string              OutputFile;
118  
119 +      std::vector<InputTag> SimTrackProducers;
120 +      std::vector<InputTag> SimVertexProducers;
121 +      std::vector<InputTag> SimHitProducers;
122 +
123 +      std::vector<InputTag> TrackProducers;
124 +      std::vector<InputTag> EcalRecHitProducers;
125 +      std::vector<InputTag> HcalHBHERecHitProducers;
126 +      std::vector<InputTag> HcalHORecHitProducers;
127 +      std::vector<InputTag> HcalHFRecHitProducers;
128 +
129 +
130 +
131  
132        // ----------member data ---------------------------
133   };
# Line 116 | Line 137 | class OpenGLDisplayer : public edm::EDAn
137   //
138   OpenGLDisplayer::OpenGLDisplayer(const edm::ParameterSet& iConfig)
139   {
140 <    SimHitSubdetectors  = iConfig.getParameter<std::vector<std::string> >("SimHitSubdetectors");
140 >    OutputFile              = iConfig.getParameter<std::string >("OutputFile");
141 >
142 >    SimTrackProducers       = iConfig.getParameter<std::vector<InputTag> >("SimTrackProducers");
143 >    SimVertexProducers      = iConfig.getParameter<std::vector<InputTag> >("SimVertexProducers");
144 >    SimHitProducers         = iConfig.getParameter<std::vector<InputTag> >("SimHitProducers");
145 >
146 >    TrackProducers          = iConfig.getParameter<std::vector<InputTag> >("TrackProducers");
147 >    EcalRecHitProducers     = iConfig.getParameter<std::vector<InputTag> >("EcalRecHitProducers");
148 >    HcalHBHERecHitProducers = iConfig.getParameter<std::vector<InputTag> >("HcalHBHERecHitProducers");
149 >    HcalHORecHitProducers   = iConfig.getParameter<std::vector<InputTag> >("HcalHORecHitProducers");
150 >    HcalHFRecHitProducers   = iConfig.getParameter<std::vector<InputTag> >("HcalHFRecHitProducers");
151  
121    OutputFile          = iConfig.getParameter<std::string >("OutputFile");
152   }
153  
154  
# Line 137 | Line 167 | OpenGLDisplayer::beginJob(const edm::Eve
167     Geom_Tracker = new Geometry();
168     Geom_ECAL    = new Geometry();
169     Geom_HCAL    = new Geometry();
170 +   Geom_Muon    = new Geometry();
171 +
172  
173 +   // ### TRACKER GEOMETRY ###
174  
175     edm::ESHandle<TrackerGeometry> tkGeom;
176     iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
# Line 234 | Line 267 | OpenGLDisplayer::beginJob(const edm::Eve
267                          CellCorners[7].x()  ,   CellCorners[7].y()  ,   CellCorners[7].z()  );
268     }
269  
270 +   // ### MUON GEOMETRY ###
271 +
272 +   edm::ESHandle<DTGeometry> DtGeom;
273 +   iSetup.get<MuonGeometryRecord>().get( DtGeom );
274 +   const vector<GeomDet*> DtDets = DtGeom->dets();
275 +
276 +   edm::ESHandle<CSCGeometry> CscGeom;
277 +   iSetup.get<MuonGeometryRecord>().get( CscGeom );
278 +   const vector<GeomDet*> CscDets = CscGeom->dets();
279 +
280 +   edm::ESHandle<RPCGeometry> RpcGeom;
281 +   iSetup.get<MuonGeometryRecord>().get( RpcGeom );
282 +   const vector<GeomDet*> RpcDets = RpcGeom->dets();
283 +
284 +   vector<GeomDet*> MuonDets;
285 +   for(unsigned int i=0;i<DtDets.size() ;i++){MuonDets.push_back(DtDets [i]);}
286 +   for(unsigned int i=0;i<CscDets.size();i++){MuonDets.push_back(CscDets[i]);}
287 +   for(unsigned int i=0;i<RpcDets.size();i++){MuonDets.push_back(RpcDets[i]);}
288 +
289 +
290 +   for(unsigned int i=0;i<MuonDets.size();i++)
291 +   {
292 +      Detid  = DetId(MuonDets[i]->geographicalId());
293 +      SubDet = Detid.subdetId();
294 +
295 +      GeomDet* DetUnit = MuonDets[i];
296 +      if(!DetUnit)continue;
297 +      const BoundPlane plane = DetUnit->surface();
298 +      const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
299 +      const RectangularPlaneBounds* rectangularBounds( dynamic_cast<const RectangularPlaneBounds*>(&(plane.bounds())));
300 +
301 +      float width            = 0;
302 +      float length           = 0;
303 +      float thickness        = 0;
304 +      float TrapezoidalParam = 0;
305 +
306 +      if(trapezoidalBounds)
307 +      {
308 +         std::vector<float> const & parameters = (*trapezoidalBounds).parameters();
309 +         width            = parameters[0]*2;
310 +         length           = parameters[3]*2;
311 +         thickness        =  (*trapezoidalBounds).thickness();
312 +         TrapezoidalParam = parameters[1]/parameters[0];
313 +      }else if(rectangularBounds){
314 +         width            = DetUnit->surface().bounds().width();
315 +         length           = DetUnit->surface().bounds().length();
316 +         thickness        = DetUnit->surface().bounds().thickness();
317 +         TrapezoidalParam = 1;
318 +      }
319 +
320 +      Surface::GlobalPoint WidthVector  = plane.toGlobal( LocalPoint(width/2, 0, 0) );
321 +      Surface::GlobalPoint LengthVector = plane.toGlobal( LocalPoint(0, length/2, 0) );
322 +      Surface::GlobalPoint ThickVector  = plane.toGlobal( LocalPoint(0, 0, thickness/2) );
323 +
324 +      GlobalVector Pos =  GlobalVector(DetUnit->position().basicVector());
325 +
326 +      Geom_Muon->Add_TrackerDet(Detid.rawId(), TrapezoidalParam,
327 +           Pos.x(),                  Pos.y(),                  Pos.z(),
328 +           WidthVector.x() -Pos.x(), WidthVector.y() -Pos.y(), WidthVector.z() -Pos.z(),
329 +           LengthVector.x()-Pos.x(), LengthVector.y()-Pos.y(), LengthVector.z()-Pos.z(),
330 +           ThickVector.x() -Pos.x(), ThickVector.y() -Pos.y(), ThickVector.z() -Pos.z());
331 +   }
332 +
333 +
334 +   // ### Save .geom ###
335 +
336     Geom_Tracker->Save("Tracker.geom");    
337 <   Geom_ECAL->Save("ECAL.geom");
338 <   Geom_HCAL->Save("HCAL.geom");
337 >   Geom_ECAL   ->Save("Ecal.geom");
338 >   Geom_HCAL   ->Save("Hcal.geom");
339  
340 +   printf("RPC = %i\n",Geom_Muon   ->Det_Muon_RPC.size());
341  
342 +   Geom_Muon   ->Save("Muon.geom");
343  
344   }
345  
# Line 247 | Line 348 | void
348   OpenGLDisplayer::endJob() {
349    
350     MyEvents->Save((char*) OutputFile.c_str());
351 <   MyEvents->Load((char*) OutputFile.c_str());
351 > //   MyEvents->Load((char*) OutputFile.c_str());
352   }
353  
354  
# Line 260 | Line 361 | OpenGLDisplayer::endJob() {
361   void
362   OpenGLDisplayer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
363   {
364 <
264 <        edm::Handle<std::vector< SimTrack > > h_SimTracks;
265 <        iEvent.getByLabel("g4SimHits", h_SimTracks);
266 <        std::vector< SimTrack > SimTrackColl = *h_SimTracks.product();
267 <
268 <        edm::Handle<std::vector< SimVertex > > h_Vertex;
269 <        iEvent.getByLabel("g4SimHits", h_Vertex);
270 <        std::vector< SimVertex > VertexColl = *h_Vertex.product();
364 >        MySimEvent* MyEvent = new MySimEvent;
365  
366  
367  
# Line 280 | Line 374 | OpenGLDisplayer::analyze(const edm::Even
374          TrackingGeometry::DetContainer theDetUnits = theTracker.dets();
375  
376  
377 +        // Save Data
378 +        for(unsigned int i=0;i<SimTrackProducers.size();i++){
379 +           edm::Handle<std::vector< SimTrack > > h_SimTracks;
380 +           iEvent.getByLabel(SimTrackProducers[i], h_SimTracks);
381 +           std::vector< SimTrack > SimTrackColl = *h_SimTracks.product();
382  
383 <
285 <        // Save the data
286 <
287 <        MySimEvent* MyEvent = new MySimEvent;
288 <  
289 <        for ( unsigned int a = 0; a < SimTrackColl.size(); ++a ) {
383 >           for ( unsigned int a = 0; a < SimTrackColl.size(); ++a ) {
384                  MySimTrack  MysimTrack;
385                  SimTrack    simTrack    =SimTrackColl[a];
386  
# Line 300 | Line 394 | OpenGLDisplayer::analyze(const edm::Even
394                  MysimTrack.charge       =simTrack.charge();
395  
396                  MyEvent->MySimTrackCollection.push_back(MysimTrack);
397 <        }
397 >           }      
398 >        }
399 >
400  
401 +        for(unsigned int i=0;i<SimVertexProducers.size();i++){
402 +           edm::Handle<std::vector< SimVertex > > h_Vertex;
403 +           iEvent.getByLabel(SimVertexProducers[i], h_Vertex);
404 +           std::vector< SimVertex > VertexColl = *h_Vertex.product();
405  
406 <        for (unsigned int b = 0; b < VertexColl.size(); ++b ) {
406 >           for (unsigned int b = 0; b < VertexColl.size(); ++b ) {
407                  MySimVertex     MyVertex;
408                  SimVertex       Vertex  =  VertexColl[b];
409  
# Line 313 | Line 413 | OpenGLDisplayer::analyze(const edm::Even
413                  MyVertex.z              =Vertex.position().z();
414  
415                  MyEvent->MySimVertexCollection.push_back(MyVertex);
416 <        }
416 >           }
417 >        }
418  
419 <        for(unsigned int i=0; i<SimHitSubdetectors.size(); i++)
319 <        {
419 >        for(unsigned int i=0;i<SimHitProducers.size();i++){
420             edm::Handle<std::vector< PSimHit > > h_Hits;
421 <           iEvent.getByLabel("g4SimHits",SimHitSubdetectors[i].c_str(), h_Hits);
421 >           iEvent.getByLabel(SimHitProducers[i], h_Hits);
422             std::vector< PSimHit > Hits = *h_Hits.product();
423  
424             for(unsigned int h=0; h<Hits.size(); h++)
# Line 334 | Line 434 | OpenGLDisplayer::analyze(const edm::Even
434                  Hit.dEdX        = Hits[h].energyLoss();
435  
436                  MyEvent->MyPSimHitCollection.push_back(Hit);
337
437             }
438          }
439  
341        edm::Handle<std::vector< reco::Track > > h_Tracks;
342        iEvent.getByLabel("ctfWithMaterialTracks", h_Tracks);
343        std::vector< reco::Track > TrackColl = *h_Tracks.product();
440  
441 <        for ( unsigned int t = 0; t < TrackColl.size(); ++t ) {
441 >        for(unsigned int i=0;i<TrackProducers.size();i++){
442 >           edm::Handle<std::vector< reco::Track > > h_Tracks;
443 >           iEvent.getByLabel(TrackProducers[i], h_Tracks);
444 >           std::vector< reco::Track > TrackColl = *h_Tracks.product();
445 >
446 >           for ( unsigned int t = 0; t < TrackColl.size(); ++t ) {
447                  MyRecoTrack  MyrecoTrack;
448                  reco::Track  recoTrack  =TrackColl[t];
449  
349 //                MyrecoTrack.Hits = new MyRecoHit[MyrecoTrack.N];
350
450                  for(unsigned int h=0;h<recoTrack.recHitsSize();h++){
451                        TrackingRecHitRef h_it     = recoTrack.recHit(h);
452                        if(!h_it->isValid() )continue;
# Line 362 | Line 461 | OpenGLDisplayer::analyze(const edm::Even
461                        hit.DetId  = detId.rawId();
462                        hit.Charge = -1;
463                        MyrecoTrack.Hits.push_back(hit);
365
366
367 //                    printf("%8.2f %8.2f %8.2f\n",theDet->surface().toGlobal(localPos).x(),theDet->surface().toGlobal(localPos).y(),theDet->surface().toGlobal(localPos).z());
464                  }
465                  MyEvent->MyRecoTrackCollection.push_back(MyrecoTrack);
466 +           }
467 +        }
468 +
469 +
470 +        for(unsigned int i=0;i<EcalRecHitProducers.size();i++){
471 +           edm::Handle<EcalRecHitCollection > h_Ecal_RecHits;
472 +           iEvent.getByLabel(EcalRecHitProducers[i], h_Ecal_RecHits);
473 +           EcalRecHitCollection Ecal_RecHits = *h_Ecal_RecHits.product();
474 +
475 +           for(unsigned int eh=0;eh<Ecal_RecHits.size();eh++){
476 +                MyCaloHit temp_EcalHit;
477 +                temp_EcalHit.E     = Ecal_RecHits[eh].energy();
478 +                temp_EcalHit.t     = Ecal_RecHits[eh].time();
479 +                temp_EcalHit.DetId = (Ecal_RecHits[eh].detid()).rawId();
480 +        
481 +                MyEvent->MyEcalCaloHitCollection.push_back(temp_EcalHit);
482 +           }
483 +        }
484 +
485 +
486 +        for(unsigned int i=0;i<HcalHBHERecHitProducers.size();i++){
487 +           edm::Handle<HBHERecHitCollection > h_HcalHBHE_RecHits;
488 +           iEvent.getByLabel(HcalHBHERecHitProducers[i], h_HcalHBHE_RecHits);
489 +           HBHERecHitCollection HcalHBHE_RecHits = *h_HcalHBHE_RecHits.product();
490 +
491 +           for(unsigned int hh=0;hh<HcalHBHE_RecHits.size();hh++){
492 +                MyCaloHit temp_HcalHBHEHit;
493 +                temp_HcalHBHEHit.E      = HcalHBHE_RecHits[hh].energy();
494 +                temp_HcalHBHEHit.t      = HcalHBHE_RecHits[hh].time();
495 +                temp_HcalHBHEHit.DetId = (HcalHBHE_RecHits[hh].detid()).rawId();
496 +
497 +                MyEvent->MyHcalCaloHitCollection.push_back(temp_HcalHBHEHit);
498 +           }
499          }
500  
372        MyEvents->Events.push_back(MyEvent);  
501  
502 +        for(unsigned int i=0;i<HcalHORecHitProducers.size();i++){
503 +           edm::Handle<HORecHitCollection > h_HcalHO_RecHits;
504 +           iEvent.getByLabel(HcalHORecHitProducers[i], h_HcalHO_RecHits);
505 +           HORecHitCollection HcalHO_RecHits = *h_HcalHO_RecHits.product();
506 +
507 +           for(unsigned int hh=0;hh<HcalHO_RecHits.size();hh++){
508 +                MyCaloHit temp_HcalHOHit;
509 +                temp_HcalHOHit.E      = HcalHO_RecHits[hh].energy();
510 +                temp_HcalHOHit.t      = HcalHO_RecHits[hh].time();
511 +                temp_HcalHOHit.DetId = (HcalHO_RecHits[hh].detid()).rawId();
512 +
513 +                MyEvent->MyHcalCaloHitCollection.push_back(temp_HcalHOHit);
514 +           }
515 +        }
516 +
517 +
518 +        for(unsigned int i=0;i<HcalHFRecHitProducers.size();i++){
519 +           edm::Handle<HFRecHitCollection > h_HcalHF_RecHits;
520 +           iEvent.getByLabel(HcalHFRecHitProducers[i], h_HcalHF_RecHits);
521 +           HFRecHitCollection HcalHF_RecHits = *h_HcalHF_RecHits.product();
522 +
523 +           for(unsigned int hh=0;hh<HcalHF_RecHits.size();hh++){
524 +                MyCaloHit temp_HcalHFHit;
525 +                temp_HcalHFHit.E      = HcalHF_RecHits[hh].energy();
526 +                temp_HcalHFHit.t      = HcalHF_RecHits[hh].time();
527 +                temp_HcalHFHit.DetId = (HcalHF_RecHits[hh].detid()).rawId();
528 +
529 +                MyEvent->MyHcalCaloHitCollection.push_back(temp_HcalHFHit);
530 +           }
531 +        }
532 +
533 +        MyEvents->Events.push_back(MyEvent);  
534   }
535  
536  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines