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.9 by querten, Fri Mar 21 15:11:29 2008 UTC vs.
Revision 1.14 by roberfro, Thu Apr 3 12:18:29 2008 UTC

# Line 54 | Line 54
54   #include "Geometry/CaloGeometry/interface/CaloCellGeometry.h"
55   #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
56  
57 <
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"
# Line 98 | Line 100 | class OpenGLDisplayer : public edm::EDAn
100  
101  
102        MySimEvents* MyEvents;
103 <      Geometry*    Geom;
103 >      Geometry*    Geom_Tracker;
104 >      Geometry*    Geom_ECAL;
105 >      Geometry*    Geom_HCAL;
106  
107  
108        std::vector<std::string> SimHitSubdetectors;
109  
110        std::string              OutputFile;
111 +      std::string              trackProducer;
112  
113  
114        // ----------member data ---------------------------
# Line 117 | Line 122 | OpenGLDisplayer::OpenGLDisplayer(const e
122      SimHitSubdetectors  = iConfig.getParameter<std::vector<std::string> >("SimHitSubdetectors");
123  
124      OutputFile          = iConfig.getParameter<std::string >("OutputFile");
125 +
126 +    trackProducer = iConfig.getParameter<std::string >("TrackProducer");
127   }
128  
129  
# Line 131 | Line 138 | OpenGLDisplayer::beginJob(const edm::Eve
138     DetId  Detid;
139     int    SubDet;
140  
141 <   MyEvents = new MySimEvents();
142 <   Geom     = new Geometry();
141 >   MyEvents     = new MySimEvents();
142 >   Geom_Tracker = new Geometry();
143 >   Geom_ECAL    = new Geometry();
144 >   Geom_HCAL    = new Geometry();
145 >
146  
147     edm::ESHandle<TrackerGeometry> tkGeom;
148     iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
# Line 173 | Line 183 | OpenGLDisplayer::beginJob(const edm::Eve
183  
184        GlobalVector Pos =  GlobalVector(DetUnit->position().basicVector());
185  
186 <      Geom->Add_TrackerDet(Detid.rawId(), TrapezoidalParam,
186 >      Geom_Tracker->Add_TrackerDet(Detid.rawId(), TrapezoidalParam,
187             Pos.x(),                  Pos.y(),                  Pos.z(),
188             WidthVector.x() -Pos.x(), WidthVector.y() -Pos.y(), WidthVector.z() -Pos.z(),
189             LengthVector.x()-Pos.x(), LengthVector.y()-Pos.y(), LengthVector.z()-Pos.z(),
# Line 193 | Line 203 | OpenGLDisplayer::beginJob(const edm::Eve
203     {
204        Detid  = CaloDets[i];
205        SubDet = Detid.subdetId();
196    
197       if(! (Detid.det()==DetId::Ecal||Detid.det()==DetId::Hcal)) continue;
206  
207 <      //EcalBarrel=1, EcalEndcap=2, EcalPreshower=3, EcalTriggerTower=4, EcalLaserPnDiode=5
208 < //      if(SubDet!=EcalBarrel)continue;
207 >      Geometry* Geom_temp = NULL;
208 >      if(Detid.det()==DetId::Ecal){
209 >        Geom_temp = Geom_ECAL;
210 >
211 >        if(SubDet<1 || SubDet>3){
212 >                printf("Don't Save EcalTriggerTower or EcalLaserPnDiode\n");
213 >                continue;
214 >        }
215 >      }else if(Detid.det()==DetId::Hcal){
216 >        Geom_temp = Geom_HCAL;
217 >
218 >        if(SubDet<1 || SubDet>4){
219 >                printf("Don't Save HcalEmpty, HcalTriggerTower, HcalOther\n");
220 >                continue;
221 >        }
222 >      }else{
223 >        continue;
224 >      }
225  
226        const CaloCellGeometry* CellGeom = CaloGeom->getGeometry(Detid);
227        GlobalPoint CellPos =  CellGeom->getPosition();
204
228        const CaloCellGeometry::CornersVec CellCorners =  CellGeom->getCorners();
229  
230 <      float Coord[24];
231 <      for(unsigned int i=0;i<8;i++){
232 <         Coord[i*3+0] = CellCorners[i].x();
233 <         Coord[i*3+1] = CellCorners[i].y();
234 <         Coord[i*3+2] = CellCorners[i].z();
235 <      }
236 <
237 <      Geom->Add_CaloDet(Detid.rawId(),
238 <                        CellPos.x(),   CellPos.y(),   CellPos.z(),
239 <                        Coord[0 ]  ,   Coord[1 ]  ,   Coord[2 ]  ,
217 <                        Coord[3 ]  ,   Coord[4 ]  ,   Coord[5 ]  ,
218 <                        Coord[6 ]  ,   Coord[7 ]  ,   Coord[8 ]  ,
219 <                        Coord[9 ]  ,   Coord[10]  ,   Coord[11]  ,
220 <                        Coord[12]  ,   Coord[13]  ,   Coord[14]  ,
221 <                        Coord[15]  ,   Coord[16]  ,   Coord[17]  ,
222 <                        Coord[18]  ,   Coord[19]  ,   Coord[20]  ,
223 <                        Coord[21]  ,   Coord[22]  ,   Coord[23]  );
224 <                        
225 <      printf("Det = %i Subdet = %i --> %6.2f %6.2f %6.2f - %i\n",  Detid.det(), SubDet, CellPos.x(), CellPos.y(), CellPos.z(), CellCorners.size());
230 >      Geom_temp->Add_CaloDet(Detid.rawId(),
231 >                        CellPos.x()         ,   CellPos.y()         ,   CellPos.z(),
232 >                        CellCorners[0].x()  ,   CellCorners[0].y()  ,   CellCorners[0].z()  ,
233 >                        CellCorners[1].x()  ,   CellCorners[1].y()  ,   CellCorners[1].z()  ,
234 >                        CellCorners[2].x()  ,   CellCorners[2].y()  ,   CellCorners[2].z()  ,
235 >                        CellCorners[3].x()  ,   CellCorners[3].y()  ,   CellCorners[3].z()  ,
236 >                        CellCorners[4].x()  ,   CellCorners[4].y()  ,   CellCorners[4].z()  ,
237 >                        CellCorners[5].x()  ,   CellCorners[5].y()  ,   CellCorners[5].z()  ,
238 >                        CellCorners[6].x()  ,   CellCorners[6].y()  ,   CellCorners[6].z()  ,
239 >                        CellCorners[7].x()  ,   CellCorners[7].y()  ,   CellCorners[7].z()  );
240     }
241  
242 +   Geom_Tracker->Save("Tracker.geom");    
243 +   Geom_ECAL->Save("ECAL.geom");
244 +   Geom_HCAL->Save("HCAL.geom");
245  
229   Geom->Save("Tracker.geom");    
246  
247  
248   }
# Line 236 | Line 252 | void
252   OpenGLDisplayer::endJob() {
253    
254     MyEvents->Save((char*) OutputFile.c_str());
255 <   MyEvents->Load((char*) OutputFile.c_str());
255 > //   MyEvents->Load((char*) OutputFile.c_str());
256   }
257  
258  
# Line 327 | Line 343 | OpenGLDisplayer::analyze(const edm::Even
343             }
344          }
345  
346 +        // access primary tracks
347          edm::Handle<std::vector< reco::Track > > h_Tracks;
348 <        iEvent.getByLabel("ctfWithMaterialTracks", h_Tracks);
348 >        iEvent.getByLabel(trackProducer, h_Tracks);
349          std::vector< reco::Track > TrackColl = *h_Tracks.product();
350  
351          for ( unsigned int t = 0; t < TrackColl.size(); ++t ) {
# Line 358 | Line 375 | OpenGLDisplayer::analyze(const edm::Even
375                  MyEvent->MyRecoTrackCollection.push_back(MyrecoTrack);
376          }
377  
378 +
379 +
380 +        edm::Handle<EcalRecHitCollection > h_EcalEB_RecHits;
381 +        iEvent.getByLabel("ecalRecHit","EcalRecHitsEB", h_EcalEB_RecHits);
382 +        EcalRecHitCollection EcalEB_RecHits = *h_EcalEB_RecHits.product();
383 +
384 +        for(unsigned int eh=0;eh<EcalEB_RecHits.size();eh++){
385 +                MyCaloHit temp_EcalEBHit;
386 +                temp_EcalEBHit.E     = EcalEB_RecHits[eh].energy();
387 +                temp_EcalEBHit.t     = EcalEB_RecHits[eh].time();
388 +                temp_EcalEBHit.DetId = (EcalEB_RecHits[eh].detid()).rawId();
389 +        
390 +                MyEvent->MyEcalCaloHitCollection.push_back(temp_EcalEBHit);
391 +        }
392 +
393 +
394 +        edm::Handle<EcalRecHitCollection > h_EcalEE_RecHits;
395 +        iEvent.getByLabel("ecalRecHit","EcalRecHitsEE", h_EcalEE_RecHits);
396 +        EcalRecHitCollection EcalEE_RecHits = *h_EcalEE_RecHits.product();
397 +
398 +        for(unsigned int eh=0;eh<EcalEE_RecHits.size();eh++){
399 +                MyCaloHit temp_EcalEEHit;
400 +                temp_EcalEEHit.E     = EcalEE_RecHits[eh].energy();
401 +                temp_EcalEEHit.t     = EcalEE_RecHits[eh].time();
402 +                temp_EcalEEHit.DetId = (EcalEE_RecHits[eh].detid()).rawId();
403 +
404 +                MyEvent->MyEcalCaloHitCollection.push_back(temp_EcalEEHit);
405 +        }
406 +
407 +
408 +        edm::Handle<EcalRecHitCollection > h_EcalES_RecHits;
409 +        iEvent.getByLabel("ecalPreshowerRecHit","EcalRecHitsES", h_EcalES_RecHits);
410 +        EcalRecHitCollection EcalES_RecHits = *h_EcalES_RecHits.product();
411 +
412 +        for(unsigned int eh=0;eh<EcalES_RecHits.size();eh++){
413 +                MyCaloHit temp_EcalESHit;
414 +                temp_EcalESHit.E     = EcalES_RecHits[eh].energy();
415 +                temp_EcalESHit.t     = EcalES_RecHits[eh].time();
416 +                temp_EcalESHit.DetId = (EcalES_RecHits[eh].detid()).rawId();
417 +
418 +                MyEvent->MyEcalCaloHitCollection.push_back(temp_EcalESHit);
419 +        }
420 +
421 +
422 +
423 +        edm::Handle<HBHERecHitCollection > h_HcalHBHE_RecHits;
424 +        iEvent.getByLabel("hbhereco", h_HcalHBHE_RecHits);
425 +        HBHERecHitCollection HcalHBHE_RecHits = *h_HcalHBHE_RecHits.product();
426 +
427 +        for(unsigned int hh=0;hh<HcalHBHE_RecHits.size();hh++){
428 +                MyCaloHit temp_HcalHBHEHit;
429 +                temp_HcalHBHEHit.E      = HcalHBHE_RecHits[hh].energy();
430 +                temp_HcalHBHEHit.t      = HcalHBHE_RecHits[hh].time();
431 +                temp_HcalHBHEHit.DetId = (HcalHBHE_RecHits[hh].detid()).rawId();
432 +
433 +                MyEvent->MyHcalCaloHitCollection.push_back(temp_HcalHBHEHit);
434 +        }
435 +
436 +
437 +        edm::Handle<HORecHitCollection > h_HcalHO_RecHits;
438 +        iEvent.getByLabel("horeco", h_HcalHO_RecHits);
439 +        HORecHitCollection HcalHO_RecHits = *h_HcalHO_RecHits.product();
440 +
441 +        for(unsigned int hh=0;hh<HcalHO_RecHits.size();hh++){
442 +                MyCaloHit temp_HcalHOHit;
443 +                temp_HcalHOHit.E      = HcalHO_RecHits[hh].energy();
444 +                temp_HcalHOHit.t      = HcalHO_RecHits[hh].time();
445 +                temp_HcalHOHit.DetId = (HcalHO_RecHits[hh].detid()).rawId();
446 +
447 +                MyEvent->MyHcalCaloHitCollection.push_back(temp_HcalHOHit);
448 +        }
449 +
450 +        edm::Handle<HFRecHitCollection > h_HcalHF_RecHits;
451 +        iEvent.getByLabel("hfreco", h_HcalHF_RecHits);
452 +        HFRecHitCollection HcalHF_RecHits = *h_HcalHF_RecHits.product();
453 +
454 +        for(unsigned int hh=0;hh<HcalHF_RecHits.size();hh++){
455 +                MyCaloHit temp_HcalHFHit;
456 +                temp_HcalHFHit.E      = HcalHF_RecHits[hh].energy();
457 +                temp_HcalHFHit.t      = HcalHF_RecHits[hh].time();
458 +                temp_HcalHFHit.DetId = (HcalHF_RecHits[hh].detid()).rawId();
459 +
460 +                MyEvent->MyHcalCaloHitCollection.push_back(temp_HcalHFHit);
461 +        }
462 +
463 +
464 +
465 +
466 +
467 +
468 +
469 +
470 +
471 +
472 +
473          MyEvents->Events.push_back(MyEvent);  
474  
475   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines