Belle II Software  release-05-01-25
GeoARICHBtestCreator.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Luka Santelj, Rok Pestotnik *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #include <sstream>
11 #include <string.h>
12 #include <boost/format.hpp>
13 #include <boost/foreach.hpp>
14 #include <boost/algorithm/string.hpp>
15 
16 //#include <geant4/G4LogicalVolume.hh>
17 
18 // Geant4
19 #include <G4LogicalVolume.hh>
20 #include <G4PVPlacement.hh>
21 #include <G4LogicalSkinSurface.hh>
22 #include <G4OpticalSurface.hh>
23 // Geant4 Shapes
24 #include <G4Box.hh>
25 #include <G4SubtractionSolid.hh>
26 #include <G4Material.hh>
27 
28 #include <Python.h>
29 
30 #include <arich/geometry/GeoARICHBtestCreator.h>
31 #include <arich/geometry/ARICHGeometryPar.h>
32 #include <arich/geometry/ARICHBtestGeometryPar.h>
33 
34 #include <geometry/Materials.h>
35 #include <geometry/CreatorFactory.h>
36 #include <geometry/utilities.h>
37 #include <framework/gearbox/GearDir.h>
38 #include <framework/gearbox/Unit.h>
39 #include <framework/logging/Logger.h>
40 // Framework - DataStore
41 #include <framework/datastore/StoreObjPtr.h>
42 #include <framework/dataobjects/EventMetaData.h>
43 
44 #include <arich/simulation/SensitiveDetector.h>
45 #include <arich/simulation/SensitiveAero.h>
46 
47 using namespace std;
48 using namespace boost;
49 
50 namespace Belle2 {
56  using namespace geometry;
57 
58  namespace arich {
59 
60  //-----------------------------------------------------------------
61  // Register the Creator
62  //-----------------------------------------------------------------
63 
64  geometry::CreatorFactory<GeoARICHBtestCreator> GeoARICHBtestFactory("ARICHBtestCreator");
65 
66  //-----------------------------------------------------------------
67  // Implementation
68  //-----------------------------------------------------------------
69 
70  GeoARICHBtestCreator::GeoARICHBtestCreator():
71  m_sensitive(new SensitiveDetector),
72  m_sensitiveAero(new SensitiveAero),
73  m_runno(0),
74  m_neve(0),
75  m_rotation(0),
76  m_rx(0),
77  m_ry(0),
78  m_aerosupport(0),
79  m_aerogeldx(0),
80  m_framedx(0),
81  m_rotation1(0),
82  m_configuration(0)
83  {};
84 
86  {
87 
88  }
89 
90 
91  void GeoARICHBtestCreator::create(const GearDir& content, G4LogicalVolume& topVolume, GeometryTypes)
92  {
93 
94  B2INFO("GeoARICHBtestCreator::create");
95  StoreObjPtr<EventMetaData> eventMetaDataPtr;
96 
97  int run = 68;
98  PyObject* m = PyImport_AddModule(strdup("__main__"));
99  if (m) {
100  PyObject* v = PyObject_GetAttrString(m, strdup("runno"));
101  if (v) {
102  run = PyLong_AsLong(v);
103  Py_DECREF(v);
104  }
105  B2INFO("GeoARICHBtestCreator::create runno = " << run);
106  }
107 
108  B2INFO("eventMetaDataPtr run:" << run);
109  // eventMetaDataPtr->setEndOfData();
110 
111 
112 
113 
114  string Type = content.getString("@type", "");
115 
116  char nodestr[100];
117  sprintf(nodestr, "run[runno=%d]", run);
118  if (Type == "beamtest") {
119  BOOST_FOREACH(const GearDir & runparam, content.getNodes(nodestr)) {
120  m_runno = runparam.getInt("runno", -1);
121  m_author = runparam.getString("author", "");
122  m_neve = runparam.getInt("neve", -1);
123  m_runtype = runparam.getString("calibration", "pion");
124  m_hapdID = runparam.getString("setup1", "unknown");
125  m_aerogelID = runparam.getString("aerogel1", "unknown");
126  m_mirrorID = runparam.getString("mirror", "unknown");
127  m_rotation = runparam.getDouble("rotation", 0);
128  m_rx = runparam.getDouble("positionx", 0);
129  m_ry = runparam.getDouble("positiony", 0);
130  m_mytype = runparam.getString("type1", "unknown");
131  m_daqqa = runparam.getString("daqqa1", "unknown");
132  m_comment = runparam.getString("comment1", "unknown");
133  m_datum = runparam.getString("datum", "unknown");
134 
135 
136  B2INFO("runno : " << m_runno);
137  B2INFO("author : " << m_author);
138  B2INFO("neve : " << m_neve);
139  B2INFO("runtype : " << m_runtype);
140  B2INFO("hapdID : " << m_hapdID);
141  B2INFO("aerogelID: " << m_aerogelID);
142  B2INFO("mirrorID : " << m_mirrorID);
143  B2INFO("rotation : " << m_rotation);
144  B2INFO("rx : " << m_rx);
145  B2INFO("ry : " << m_ry);
146  B2INFO("runtype : " << m_mytype);
147  B2INFO("daqqa : " << m_daqqa);
148  B2INFO("comment : " << m_comment);
149  B2INFO("datum : " << m_datum);
150 
151 
152  }
153  string aerogelname;
154  sprintf(nodestr, "setup/aerogel/row[@id=\"%s\"]", m_aerogelID.c_str());
155 
156  GearDir runparam(content, nodestr);
157  B2INFO("id : " << runparam.getString("@id", ""));
158  BOOST_FOREACH(const GearDir & aeroparam, runparam.getNodes("aerogel")) {
159  aerogelname = aeroparam.getString(".", "");
160  string stype = aeroparam.getString("@type", "");
161  B2INFO(stype << " aerogelname : " << aerogelname);
162  sprintf(nodestr, "setup/aerogelinfo/row[@id=\"%s\"]", aerogelname.c_str());
163  GearDir infoparam(content, nodestr);
164 
165  double agelrefind = infoparam.getDouble("refind", 1);
166  double ageltrlen = infoparam.getLength("trlen", 0);
167  double agelthickness = infoparam.getLength("thickness", 0);
168  if (stype != string("left")) {
169  m_ageltrlen.push_back(ageltrlen);
170  m_agelrefind.push_back(agelrefind);
171  m_agelthickness.push_back(agelthickness);
172  }
173  B2INFO("refind : " << agelrefind);
174  B2INFO("trlen : " << ageltrlen / Unit::mm);
175  B2INFO("thickness : " << agelthickness / Unit::mm);
176 
177  }
178  int size = m_hapdID.size();
179 
180  m_aerosupport = 0;
181  if (size > 0) {
182  char agelsupport = m_hapdID.at(size - 1);
183  if (agelsupport == 'a') m_aerosupport = 1;
184  if (agelsupport == 'b') m_aerosupport = 2;
185  }
186 
187  if (m_aerosupport) size--;
188  sprintf(nodestr, "setup/hapd/row[@id=\"%s\"]", m_hapdID.substr(0, size).c_str());
189  B2INFO("nodestr : " << nodestr);
190  B2INFO("aerogelsupport : " << m_aerosupport);
191  GearDir hapdparam(content, nodestr);
192  //BOOST_FOREACH(const GearDir & runparam, content.getNodes(nodestr)) {
193  m_aerogeldx = hapdparam.getLength("aerogeldx", 0);
194  m_framedx = hapdparam.getLength("framedx", 0) * CLHEP::mm / Unit::mm ;
195  m_rotation1 = hapdparam.getDouble("rotation", 0);
196  m_configuration = hapdparam.getInt("setup", 0);
197  m_comment1 = hapdparam.getString("comment", "");
198 
199 
200  B2INFO("aerogeldx : " << m_aerogeldx);
201  B2INFO("framedx : " << m_framedx);
202  B2INFO("rotation : " << m_rotation1);
203  B2INFO("configuration : " << m_configuration);
204  B2INFO("comment : " << m_comment);
205  //}
206 
207  GearDir setup(content, "setup");
208 
209  createBtestGeometry(setup, topVolume);
210  }
211  }
212 
213  double GeoARICHBtestCreator::getAvgRINDEX(G4Material* material)
214  {
215  G4MaterialPropertiesTable* mTable = material->GetMaterialPropertiesTable();
216  if (!mTable) return 0;
217  G4MaterialPropertyVector* mVector = mTable->GetProperty("RINDEX");
218  if (!mVector) return 0;
219  G4bool b;
220  return mVector->GetValue(2 * Unit::eV / Unit::MeV, b);
221  }
222 
224  {
225 
226  // get detector module parameters
227 
228  // get module materials
229  string wallMat = Module.getString("wallMaterial");
230  string winMat = Module.getString("windowMaterial");
231  string botMat = Module.getString("Bottom/material");
232  G4Material* wallMaterial = Materials::get(wallMat);
233  G4Material* windowMaterial = Materials::get(winMat);
234  G4Material* bottomMaterial = Materials::get(botMat);
235  G4Material* boxFill = Materials::get("ARICH_Vacuum");
236 
237  // check that module window material has specified refractive index
238  double wref = getAvgRINDEX(windowMaterial);
239  if (!wref) B2WARNING("Material '" << winMat <<
240  "', required for ARICH photon detector window as no specified refractive index. Continuing, but no photons in ARICH will be detected.");
242  m_arichgp->setWindowRefIndex(wref);
243  // get module dimensions
244  double modXsize = Module.getLength("moduleXSize") / Unit::mm;
245  double modZsize = Module.getLength("moduleZSize") / Unit::mm;
246  double wallThick = Module.getLength("moduleWallThickness") / Unit::mm;
247  double winThick = Module.getLength("windowThickness") / Unit::mm ;
248  double sensXsize = m_arichgp->getSensitiveSurfaceSize() / Unit::mm;
249  double botThick = Module.getLength("Bottom/thickness") / Unit::mm;
250 
251  // some trivial checks of overlaps
252  if (sensXsize > modXsize - 2 * wallThick)
253  B2FATAL("ARICH photon detector module: Sensitive surface is too big. Doesn't fit into module box.");
254  if (winThick + botThick > modZsize)
255  B2FATAL("ARICH photon detector module: window + bottom thickness larger than module thickness.");
256 
257  // module master volume
258  G4Box* moduleBox = new G4Box("Box", modXsize / 2., modXsize / 2., modZsize / 2.);
259  G4LogicalVolume* lmoduleBox = new G4LogicalVolume(moduleBox, boxFill, "moduleBox");
260 
261  // build and place module wall
262  G4Box* tempBox = new G4Box("tempBox", modXsize / 2. - wallThick, modXsize / 2. - wallThick,
263  modZsize / 2. + 0.1); // Dont't care about "+0.1", needs to be there.
264  G4SubtractionSolid* moduleWall = new G4SubtractionSolid("Box-tempBox", moduleBox, tempBox);
265  G4LogicalVolume* lmoduleWall = new G4LogicalVolume(moduleWall, wallMaterial, "moduleWall");
266  setColor(*lmoduleWall, "rgb(1.0,0.0,0.0,1.0)");
267  new G4PVPlacement(G4Transform3D(), lmoduleWall, "moduleWall", lmoduleBox, false, 1);
268 
269  // build module window
270  G4Box* winBox = new G4Box("winBox", modXsize / 2. - wallThick, modXsize / 2. - wallThick, winThick / 2.);
271  G4LogicalVolume* lmoduleWin = new G4LogicalVolume(winBox, windowMaterial, "moduleWindow");
272  setColor(*lmoduleWin, "rgb(0.7,0.7,0.7,1.0)");
273  G4Transform3D transform = G4Translate3D(0., 0., (-modZsize + winThick) / 2.);
274  new G4PVPlacement(transform, lmoduleWin, "moduleWindow", lmoduleBox, false, 1);
275 
276  // build module bottom
277  G4Box* botBox = new G4Box("botBox", modXsize / 2. - wallThick, modXsize / 2. - wallThick, botThick / 2.);
278  G4LogicalVolume* lmoduleBot = new G4LogicalVolume(botBox, bottomMaterial, "moduleBottom");
279  // if (isBeamBkgStudy) lmoduleBot->SetSensitiveDetector(new BkgSensitiveDetector("ARICH", 1));
280  setColor(*lmoduleBot, "rgb(0.0,1.0,0.0,1.0)");
281  G4Transform3D transform1 = G4Translate3D(0., 0., (modZsize - botThick) / 2.);
282  // add surface optical properties if specified
283  Materials& materials = Materials::getInstance();
284  GearDir bottomParam(Module, "Bottom/Surface");
285  if (bottomParam) {
286  G4OpticalSurface* optSurf = materials.createOpticalSurface(bottomParam);
287  new G4LogicalSkinSurface("bottomSurface", lmoduleBot, optSurf);
288  } else B2INFO("ARICH: No optical properties are specified for detector module bottom surface.");
289  new G4PVPlacement(transform1, lmoduleBot, "moduleBottom", lmoduleBox, false, 1);
290 
291  // build sensitive surface
292  G4Box* sensBox = new G4Box("sensBox", sensXsize / 2., sensXsize / 2., 0.1 * Unit::mm);
293  G4LogicalVolume* lmoduleSens = new G4LogicalVolume(sensBox, boxFill, "moduleSensitive");
294  lmoduleSens->SetSensitiveDetector(m_sensitive);
295  setColor(*lmoduleSens, "rgb(0.5,0.5,0.5,1.0)");
296  G4Transform3D transform2 = G4Translate3D(0., 0., (-modZsize + 0.1) / 2. + winThick);
297  new G4PVPlacement(transform2, lmoduleSens, "moduleSensitive", lmoduleBox, false, 1);
298 
299  // module is build, return module logical volume
300  return lmoduleBox;
301  }
302 
303 
304  G4Material* GeoARICHBtestCreator::createAerogel(const char* aeroname, double RefractiveIndex, double AerogelTransmissionLength)
305  {
306 
307 
308  G4double density = (RefractiveIndex - 1) / 0.21 * CLHEP::g / CLHEP::cm3;
309  B2INFO("Creating ARICH " << aeroname << " n=" << RefractiveIndex << " density=" << density / CLHEP::g * CLHEP::cm3 << " g/cm3");
310  Materials& materials = Materials::getInstance();
311  G4Material* _aerogel = new G4Material(aeroname, density, 4);
312  _aerogel->AddElement(materials.getElement("O") , 0.665);
313  _aerogel->AddElement(materials.getElement("H") , 0.042);
314  _aerogel->AddElement(materials.getElement("Si") , 0.292);
315  _aerogel->AddElement(materials.getElement("C") , 0.001);
316 
317 
318  const G4double AerogelAbsorbtionLength = 1000 * Unit::mm;
319 
320  const G4int NBins = 40;
321  G4double MomentumBins[NBins];
322 
323  G4double AerogelRindex[NBins];
324  G4double AerogelAbsorption[NBins];
325  G4double AerogelRayleigh[NBins];
326 
327  G4double MaxPhotonEnergy = 5 * CLHEP::eV;
328  G4double MinPhotonEnergy = 1.5 * CLHEP::eV;
329 
330  for (G4int i = 0; i < NBins; i++) {
331 
332  const G4double energy = float(i) / NBins * (MaxPhotonEnergy - MinPhotonEnergy) + MinPhotonEnergy;
333 
334  MomentumBins[i] = energy;
335  AerogelRindex[i] = RefractiveIndex;
336  AerogelAbsorption[i] = AerogelAbsorbtionLength;
337 
338  const G4double Lambda0 = 400 * 1e-6 * CLHEP::mm;
339  const G4double Lambda = 1240 * CLHEP::eV / energy * 1e-6 * CLHEP::mm;
340  G4double x = Lambda / Lambda0;
341  AerogelRayleigh[i] = AerogelTransmissionLength * x * x * x * x;
342  }
343 
344 
345  G4MaterialPropertiesTable* AeroProperty = new G4MaterialPropertiesTable();
346  AeroProperty->AddProperty("RINDEX" , MomentumBins, AerogelRindex , NBins);
347  AeroProperty->AddProperty("ABSLENGTH", MomentumBins, AerogelAbsorption, NBins);
348  AeroProperty->AddProperty("RAYLEIGH" , MomentumBins, AerogelRayleigh, NBins);
349 
350 
351  _aerogel->SetMaterialPropertiesTable(AeroProperty);
352 
353 
354  return _aerogel;
355  }
356 
357 
358  void GeoARICHBtestCreator::createBtestGeometry(const GearDir& content, G4LogicalVolume& topWorld)
359  {
360 
361  B2INFO("ARICH Btest geometry will be built.");
363 
365 
366  // experimental box
367 
368  GearDir boxParams(content, "ExperimentalBox");
369  double xBox = boxParams.getLength("xSize") * CLHEP::mm / Unit::mm;
370  double yBox = boxParams.getLength("ySize") * CLHEP::mm / Unit::mm;
371  double zBox = boxParams.getLength("zSize") * CLHEP::mm / Unit::mm;
372 
373  double xoffset = boxParams.getLength("beamcenter/x") * CLHEP::mm / Unit::mm;
374  double yoffset = boxParams.getLength("beamcenter/y") * CLHEP::mm / Unit::mm;
375  double zoffset = boxParams.getLength("beamcenter/z") * CLHEP::mm / Unit::mm - zBox / 2.;
376  G4ThreeVector roffset(xoffset, yoffset, zoffset);
377 
378  TVector3 sh(boxParams.getLength("beamcenter/x"), boxParams.getLength("beamcenter/y"),
379  boxParams.getLength("beamcenter/z") - boxParams.getLength("zSize") / 2.);
380  m_arichbtgp->setOffset(sh);
381 
382  string boxMat = boxParams.getString("material");
383  G4Material* boxMaterial = Materials::get(boxMat);
384  G4Box* expBox = new G4Box("ExperimentalBox", xBox / 2., yBox / 2., zBox / 2.);
385  G4LogicalVolume* topVolume = new G4LogicalVolume(expBox, boxMaterial, "ARICH.experimentalbox");
386  new G4PVPlacement(G4Transform3D(), topVolume, "ARICH.experimentalbox", &topWorld, false, 1);
387  setVisibility(*topVolume, false);
388 
389  TVector3 trackingshift(content.getLength("tracking/shift/x"),
390  content.getLength("tracking/shift/y"),
391  content.getLength("tracking/shift/z"));
392 
393  char mnodestr[256];
394  sprintf(mnodestr, "tracking/shift/run[@id=\"%d\"]", m_runno);
395  if (content.exists(mnodestr)) {
396  GearDir runtrackingshift(content, mnodestr);
397  trackingshift[0] = runtrackingshift.getLength("x");
398  trackingshift[1] = runtrackingshift.getLength("y");
399  trackingshift[2] = runtrackingshift.getLength("z");
400  }
401  m_arichbtgp->setTrackingShift(trackingshift);
402  ARICHTracking* m_mwpc = new ARICHTracking[4];
403  m_arichbtgp->setMwpc(m_mwpc);
404  BOOST_FOREACH(const GearDir & mwpc, content.getNodes("tracking/mwpc")) {
405  double x = mwpc.getLength("size/x") * CLHEP::mm / Unit::mm;
406  double y = mwpc.getLength("size/y") * CLHEP::mm / Unit::mm;
407  double z = mwpc.getLength("size/z") * CLHEP::mm / Unit::mm;
408 
409  double px = mwpc.getLength("position/x") * CLHEP::mm / Unit::mm;
410  double py = mwpc.getLength("position/y") * CLHEP::mm / Unit::mm;
411  double pz = mwpc.getLength("position/z") * CLHEP::mm / Unit::mm;
412 
413  G4Box* mwpcBox = new G4Box("MwpcBox", x / 2., y / 2., z / 2.);
414  G4LogicalVolume* mwpcVol = new G4LogicalVolume(mwpcBox, Materials::get(mwpc.getString("material")) , "ARICH.mwpc");
415  new G4PVPlacement(G4Transform3D(G4RotationMatrix(), G4ThreeVector(px, py, pz) + roffset), mwpcVol, "ARICH.mwpc", topVolume, false,
416  1);
417  //setVisibility(*mwpc, true);
418 
419  int id = mwpc.getInt("@id", -1);
420  B2INFO("GeoARICHBtestCreator:: MWPC ID=" << id);
421  if (id < 4 && id >= 0) {
422  m_mwpc[id].tdc[0] = mwpc.getInt("tdc/y/up");
423  m_mwpc[id].tdc[1] = mwpc.getInt("tdc/y/down");
424  m_mwpc[id].tdc[2] = mwpc.getInt("tdc/x/left");
425  m_mwpc[id].tdc[3] = mwpc.getInt("tdc/x/right");
426  m_mwpc[id].atdc = mwpc.getInt("tdc/anode", 0);
427  m_mwpc[id].slp[0] = mwpc.getDouble("slope/x");
428  m_mwpc[id].slp[1] = mwpc.getDouble("slope/y");
429  m_mwpc[id].offset[0] = mwpc.getDouble("offset/x");
430  m_mwpc[id].offset[1] = mwpc.getDouble("offset/y");
431  m_mwpc[id].cutll[0] = mwpc.getInt("tdccut/y/min");
432  m_mwpc[id].cutll[1] = mwpc.getInt("tdccut/x/min");
433  m_mwpc[id].cutul[0] = mwpc.getInt("tdccut/y/max");
434  m_mwpc[id].cutul[1] = mwpc.getInt("tdccut/x/max");
435  m_mwpc[id].pos[0] = mwpc.getDouble("position/x");
436  m_mwpc[id].pos[1] = mwpc.getDouble("position/y");
437  m_mwpc[id].pos[2] = mwpc.getDouble("position/z");
438  // m_mwpc[id].Print();
439  }
440 
441  }
442  // physical position of the hapd channels
443 
444  istringstream mapstream;
445  double mx, my;
446  mapstream.str(content.getString("hapdmap"));
447  while (mapstream >> mx >> my) {
448  m_arichbtgp->AddHapdChannelPositionPair(mx, my);
449  }
450  mapstream.clear();
451 
452  // mapping of the electronic channels
453  int ipx, ipy;
454  mapstream.str(content.getString("hapdchmap"));
455  while (mapstream >> ipx >> ipy) {
456  m_arichbtgp->AddHapdElectronicMapPair(ipx, ipy);
457  }
458  // experimental frame consisting of detector plane, aerogel and mirrors
459 
460  GearDir frameParams(content, "Frame");
461  double xFrame = frameParams.getLength("xSize") * CLHEP::mm / Unit::mm;
462  double yFrame = frameParams.getLength("ySize") * CLHEP::mm / Unit::mm;
463  double zFrame = frameParams.getLength("zSize") * CLHEP::mm / Unit::mm;
464  string envMat = frameParams.getString("material");
465 
466  double px = frameParams.getLength("position/x") * CLHEP::mm / Unit::mm;
467  double py = frameParams.getLength("position/y") * CLHEP::mm / Unit::mm;
468  double pz = frameParams.getLength("position/z") * CLHEP::mm / Unit::mm;
469 
470  G4Material* envMaterial = Materials::get(envMat);
471 
472 
473  G4Box* envBox = new G4Box("FrameBox", xFrame / 2., yFrame / 2., zFrame / 2.);
474  G4LogicalVolume* lenvBox = new G4LogicalVolume(envBox, envMaterial, "ARICH.frame");
475  G4ThreeVector frameOrigin0(m_framedx + px, py, pz); // rotation point of the detector frame wrt beamcenter
476  G4ThreeVector frameOrigin = frameOrigin0 + roffset;
477  G4RotationMatrix frameRotation;
478  frameRotation.rotateY(-m_rotation1 * CLHEP::degree);
479  G4Transform3D frameTransformation = G4Transform3D(frameRotation, frameOrigin);
480 
481  new G4PVPlacement(frameTransformation, lenvBox, "ARICH.frame", topVolume, false, 1);
482  //setVisibility(*lenvBox, false);
483 
484  TVector3 rotationCenter = TVector3(frameOrigin0.x() * Unit::mm / CLHEP::mm, frameOrigin0.y() * Unit::mm / CLHEP::mm,
485  frameOrigin0.z() * Unit::mm / CLHEP::mm);
486  m_arichbtgp->setFrameRotation(m_rotation1 * CLHEP::degree);
487  m_arichbtgp->setRotationCenter(rotationCenter);
488 
489 
490  char nodestr[256];
491  B2INFO(content.getPath());
492  sprintf(nodestr, "PhotonDetector/setup[@id=\"%d\"]", m_configuration);
493  GearDir hapdcontent(content, nodestr);
494  B2INFO(hapdcontent.getPath());
495 
496 
497 
498  char mirrornodestr[256];
499  sprintf(mirrornodestr, "Mirrors/setup[@id=\"%s\"]", m_mirrorID.c_str());
500 
501  GearDir mirrorcontent(content, mirrornodestr);
502  B2INFO(mirrorcontent.getPath());
503 
504  // detectors
505  m_arichgp->Initialize(hapdcontent, mirrorcontent);
506 
507 
508  GearDir moduleParam(hapdcontent, "Detector/Module");
509  G4LogicalVolume* detModule = buildModule(moduleParam);
510 
511  double detZpos = hapdcontent.getLength("Detector/Plane/zPosition") * CLHEP::mm / Unit::mm;
512  double detThick = hapdcontent.getLength("Detector/Module/moduleZSize") * CLHEP::mm / Unit::mm;
513  int nModules = m_arichgp->getNMCopies();
514 
515  for (int i = 1; i <= nModules; i++) {
516  G4ThreeVector origin = m_arichgp->getOriginG4(i);
517  origin.setZ(detZpos + detThick / 2.);
518  double angle = m_arichgp->getModAngle(i);
519  G4RotationMatrix Ra;
520  Ra.rotateZ(angle);
521  G4Transform3D trans = G4Transform3D(Ra, origin);
522  new G4PVPlacement(G4Transform3D(Ra, origin), detModule, "detModule", lenvBox, false, i);
523  B2INFO(nodestr << "Module " << i << " is build ");
524  }
525  // mask hot channels
526  int npx = m_arichgp->getDetectorXPadNumber();
527  BOOST_FOREACH(const double & ch, hapdcontent.getArray("HotChannels")) {
528  int channelID = (int) ch;
529  int moduleID = (npx) ? channelID / (npx * npx) : 0;
530  channelID %= (npx * npx);
531  m_arichgp->setActive(moduleID, channelID, false);
532  B2INFO("HotChannel " << ch << " : Module " << moduleID << "channelID " << channelID << " disabled");
533  }
534  // mask dead channels
535  BOOST_FOREACH(const double & ch, hapdcontent.getArray("DeadChannels")) {
536  int channelID = (int) ch;
537  int moduleID = (npx) ? channelID / (npx * npx) : 0;
538  channelID %= (npx * npx);
539  m_arichgp->setActive(moduleID, channelID, false);
540  B2INFO("DeadChannel " << ch << " : Module " << moduleID << "channelID " << channelID << " disabled");
541  }
542  // place aerogel tiles
543  GearDir aerogelParam(content, "Aerogel");
544  double sizeX = aerogelParam.getLength("tileXSize") * CLHEP::mm / Unit::mm;
545  double sizeY = aerogelParam.getLength("tileYSize") * CLHEP::mm / Unit::mm;
546  double posX = aerogelParam.getLength("tileXPos") * CLHEP::mm / Unit::mm;
547  double posY = aerogelParam.getLength("tileYPos") * CLHEP::mm / Unit::mm;
548  double posZ = aerogelParam.getLength("tileZPos") * CLHEP::mm / Unit::mm;
549  double posZ0 = posZ;
550  double meanrefind = 0;
551  double meantrlen = 0;
552 
553  // get parameter from python script
554  PyObject* m = PyImport_AddModule(strdup("__main__"));
555  if (m) {
556  int averageagel = 0;
557  PyObject* v = PyObject_GetAttrString(m, strdup("averageagel"));
558  if (v) {
559  averageagel = PyLong_AsLong(v);
560  Py_DECREF(v);
561  }
562  B2INFO("Python averageagel = " << averageagel);
563  m_arichbtgp->setAverageAgel(averageagel > 0);
564  }
565 
566  for (unsigned int ilayer = 0; ilayer < m_agelthickness.size(); ilayer++) {
567  char aeroname[100];
568  sprintf(aeroname, "Aerogel%u", ilayer + 1);
569  G4Material* tileMaterial = createAerogel(aeroname, m_agelrefind[ilayer], m_ageltrlen[ilayer]);
570  double sizeZ = m_agelthickness[ilayer] * CLHEP::mm / Unit::mm;
571 
572  if (!m_arichbtgp->getAverageAgel()) {
573  m_arichgp->setAeroRefIndex(ilayer, m_agelrefind[ilayer]);
574  m_arichgp->setAerogelZPosition(ilayer, (posZ - zFrame / 2.) * Unit::mm / CLHEP::mm);
575  m_arichgp->setAerogelThickness(ilayer, sizeZ * Unit::mm / CLHEP::mm);
576  m_arichgp->setAeroTransLength(ilayer, m_ageltrlen[ilayer]);
577  }
578 
579  meantrlen += sizeZ / m_ageltrlen[ilayer];
580  meanrefind += m_agelrefind[ilayer];
581  G4Box* tileBox = new G4Box("tileBox", sizeX / 2., sizeY / 2., sizeZ / 2.);
582  G4LogicalVolume* lTile = new G4LogicalVolume(tileBox, tileMaterial, "Tile", 0, ilayer == 0 ? m_sensitiveAero : 0);
583  setColor(*lTile, "rgb(0.0, 1.0, 1.0,1.0)");
584  G4Transform3D trans = G4Translate3D(posX, posY, posZ + sizeZ / 2. - zFrame / 2.);
585  new G4PVPlacement(trans, lTile, "ARICH.tile", lenvBox, false, ilayer + 1);
586  posZ += sizeZ;
587  }
588  if (m_arichbtgp->getAverageAgel() && m_agelthickness.size()) {
589  B2INFO("Average aerogel will be used in the reconstruction ");
590  m_arichgp->setAeroRefIndex(0, meanrefind / m_agelthickness.size());
591  m_arichgp->setAerogelZPosition(0, (posZ0 - zFrame)* Unit::mm / CLHEP::mm);
592  m_arichgp->setAerogelThickness(0, posZ * Unit::mm / CLHEP::mm);
593  if (meantrlen > 0 && posZ > 0) meantrlen = 1 / meantrlen / posZ;
594  m_arichgp->setAeroTransLength(0, meantrlen);
595  }
596 
597 
598  // place mirrors
599  GearDir mirrorsParam(mirrorcontent, "Mirrors");
600  double height = mirrorsParam.getLength("height") * CLHEP::mm / Unit::mm;
601  double width = mirrorsParam.getLength("width") * CLHEP::mm / Unit::mm;
602  double thickness = mirrorsParam.getLength("thickness") * CLHEP::mm / Unit::mm;
603  string mirrMat = mirrorsParam.getString("material");
604  G4Material* mirrMaterial = Materials::get(mirrMat);
605  G4Box* mirrBox = new G4Box("mirrBox", thickness / 2., height / 2., width / 2.);
606  G4LogicalVolume* lmirror = new G4LogicalVolume(mirrBox, mirrMaterial, "mirror");
607 
608  Materials& materials = Materials::getInstance();
609  GearDir surface(mirrorsParam, "Surface");
610  G4OpticalSurface* optSurf = materials.createOpticalSurface(surface);
611  new G4LogicalSkinSurface("mirrorsSurface", lmirror, optSurf);
612  int iMirror = 0;
613  BOOST_FOREACH(const GearDir & mirror, mirrorsParam.getNodes("Mirror")) {
614  double xpos = mirror.getLength("xPos") * CLHEP::mm / Unit::mm;
615  double ypos = mirror.getLength("yPos") * CLHEP::mm / Unit::mm;
616  double zpos = mirror.getLength("zPos") * CLHEP::mm / Unit::mm;
617  double angle = mirror.getAngle("angle") / Unit::rad;
618  G4ThreeVector origin(xpos, ypos, zpos + width / 2. - zFrame / 2.);
619  G4RotationMatrix Ra;
620  Ra.rotateZ(angle);
621  G4Transform3D trans = G4Transform3D(Ra, origin);
622  new G4PVPlacement(G4Transform3D(Ra, origin), lmirror, "ARICH.mirror", lenvBox, false, iMirror);
623  iMirror++;
624  }
625  m_arichgp->Print();
626  m_arichbtgp->Print();
627  }
628 
629 
630  }
632 }
setup
Belle2::arich::GeoARICHBtestCreator::m_configuration
int m_configuration
configuration number of the HAPD
Definition: GeoARICHBtestCreator.h:109
Belle2::ARICHTracking::cutll
int cutll[2]
Cuts on the tdc sums - lower levels.
Definition: ARICHBtestGeometryPar.h:68
Belle2::arich::GeoARICHBtestCreator::m_comment
std::string m_comment
comment in the runlog
Definition: GeoARICHBtestCreator.h:96
Belle2::arich::GeoARICHBtestCreator::getAvgRINDEX
double getAvgRINDEX(G4Material *material)
Get the average refractive index if the material.
Definition: GeoARICHBtestCreator.cc:213
Belle2::ARICHBtestGeometryPar::AddHapdElectronicMapPair
int AddHapdElectronicMapPair(int, int)
Set the mapping of the electronic channel to the HAPD module nr and the channel number.
Definition: ARICHBtestGeometryPar.cc:100
Belle2::ARICHTracking::offset
float offset[2]
Calibration constants of the MWPC - offsets for x an y direction.
Definition: ARICHBtestGeometryPar.h:66
Belle2::arich::GeoARICHBtestCreator::createBtestGeometry
void createBtestGeometry(const GearDir &content, G4LogicalVolume &topVolume)
Creation of the beamtest geometry.
Definition: GeoARICHBtestCreator.cc:358
Belle2::arich::GeoARICHBtestCreator::m_rotation1
double m_rotation1
rotation angle of the frame
Definition: GeoARICHBtestCreator.h:107
Belle2::arich::GeoARICHBtestCreator::m_comment1
std::string m_comment1
tbc
Definition: GeoARICHBtestCreator.h:111
Belle2::arich::GeoARICHBtestCreator::createAerogel
G4Material * createAerogel(const char *aeroname, double rind, double trl)
create aerogel material
Definition: GeoARICHBtestCreator.cc:304
Belle2::arich::SensitiveDetector
The Class for ARICH Sensitive Detector.
Definition: SensitiveDetector.h:36
Belle2::geometry::setColor
void setColor(G4LogicalVolume &volume, const std::string &color)
Set the color of a logical volume.
Definition: utilities.cc:107
Belle2::ARICHBtestGeometryPar::setRotationCenter
void setRotationCenter(const TVector3 &)
Set the rotation center of the Aerogel RICH frame.
Definition: ARICHBtestGeometryPar.cc:120
Belle2::gearbox::Interface::getAngle
double getAngle(const std::string &path="") const noexcept(false)
Get the parameter path as a double converted to the standard angle unit.
Definition: Interface.h:301
Belle2::gearbox::Interface::getInt
int getInt(const std::string &path="") const noexcept(false)
Get the parameter path as a int.
Definition: Interface.cc:70
Belle2::arich::GeoARICHBtestCreator::m_sensitive
SensitiveDetector * m_sensitive
pointer to the sensitive detector
Definition: GeoARICHBtestCreator.h:63
Belle2::ARICHGeometryPar::getSensitiveSurfaceSize
double getSensitiveSurfaceSize() const
get size of detector sensitive surface (size of two chips + gap between)
Definition: ARICHGeometryPar.h:283
Belle2::ARICHTracking::slp
float slp[2]
Calibration constants of the MWPC (\delta x= slope \delta t + offset) - slopes for x an y direction.
Definition: ARICHBtestGeometryPar.h:64
Belle2::arich::GeoARICHBtestCreator::create
virtual void create(const GearDir &content, G4LogicalVolume &topVolume, geometry::GeometryTypes type)
Creates the ROOT Objects for the ARICH Beamtest 2011 geometry.
Definition: GeoARICHBtestCreator.cc:91
Belle2::gearbox::Interface::getPath
std::string getPath() const
Return path of the current interface.
Definition: Interface.h:72
Belle2::ARICHGeometryPar::Initialize
void Initialize(const GearDir &content)
calculates detector parameters needed for geometry build and reconstruction.
Definition: ARICHGeometryPar.cc:70
Belle2::ARICHBtestGeometryPar::AddHapdChannelPositionPair
int AddHapdChannelPositionPair(double, double)
Set the position of the HAPD channel.
Definition: ARICHBtestGeometryPar.cc:94
Belle2::ARICHGeometryPar::setAeroRefIndex
void setAeroRefIndex(int ilayer, double n)
set refractive index of "ilayer" aerogel layer
Definition: ARICHGeometryPar.cc:510
Belle2::arich::GeoARICHBtestCreator::m_datum
std::string m_datum
datum of the runlog
Definition: GeoARICHBtestCreator.h:98
Belle2::ARICHGeometryPar::Instance
static ARICHGeometryPar * Instance()
Static method to get a reference to the ARICHGeometryPar instance.
Definition: ARICHGeometryPar.cc:32
Belle2::ARICHBtestGeometryPar::setFrameRotation
void setFrameRotation(double)
Set the rotation angle of the Aerogel RICH frame.
Definition: ARICHBtestGeometryPar.cc:133
Belle2::arich::GeoARICHBtestCreator::m_agelrefind
std::vector< double > m_agelrefind
vector of aerogel refractive indices
Definition: GeoARICHBtestCreator.h:114
Belle2::geometry::Materials::get
static G4Material * get(const std::string &name)
Find given material.
Definition: Materials.h:65
Belle2::ARICHTracking::tdc
int tdc[4]
TDC of the 4 cathode signals.
Definition: ARICHBtestGeometryPar.h:58
Belle2::gearbox::Interface::getDouble
double getDouble(const std::string &path="") const noexcept(false)
Get the parameter path as a double.
Definition: Interface.cc:51
Belle2::Unit::rad
static const double rad
Standard of [angle].
Definition: Unit.h:60
Belle2::Module
Base class for Modules.
Definition: Module.h:74
Belle2::arich::GeoARICHBtestCreator::m_ageltrlen
std::vector< double > m_ageltrlen
vector of aerogel transmission lengths
Definition: GeoARICHBtestCreator.h:118
Belle2::arich::GeoARICHBtestCreator::m_ry
double m_ry
y shift of the prototype ARICH frame
Definition: GeoARICHBtestCreator.h:90
Belle2::Unit::MeV
static const double MeV
[megaelectronvolt]
Definition: Unit.h:124
Belle2::ARICHTracking::atdc
int atdc
TDC of the anode signal.
Definition: ARICHBtestGeometryPar.h:62
Belle2::ARICHBtestGeometryPar::setAverageAgel
void setAverageAgel(bool)
Set the flag for the reconstruction by using the average aerogel refractive index.
Definition: ARICHBtestGeometryPar.cc:146
Belle2::Unit::eV
static const double eV
[electronvolt]
Definition: Unit.h:122
Belle2::ARICHGeometryPar::setActive
void setActive(int module, int channel, bool val)
set the channel on/off
Definition: ARICHGeometryPar.cc:541
Belle2::ARICHBtestGeometryPar::setOffset
void setOffset(const TVector3 &)
Set of the setup global offset.
Definition: ARICHBtestGeometryPar.cc:167
Belle2::arich::GeoARICHBtestCreator::m_aerosupport
int m_aerosupport
Type of aerogel support - not used at the moment.
Definition: GeoARICHBtestCreator.h:101
Belle2::arich::GeoARICHBtestCreator::m_rotation
double m_rotation
rotation angle of the setup
Definition: GeoARICHBtestCreator.h:86
Belle2::ARICHBtestGeometryPar::getAverageAgel
bool getAverageAgel()
Get the flag for the reconstruction by using the average aerogel refractive index.
Definition: ARICHBtestGeometryPar.cc:151
Belle2::ARICHGeometryPar::getModAngle
double getModAngle(int copyno)
get the angle of copyno-th HAPD rotation
Definition: ARICHGeometryPar.cc:404
Belle2::ARICHTracking::pos
float pos[3]
MWPC chamber position.
Definition: ARICHBtestGeometryPar.h:72
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::geometry::Materials::getInstance
static Materials & getInstance()
Get a reference to the singleton instance.
Definition: Materials.cc:87
Belle2::geometry::setVisibility
void setVisibility(G4LogicalVolume &volume, bool visible)
Helper function to quickly set the visibility of a given volume.
Definition: utilities.cc:115
Belle2::StoreObjPtr
Type-safe access to single objects in the data store.
Definition: ParticleList.h:33
Belle2::ARICHBtestGeometryPar::Instance
static ARICHBtestGeometryPar * Instance()
Static method to get a reference to the ARICHBtestGeometryPar instance.
Definition: ARICHBtestGeometryPar.cc:29
Belle2::arich::GeoARICHBtestCreator::m_agelthickness
std::vector< double > m_agelthickness
vector of aerogel thicknesses
Definition: GeoARICHBtestCreator.h:116
Belle2::arich::GeoARICHBtestCreator::m_rx
double m_rx
x shift of the prototype ARICH frame
Definition: GeoARICHBtestCreator.h:88
Belle2::GearDir
GearDir is the basic class used for accessing the parameter store.
Definition: GearDir.h:41
Belle2::geometry::Materials::createOpticalSurface
G4OpticalSurface * createOpticalSurface(const gearbox::Interface &parameters)
Create an optical surface from parameters, will abort on error.
Definition: Materials.cc:288
Belle2::ARICHGeometryPar
The Class for ARICH Geometry Parameters.
Definition: ARICHGeometryPar.h:36
Belle2::geometry::Materials
Thin wrapper around the Geant4 Material system.
Definition: Materials.h:50
Belle2::arich::GeoARICHBtestCreator::m_hapdID
std::string m_hapdID
ID of the HAPD configuration setup.
Definition: GeoARICHBtestCreator.h:80
Belle2::arich::GeoARICHBtestCreator::m_daqqa
std::string m_daqqa
classification of the run
Definition: GeoARICHBtestCreator.h:94
Belle2::ARICHBtestGeometryPar::setMwpc
void setMwpc(ARICHTracking *m_mwpc)
Set the pointer of the tracking MWPCs.
Definition: ARICHBtestGeometryPar.cc:73
Belle2::arich::SensitiveAero
This is optional (temporary) class that provides information on track parameters on aerogel plane,...
Definition: SensitiveAero.h:32
Belle2::ARICHGeometryPar::getDetectorXPadNumber
int getDetectorXPadNumber()
get number of pads of detector module (in one direction)
Definition: ARICHGeometryPar.h:354
Belle2::arich::GeoARICHBtestCreator::~GeoARICHBtestCreator
virtual ~GeoARICHBtestCreator()
The destructor of the GeoPXDCreator class.
Definition: GeoARICHBtestCreator.cc:85
Belle2::arich::GeoARICHBtestCreator::m_framedx
double m_framedx
shift of the frame
Definition: GeoARICHBtestCreator.h:105
Belle2::gearbox::Interface::getLength
double getLength(const std::string &path="") const noexcept(false)
Get the parameter path as a double converted to the standard length unit.
Definition: Interface.h:261
Belle2::ARICHTracking
Beamtest ARICH Geometry Tracking Class.
Definition: ARICHBtestGeometryPar.h:36
Belle2::arich::GeoARICHBtestCreator::m_neve
int m_neve
Number of event in the beamtest run.
Definition: GeoARICHBtestCreator.h:76
Belle2::GearDir::getString
virtual std::string getString(const std::string &path="") const noexcept(false) override
Get the parameter path as a string.
Definition: GearDir.h:79
Belle2::Unit::mm
static const double mm
[millimeters]
Definition: Unit.h:80
Belle2::ARICHGeometryPar::setAerogelZPosition
void setAerogelZPosition(int ilayer, double zPos)
set z position of "ilayer" aerogel layer
Definition: ARICHGeometryPar.cc:521
Belle2::gearbox::Interface::getArray
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.
Definition: Interface.cc:133
Belle2::arich::GeoARICHBtestCreator::m_runno
int m_runno
Beamtest Run number.
Definition: GeoARICHBtestCreator.h:72
Belle2::arich::GeoARICHBtestCreator::m_aerogeldx
double m_aerogeldx
shift of the aerogel center
Definition: GeoARICHBtestCreator.h:103
Belle2::ARICHGeometryPar::setWindowRefIndex
void setWindowRefIndex(double refInd)
set detector module window refractive index
Definition: ARICHGeometryPar.cc:526
Belle2::geometry::Materials::getElement
G4Element * getElement(const std::string &name)
Find given chemical element.
Definition: Materials.cc:151
Belle2::arich::GeoARICHBtestCreator::m_mytype
std::string m_mytype
type of the run
Definition: GeoARICHBtestCreator.h:92
Belle2::ARICHTracking::cutul
int cutul[2]
Cuts on the tdc sums - upper levels.
Definition: ARICHBtestGeometryPar.h:70
Belle2::ARICHGeometryPar::setAeroTransLength
void setAeroTransLength(int ilayer, double trlen)
set transmission length of "ilayer" aerogel layer
Definition: ARICHGeometryPar.cc:505
Belle2::ARICHGeometryPar::setAerogelThickness
void setAerogelThickness(int ilayer, double thick)
set thickness of "ilayer" aerogel layer
Definition: ARICHGeometryPar.cc:515
Belle2::arich::GeoARICHBtestCreator::m_author
std::string m_author
Beamtest runlog record author.
Definition: GeoARICHBtestCreator.h:74
Belle2::gearbox::Interface::getNodes
std::vector< GearDir > getNodes(const std::string &path="") const
Get vector of GearDirs which point to all the nodes the given path evaluates to.
Definition: Interface.cc:31
Belle2::ARICHBtestGeometryPar::setTrackingShift
void setTrackingShift(const TVector3 &)
Set the tracking shift.
Definition: ARICHBtestGeometryPar.cc:106
Belle2::arich::GeoARICHBtestCreator::m_sensitiveAero
SensitiveAero * m_sensitiveAero
pointer to the sesnitive aerogel
Definition: GeoARICHBtestCreator.h:65
Belle2::geometry::GeometryTypes
GeometryTypes
Flag indiciating the type of geometry to be used.
Definition: GeometryManager.h:39
Belle2::ARICHGeometryPar::getOriginG4
G4ThreeVector getOriginG4(int copyNo)
get the position of copyNo-th HAPD module origin (returns G4ThreeVector)
Definition: ARICHGeometryPar.cc:398
Belle2::arich::GeoARICHBtestCreator::m_runtype
std::string m_runtype
Type of the beamtest run.
Definition: GeoARICHBtestCreator.h:78
Belle2::arich::GeoARICHBtestCreator::m_mirrorID
std::string m_mirrorID
ID of the mirror configuration setup.
Definition: GeoARICHBtestCreator.h:84
Belle2::ARICHGeometryPar::Print
void Print(void) const
Print some debug information.
Definition: ARICHGeometryPar.cc:302
Belle2::ARICHBtestGeometryPar
The Class for ARICH Beamtest Geometry Parameters.
Definition: ARICHBtestGeometryPar.h:109
Belle2::arich::GeoARICHBtestCreator::buildModule
G4LogicalVolume * buildModule(GearDir Module)
Build the module.
Definition: GeoARICHBtestCreator.cc:223
Belle2::ARICHGeometryPar::getNMCopies
int getNMCopies() const
get the total number of HAPD modules
Definition: ARICHGeometryPar.h:288
Belle2::arich::GeoARICHBtestCreator::m_aerogelID
std::string m_aerogelID
ID of the aerogel configuration setup.
Definition: GeoARICHBtestCreator.h:82