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.3 by querten, Mon Mar 17 06:26:31 2008 UTC vs.
Revision 1.12 by querten, Mon Mar 24 09:55:23 2008 UTC

# Line 45 | Line 45
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"
# Line 61 | Line 74
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/Geometry.h"
# Line 86 | 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;
# Line 116 | Line 132 | OpenGLDisplayer::~OpenGLDisplayer()
132   void
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  
120   MyEvents = new MySimEvents();
121   Geom     = new Geometry();
143  
144     edm::ESHandle<TrackerGeometry> tkGeom;
145     iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
146 <   vector<GeomDet*> Det = tkGeom->dets();
146 >   vector<GeomDet*> TrackerDets = tkGeom->dets();
147  
148 <   for(unsigned int i=0;i<Det.size();i++){
149 <      DetId  Detid  = Det[i]->geographicalId();
150 <      int    SubDet = Detid.subdetId();
151 <  
152 <      StripGeomDetUnit* DetUnit     = dynamic_cast<StripGeomDetUnit*> (Det[i]);
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->Add_TrackerDet(SubDet,Pos.x(),Pos.y(),Pos.z(),Detid.rawId());
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 <   Geom->Save("Tracker.geom");    
238 >
239 >   Geom_Tracker->Save("Tracker.geom");    
240 >   Geom_ECAL->Save("ECAL.geom");
241 >   Geom_HCAL->Save("HCAL.geom");
242 >
243  
244  
245   }
# Line 145 | Line 249 | void
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  
# Line 267 | Line 371 | OpenGLDisplayer::analyze(const edm::Even
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  
471   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines