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.4 by querten, Tue Mar 18 10:52:55 2008 UTC vs.
Revision 1.14 by roberfro, Thu Apr 3 12:18:29 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;
109  
110        std::string              OutputFile;
111 +      std::string              trackProducer;
112  
113  
114        // ----------member data ---------------------------
# Line 105 | 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 116 | Line 135 | OpenGLDisplayer::~OpenGLDisplayer()
135   void
136   OpenGLDisplayer::beginJob(const edm::EventSetup& iSetup)
137   {
138 +   DetId  Detid;
139 +   int    SubDet;
140 +
141 +   MyEvents     = new MySimEvents();
142 +   Geom_Tracker = new Geometry();
143 +   Geom_ECAL    = new Geometry();
144 +   Geom_HCAL    = new Geometry();
145  
120   MyEvents = new MySimEvents();
121   Geom     = new Geometry();
146  
147     edm::ESHandle<TrackerGeometry> tkGeom;
148     iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
149 <   vector<GeomDet*> Det = tkGeom->dets();
149 >   vector<GeomDet*> TrackerDets = tkGeom->dets();
150  
151 <   for(unsigned int i=0;i<Det.size();i++){
152 <      DetId  Detid  = Det[i]->geographicalId();
153 < //      int    SubDet = Detid.subdetId();
151 >   for(unsigned int i=0;i<TrackerDets.size();i++){
152 >      Detid  = TrackerDets[i]->geographicalId();
153 > //    SubDet = Detid.subdetId();
154    
155 <      GeomDet* DetUnit = Det[i];
132 < //      StripGeomDetUnit* DetUnit     = dynamic_cast<StripGeomDetUnit*> (Det[i]);
155 >      GeomDet* DetUnit = TrackerDets[i];
156        if(!DetUnit)continue;
134
157        const BoundPlane plane = DetUnit->surface();
158 <      float width     = DetUnit->surface().bounds().width();
159 <      float length    = DetUnit->surface().bounds().length();
160 <      float thickness = DetUnit->surface().bounds().thickness();
158 >      const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
159 >      const RectangularPlaneBounds* rectangularBounds( dynamic_cast<const RectangularPlaneBounds*>(&(plane.bounds())));  
160 >
161 >      float width            = 0;
162 >      float length           = 0;
163 >      float thickness        = 0;
164 >      float TrapezoidalParam = 0;
165 >
166 >      if(trapezoidalBounds)
167 >      {
168 >         std::vector<float> const & parameters = (*trapezoidalBounds).parameters();      
169 >         width            = parameters[0]*2;
170 >         length           = parameters[3]*2;  
171 >         thickness        =  (*trapezoidalBounds).thickness();
172 >         TrapezoidalParam = parameters[1]/parameters[0];
173 >      }else if(rectangularBounds){
174 >         width            = DetUnit->surface().bounds().width();
175 >         length           = DetUnit->surface().bounds().length();
176 >         thickness        = DetUnit->surface().bounds().thickness();
177 >         TrapezoidalParam = 1;
178 >      }
179  
180        Surface::GlobalPoint WidthVector  = plane.toGlobal( LocalPoint(width/2, 0, 0) );
181        Surface::GlobalPoint LengthVector = plane.toGlobal( LocalPoint(0, length/2, 0) );
182        Surface::GlobalPoint ThickVector  = plane.toGlobal( LocalPoint(0, 0, thickness/2) );
183  
144
184        GlobalVector Pos =  GlobalVector(DetUnit->position().basicVector());
185  
186 <      Geom->Add_TrackerDet(Detid.rawId(),
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(),
190 <                           ThickVector.x() -Pos.x(), ThickVector.y() -Pos.y(), ThickVector.z() -Pos.z());
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(),
190 >           ThickVector.x() -Pos.x(), ThickVector.y() -Pos.y(), ThickVector.z() -Pos.z());
191 >      
192 >
193 >   }
194 >
195 >
196 >   // ### CALO GEOMETRY ###
197 >
198 >   edm::ESHandle<CaloGeometry> CaloGeom;
199 >   iSetup.get<IdealGeometryRecord>().get( CaloGeom );
200 >   const vector<DetId> CaloDets = CaloGeom->getValidDetIds();
201 >
202 >   for(unsigned int i=0;i<CaloDets.size();i++)
203 >   {
204 >      Detid  = CaloDets[i];
205 >      SubDet = Detid.subdetId();
206 >
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();
228 >      const CaloCellGeometry::CornersVec CellCorners =  CellGeom->getCorners();
229 >
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 <   Geom->Save("Tracker.geom");    
241 >
242 >   Geom_Tracker->Save("Tracker.geom");    
243 >   Geom_ECAL->Save("ECAL.geom");
244 >   Geom_HCAL->Save("HCAL.geom");
245 >
246  
247  
248   }
# Line 160 | 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 251 | 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 282 | 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