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" |
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/SimEvent.cpp" |
68 |
< |
|
69 |
< |
|
79 |
> |
#include "Visualisation/OpenGLDisplayer/interface/Geometry.h" |
80 |
|
|
81 |
|
using namespace edm; |
82 |
|
using namespace std; |
92 |
|
|
93 |
|
|
94 |
|
private: |
95 |
< |
virtual void beginJob(const edm::EventSetup&) ; |
96 |
< |
virtual void analyze(const edm::Event&, const edm::EventSetup&); |
97 |
< |
virtual void endJob() ; |
95 |
> |
virtual void beginJob(const edm::EventSetup& iSetup); |
96 |
> |
virtual void analyze (const edm::Event&, const edm::EventSetup&); |
97 |
> |
virtual void endJob (); |
98 |
|
|
99 |
|
|
100 |
|
MySimEvents* MyEvents; |
101 |
+ |
Geometry* Geom_Tracker; |
102 |
+ |
Geometry* Geom_ECAL; |
103 |
+ |
Geometry* Geom_HCAL; |
104 |
|
|
105 |
|
|
106 |
|
std::vector<std::string> SimHitSubdetectors; |
128 |
|
|
129 |
|
// ------------ method called once each job just before starting event loop ------------ |
130 |
|
void |
131 |
< |
OpenGLDisplayer::beginJob(const edm::EventSetup&) |
131 |
> |
OpenGLDisplayer::beginJob(const edm::EventSetup& iSetup) |
132 |
|
{ |
133 |
+ |
DetId Detid; |
134 |
+ |
int SubDet; |
135 |
+ |
|
136 |
+ |
MyEvents = new MySimEvents(); |
137 |
+ |
Geom_Tracker = new Geometry(); |
138 |
+ |
Geom_ECAL = new Geometry(); |
139 |
+ |
Geom_HCAL = new Geometry(); |
140 |
+ |
|
141 |
+ |
|
142 |
+ |
edm::ESHandle<TrackerGeometry> tkGeom; |
143 |
+ |
iSetup.get<TrackerDigiGeometryRecord>().get( tkGeom ); |
144 |
+ |
vector<GeomDet*> TrackerDets = tkGeom->dets(); |
145 |
+ |
|
146 |
+ |
for(unsigned int i=0;i<TrackerDets.size();i++){ |
147 |
+ |
Detid = TrackerDets[i]->geographicalId(); |
148 |
+ |
// SubDet = Detid.subdetId(); |
149 |
+ |
|
150 |
+ |
GeomDet* DetUnit = TrackerDets[i]; |
151 |
+ |
if(!DetUnit)continue; |
152 |
+ |
const BoundPlane plane = DetUnit->surface(); |
153 |
+ |
const TrapezoidalPlaneBounds* trapezoidalBounds( dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds()))); |
154 |
+ |
const RectangularPlaneBounds* rectangularBounds( dynamic_cast<const RectangularPlaneBounds*>(&(plane.bounds()))); |
155 |
+ |
|
156 |
+ |
float width = 0; |
157 |
+ |
float length = 0; |
158 |
+ |
float thickness = 0; |
159 |
+ |
float TrapezoidalParam = 0; |
160 |
+ |
|
161 |
+ |
if(trapezoidalBounds) |
162 |
+ |
{ |
163 |
+ |
std::vector<float> const & parameters = (*trapezoidalBounds).parameters(); |
164 |
+ |
width = parameters[0]*2; |
165 |
+ |
length = parameters[3]*2; |
166 |
+ |
thickness = (*trapezoidalBounds).thickness(); |
167 |
+ |
TrapezoidalParam = parameters[1]/parameters[0]; |
168 |
+ |
}else if(rectangularBounds){ |
169 |
+ |
width = DetUnit->surface().bounds().width(); |
170 |
+ |
length = DetUnit->surface().bounds().length(); |
171 |
+ |
thickness = DetUnit->surface().bounds().thickness(); |
172 |
+ |
TrapezoidalParam = 1; |
173 |
+ |
} |
174 |
+ |
|
175 |
+ |
Surface::GlobalPoint WidthVector = plane.toGlobal( LocalPoint(width/2, 0, 0) ); |
176 |
+ |
Surface::GlobalPoint LengthVector = plane.toGlobal( LocalPoint(0, length/2, 0) ); |
177 |
+ |
Surface::GlobalPoint ThickVector = plane.toGlobal( LocalPoint(0, 0, thickness/2) ); |
178 |
+ |
|
179 |
+ |
GlobalVector Pos = GlobalVector(DetUnit->position().basicVector()); |
180 |
+ |
|
181 |
+ |
Geom_Tracker->Add_TrackerDet(Detid.rawId(), TrapezoidalParam, |
182 |
+ |
Pos.x(), Pos.y(), Pos.z(), |
183 |
+ |
WidthVector.x() -Pos.x(), WidthVector.y() -Pos.y(), WidthVector.z() -Pos.z(), |
184 |
+ |
LengthVector.x()-Pos.x(), LengthVector.y()-Pos.y(), LengthVector.z()-Pos.z(), |
185 |
+ |
ThickVector.x() -Pos.x(), ThickVector.y() -Pos.y(), ThickVector.z() -Pos.z()); |
186 |
+ |
|
187 |
+ |
|
188 |
+ |
} |
189 |
+ |
|
190 |
+ |
|
191 |
+ |
// ### CALO GEOMETRY ### |
192 |
+ |
|
193 |
+ |
edm::ESHandle<CaloGeometry> CaloGeom; |
194 |
+ |
iSetup.get<IdealGeometryRecord>().get( CaloGeom ); |
195 |
+ |
const vector<DetId> CaloDets = CaloGeom->getValidDetIds(); |
196 |
+ |
|
197 |
+ |
for(unsigned int i=0;i<CaloDets.size();i++) |
198 |
+ |
{ |
199 |
+ |
Detid = CaloDets[i]; |
200 |
+ |
SubDet = Detid.subdetId(); |
201 |
+ |
|
202 |
+ |
Geometry* Geom_temp = NULL; |
203 |
+ |
if(Detid.det()==DetId::Ecal){ |
204 |
+ |
Geom_temp = Geom_ECAL; |
205 |
+ |
|
206 |
+ |
if(SubDet<1 || SubDet>3){ |
207 |
+ |
printf("Don't Save EcalTriggerTower or EcalLaserPnDiode\n"); |
208 |
+ |
continue; |
209 |
+ |
} |
210 |
+ |
}else if(Detid.det()==DetId::Hcal){ |
211 |
+ |
Geom_temp = Geom_HCAL; |
212 |
+ |
|
213 |
+ |
if(SubDet<1 || SubDet>4){ |
214 |
+ |
printf("Don't Save HcalEmpty, HcalTriggerTower, HcalOther\n"); |
215 |
+ |
continue; |
216 |
+ |
} |
217 |
+ |
}else{ |
218 |
+ |
continue; |
219 |
+ |
} |
220 |
+ |
|
221 |
+ |
const CaloCellGeometry* CellGeom = CaloGeom->getGeometry(Detid); |
222 |
+ |
GlobalPoint CellPos = CellGeom->getPosition(); |
223 |
+ |
const CaloCellGeometry::CornersVec CellCorners = CellGeom->getCorners(); |
224 |
+ |
|
225 |
+ |
Geom_temp->Add_CaloDet(Detid.rawId(), |
226 |
+ |
CellPos.x() , CellPos.y() , CellPos.z(), |
227 |
+ |
CellCorners[0].x() , CellCorners[0].y() , CellCorners[0].z() , |
228 |
+ |
CellCorners[1].x() , CellCorners[1].y() , CellCorners[1].z() , |
229 |
+ |
CellCorners[2].x() , CellCorners[2].y() , CellCorners[2].z() , |
230 |
+ |
CellCorners[3].x() , CellCorners[3].y() , CellCorners[3].z() , |
231 |
+ |
CellCorners[4].x() , CellCorners[4].y() , CellCorners[4].z() , |
232 |
+ |
CellCorners[5].x() , CellCorners[5].y() , CellCorners[5].z() , |
233 |
+ |
CellCorners[6].x() , CellCorners[6].y() , CellCorners[6].z() , |
234 |
+ |
CellCorners[7].x() , CellCorners[7].y() , CellCorners[7].z() ); |
235 |
+ |
} |
236 |
+ |
|
237 |
+ |
Geom_Tracker->Save("Tracker.geom"); |
238 |
+ |
Geom_ECAL->Save("ECAL.geom"); |
239 |
+ |
Geom_HCAL->Save("HCAL.geom"); |
240 |
|
|
241 |
|
|
122 |
– |
MyEvents = new MySimEvents(); |
242 |
|
|
243 |
|
} |
244 |
|
|