Project
Loading...
Searching...
No Matches
Detector.cxx
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12// FairRoot includes
13#include "Framework/Logger.h"
14#include "FairRootManager.h" // for FairRootManager
15#include "FairVolume.h" // for FairVolume
17#include "DetectorsBase/Stack.h"
20#include "DataFormatsZDC/Hit.h"
21
22#include "TMath.h"
23#include "TGeoManager.h" // for TGeoManager, gGeoManager
24#include "TGeoVolume.h" // for TGeoVolume, TGeoVolumeAssembly
25#include "TGeoTube.h" // for TGeoTube
26#include "TGeoCone.h" // for TGeoCone
27#include "TGeoCompositeShape.h" // for TGeoCone
28#include "TVirtualMC.h" // for gMC, TVirtualMC
29#include "TString.h" // for TString, operator+
30#include <TRandom.h>
31#include <cassert>
32#include <fstream>
34#include "SimConfig/SimConfig.h"
35#include <algorithm>
36#ifdef ZDC_FASTSIM_ONNX
37#include "Utils.h" // for normal_distribution()
38#include "FastSimulations.h" // for fastsim module
39#include "Processors.h" // for fastsim module
40#endif
41
42using namespace o2::zdc;
43
45#define kRaddeg TMath::RadToDeg()
46
47//_____________________________________________________________________________
49 : o2::base::DetImpl<Detector>("ZDC", active),
50 mHits(new std::vector<o2::zdc::Hit>),
51 mXImpact(-999, -999, -999),
52 mNeutronResponseImage(Geometry::ZNDIVISION[0] * Geometry::ZNSECTORS[0] * 2,
53 Geometry::ZNDIVISION[1] * Geometry::ZNSECTORS[1] * 2,
54 Geometry::ZNAPOSITION[0] - Geometry::ZNDIMENSION[0],
55 Geometry::ZNAPOSITION[1] - Geometry::ZNDIMENSION[1],
56 Geometry::ZNDIMENSION[0] * 2,
57 Geometry::ZNDIMENSION[1] * 2),
58 mProtonResponseImage(Geometry::ZPDIVISION[0] * Geometry::ZPSECTORS[0] * 2,
59 Geometry::ZPDIVISION[1] * Geometry::ZPSECTORS[1] * 2,
60 Geometry::ZPAPOSITION[0] - Geometry::ZPDIMENSION[0],
61 Geometry::ZPAPOSITION[1] - Geometry::ZPDIMENSION[1],
62 Geometry::ZPDIMENSION[0] * 2,
63 Geometry::ZPDIMENSION[1] * 2)
64{
65 mTrackEta = 999;
66 // REsetting summed variables
67 mTotLightPMC = 0;
68 mTotLightPMQ = 0;
69 mMediumPMCid = -1; // minus for unitialized
70 mMediumPMQid = -2; // different to PMC in any case
71 resetHitIndices();
72 setupFastSim();
73}
74
75//_____________________________________________________________________________
77 : o2::base::DetImpl<Detector>(rhs),
78 mXImpact(-999, -999, -999),
79 // the medium ids are set while the geometry is built, which only the master does
80 mMediumPMCid(rhs.mMediumPMCid),
81 mMediumPMQid(rhs.mMediumPMQid),
82 mHits(new std::vector<o2::zdc::Hit>),
83 mNeutronResponseImage(rhs.mNeutronResponseImage),
84 mProtonResponseImage(rhs.mProtonResponseImage)
85{
86 mTrackEta = 999;
87 mTotLightPMC = 0;
88 mTotLightPMQ = 0;
89 resetHitIndices();
90 // each copy has its own fast simulation models, since running a model changes its state
91 setupFastSim();
92}
93
94//_____________________________________________________________________________
95void Detector::setupFastSim()
96{
97#ifdef ZDC_FASTSIM_ONNX
98 // If FastSim module was disabled, log appropriate message
99 // otherwise check if all necessary parameters were passed, if so try build objects
100 auto& simparam = o2::zdc::ZDCSimParam::Instance();
101
102 if (!simparam.useZDCFastSim) {
103 LOG(info) << "FastSim module disabled";
104 } else if (simparam.useZDCFastSim && !simparam.ZDCFastSimClassifierPath.empty() && !simparam.ZDCFastSimClassifierScales.empty()) {
105 if (!mClassifierScaler) {
106 mClassifierScaler = new fastsim::processors::StandardScaler;
107 }
108 if (!mModelScalerNeutron) {
109 mModelScalerNeutron = new fastsim::processors::StandardScaler;
110 }
111 if (!mModelScalerProton) {
112 mModelScalerProton = new fastsim::processors::StandardScaler;
113 }
114 auto eonScales = o2::zdc::fastsim::loadScales(simparam.ZDCFastSimClassifierScales);
115 if (!eonScales.has_value()) {
116 LOG(error) << "Error while reading model scales from: "
117 << "'" << simparam.ZDCFastSimClassifierScales << "'";
118 LOG(error) << "FastSim module disabled.";
119 } else {
120 mClassifierScaler->setScales(eonScales->first, eonScales->second);
121 mFastSimClassifier = new o2::zdc::fastsim::ConditionalModelSimulation(simparam.ZDCFastSimClassifierPath, 1);
122
123 if (simparam.useZDCFastSim && !simparam.ZDCFastSimModelPathNeutron.empty() && !simparam.ZDCFastSimModelScalesNeutron.empty()) {
124 auto modelScalesNeutron = o2::zdc::fastsim::loadScales(simparam.ZDCFastSimModelScalesNeutron);
125
126 if (!modelScalesNeutron.has_value()) {
127 LOG(error) << "Error while reading model scales from: "
128 << "'" << simparam.ZDCFastSimModelScalesNeutron << "'";
129 LOG(error) << "FastSim module disabled";
130 } else {
131 mModelScalerNeutron->setScales(modelScalesNeutron->first, modelScalesNeutron->second);
132 mFastSimModelNeutron = new o2::zdc::fastsim::ConditionalModelSimulation(simparam.ZDCFastSimModelPathNeutron, 1);
133 LOG(info) << "FastSim neutron module enabled";
134 }
135 }
136 if (simparam.useZDCFastSim && !simparam.ZDCFastSimModelPathProton.empty() && !simparam.ZDCFastSimModelScalesProton.empty()) {
137 auto modelScalesProton = o2::zdc::fastsim::loadScales(simparam.ZDCFastSimModelScalesProton);
138
139 if (!modelScalesProton.has_value()) {
140 LOG(error) << "Error while reading model scales from: "
141 << "'" << simparam.ZDCFastSimModelScalesProton << "'";
142 LOG(error) << "FastSim module disabled";
143 } else {
144 mModelScalerProton->setScales(modelScalesProton->first, modelScalesProton->second);
145 mFastSimModelProton = new o2::zdc::fastsim::ConditionalModelSimulation(simparam.ZDCFastSimModelPathProton, 1);
146 LOG(info) << "FastSim proton module enabled";
147 }
148 }
149 }
150 }
151#endif
152}
153
154//_____________________________________________________________________________
155#ifdef ZDC_FASTSIM_ONNX
157{
158 delete (mFastSimClassifier);
159 delete (mFastSimModelNeutron);
160 delete (mFastSimModelProton);
161 delete (mClassifierScaler);
162 delete (mModelScalerNeutron);
163 delete (mModelScalerProton);
164}
165#endif
166
167//_____________________________________________________________________________
168template <typename T>
169int loadLightTable(T& table, int beta, int NRADBINS, std::string filename)
170{
171 // Retrieve the light yield table
172 std::string data;
173 std::ifstream input(filename);
174 //std::cout << " ********* Reading data from light table " << filename << std::endl;
175 int radiusbin = 0;
176 int anglebin = 0;
177 int counter = 0;
178 float value;
179 if (input.is_open()) {
180 while (input >> value) {
181 counter++;
182 table[beta][anglebin][radiusbin] = value;
183 //printf(" %f ", value);
184 radiusbin++;
185 if (radiusbin % NRADBINS == 0) {
186 radiusbin = 0;
187 anglebin++;
188 //printf("\n");
189 }
190 }
191 LOG(debug) << "Read " << counter << " values from ZDC data file " << filename;
192 input.close();
193 return counter;
194 } else {
195 LOG(error) << "Could not open file " << filename;
196 return 0;
197 }
198}
199
200//_____________________________________________________________________________
202{
203 // Define the list of sensitive volumes
204 defineSensitiveVolumes();
205
206 std::string inputDir;
207 const char* aliceO2env = std::getenv("O2_ROOT");
208 if (aliceO2env) {
209 inputDir = std::string(aliceO2env);
210 }
211 inputDir += "/share/Detectors/ZDC/simulation/data/";
212 //ZN case
213 loadLightTable(mLightTableZN, 0, ZNRADIUSBINS, inputDir + "light22620362207s");
214 loadLightTable(mLightTableZN, 1, ZNRADIUSBINS, inputDir + "light22620362208s");
215 loadLightTable(mLightTableZN, 2, ZNRADIUSBINS, inputDir + "light22620362209s");
216 auto elements = loadLightTable(mLightTableZN, 3, ZNRADIUSBINS, inputDir + "light22620362210s");
217 assert(elements == ZNRADIUSBINS * ANGLEBINS);
218 // check a few values to test correctness of reading from file light22620362207s
219 /*assert(std::abs(mLightTableZN[0][ZNRADIUSBINS - 1][0] - 1.39742) < 1.E-4); // beta=0; radius = ZNRADIUSBINS - 1; anglebin = 2;
220 assert(std::abs(mLightTableZN[0][ZNRADIUSBINS - 1][1] - .45017) < 1.E-4); // beta=1; radius = ZNRADIUSBINS - 1; anglebin = 2;
221 assert(std::abs(mLightTableZN[0][0][2] - .47985) < 1.E-4); // beta=0; radius = 0; anglebin = 2;
222 assert(std::abs(mLightTableZN[0][0][11] - .01358) < 1.E-4); // beta=0; radius = 0; anglebin = 11;
223 */
224
225 //ZP case
226 loadLightTable(mLightTableZP, 0, ZPRADIUSBINS, inputDir + "light22620552207s");
227 loadLightTable(mLightTableZP, 1, ZPRADIUSBINS, inputDir + "light22620552208s");
228 loadLightTable(mLightTableZP, 2, ZPRADIUSBINS, inputDir + "light22620552209s");
229 elements = loadLightTable(mLightTableZP, 3, ZPRADIUSBINS, inputDir + "light22620552210s");
230 assert(elements == ZPRADIUSBINS * ANGLEBINS);
231}
232
233//_____________________________________________________________________________
235{
236 LOG(debug) << "Creating ZDC geometry\n";
237
239
240 if (ZDCSimParam::Instance().buildBeamLine) {
241 createAsideBeamLine();
242 createCsideBeamLine();
243 createMagnets();
244 } else {
245 LOG(info) << "ZDC: beam line, magnets and the ZN/ZP calorimeters are not built";
246 }
247 createDetectors();
248}
249
250//_____________________________________________________________________________
251void Detector::defineSensitiveVolumes()
252{
253 LOG(info) << "defining sensitive for ZDC";
254 TGeoVolume* vol = nullptr;
255 if (ZDCSimParam::Instance().buildBeamLine) {
256 vol = gGeoManager->GetVolume("ZNENV");
257 if (vol) {
259 mZNENVVolID = vol->GetNumber(); // initialize id
260
261 AddSensitiveVolume(gGeoManager->GetVolume("ZNF1"));
262 AddSensitiveVolume(gGeoManager->GetVolume("ZNF2"));
263 AddSensitiveVolume(gGeoManager->GetVolume("ZNF3"));
264 AddSensitiveVolume(gGeoManager->GetVolume("ZNF4"));
265 } else {
266 LOG(fatal) << "can't find volume ZNENV";
267 }
268 vol = gGeoManager->GetVolume("ZPENV");
269 if (vol) {
271 mZPENVVolID = vol->GetNumber(); // initialize id
272
273 AddSensitiveVolume(gGeoManager->GetVolume("ZPF1"));
274 AddSensitiveVolume(gGeoManager->GetVolume("ZPF2"));
275 AddSensitiveVolume(gGeoManager->GetVolume("ZPF3"));
276 AddSensitiveVolume(gGeoManager->GetVolume("ZPF4"));
277 } else {
278 LOG(fatal) << "can't find volume ZPENV";
279 }
280 }
281 // em calorimeter
282 vol = gGeoManager->GetVolume("ZEM ");
283 if (vol) {
285 mZEMVolID = vol->GetNumber();
286 AddSensitiveVolume(gGeoManager->GetVolume("ZEMF"));
287 } else if (ZDCSimParam::Instance().buildZEM) {
288 LOG(fatal) << "can't find volume ZEM";
289 }
290}
291
292// determines detectorID and sectorID from volume and coordinates
293void Detector::getDetIDandSecID(TString const& volname, math_utils::Vector3D<float> const& x,
294 math_utils::Vector3D<float>& xDet, int& detector, int& sector) const
295{
296 if (volname.BeginsWith("ZN")) {
297 // for the neutron calorimeter
298
299 if (x.Z() > 0) {
300 detector = ZNA;
301 xDet = -(x - math_utils::Vector3D<float>(Geometry::ZNAPOSITION[0], Geometry::ZNAPOSITION[1], Geometry::ZNAPOSITION[2]));
302
303 } else if (x.Z() < 0) {
304 detector = ZNC;
305 xDet = x - math_utils::Vector3D<float>(Geometry::ZNCPOSITION[0], Geometry::ZNCPOSITION[1], Geometry::ZNCPOSITION[2]);
306 }
307 // now determine sector/tower
308 if (xDet.X() <= 0.) {
309 if (xDet.Y() <= 0.) {
310 sector = Ch1;
311 } else {
312 sector = Ch3;
313 }
314 } else {
315 if (xDet.Y() <= 0.) {
316 sector = Ch2;
317 } else {
318 sector = Ch4;
319 }
320 }
321 return;
322
323 } else if (volname.BeginsWith("ZP")) {
324 // proton calorimeter
325 if (x.Z() > 0) {
326 detector = ZPA; // (NB -> DIFFERENT FROM AliRoot!!!)
327 xDet = -(x - math_utils::Vector3D<float>(Geometry::ZPAPOSITION[0], Geometry::ZPAPOSITION[1], Geometry::ZPAPOSITION[2]));
328 } else if (x.Z() < 0) {
329 detector = ZPC; // (NB -> DIFFERENT FROM AliRoot!!!)
330 xDet = x - math_utils::Vector3D<float>(Geometry::ZPCPOSITION[0], Geometry::ZPCPOSITION[1], Geometry::ZPCPOSITION[2]);
331 }
332
333 // determine sector/tower
334 if (xDet.X() >= Geometry::ZPDIMENSION[0]) {
335 xDet.SetX(Geometry::ZPDIMENSION[0] - 0.01);
336 } else if (xDet.X() <= -Geometry::ZPDIMENSION[0]) {
337 xDet.SetX(-Geometry::ZPDIMENSION[0] + 0.01);
338 }
339
340 float xTow = 2. * xDet.X() / (Geometry::ZPDIMENSION[0]);
341 for (int i = 1; i <= 4; i++) {
342 if (xTow >= (i - 3) && xTow < (i - 2)) {
343 sector = i;
344 break;
345 }
346 }
347 return;
348
349 } else if (volname.BeginsWith("ZE")) {
350 // electromagnetic calorimeter
351 detector = ZEM;
352 xDet = x - math_utils::Vector3D<float>(Geometry::ZEMPOSITION[0], Geometry::ZEMPOSITION[1], Geometry::ZEMPOSITION[2]);
353 sector = (x.X() > 0.) ? Ch1 : Ch2;
354 return;
355 }
356
357 assert(false);
358}
359
360//_____________________________________________________________________________
361void Detector::resetHitIndices()
362{
363 // reinit hit buffer to null (because we make new hits for each principal track)
364 for (int det = 0; det < NUMDETS; ++det) {
365 for (int sec = 0; sec < NUMSECS; ++sec) {
366 mCurrentHitsIndices[det][sec] = -1;
367 }
368 }
369 // Summed variables are set to 0
370 mTotLightPMC = 0;
371 mTotLightPMQ = 0;
372}
373
374void Detector::flushSpatialResponse()
375{
376 if (o2::zdc::ZDCSimParam::Instance().recordSpatialResponse) {
377 auto c = mNeutronResponseImage.getPhotonsPerChannel();
378 std::fstream output("o2sim-FullSimResult", std::fstream::out | std::fstream::app);
379 output << c[0] << " " << c[1] << " " << c[2] << " " << c[3] << " " << c[4] << "\n";
380 output.close();
381
382 // only write non-trivial image pairs
383 if (mNeutronResponseImage.getPhotonSum() > 0 || mProtonResponseImage.getPhotonSum() > 0) {
384 mResponses.push_back(std::make_pair(mCurrentPrincipalParticle,
385 std::make_pair(mNeutronResponseImage, mProtonResponseImage)));
386 }
387 mNeutronResponseImage.reset();
388 mProtonResponseImage.reset();
389 }
390}
391
392// quick estimates the time of flight to reach this detector (located at z)
393// just based on primary particle properties
394// Meant for the neutron / proton detectors which sit a large z so that speed
395// is essentially the speed in z-direction.
396double estimateTimeOfFlight(TParticle const& part, double z /* needs to be in meters */)
397{
398 const auto m = part.GetMass();
399 constexpr auto SPEED_OF_LIGHT = 299792458.; // m/s
400 if (m == 0.) {
401 return z / SPEED_OF_LIGHT;
402 } else {
403 TLorentzVector lorentz; // could be made member var
404 part.Momentum(lorentz);
405 const auto gamma = lorentz.Gamma();
406 const auto speed = SPEED_OF_LIGHT * std::sqrt(1. - 1. / (gamma * gamma));
407 return z / speed; // could refine this
408 }
409}
410
411//_____________________________________________________________________________
413{
414 // Method called from MC stepping for the sensitive volumes
415 TString volname = fMC->CurrentVolName();
416 float x[3] = {0., 0., 0.};
417 fMC->TrackPosition(x[0], x[1], x[2]);
418
419 // determine detectorID and sectorID
420 int detector = -1;
421 int sector = -1;
422 math_utils::Vector3D<float> xImp;
423 getDetIDandSecID(volname, math_utils::Vector3D<float>(x[0], x[1], x[2]), xImp, detector, sector);
424
425 auto stack = (o2::data::Stack*)fMC->GetStack();
426 int trackn = stack->GetCurrentTrackNumber();
427
428 // find out if we are entering into the detector NEU or PRO for the first time
429 int volID, copy;
430 volID = fMC->CurrentVolID(copy);
431 //printf("\t ---> track %d in vol. %d %d (volID %d) mother %d \n",
432 //trackn, detector, sector, volID, stack->GetCurrentTrack()->GetMother(0));
433
434 // If the particle is in a ZN or ZP fiber connected to the common PMT
435 // then the assigned sector is 0 (PMC) NB-> does not work for ZEM
436 if ((fMC->CurrentMedium() == mMediumPMCid) && (detector != ZEM)) {
437 sector = 0;
438 }
439 //printf("ProcessHits: x=(%f, %f, %f) \n",x[0], x[1], x[2]);
440 //printf("\tDET %d SEC %d -> XImpact=(%f, %f, %f)\n",detector,sector, xImp.X(), xImp.Y(), xImp.Z());
441
442 if ((volID == mZNENVVolID || volID == mZPENVVolID || volID == mZEMVolID)) {
443 // there is nothing more to do here as we are not
444 // in the fiber volumes
445 return false;
446 }
447
448 float p[3] = {0., 0., 0.};
449 float trackenergy = 0.;
450 fMC->TrackMomentum(p[0], p[1], p[2], trackenergy);
451 float eDep = fMC->Edep();
452
453 int pdgCode = fMC->TrackPid();
454 float lightoutput = 0.;
455 auto currentMediumid = fMC->CurrentMedium();
456 int nphe = 0;
457 if (((currentMediumid == mMediumPMCid) || (currentMediumid == mMediumPMQid))) {
458 if (eDep) {
459 int ibeta = 0, iangle = 0, iradius = 0;
460 Bool_t isLightProduced = calculateTableIndexes(ibeta, iangle, iradius);
461 if (isLightProduced) {
462 int charge = 0;
463 if (pdgCode < 10000) {
464 charge = fMC->TrackCharge();
465 } else {
466 charge = TMath::Abs(pdgCode / 10000 - 100000);
467 }
468
469 //look into the light tables if the particle is charged
470 if (TMath::Abs(charge) > 0) {
471 if (detector == 1 || detector == 4) {
472 iradius = std::min((int)Geometry::ZNFIBREDIAMETER, iradius);
473 lightoutput = charge * charge * mLightTableZN[ibeta][iangle][iradius];
474 //printf(" \t ZNtableEntry[%d %d %d] = %1.5f -> lightoutput %f\n", ibeta, iangle, iradius, mLightTableZN[ibeta][iangle][iradius], lightoutput);
475 } else {
476 iradius = std::min((int)Geometry::ZPFIBREDIAMETER, iradius);
477 lightoutput = charge * charge * mLightTableZP[ibeta][iangle][iradius];
478 //printf(" \t ZPtableEntry[%d %d %d] = %1.5f -> lightoutput %f\n", ibeta, iangle, iradius, mLightTableZP[ibeta][iangle][iradius], lightoutput);
479 }
480 if (lightoutput > 0) {
481 nphe = o2::base::simRandom()->Poisson(lightoutput);
482 //printf(" \t\t-> nphe %d \n", nphe);
483 }
484 }
485 }
486 }
487 }
488
489 auto tof = 1.e09 * fMC->TrackTime(); //TOF in ns
490
491 if (o2::zdc::ZDCSimParam::Instance().recordSpatialResponse) {
492 // some diagnostic; trying to really get the pixel fired
493 if (nphe > 0) {
494 if (detector == ZNA || detector == ZNC) {
495 mNeutronResponseImage.setDetectorID(detector);
496 mNeutronResponseImage.addPhoton(x[0], x[1], nphe);
497 mNeutronResponseImage.setHitTime(tof);
498 }
499 if (detector == ZPA || detector == ZPC) {
500 mProtonResponseImage.setDetectorID(detector);
501 mProtonResponseImage.addPhoton(x[0], x[1], nphe);
502 mProtonResponseImage.setHitTime(tof);
503 }
504 }
505 }
506
507 // A new hit is created when there is nothing yet for this det + sector
508 if (mCurrentHitsIndices[detector - 1][sector] == -1) {
509 bool issecondary = trackn != stack->getCurrentPrimaryIndex();
510 //if(!issecondary) printf(" !!! primary track (index %d)\n",stack->getCurrentPrimaryIndex());
511
512 mTotLightPMC = mTotLightPMQ = 0;
513 if (currentMediumid == mMediumPMCid) {
514 mTotLightPMC = nphe;
515 } else if (currentMediumid == mMediumPMQid) {
516 mTotLightPMQ = nphe;
517 }
518
519 math_utils::Vector3D<float> pos(x[0], x[1], x[2]);
520 math_utils::Vector3D<float> mom(p[0], p[1], p[2]);
521 addHit(trackn, mLastPrincipalTrackEntered, issecondary, trackenergy, detector, sector,
522 pos, mom, tof, xImp, eDep, mTotLightPMC, mTotLightPMQ);
523 stack->addHit(GetDetId());
524 mCurrentHitsIndices[detector - 1][sector] = mHits->size() - 1;
525
526 mXImpact = xImp;
527 //printf("### NEW HIT CREATED in vol %d %d for track %d (mother: %d) \t light %1.0f %1.0f\n",
528 //detector, sector, trackn, stack->GetCurrentTrack()->GetFirstMother(), mTotLightPMC, mTotLightPMQ);
529 return true;
530
531 } else {
532 auto& curHit = (*mHits)[mCurrentHitsIndices[detector - 1][sector]];
533 // summing variables that needs to be updated (Eloss and light yield)
534 curHit.setNoNumContributingSteps(curHit.getNumContributingSteps() + 1);
535 int nPMC{0}, nPMQ{0};
536 if (currentMediumid == mMediumPMCid) {
537 mTotLightPMC += nphe;
538 nPMC = nphe;
539 } else if (currentMediumid == mMediumPMQid) {
540 mTotLightPMQ += nphe;
541 nPMQ = nphe;
542 }
543 float incenloss = curHit.GetEnergyLoss() + eDep;
544 if (nphe > 0) {
545 curHit.SetEnergyLoss(incenloss);
546 curHit.setPMCLightYield(curHit.getPMCLightYield() + nPMC);
547 curHit.setPMQLightYield(curHit.getPMQLightYield() + nPMQ);
548 stack->modifiesHit(GetDetId());
549 //printf(" >>> Hit updated in vol %d %d for track %d (mother: %d) \t light %1.0f %1.0f \n",
550 //detector, sector, trackn, stack->GetCurrentTrack()->GetFirstMother(), curHit.getPMCLightYield(), curHit.getPMQLightYield());
551 }
552 return true;
553 }
554 return false;
555}
556
557// function to create hit structure from a SpatialResponseImage
558// idea is to use this from a fast sim generating the response
560{
561 // one image will make one hit per sector
562 math_utils::Vector3D<float> xImp(0., 0., 0.); // good value
563
564 const int Nx = image.getNx();
565 const int Ny = image.getNy();
566 const auto& pixels = image.getImageData();
567
568 // could be put inside the image class
569 auto determineSectorID = [Nx, Ny](int detector, int x, int y) {
570 if (detector == ZNA || detector == ZNC) {
571 if ((x + y) % 2 == 0) {
572 return (int)Common;
573 }
574 if (x < Nx / 2) {
575 if (y < Ny / 2) {
576 return (int)Ch1;
577 } else {
578 return (int)Ch3;
579 }
580 } else {
581 if (y >= Ny / 2) {
582 return (int)Ch4;
583 } else {
584 return (int)Ch2;
585 }
586 }
587 }
588
589 if (detector == ZPA || detector == ZPC) {
590 if ((x + y) % 2 == 0) {
591 return (int)Common;
592 }
593 auto i = (int)(4.f * x / Nx);
594 return (int)(i + 1);
595 }
596 return -1;
597 };
598
599 auto determineMediumID = [this](int detector, int x, int y) {
600 // it is a simple checkerboard pattern
601 return ((x + y) % 2 == 0) ? mMediumPMCid : mMediumPMQid;
602 };
603
604 // loop over x = columns
605 for (int x = 0; x < Nx; ++x) {
606 // loop over y = rows
607 for (int y = 0; y < Ny; ++y) {
608 // get sector
609 int sector = determineSectorID(detector, x, y);
610 // get medium PMQ and PMC
611 int currentMediumid = determineMediumID(detector, x, y);
612 // LOG(info) << " x " << x << " y " << y << " sec " << sector << " medium " << currentMediumid;
613 int nphe = pixels[x][y];
614 float tof = 0.; // needs to be in nanoseconds ---> to be filled later on (should be meta-data of image or calculated otherwise)
615 float trackenergy = 0; // energy of the primary (need to fill good value)
616 createOrAddHit(detector,
617 sector,
618 currentMediumid,
619 0 /*issecondary ---> don't know in fast sim */,
620 nphe,
621 0 /* trackn */,
622 0 /* parent */,
623 tof,
624 trackenergy,
625 xImp,
626 0. /* eDep */, 0 /* x */, 0. /* y */, 0. /* z */, 0. /* px */, 0. /* py */, 0. /* pz */);
627 } // end loop over y
628 } // end loop over x
629 return true;
630} // end function
631
632//_____________________________________________________________________________
633o2::zdc::Hit* Detector::addHit(int32_t trackID, int32_t parentID, int32_t sFlag, float primaryEnergy, int32_t detID,
634 int32_t secID, math_utils::Vector3D<float> pos, math_utils::Vector3D<float> mom, float tof, math_utils::Vector3D<float> xImpact,
635 double energyloss, int32_t nphePMC, int32_t nphePMQ)
636{
637 LOG(debug4) << "Adding hit for track " << trackID << " X (" << pos.X() << ", " << pos.Y() << ", "
638 << pos.Z() << ") P (" << mom.X() << ", " << mom.Y() << ", " << mom.Z() << ") Ekin "
639 << primaryEnergy << " lightPMC " << nphePMC << " lightPMQ " << nphePMQ << std::endl;
640 mHits->emplace_back(trackID, parentID, sFlag, primaryEnergy, detID, secID, pos, mom,
641 tof, xImpact, energyloss, nphePMC, nphePMQ);
642 return &(mHits->back());
643}
644
645//_____________________________________________________________________________
647{
648 int32_t ifield = 2;
649 float fieldm = 10.0;
651 LOG(info) << "Detector::CreateMaterials >>>>> magnetic field: type " << ifield << " max " << fieldm << "\n";
652
653 // ******** MATERIAL DEFINITION ********
654 // --- W alloy -> ZN passive material
655 float aW[3] = {183.85, 55.85, 58.71};
656 float zW[3] = {74., 26., 28.};
657 float wW[3] = {0.93, 0.03, 0.04};
658 float dW = 17.6;
659
660 // --- Brass (CuZn) -> ZP passive material
661 float aCuZn[2] = {63.546, 65.39};
662 float zCuZn[2] = {29., 30.};
663 float wCuZn[2] = {0.63, 0.37};
664 float dCuZn = 8.48;
665
666 // --- SiO2 -> fibres
667 float aq[2] = {28.0855, 15.9994};
668 float zq[2] = {14., 8.};
669 float wq[2] = {1., 2.};
670 float dq = 2.64;
671
672 // --- Lead -> ZEM passive material
673 float aPb = 207.2;
674 float zPb = 82.;
675 float dPb = 11.35;
676 float radPb = 6.37 / dPb;
677 float absPb = 199.6 / dPb;
678
679 // --- Copper -> beam pipe
680 float aCu = 63.546;
681 float zCu = 29.;
682 float dCu = 8.96;
683 float radCu = 12.86 / dCu;
684 float absCu = 137.3 / dCu;
685 // int32_t nCu = 1.10;
686
687 // --- Iron -> beam pipe
688 float aFe = 55.845;
689 float zFe = 26.;
690 float dFe = 7.874;
691 float radFe = 13.84 / dFe;
692 float absFe = 132.1 / dFe;
693
694 // --- Aluminum -> beam pipe
695 float aAl = 26.98;
696 float zAl = 13.;
697 float dAl = 2.699;
698 float radAl = 24.01 / dAl;
699 float absAl = 107.2 / dAl;
700
701 // --- Carbon -> beam pipe
702 float aCarb = 12.01;
703 float zCarb = 6.;
704 float dCarb = 2.265;
705 float radCarb = 18.8;
706 float absCarb = 49.9;
707
708 // --- Residual gas -> inside beam pipe
709 float aResGas[3] = {1.008, 12.0107, 15.9994};
710 float zResGas[3] = {1., 6., 8.};
711 float wResGas[3] = {0.28, 0.28, 0.44};
712 float dResGas = 3.2E-14;
713
714 // --- Air
715 float aAir[4] = {12.0107, 14.0067, 15.9994, 39.948};
716 float zAir[4] = {6., 7., 8., 18.};
717 float wAir[4] = {0.000124, 0.755267, 0.231781, 0.012827};
718 float dAir = 1.20479E-3;
719
720 // ******** TRACKING MEDIA PARAMETERS ********
721 int32_t notactiveMed = 0, sensMed = 1; // sensitive or not sensitive medium
722
723 // field integration 0 no field -1 user in guswim 1 Runge Kutta 2 helix 3 const field along z
724 int32_t inofld = 0; // Max. field value (no field)
725 int32_t ifld = 2; //TODO: ????CHECK!!!! secondo me va -1!!!!!
726 float nofieldm = 0.;
727
728 float maxnofld = 0.; // max field value (no field)
729 float maxfld = 45.; // max field value (with field)
730 float tmaxnofd = 0.; // max deflection angle due to magnetic field in one step
731 float tmaxfd = 0.1; // max deflection angle due to magnetic field in one step
732 float deemax = -1.; // maximum fractional energy loss in one step 0<deemax<=1
733 float epsil = 0.001; // tracking precision [cm]
734 float stemax = 1.; // max step allowed [cm] ????CHECK!!!!
735 float stmin = 0.01; // minimum step due to continuous processes [cm] (negative value: choose it automatically) ????CHECK!!!! 0.01 in aliroot
736
737 // ******** MATERIAL DEFINITION ********
738 Mixture(0, "Walloy$", aW, zW, dW, 3, wW);
739 Mixture(1, "CuZn$", aCuZn, zCuZn, dCuZn, 2, wCuZn);
740 Mixture(2, "SiO2$", aq, zq, dq, -2, wq);
741 Material(3, "Pb $", aPb, zPb, dPb, radPb, absPb);
742 Material(4, "Cu $", aCu, zCu, dCu, radCu, absCu);
743 Material(5, "Fe $", aFe, zFe, dFe, radFe, absFe);
744 Material(6, "Al $", aAl, zAl, dAl, radAl, absAl);
745 Material(7, "graphite$", aCarb, zCarb, dCarb, radCarb, absCarb);
746 Mixture(8, "residualGas$", aResGas, zResGas, dResGas, 3, wResGas);
747 Mixture(9, "Air$", aAir, zAir, dAir, 4, wAir);
748
749 // ******** MEDIUM DEFINITION ********
750 Medium(kWalloy, "Walloy$", 0, notactiveMed, inofld, nofieldm, tmaxnofd, stemax, deemax, epsil, stmin);
751 Medium(kCuZn, "CuZn$", 1, notactiveMed, inofld, nofieldm, tmaxnofd, stemax, deemax, epsil, stmin);
752 Medium(kSiO2pmc, "quartzPMC$", 2, sensMed, inofld, nofieldm, tmaxnofd, stemax, deemax, epsil, stmin);
753 Medium(kSiO2pmq, "quartzPMQ$", 2, sensMed, inofld, nofieldm, tmaxnofd, stemax, deemax, epsil, stmin);
754 Medium(kPb, "Lead$", 3, notactiveMed, inofld, nofieldm, tmaxnofd, stemax, deemax, epsil, stmin);
755 Medium(kCu, "Copper$", 4, notactiveMed, inofld, nofieldm, tmaxnofd, stemax, deemax, epsil, stmin);
756 Medium(kCuLumi, "CopperLowTh$", 4, notactiveMed, inofld, nofieldm, tmaxnofd, stemax, deemax, epsil, stmin);
757 Medium(kFe, "Iron$", 5, notactiveMed, inofld, nofieldm, tmaxnofd, stemax, deemax, epsil, stmin);
758 Medium(kFeLowTh, "IronLowTh$", 5, notactiveMed, inofld, nofieldm, tmaxnofd, stemax, deemax, epsil, stmin);
759 Medium(kAl, "Aluminum$", 6, notactiveMed, inofld, nofieldm, tmaxnofd, stemax, deemax, epsil, stmin);
760 Medium(kGraphite, "Graphite$", 7, notactiveMed, inofld, nofieldm, tmaxnofd, stemax, deemax, epsil, stmin);
761 Medium(kVoidNoField, "VoidNoField$", 8, notactiveMed, inofld, nofieldm, tmaxnofd, stemax, deemax, epsil, stmin);
762 Medium(kVoidwField, "VoidwField$", 8, notactiveMed, ifld, maxfld, tmaxfd, stemax, deemax, epsil, stmin);
763 Medium(kAir, "Air$", 9, notactiveMed, inofld, nofieldm, tmaxnofd, stemax, deemax, epsil, stmin);
764}
765
766//_____________________________________________________________________________
767void Detector::createAsideBeamLine()
768{
769
770 double tubpar[3] = {0., 0., 0};
771 double boxpar[3] = {0., 0., 0};
772 double tubspar[5] = {0., 0., 0., 0., 0.};
773 double conpar[15] = {0.}; // all elements will be 0
774
775 float zA = 1910.4;
776
777 conpar[0] = 0.;
778 conpar[1] = 360.;
779 conpar[2] = 2.;
780 conpar[3] = zA;
781 conpar[4] = 0.;
782 conpar[5] = 55.;
783 conpar[6] = 13500.;
784 conpar[7] = 0.;
785 conpar[8] = 55.;
786 TVirtualMC::GetMC()->Gsvolu("ZDCA", "PCON", getMediumID(kVoidNoField), conpar, 9);
787 TVirtualMC::GetMC()->Gspos("ZDCA", 1, "cave", 0., 0., 0., 0, "ONLY");
788
789 // BEAM PIPE from 19.10 m to inner triplet beginning (22.965 m)
790 tubpar[0] = 6.0 / 2.;
791 tubpar[1] = 6.4 / 2.;
792 tubpar[2] = (386.28 - 0.18) / 2.;
793 TVirtualMC::GetMC()->Gsvolu("QA01", "TUBE", getMediumID(kFe), tubpar, 3);
794 TVirtualMC::GetMC()->Gspos("QA01", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
795
796 zA += 2. * tubpar[2];
797
798 // -- FIRST SECTION OF THE BEAM PIPE (from beginning of inner triplet to beginning of D1)
799 tubpar[0] = 6.3 / 2.;
800 tubpar[1] = 6.7 / 2.;
801 tubpar[2] = 3541.8 / 2.;
802 TVirtualMC::GetMC()->Gsvolu("QA02", "TUBE", getMediumID(kFe), tubpar, 3);
803 TVirtualMC::GetMC()->Gspos("QA02", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
804
805 zA += 2. * tubpar[2];
806
807 // -- SECOND SECTION OF THE BEAM PIPE (from the beginning of D1 to the beginning of D2)
808 // FROM (MAGNETIC) BEGINNING OF D1 TO THE (MAGNETIC) END OF D1 + 126.5 cm
809 // CYLINDRICAL PIPE of diameter increasing from 6.75 cm up to 8.0 cm
810 // from magnetic end :
811 // 1) 80.1 cm still with ID = 6.75 radial beam screen
812 // 2) 2.5 cm conical section from ID = 6.75 to ID = 8.0 cm
813 // 3) 43.9 cm straight section (tube) with ID = 8.0 cm
814
815 tubpar[0] = 6.75 / 2.;
816 tubpar[1] = 7.15 / 2.;
817 tubpar[2] = (945.0 + 80.1) / 2.;
818 TVirtualMC::GetMC()->Gsvolu("QA03", "TUBE", getMediumID(kFe), tubpar, 3);
819 TVirtualMC::GetMC()->Gspos("QA03", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
820
821 zA += 2. * tubpar[2];
822
823 // Transition Cone from ID=67.5 mm to ID=80 mm
824 conpar[0] = 2.5 / 2.;
825 conpar[1] = 6.75 / 2.;
826 conpar[2] = 7.15 / 2.;
827 conpar[3] = 8.0 / 2.;
828 conpar[4] = 8.4 / 2.;
829 TVirtualMC::GetMC()->Gsvolu("QA04", "CONE", getMediumID(kFe), conpar, 5);
830 TVirtualMC::GetMC()->Gspos("QA04", 1, "ZDCA", 0., 0., conpar[0] + zA, 0, "ONLY");
831
832 zA += 2. * conpar[0];
833
834 tubpar[0] = 8.0 / 2.;
835 tubpar[1] = 8.4 / 2.;
836 tubpar[2] = (43.9 + 20. + 28.5 + 28.5) / 2.;
837 TVirtualMC::GetMC()->Gsvolu("QA05", "TUBE", getMediumID(kFe), tubpar, 3);
838 TVirtualMC::GetMC()->Gspos("QA05", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
839
840 zA += 2. * tubpar[2];
841
842 // Second section of VAEHI (transition cone from ID=80mm to ID=98mm)
843 conpar[0] = 4.0 / 2.;
844 conpar[1] = 8.0 / 2.;
845 conpar[2] = 8.4 / 2.;
846 conpar[3] = 9.8 / 2.;
847 conpar[4] = 10.2 / 2.;
848 TVirtualMC::GetMC()->Gsvolu("QAV1", "CONE", getMediumID(kFe), conpar, 5);
849 TVirtualMC::GetMC()->Gspos("QAV1", 1, "ZDCA", 0., 0., conpar[0] + zA, 0, "ONLY");
850
851 zA += 2. * conpar[0];
852
853 //Third section of VAEHI (transition cone from ID=98mm to ID=90mm)
854 conpar[0] = 1.0 / 2.;
855 conpar[1] = 9.8 / 2.;
856 conpar[2] = 10.2 / 2.;
857 conpar[3] = 9.0 / 2.;
858 conpar[4] = 9.4 / 2.;
859 TVirtualMC::GetMC()->Gsvolu("QAV2", "CONE", getMediumID(kFe), conpar, 5);
860 TVirtualMC::GetMC()->Gspos("QAV2", 1, "ZDCA", 0., 0., conpar[0] + zA, 0, "ONLY");
861
862 zA += 2. * conpar[0];
863
864 // Fourth section of VAEHI (tube ID=90mm)
865 tubpar[0] = 9.0 / 2.;
866 tubpar[1] = 9.4 / 2.;
867 tubpar[2] = 31.0 / 2.;
868 TVirtualMC::GetMC()->Gsvolu("QAV3", "TUBE", getMediumID(kFe), tubpar, 3);
869 TVirtualMC::GetMC()->Gspos("QAV3", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
870
871 zA += 2. * tubpar[2];
872
873 //---------------------------- TCDD beginning ----------------------------------
874 // space for the insertion of the collimator TCDD (2 m)
875 // TCDD ZONE - 1st volume
876 conpar[0] = 1.3 / 2.;
877 conpar[1] = 9.0 / 2.;
878 conpar[2] = 13.0 / 2.;
879 conpar[3] = 9.6 / 2.;
880 conpar[4] = 13.0 / 2.;
881 TVirtualMC::GetMC()->Gsvolu("Q01T", "CONE", getMediumID(kFe), conpar, 5);
882 TVirtualMC::GetMC()->Gspos("Q01T", 1, "ZDCA", 0., 0., conpar[0] + zA, 0, "ONLY");
883
884 zA += 2. * conpar[0];
885
886 // TCDD ZONE - 2nd volume
887 tubpar[0] = 9.6 / 2.;
888 tubpar[1] = 10.0 / 2.;
889 tubpar[2] = 1.0 / 2.;
890 TVirtualMC::GetMC()->Gsvolu("Q02T", "TUBE", getMediumID(kFe), tubpar, 3);
891 TVirtualMC::GetMC()->Gspos("Q02T", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
892
893 zA += 2. * tubpar[2];
894
895 // TCDD ZONE - third volume
896 conpar[0] = 9.04 / 2.;
897 conpar[1] = 9.6 / 2.;
898 conpar[2] = 10.0 / 2.;
899 conpar[3] = 13.8 / 2.;
900 conpar[4] = 14.2 / 2.;
901 TVirtualMC::GetMC()->Gsvolu("Q03T", "CONE", getMediumID(kFe), conpar, 5);
902 TVirtualMC::GetMC()->Gspos("Q03T", 1, "ZDCA", 0., 0., conpar[0] + zA, 0, "ONLY");
903
904 zA += 2. * conpar[0];
905
906 // TCDD ZONE - 4th volume
907 tubpar[0] = 13.8 / 2.;
908 tubpar[1] = 14.2 / 2.;
909 tubpar[2] = 38.6 / 2.;
910 TVirtualMC::GetMC()->Gsvolu("Q04T", "TUBE", getMediumID(kFe), tubpar, 3);
911 TVirtualMC::GetMC()->Gspos("Q04T", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
912
913 zA += 2. * tubpar[2];
914
915 // TCDD ZONE - 5th volume
916 tubpar[0] = 21.0 / 2.;
917 tubpar[1] = 21.4 / 2.;
918 tubpar[2] = 100.12 / 2.;
919 TVirtualMC::GetMC()->Gsvolu("Q05T", "TUBE", getMediumID(kFe), tubpar, 3);
920 TVirtualMC::GetMC()->Gspos("Q05T", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
921
922 zA += 2. * tubpar[2];
923
924 // TCDD ZONE - 6th volume
925 tubpar[0] = 13.8 / 2.;
926 tubpar[1] = 14.2 / 2.;
927 tubpar[2] = 38.6 / 2.;
928 TVirtualMC::GetMC()->Gsvolu("Q06T", "TUBE", getMediumID(kFe), tubpar, 3);
929 TVirtualMC::GetMC()->Gspos("Q06T", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
930
931 zA += 2. * tubpar[2];
932
933 // TCDD ZONE - 7th volume
934 conpar[0] = 11.34 / 2.;
935 conpar[1] = 13.8 / 2.;
936 conpar[2] = 14.2 / 2.;
937 conpar[3] = 18.0 / 2.;
938 conpar[4] = 18.4 / 2.;
939 TVirtualMC::GetMC()->Gsvolu("Q07T", "CONE", getMediumID(kFe), conpar, 5);
940 TVirtualMC::GetMC()->Gspos("Q07T", 1, "ZDCA", 0., 0., conpar[0] + zA, 0, "ONLY");
941
942 zA += 2. * conpar[0];
943
944 // Upper section : one single phi segment of a tube
945 // 5 parameters for tubs: inner radius = 0.,
946 // outer radius = 7. cm, half length = 50 cm
947 // phi1 = 0., phi2 = 180.
948 tubspar[0] = 0.0 / 2.;
949 tubspar[1] = 14.0 / 2.;
950 tubspar[2] = 100.0 / 2.;
951 tubspar[3] = 0.;
952 tubspar[4] = 180.;
953 TVirtualMC::GetMC()->Gsvolu("Q08T", "TUBS", getMediumID(kFe), tubspar, 5);
954
955 // rectangular beam pipe inside TCDD upper section (Vacuum)
956 boxpar[0] = 7.0 / 2.;
957 boxpar[1] = 2.2 / 2.;
958 boxpar[2] = 100. / 2.;
959 TVirtualMC::GetMC()->Gsvolu("Q09T", "BOX ", getMediumID(kVoidNoField), boxpar, 3);
960 // positioning vacuum box in the upper section of TCDD
961 TVirtualMC::GetMC()->Gspos("Q09T", 1, "Q08T", 0., 1.1, 0., 0, "ONLY");
962
963 // lower section : one single phi segment of a tube
964 tubspar[0] = 0.0 / 2.;
965 tubspar[1] = 14.0 / 2.;
966 tubspar[2] = 100.0 / 2.;
967 tubspar[3] = 180.;
968 tubspar[4] = 360.;
969 TVirtualMC::GetMC()->Gsvolu("Q10T", "TUBS", getMediumID(kFe), tubspar, 5);
970 // rectangular beam pipe inside TCDD lower section (Vacuum)
971 boxpar[0] = 7.0 / 2.;
972 boxpar[1] = 2.2 / 2.;
973 boxpar[2] = 100. / 2.;
974 TVirtualMC::GetMC()->Gsvolu("Q11T", "BOX ", getMediumID(kVoidNoField), boxpar, 3);
975 // positioning vacuum box in the lower section of TCDD
976 TVirtualMC::GetMC()->Gspos("Q11T", 1, "Q10T", 0., -1.1, 0., 0, "ONLY");
977
978 // positioning TCDD elements in ZDCA, (inside TCDD volume)
979 // TODO: think about making those parameters tunable/settable from outside
980 double TCDDAperturePos = 2.2;
981 double TCDDApertureNeg = 2.4;
982 TVirtualMC::GetMC()->Gspos("Q08T", 1, "ZDCA", 0., TCDDAperturePos, -100. + zA, 0, "ONLY");
983 TVirtualMC::GetMC()->Gspos("Q10T", 1, "ZDCA", 0., -TCDDApertureNeg, -100. + zA, 0, "ONLY");
984
985 // RF screen
986 boxpar[0] = 0.2 / 2.;
987 boxpar[1] = 4.0 / 2.;
988 boxpar[2] = 100. / 2.;
989 TVirtualMC::GetMC()->Gsvolu("Q12T", "BOX ", getMediumID(kFe), boxpar, 3);
990 // positioning RF screen at both sides of TCDD
991 TVirtualMC::GetMC()->Gspos("Q12T", 1, "ZDCA", tubspar[1] + boxpar[0], 0., -100. + zA, 0, "ONLY");
992 TVirtualMC::GetMC()->Gspos("Q12T", 2, "ZDCA", -tubspar[1] - boxpar[0], 0., -100. + zA, 0, "ONLY");
993 //---------------------------- TCDD end ---------------------------------------
994
995 // The following elliptical tube 180 mm x 70 mm (obtained positioning the void QA06 in QA07)
996 // represents VAMTF + first part of VCTCP (93 mm)
997
998 tubpar[0] = 18.4 / 2.;
999 tubpar[1] = 7.4 / 2.;
1000 tubpar[2] = (78 + 9.3) / 2.;
1001 TVirtualMC::GetMC()->Gsvolu("QA06", "ELTU", getMediumID(kFe), tubpar, 3);
1002 // AliRoot: temporary replace with a scaled tube (AG) ????????????
1003 /*TGeoTube *tubeQA06 = new TGeoTube(0.,tubpar[0],tubpar[2]);
1004 TGeoScale *scaleQA06 = new TGeoScale(1., tubpar[1]/tubpar[0], 1.);
1005 TGeoScaledShape *sshapeQA06 = new TGeoScaledShape(tubeQA06, scaleQA06);
1006 new TGeoVolume("QA06", sshapeQA06, gGeoManager->GetMedium(getMediumID(kVoidNoField)));*/
1007
1008 tubpar[0] = 18.0 / 2.;
1009 tubpar[1] = 7.0 / 2.;
1010 tubpar[2] = (78 + 9.3) / 2.;
1011 TVirtualMC::GetMC()->Gsvolu("QA07", "ELTU", getMediumID(kVoidNoField), tubpar, 3);
1012 // temporary replace with a scaled tube (AG) ????????????
1013 /*TGeoTube *tubeQA07 = new TGeoTube(0.,tubpar[0],tubpar[2]);
1014 TGeoScale *scaleQA07 = new TGeoScale(1., tubpar[1]/tubpar[0], 1.);
1015 TGeoScaledShape *sshapeQA07 = new TGeoScaledShape(tubeQA07, scaleQA07);
1016 new TGeoVolume("QA07", sshapeQA07, gGeoManager->GetMedium(getMediumID(k10]));*/
1017 TVirtualMC::GetMC()->Gspos("QA06", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
1018 TVirtualMC::GetMC()->Gspos("QA07", 1, "QA06", 0., 0., 0., 0, "ONLY");
1019
1020 zA += 2. * tubpar[2];
1021
1022 // VCTCP second part: transition cone from ID=180 to ID=212.7
1023 conpar[0] = 31.5 / 2.;
1024 conpar[1] = 18.0 / 2.;
1025 conpar[2] = 18.6 / 2.;
1026 conpar[3] = 21.27 / 2.;
1027 conpar[4] = 21.87 / 2.;
1028 TVirtualMC::GetMC()->Gsvolu("QA08", "CONE", getMediumID(kFe), conpar, 5);
1029 TVirtualMC::GetMC()->Gspos("QA08", 1, "ZDCA", 0., 0., conpar[0] + zA, 0, "ONLY");
1030
1031 zA += 2. * conpar[0];
1032
1033 //-- rotation matrices for the tilted cone after the TDI to recenter vacuum chamber
1034 int32_t irotpipe3, irotpipe4, irotpipe5;
1035 double rang3[6] = {90. - 1.8934, 0., 90., 90., 1.8934, 180.};
1036 double rang4[6] = {90. - 3.8, 0., 90., 90., 3.8, 180.};
1037 double rang5[6] = {90. + 9.8, 0., 90., 90., 9.8, 0.};
1038 TVirtualMC::GetMC()->Matrix(irotpipe3, rang3[0], rang3[1], rang3[2], rang3[3], rang3[4], rang3[5]);
1039 TVirtualMC::GetMC()->Matrix(irotpipe4, rang4[0], rang4[1], rang4[2], rang4[3], rang4[4], rang4[5]);
1040 TVirtualMC::GetMC()->Matrix(irotpipe5, rang5[0], rang5[1], rang5[2], rang5[3], rang5[4], rang5[5]);
1041
1042 // Tube ID 212.7 mm
1043 // Represents VCTCP third part (92 mm) + VCDWB (765 mm) + VMBGA (400 mm) +
1044 // VCDWE (300 mm) + VMBGA (400 mm) + TCTVB space + VAMTF space
1045 tubpar[0] = 21.27 / 2.;
1046 tubpar[1] = 21.87 / 2.;
1047 tubpar[2] = (195.7 + 148. + 78.) / 2.;
1048 TVirtualMC::GetMC()->Gsvolu("QA09", "TUBE", getMediumID(kFe), tubpar, 3);
1049 TVirtualMC::GetMC()->Gspos("QA09", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
1050
1051 zA += 2. * tubpar[2];
1052
1053 // skewed transition piece (ID=212.7 mm to 332 mm) (before TDI)
1054 conpar[0] = (50.0 - 0.73 - 1.13) / 2.;
1055 conpar[1] = 21.27 / 2.;
1056 conpar[2] = 21.87 / 2.;
1057 conpar[3] = 33.2 / 2.;
1058 conpar[4] = 33.8 / 2.;
1059 TVirtualMC::GetMC()->Gsvolu("QA10", "CONE", getMediumID(kFe), conpar, 5);
1060 TVirtualMC::GetMC()->Gspos("QA10", 1, "ZDCA", -1.66, 0., conpar[0] + 0.73 + zA, irotpipe4, "ONLY");
1061
1062 zA += 2. * conpar[0] + 0.73 + 1.13;
1063
1064 // Vacuum chamber containing TDI
1065 tubpar[0] = 0.;
1066 tubpar[1] = 54.6 / 2.;
1067 tubpar[2] = 540.0 / 2.;
1068 TVirtualMC::GetMC()->Gsvolu("Q13TM", "TUBE", getMediumID(kVoidNoField), tubpar, 3);
1069 TVirtualMC::GetMC()->Gspos("Q13TM", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
1070 tubpar[0] = 54.0 / 2.;
1071 tubpar[1] = 54.6 / 2.;
1072 tubpar[2] = 540.0 / 2.;
1073 TVirtualMC::GetMC()->Gsvolu("Q13T", "TUBE", getMediumID(kFe), tubpar, 3);
1074 TVirtualMC::GetMC()->Gspos("Q13T", 1, "Q13TM", 0., 0., 0., 0, "ONLY");
1075
1076 zA += 2. * tubpar[2];
1077
1078 //---------------- INSERT TDI INSIDE Q13T -----------------------------------
1079 boxpar[0] = 11.0 / 2.;
1080 boxpar[1] = 9.0 / 2.;
1081 boxpar[2] = 418.5 / 2.;
1082 double TDIAperturePos = 6.;
1083 TVirtualMC::GetMC()->Gsvolu("QTD1", "BOX ", getMediumID(kFe), boxpar, 3);
1084 TVirtualMC::GetMC()->Gspos("QTD1", 1, "Q13TM", -3.8, boxpar[1] + TDIAperturePos, 0., 0, "ONLY");
1085 boxpar[0] = 11.0 / 2.;
1086 boxpar[1] = 9.0 / 2.;
1087 boxpar[2] = 418.5 / 2.;
1088 TVirtualMC::GetMC()->Gsvolu("QTD2", "BOX ", getMediumID(kFe), boxpar, 3);
1089 double TDIApertureNeg = 6.;
1090 TVirtualMC::GetMC()->Gspos("QTD2", 1, "Q13TM", -3.8, -boxpar[1] - TDIApertureNeg, 0., 0, "ONLY");
1091 boxpar[0] = 5.1 / 2.;
1092 boxpar[1] = 0.2 / 2.;
1093 boxpar[2] = 418.5 / 2.;
1094 TVirtualMC::GetMC()->Gsvolu("QTD3", "BOX ", getMediumID(kFe), boxpar, 3);
1095 TVirtualMC::GetMC()->Gspos("QTD3", 1, "Q13TM", -3.8 + 5.5 + boxpar[0], TDIAperturePos, 0., 0, "ONLY");
1096 TVirtualMC::GetMC()->Gspos("QTD3", 2, "Q13TM", -3.8 + 5.5 + boxpar[0], -TDIApertureNeg, 0., 0, "ONLY");
1097 TVirtualMC::GetMC()->Gspos("QTD3", 3, "Q13TM", -3.8 - 5.5 - boxpar[0], TDIAperturePos, 0., 0, "ONLY");
1098 TVirtualMC::GetMC()->Gspos("QTD3", 4, "Q13TM", -3.8 - 5.5 - boxpar[0], -TDIApertureNeg, 0., 0, "ONLY");
1099 //
1100 tubspar[0] = 12.0 / 2.;
1101 tubspar[1] = 12.4 / 2.;
1102 tubspar[2] = 418.5 / 2.;
1103 tubspar[3] = 90.;
1104 tubspar[4] = 270.;
1105 TVirtualMC::GetMC()->Gsvolu("QTD4", "TUBS", getMediumID(kCu), tubspar, 5);
1106 TVirtualMC::GetMC()->Gspos("QTD4", 1, "Q13TM", -3.8 - 10.6, 0., 0., 0, "ONLY");
1107 tubspar[0] = 12.0 / 2.;
1108 tubspar[1] = 12.4 / 2.;
1109 tubspar[2] = 418.5 / 2.;
1110 tubspar[3] = -90.;
1111 tubspar[4] = 90.;
1112 TVirtualMC::GetMC()->Gsvolu("QTD5", "TUBS", getMediumID(kCu), tubspar, 5);
1113 TVirtualMC::GetMC()->Gspos("QTD5", 1, "Q13TM", -3.8 + 10.6, 0., 0., 0, "ONLY");
1114 //---------------- END DEFINING TDI INSIDE Q13T -------------------------------
1115
1116 // VCTCG skewed transition piece (ID=332 mm to 212.7 mm) (after TDI)
1117 conpar[0] = (50.0 - 2.92 - 1.89) / 2.;
1118 conpar[1] = 33.2 / 2.;
1119 conpar[2] = 33.8 / 2.;
1120 conpar[3] = 21.27 / 2.;
1121 conpar[4] = 21.87 / 2.;
1122 TVirtualMC::GetMC()->Gsvolu("QA11", "CONE", getMediumID(kFe), conpar, 5);
1123 TVirtualMC::GetMC()->Gspos("QA11", 1, "ZDCA", 4.32 - 3.8, 0., conpar[0] + 2.92 + zA, irotpipe5, "ONLY");
1124
1125 zA += 2. * conpar[0] + 2.92 + 1.89;
1126
1127 // The following tube ID 212.7 mm
1128 // represents VMBGA (400 mm) + VCDWE (300 mm) + VMBGA (400 mm) +
1129 // BTVTS (600 mm) + VMLGB (400 mm)
1130 tubpar[0] = 21.27 / 2.;
1131 tubpar[1] = 21.87 / 2.;
1132 tubpar[2] = 210.0 / 2.;
1133 TVirtualMC::GetMC()->Gsvolu("QA12", "TUBE", getMediumID(kFe), tubpar, 3);
1134 TVirtualMC::GetMC()->Gspos("QA12", 1, "ZDCA", 4., 0., tubpar[2] + zA, 0, "ONLY");
1135
1136 zA += 2. * tubpar[2];
1137
1138 // First part of VCTCC
1139 // skewed transition cone from ID=212.7 mm to ID=797 mm
1140 conpar[0] = (121.0 - 0.37 - 1.35) / 2.;
1141 conpar[1] = 21.27 / 2.;
1142 conpar[2] = 21.87 / 2.;
1143 conpar[3] = 79.7 / 2.;
1144 conpar[4] = 81.3 / 2.;
1145 TVirtualMC::GetMC()->Gsvolu("QA13", "CONE", getMediumID(kFe), conpar, 5);
1146 TVirtualMC::GetMC()->Gspos("QA13", 1, "ZDCA", 4. - 2., 0., conpar[0] + 0.37 + zA, irotpipe3, "ONLY");
1147
1148 zA += 2. * conpar[0] + 0.37 + 1.35;
1149
1150 // The following tube ID 797 mm represents the second part of VCTCC (4272 mm) +
1151 // 4 x VCDGA (4 x 4272 mm) + the first part of VCTCR (850 mm)
1152 tubpar[0] = 79.7 / 2.;
1153 tubpar[1] = 81.3 / 2.;
1154 tubpar[2] = (2221. - 136.) / 2.;
1155 TVirtualMC::GetMC()->Gsvolu("QA14", "TUBE", getMediumID(kFe), tubpar, 3);
1156 TVirtualMC::GetMC()->Gspos("QA14", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
1157
1158 zA += 2. * tubpar[2];
1159
1160 // Second part of VCTCR
1161 // Transition from ID=797 mm to ID=196 mm. To simulate the thin window opened in the transition cone
1162 // we divide the transition cone in three cones:
1163 // (1) 8 mm thick (2) 3 mm thick (3) the third 8 mm thick
1164
1165 // (1) 8 mm thick
1166 conpar[0] = 9.09 / 2.; // 15 degree
1167 conpar[1] = 79.7 / 2.;
1168 conpar[2] = 81.3 / 2.; // thickness 8 mm
1169 conpar[3] = 74.82868 / 2.;
1170 conpar[4] = 76.42868 / 2.; // thickness 8 mm
1171 TVirtualMC::GetMC()->Gsvolu("QA15", "CONE", getMediumID(kFe), conpar, 5);
1172 TVirtualMC::GetMC()->Gspos("QA15", 1, "ZDCA", 0., 0., conpar[0] + zA, 0, "ONLY");
1173
1174 zA += 2. * conpar[0];
1175
1176 // (2) 3 mm thick
1177 conpar[0] = 96.2 / 2.; // 15 degree
1178 conpar[1] = 74.82868 / 2.;
1179 conpar[2] = 75.42868 / 2.; // thickness 3 mm
1180 conpar[3] = 23.19588 / 2.;
1181 conpar[4] = 23.79588 / 2.; // thickness 3 mm
1182 TVirtualMC::GetMC()->Gsvolu("QA16", "CONE", getMediumID(kFe), conpar, 5);
1183 TVirtualMC::GetMC()->Gspos("QA16", 1, "ZDCA", 0., 0., conpar[0] + zA, 0, "ONLY");
1184
1185 zA += 2. * conpar[0];
1186
1187 // (3) 8 mm thick
1188 conpar[0] = 6.71 / 2.; // 15 degree
1189 conpar[1] = 23.19588 / 2.;
1190 conpar[2] = 24.79588 / 2.; // thickness 8 mm
1191 conpar[3] = 19.6 / 2.;
1192 conpar[4] = 21.2 / 2.; // thickness 8 mm
1193 TVirtualMC::GetMC()->Gsvolu("QA17", "CONE", getMediumID(kFe), conpar, 5);
1194 TVirtualMC::GetMC()->Gspos("QA17", 1, "ZDCA", 0., 0., conpar[0] + zA, 0, "ONLY");
1195
1196 zA += 2. * conpar[0];
1197
1198 // Third part of VCTCR: tube (ID=196 mm)
1199 tubpar[0] = 19.6 / 2.;
1200 tubpar[1] = 21.2 / 2.;
1201 tubpar[2] = 9.55 / 2.;
1202 TVirtualMC::GetMC()->Gsvolu("QA18", "TUBE", getMediumID(kFe), tubpar, 3);
1203 TVirtualMC::GetMC()->Gspos("QA18", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
1204
1205 zA += 2. * tubpar[2];
1206
1207 // Flange (ID=196 mm) (last part of VCTCR and first part of VMZAR)
1208 tubpar[0] = 19.6 / 2.;
1209 tubpar[1] = 25.3 / 2.;
1210 tubpar[2] = 4.9 / 2.;
1211 TVirtualMC::GetMC()->Gsvolu("QF01", "TUBE", getMediumID(kFe), tubpar, 3);
1212 TVirtualMC::GetMC()->Gspos("QF01", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
1213
1214 zA += 2. * tubpar[2];
1215
1216 // VMZAR (5 volumes)
1217 tubpar[0] = 20.2 / 2.;
1218 tubpar[1] = 20.6 / 2.;
1219 tubpar[2] = 2.15 / 2.;
1220 TVirtualMC::GetMC()->Gsvolu("QA19", "TUBE", getMediumID(kFe), tubpar, 3);
1221 TVirtualMC::GetMC()->Gspos("QA19", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
1222
1223 zA += 2. * tubpar[2];
1224
1225 conpar[0] = 6.9 / 2.;
1226 conpar[1] = 20.2 / 2.;
1227 conpar[2] = 20.6 / 2.;
1228 conpar[3] = 23.9 / 2.;
1229 conpar[4] = 24.3 / 2.;
1230 TVirtualMC::GetMC()->Gsvolu("QA20", "CONE", getMediumID(kFe), conpar, 5);
1231 TVirtualMC::GetMC()->Gspos("QA20", 1, "ZDCA", 0., 0., conpar[0] + zA, 0, "ONLY");
1232
1233 zA += 2. * conpar[0];
1234
1235 tubpar[0] = 23.9 / 2.;
1236 tubpar[1] = 25.5 / 2.;
1237 tubpar[2] = 17.0 / 2.;
1238 TVirtualMC::GetMC()->Gsvolu("QA21", "TUBE", getMediumID(kFe), tubpar, 3);
1239 TVirtualMC::GetMC()->Gspos("QA21", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
1240
1241 zA += 2. * tubpar[2];
1242
1243 conpar[0] = 6.9 / 2.;
1244 conpar[1] = 23.9 / 2.;
1245 conpar[2] = 24.3 / 2.;
1246 conpar[3] = 20.2 / 2.;
1247 conpar[4] = 20.6 / 2.;
1248 TVirtualMC::GetMC()->Gsvolu("QA22", "CONE", getMediumID(kFe), conpar, 5);
1249 TVirtualMC::GetMC()->Gspos("QA22", 1, "ZDCA", 0., 0., conpar[0] + zA, 0, "ONLY");
1250
1251 zA += 2. * conpar[0];
1252
1253 tubpar[0] = 20.2 / 2.;
1254 tubpar[1] = 20.6 / 2.;
1255 tubpar[2] = 2.15 / 2.;
1256 TVirtualMC::GetMC()->Gsvolu("QA23", "TUBE", getMediumID(kFe), tubpar, 3);
1257 TVirtualMC::GetMC()->Gspos("QA23", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
1258
1259 zA += 2. * tubpar[2];
1260
1261 // Flange (ID=196 mm)(last part of VMZAR and first part of VCTYD)
1262 tubpar[0] = 19.6 / 2.;
1263 tubpar[1] = 25.3 / 2.;
1264 tubpar[2] = 4.9 / 2.;
1265 TVirtualMC::GetMC()->Gsvolu("QF02", "TUBE", getMediumID(kFe), tubpar, 3);
1266 TVirtualMC::GetMC()->Gspos("QF02", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
1267
1268 zA += 2. * tubpar[2];
1269
1270 // simulation of the trousers (VCTYB)
1271 tubpar[0] = 19.6 / 2.;
1272 tubpar[1] = 20.0 / 2.;
1273 tubpar[2] = 3.9 / 2.;
1274 TVirtualMC::GetMC()->Gsvolu("QA24", "TUBE", getMediumID(kFe), tubpar, 3);
1275 TVirtualMC::GetMC()->Gspos("QA24", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
1276
1277 zA += 2. * tubpar[2];
1278
1279 // transition cone from ID=196. to ID=216.6
1280 conpar[0] = 32.55 / 2.;
1281 conpar[1] = 19.6 / 2.;
1282 conpar[2] = 20.0 / 2.;
1283 conpar[3] = 21.66 / 2.;
1284 conpar[4] = 22.06 / 2.;
1285 TVirtualMC::GetMC()->Gsvolu("QA25", "CONE", getMediumID(kFe), conpar, 5);
1286 TVirtualMC::GetMC()->Gspos("QA25", 1, "ZDCA", 0., 0., conpar[0] + zA, 0, "ONLY");
1287
1288 zA += 2. * conpar[0];
1289
1290 // tube
1291 tubpar[0] = 21.66 / 2.;
1292 tubpar[1] = 22.06 / 2.;
1293 tubpar[2] = 28.6 / 2.;
1294 TVirtualMC::GetMC()->Gsvolu("QA26", "TUBE", getMediumID(kFe), tubpar, 3);
1295 TVirtualMC::GetMC()->Gspos("QA26", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
1296
1297 zA += 2. * tubpar[2];
1298
1299 // --------------------------------------------------------
1300 // RECOMBINATION CHAMBER
1301 // TRANSFORMATION MATRICES
1302 double dx = -3.970000;
1303 double dy = 0.000000;
1304 double dz = 0.0;
1305 // Rotation:
1306 double thx = 84.989100;
1307 double phx = 0.000000;
1308 double thy = 90.000000;
1309 double phy = 90.000000;
1310 double thz = 5.010900;
1311 double phz = 180.000000;
1312 TGeoRotation* rotMatrix1 = new TGeoRotation("", thx, phx, thy, phy, thz, phz);
1313 // Combi transformation:
1314 TGeoCombiTrans* rotMatrix2 = new TGeoCombiTrans("ZDC_c1", dx, dy, dz, rotMatrix1);
1315 rotMatrix2->RegisterYourself();
1316 // Combi transformation:
1317 // Rotation:
1318 double thx3 = 95.010900;
1319 double phx3 = 0.000000;
1320 double thy3 = 90.000000;
1321 double phy3 = 90.000000;
1322 double thz3 = 5.010900;
1323 double phz3 = 0.000000;
1324 TGeoRotation* rotMatrix3 = new TGeoRotation("", thx3, phx3, thy3, phy3, thz3, phz3);
1325 TGeoCombiTrans* rotMatrix4 = new TGeoCombiTrans("ZDC_c2", -dx, dy, dz, rotMatrix3);
1326 rotMatrix4->RegisterYourself();
1327
1328 //-- rotation matrices for the legs
1329 int32_t irotpipe1, irotpipe2;
1330 double rang1[6] = {90. - 1.0027, 0., 90., 90., 1.0027, 180.};
1331 double rang2[6] = {90. + 1.0027, 0., 90., 90., 1.0027, 0.};
1332 TVirtualMC::GetMC()->Matrix(irotpipe1, rang1[0], rang1[1], rang1[2], rang1[3], rang1[4], rang1[5]);
1333 TVirtualMC::GetMC()->Matrix(irotpipe2, rang2[0], rang2[1], rang2[2], rang2[3], rang2[4], rang2[5]);
1334
1335 // VOLUMES DEFINITION
1336 // Volume: ZDCA
1337 TGeoVolume* pZDCA = gGeoManager->GetVolume("ZDCA");
1338
1339 conpar[0] = (90.1 - 0.95 - 0.26) / 2.;
1340 conpar[1] = 0.0 / 2.;
1341 conpar[2] = 21.6 / 2.;
1342 conpar[3] = 0.0 / 2.;
1343 conpar[4] = 5.8 / 2.;
1344 new TGeoCone("QALext", conpar[0], conpar[1], conpar[2], conpar[3], conpar[4]);
1345
1346 conpar[0] = (90.1 - 0.95 - 0.26) / 2.;
1347 conpar[1] = 0.0 / 2.;
1348 conpar[2] = 21.2 / 2.;
1349 conpar[3] = 0.0 / 2.;
1350 conpar[4] = 5.4 / 2.;
1351 new TGeoCone("QALint", conpar[0], conpar[1], conpar[2], conpar[3], conpar[4]);
1352
1353 // Outer trousers
1354 TGeoCompositeShape* pOutTrousers = new TGeoCompositeShape("outTrousers", "QALext:ZDC_c1+QALext:ZDC_c2");
1355
1356 auto& matmgr = o2::base::MaterialManager::Instance();
1357
1358 // Volume: QALext
1359 TGeoVolume* pQALext = new TGeoVolume("QALext", pOutTrousers, matmgr.getTGeoMedium("ZDC", kFeLowTh));
1360 pQALext->SetLineColor(kBlue);
1361 pQALext->SetVisLeaves(kTRUE);
1362 //
1363 TGeoTranslation* tr1 = new TGeoTranslation(0., 0., (double)conpar[0] + 0.95 + zA);
1364 pZDCA->AddNode(pQALext, 1, tr1);
1365 // Inner trousers
1366 TGeoCompositeShape* pIntTrousers = new TGeoCompositeShape("intTrousers", "QALint:ZDC_c1+QALint:ZDC_c2");
1367 // Volume: QALint
1368 TGeoVolume* pQALint = new TGeoVolume("QALint", pIntTrousers, matmgr.getTGeoMedium("ZDC", kVoidNoField));
1369 pQALint->SetLineColor(kAzure);
1370 pQALint->SetVisLeaves(kTRUE);
1371 pQALext->AddNode(pQALint, 1);
1372
1373 zA += 90.1;
1374
1375 // second section : 2 tubes (ID = 54. OD = 58.)
1376 tubpar[0] = 5.4 / 2.;
1377 tubpar[1] = 5.8 / 2.;
1378 tubpar[2] = 40.0 / 2.;
1379 TVirtualMC::GetMC()->Gsvolu("QA27", "TUBE", getMediumID(kFe), tubpar, 3);
1380 TVirtualMC::GetMC()->Gspos("QA27", 1, "ZDCA", -15.8 / 2., 0., tubpar[2] + zA, 0, "ONLY");
1381 TVirtualMC::GetMC()->Gspos("QA27", 2, "ZDCA", 15.8 / 2., 0., tubpar[2] + zA, 0, "ONLY");
1382
1383 zA += 2. * tubpar[2];
1384
1385 // transition x2zdc to recombination chamber : skewed cone
1386 conpar[0] = (10. - 1.) / 2.;
1387 conpar[1] = 5.4 / 2.;
1388 conpar[2] = 5.8 / 2.;
1389 conpar[3] = 6.3 / 2.;
1390 conpar[4] = 7.0 / 2.;
1391 TVirtualMC::GetMC()->Gsvolu("QA28", "CONE", getMediumID(kFe), conpar, 5);
1392 TVirtualMC::GetMC()->Gspos("QA28", 1, "ZDCA", -7.9 - 0.175, 0., conpar[0] + 0.5 + zA, irotpipe1, "ONLY");
1393 TVirtualMC::GetMC()->Gspos("QA28", 2, "ZDCA", 7.9 + 0.175, 0., conpar[0] + 0.5 + zA, irotpipe2, "ONLY");
1394
1395 zA += 2. * conpar[0] + 1.;
1396
1397 // 2 tubes (ID = 63 mm OD=70 mm)
1398 tubpar[0] = 6.3 / 2.;
1399 tubpar[1] = 7.0 / 2.;
1400 tubpar[2] = (342.5 + 498.3) / 2.;
1401 TVirtualMC::GetMC()->Gsvolu("QA29", "TUBE", getMediumID(kFe), tubpar, 3);
1402 TVirtualMC::GetMC()->Gspos("QA29", 1, "ZDCA", -16.5 / 2., 0., tubpar[2] + zA, 0, "ONLY");
1403 TVirtualMC::GetMC()->Gspos("QA29", 2, "ZDCA", 16.5 / 2., 0., tubpar[2] + zA, 0, "ONLY");
1404 //printf("QA29 TUBE from z = %1.2f to z= %1.2f (separate pipes)\n",zA,2*tubpar[2]+zA);
1405
1406 zA += 2. * tubpar[2];
1407
1408 // -- Luminometer (Cu box) in front of ZN - side A
1409 if (mLumiLength > 0.) { // FIX IT!!!!!!!!!!!!!!!
1410 boxpar[0] = 8.0 / 2.;
1411 boxpar[1] = 8.0 / 2.;
1412 boxpar[2] = mLumiLength / 2.;
1413 TVirtualMC::GetMC()->Gsvolu("QLUA", "BOX ", getMediumID(kCuLumi), boxpar, 3);
1414 TVirtualMC::GetMC()->Gspos("QLUA", 1, "ZDCA", 0., 0., Geometry::ZNAPOSITION[1] /*fPosZNA[2]*/ - 66. - boxpar[2], 0, "ONLY");
1415 LOG(debug) << "A-side luminometer positioned in front of ZNA\n";
1416 }
1417}
1418
1419//_____________________________________________________________________________
1420void Detector::createCsideBeamLine()
1421{
1422 double tubpar[3] = {0., 0., 0};
1423 double boxpar[3] = {0., 0., 0};
1424 double tubspar[5] = {0., 0., 0., 0., 0.};
1425 double conpar[15] = {
1426 0.,
1427 };
1428
1429 float zC = 1947.2;
1430 float zCompensator = 1974.;
1431
1432 conpar[0] = 0.;
1433 conpar[1] = 360.;
1434 conpar[2] = 4.; // Num radius specifications: 4
1435 conpar[3] = -13500.;
1436 conpar[4] = 0.;
1437 conpar[5] = 55.;
1438 conpar[6] = -zCompensator;
1439 conpar[7] = 0.;
1440 conpar[8] = 55.;
1441 conpar[9] = -zCompensator;
1442 conpar[10] = 0.;
1443 conpar[11] = 6.7 / 2.;
1444 conpar[12] = -zC; // (4) Beginning of ZDCC mother volume
1445 conpar[13] = 0.;
1446 conpar[14] = 6.7 / 2.;
1447 TVirtualMC::GetMC()->Gsvolu("ZDCC", "PCON", getMediumID(kVoidNoField), conpar, 15);
1448 TVirtualMC::GetMC()->Gspos("ZDCC", 1, "cave", 0., 0., 0., 0, "ONLY");
1449
1450 // -- BEAM PIPE from compensator dipole to the beginning of D1
1451 tubpar[0] = 6.3 / 2.;
1452 tubpar[1] = 6.7 / 2.;
1453 // From beginning of ZDC volumes to beginning of D1
1454 tubpar[2] = (5838.3 - zC) / 2.;
1455 TVirtualMC::GetMC()->Gsvolu("QT01", "TUBE", getMediumID(kFe), tubpar, 3);
1456 TVirtualMC::GetMC()->Gspos("QT01", 1, "ZDCC", 0., 0., -tubpar[2] - zC, 0, "ONLY");
1457
1458 zC += 2. * tubpar[2];
1459
1460 //-- BEAM PIPE from the end of D1 to the beginning of D2
1461 //-- FROM MAGNETIC BEGINNING OF D1 TO MAGNETIC END OF D1
1462 //-- Cylindrical pipe (r = 3.47) + conical flare
1463 tubpar[0] = 6.94 / 2.;
1464 tubpar[1] = 7.34 / 2.;
1465 tubpar[2] = (6909.8 - zC) / 2.;
1466 TVirtualMC::GetMC()->Gsvolu("QT02", "TUBE", getMediumID(kFe), tubpar, 3);
1467 TVirtualMC::GetMC()->Gspos("QT02", 1, "ZDCC", 0., 0., -tubpar[2] - zC, 0, "ONLY");
1468
1469 zC += 2. * tubpar[2];
1470
1471 tubpar[0] = 8. / 2.;
1472 tubpar[1] = 8.6 / 2.;
1473 tubpar[2] = (6958.3 - zC) / 2.;
1474 TVirtualMC::GetMC()->Gsvolu("QT0B", "TUBE", getMediumID(kFe), tubpar, 3);
1475 TVirtualMC::GetMC()->Gspos("QT0B", 1, "ZDCC", 0., 0., -tubpar[2] - zC, 0, "ONLY");
1476
1477 zC += 2. * tubpar[2];
1478
1479 tubpar[0] = 9. / 2.;
1480 tubpar[1] = 9.6 / 2.;
1481 tubpar[2] = (7022.8 - zC) / 2.;
1482 TVirtualMC::GetMC()->Gsvolu("QT03", "TUBE", getMediumID(kFe), tubpar, 3);
1483 TVirtualMC::GetMC()->Gspos("QT03", 1, "ZDCC", 0., 0., -tubpar[2] - zC, 0, "ONLY");
1484
1485 zC += 2. * tubpar[2];
1486
1487 conpar[0] = 39.2 / 2.;
1488 conpar[1] = 18. / 2.;
1489 conpar[2] = 18.6 / 2.;
1490 conpar[3] = 9. / 2.;
1491 conpar[4] = 9.6 / 2.;
1492 TVirtualMC::GetMC()->Gsvolu("QC01", "CONE", getMediumID(kFe), conpar, 5);
1493 TVirtualMC::GetMC()->Gspos("QC01", 1, "ZDCC", 0., 0., -conpar[0] - zC, 0, "ONLY");
1494
1495 zC += conpar[0] * 2.;
1496
1497 // 2nd section of VCTCQ+VAMTF+TCLIA+VAMTF+1st part of VCTCP
1498 float totLength1 = 160.8 + 78. + 148. + 78. + 9.3;
1499 //
1500 tubpar[0] = 18.6 / 2.;
1501 tubpar[1] = 7.6 / 2.;
1502 tubpar[2] = totLength1 / 2.;
1503 TVirtualMC::GetMC()->Gsvolu("QE01", "ELTU", getMediumID(kFe), tubpar, 3);
1504 // in AliRoot: temporary replace with a scaled tube (AG) ??????????
1505 /*TGeoTube *tubeQE01 = new TGeoTube(0.,tubpar[0],tubpar[2]);
1506 TGeoScale *scaleQE01 = new TGeoScale(1., tubpar[1]/tubpar[0], 1.);
1507 TGeoScaledShape *sshapeQE01 = new TGeoScaledShape(tubeQE01, scaleQE01);
1508 new TGeoVolume("QE01", sshapeQE01, gGeoManager->GetMedium(getMediumID(kVoidNoField)));*/
1509
1510 tubpar[0] = 18.0 / 2.;
1511 tubpar[1] = 7.0 / 2.;
1512 tubpar[2] = totLength1 / 2.;
1513 TVirtualMC::GetMC()->Gsvolu("QE02", "ELTU", getMediumID(kVoidNoField), tubpar, 3);
1514 // in AliRoot: temporary replace with a scaled tube (AG) ??????????
1515 /*TGeoTube *tubeQE02 = new TGeoTube(0.,tubpar[0],tubpar[2]);
1516 TGeoScale *scaleQE02 = new TGeoScale(1., tubpar[1]/tubpar[0], 1.);
1517 TGeoScaledShape *sshapeQE02 = new TGeoScaledShape(tubeQE02, scaleQE02);
1518 new TGeoVolume("QE02", sshapeQE02, gGeoManager->GetMedium(getMediumID(k10]));*/
1519
1520 TVirtualMC::GetMC()->Gspos("QE01", 1, "ZDCC", 0., 0., -tubpar[2] - zC, 0, "ONLY");
1521 TVirtualMC::GetMC()->Gspos("QE02", 1, "QE01", 0., 0., 0., 0, "ONLY");
1522
1523 // TCLIA collimator jaws (defined ONLY if aperture<3.5!)
1524 if (mTCLIAAPERTURE < 3.5) {
1525 boxpar[0] = 5.4 / 2.;
1526 boxpar[1] = (3.5 - mTCLIAAPERTURE - mVCollSideCCentreY - 0.7) / 2.; // FIX IT!!!!!!!!
1527 if (boxpar[1] < 0.) {
1528 boxpar[1] = 0.;
1529 }
1530 boxpar[2] = 124.4 / 2.;
1531 TVirtualMC::GetMC()->Gsvolu("QCVC", "BOX ", getMediumID(kGraphite), boxpar, 3);
1532 TVirtualMC::GetMC()->Gspos("QCVC", 1, "QE02", -boxpar[0], mTCLIAAPERTURE + mVCollSideCCentreY + boxpar[1], -totLength1 / 2. + 160.8 + 78. + 148. / 2., 0, "ONLY"); // FIX IT!!!!!!!!
1533 TVirtualMC::GetMC()->Gspos("QCVC", 2, "QE02", -boxpar[0], -mTCLIAAPERTURENEG + mVCollSideCCentreY - boxpar[1], -totLength1 / 2. + 160.8 + 78. + 148. / 2., 0, "ONLY"); // FIX IT!!!!!!!!
1534 }
1535
1536 zC += tubpar[2] * 2.;
1537
1538 // 2nd part of VCTCP
1539 conpar[0] = 31.5 / 2.;
1540 conpar[1] = 21.27 / 2.;
1541 conpar[2] = 21.87 / 2.;
1542 conpar[3] = 18.0 / 2.;
1543 conpar[4] = 18.6 / 2.;
1544 TVirtualMC::GetMC()->Gsvolu("QC02", "CONE", getMediumID(kFe), conpar, 5);
1545 TVirtualMC::GetMC()->Gspos("QC02", 1, "ZDCC", 0., 0., -conpar[0] - zC, 0, "ONLY");
1546
1547 zC += conpar[0] * 2.;
1548
1549 // 3rd section of VCTCP+VCDWC+VMLGB
1550 float totLenght2 = (8373.3 - zC);
1551 tubpar[0] = 21.2 / 2.;
1552 tubpar[1] = 21.9 / 2.;
1553 tubpar[2] = totLenght2 / 2.;
1554 TVirtualMC::GetMC()->Gsvolu("QT04", "TUBE", getMediumID(kVoidNoField), tubpar, 3);
1555 TVirtualMC::GetMC()->Gspos("QT04", 1, "ZDCC", 0., 0., -tubpar[2] - zC, 0, "ONLY");
1556
1557 zC += tubpar[2] * 2.;
1558
1559 // First part of VCTCD
1560 // skewed transition cone from ID=212.7 mm to ID=797 mm
1561 conpar[0] = 121. / 2.;
1562 conpar[1] = 79.7 / 2.;
1563 conpar[2] = 81.3 / 2.;
1564 conpar[3] = 21.27 / 2.;
1565 conpar[4] = 21.87 / 2.;
1566 TVirtualMC::GetMC()->Gsvolu("QC03", "CONE", getMediumID(kVoidNoField), conpar, 5);
1567 TVirtualMC::GetMC()->Gspos("QC03", 1, "ZDCC", 0., 0., -conpar[0] - zC, 0, "ONLY");
1568
1569 zC += 2. * conpar[0];
1570
1571 // VCDGB + 1st part of VCTCH
1572 tubpar[0] = 79.7 / 2.;
1573 tubpar[1] = 81.3 / 2.;
1574 tubpar[2] = (5 * 475.2 + 97. - 136) / 2.;
1575 TVirtualMC::GetMC()->Gsvolu("QT05", "TUBE", getMediumID(kVoidNoField), tubpar, 3);
1576 TVirtualMC::GetMC()->Gspos("QT05", 1, "ZDCC", 0., 0., -tubpar[2] - zC, 0, "ONLY");
1577
1578 zC += 2. * tubpar[2];
1579
1580 // 2nd part of VCTCH
1581 // Transition from ID=797 mm to ID=196 mm:
1582 // in order to simulate the thin window opened in the transition cone
1583 // we divide the transition cone in three cones:
1584 // (1) 8 mm thick (2) 3 mm thick (3) the third 8 mm thick
1585
1586 // (1) 8 mm thick
1587 conpar[0] = 9.09 / 2.; // 15 degree
1588 conpar[1] = 74.82868 / 2.;
1589 conpar[2] = 76.42868 / 2.; // thickness 8 mm
1590 conpar[3] = 79.7 / 2.;
1591 conpar[4] = 81.3 / 2.; // thickness 8 mm
1592 TVirtualMC::GetMC()->Gsvolu("QC04", "CONE", getMediumID(kVoidNoField), conpar, 5);
1593 TVirtualMC::GetMC()->Gspos("QC04", 1, "ZDCC", 0., 0., -conpar[0] - zC, 0, "ONLY");
1594
1595 zC += 2. * conpar[0];
1596
1597 // (2) 3 mm thick
1598 conpar[0] = 96.2 / 2.; // 15 degree
1599 conpar[1] = 23.19588 / 2.;
1600 conpar[2] = 23.79588 / 2.; // thickness 3 mm
1601 conpar[3] = 74.82868 / 2.;
1602 conpar[4] = 75.42868 / 2.; // thickness 3 mm
1603 TVirtualMC::GetMC()->Gsvolu("QC05", "CONE", getMediumID(kVoidNoField), conpar, 5);
1604 TVirtualMC::GetMC()->Gspos("QC05", 1, "ZDCC", 0., 0., -conpar[0] - zC, 0, "ONLY");
1605
1606 zC += 2. * conpar[0];
1607
1608 // (3) 8 mm thick
1609 conpar[0] = 6.71 / 2.; // 15 degree
1610 conpar[1] = 19.6 / 2.;
1611 conpar[2] = 21.2 / 2.; // thickness 8 mm
1612 conpar[3] = 23.19588 / 2.;
1613 conpar[4] = 24.79588 / 2.; // thickness 8 mm
1614 TVirtualMC::GetMC()->Gsvolu("QC06", "CONE", getMediumID(kVoidNoField), conpar, 5);
1615 TVirtualMC::GetMC()->Gspos("QC06", 1, "ZDCC", 0., 0., -conpar[0] - zC, 0, "ONLY");
1616
1617 zC += 2. * conpar[0];
1618
1619 // VMZAR (5 volumes)
1620 tubpar[0] = 20.2 / 2.;
1621 tubpar[1] = 20.6 / 2.;
1622 tubpar[2] = 2.15 / 2.;
1623 TVirtualMC::GetMC()->Gsvolu("QT06", "TUBE", getMediumID(kVoidNoField), tubpar, 3);
1624 TVirtualMC::GetMC()->Gspos("QT06", 1, "ZDCC", 0., 0., -tubpar[2] - zC, 0, "ONLY");
1625
1626 zC += 2. * tubpar[2];
1627
1628 conpar[0] = 6.9 / 2.;
1629 conpar[1] = 23.9 / 2.;
1630 conpar[2] = 24.3 / 2.;
1631 conpar[3] = 20.2 / 2.;
1632 conpar[4] = 20.6 / 2.;
1633 TVirtualMC::GetMC()->Gsvolu("QC07", "CONE", getMediumID(kVoidNoField), conpar, 5);
1634 TVirtualMC::GetMC()->Gspos("QC07", 1, "ZDCC", 0., 0., -conpar[0] - zC, 0, "ONLY");
1635
1636 zC += 2. * conpar[0];
1637
1638 tubpar[0] = 23.9 / 2.;
1639 tubpar[1] = 25.5 / 2.;
1640 tubpar[2] = 17.0 / 2.;
1641 TVirtualMC::GetMC()->Gsvolu("QT07", "TUBE", getMediumID(kVoidNoField), tubpar, 3);
1642 TVirtualMC::GetMC()->Gspos("QT07", 1, "ZDCC", 0., 0., -tubpar[2] - zC, 0, "ONLY");
1643
1644 zC += 2. * tubpar[2];
1645
1646 conpar[0] = 6.9 / 2.;
1647 conpar[1] = 20.2 / 2.;
1648 conpar[2] = 20.6 / 2.;
1649 conpar[3] = 23.9 / 2.;
1650 conpar[4] = 24.3 / 2.;
1651 TVirtualMC::GetMC()->Gsvolu("QC08", "CONE", getMediumID(kVoidNoField), conpar, 5);
1652 TVirtualMC::GetMC()->Gspos("QC08", 1, "ZDCC", 0., 0., -conpar[0] - zC, 0, "ONLY");
1653
1654 zC += 2. * conpar[0];
1655
1656 tubpar[0] = 20.2 / 2.;
1657 tubpar[1] = 20.6 / 2.;
1658 tubpar[2] = 2.15 / 2.;
1659 TVirtualMC::GetMC()->Gsvolu("QT08", "TUBE", getMediumID(kVoidNoField), tubpar, 3);
1660 TVirtualMC::GetMC()->Gspos("QT08", 1, "ZDCC", 0., 0., -tubpar[2] - zC, 0, "ONLY");
1661
1662 zC += 2. * tubpar[2];
1663
1664 // Flange (ID=196 mm)(last part of VMZAR and first part of VCTYB)
1665 tubpar[0] = 19.6 / 2.;
1666 tubpar[1] = 25.3 / 2.;
1667 tubpar[2] = 4.9 / 2.;
1668 TVirtualMC::GetMC()->Gsvolu("QT09", "TUBE", getMediumID(kVoidNoField), tubpar, 3);
1669 TVirtualMC::GetMC()->Gspos("QT09", 1, "ZDCC", 0., 0., -tubpar[2] - zC, 0, "ONLY");
1670
1671 zC += 2. * tubpar[2];
1672
1673 // simulation of the trousers (VCTYB)
1674 tubpar[0] = 19.6 / 2.;
1675 tubpar[1] = 20.0 / 2.;
1676 tubpar[2] = 3.9 / 2.;
1677 TVirtualMC::GetMC()->Gsvolu("QT10", "TUBE", getMediumID(kVoidNoField), tubpar, 3);
1678 TVirtualMC::GetMC()->Gspos("QT10", 1, "ZDCC", 0., 0., -tubpar[2] - zC, 0, "ONLY");
1679
1680 zC += 2. * tubpar[2];
1681
1682 // transition cone from ID=196. to ID=216.6
1683 conpar[0] = 32.55 / 2.;
1684 conpar[1] = 21.66 / 2.;
1685 conpar[2] = 22.06 / 2.;
1686 conpar[3] = 19.6 / 2.;
1687 conpar[4] = 20.0 / 2.;
1688 TVirtualMC::GetMC()->Gsvolu("QC09", "CONE", getMediumID(kVoidNoField), conpar, 5);
1689 TVirtualMC::GetMC()->Gspos("QC09", 1, "ZDCC", 0., 0., -conpar[0] - zC, 0, "ONLY");
1690
1691 zC += 2. * conpar[0];
1692
1693 // tube
1694 tubpar[0] = 21.66 / 2.;
1695 tubpar[1] = 22.06 / 2.;
1696 tubpar[2] = 28.6 / 2.;
1697 TVirtualMC::GetMC()->Gsvolu("QT11", "TUBE", getMediumID(kVoidNoField), tubpar, 3);
1698 TVirtualMC::GetMC()->Gspos("QT11", 1, "ZDCC", 0., 0., -tubpar[2] - zC, 0, "ONLY");
1699
1700 zC += 2. * tubpar[2];
1701
1702 // --------------------------------------------------------
1703 // RECOMBINATION CHAMBER
1704 // TRANSFORMATION MATRICES
1705 double dx = -3.970000;
1706 double dy = 0.000000;
1707 double dz = 0.0;
1708 // Rotation:
1709 double thx = 84.989100;
1710 double phx = 180.000000;
1711 double thy = 90.000000;
1712 double phy = 90.000000;
1713 double thz = 185.010900;
1714 double phz = 0.000000;
1715 TGeoRotation* rotMatrix1c = new TGeoRotation("c", thx, phx, thy, phy, thz, phz);
1716 // Combi transformation:
1717 dx = -3.970000;
1718 dy = 0.000000;
1719 dz = 0.0;
1720 TGeoCombiTrans* rotMatrix2c = new TGeoCombiTrans("ZDCC_c1", dx, dy, dz, rotMatrix1c);
1721 rotMatrix2c->RegisterYourself();
1722 // Combi transformation:
1723 dx = 3.970000;
1724 dy = 0.000000;
1725 dz = 0.0;
1726 // Rotation:
1727 thx = 95.010900;
1728 phx = 180.000000;
1729 thy = 90.000000;
1730 phy = 90.000000;
1731 thz = 180. - 5.010900;
1732 phz = 0.000000;
1733 TGeoRotation* rotMatrix3c = new TGeoRotation("", thx, phx, thy, phy, thz, phz);
1734 TGeoCombiTrans* rotMatrix4c = new TGeoCombiTrans("ZDCC_c2", dx, dy, dz, rotMatrix3c);
1735 rotMatrix4c->RegisterYourself();
1736
1737 // VOLUMES DEFINITION
1738 // Volume: ZDCC
1739 TGeoVolume* pZDCC = gGeoManager->GetVolume("ZDCC");
1740
1741 conpar[0] = (90.1 - 0.95 - 0.26 - 0.0085) / 2.;
1742 conpar[1] = 0.0 / 2.;
1743 conpar[2] = 21.6 / 2.;
1744 conpar[3] = 0.0 / 2.;
1745 conpar[4] = 5.8 / 2.;
1746 new TGeoCone("QCLext", conpar[0], conpar[1], conpar[2], conpar[3], conpar[4]);
1747
1748 conpar[0] = (90.1 - 0.95 - 0.26 - 0.0085) / 2.;
1749 conpar[1] = 0.0 / 2.;
1750 conpar[2] = 21.2 / 2.;
1751 conpar[3] = 0.0 / 2.;
1752 conpar[4] = 5.4 / 2.;
1753 new TGeoCone("QCLint", conpar[0], conpar[1], conpar[2], conpar[3], conpar[4]);
1754
1755 // Outer trousers
1756 TGeoCompositeShape* pOutTrousersC = new TGeoCompositeShape("outTrousersC", "QCLext:ZDCC_c1+QCLext:ZDCC_c2");
1757
1758 //auto& matmgr = o2::base::MaterialManager::Instance();
1759
1760 // Volume: QCLext
1761 TGeoMedium* medZDCFeLowTh = gGeoManager->GetMedium("ZDC_IronLowTh$");
1762 TGeoVolume* pQCLext = new TGeoVolume("QCLext", pOutTrousersC, medZDCFeLowTh);
1763 pQCLext->SetLineColor(kAzure);
1764 pQCLext->SetVisLeaves(kTRUE);
1765 //
1766 TGeoTranslation* tr1c = new TGeoTranslation(0., 0., (double)-conpar[0] - 0.95 - zC);
1767 //
1768 pZDCC->AddNode(pQCLext, 1, tr1c);
1769 // Inner trousers
1770 TGeoCompositeShape* pIntTrousersC = new TGeoCompositeShape("intTrousersC", "QCLint:ZDCC_c1+QCLint:ZDCC_c2");
1771 // Volume: QCLint
1772 TGeoMedium* medZDCvoid = gGeoManager->GetMedium("ZDC_VoidNoField$");
1773 TGeoVolume* pQCLint = new TGeoVolume("QCLint", pIntTrousersC, medZDCvoid);
1774 pQCLint->SetLineColor(kBlue);
1775 pQCLint->SetVisLeaves(kTRUE);
1776 pQCLext->AddNode(pQCLint, 1);
1777
1778 zC += 90.1;
1779 double offset = 0.5;
1780 zC = zC + offset;
1781
1782 // second section : 2 tubes (ID = 54. OD = 58.)
1783 tubpar[0] = 5.4 / 2.;
1784 tubpar[1] = 5.8 / 2.;
1785 tubpar[2] = 40.0 / 2.;
1786 TVirtualMC::GetMC()->Gsvolu("QT12", "TUBE", getMediumID(kVoidNoField), tubpar, 3);
1787 TVirtualMC::GetMC()->Gspos("QT12", 1, "ZDCC", -15.8 / 2., 0., -tubpar[2] - zC, 0, "ONLY");
1788 TVirtualMC::GetMC()->Gspos("QT12", 2, "ZDCC", 15.8 / 2., 0., -tubpar[2] - zC, 0, "ONLY");
1789
1790 zC += 2. * tubpar[2];
1791
1792 //-- rotation matrices for the legs
1793 int32_t irotpipe1, irotpipe2;
1794 double rang1[6] = {90. - 1.0027, 0., 90., 90., 1.0027, 180.};
1795 double rang2[6] = {90. + 1.0027, 0., 90., 90., 1.0027, 0.};
1796 TVirtualMC::GetMC()->Matrix(irotpipe1, rang1[0], rang1[1], rang1[2], rang1[3], rang1[4], rang1[5]);
1797 TVirtualMC::GetMC()->Matrix(irotpipe2, rang2[0], rang2[1], rang2[2], rang2[3], rang2[4], rang2[5]);
1798
1799 // transition x2zdc to recombination chamber : skewed cone
1800 conpar[0] = (10. - 0.2 - offset) / 2.;
1801 conpar[1] = 6.3 / 2.;
1802 conpar[2] = 7.0 / 2.;
1803 conpar[3] = 5.4 / 2.;
1804 conpar[4] = 5.8 / 2.;
1805 TVirtualMC::GetMC()->Gsvolu("QC10", "CONE", getMediumID(kVoidNoField), conpar, 5);
1806 TVirtualMC::GetMC()->Gspos("QC10", 1, "ZDCC", -7.9 - 0.175, 0., -conpar[0] - 0.1 - zC, irotpipe1, "ONLY");
1807 TVirtualMC::GetMC()->Gspos("QC10", 2, "ZDCC", 7.9 + 0.175, 0., -conpar[0] - 0.1 - zC, irotpipe2, "ONLY");
1808
1809 zC += 2. * conpar[0] + 0.2;
1810
1811 // 2 tubes (ID = 63 mm OD=70 mm)
1812 tubpar[0] = 6.3 / 2.;
1813 tubpar[1] = 7.0 / 2.;
1814 tubpar[2] = 639.8 / 2.;
1815 TVirtualMC::GetMC()->Gsvolu("QT13", "TUBE", getMediumID(kVoidNoField), tubpar, 3);
1816 TVirtualMC::GetMC()->Gspos("QT13", 1, "ZDCC", -16.5 / 2., 0., -tubpar[2] - zC, 0, "ONLY");
1817 TVirtualMC::GetMC()->Gspos("QT13", 2, "ZDCC", 16.5 / 2., 0., -tubpar[2] - zC, 0, "ONLY");
1818
1819 zC += 2. * tubpar[2];
1820
1821 // -- Luminometer (Cu box) in front of ZN - side C
1822 if (mLumiLength > 0.) { // FIX IT!!!!!!!!!!!!!!!!!!!!!!!!
1823 boxpar[0] = 8.0 / 2.;
1824 boxpar[1] = 8.0 / 2.;
1825 boxpar[2] = mLumiLength / 2.; // FIX IT!!!!!!!!!!!!!!!!!!!!!!!!
1826 TVirtualMC::GetMC()->Gsvolu("QLUC", "BOX ", getMediumID(kCuLumi), boxpar, 3);
1827 TVirtualMC::GetMC()->Gspos("QLUC", 1, "ZDCC", 0., 0., Geometry::ZNCPOSITION[1] + 66. + boxpar[2], 0, "ONLY");
1828 LOG(debug) << "C-side luminometer positioned in front of ZNC\n";
1829 }
1830}
1831
1832//_____________________________________________________________________________
1833void Detector::createMagnets()
1834{
1835 float tubpar[3] = {0., 0., 0.};
1836 float boxpar[3] = {0., 0., 0.};
1837 // Parameters from magnet DEFINITION
1838 double zCompensatorField = 1972.5;
1839 double zITField = 2296.5;
1840 double zD1Field = 5838.3001;
1841 double zD2Field = 12167.8;
1842
1843 // ***************************************************************
1844 //SIDE C
1845 // ***************************************************************
1846 // -- COMPENSATOR DIPOLE (MBXW)
1847 // -- GAP (VACUUM WITH MAGNETIC FIELD)
1848 tubpar[0] = 0.;
1849 tubpar[1] = 3.14;
1850 // New -> Added to accomodate AD (A. Morsch)
1851 // Updated -> The field must be 1.53 m long
1852 tubpar[2] = 153. / 2.;
1853 TVirtualMC::GetMC()->Gsvolu("MBXW", "TUBE", getMediumID(kVoidwField), tubpar, 3);
1854 TVirtualMC::GetMC()->Gspos("MBXW", 1, "ZDCC", 0., 0., -tubpar[2] - zCompensatorField, 0, "ONLY");
1855 // -- YOKE
1856 tubpar[0] = 4.5;
1857 tubpar[1] = 55.;
1858 // Updated -> The yoke can be 1.50 m to avoid overlaps
1859 tubpar[2] = 150. / 2.;
1860 TVirtualMC::GetMC()->Gsvolu("YMBX", "TUBE", getMediumID(kVoidNoField), tubpar, 3);
1861 TVirtualMC::GetMC()->Gspos("YMBX", 1, "ZDCC", 0., 0., -tubpar[2] - zCompensatorField - 1.5, 0, "ONLY");
1862
1863 // -- INNER TRIPLET
1864 // -- DEFINE MQXL AND MQX QUADRUPOLE ELEMENT
1865 // -- MQXL
1866 // -- GAP (VACUUM WITH MAGNETIC FIELD)
1867 tubpar[0] = 0.;
1868 tubpar[1] = 3.14;
1869 tubpar[2] = 637. / 2.;
1870 TVirtualMC::GetMC()->Gsvolu("MQXL", "TUBE", getMediumID(kVoidwField), tubpar, 3);
1871
1872 // -- YOKE
1873 tubpar[0] = 3.5;
1874 tubpar[1] = 22.;
1875 tubpar[2] = 637. / 2.;
1876 TVirtualMC::GetMC()->Gsvolu("YMQL", "TUBE", getMediumID(kVoidNoField), tubpar, 3);
1877
1878 TVirtualMC::GetMC()->Gspos("MQXL", 1, "ZDCC", 0., 0., -tubpar[2] - zITField, 0, "ONLY");
1879 TVirtualMC::GetMC()->Gspos("YMQL", 1, "ZDCC", 0., 0., -tubpar[2] - zITField, 0, "ONLY");
1880
1881 TVirtualMC::GetMC()->Gspos("MQXL", 2, "ZDCC", 0., 0., -tubpar[2] - zITField - 2400., 0, "ONLY");
1882 TVirtualMC::GetMC()->Gspos("YMQL", 2, "ZDCC", 0., 0., -tubpar[2] - zITField - 2400., 0, "ONLY");
1883
1884 // -- MQX
1885 // -- GAP (VACUUM WITH MAGNETIC FIELD)
1886 tubpar[0] = 0.;
1887 tubpar[1] = 3.14;
1888 tubpar[2] = 550. / 2.;
1889 TVirtualMC::GetMC()->Gsvolu("MQX ", "TUBE", getMediumID(kVoidwField), tubpar, 3);
1890
1891 // -- YOKE
1892 tubpar[0] = 3.5;
1893 tubpar[1] = 22.;
1894 tubpar[2] = 550. / 2.;
1895 TVirtualMC::GetMC()->Gsvolu("YMQ ", "TUBE", getMediumID(kVoidNoField), tubpar, 3);
1896
1897 TVirtualMC::GetMC()->Gspos("MQX ", 1, "ZDCC", 0., 0., -tubpar[2] - zITField - 908.5, 0, "ONLY");
1898 TVirtualMC::GetMC()->Gspos("YMQ ", 1, "ZDCC", 0., 0., -tubpar[2] - zITField - 908.5, 0, "ONLY");
1899
1900 TVirtualMC::GetMC()->Gspos("MQX ", 2, "ZDCC", 0., 0., -tubpar[2] - zITField - 1558.5, 0, "ONLY");
1901 TVirtualMC::GetMC()->Gspos("YMQ ", 2, "ZDCC", 0., 0., -tubpar[2] - zITField - 1558.5, 0, "ONLY");
1902
1903 // -- SEPARATOR DIPOLE D1
1904 // -- GAP (VACUUM WITH MAGNETIC FIELD)
1905 tubpar[0] = 0.;
1906 tubpar[1] = 3.46;
1907 tubpar[2] = 945. / 2.;
1908 TVirtualMC::GetMC()->Gsvolu("MD1 ", "TUBE", getMediumID(kVoidwField), tubpar, 3);
1909
1910 // -- Insert horizontal Cu plates inside D1
1911 // -- (to simulate the vacuum chamber)
1912 boxpar[0] = TMath::Sqrt(tubpar[1] * tubpar[1] - (2.98 + 0.2) * (2.98 + 0.2)) - 0.05;
1913 boxpar[1] = 0.2 / 2.;
1914 boxpar[2] = 945. / 2.;
1915 TVirtualMC::GetMC()->Gsvolu("MD1V", "BOX ", getMediumID(kCu), boxpar, 3);
1916 TVirtualMC::GetMC()->Gspos("MD1V", 1, "MD1 ", 0., 2.98 + boxpar[1], 0., 0, "ONLY");
1917 TVirtualMC::GetMC()->Gspos("MD1V", 2, "MD1 ", 0., -2.98 - boxpar[1], 0., 0, "ONLY");
1918
1919 // -- YOKE
1920 tubpar[0] = 3.68;
1921 tubpar[1] = 110. / 2.;
1922 tubpar[2] = 945. / 2.;
1923 TVirtualMC::GetMC()->Gsvolu("YD1 ", "TUBE", getMediumID(kVoidNoField), tubpar, 3);
1924
1925 TVirtualMC::GetMC()->Gspos("YD1 ", 1, "ZDCC", 0., 0., -tubpar[2] - zD1Field, 0, "ONLY");
1926 TVirtualMC::GetMC()->Gspos("MD1 ", 1, "ZDCC", 0., 0., -tubpar[2] - zD1Field, 0, "ONLY");
1927
1928 // -- DIPOLE D2
1929 // -- GAP (VACUUM WITH MAGNETIC FIELD)
1930 tubpar[0] = 0.;
1931 tubpar[1] = 7.5 / 2.;
1932 tubpar[2] = 945. / 2.;
1933 TVirtualMC::GetMC()->Gsvolu("MD2 ", "TUBE", getMediumID(kVoidwField), tubpar, 3);
1934
1935 // -- YOKE
1936 tubpar[0] = 0.;
1937 tubpar[1] = 55.;
1938 tubpar[2] = 945. / 2.;
1939 TVirtualMC::GetMC()->Gsvolu("YD2 ", "TUBE", getMediumID(kVoidNoField), tubpar, 3);
1940 TVirtualMC::GetMC()->Gspos("YD2 ", 1, "ZDCC", 0., 0., -tubpar[2] - zD2Field, 0, "ONLY");
1941
1942 TVirtualMC::GetMC()->Gspos("MD2 ", 1, "YD2 ", -9.4, 0., 0., 0, "ONLY");
1943 TVirtualMC::GetMC()->Gspos("MD2 ", 2, "YD2 ", 9.4, 0., 0., 0, "ONLY");
1944
1945 // ***************************************************************
1946 //SIDE A
1947 // ***************************************************************
1948
1949 // COMPENSATOR DIPOLE (MCBWA) (2nd compensator)
1950 // -- GAP (VACUUM WITH MAGNETIC FIELD)
1951 tubpar[0] = 0.;
1952 tubpar[1] = 3.;
1953 tubpar[2] = 153. / 2.;
1954 TVirtualMC::GetMC()->Gsvolu("MCBW", "TUBE", getMediumID(kVoidwField), tubpar, 3);
1955 TVirtualMC::GetMC()->Gspos("MCBW", 1, "ZDCA", 0., 0., tubpar[2] + zCompensatorField, 0, "ONLY");
1956
1957 // -- YOKE
1958 tubpar[0] = 4.5;
1959 tubpar[1] = 55.;
1960 tubpar[2] = 153. / 2.;
1961 TVirtualMC::GetMC()->Gsvolu("YMCB", "TUBE", getMediumID(kVoidNoField), tubpar, 3);
1962 TVirtualMC::GetMC()->Gspos("YMCB", 1, "ZDCA", 0., 0., tubpar[2] + zCompensatorField, 0, "ONLY");
1963
1964 // -- INNER TRIPLET
1965 // -- DEFINE MQX1 AND MQX2 QUADRUPOLE ELEMENT
1966 // -- MQX1
1967 // -- GAP (VACUUM WITH MAGNETIC FIELD)
1968 tubpar[0] = 0.;
1969 tubpar[1] = 3.14;
1970 tubpar[2] = 637. / 2.;
1971 TVirtualMC::GetMC()->Gsvolu("MQX1", "TUBE", getMediumID(kVoidwField), tubpar, 3);
1972 TVirtualMC::GetMC()->Gsvolu("MQX4", "TUBE", getMediumID(kVoidwField), tubpar, 3);
1973
1974 // -- YOKE
1975 tubpar[0] = 3.5;
1976 tubpar[1] = 22.;
1977 tubpar[2] = 637. / 2.;
1978 TVirtualMC::GetMC()->Gsvolu("YMQ1", "TUBE", getMediumID(kVoidNoField), tubpar, 3);
1979
1980 // -- Q1
1981 TVirtualMC::GetMC()->Gspos("MQX1", 1, "ZDCA", 0., 0., tubpar[2] + zITField, 0, "ONLY");
1982 TVirtualMC::GetMC()->Gspos("YMQ1", 1, "ZDCA", 0., 0., tubpar[2] + zITField, 0, "ONLY");
1983
1984 // -- BEAM SCREEN FOR Q1
1985 tubpar[0] = 4.78 / 2.;
1986 tubpar[1] = 5.18 / 2.;
1987 tubpar[2] = 637. / 2.;
1988 TVirtualMC::GetMC()->Gsvolu("QBS1", "TUBE", getMediumID(kCu), tubpar, 3);
1989 TVirtualMC::GetMC()->Gspos("QBS1", 1, "MQX1", 0., 0., 0., 0, "ONLY");
1990 // INSERT VERTICAL PLATE INSIDE Q1
1991 boxpar[0] = 0.2 / 2.0;
1992 boxpar[1] = TMath::Sqrt(tubpar[0] * tubpar[0] - (1.9 + 0.2) * (1.9 + 0.2));
1993 boxpar[2] = 637. / 2.;
1994 TVirtualMC::GetMC()->Gsvolu("QBS2", "BOX ", getMediumID(kCu), boxpar, 3);
1995 TVirtualMC::GetMC()->Gspos("QBS2", 1, "MQX1", 1.9 + boxpar[0], 0., 0., 0, "ONLY");
1996 TVirtualMC::GetMC()->Gspos("QBS2", 2, "MQX1", -1.9 - boxpar[0], 0., 0., 0, "ONLY");
1997
1998 // -- Q3
1999 TVirtualMC::GetMC()->Gspos("MQX4", 1, "ZDCA", 0., 0., tubpar[2] + zITField + 2400., 0, "ONLY");
2000 TVirtualMC::GetMC()->Gspos("YMQ1", 2, "ZDCA", 0., 0., tubpar[2] + zITField + 2400., 0, "ONLY");
2001
2002 // -- BEAM SCREEN FOR Q3
2003 tubpar[0] = 5.79 / 2.;
2004 tubpar[1] = 6.14 / 2.;
2005 tubpar[2] = 637. / 2.;
2006 TVirtualMC::GetMC()->Gsvolu("QBS3", "TUBE", getMediumID(kCu), tubpar, 3);
2007 TVirtualMC::GetMC()->Gspos("QBS3", 1, "MQX4", 0., 0., 0., 0, "ONLY");
2008 // INSERT VERTICAL PLATE INSIDE Q3
2009 boxpar[0] = 0.2 / 2.0;
2010 boxpar[1] = TMath::Sqrt(tubpar[0] * tubpar[0] - (2.405 + 0.2) * (2.405 + 0.2));
2011 boxpar[2] = 637. / 2.;
2012 TVirtualMC::GetMC()->Gsvolu("QBS4", "BOX ", getMediumID(kCu), boxpar, 3);
2013 TVirtualMC::GetMC()->Gspos("QBS4", 1, "MQX4", 2.405 + boxpar[0], 0., 0., 0, "ONLY");
2014 TVirtualMC::GetMC()->Gspos("QBS4", 2, "MQX4", -2.405 - boxpar[0], 0., 0., 0, "ONLY");
2015
2016 // -- MQX2
2017 // -- GAP (VACUUM WITH MAGNETIC FIELD)
2018 tubpar[0] = 0.;
2019 tubpar[1] = 3.14;
2020 tubpar[2] = 550. / 2.;
2021 TVirtualMC::GetMC()->Gsvolu("MQX2", "TUBE", getMediumID(kVoidwField), tubpar, 3);
2022 TVirtualMC::GetMC()->Gsvolu("MQX3", "TUBE", getMediumID(kVoidwField), tubpar, 3);
2023
2024 // -- YOKE
2025 tubpar[0] = 3.5;
2026 tubpar[1] = 22.;
2027 tubpar[2] = 550. / 2.;
2028 TVirtualMC::GetMC()->Gsvolu("YMQ2", "TUBE", getMediumID(kVoidNoField), tubpar, 3);
2029
2030 // -- BEAM SCREEN FOR Q2
2031 tubpar[0] = 5.79 / 2.;
2032 tubpar[1] = 6.14 / 2.;
2033 tubpar[2] = 550. / 2.;
2034 TVirtualMC::GetMC()->Gsvolu("QBS5", "TUBE", getMediumID(kCu), tubpar, 3);
2035 // VERTICAL PLATE INSIDE Q2
2036 boxpar[0] = 0.2 / 2.0;
2037 boxpar[1] = TMath::Sqrt(tubpar[0] * tubpar[0] - (2.405 + 0.2) * (2.405 + 0.2));
2038 boxpar[2] = 550. / 2.;
2039 TVirtualMC::GetMC()->Gsvolu("QBS6", "BOX ", getMediumID(kCu), boxpar, 3);
2040
2041 // -- Q2A
2042 TVirtualMC::GetMC()->Gspos("MQX2", 1, "ZDCA", 0., 0., tubpar[2] + zITField + 908.5, 0, "ONLY");
2043 TVirtualMC::GetMC()->Gspos("QBS5", 1, "MQX2", 0., 0., 0., 0, "ONLY");
2044 TVirtualMC::GetMC()->Gspos("QBS6", 1, "MQX2", 2.405 + boxpar[0], 0., 0., 0, "ONLY");
2045 TVirtualMC::GetMC()->Gspos("QBS6", 2, "MQX2", -2.405 - boxpar[0], 0., 0., 0, "ONLY");
2046 TVirtualMC::GetMC()->Gspos("YMQ2", 1, "ZDCA", 0., 0., tubpar[2] + zITField + 908.5, 0, "ONLY");
2047
2048 // -- Q2B
2049 TVirtualMC::GetMC()->Gspos("MQX3", 1, "ZDCA", 0., 0., tubpar[2] + zITField + 1558.5, 0, "ONLY");
2050 TVirtualMC::GetMC()->Gspos("QBS5", 2, "MQX3", 0., 0., 0., 0, "ONLY");
2051 TVirtualMC::GetMC()->Gspos("QBS6", 3, "MQX3", 2.405 + boxpar[0], 0., 0., 0, "ONLY");
2052 TVirtualMC::GetMC()->Gspos("QBS6", 4, "MQX3", -2.405 - boxpar[0], 0., 0., 0, "ONLY");
2053 TVirtualMC::GetMC()->Gspos("YMQ2", 2, "ZDCA", 0., 0., tubpar[2] + zITField + 1558.5, 0, "ONLY");
2054
2055 // -- SEPARATOR DIPOLE D1
2056 // -- GAP (VACUUM WITH MAGNETIC FIELD)
2057 tubpar[0] = 0.;
2058 tubpar[1] = 6.75 / 2.; //3.375
2059 tubpar[2] = 945. / 2.;
2060 TVirtualMC::GetMC()->Gsvolu("MD1L", "TUBE", getMediumID(kVoidwField), tubpar, 3);
2061
2062 // -- The beam screen tube is provided by the beam pipe in D1 (QA03 volume)
2063 // -- Insert the beam screen horizontal Cu plates inside D1 to simulate the vacuum chamber
2064 boxpar[0] = TMath::Sqrt(tubpar[1] * tubpar[1] - (2.885 + 0.2) * (2.885 + 0.2));
2065 boxpar[1] = 0.2 / 2.;
2066 boxpar[2] = 945. / 2.;
2067 TVirtualMC::GetMC()->Gsvolu("QBS7", "BOX ", getMediumID(kCu), boxpar, 3);
2068 TVirtualMC::GetMC()->Gspos("QBS7", 1, "MD1L", 0., 2.885 + boxpar[1], 0., 0, "ONLY");
2069 TVirtualMC::GetMC()->Gspos("QBS7", 2, "MD1L", 0., -2.885 - boxpar[1], 0., 0, "ONLY");
2070
2071 // -- YOKE
2072 tubpar[0] = 3.68;
2073 tubpar[1] = 110. / 2;
2074 tubpar[2] = 945. / 2.;
2075 TVirtualMC::GetMC()->Gsvolu("YD1L", "TUBE", getMediumID(kVoidNoField), tubpar, 3);
2076
2077 TVirtualMC::GetMC()->Gspos("YD1L", 1, "ZDCA", 0., 0., tubpar[2] + zD1Field, 0, "ONLY");
2078 TVirtualMC::GetMC()->Gspos("MD1L", 1, "ZDCA", 0., 0., tubpar[2] + zD1Field, 0, "ONLY");
2079
2080 // -- DIPOLE D2
2081 // -- GAP (VACUUM WITH MAGNETIC FIELD)
2082 tubpar[0] = 0.;
2083 tubpar[1] = 7.5 / 2.; // this has to be checked
2084 tubpar[2] = 945. / 2.;
2085 TVirtualMC::GetMC()->Gsvolu("MD2L", "TUBE", getMediumID(kVoidwField), tubpar, 3);
2086
2087 // -- YOKE
2088 tubpar[0] = 0.;
2089 tubpar[1] = 55.;
2090 tubpar[2] = 945. / 2.;
2091 TVirtualMC::GetMC()->Gsvolu("YD2L", "TUBE", getMediumID(kVoidNoField), tubpar, 3);
2092 TVirtualMC::GetMC()->Gspos("YD2L", 1, "ZDCA", 0., 0., tubpar[2] + zD2Field, 0, "ONLY");
2093
2094 TVirtualMC::GetMC()->Gspos("MD2L", 1, "YD2L", -9.4, 0., 0., 0, "ONLY");
2095 TVirtualMC::GetMC()->Gspos("MD2L", 2, "YD2L", 9.4, 0., 0., 0, "ONLY");
2096}
2097//_____________________________________________________________________________
2098void Detector::createDetectors()
2099{
2100 // ProcessHits compares the medium of every step against these two, for ZEM as
2101 // much as for ZN and ZP, so they have to be resolved whatever is built.
2102 mMediumPMCid = getMediumID(kSiO2pmc);
2103 mMediumPMQid = getMediumID(kSiO2pmq);
2104
2105 // ZN and ZP sit in the ZDCA/ZDCC mother volumes that the beam line builds, so
2106 // they stand or fall with it. ZEM is at z = 7.6 m and is built either way.
2107 if (ZDCSimParam::Instance().buildBeamLine) {
2108 createZNZP();
2109 }
2110 createZEM();
2111}
2112
2113//_____________________________________________________________________________
2114void Detector::createZNZP()
2115{
2116 // Create the ZDCs
2117
2118 double znSupportBase[3] = {6.3, 4.57, 71.2}; //Basement of ZN table (thick one)
2119 double znSupportBasePos[3] = {0., -14., 21.2};
2120 double znSupportScintillH[3] = {4.32 - 0.8, 0.8, 50.}; //Scintillator container: top&bottom
2121 double znSupportScintillV[3] = {0.8, 1.955, 50.}; //Scintillator container: sides
2122 double znSupportWallsud[3] = {3.52, 1., 50.}; //Top and bottom walls
2123 double znSupportWallside[3] = {0.4, 5.52, 50.}; //Side walls
2124
2125 float dimPb[6], dimVoid[6];
2126
2127 // -------------------------------------------------------------------------------
2128 //--> Neutron calorimeter (ZN)
2129
2130 // an envelop volume for the purpose of registering particles entering the detector
2131 double eps = 0.1; // 1 mm
2132 double neu_envelopdim[3] = {Geometry::ZNDIMENSION[0] + eps, Geometry::ZNDIMENSION[1] + eps, Geometry::ZNDIMENSION[2] + eps};
2133 TVirtualMC::GetMC()->Gsvolu("ZNENV", "BOX ", getMediumID(kVoidNoField), neu_envelopdim, 3);
2134
2135 TVirtualMC::GetMC()->Gsvolu("ZNEU", "BOX ", getMediumID(kWalloy), const_cast<double*>(Geometry::ZNDIMENSION), 3); // Passive material
2136 TVirtualMC::GetMC()->Gsvolu("ZNF1", "TUBE", mMediumPMCid, const_cast<double*>(Geometry::ZNFIBRE), 3); // Active material
2137 TVirtualMC::GetMC()->Gsvolu("ZNF2", "TUBE", mMediumPMQid, const_cast<double*>(Geometry::ZNFIBRE), 3);
2138 TVirtualMC::GetMC()->Gsvolu("ZNF3", "TUBE", mMediumPMQid, const_cast<double*>(Geometry::ZNFIBRE), 3);
2139 TVirtualMC::GetMC()->Gsvolu("ZNF4", "TUBE", mMediumPMCid, const_cast<double*>(Geometry::ZNFIBRE), 3);
2140 TVirtualMC::GetMC()->Gsvolu("ZNG1", "BOX ", getMediumID(kAir), const_cast<double*>(Geometry::ZNGROOVES), 3); // Empty grooves
2141 TVirtualMC::GetMC()->Gsvolu("ZNG2", "BOX ", getMediumID(kAir), const_cast<double*>(Geometry::ZNGROOVES), 3);
2142 TVirtualMC::GetMC()->Gsvolu("ZNG3", "BOX ", getMediumID(kAir), const_cast<double*>(Geometry::ZNGROOVES), 3);
2143 TVirtualMC::GetMC()->Gsvolu("ZNG4", "BOX ", getMediumID(kAir), const_cast<double*>(Geometry::ZNGROOVES), 3);
2144
2145 // Divide ZNEU in quadrants
2146 TVirtualMC::GetMC()->Gsdvn("ZNTX", "ZNEU", Geometry::ZNSECTORS[0], 1); // x-tower
2147 TVirtualMC::GetMC()->Gsdvn("ZN1 ", "ZNTX", Geometry::ZNSECTORS[1], 2); // y-tower
2148
2149 //-- Divide ZN1 in minitowers (4 fibres per minitower)
2150 // ZNDIVISION[0]= NUMBER OF FIBERS PER TOWER ALONG X-AXIS =11,
2151 // ZNDIVISION[1]= NUMBER OF FIBERS PER TOWER ALONG Y-AXIS =11
2152 TVirtualMC::GetMC()->Gsdvn("ZNSL", "ZN1 ", Geometry::ZNDIVISION[1], 2); // Slices
2153 TVirtualMC::GetMC()->Gsdvn("ZNST", "ZNSL", Geometry::ZNDIVISION[0], 1); // Sticks
2154
2155 // --- Position the empty grooves in the sticks (4 grooves per stick)
2156 float dx = Geometry::ZNDIMENSION[0] / Geometry::ZNDIVISION[0] / 4.;
2157 float dy = Geometry::ZNDIMENSION[1] / Geometry::ZNDIVISION[1] / 4.;
2158
2159 TVirtualMC::GetMC()->Gspos("ZNG1", 1, "ZNST", 0. - dx, 0. + dy, 0., 0, "ONLY");
2160 TVirtualMC::GetMC()->Gspos("ZNG2", 1, "ZNST", 0. + dx, 0. + dy, 0., 0, "ONLY");
2161 TVirtualMC::GetMC()->Gspos("ZNG3", 1, "ZNST", 0. - dx, 0. - dy, 0., 0, "ONLY");
2162 TVirtualMC::GetMC()->Gspos("ZNG4", 1, "ZNST", 0. + dx, 0. - dy, 0., 0, "ONLY");
2163
2164 // --- Position the fibers in the grooves
2165 TVirtualMC::GetMC()->Gspos("ZNF1", 1, "ZNG1", 0., 0., 0., 0, "ONLY");
2166 TVirtualMC::GetMC()->Gspos("ZNF2", 1, "ZNG2", 0., 0., 0., 0, "ONLY");
2167 TVirtualMC::GetMC()->Gspos("ZNF3", 1, "ZNG3", 0., 0., 0., 0, "ONLY");
2168 TVirtualMC::GetMC()->Gspos("ZNF4", 1, "ZNG4", 0., 0., 0., 0, "ONLY");
2169
2170 // --- Position the neutron calorimeter in ZDC
2171 // -- Rotation of C side ZN
2172 int32_t irotznc;
2173 double rangznc[6] = {90., 180., 90., 90., 180., 0.};
2174 TVirtualMC::GetMC()->Matrix(irotznc, rangznc[0], rangznc[1], rangznc[2], rangznc[3], rangznc[4], rangznc[5]);
2175 //
2176 TVirtualMC::GetMC()->Gspos("ZNEU", 1, "ZNENV", 0., 0., 0., 0, "ONLY");
2177 TVirtualMC::GetMC()->Gspos("ZNENV", 1, "ZDCC", Geometry::ZNCPOSITION[0], Geometry::ZNCPOSITION[1], Geometry::ZNCPOSITION[2] - Geometry::ZNDIMENSION[2], irotznc, "ONLY");
2178
2179 // --- Position the neutron calorimeter on the A side
2180 TVirtualMC::GetMC()->Gspos("ZNENV", 2, "ZDCA", Geometry::ZNAPOSITION[0], Geometry::ZNAPOSITION[1], Geometry::ZNAPOSITION[2] + Geometry::ZNDIMENSION[2], 0, "ONLY");
2181
2182 // -------------------------------------------------------------------------------
2183 // -> ZN supports
2184
2185 // Basements (A and C sides)
2186 TVirtualMC::GetMC()->Gsvolu("ZNBASE", "BOX ", getMediumID(kAl), znSupportBase, 3);
2187 TVirtualMC::GetMC()->Gspos("ZNBASE", 1, "ZDCC", Geometry::ZNCPOSITION[0] + znSupportBasePos[0],
2188 Geometry::ZNCPOSITION[1] + znSupportBasePos[1], Geometry::ZNCPOSITION[2] - znSupportBase[2], 0, "ONLY");
2189 TVirtualMC::GetMC()->Gspos("ZNBASE", 2, "ZDCA", Geometry::ZNAPOSITION[0] + znSupportBasePos[0],
2190 Geometry::ZNAPOSITION[1] + znSupportBasePos[1], Geometry::ZNAPOSITION[2] + znSupportBase[2], 0, "ONLY");
2191
2192 // Box containing scintillators (C side)
2193 TVirtualMC::GetMC()->Gsvolu("ZNSCH", "BOX ", getMediumID(kAl), znSupportScintillH, 3);
2194 TVirtualMC::GetMC()->Gspos("ZNSCH", 1, "ZDCC", Geometry::ZNCPOSITION[0] + znSupportBasePos[0],
2195 Geometry::ZNCPOSITION[1] + znSupportBasePos[1] + znSupportBase[1] + znSupportScintillH[1], Geometry::ZNCPOSITION[2] - znSupportScintillH[2], 0, "ONLY");
2196 TVirtualMC::GetMC()->Gspos("ZNSCH", 2, "ZDCC", Geometry::ZNCPOSITION[0] + znSupportBasePos[0],
2197 Geometry::ZNCPOSITION[1] - Geometry::ZNDIMENSION[1] - znSupportScintillV[1] + znSupportScintillH[1], Geometry::ZNCPOSITION[2] - znSupportScintillH[2], 0, "ONLY");
2198
2199 TVirtualMC::GetMC()->Gsvolu("ZNSCV", "BOX ", getMediumID(kAl), znSupportScintillV, 3);
2200 TVirtualMC::GetMC()->Gspos("ZNSCV", 1, "ZDCC", Geometry::ZNCPOSITION[0] + znSupportBasePos[0] + znSupportScintillH[0] + znSupportScintillV[0],
2201 Geometry::ZNCPOSITION[1] + znSupportBasePos[1] + znSupportBase[1] + znSupportScintillV[1], Geometry::ZNCPOSITION[2] - znSupportScintillV[2], 0, "ONLY");
2202 TVirtualMC::GetMC()->Gspos("ZNSCV", 2, "ZDCC", Geometry::ZNCPOSITION[0] + znSupportBasePos[0] - znSupportScintillH[0] - znSupportScintillV[0],
2203 Geometry::ZNCPOSITION[1] + znSupportBasePos[1] + znSupportBase[1] + znSupportScintillV[1], Geometry::ZNCPOSITION[2] - znSupportScintillV[2], 0, "ONLY");
2204
2205 // Box containing scintillators (A side)
2206 TVirtualMC::GetMC()->Gsvolu("ZNSCH", "BOX ", getMediumID(kAl), znSupportScintillH, 3);
2207 TVirtualMC::GetMC()->Gspos("ZNSCH", 1, "ZDCA", Geometry::ZNAPOSITION[0] + znSupportBasePos[0],
2208 Geometry::ZNAPOSITION[1] + znSupportBasePos[1] + znSupportBase[1] + znSupportScintillH[1], Geometry::ZNAPOSITION[2] + znSupportScintillH[2], 0, "ONLY");
2209 TVirtualMC::GetMC()->Gspos("ZNSCH", 2, "ZDCA", Geometry::ZNAPOSITION[0] + znSupportBasePos[0],
2210 Geometry::ZNAPOSITION[1] - Geometry::ZNDIMENSION[1] - znSupportScintillV[1] + znSupportScintillH[1], Geometry::ZNAPOSITION[2] + znSupportScintillH[2], 0, "ONLY");
2211
2212 TVirtualMC::GetMC()->Gsvolu("ZNSCV", "BOX ", getMediumID(kAl), const_cast<double*>(znSupportScintillV), 3);
2213 TVirtualMC::GetMC()->Gspos("ZNSCV", 1, "ZDCA", Geometry::ZNAPOSITION[0] + znSupportBasePos[0] + znSupportScintillH[0] + znSupportScintillV[0],
2214 Geometry::ZNAPOSITION[1] + znSupportBasePos[1] + znSupportBase[1] + znSupportScintillV[1], Geometry::ZNAPOSITION[2] + znSupportScintillV[2], 0, "ONLY");
2215 TVirtualMC::GetMC()->Gspos("ZNSCV", 2, "ZDCA", Geometry::ZNAPOSITION[0] + znSupportBasePos[0] - znSupportScintillH[0] - znSupportScintillV[0],
2216 Geometry::ZNAPOSITION[1] + znSupportBasePos[1] + znSupportBase[1] + znSupportScintillV[1], Geometry::ZNAPOSITION[2] + znSupportScintillV[2], 0, "ONLY");
2217
2218 // ZNC Box (A and C sides)
2219 // Top & bottom walls
2220 TVirtualMC::GetMC()->Gsvolu("ZNBH", "BOX ", getMediumID(kAl), const_cast<double*>(znSupportWallsud), 3);
2221 TVirtualMC::GetMC()->Gspos("ZNBH", 1, "ZDCC", Geometry::ZNCPOSITION[0] + znSupportBasePos[0],
2222 Geometry::ZNCPOSITION[1] - Geometry::ZNDIMENSION[1] - znSupportWallsud[1], Geometry::ZNCPOSITION[2] - znSupportWallsud[2], 0, "ONLY");
2223 TVirtualMC::GetMC()->Gspos("ZNBH", 2, "ZDCC", Geometry::ZNCPOSITION[0] + znSupportBasePos[0],
2224 Geometry::ZNCPOSITION[1] + Geometry::ZNDIMENSION[1] + znSupportWallsud[1], Geometry::ZNCPOSITION[2] - znSupportWallsud[2], 0, "ONLY");
2225 TVirtualMC::GetMC()->Gspos("ZNBH", 3, "ZDCA", Geometry::ZNAPOSITION[0] + znSupportBasePos[0],
2226 Geometry::ZNAPOSITION[1] - Geometry::ZNDIMENSION[1] - znSupportWallsud[1], Geometry::ZNAPOSITION[2] + znSupportWallsud[2], 0, "ONLY");
2227 TVirtualMC::GetMC()->Gspos("ZNBH", 4, "ZDCA", Geometry::ZNAPOSITION[0] + znSupportBasePos[0],
2228 Geometry::ZNAPOSITION[1] + Geometry::ZNDIMENSION[1] + znSupportWallsud[1], Geometry::ZNAPOSITION[2] + znSupportWallsud[2], 0, "ONLY");
2229
2230 // Side walls
2231 TVirtualMC::GetMC()->Gsvolu("ZNBS", "BOX ", getMediumID(kAl), const_cast<double*>(znSupportWallside), 3);
2232 TVirtualMC::GetMC()->Gspos("ZNBS", 1, "ZDCC", Geometry::ZNCPOSITION[0] + Geometry::ZNDIMENSION[0] + znSupportWallside[0],
2233 Geometry::ZNCPOSITION[1], Geometry::ZNCPOSITION[2] - znSupportWallside[2], 0, "ONLY");
2234 TVirtualMC::GetMC()->Gspos("ZNBS", 2, "ZDCC", Geometry::ZNCPOSITION[0] - Geometry::ZNDIMENSION[0] - znSupportWallside[0],
2235 Geometry::ZNCPOSITION[1], Geometry::ZNCPOSITION[2] - znSupportWallsud[2], 0, "ONLY");
2236 TVirtualMC::GetMC()->Gspos("ZNBS", 3, "ZDCA", Geometry::ZNAPOSITION[0] + Geometry::ZNDIMENSION[0] + znSupportWallside[0],
2237 Geometry::ZNAPOSITION[1], Geometry::ZNAPOSITION[2] + znSupportWallside[2], 0, "ONLY");
2238 TVirtualMC::GetMC()->Gspos("ZNBS", 4, "ZDCA", Geometry::ZNAPOSITION[0] - Geometry::ZNDIMENSION[0] - znSupportWallside[0],
2239 Geometry::ZNAPOSITION[1], Geometry::ZNAPOSITION[2] + znSupportWallsud[2], 0, "ONLY");
2240
2241 // -------------------------------------------------------------------------------
2242 //--> Proton calorimeter (ZP)
2243 double zpSupportBase1[3] = {12.5, 1.4, 75.}; //Bottom basement of ZP table (thinner one)
2244 double zpSupportBase1Pos[3] = {0., -17., 0.};
2245 double zpSupportBase2[3] = {12.5, 2.5, 75.}; //Upper basement of ZP table (thicker one)
2246 double zpSupportBase2Pos[3] = {0., -9., 0.};
2247 double zpSupportBase3[3] = {1.5, 2.05, 75.}; //support table heels (piedini)
2248 double zpSupportWallBottom[3] = {11.2, 0.25, 75.}; //Bottom wall
2249 double zpSupportWallup[3] = {11.2, 1., 75.}; //Top wall
2250 //double zpSupportWallside[3] = {0.5, 7.25, 75.}; //Side walls (original)
2251 double zpSupportWallside[3] = {0.5, 6., 75.}; //Side walls (modified)
2252
2253 double pro_envelopdim[3] = {Geometry::ZPDIMENSION[0] + eps, Geometry::ZPDIMENSION[1] + eps, Geometry::ZPDIMENSION[2] + eps};
2254 TVirtualMC::GetMC()->Gsvolu("ZPENV", "BOX", getMediumID(kVoidNoField), pro_envelopdim, 3);
2255
2256 TVirtualMC::GetMC()->Gsvolu("ZPRO", "BOX ", getMediumID(kCuZn), const_cast<double*>(Geometry::ZPDIMENSION), 3); // Passive material
2257 TVirtualMC::GetMC()->Gsvolu("ZPF1", "TUBE", getMediumID(kSiO2pmc), const_cast<double*>(Geometry::ZPFIBRE), 3); // Active material
2258 TVirtualMC::GetMC()->Gsvolu("ZPF2", "TUBE", getMediumID(kSiO2pmq), const_cast<double*>(Geometry::ZPFIBRE), 3);
2259 TVirtualMC::GetMC()->Gsvolu("ZPF3", "TUBE", getMediumID(kSiO2pmq), const_cast<double*>(Geometry::ZPFIBRE), 3);
2260 TVirtualMC::GetMC()->Gsvolu("ZPF4", "TUBE", getMediumID(kSiO2pmc), const_cast<double*>(Geometry::ZPFIBRE), 3);
2261 TVirtualMC::GetMC()->Gsvolu("ZPG1", "BOX ", getMediumID(kAir), const_cast<double*>(Geometry::ZPGROOVES), 3); // Empty grooves
2262 TVirtualMC::GetMC()->Gsvolu("ZPG2", "BOX ", getMediumID(kAir), const_cast<double*>(Geometry::ZPGROOVES), 3);
2263 TVirtualMC::GetMC()->Gsvolu("ZPG3", "BOX ", getMediumID(kAir), const_cast<double*>(Geometry::ZPGROOVES), 3);
2264 TVirtualMC::GetMC()->Gsvolu("ZPG4", "BOX ", getMediumID(kAir), const_cast<double*>(Geometry::ZPGROOVES), 3);
2265
2266 //-- Divide ZPRO in towers
2267 TVirtualMC::GetMC()->Gsdvn("ZPTX", "ZPRO", Geometry::ZPSECTORS[0], 1); // x-tower
2268 TVirtualMC::GetMC()->Gsdvn("ZP1 ", "ZPTX", Geometry::ZPSECTORS[1], 2); // y-tower
2269
2270 //-- Divide ZP1 in minitowers (4 fiber per minitower)
2271 // ZPDIVISION[0]= NUMBER OF FIBERS ALONG X-AXIS PER MINITOWER,
2272 // ZPDIVISION[1]= NUMBER OF FIBERS ALONG Y-AXIS PER MINITOWER
2273 TVirtualMC::GetMC()->Gsdvn("ZPSL", "ZP1 ", Geometry::ZPDIVISION[1], 2); // Slices
2274 TVirtualMC::GetMC()->Gsdvn("ZPST", "ZPSL", Geometry::ZPDIVISION[0], 1); // Sticks
2275
2276 // --- Position the empty grooves in the sticks (4 grooves per stick)
2279
2280 TVirtualMC::GetMC()->Gspos("ZPG1", 1, "ZPST", 0. - dx, 0. + dy, 0., 0, "ONLY");
2281 TVirtualMC::GetMC()->Gspos("ZPG2", 1, "ZPST", 0. + dx, 0. + dy, 0., 0, "ONLY");
2282 TVirtualMC::GetMC()->Gspos("ZPG3", 1, "ZPST", 0. - dx, 0. - dy, 0., 0, "ONLY");
2283 TVirtualMC::GetMC()->Gspos("ZPG4", 1, "ZPST", 0. + dx, 0. - dy, 0., 0, "ONLY");
2284
2285 // --- Position the fibers in the grooves
2286 TVirtualMC::GetMC()->Gspos("ZPF1", 1, "ZPG1", 0., 0., 0., 0, "ONLY");
2287 TVirtualMC::GetMC()->Gspos("ZPF2", 1, "ZPG2", 0., 0., 0., 0, "ONLY");
2288 TVirtualMC::GetMC()->Gspos("ZPF3", 1, "ZPG3", 0., 0., 0., 0, "ONLY");
2289 TVirtualMC::GetMC()->Gspos("ZPF4", 1, "ZPG4", 0., 0., 0., 0, "ONLY");
2290
2291 // --- Position the proton calorimeter in ZDCC
2292 // -- Rotation of C side ZP
2293 TVirtualMC::GetMC()->Gspos("ZPRO", 1, "ZPENV", 0., 0., 0., 0, "ONLY");
2294 TVirtualMC::GetMC()->Gspos("ZPENV", 1, "ZDCC", Geometry::ZPCPOSITION[0], Geometry::ZPCPOSITION[1], Geometry::ZPCPOSITION[2] - Geometry::ZPDIMENSION[2], irotznc, "ONLY");
2295
2296 // --- Position the proton calorimeter in ZDCA
2297 TVirtualMC::GetMC()->Gspos("ZPENV", 2, "ZDCA", Geometry::ZPAPOSITION[0], Geometry::ZPAPOSITION[1], Geometry::ZPAPOSITION[2] + Geometry::ZPDIMENSION[2], 0, "ONLY");
2298
2299 // -------------------------------------------------------------------------------
2300 // -> ZP supports
2301
2302 // Bottom basements (A and C sides)
2303 TVirtualMC::GetMC()->Gsvolu("ZPBASE1", "BOX ", getMediumID(kAl), const_cast<double*>(zpSupportBase1), 3);
2304 TVirtualMC::GetMC()->Gspos("ZPBASE1", 1, "ZDCC", Geometry::ZPCPOSITION[0] + zpSupportBase1Pos[0],
2305 Geometry::ZPCPOSITION[1] + zpSupportBase1Pos[1], Geometry::ZPCPOSITION[2] - zpSupportBase1[2], 0, "ONLY");
2306 TVirtualMC::GetMC()->Gspos("ZPBASE1", 2, "ZDCA", Geometry::ZPAPOSITION[0] + zpSupportBase1Pos[0],
2307 Geometry::ZPAPOSITION[1] + zpSupportBase1Pos[1], Geometry::ZPAPOSITION[2] + zpSupportBase1[2], 0, "ONLY");
2308
2309 // Bottom foot between 2 basements (A and C sides)
2310 TVirtualMC::GetMC()->Gsvolu("ZPFOOT", "BOX ", getMediumID(kAl), const_cast<double*>(zpSupportBase3), 3);
2311 TVirtualMC::GetMC()->Gspos("ZPFOOT", 1, "ZDCC", Geometry::ZPCPOSITION[0] + zpSupportBase1Pos[0] - zpSupportBase1[0] + zpSupportBase3[0], Geometry::ZPCPOSITION[1] + zpSupportBase1Pos[1] + zpSupportBase1[1] + zpSupportBase3[1], Geometry::ZPCPOSITION[2] - zpSupportBase3[2], 0, "ONLY");
2312 TVirtualMC::GetMC()->Gspos("ZPFOOT", 2, "ZDCC", Geometry::ZPCPOSITION[0] + zpSupportBase1Pos[0] + zpSupportBase1[0] - zpSupportBase3[0], Geometry::ZPCPOSITION[1] + zpSupportBase1Pos[1] + zpSupportBase1[1] + zpSupportBase3[1], Geometry::ZPCPOSITION[2] - zpSupportBase3[2], 0, "ONLY");
2313 TVirtualMC::GetMC()->Gspos("ZPFOOT", 3, "ZDCA", Geometry::ZPAPOSITION[0] + zpSupportBase1Pos[0] - zpSupportBase1[0] + zpSupportBase3[0], Geometry::ZPAPOSITION[1] + zpSupportBase1Pos[1] + zpSupportBase1[1] + zpSupportBase3[1], Geometry::ZPAPOSITION[2] + zpSupportBase3[2], 0, "ONLY");
2314 TVirtualMC::GetMC()->Gspos("ZPFOOT", 4, "ZDCA", Geometry::ZPAPOSITION[0] + zpSupportBase1Pos[0] + zpSupportBase1[0] - zpSupportBase3[0], Geometry::ZPAPOSITION[1] + zpSupportBase1Pos[1] + zpSupportBase1[1] + zpSupportBase3[1], Geometry::ZPAPOSITION[2] + zpSupportBase3[2], 0, "ONLY");
2315
2316 // Upper basements (A and C sides)
2317 TVirtualMC::GetMC()->Gsvolu("ZPBASE2", "BOX ", getMediumID(kAl), const_cast<double*>(zpSupportBase2), 3);
2318 TVirtualMC::GetMC()->Gspos("ZPBASE2", 1, "ZDCC", Geometry::ZPCPOSITION[0] + zpSupportBase2Pos[0],
2319 Geometry::ZPCPOSITION[1] + zpSupportBase2Pos[1], Geometry::ZPCPOSITION[2] - zpSupportBase2[2], 0, "ONLY");
2320 TVirtualMC::GetMC()->Gspos("ZPBASE2", 2, "ZDCA", Geometry::ZPAPOSITION[0] + zpSupportBase2Pos[0],
2321 Geometry::ZPAPOSITION[1] + zpSupportBase2Pos[1], Geometry::ZPAPOSITION[2] + zpSupportBase2[2], 0, "ONLY");
2322
2323 // ZPC Box (A and C sides)
2324 // Bottom walls
2325 TVirtualMC::GetMC()->Gsvolu("ZPBB", "BOX ", getMediumID(kAl), const_cast<double*>(zpSupportWallBottom), 3);
2326 TVirtualMC::GetMC()->Gspos("ZPBB", 1, "ZDCC", Geometry::ZPCPOSITION[0],
2327 Geometry::ZPCPOSITION[1] - Geometry::ZPDIMENSION[1] - zpSupportWallBottom[1], Geometry::ZPCPOSITION[2] - zpSupportWallBottom[2], 0, "ONLY");
2328 TVirtualMC::GetMC()->Gspos("ZPBB", 2, "ZDCA", Geometry::ZPAPOSITION[0],
2329 Geometry::ZPAPOSITION[1] - Geometry::ZPDIMENSION[1] - zpSupportWallBottom[1], Geometry::ZPAPOSITION[2] + zpSupportWallBottom[2], 0, "ONLY");
2330
2331 // Top walls
2332 TVirtualMC::GetMC()->Gsvolu("ZPBT", "BOX ", getMediumID(kAl), const_cast<double*>(zpSupportWallup), 3);
2333 TVirtualMC::GetMC()->Gspos("ZPBT", 1, "ZDCC", Geometry::ZPCPOSITION[0],
2334 Geometry::ZPCPOSITION[1] + Geometry::ZPDIMENSION[1] + zpSupportWallup[1], Geometry::ZPCPOSITION[2] - zpSupportWallup[2], 0, "ONLY");
2335 TVirtualMC::GetMC()->Gspos("ZPBT", 2, "ZDCA", Geometry::ZPAPOSITION[0],
2336 Geometry::ZPAPOSITION[1] + Geometry::ZPDIMENSION[1] + zpSupportWallup[1], Geometry::ZPAPOSITION[2] + zpSupportWallup[2], 0, "ONLY");
2337
2338 // Side walls
2339 TVirtualMC::GetMC()->Gsvolu("ZPBS", "BOX ", getMediumID(kAl), const_cast<double*>(zpSupportWallside), 3);
2340 TVirtualMC::GetMC()->Gspos("ZPBS", 1, "ZDCC", Geometry::ZPCPOSITION[0] + Geometry::ZPDIMENSION[0] + zpSupportWallside[0], Geometry::ZPCPOSITION[1] + 0.75, Geometry::ZPCPOSITION[2] - zpSupportWallside[2], 0, "ONLY");
2341 TVirtualMC::GetMC()->Gspos("ZPBS", 2, "ZDCC", Geometry::ZPCPOSITION[0] - Geometry::ZPDIMENSION[0] - zpSupportWallside[0], Geometry::ZPCPOSITION[1] + 0.75, Geometry::ZPCPOSITION[2] - zpSupportWallside[2], 0, "ONLY");
2342 TVirtualMC::GetMC()->Gspos("ZPBS", 3, "ZDCA", Geometry::ZPAPOSITION[0] + Geometry::ZPDIMENSION[0] + zpSupportWallside[0], Geometry::ZPAPOSITION[1] + 0.75, Geometry::ZPAPOSITION[2] + zpSupportWallside[2], 0, "ONLY");
2343 TVirtualMC::GetMC()->Gspos("ZPBS", 4, "ZDCA", Geometry::ZPAPOSITION[0] - Geometry::ZPDIMENSION[0] - zpSupportWallside[0], Geometry::ZPAPOSITION[1] + 0.75, Geometry::ZPAPOSITION[2] + zpSupportWallside[2], 0, "ONLY");
2344}
2345
2346//_____________________________________________________________________________
2347void Detector::createZEM()
2348{
2349 // -------------------------------------------------------------------------------
2350 // -> EM calorimeter (ZEM)
2351 if (!ZDCSimParam::Instance().buildZEM) {
2352 LOG(warning) << "ZDC: the ZEM calorimeters are not built";
2353 return;
2354 }
2355 int32_t irotzem1, irotzem2;
2356 double rangzem1[6] = {0., 0., 90., 90., -90., 0.};
2357 double rangzem2[6] = {180., 0., 90., 45. + 90., 90., 45.};
2358 TVirtualMC::GetMC()->Matrix(irotzem1, rangzem1[0], rangzem1[1], rangzem1[2], rangzem1[3], rangzem1[4], rangzem1[5]);
2359 TVirtualMC::GetMC()->Matrix(irotzem2, rangzem2[0], rangzem2[1], rangzem2[2], rangzem2[3], rangzem2[4], rangzem2[5]);
2360
2361 double zemLength = Geometry::ZEMDIMENSION[0];
2362 double zemTranLength = zemLength / 20.;
2363 double zemPbSlice[6] = {0.15 * TMath::Sqrt(2), 3.5, 3.5, 45., 0., 0.};
2364 double zemVoidLayer[6] = {(zemTranLength - 2. * zemPbSlice[0]) / 2., 3.5, 3.5, 45., 0., 0.};
2365 // Platform and support structures
2366 double zemSupportTable[3] = {55. / 2., 1.5 / 2., 110. / 2.};
2367 double zemSupportBox[6] = {10.5 / 2., 100. / 2., 95. / 2., 0.25 / 2., 2. / 2., 2. / 2.};
2368 double zemSupport1[3] = {15. / 2, 3. / 2., 95. / 2.}; //support table
2369 double zemSupport2[3] = {2. / 2, 5. / 2., 95. / 2.}; //support table heels (piedini)
2370 double zemSupport3[3] = {3.5, 2. / 2., zemLength}; //screens around ZEM
2371 double zemSupport4[6] = {20. / 2., 3.5, 1.5 / 2., 45., 0., 0.}; //detector box walls (side)
2372 double zemWallH[3] = {10.5 / 2., /*bthickness[1]*/ 1., 95. / 2.}; //box walls
2373 double zemWallVfwd[3] = {10.5 / 2., (100. - 2.) / 2., 0.2};
2374 double zemWallVbkw[3] = {10.5 / 2., (100. - 2.) / 2., 2. / 2.};
2375 double zemWallVside[3] = {0.25 / 2., (100. - 2.) / 2., (95. - 2.) / 2.};
2376
2377 TVirtualMC::GetMC()->Gsvolu("ZEM ", "PARA", getMediumID(kVoidNoField), const_cast<double*>(Geometry::ZEMDIMENSION), 6);
2378 TVirtualMC::GetMC()->Gsvolu("ZEMF", "TUBE", getMediumID(kSiO2pmc), const_cast<double*>(Geometry::ZEMFIBRE), 3); // Active material
2379 TVirtualMC::GetMC()->Gsdvn("ZETR", "ZEM ", Geometry::ZEMDIVISION[2], 1); // Tranches
2380
2381 TVirtualMC::GetMC()->Gsvolu("ZEL0", "PARA", getMediumID(kPb), const_cast<double*>(zemPbSlice), 6); // Lead slices
2382 TVirtualMC::GetMC()->Gsvolu("ZEL1", "PARA", getMediumID(kPb), const_cast<double*>(zemPbSlice), 6);
2383 TVirtualMC::GetMC()->Gsvolu("ZEL2", "PARA", getMediumID(kPb), const_cast<double*>(zemPbSlice), 6);
2384
2385 // --- Position the lead slices in the tranche
2386 TVirtualMC::GetMC()->Gspos("ZEL0", 1, "ZETR", -zemTranLength + zemPbSlice[0], 0., 0., 0, "ONLY");
2387 TVirtualMC::GetMC()->Gspos("ZEL1", 1, "ZETR", zemPbSlice[0], 0., 0., 0, "ONLY");
2388
2389 // --- Vacuum zone (to be filled with fibres)
2390 TVirtualMC::GetMC()->Gsvolu("ZEV0", "PARA", getMediumID(kVoidNoField), const_cast<double*>(zemVoidLayer), 6);
2391 TVirtualMC::GetMC()->Gsvolu("ZEV1", "PARA", getMediumID(kVoidNoField), const_cast<double*>(zemVoidLayer), 6);
2392
2393 // --- Divide the vacuum slice into sticks along x axis
2394 TVirtualMC::GetMC()->Gsdvn("ZES0", "ZEV0", Geometry::ZEMDIVISION[0], 3);
2395 TVirtualMC::GetMC()->Gsdvn("ZES1", "ZEV1", Geometry::ZEMDIVISION[0], 3);
2396
2397 // --- Positioning the fibers into the sticks
2398 TVirtualMC::GetMC()->Gspos("ZEMF", 1, "ZES0", 0., 0., 0., irotzem2, "ONLY");
2399 TVirtualMC::GetMC()->Gspos("ZEMF", 1, "ZES1", 0., 0., 0., irotzem2, "ONLY");
2400
2401 // --- Positioning the vacuum slice into the tranche
2402 //float displFib = fDimZEM[1]/fDivZEM[0];
2403 TVirtualMC::GetMC()->Gspos("ZEV0", 1, "ZETR", -zemVoidLayer[0], 0., 0., 0, "ONLY");
2404 TVirtualMC::GetMC()->Gspos("ZEV1", 1, "ZETR", -zemVoidLayer[0] + zemTranLength, 0., 0., 0, "ONLY");
2405
2406 // --- Positioning the ZEM into the ZDC - rotation for 90 degrees
2407 // NB -> ZEM is positioned in the barrel volume
2408 // The ZEM calorimeters and their supports occupy 750 < z < 860 cm, a region that
2409 // belongs to the barrel mother volume (caveRB24 starts only at z = 864.6 cm).
2410 // The barrel is placed at y = -30 cm in the cave, hence the y0 offset.
2411 const float y0 = 30.;
2412 TVirtualMC::GetMC()->Gspos("ZEM ", 1, "barrel", -Geometry::ZEMPOSITION[0], Geometry::ZEMPOSITION[1] + y0, Geometry::ZEMPOSITION[2] + Geometry::ZEMDIMENSION[0], irotzem1, "ONLY");
2413
2414 // Second EM ZDC (same side w.r.t. IP, just on the other side w.r.t. beam pipe)
2415 TVirtualMC::GetMC()->Gspos("ZEM ", 2, "barrel", Geometry::ZEMPOSITION[0], Geometry::ZEMPOSITION[1] + y0, Geometry::ZEMPOSITION[2] + Geometry::ZEMDIMENSION[0], irotzem1, "ONLY");
2416
2417 // --- Adding last slice at the end of the EM calorimeter
2418 float zLastSlice = Geometry::ZEMPOSITION[2] + zemPbSlice[0] + 2 * Geometry::ZEMDIMENSION[0];
2419 TVirtualMC::GetMC()->Gspos("ZEL2", 1, "barrel", Geometry::ZEMPOSITION[0], Geometry::ZEMPOSITION[1] + y0, zLastSlice, irotzem1, "ONLY");
2420
2421 // -------------------------------------------------------------------------------
2422 // -> ZEM supports
2423
2424 // Platform and supports
2425 float ybox = Geometry::ZEMPOSITION[1] - Geometry::ZEMDIMENSION[1] - 2. * 2. * zemSupportBox[3 + 1] + zemSupportBox[1];
2426 float zSupport = Geometry::ZEMPOSITION[2] - 3.5; //to take into account the titlted front face
2427 float zbox = zSupport + zemSupportBox[2];
2428
2429 // Bridge
2430 TVirtualMC::GetMC()->Gsvolu("ZESH", "BOX ", getMediumID(kAl), const_cast<double*>(zemSupport1), 3);
2431 float ybridge = Geometry::ZEMPOSITION[1] - Geometry::ZEMDIMENSION[1] - 2. * 2. * zemSupportBox[3 + 1] - 5. - zemSupport1[1];
2432 TVirtualMC::GetMC()->Gspos("ZESH", 1, "barrel", Geometry::ZEMPOSITION[0], ybridge + y0, zbox, 0, "ONLY");
2433 TVirtualMC::GetMC()->Gspos("ZESH", 2, "barrel", -Geometry::ZEMPOSITION[0], ybridge + y0, zbox, 0, "ONLY");
2434 //
2435 TVirtualMC::GetMC()->Gsvolu("ZESV", "BOX ", getMediumID(kAl), const_cast<double*>(zemSupport2), 3);
2436 TVirtualMC::GetMC()->Gspos("ZESV", 1, "barrel", Geometry::ZEMPOSITION[0] - zemSupportBox[0] + zemSupport2[0], ybox - zemSupportBox[1] - zemSupport2[1] + y0, zbox, 0, "ONLY");
2437 TVirtualMC::GetMC()->Gspos("ZESV", 2, "barrel", Geometry::ZEMPOSITION[0] + zemSupportBox[0] - zemSupport2[0], ybox - zemSupportBox[1] - zemSupport2[1] + y0, zbox, 0, "ONLY");
2438 TVirtualMC::GetMC()->Gspos("ZESV", 3, "barrel", -(Geometry::ZEMPOSITION[0] - zemSupportBox[0] + zemSupport2[0]), ybox - zemSupportBox[1] - zemSupport2[1] + y0, zbox, 0, "ONLY");
2439 TVirtualMC::GetMC()->Gspos("ZESV", 4, "barrel", -(Geometry::ZEMPOSITION[0] + zemSupportBox[0] - zemSupport2[0]), ybox - zemSupportBox[1] - zemSupport2[1] + y0, zbox, 0, "ONLY");
2440
2441 // Table
2442 TVirtualMC::GetMC()->Gsvolu("ZETA", "BOX ", getMediumID(kAl), const_cast<double*>(zemSupportTable), 3);
2443 float ytable = ybridge - zemSupport1[1] - zemSupportTable[1];
2444 TVirtualMC::GetMC()->Gspos("ZETA", 1, "barrel", 0.0, ytable + y0, zbox, 0, "ONLY");
2445 TVirtualMC::GetMC()->Gspos("ZETA", 2, "barrel", 0.0, ytable - 13. + 2. * zemSupportTable[1] + y0, zbox, 0, "ONLY");
2446
2447 //Screens around ZEM
2448 TVirtualMC::GetMC()->Gsvolu("ZEFL", "BOX ", getMediumID(kAl), const_cast<double*>(zemSupport3), 3);
2449 TVirtualMC::GetMC()->Gspos("ZEFL", 1, "barrel", Geometry::ZEMPOSITION[0], -Geometry::ZEMDIMENSION[1] - zemSupport3[1] + y0, zSupport + zemSupport3[2], 0, "ONLY");
2450 TVirtualMC::GetMC()->Gspos("ZEFL", 2, "barrel", -Geometry::ZEMPOSITION[0], -Geometry::ZEMDIMENSION[1] - zemSupport3[1] + y0, zSupport + zemSupport3[2], 0, "ONLY");
2451
2452 TVirtualMC::GetMC()->Gsvolu("ZELA", "PARA", getMediumID(kAl), const_cast<double*>(zemSupport4), 6);
2453 TVirtualMC::GetMC()->Gspos("ZELA", 1, "barrel", Geometry::ZEMPOSITION[0] - Geometry::ZEMDIMENSION[2] - zemSupport4[2], Geometry::ZEMPOSITION[1] + y0, Geometry::ZEMPOSITION[2] + zemSupport4[0], irotzem1, "ONLY");
2454 TVirtualMC::GetMC()->Gspos("ZELA", 2, "barrel", Geometry::ZEMPOSITION[0] + Geometry::ZEMDIMENSION[2] + zemSupport4[2], Geometry::ZEMPOSITION[1] + y0, Geometry::ZEMPOSITION[2] + zemSupport4[0], irotzem1, "ONLY");
2455 TVirtualMC::GetMC()->Gspos("ZELA", 3, "barrel", -(Geometry::ZEMPOSITION[0] - Geometry::ZEMDIMENSION[2] - zemSupport4[2]), Geometry::ZEMPOSITION[1] + y0, Geometry::ZEMPOSITION[2] + zemSupport4[0], irotzem1, "ONLY");
2456 TVirtualMC::GetMC()->Gspos("ZELA", 4, "barrel", -(Geometry::ZEMPOSITION[0] + Geometry::ZEMDIMENSION[2] + zemSupport4[2]), Geometry::ZEMPOSITION[1] + y0, Geometry::ZEMPOSITION[2] + zemSupport4[0], irotzem1, "ONLY");
2457
2458 // Containers for ZEM calorimeters
2459 TVirtualMC::GetMC()->Gsvolu("ZEW1", "BOX ", getMediumID(kAl), const_cast<double*>(zemWallH), 3);
2460 TVirtualMC::GetMC()->Gsvolu("ZEW2", "BOX ", getMediumID(kAl), const_cast<double*>(zemWallVfwd), 3);
2461 TVirtualMC::GetMC()->Gsvolu("ZEW3", "BOX ", getMediumID(kAl), const_cast<double*>(zemWallVbkw), 3);
2462 TVirtualMC::GetMC()->Gsvolu("ZEW4", "BOX ", getMediumID(kFe), const_cast<double*>(zemWallVside), 3);
2463 //
2464 float yh1 = Geometry::ZEMPOSITION[1] - Geometry::ZEMDIMENSION[1] - 2 * zemSupport3[1] - zemWallH[1];
2465 float zh1 = zSupport + zemWallH[2];
2466 TVirtualMC::GetMC()->Gspos("ZEW1", 1, "barrel", Geometry::ZEMPOSITION[0], yh1 + y0, zh1, 0, "ONLY");
2467 TVirtualMC::GetMC()->Gspos("ZEW1", 2, "barrel", Geometry::ZEMPOSITION[0], yh1 + 2 * zemSupportBox[1] + y0, zh1, 0, "ONLY");
2468 TVirtualMC::GetMC()->Gspos("ZEW1", 3, "barrel", -Geometry::ZEMPOSITION[0], yh1 + y0, zh1, 0, "ONLY");
2469 TVirtualMC::GetMC()->Gspos("ZEW1", 4, "barrel", -Geometry::ZEMPOSITION[0], yh1 + 2 * zemSupportBox[1] + y0, zh1, 0, "ONLY");
2470 //
2471 TVirtualMC::GetMC()->Gspos("ZEW2", 1, "barrel", Geometry::ZEMPOSITION[0], yh1 + zemSupportBox[1] + y0, zSupport - zemWallVfwd[2], 0, "ONLY");
2472 TVirtualMC::GetMC()->Gspos("ZEW3", 1, "barrel", Geometry::ZEMPOSITION[0], yh1 + zemSupportBox[1] + y0, zSupport + 2 * zemWallH[2], 0, "ONLY");
2473 TVirtualMC::GetMC()->Gspos("ZEW2", 2, "barrel", -Geometry::ZEMPOSITION[0], yh1 + zemSupportBox[1] + y0, zSupport - zemWallVfwd[2], 0, "ONLY");
2474 TVirtualMC::GetMC()->Gspos("ZEW3", 2, "barrel", -Geometry::ZEMPOSITION[0], yh1 + zemSupportBox[1] + y0, zSupport + 2 * zemWallH[2], 0, "ONLY");
2475 //
2476 float xl1 = Geometry::ZEMPOSITION[0] - Geometry::ZEMDIMENSION[2] - 2. * zemSupport4[2] - zemWallVside[0];
2477 float xl2 = Geometry::ZEMPOSITION[0] + Geometry::ZEMDIMENSION[2] + 2. * zemSupport4[2] + zemWallVside[0];
2478 TVirtualMC::GetMC()->Gspos("ZEW4", 1, "barrel", xl1, yh1 + zemSupportBox[1] + y0, zh1, 0, "ONLY");
2479 TVirtualMC::GetMC()->Gspos("ZEW4", 2, "barrel", xl2, yh1 + zemSupportBox[1] + y0, zh1, 0, "ONLY");
2480 TVirtualMC::GetMC()->Gspos("ZEW4", 3, "barrel", -xl1, yh1 + zemSupportBox[1] + y0, zh1, 0, "ONLY");
2481 TVirtualMC::GetMC()->Gspos("ZEW4", 4, "barrel", -xl2, yh1 + zemSupportBox[1] + y0, zh1, 0, "ONLY");
2482}
2483
2484//_____________________________________________________________________________
2493Bool_t Detector::withZEM()
2494{
2495 const auto& modules = o2::conf::SimConfig::Instance().getActiveModules();
2496 return std::find(modules.begin(), modules.end(), "FOC") == modules.end();
2497}
2498
2499//_____________________________________________________________________________
2500Bool_t Detector::calculateTableIndexes(int& ibeta, int& iangle, int& iradius)
2501{
2502 double x[3] = {0., 0., 0.}, xDet[3] = {0., 0., 0.}, p[3] = {0., 0., 0.}, energy = 0.;
2503 fMC->TrackPosition(x[0], x[1], x[2]);
2504 fMC->TrackMomentum(p[0], p[1], p[2], energy);
2505
2506 //particle velocity
2507 float ptot = TMath::Sqrt(p[0] * p[0] + p[1] * p[1] + p[2] * p[2]);
2508 float beta = 0.;
2509 if (energy > 0.) {
2510 beta = ptot / energy;
2511 }
2512 if (beta >= 0.67) {
2513 if (beta <= 0.75) {
2514 ibeta = 0;
2515 } else if (beta > 0.75 && beta <= 0.85) {
2516 ibeta = 1;
2517 } else if (beta > 0.85 && beta <= 0.95) {
2518 ibeta = 2;
2519 } else if (beta > 0.95) {
2520 ibeta = 3;
2521 }
2522 } else {
2523 return kFALSE;
2524 }
2525 //track angle wrt fibre axis (||LHC axis)
2526 double umom[3] = {0., 0., 0.}, udet[3] = {0., 0., 0.};
2527 umom[0] = p[0] / ptot;
2528 umom[1] = p[1] / ptot;
2529 umom[2] = p[2] / ptot;
2530 fMC->Gmtod(umom, udet, 2);
2531 double angleRad = TMath::ACos(udet[2]);
2532 double angleDeg = angleRad * kRaddeg;
2533 if (angleDeg < 110.) {
2534 iangle = int(0.5 + angleDeg / 2.);
2535 } else {
2536 return kFALSE;
2537 }
2538 //radius from fibre axis
2539 fMC->Gmtod(x, xDet, 1);
2540 float radius = 0.;
2541 if (TMath::Abs(udet[0]) > 0) {
2542 float dcoeff = udet[1] / udet[0];
2543 radius = TMath::Abs((xDet[1] - dcoeff * xDet[0]) / TMath::Sqrt(dcoeff * dcoeff + 1.));
2544 } else {
2545 radius = TMath::Abs(udet[0]);
2546 }
2547 iradius = int(radius * 1000. + 1.);
2548 //printf("\t beta %f angle %f radius %f\n",beta, angleDeg, radius);
2549 return kTRUE;
2550}
2551
2552//_____________________________________________________________________________
2554{
2555 Reset();
2556}
2557
2558//_____________________________________________________________________________
2560{
2561 // after each primary we should definitely reset
2562 mLastPrincipalTrackEntered = -1;
2563 flushSpatialResponse();
2564
2565#ifdef ZDC_FASTSIM_ONNX
2566 // dump to file only if debugZDCFastSim is set to true
2567 auto& simparam = o2::zdc::ZDCSimParam::Instance();
2568 if (simparam.debugZDCFastSim && simparam.useZDCFastSim && mFastSimModelNeutron != nullptr && mFastSimModelProton != nullptr && mFastSimClassifier != nullptr) {
2569 std::fstream output("o2sim-FastSimResult", std::fstream::out | std::fstream::app);
2570 if (!output.is_open()) {
2571 LOG(error) << "Could not open file.";
2572 } else {
2573
2574 for (auto& result : mFastSimResults) {
2575 output << result[0] << ", " << result[1] << ", " << result[2] << ", " << result[3] << ", " << result[4];
2576 output << std::endl;
2577 }
2578 mFastSimResults.clear();
2579 }
2580 output.close();
2581 }
2582#endif
2583}
2584
2586{
2587 // set current principal track
2588 auto stack = (o2::data::Stack*)fMC->GetStack();
2589
2590 mLastPrincipalTrackEntered = stack->GetCurrentTrackNumber();
2591 resetHitIndices();
2592
2593 mCurrentPrincipalParticle = *stack->GetCurrentTrack();
2594
2595#ifdef ZDC_FASTSIM_ONNX
2596 auto& simparam = o2::zdc::ZDCSimParam::Instance();
2597 using std::vector;
2598 if (simparam.useZDCFastSim && (mFastSimModelNeutron != nullptr || mFastSimModelProton != nullptr) && mFastSimClassifier != nullptr) {
2599 const std::vector<float> rawInput = {static_cast<float>(mCurrentPrincipalParticle.Energy()),
2600 static_cast<float>(mCurrentPrincipalParticle.Vx()),
2601 static_cast<float>(mCurrentPrincipalParticle.Vy()),
2602 static_cast<float>(mCurrentPrincipalParticle.Vz()),
2603 static_cast<float>(mCurrentPrincipalParticle.Px()),
2604 static_cast<float>(mCurrentPrincipalParticle.Py()),
2605 static_cast<float>(mCurrentPrincipalParticle.Pz()),
2606 static_cast<float>(mCurrentPrincipalParticle.GetMass() * 1000.0),
2607 static_cast<float>(mCurrentPrincipalParticle.GetPDG()->Charge())};
2608
2609 auto scaledClassParticle = mClassifierScaler->scale(rawInput);
2610 if (!scaledClassParticle.has_value()) {
2611 LOG(error) << "FastSimModule: error occurred on scaling";
2612 } else {
2613 vector<vector<float>> classifierInput = {std::move(*scaledClassParticle)};
2614 mFastSimClassifier->setInput(classifierInput);
2615 mFastSimClassifier->run();
2616
2617 // this classifies if particle will leave a trace at all in one of the calos ---> TODO: better do it separately for ZN + ZP?
2618 if (fastsim::processors::readClassifier(mFastSimClassifier->getResult()[0], 1)[0]) {
2619 // let's do the neutron (ZN) part
2620 if (mModelScalerNeutron && mFastSimModelNeutron) {
2621 LOG(info) << "Generating fast hits for ZN";
2622 auto scaledModelParticleNeutron = mModelScalerNeutron->scale(rawInput);
2623 if (!scaledModelParticleNeutron.has_value()) {
2624 LOG(error) << "FastSimModule: error occurred on scaling";
2625 } else {
2626 vector<vector<float>> modelInputNeutron = {fastsim::normal_distribution(0.0, 1.0, 10), std::move(*scaledModelParticleNeutron)};
2627 mFastSimModelNeutron->setInput(modelInputNeutron);
2628 mFastSimModelNeutron->run();
2629 if (simparam.debugZDCFastSim) {
2630 mFastSimResults.push_back(fastsim::processors::calculateChannels(mFastSimModelNeutron->getResult()[0], 1)[0]);
2631 }
2632 // produce hits from fast sim result
2633 bool forward = mCurrentPrincipalParticle.Pz() > 0.;
2634 FastSimToHits(mFastSimModelNeutron->getResult()[0], mCurrentPrincipalParticle, forward ? ZNA : ZNC);
2635 }
2636 }
2637 // let's do the proton (ZP) part
2638 if (mModelScalerProton && mFastSimModelProton) {
2639 LOG(info) << "Generating fast hits for ZP";
2640 auto scaledModelParticleProton = mModelScalerProton->scale(rawInput);
2641 if (!scaledModelParticleProton.has_value()) {
2642 LOG(error) << "FastSimModule: error occurred on scaling";
2643 } else {
2644 vector<vector<float>> modelInputProton = {fastsim::normal_distribution(0.0, 1.0, 10), std::move(*scaledModelParticleProton)};
2645 mFastSimModelProton->setInput(modelInputProton);
2646 mFastSimModelProton->run();
2647 // produce hits from fast sim result
2648 bool forward = mCurrentPrincipalParticle.Pz() > 0.;
2649 FastSimToHits(mFastSimModelProton->getResult()[0], mCurrentPrincipalParticle, forward ? ZPA : ZPC);
2650 }
2651 } // end proton treatment
2652 }
2653 }
2654 }
2655#endif
2656}
2657
2658//_____________________________________________________________________________
2659void Detector::Register()
2660{
2661 // This will create a branch in the output tree called Hit, setting the last
2662 // parameter to kFALSE means that this collection will not be written to the file,
2663 // it will exist only during the simulation
2664
2666 FairRootManager::Instance()->RegisterAny(addNameTo("Hit").data(), mHits, kTRUE);
2667
2668 if (o2::zdc::ZDCSimParam::Instance().recordSpatialResponse) {
2669 FairRootManager::Instance()->RegisterAny(addNameTo("ResponseImage").data(), mResponsesPtr, kTRUE);
2670 }
2671 }
2672}
2673
2674//_____________________________________________________________________________
2675void Detector::Reset()
2676{
2677 if (!o2::utils::ShmManager::Instance().isOperational()) {
2678 mHits->clear();
2679 }
2680 mResponses.clear();
2681 mLastPrincipalTrackEntered = -1;
2682 resetHitIndices();
2683}
2684
2685//_____________________________________________________________________________
2686// The code of this function is taken from createHitsFromImage
2687// The changes were made to directly convert FastSim output to Hits
2688// TParticle can be used to fill additional data required by Hits
2689#ifdef ZDC_FASTSIM_ONNX
2690bool Detector::FastSimToHits(const Ort::Value& response, const TParticle& particle, int detector)
2691{
2692 math_utils::Vector3D<float> xImp(0., 0., 0.); // good value
2693
2694 // determines dimensions of the detector and binds it
2695 auto [Nx, Ny] = determineDetectorSize(detector);
2696 // if invalid detector was provided return false
2697 if (Nx == -1 || Ny == -1) {
2698 return false;
2699 }
2700
2701 // gets model output as const float*
2702 auto pixels = response.GetTensorData<float>();
2703
2704 auto determineSectorID = [&Nx = Nx, &Ny = Ny](int detector, int x, int y) {
2705 if (detector == ZNA || detector == ZNC) {
2706 if ((x + y) % 2 == 0) {
2707 return (int)Common;
2708 }
2709 if (x < Nx / 2) {
2710 if (y < Ny / 2) {
2711 return (int)Ch1;
2712 } else {
2713 return (int)Ch3;
2714 }
2715 } else {
2716 if (y >= Ny / 2) {
2717 return (int)Ch4;
2718 } else {
2719 return (int)Ch2;
2720 }
2721 }
2722 }
2723
2724 if (detector == ZPA || detector == ZPC) {
2725 if ((x + y) % 2 == 0) {
2726 return (int)Common;
2727 }
2728 auto i = (int)(4.f * x / Nx);
2729 return (int)(i + 1);
2730 }
2731 return -1;
2732 };
2733
2734 auto determineMediumID = [this](int detector, int x, int y) {
2735 // it is a simple checkerboard pattern
2736 return ((x + y) % 2 == 0) ? mMediumPMCid : mMediumPMQid;
2737 };
2738
2739 auto z_pos = 0.;
2740 if (detector == ZPA) {
2742 } else if (detector == ZPC) {
2744 } else if (detector == ZNA) {
2746 } else if (detector == ZNC) {
2748 } else {
2749 // should not happen --> we don't have fastsim for other detectors
2750 LOG(fatal) << "Unsupported detector in ZDC fast sim";
2751 }
2752 z_pos /= 1.e02; //z_pos in m
2753
2754 const float tof = 1.e09 * estimateTimeOfFlight(particle, std::abs(z_pos)); //TOF in ns
2755
2756 // loop over x = columns
2757 for (int x = 0; x < Nx; ++x) {
2758 // loop over y = rows
2759 for (int y = 0; y < Ny; ++y) {
2760 // get sector
2761 int sector = determineSectorID(detector, x, y);
2762 // get medium PMQ and PMC
2763 int currentMediumid = determineMediumID(detector, x, y);
2764 // LOG(info) << " x " << x << " y " << y << " sec " << sector << " medium " << currentMediumid;
2765 // Model output needs to be converted with exp(x)-1 function to be valid
2766 int nphe = (int)std::expm1(pixels[Nx * y + x]);
2767
2768 if (nphe > 0) {
2769 float trackenergy = 0; // energy of the primary (need to fill good value)
2770 createOrAddHit(detector,
2771 sector,
2772 currentMediumid,
2773 0 /*issecondary ---> don't know in fast sim */,
2774 nphe,
2775 0 /* trackn */,
2776 0 /* parent */,
2777 tof,
2778 trackenergy,
2779 xImp,
2780 0. /* eDep */, 0 /* x */, 0. /* y */, 0. /* z */, 0. /* px */, 0. /* py */, 0. /* pz */);
2781 }
2782 } // end loop over y
2783 } // end loop over x
2784 return true;
2785}
2786#endif
Definition of the ZDC Hit class.
Definition of the Stack class.
std::ostringstream debug
int16_t charge
Definition RawEventData.h:5
#define kRaddeg
int32_t i
configStandalone Light OpenGL display display_light Apply smoothing to points Enable Z buffer Highlight links Highlight seeds Highlight sector tracks Highlight final tracks Show individual sector
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc Replace constant variables static by constexpr expressions Compile RTC in deterministic with NO_FAST_MATH flags and GPUCA_DETERMINISTIC_MODE define Use RTC to optimize GPU code h configStandalone Processing proc_rtctech Use a file lock to serialize access to the cache folder int32_t
char error[CURL_ERROR_SIZE]
void output(const std::map< std::string, ChannelStat > &channels)
Definition rawdump.cxx:197
uint16_t pos
Definition RawData.h:3
uint32_t c
Definition RawData.h:2
uint32_t stack
Definition RawData.h:1
double radius
int loadLightTable(T &table, int beta, int NRADBINS, std::string filename)
Definition Detector.cxx:169
double estimateTimeOfFlight(TParticle const &part, double z)
Definition Detector.cxx:396
ClassImp(o2::zdc::Detector)
Int_t GetDetId()
void AddSensitiveVolume(TGeoVolume *v)
TVirtualMC * fMC
flag for initialisation
Definition FairModule.h:160
void RegisterAny(const char *name, T *&obj, Bool_t toFile)
static FairRootManager * Instance()
void Mixture(Int_t imat, const char *name, Float_t *a, Float_t *z, Float_t dens, Int_t nlmat, Float_t *wmat)
Definition Detector.cxx:66
void Medium(Int_t numed, const char *name, Int_t nmat, Int_t isvol, Int_t ifield, Float_t fieldm, Float_t tmaxfd, Float_t stemax, Float_t deemax, Float_t epsil, Float_t stmin, Float_t *ubuf=nullptr, Int_t nbuf=0)
Definition Detector.cxx:72
int getMediumID(int imed) const
Definition Detector.h:136
static void initFieldTrackingParams(int &mode, float &maxfield)
Definition Detector.cxx:143
void Material(Int_t imat, const char *name, Float_t a, Float_t z, Float_t dens, Float_t radl, Float_t absl, Float_t *buf=nullptr, Int_t nwbuf=0)
Definition Detector.cxx:59
std::string addNameTo(const char *ext) const
Definition Detector.h:151
static MaterialManager & Instance()
std::vector< std::string > const & getActiveModules() const
Definition SimConfig.h:140
static SimConfig & Instance()
Definition SimConfig.h:112
static ShmManager & Instance()
Definition ShmManager.h:62
o2::zdc::Hit * addHit(int32_t trackID, int32_t parentID, int32_t sFlag, float primaryEnergy, int32_t detID, int32_t secID, math_utils::Vector3D< float > pos, math_utils::Vector3D< float > mom, float tof, math_utils::Vector3D< float > xImpact, double energyloss, int32_t nphePMC, int32_t nphePMQ)
Definition Detector.cxx:633
void BeginPrimary() final
void ConstructGeometry() final
Definition Detector.cxx:365
void Register() override
Definition Detector.cxx:343
Detector(Bool_t active=true)
Definition Detector.cxx:71
void InitializeO2Detector() final
Definition Detector.cxx:201
void FinishPrimary() final
~Detector() override=default
Bool_t ProcessHits(FairVolume *v=nullptr) final
Definition Detector.cxx:412
void EndOfEvent() final
Definition Detector.cxx:331
bool createHitsFromImage(SpatialPhotonResponse const &image, int detector)
Definition Detector.cxx:559
void Reset() final
Definition Detector.cxx:357
static constexpr double ZNAPOSITION[3]
Definition Geometry.h:33
static constexpr double ZPFIBRE[3]
Definition Geometry.h:37
static constexpr double ZEMFIBRE[3]
Definition Geometry.h:47
static constexpr double ZNFIBRE[3]
Definition Geometry.h:28
static constexpr double ZPAPOSITION[3]
Definition Geometry.h:42
static constexpr double ZEMPOSITION[3]
Definition Geometry.h:51
static constexpr double ZNDIVISION[2]
Definition Geometry.h:30
static constexpr double ZPSECTORS[2]
Definition Geometry.h:38
static constexpr double ZPGROOVES[3]
Definition Geometry.h:40
static constexpr double ZPFIBREDIAMETER
Definition Geometry.h:43
static constexpr double ZNFIBREDIAMETER
Definition Geometry.h:34
static constexpr double ZEMDIVISION[3]
Definition Geometry.h:48
static constexpr double ZPCPOSITION[3]
Definition Geometry.h:41
static constexpr double ZNDIMENSION[3]
Definition Geometry.h:27
static constexpr double ZNGROOVES[3]
Definition Geometry.h:31
static constexpr double ZNSECTORS[2]
Definition Geometry.h:29
static constexpr double ZPDIVISION[2]
Definition Geometry.h:39
static constexpr double ZEMDIMENSION[6]
Definition Geometry.h:46
static constexpr double ZPDIMENSION[3]
Definition Geometry.h:36
static constexpr double ZNCPOSITION[3]
Definition Geometry.h:32
void addPhoton(double x, double y, int nphotons)
std::array< int, 5 > getPhotonsPerChannel() const
Derived class implementing interface for specific types of models.
GLeglImageOES image
Definition glcorearb.h:4021
GLint GLenum GLint x
Definition glcorearb.h:403
const GLfloat * m
Definition glcorearb.h:4066
GLuint64EXT * result
Definition glcorearb.h:5662
const GLdouble * v
Definition glcorearb.h:832
GLint y
Definition glcorearb.h:270
GLsizei const GLfloat * value
Definition glcorearb.h:819
GLintptr offset
Definition glcorearb.h:660
GLint GLint GLsizei GLint GLenum GLenum const void * pixels
Definition glcorearb.h:275
GLuint GLfloat GLfloat y0
Definition glcorearb.h:5034
GLdouble GLdouble GLdouble z
Definition glcorearb.h:843
GLuint counter
Definition glcorearb.h:3987
uint8_t int statusCode int
TRandom * simRandom()
Definition SimRandom.cxx:22
D const SVectorGPU< T, D > & rhs
Definition SMatrixGPU.h:193
std::vector< T, fair::mq::pmr::polymorphic_allocator< T > > vector
struct o2::upgrades_utils::@482 zdc
structure to keep FT0 information
std::vector< int > readClassifier(const Ort::Value &value, size_t batchSize)
Reads predicted class as int.
std::vector< std::array< long, 5 > > calculateChannels(const Ort::Value &value, size_t batchSize)
Calculate 5 channels values from 44x44 float array (for every batch)
std::vector< float > normal_distribution(double mean, double stddev, size_t size)
Generates a vector of numbers with a given normal distribution and length.
Definition Utils.cxx:19
std::optional< std::pair< std::vector< float >, std::vector< float > > > loadScales(const std::string &path)
loads and parse model scales from file at path
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::string filename()
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"