Newer
Older
#include "DDRec/Surface.h"
#include "DDRec/DetectorData.h"
#include "DD4hep/OpticalSurfaces.h"
#include "DD4hep/DetFactoryHelper.h"
#include "DD4hep/Printout.h"
//////////////////////////////////////////////////
// Far Forward Ion Zero Degree Calorimeter - Ecal
//////////////////////////////////////////////////
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using namespace std;
using namespace dd4hep;
static Ref_t createDetector(Detector& desc, xml_h e, SensitiveDetector sens)
{
xml_det_t x_det = e;
string detName = x_det.nameStr();
int detID = x_det.id();
xml_dim_t dim = x_det.dimensions();
double Width = dim.x();
double Thickness = dim.z();
xml_dim_t pos = x_det.position();
xml_dim_t rot = x_det.rotation();
Material Vacuum = desc.material("Vacuum");
xml_comp_t mod = x_det.child(_Unicode(module));
string modName = mod.nameStr();
Material mPbWO4 = desc.material(mod.materialStr());
double mThickness = mod.attr<double>(_Unicode(thickness));
double mWidth = mod.attr<double>(_Unicode(width));
double mGap = mod.attr<double>(_Unicode(gap));
int mNTowers = mod.attr<double>(_Unicode(ntower));
// Create Global Volume
Box ffi_ZDC_GVol_Solid(Width * 0.5, Width * 0.5, Thickness * 0.5);
Volume detVol("ffi_ZDC_GVol_Logic", ffi_ZDC_GVol_Solid, Vacuum);
detVol.setVisAttributes(desc.visAttributes(x_det.visStr()));
// Construct Tower
// Single Module
Box ffi_ZDC_ECAL_Solid_Tower(mWidth * 0.5, mWidth * 0.5, mThickness * 0.5);
Volume modVol("ffi_ZDC_ECAL_Logic_Tower", ffi_ZDC_ECAL_Solid_Tower, mPbWO4);
modVol.setVisAttributes(desc.visAttributes(mod.visStr()));
sens.setType("calorimeter");
modVol.setSensitiveDetector(sens);
// Module Position
double mod_x = 0.0 * mm;
double mod_y = 0.0 * mm;
double mod_z = -1.0 * Thickness / 2.0 + mThickness / 2.0 + 2.0 * mm;
int k = -1;
// Place Modules
for (int j = 0; j < mNTowers; j++) {
if (j == 0)
mod_y = Width / 2.0 - mWidth / 2.0 - mGap;
else
mod_y -= (mWidth + mGap);
if (abs(mod_y + mWidth / 2.0) > Width / 2.0)
continue;
mod_x = Width / 2.0 - (mWidth + mGap) * 0.5;
for (int i = 0; i < mNTowers; i++) {
if (i > 0)
mod_x -= (mWidth + mGap);
if (abs(mod_x + mWidth / 2.0) > Width / 2.0)
continue;
k++;
string module_name = detName + _toString(k,"_ECAL_Phys_%d");
PlacedVolume pv_mod = detVol.placeVolume(modVol, Position(mod_x,mod_y,mod_z));
}
}
DetElement det(detName, detID);
Volume motherVol = desc.pickMotherVolume(det);
Transform3D tr(RotationZYX(rot.z(), -rot.y(), rot.x()), Position(pos.x(), pos.y(), pos.z()));
PlacedVolume detPV = motherVol.placeVolume(detVol, tr);
detPV.addPhysVolID("system", detID);
det.setPlacement(detPV);
return det;
}