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.17 by querten, Wed Apr 16 08:21:47 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 +      std::string              OutputFile;
108 +
109 +      std::vector<InputTag> SimTrackProducers;
110 +      std::vector<InputTag> SimVertexProducers;
111 +      std::vector<InputTag> SimHitProducers;
112 +
113 +      std::vector<InputTag> TrackProducers;
114 +      std::vector<InputTag> EcalRecHitProducers;
115 +      std::vector<InputTag> HcalHBHERecHitProducers;
116 +      std::vector<InputTag> HcalHORecHitProducers;
117 +      std::vector<InputTag> HcalHFRecHitProducers;
118  
104      std::vector<std::string> SimHitSubdetectors;
119  
106      std::string              OutputFile;
120  
121  
122        // ----------member data ---------------------------
# Line 114 | Line 127 | class OpenGLDisplayer : public edm::EDAn
127   //
128   OpenGLDisplayer::OpenGLDisplayer(const edm::ParameterSet& iConfig)
129   {
130 <    SimHitSubdetectors  = iConfig.getParameter<std::vector<std::string> >("SimHitSubdetectors");
130 >    OutputFile              = iConfig.getParameter<std::string >("OutputFile");
131 >
132 >    SimTrackProducers       = iConfig.getParameter<std::vector<InputTag> >("SimTrackProducers");
133 >    SimVertexProducers      = iConfig.getParameter<std::vector<InputTag> >("SimVertexProducers");
134 >    SimHitProducers         = iConfig.getParameter<std::vector<InputTag> >("SimHitProducers");
135 >
136 >    TrackProducers          = iConfig.getParameter<std::vector<InputTag> >("TrackProducers");
137 >    EcalRecHitProducers     = iConfig.getParameter<std::vector<InputTag> >("EcalRecHitProducers");
138 >    HcalHBHERecHitProducers = iConfig.getParameter<std::vector<InputTag> >("HcalHBHERecHitProducers");
139 >    HcalHORecHitProducers   = iConfig.getParameter<std::vector<InputTag> >("HcalHORecHitProducers");
140 >    HcalHFRecHitProducers   = iConfig.getParameter<std::vector<InputTag> >("HcalHFRecHitProducers");
141  
119    OutputFile          = iConfig.getParameter<std::string >("OutputFile");
142   }
143  
144  
# Line 131 | Line 153 | OpenGLDisplayer::beginJob(const edm::Eve
153     DetId  Detid;
154     int    SubDet;
155  
156 <   MyEvents = new MySimEvents();
157 <   Geom     = new Geometry();
156 >   MyEvents     = new MySimEvents();
157 >   Geom_Tracker = new Geometry();
158 >   Geom_ECAL    = new Geometry();
159 >   Geom_HCAL    = new Geometry();
160 >
161  
162     edm::ESHandle<TrackerGeometry> tkGeom;
163     iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
# Line 173 | Line 198 | OpenGLDisplayer::beginJob(const edm::Eve
198  
199        GlobalVector Pos =  GlobalVector(DetUnit->position().basicVector());
200  
201 <      Geom->Add_TrackerDet(Detid.rawId(), TrapezoidalParam,
201 >      Geom_Tracker->Add_TrackerDet(Detid.rawId(), TrapezoidalParam,
202             Pos.x(),                  Pos.y(),                  Pos.z(),
203             WidthVector.x() -Pos.x(), WidthVector.y() -Pos.y(), WidthVector.z() -Pos.z(),
204             LengthVector.x()-Pos.x(), LengthVector.y()-Pos.y(), LengthVector.z()-Pos.z(),
# Line 193 | Line 218 | OpenGLDisplayer::beginJob(const edm::Eve
218     {
219        Detid  = CaloDets[i];
220        SubDet = Detid.subdetId();
196    
197      if(Detid.det()!=DetId::Ecal) continue;
221  
222 <      //EcalBarrel=1, EcalEndcap=2, EcalPreshower=3, EcalTriggerTower=4, EcalLaserPnDiode=5
223 <      if(SubDet!=EcalBarrel)continue;
222 >      Geometry* Geom_temp = NULL;
223 >      if(Detid.det()==DetId::Ecal){
224 >        Geom_temp = Geom_ECAL;
225 >
226 >        if(SubDet<1 || SubDet>3){
227 >                printf("Don't Save EcalTriggerTower or EcalLaserPnDiode\n");
228 >                continue;
229 >        }
230 >      }else if(Detid.det()==DetId::Hcal){
231 >        Geom_temp = Geom_HCAL;
232 >
233 >        if(SubDet<1 || SubDet>4){
234 >                printf("Don't Save HcalEmpty, HcalTriggerTower, HcalOther\n");
235 >                continue;
236 >        }
237 >      }else{
238 >        continue;
239 >      }
240  
241        const CaloCellGeometry* CellGeom = CaloGeom->getGeometry(Detid);
242        GlobalPoint CellPos =  CellGeom->getPosition();
204
243        const CaloCellGeometry::CornersVec CellCorners =  CellGeom->getCorners();
244 <                
245 <      printf("Det = %i Subdet = %i --> %6.2f %6.2f %6.2f - %i\n",  Detid.det(), SubDet, CellPos.x(), CellPos.y(), CellPos.z(), CellCorners.size());
244 >
245 >      Geom_temp->Add_CaloDet(Detid.rawId(),
246 >                        CellPos.x()         ,   CellPos.y()         ,   CellPos.z(),
247 >                        CellCorners[0].x()  ,   CellCorners[0].y()  ,   CellCorners[0].z()  ,
248 >                        CellCorners[1].x()  ,   CellCorners[1].y()  ,   CellCorners[1].z()  ,
249 >                        CellCorners[2].x()  ,   CellCorners[2].y()  ,   CellCorners[2].z()  ,
250 >                        CellCorners[3].x()  ,   CellCorners[3].y()  ,   CellCorners[3].z()  ,
251 >                        CellCorners[4].x()  ,   CellCorners[4].y()  ,   CellCorners[4].z()  ,
252 >                        CellCorners[5].x()  ,   CellCorners[5].y()  ,   CellCorners[5].z()  ,
253 >                        CellCorners[6].x()  ,   CellCorners[6].y()  ,   CellCorners[6].z()  ,
254 >                        CellCorners[7].x()  ,   CellCorners[7].y()  ,   CellCorners[7].z()  );
255     }
256  
257 +   Geom_Tracker->Save("Tracker.geom");    
258 +   Geom_ECAL->Save("Ecal.geom");
259 +   Geom_HCAL->Save("Hcal.geom");
260  
211   Geom->Save("Tracker.geom");    
261  
262  
263   }
# Line 218 | Line 267 | void
267   OpenGLDisplayer::endJob() {
268    
269     MyEvents->Save((char*) OutputFile.c_str());
270 <   MyEvents->Load((char*) OutputFile.c_str());
270 > //   MyEvents->Load((char*) OutputFile.c_str());
271   }
272  
273  
# Line 231 | Line 280 | OpenGLDisplayer::endJob() {
280   void
281   OpenGLDisplayer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
282   {
283 <
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();
283 >        MySimEvent* MyEvent = new MySimEvent;
284  
285  
286  
# Line 251 | Line 293 | OpenGLDisplayer::analyze(const edm::Even
293          TrackingGeometry::DetContainer theDetUnits = theTracker.dets();
294  
295  
296 +        // Save Data
297 +        for(unsigned int i=0;i<SimTrackProducers.size();i++){
298 +           edm::Handle<std::vector< SimTrack > > h_SimTracks;
299 +           iEvent.getByLabel(SimTrackProducers[i], h_SimTracks);
300 +           std::vector< SimTrack > SimTrackColl = *h_SimTracks.product();
301  
302 <
256 <        // Save the data
257 <
258 <        MySimEvent* MyEvent = new MySimEvent;
259 <  
260 <        for ( unsigned int a = 0; a < SimTrackColl.size(); ++a ) {
302 >           for ( unsigned int a = 0; a < SimTrackColl.size(); ++a ) {
303                  MySimTrack  MysimTrack;
304                  SimTrack    simTrack    =SimTrackColl[a];
305  
# Line 271 | Line 313 | OpenGLDisplayer::analyze(const edm::Even
313                  MysimTrack.charge       =simTrack.charge();
314  
315                  MyEvent->MySimTrackCollection.push_back(MysimTrack);
316 <        }
316 >           }      
317 >        }
318 >
319  
320 +        for(unsigned int i=0;i<SimVertexProducers.size();i++){
321 +           edm::Handle<std::vector< SimVertex > > h_Vertex;
322 +           iEvent.getByLabel(SimVertexProducers[i], h_Vertex);
323 +           std::vector< SimVertex > VertexColl = *h_Vertex.product();
324  
325 <        for (unsigned int b = 0; b < VertexColl.size(); ++b ) {
325 >           for (unsigned int b = 0; b < VertexColl.size(); ++b ) {
326                  MySimVertex     MyVertex;
327                  SimVertex       Vertex  =  VertexColl[b];
328  
# Line 284 | Line 332 | OpenGLDisplayer::analyze(const edm::Even
332                  MyVertex.z              =Vertex.position().z();
333  
334                  MyEvent->MySimVertexCollection.push_back(MyVertex);
335 <        }
335 >           }
336 >        }
337  
338 <        for(unsigned int i=0; i<SimHitSubdetectors.size(); i++)
290 <        {
338 >        for(unsigned int i=0;i<SimHitProducers.size();i++){
339             edm::Handle<std::vector< PSimHit > > h_Hits;
340 <           iEvent.getByLabel("g4SimHits",SimHitSubdetectors[i].c_str(), h_Hits);
340 >           iEvent.getByLabel(SimHitProducers[i], h_Hits);
341             std::vector< PSimHit > Hits = *h_Hits.product();
342  
343             for(unsigned int h=0; h<Hits.size(); h++)
# Line 305 | Line 353 | OpenGLDisplayer::analyze(const edm::Even
353                  Hit.dEdX        = Hits[h].energyLoss();
354  
355                  MyEvent->MyPSimHitCollection.push_back(Hit);
308
356             }
357          }
358  
312        edm::Handle<std::vector< reco::Track > > h_Tracks;
313        iEvent.getByLabel("ctfWithMaterialTracks", h_Tracks);
314        std::vector< reco::Track > TrackColl = *h_Tracks.product();
359  
360 <        for ( unsigned int t = 0; t < TrackColl.size(); ++t ) {
360 >        for(unsigned int i=0;i<TrackProducers.size();i++){
361 >           edm::Handle<std::vector< reco::Track > > h_Tracks;
362 >           iEvent.getByLabel(TrackProducers[i], h_Tracks);
363 >           std::vector< reco::Track > TrackColl = *h_Tracks.product();
364 >
365 >           for ( unsigned int t = 0; t < TrackColl.size(); ++t ) {
366                  MyRecoTrack  MyrecoTrack;
367                  reco::Track  recoTrack  =TrackColl[t];
368  
320 //                MyrecoTrack.Hits = new MyRecoHit[MyrecoTrack.N];
321
369                  for(unsigned int h=0;h<recoTrack.recHitsSize();h++){
370                        TrackingRecHitRef h_it     = recoTrack.recHit(h);
371                        if(!h_it->isValid() )continue;
# Line 333 | Line 380 | OpenGLDisplayer::analyze(const edm::Even
380                        hit.DetId  = detId.rawId();
381                        hit.Charge = -1;
382                        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());
383                  }
384                  MyEvent->MyRecoTrackCollection.push_back(MyrecoTrack);
385 +           }
386          }
387  
343        MyEvents->Events.push_back(MyEvent);  
388  
389 +        for(unsigned int i=0;i<EcalRecHitProducers.size();i++){
390 +           edm::Handle<EcalRecHitCollection > h_Ecal_RecHits;
391 +           iEvent.getByLabel(EcalRecHitProducers[i], h_Ecal_RecHits);
392 +           EcalRecHitCollection Ecal_RecHits = *h_Ecal_RecHits.product();
393 +
394 +           for(unsigned int eh=0;eh<Ecal_RecHits.size();eh++){
395 +                MyCaloHit temp_EcalHit;
396 +                temp_EcalHit.E     = Ecal_RecHits[eh].energy();
397 +                temp_EcalHit.t     = Ecal_RecHits[eh].time();
398 +                temp_EcalHit.DetId = (Ecal_RecHits[eh].detid()).rawId();
399 +        
400 +                MyEvent->MyEcalCaloHitCollection.push_back(temp_EcalHit);
401 +           }
402 +        }
403 +
404 +
405 +        for(unsigned int i=0;i<HcalHBHERecHitProducers.size();i++){
406 +           edm::Handle<HBHERecHitCollection > h_HcalHBHE_RecHits;
407 +           iEvent.getByLabel(HcalHBHERecHitProducers[i], h_HcalHBHE_RecHits);
408 +           HBHERecHitCollection HcalHBHE_RecHits = *h_HcalHBHE_RecHits.product();
409 +
410 +           for(unsigned int hh=0;hh<HcalHBHE_RecHits.size();hh++){
411 +                MyCaloHit temp_HcalHBHEHit;
412 +                temp_HcalHBHEHit.E      = HcalHBHE_RecHits[hh].energy();
413 +                temp_HcalHBHEHit.t      = HcalHBHE_RecHits[hh].time();
414 +                temp_HcalHBHEHit.DetId = (HcalHBHE_RecHits[hh].detid()).rawId();
415 +
416 +                MyEvent->MyHcalCaloHitCollection.push_back(temp_HcalHBHEHit);
417 +           }
418 +        }
419 +
420 +
421 +        for(unsigned int i=0;i<HcalHORecHitProducers.size();i++){
422 +           edm::Handle<HORecHitCollection > h_HcalHO_RecHits;
423 +           iEvent.getByLabel(HcalHORecHitProducers[i], h_HcalHO_RecHits);
424 +           HORecHitCollection HcalHO_RecHits = *h_HcalHO_RecHits.product();
425 +
426 +           for(unsigned int hh=0;hh<HcalHO_RecHits.size();hh++){
427 +                MyCaloHit temp_HcalHOHit;
428 +                temp_HcalHOHit.E      = HcalHO_RecHits[hh].energy();
429 +                temp_HcalHOHit.t      = HcalHO_RecHits[hh].time();
430 +                temp_HcalHOHit.DetId = (HcalHO_RecHits[hh].detid()).rawId();
431 +
432 +                MyEvent->MyHcalCaloHitCollection.push_back(temp_HcalHOHit);
433 +           }
434 +        }
435 +
436 +
437 +        for(unsigned int i=0;i<HcalHFRecHitProducers.size();i++){
438 +           edm::Handle<HFRecHitCollection > h_HcalHF_RecHits;
439 +           iEvent.getByLabel(HcalHFRecHitProducers[i], h_HcalHF_RecHits);
440 +           HFRecHitCollection HcalHF_RecHits = *h_HcalHF_RecHits.product();
441 +
442 +           for(unsigned int hh=0;hh<HcalHF_RecHits.size();hh++){
443 +                MyCaloHit temp_HcalHFHit;
444 +                temp_HcalHFHit.E      = HcalHF_RecHits[hh].energy();
445 +                temp_HcalHFHit.t      = HcalHF_RecHits[hh].time();
446 +                temp_HcalHFHit.DetId = (HcalHF_RecHits[hh].detid()).rawId();
447 +
448 +                MyEvent->MyHcalCaloHitCollection.push_back(temp_HcalHFHit);
449 +           }
450 +        }
451 +
452 +        MyEvents->Events.push_back(MyEvent);  
453   }
454  
455  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines