9 #include <framework/gearbox/GearDir.h>
10 #include <framework/logging/Logger.h>
11 #include <framework/gearbox/Unit.h>
13 #include <arich/dbobjects/ARICHGeometryConfig.h>
14 #include <arich/dbobjects/tessellatedSolidStr.h>
16 #include <geometry/Materials.h>
17 #include <arich/dbobjects/ARICHGeoHAPD.h>
25 ARICHGeometryConfig::ARICHGeometryConfig(
const GearDir& content)
30 void ARICHGeometryConfig::read(
const GearDir& content)
35 m_bbstudy = content.getInt(
"BeamBackgroundStudy");
37 GearDir envParams(content,
"Envelope");
39 std::string(
"ARICH_Air"));
40 m_masterVolume.setPlacement(envParams.
getLength(
"xPosition"), envParams.
getLength(
"yPosition"),
44 GearDir displParams(content,
"GlobalDisplacement");
45 m_displaceGlobal = !displParams.
getBool(
"Disable");
46 m_globalDispl.setX(displParams.
getLength(
"x"));
47 m_globalDispl.setY(displParams.
getLength(
"y"));
48 m_globalDispl.setZ(displParams.
getLength(
"z"));
49 m_globalDispl.setAlpha(displParams.
getAngle(
"alpha"));
50 m_globalDispl.setBeta(displParams.
getAngle(
"beta"));
51 m_globalDispl.setGamma(displParams.
getAngle(
"gamma"));
53 auto& materials = geometry::Materials::getInstance();
55 GearDir detParams(content,
"Detector/Module");
57 m_hapd.setWallThickness(detParams.
getLength(
"HAPD/windowThickness"));
58 m_hapd.setPadSize(detParams.
getLength(
"HAPD/padSize"));
59 m_hapd.setChipGap(detParams.
getLength(
"HAPD/chipGap"));
60 m_hapd.setNPads(
int(
sqrt(detParams.
getInt(
"HAPD/padNum"))),
int(
sqrt(detParams.
getInt(
"HAPD/padNum"))));
61 m_hapd.setWinThickness(detParams.
getLength(
"HAPD/windowThickness"));
62 m_hapd.setWinRefIndex(detParams.
getDouble(
"HAPD/windowRefIndex"));
63 m_hapd.setModuleSizeZ(detParams.
getLength(
"height"));
64 m_hapd.setWallMaterial(detParams.
getString(
"HAPD/wallMaterial"));
65 m_hapd.setWinMaterial(detParams.
getString(
"HAPD/windowMaterial"));
70 detParams.
getString(
"HAPD/fillMaterial"));
72 GearDir apdSurfParams(detParams,
"HAPD/Surface");
73 m_hapd.setAPDVolume(detParams.
getLength(
"HAPD/apdSize"), detParams.
getLength(
"HAPD/apdSize"),
75 materials.createOpticalSurfaceConfig(apdSurfParams));
77 GearDir mergerParams(content,
"MergerPCB");
79 m_merger.setMergerPCBMaterialName(mergerParams.
getString(
"merger/material"));
80 m_merger.setMergerPCBLenght(mergerParams.
getDouble(
"merger/sizeL"));
81 m_merger.setMergerPCBWidth(mergerParams.
getDouble(
"merger/sizeW"));
82 m_merger.setMergerPCBThickness(mergerParams.
getDouble(
"merger/thickness"));
83 m_merger.setMergerPCBscrewholeR(mergerParams.
getDouble(
"merger/mergerPCBscrewholeR"));
84 m_merger.setMergerPCBscrewholePosdY(mergerParams.
getDouble(
"merger/mergerPCBscrewholePosdY"));
85 m_merger.setMergerPCBscrewholePosdX1(mergerParams.
getDouble(
"merger/mergerPCBscrewholePosdX1"));
86 m_merger.setMergerPCBscrewholePosdX2(mergerParams.
getDouble(
"merger/mergerPCBscrewholePosdX2"));
87 m_merger.setSingleMergerEnvelopeSizeL(mergerParams.
getDouble(
"merger/envelopeSizeL"));
88 m_merger.setSingleMergerEnvelopeSizeW(mergerParams.
getDouble(
"merger/envelopeSizeW"));
89 m_merger.setSingleMergerEnvelopeThickness(mergerParams.
getDouble(
"merger/envelopeThickness"));
90 m_merger.setSingleMergerenvelopeDeltaZ(mergerParams.
getArray(
"merger/envelopeDeltaZ"));
91 m_merger.setMergerSlotID(mergerParams.
getArray(
"merger/mergerSlotID"));
92 m_merger.setMergerPosR(mergerParams.
getArray(
"merger/mergerPosR"));
93 m_merger.setMergerAngle(mergerParams.
getArray(
"merger/mergerAngle"));
94 m_merger.setMergerOrientation(mergerParams.
getArray(
"merger/mergerOrientation"));
95 m_merger.setEnvelopeCenterPosition(mergerParams.
getDouble(
"mergerEnvelope/x0"),
96 mergerParams.
getDouble(
"mergerEnvelope/y0"),
97 mergerParams.
getDouble(
"mergerEnvelope/z0"));
98 m_merger.setSingleMergeEnvelopePosition(mergerParams.
getDouble(
"merger/envelopePosX0"),
99 mergerParams.
getDouble(
"merger/envelopePosY0"),
100 mergerParams.
getDouble(
"merger/envelopePosZ0"));
101 m_merger.setEnvelopeOuterRadius(mergerParams.
getDouble(
"mergerEnvelope/outerRadius"));
102 m_merger.setEnvelopeInnerRadius(mergerParams.
getDouble(
"mergerEnvelope/innerRadius"));
103 m_merger.setEnvelopeThickness(mergerParams.
getDouble(
"mergerEnvelope/thickness"));
104 m_merger.checkMergerPositionsDataConsistency();
107 GearDir cablesEnvelopParams(content,
"cablesEnvelope");
109 m_cablesenvelope.setCablesEffectiveMaterialName(cablesEnvelopParams.
getString(
"material"));
110 m_cablesenvelope.setEnvelopeOuterRadius(cablesEnvelopParams.
getDouble(
"outerRadius"));
111 m_cablesenvelope.setEnvelopeInnerRadius(cablesEnvelopParams.
getDouble(
"innerRadius"));
112 m_cablesenvelope.setEnvelopeThickness(cablesEnvelopParams.
getDouble(
"thickness"));
113 m_cablesenvelope.setEnvelopeCenterPosition(cablesEnvelopParams.
getDouble(
"x0"), cablesEnvelopParams.
getDouble(
"y0"),
115 m_cablesenvelope.checkCablesEnvelopDataConsistency();
118 GearDir coolingParams(content,
"coolingPipe");
120 m_cooling.setEnvelopeOuterRadius(coolingParams.
getDouble(
"coolingEnvelope/outerRadius"));
121 m_cooling.setEnvelopeInnerRadius(coolingParams.
getDouble(
"coolingEnvelope/innerRadius"));
122 m_cooling.setEnvelopeThickness(coolingParams.
getDouble(
"coolingEnvelope/thickness"));
123 m_cooling.setEnvelopeCenterPosition(coolingParams.
getDouble(
"coolingEnvelope/x0"), coolingParams.
getDouble(
"coolingEnvelope/y0"),
124 coolingParams.
getDouble(
"coolingEnvelope/z0"));
125 m_cooling.setCoolingPipeMaterialName(coolingParams.
getString(
"cooling/material"));
126 m_cooling.setRmin(coolingParams.
getDouble(
"cooling/Rmin"));
127 m_cooling.setRmax(coolingParams.
getDouble(
"cooling/Rmax"));
128 m_cooling.setCoolingGeometryID(coolingParams.
getArray(
"cooling/coolingGeometryID"));
129 m_cooling.setCoolingL(coolingParams.
getArray(
"cooling/coolingL"));
130 m_cooling.setCoolingPosPhi(coolingParams.
getArray(
"cooling/coolingPosPhi"));
131 m_cooling.setCoolingPosR(coolingParams.
getArray(
"cooling/coolingPosR"));
132 m_cooling.setCoolinRotationAngle(coolingParams.
getArray(
"cooling/coolinRotationAngle"));
133 m_cooling.setCoolingTestPlateMaterialName(coolingParams.
getString(
"coolingTestPlate/material"));
134 m_cooling.setColdTubeMaterialName(coolingParams.
getString(
"coolingTestPlate/materialColdTube"));
135 m_cooling.setCoolingTestPlateslengths(coolingParams.
getDouble(
"coolingTestPlate/lengthX"),
136 coolingParams.
getDouble(
"coolingTestPlate/lengthY"), coolingParams.
getDouble(
"coolingTestPlate/lengthZ"));
137 m_cooling.setColdTubeR(coolingParams.
getDouble(
"coolingTestPlate/coldTubeR"));
138 m_cooling.setColdTubeSubtractedR(coolingParams.
getDouble(
"coolingTestPlate/coldTubeSubtractedR"));
139 m_cooling.setColdTubeWallThickness(coolingParams.
getDouble(
"coolingTestPlate/coldTubeWallThickness"));
140 m_cooling.setDepthColdTubeInPlate(coolingParams.
getDouble(
"coolingTestPlate/depthColdTubeInPlate"));
141 m_cooling.setColdTubeSpacing(coolingParams.
getDouble(
"coolingTestPlate/coldTubeSpacing"));
142 m_cooling.setColdTubeNumber(coolingParams.
getInt(
"coolingTestPlate/coldTubeNumber"));
143 m_cooling.setCoolingTestPlatePosR(coolingParams.
getArray(
"coolingTestPlate/coolingTestPlatePosR"));
144 m_cooling.setCoolingTestPlatePosPhi(coolingParams.
getArray(
"coolingTestPlate/coolingTestPlatePosPhi"));
145 m_cooling.setCoolingTestPlatePosZ0(coolingParams.
getArray(
"coolingTestPlate/coolingTestPlatePosZ0"));
146 m_cooling.checkCoolingSystemDataConsistency();
149 GearDir coolingFEBParams(content,
"febcoolingv2");
152 m_coolingv2.setSmallSquareSize(coolingFEBParams.
getDouble(
"smallSquareSize"));
153 m_coolingv2.setSmallSquareThickness(coolingFEBParams.
getDouble(
"smallSquareThickness"));
154 m_coolingv2.setBigSquareSize(coolingFEBParams.
getDouble(
"bigSquareSize"));
155 m_coolingv2.setBigSquareThickness(coolingFEBParams.
getDouble(
"bigSquareThickness"));
156 m_coolingv2.setRectangleL(coolingFEBParams.
getDouble(
"rectangleL"));
157 m_coolingv2.setRectangleW(coolingFEBParams.
getDouble(
"rectangleW"));
158 m_coolingv2.setRectangleThickness(coolingFEBParams.
getDouble(
"rectangleThickness"));
159 m_coolingv2.setRectangleDistanceFromCenter(coolingFEBParams.
getDouble(
"rectangleDistanceFromCenter"));
160 m_coolingv2.setFebcoolingv2GeometryID(coolingFEBParams.
getArray(
"febcoolingv2GeometryID"));
163 modulesPosition(content);
165 GearDir mirrParams(content,
"Mirrors");
167 m_mirrors.setNMirrors(mirrParams.
getInt(
"nMirrors"));
168 m_mirrors.setStartAngle(mirrParams.
getAngle(
"startAngle"));
169 GearDir surfParams(mirrParams,
"Surface");
171 mirrParams.
getString(
"material"), materials.createOpticalSurfaceConfig(surfParams));
172 m_mirrors.setZPosition(mirrParams.
getLength(
"zPosition") + mirrParams.
getLength(
"width") / 2. - m_masterVolume.getLength() / 2.);
173 m_mirrors.setRadius(mirrParams.
getLength(
"radius"));
174 m_mirrors.initializeDefault();
177 GearDir mirrDisplParams(content,
"MirrorDisplacement");
178 if (mirrDisplParams) {
179 m_displaceMirrors = !mirrDisplParams.
getBool(
"Disable");
180 for (
auto plate : mirrDisplParams.
getNodes(
"Plate")) {
181 int id = plate.getInt(
"@id");
182 double r = plate.getLength(
"r");
183 double phi = plate.getAngle(
"phi");
184 double z = plate.getLength(
"z");
185 double alpha = plate.getLength(
"alpha");
186 double beta = plate.getLength(
"beta");
187 double gamma = plate.getLength(
"gamma");
188 double origPhi = m_mirrors.getPoint(
id).Phi();
189 ARICHPositionElement displEl(r * cos(origPhi + phi), r * sin(origPhi + phi), z, alpha, beta, gamma);
190 m_mirrorDispl.setDisplacementElement(
id, displEl);
195 GearDir aerogel(content,
"Aerogel");
197 std::vector<double> dPhi;
198 std::vector<int> nAeroSlotsIndividualRing;
199 for (
auto ring : aerogel.
getNodes(
"slotInRing/Ring")) {
200 dPhi.push_back(2.* M_PI / ring.getInt());
201 nAeroSlotsIndividualRing.push_back(ring.getInt());
203 std::vector<double> slotR;
204 for (
auto ring : aerogel.
getNodes(
"slotR/Ring")) {
205 slotR.push_back(ring.getLength());
208 m_aerogelPlane.setWallRadius(slotR);
209 m_aerogelPlane.setWallDPhi(dPhi);
210 m_aerogelPlane.setNAeroSlotsIndividualRing(nAeroSlotsIndividualRing);
211 m_aerogelPlane.setTileGap(aerogel.
getLength(
"tileGap"));
214 m_aerogelPlane.setWallThickness(aerogel.
getLength(
"wallThickness"));
215 m_aerogelPlane.setWallHeight(aerogel.
getLength(
"wallHeight"));
216 m_aerogelPlane.addSupportPlate(aerogel.
getLength(
"plateInnerR"), aerogel.
getLength(
"plateOuterR"),
219 for (
auto layer : aerogel.
getNodes(
"Layers/Layer")) {
220 double thick = layer.getLength(
"thickness") / Unit::cm;
221 std::string material = layer.getString(
"material");
222 double refIndex = layer.getDouble(
"refIndex");
223 double trLen = layer.getLength(
"trLength");
224 m_aerogelPlane.setAerogelLayer(ilayer, thick, refIndex, trLen, material);
228 m_aerogelPlane.setFullAerogelMaterialDescriptionKey(aerogel.
getInt(
"fullAerogelMaterialDescriptionKey"));
229 m_aerogelPlane.setImgTubeThickness(aerogel.
getDouble(
"imgTubeThickness"));
230 m_aerogelPlane.setCompensationARICHairVolumeThick_min(aerogel.
getDouble(
"compensationARICHairVolumeThick_min"));
233 GearDir aerotilesDir(content,
"AerogelTiles");
234 for (
int il = 0; il < ilayer - 1; il++) {
236 for (
auto ns_ring : nAeroSlotsIndividualRing) {
238 for (
int islot = 1; islot < ns_ring + 1; islot++) {
239 for (
auto tileNode : aerotilesDir.
getNodes(
"Tiles/Tile")) {
240 int ring = tileNode.getInt(
"ring");
241 int column = tileNode.getInt(
"column");
242 int layerN = tileNode.getInt(
"layer");
243 if (iring == ring && column == islot && il == layerN) {
244 double n = tileNode.getDouble(
"n");
245 double transmL = tileNode.getDouble(
"transmL");
246 double thick = tileNode.getDouble(
"thick");
247 std::string materialName = tileNode.getString(
"material");
248 m_aerogelPlane.addTileParameters(ring, column, layerN, n, transmL, thick, materialName);
255 if (m_aerogelPlane.getFullAerogelMaterialDescriptionKey() == 0) {
256 m_aerogelPlane.setPlacement(0.0, 0.0,
259 m_masterVolume.getLength() / 2.0,
261 }
else if (m_aerogelPlane.getFullAerogelMaterialDescriptionKey() == 1) {
262 double wallHeightNew = m_aerogelPlane.getMaximumTotalTileThickness() + m_aerogelPlane.getCompensationARICHairVolumeThick_min();
263 wallHeightNew = wallHeightNew / 10.0;
267 m_aerogelPlane.setPlacement(0.0, 0.0,
269 (wallHeightNew + aerogel.
getLength(
"plateThickness") + aerogel.
getLength(
"imgTubeThickness")) / 2.0 - m_masterVolume.getLength() /
273 B2ERROR(
"ARICHGeometryConfig::read --> getFullAerogelMaterialDescriptionKey() is wrong");
279 m_aerogelPlane.isConsistent();
282 GearDir supportDir(content,
"SupportStructure");
283 for (
auto tube : supportDir.
getNodes(
"Tubes/Tube")) {
284 std::string material = tube.getString(
"material");
285 double innerR = tube.getLength(
"innerR");
286 double outerR = tube.getLength(
"outerR");
287 double length = tube.getLength(
"length");
288 double zPosition = tube.getLength(
"zPosition") - m_masterVolume.getLength() / 2.;
289 std::string name = tube.getString(
"name");
290 m_supportStructure.addTube(innerR, outerR, length, zPosition, material, name);
294 m_supportStructure.setMaterial(supportDir.
getString(
"material"));
296 for (
auto wedge : supportDir.
getNodes(
"Wedges/Wedge")) {
297 std::vector<double> pars;
298 int id = wedge.getInt(
"@id");
299 if (
id > 3 ||
id < 1)
continue;
300 for (
auto par : wedge.getNodes(
"par")) {
301 pars.push_back(par.getLength());
303 m_supportStructure.setWedge(
id, pars);
306 for (
auto wedge : supportDir.
getNodes(
"Wedges/Placements/Placement")) {
307 int type = wedge.getInt(
"type");
308 double r = wedge.getLength(
"r");
309 double phi = wedge.getAngle(
"phi");
310 double z = wedge.getLength(
"z") - m_masterVolume.getLength() / 2.;
311 m_supportStructure.addWedge(type, r, phi, z, supportDir.
getString(
"material"));
318 void ARICHGeometryConfig::print(
const std::string& title)
const
320 ARICHGeoBase::print(title);
321 m_detectorPlane.print();
324 m_cablesenvelope.print();
326 m_masterVolume.print();
327 m_aerogelPlane.print();
328 m_aerogelPlane.printTileParameters();
330 m_supportStructure.print();
333 void ARICHGeometryConfig::modulesPosition(
const GearDir& content)
336 GearDir detParams(content,
"Detector/Plane");
338 std::vector<std::pair<double, double>> ringPar;
340 for (
auto ring : detParams.
getNodes(
"Rings/Ring")) {
341 double r = ring.getLength(
"r");
342 int nMod = ring.getInt(
"nModules");
343 ringPar.push_back({r, 2.*M_PI / nMod});
346 m_detectorPlane.setRingPar(ringPar);
348 GearDir supportParams(content,
"Detector/supportPlate");
349 double modHeight = content.getLength(
"Detector/Module/height");
350 m_detectorPlane.addSupportPlate(supportParams.
getLength(
"innerRadius"), supportParams.
getLength(
"outerRadius"),
352 m_detectorPlane.setModuleHoleSize(supportParams.
getLength(
"moduleHoleSize"));
353 m_detectorPlane.setSupportZPosition(supportParams.
getLength(
"zPosition") + (supportParams.
getLength(
"thickness") +
354 supportParams.
getLength(
"backWallHeight")) / 2. - m_masterVolume.getLength() / 2.);
355 m_detectorPlane.setSupportBackWallHeight(supportParams.
getLength(
"backWallHeight"));
356 m_detectorPlane.setSupportBackWallThickness(supportParams.
getLength(
"backWallThickness"));
358 m_detectorPlane.setPlacement(0.0, 0.0, detParams.
getLength(
"zPosition") + modHeight / 2. - m_masterVolume.getLength() / 2., 0.0,
378 TVector2 ARICHGeometryConfig::getChannelPosition(
unsigned moduleID,
unsigned chX,
unsigned chY)
const
381 origin.SetMagPhi(m_detectorPlane.getSlotR(moduleID), m_detectorPlane.getSlotPhi(moduleID));
383 m_hapd.getXYChannelPos(chX, chY, x, y);
384 TVector2 locPos(x, y);
385 return origin + locPos.Rotate(m_detectorPlane.getSlotPhi(moduleID));
Position element for ARICH.
GearDir is the basic class used for accessing the parameter store.
virtual std::string getString(const std::string &path="") const noexcept(false) override
Get the parameter path as a string.
double getAngle(const std::string &path="") const noexcept(false)
Get the parameter path as a double converted to the standard angle unit.
std::vector< double > getArray(const std::string &path) const noexcept(false)
Get the parameter path as a list of double values converted to the standard unit.
double getDouble(const std::string &path="") const noexcept(false)
Get the parameter path as a double.
double getLength(const std::string &path="") const noexcept(false)
Get the parameter path as a double converted to the standard length unit.
std::vector< GearDir > getNodes(const std::string &path="") const
Get vector of GearDirs which point to all the nodes the given path evaluates to.
bool getBool(const std::string &path="") const noexcept(false)
Get the parameter path as a bool.
int getInt(const std::string &path="") const noexcept(false)
Get the parameter path as a int.
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.