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.9 by querten, Fri Mar 21 15:11: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 +
58 +
59   #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"
60   #include "SimDataFormats/TrackingHit/interface/PSimHit.h"
61   #include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h"
# Line 61 | Line 72
72   #include "DataFormats/TrackReco/interface/Track.h"
73  
74   #include "DataFormats/Math/interface/Point3D.h"
75 <
75 > #include "DataFormats/GeometrySurface/interface/TrapezoidalPlaneBounds.h"
76 > #include "DataFormats/GeometrySurface/interface/RectangularPlaneBounds.h"
77  
78   #include "Visualisation/OpenGLDisplayer/interface/SimEvent.h"
79   #include "Visualisation/OpenGLDisplayer/interface/Geometry.h"
# Line 116 | Line 128 | OpenGLDisplayer::~OpenGLDisplayer()
128   void
129   OpenGLDisplayer::beginJob(const edm::EventSetup& iSetup)
130   {
131 +   DetId  Detid;
132 +   int    SubDet;
133  
134     MyEvents = new MySimEvents();
135     Geom     = new Geometry();
136  
137     edm::ESHandle<TrackerGeometry> tkGeom;
138     iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom );
139 <   vector<GeomDet*> Det = tkGeom->dets();
139 >   vector<GeomDet*> TrackerDets = tkGeom->dets();
140  
141 <   for(unsigned int i=0;i<Det.size();i++){
142 <      DetId  Detid  = Det[i]->geographicalId();
143 <      int    SubDet = Detid.subdetId();
144 <  
145 <      StripGeomDetUnit* DetUnit     = dynamic_cast<StripGeomDetUnit*> (Det[i]);
141 >   for(unsigned int i=0;i<TrackerDets.size();i++){
142 >      Detid  = TrackerDets[i]->geographicalId();
143 > //    SubDet = Detid.subdetId();
144 >  
145 >      GeomDet* DetUnit = TrackerDets[i];
146        if(!DetUnit)continue;
147 +      const BoundPlane plane = DetUnit->surface();
148 +      const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
149 +      const RectangularPlaneBounds* rectangularBounds( dynamic_cast<const RectangularPlaneBounds*>(&(plane.bounds())));  
150 +
151 +      float width            = 0;
152 +      float length           = 0;
153 +      float thickness        = 0;
154 +      float TrapezoidalParam = 0;
155 +
156 +      if(trapezoidalBounds)
157 +      {
158 +         std::vector<float> const & parameters = (*trapezoidalBounds).parameters();      
159 +         width            = parameters[0]*2;
160 +         length           = parameters[3]*2;  
161 +         thickness        =  (*trapezoidalBounds).thickness();
162 +         TrapezoidalParam = parameters[1]/parameters[0];
163 +      }else if(rectangularBounds){
164 +         width            = DetUnit->surface().bounds().width();
165 +         length           = DetUnit->surface().bounds().length();
166 +         thickness        = DetUnit->surface().bounds().thickness();
167 +         TrapezoidalParam = 1;
168 +      }
169 +
170 +      Surface::GlobalPoint WidthVector  = plane.toGlobal( LocalPoint(width/2, 0, 0) );
171 +      Surface::GlobalPoint LengthVector = plane.toGlobal( LocalPoint(0, length/2, 0) );
172 +      Surface::GlobalPoint ThickVector  = plane.toGlobal( LocalPoint(0, 0, thickness/2) );
173  
174        GlobalVector Pos =  GlobalVector(DetUnit->position().basicVector());
175  
176 <      Geom->Add_TrackerDet(SubDet,Pos.x(),Pos.y(),Pos.z(),Detid.rawId());
176 >      Geom->Add_TrackerDet(Detid.rawId(), TrapezoidalParam,
177 >           Pos.x(),                  Pos.y(),                  Pos.z(),
178 >           WidthVector.x() -Pos.x(), WidthVector.y() -Pos.y(), WidthVector.z() -Pos.z(),
179 >           LengthVector.x()-Pos.x(), LengthVector.y()-Pos.y(), LengthVector.z()-Pos.z(),
180 >           ThickVector.x() -Pos.x(), ThickVector.y() -Pos.y(), ThickVector.z() -Pos.z());
181 >      
182 >
183     }
184 +
185 +
186 +   // ### CALO GEOMETRY ###
187 +
188 +   edm::ESHandle<CaloGeometry> CaloGeom;
189 +   iSetup.get<IdealGeometryRecord>().get( CaloGeom );
190 +   const vector<DetId> CaloDets = CaloGeom->getValidDetIds();
191 +
192 +   for(unsigned int i=0;i<CaloDets.size();i++)
193 +   {
194 +      Detid  = CaloDets[i];
195 +      SubDet = Detid.subdetId();
196 +    
197 +       if(! (Detid.det()==DetId::Ecal||Detid.det()==DetId::Hcal)) continue;
198 +
199 +      //EcalBarrel=1, EcalEndcap=2, EcalPreshower=3, EcalTriggerTower=4, EcalLaserPnDiode=5
200 + //      if(SubDet!=EcalBarrel)continue;
201 +
202 +      const CaloCellGeometry* CellGeom = CaloGeom->getGeometry(Detid);
203 +      GlobalPoint CellPos =  CellGeom->getPosition();
204 +
205 +      const CaloCellGeometry::CornersVec CellCorners =  CellGeom->getCorners();
206 +
207 +      float Coord[24];
208 +      for(unsigned int i=0;i<8;i++){
209 +         Coord[i*3+0] = CellCorners[i].x();
210 +         Coord[i*3+1] = CellCorners[i].y();
211 +         Coord[i*3+2] = CellCorners[i].z();
212 +      }
213 +
214 +      Geom->Add_CaloDet(Detid.rawId(),
215 +                        CellPos.x(),   CellPos.y(),   CellPos.z(),
216 +                        Coord[0 ]  ,   Coord[1 ]  ,   Coord[2 ]  ,
217 +                        Coord[3 ]  ,   Coord[4 ]  ,   Coord[5 ]  ,
218 +                        Coord[6 ]  ,   Coord[7 ]  ,   Coord[8 ]  ,
219 +                        Coord[9 ]  ,   Coord[10]  ,   Coord[11]  ,
220 +                        Coord[12]  ,   Coord[13]  ,   Coord[14]  ,
221 +                        Coord[15]  ,   Coord[16]  ,   Coord[17]  ,
222 +                        Coord[18]  ,   Coord[19]  ,   Coord[20]  ,
223 +                        Coord[21]  ,   Coord[22]  ,   Coord[23]  );
224 +                        
225 +      printf("Det = %i Subdet = %i --> %6.2f %6.2f %6.2f - %i\n",  Detid.det(), SubDet, CellPos.x(), CellPos.y(), CellPos.z(), CellCorners.size());
226 +   }
227 +
228 +
229     Geom->Save("Tracker.geom");    
230  
231  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines