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.10 by querten, Fri Mar 21 19:40:46 2008 UTC vs.
Revision 1.18 by querten, Fri Apr 18 11:31:21 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  
61  
62 + #include "DataFormats/CaloRecHit/interface/CaloRecHit.h"
63 + #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
64 + #include "DataFormats/HcalRecHit/interface/HcalRecHitCollections.h"
65 +
66   #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
67   #include "SimDataFormats/TrackingHit/interface/PSimHit.h"
68   #include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h"
# Line 98 | Line 105 | class OpenGLDisplayer : public edm::EDAn
105  
106  
107        MySimEvents* MyEvents;
108 <      Geometry*    Geom;
109 <
108 >      Geometry*    Geom_Tracker;
109 >      Geometry*    Geom_ECAL;
110 >      Geometry*    Geom_HCAL;
111 >      Geometry*    Geom_Muon;
112  
104      std::vector<std::string> SimHitSubdetectors;
113  
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   };
# Line 114 | Line 134 | class OpenGLDisplayer : public edm::EDAn
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  
119    OutputFile          = iConfig.getParameter<std::string >("OutputFile");
149   }
150  
151  
# Line 131 | Line 160 | OpenGLDisplayer::beginJob(const edm::Eve
160     DetId  Detid;
161     int    SubDet;
162  
163 <   MyEvents = new MySimEvents();
164 <   Geom     = new Geometry();
163 >   MyEvents     = new MySimEvents();
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 );
# Line 173 | Line 208 | OpenGLDisplayer::beginJob(const edm::Eve
208  
209        GlobalVector Pos =  GlobalVector(DetUnit->position().basicVector());
210  
211 <      Geom->Add_TrackerDet(Detid.rawId(), TrapezoidalParam,
211 >      Geom_Tracker->Add_TrackerDet(Detid.rawId(), TrapezoidalParam,
212             Pos.x(),                  Pos.y(),                  Pos.z(),
213             WidthVector.x() -Pos.x(), WidthVector.y() -Pos.y(), WidthVector.z() -Pos.z(),
214             LengthVector.x()-Pos.x(), LengthVector.y()-Pos.y(), LengthVector.z()-Pos.z(),
# Line 193 | Line 228 | OpenGLDisplayer::beginJob(const edm::Eve
228     {
229        Detid  = CaloDets[i];
230        SubDet = Detid.subdetId();
196    
197      if(Detid.det()!=DetId::Ecal) continue;
231  
232 <      //EcalBarrel=1, EcalEndcap=2, EcalPreshower=3, EcalTriggerTower=4, EcalLaserPnDiode=5
233 <      if(SubDet!=EcalBarrel)continue;
232 >      Geometry* Geom_temp = NULL;
233 >      if(Detid.det()==DetId::Ecal){
234 >        Geom_temp = Geom_ECAL;
235 >
236 >        if(SubDet<1 || SubDet>3){
237 >                printf("Don't Save EcalTriggerTower or EcalLaserPnDiode\n");
238 >                continue;
239 >        }
240 >      }else if(Detid.det()==DetId::Hcal){
241 >        Geom_temp = Geom_HCAL;
242 >
243 >        if(SubDet<1 || SubDet>4){
244 >                printf("Don't Save HcalEmpty, HcalTriggerTower, HcalOther\n");
245 >                continue;
246 >        }
247 >      }else{
248 >        continue;
249 >      }
250  
251        const CaloCellGeometry* CellGeom = CaloGeom->getGeometry(Detid);
252        GlobalPoint CellPos =  CellGeom->getPosition();
204
253        const CaloCellGeometry::CornersVec CellCorners =  CellGeom->getCorners();
254 <                
255 <      printf("Det = %i Subdet = %i --> %6.2f %6.2f %6.2f - %i\n",  Detid.det(), SubDet, CellPos.x(), CellPos.y(), CellPos.z(), CellCorners.size());
254 >
255 >      Geom_temp->Add_CaloDet(Detid.rawId(),
256 >                        CellPos.x()         ,   CellPos.y()         ,   CellPos.z(),
257 >                        CellCorners[0].x()  ,   CellCorners[0].y()  ,   CellCorners[0].z()  ,
258 >                        CellCorners[1].x()  ,   CellCorners[1].y()  ,   CellCorners[1].z()  ,
259 >                        CellCorners[2].x()  ,   CellCorners[2].y()  ,   CellCorners[2].z()  ,
260 >                        CellCorners[3].x()  ,   CellCorners[3].y()  ,   CellCorners[3].z()  ,
261 >                        CellCorners[4].x()  ,   CellCorners[4].y()  ,   CellCorners[4].z()  ,
262 >                        CellCorners[5].x()  ,   CellCorners[5].y()  ,   CellCorners[5].z()  ,
263 >                        CellCorners[6].x()  ,   CellCorners[6].y()  ,   CellCorners[6].z()  ,
264 >                        CellCorners[7].x()  ,   CellCorners[7].y()  ,   CellCorners[7].z()  );
265 >   }
266 >
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 <   Geom->Save("Tracker.geom");    
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  
# Line 218 | Line 331 | void
331   OpenGLDisplayer::endJob() {
332    
333     MyEvents->Save((char*) OutputFile.c_str());
334 <   MyEvents->Load((char*) OutputFile.c_str());
334 > //   MyEvents->Load((char*) OutputFile.c_str());
335   }
336  
337  
# Line 231 | Line 344 | OpenGLDisplayer::endJob() {
344   void
345   OpenGLDisplayer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
346   {
347 <
235 <        edm::Handle<std::vector< SimTrack > > h_SimTracks;
236 <        iEvent.getByLabel("g4SimHits", h_SimTracks);
237 <        std::vector< SimTrack > SimTrackColl = *h_SimTracks.product();
238 <
239 <        edm::Handle<std::vector< SimVertex > > h_Vertex;
240 <        iEvent.getByLabel("g4SimHits", h_Vertex);
241 <        std::vector< SimVertex > VertexColl = *h_Vertex.product();
347 >        MySimEvent* MyEvent = new MySimEvent;
348  
349  
350  
# Line 251 | Line 357 | OpenGLDisplayer::analyze(const edm::Even
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 <
256 <        // Save the data
257 <
258 <        MySimEvent* MyEvent = new MySimEvent;
259 <  
260 <        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  
# Line 271 | Line 377 | OpenGLDisplayer::analyze(const edm::Even
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  
# Line 284 | Line 396 | OpenGLDisplayer::analyze(const edm::Even
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++)
290 <        {
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++)
# Line 305 | Line 417 | OpenGLDisplayer::analyze(const edm::Even
417                  Hit.dEdX        = Hits[h].energyLoss();
418  
419                  MyEvent->MyPSimHitCollection.push_back(Hit);
308
420             }
421          }
422  
312        edm::Handle<std::vector< reco::Track > > h_Tracks;
313        iEvent.getByLabel("ctfWithMaterialTracks", h_Tracks);
314        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  
320 //                MyrecoTrack.Hits = new MyRecoHit[MyrecoTrack.N];
321
433                  for(unsigned int h=0;h<recoTrack.recHitsSize();h++){
434                        TrackingRecHitRef h_it     = recoTrack.recHit(h);
435                        if(!h_it->isValid() )continue;
# Line 333 | Line 444 | OpenGLDisplayer::analyze(const edm::Even
444                        hit.DetId  = detId.rawId();
445                        hit.Charge = -1;
446                        MyrecoTrack.Hits.push_back(hit);
336
337
338 //                    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 +        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 +           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  
343        MyEvents->Events.push_back(MyEvent);  
484  
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++){
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 +
500 +
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 +
516 +        MyEvents->Events.push_back(MyEvent);  
517   }
518  
519  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines