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.6 by querten, Fri Mar 21 07:25:16 2008 UTC

# Line 64 | Line 64
64  
65  
66   #include "Visualisation/OpenGLDisplayer/interface/SimEvent.h"
67 < //#include "Visualisation/OpenGLDisplayer/interface/SimEvent.cpp"
68 <
69 <
67 > #include "Visualisation/OpenGLDisplayer/interface/Geometry.h"
68  
69   using namespace edm;
70   using namespace std;
# Line 82 | Line 80 | class OpenGLDisplayer : public edm::EDAn
80  
81  
82     private:
83 <      virtual void beginJob(const edm::EventSetup&) ;
84 <      virtual void analyze(const edm::Event&, const edm::EventSetup&);
85 <      virtual void endJob() ;
83 >      virtual void beginJob(const edm::EventSetup& iSetup);
84 >      virtual void analyze (const edm::Event&, const edm::EventSetup&);
85 >      virtual void endJob  ();
86  
87  
88        MySimEvents* MyEvents;
89 +      Geometry*    Geom;
90  
91  
92        std::vector<std::string> SimHitSubdetectors;
# Line 115 | Line 114 | OpenGLDisplayer::~OpenGLDisplayer()
114  
115   // ------------ method called once each job just before starting event loop  ------------
116   void
117 < OpenGLDisplayer::beginJob(const edm::EventSetup&)
117 > OpenGLDisplayer::beginJob(const edm::EventSetup& iSetup)
118   {
119  
121
120     MyEvents = new MySimEvents();
121 +   Geom     = new Geometry();
122 +
123 +   edm::ESHandle<TrackerGeometry> tkGeom;
124 +   iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
125 +   vector<GeomDet*> Det = tkGeom->dets();
126 +
127 +   for(unsigned int i=0;i<Det.size();i++){
128 +      DetId  Detid  = Det[i]->geographicalId();
129 + //      int    SubDet = Detid.subdetId();
130 +  
131 +      GeomDet* DetUnit = Det[i];
132 + //      StripGeomDetUnit* DetUnit     = dynamic_cast<StripGeomDetUnit*> (Det[i]);
133 +      if(!DetUnit)continue;
134 +
135 +      const BoundPlane plane = DetUnit->surface();
136 +      float width     = DetUnit->surface().bounds().width();
137 +      float length    = DetUnit->surface().bounds().length();
138 +      float thickness = DetUnit->surface().bounds().thickness();
139 +
140 +      Surface::GlobalPoint WidthVector  = plane.toGlobal( LocalPoint(width/2, 0, 0) );
141 +      Surface::GlobalPoint LengthVector = plane.toGlobal( LocalPoint(0, length/2, 0) );
142 +      Surface::GlobalPoint ThickVector  = plane.toGlobal( LocalPoint(0, 0, thickness/2) );
143 +
144 +
145 +      GlobalVector Pos =  GlobalVector(DetUnit->position().basicVector());
146 +
147 +      Geom->Add_TrackerDet(Detid.rawId(),
148 +                           Pos.x(),                  Pos.y(),                  Pos.z(),
149 +                           WidthVector.x() -Pos.x(), WidthVector.y() -Pos.y(), WidthVector.z() -Pos.z(),
150 +                           LengthVector.x()-Pos.x(), LengthVector.y()-Pos.y(), LengthVector.z()-Pos.z(),
151 +                           ThickVector.x() -Pos.x(), ThickVector.y() -Pos.y(), ThickVector.z() -Pos.z());
152 +   }
153 +   Geom->Save("Tracker.geom");    
154 +
155  
156   }
157  
# Line 219 | Line 251 | OpenGLDisplayer::analyze(const edm::Even
251             }
252          }
253  
222
223
224
254          edm::Handle<std::vector< reco::Track > > h_Tracks;
255          iEvent.getByLabel("ctfWithMaterialTracks", h_Tracks);
256          std::vector< reco::Track > TrackColl = *h_Tracks.product();
# Line 230 | Line 259 | OpenGLDisplayer::analyze(const edm::Even
259                  MyRecoTrack  MyrecoTrack;
260                  reco::Track  recoTrack  =TrackColl[t];
261  
262 <                MyrecoTrack.N    = recoTrack.recHitsSize();
234 <                MyrecoTrack.Hits = new MyRecoHit[MyrecoTrack.N];
262 > //                MyrecoTrack.Hits = new MyRecoHit[MyrecoTrack.N];
263  
264 < //                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++){
264 >                for(unsigned int h=0;h<recoTrack.recHitsSize();h++){
265                        TrackingRecHitRef h_it     = recoTrack.recHit(h);
266                        if(!h_it->isValid() )continue;
267                        DetId detId                = h_it->geographicalId();
268                        const GeomDet * theDet     = theTracker.idToDet(detId);
269                        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                }
270  
271 +                      MyRecoHit hit;          
272 +                      hit.x      = theDet->surface().toGlobal(localPos).x();
273 +                      hit.y      = theDet->surface().toGlobal(localPos).y();
274 +                      hit.z      = theDet->surface().toGlobal(localPos).z();
275 +                      hit.DetId  = detId.rawId();
276 +                      hit.Charge = -1;
277 +                      MyrecoTrack.Hits.push_back(hit);
278 +
279 +
280 + //                    printf("%8.2f %8.2f %8.2f\n",theDet->surface().toGlobal(localPos).x(),theDet->surface().toGlobal(localPos).y(),theDet->surface().toGlobal(localPos).z());
281 +                }
282                  MyEvent->MyRecoTrackCollection.push_back(MyrecoTrack);
283          }
284  
263        
264
285          MyEvents->Events.push_back(MyEvent);  
286  
287   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines