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.1 by querten, Fri Mar 14 18:31:03 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/SimEvent.cpp"
68 <
69 <
81 > #include "Visualisation/OpenGLDisplayer/interface/Geometry.h"
82  
83   using namespace edm;
84   using namespace std;
# Line 82 | Line 94 | class OpenGLDisplayer : public edm::EDAn
94  
95  
96     private:
97 <      virtual void beginJob(const edm::EventSetup&) ;
98 <      virtual void analyze(const edm::Event&, const edm::EventSetup&);
99 <      virtual void endJob() ;
97 >      virtual void beginJob(const edm::EventSetup& iSetup);
98 >      virtual void analyze (const edm::Event&, const edm::EventSetup&);
99 >      virtual void endJob  ();
100  
101  
102        MySimEvents* MyEvents;
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 106 | 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 115 | Line 133 | OpenGLDisplayer::~OpenGLDisplayer()
133  
134   // ------------ method called once each job just before starting event loop  ------------
135   void
136 < OpenGLDisplayer::beginJob(const edm::EventSetup&)
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 +
146 +
147 +   edm::ESHandle<TrackerGeometry> tkGeom;
148 +   iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
149 +   vector<GeomDet*> TrackerDets = tkGeom->dets();
150 +
151 +   for(unsigned int i=0;i<TrackerDets.size();i++){
152 +      Detid  = TrackerDets[i]->geographicalId();
153 + //    SubDet = Detid.subdetId();
154 +  
155 +      GeomDet* DetUnit = TrackerDets[i];
156 +      if(!DetUnit)continue;
157 +      const BoundPlane plane = DetUnit->surface();
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 +
184 +      GlobalVector Pos =  GlobalVector(DetUnit->position().basicVector());
185 +
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 +
242 +   Geom_Tracker->Save("Tracker.geom");    
243 +   Geom_ECAL->Save("ECAL.geom");
244 +   Geom_HCAL->Save("HCAL.geom");
245  
246  
122   MyEvents = new MySimEvents();
247  
248   }
249  
# Line 128 | 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 219 | Line 343 | OpenGLDisplayer::analyze(const edm::Even
343             }
344          }
345  
346 <
223 <
224 <
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 ) {
352                  MyRecoTrack  MyrecoTrack;
353                  reco::Track  recoTrack  =TrackColl[t];
354  
355 <                MyrecoTrack.N    = recoTrack.recHitsSize();
234 <                MyrecoTrack.Hits = new MyRecoHit[MyrecoTrack.N];
355 > //                MyrecoTrack.Hits = new MyRecoHit[MyrecoTrack.N];
356  
357 < //                for(int h=0;h<MyrecoTrack.N;h++){                        
237 < //                      MyrecoTrack.Hits[h].x      = 1;
238 < //                        MyrecoTrack.Hits[h].y      = 2;
239 < //                        MyrecoTrack.Hits[h].z      = 3;
240 < //                        MyrecoTrack.Hits[h].DetId  = 4;
241 < //                        MyrecoTrack.Hits[h].Charge = 5;
242 < //                }
243 <
244 < //                unsigned int h=0;
245 < //              for(trackingRecHit_iterator h_it = recoTrack.recHitsBegin();h_it!=recoTrack.recHitsEnd();h_it++){
246 <                for(int h=0;h<MyrecoTrack.N;h++){
357 >                for(unsigned int h=0;h<recoTrack.recHitsSize();h++){
358                        TrackingRecHitRef h_it     = recoTrack.recHit(h);
359                        if(!h_it->isValid() )continue;
360                        DetId detId                = h_it->geographicalId();
361                        const GeomDet * theDet     = theTracker.idToDet(detId);
362                        LocalPoint localPos        = h_it->localPosition();
252          
253                      MyrecoTrack.Hits[h].x      = theDet->surface().toGlobal(localPos).x();
254                      MyrecoTrack.Hits[h].y      = theDet->surface().toGlobal(localPos).y();
255                      MyrecoTrack.Hits[h].z      = theDet->surface().toGlobal(localPos).z();
256                      MyrecoTrack.Hits[h].DetId  = detId.rawId();
257                      MyrecoTrack.Hits[h].Charge = -1;
258                }
363  
364 +                      MyRecoHit hit;          
365 +                      hit.x      = theDet->surface().toGlobal(localPos).x();
366 +                      hit.y      = theDet->surface().toGlobal(localPos).y();
367 +                      hit.z      = theDet->surface().toGlobal(localPos).z();
368 +                      hit.DetId  = detId.rawId();
369 +                      hit.Charge = -1;
370 +                      MyrecoTrack.Hits.push_back(hit);
371 +
372 +
373 + //                    printf("%8.2f %8.2f %8.2f\n",theDet->surface().toGlobal(localPos).x(),theDet->surface().toGlobal(localPos).y(),theDet->surface().toGlobal(localPos).z());
374 +                }
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  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines