forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDetector.cxx
More file actions
2718 lines (2351 loc) · 118 KB
/
Detector.cxx
File metadata and controls
2718 lines (2351 loc) · 118 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
// FairRoot includes
#include "Framework/Logger.h"
#include "FairRootManager.h" // for FairRootManager
#include "FairVolume.h" // for FairVolume
#include "DetectorsBase/MaterialManager.h"
#include "DetectorsBase/Stack.h"
#include "ZDCSimulation/Detector.h"
#include "DataFormatsZDC/Hit.h"
#include "TMath.h"
#include "TGeoManager.h" // for TGeoManager, gGeoManager
#include "TGeoVolume.h" // for TGeoVolume, TGeoVolumeAssembly
#include "TGeoTube.h" // for TGeoTube
#include "TGeoCone.h" // for TGeoCone
#include "TGeoCompositeShape.h" // for TGeoCone
#include "TVirtualMC.h" // for gMC, TVirtualMC
#include "TString.h" // for TString, operator+
#include <TRandom.h>
#include <cassert>
#include <fstream>
#include "ZDCSimulation/ZDCSimParam.h"
#ifdef ZDC_FASTSIM_ONNX
#include "Utils.h" // for normal_distribution()
#include "FastSimulations.h" // for fastsim module
#include "Processors.h" // for fastsim module
#endif
using namespace o2::zdc;
ClassImp(o2::zdc::Detector);
#define kRaddeg TMath::RadToDeg()
//_____________________________________________________________________________
Detector::Detector(Bool_t active)
: o2::base::DetImpl<Detector>("ZDC", active),
mHits(new std::vector<o2::zdc::Hit>),
mXImpact(-999, -999, -999),
mNeutronResponseImage(Geometry::ZNDIVISION[0] * Geometry::ZNSECTORS[0] * 2,
Geometry::ZNDIVISION[1] * Geometry::ZNSECTORS[1] * 2,
Geometry::ZNAPOSITION[0] - Geometry::ZNDIMENSION[0],
Geometry::ZNAPOSITION[1] - Geometry::ZNDIMENSION[1],
Geometry::ZNDIMENSION[0] * 2,
Geometry::ZNDIMENSION[1] * 2),
mProtonResponseImage(Geometry::ZPDIVISION[0] * Geometry::ZPSECTORS[0] * 2,
Geometry::ZPDIVISION[1] * Geometry::ZPSECTORS[1] * 2,
Geometry::ZPAPOSITION[0] - Geometry::ZPDIMENSION[0],
Geometry::ZPAPOSITION[1] - Geometry::ZPDIMENSION[1],
Geometry::ZPDIMENSION[0] * 2,
Geometry::ZPDIMENSION[1] * 2)
{
mTrackEta = 999;
// REsetting summed variables
mTotLightPMC = 0;
mTotLightPMQ = 0;
mMediumPMCid = -1; // minus for unitialized
mMediumPMQid = -2; // different to PMC in any case
resetHitIndices();
#ifdef ZDC_FASTSIM_ONNX
// If FastSim module was disabled, log appropriate message
// otherwise check if all necessary parameters were passed, if so try build objects
auto& simparam = o2::zdc::ZDCSimParam::Instance();
if (!simparam.useZDCFastSim) {
LOG(info) << "FastSim module disabled";
} else if (simparam.useZDCFastSim && !simparam.ZDCFastSimClassifierPath.empty() && !simparam.ZDCFastSimClassifierScales.empty()) {
if (!mClassifierScaler) {
mClassifierScaler = new fastsim::processors::StandardScaler;
}
if (!mModelScalerNeutron) {
mModelScalerNeutron = new fastsim::processors::StandardScaler;
}
if (!mModelScalerProton) {
mModelScalerProton = new fastsim::processors::StandardScaler;
}
auto eonScales = o2::zdc::fastsim::loadScales(simparam.ZDCFastSimClassifierScales);
if (!eonScales.has_value()) {
LOG(error) << "Error while reading model scales from: "
<< "'" << simparam.ZDCFastSimClassifierScales << "'";
LOG(error) << "FastSim module disabled.";
} else {
mClassifierScaler->setScales(eonScales->first, eonScales->second);
mFastSimClassifier = new o2::zdc::fastsim::ConditionalModelSimulation(simparam.ZDCFastSimClassifierPath, 1);
if (simparam.useZDCFastSim && !simparam.ZDCFastSimModelPathNeutron.empty() && !simparam.ZDCFastSimModelScalesNeutron.empty()) {
auto modelScalesNeutron = o2::zdc::fastsim::loadScales(simparam.ZDCFastSimModelScalesNeutron);
if (!modelScalesNeutron.has_value()) {
LOG(error) << "Error while reading model scales from: "
<< "'" << simparam.ZDCFastSimModelScalesNeutron << "'";
LOG(error) << "FastSim module disabled";
} else {
mModelScalerNeutron->setScales(modelScalesNeutron->first, modelScalesNeutron->second);
mFastSimModelNeutron = new o2::zdc::fastsim::ConditionalModelSimulation(simparam.ZDCFastSimModelPathNeutron, 1);
LOG(info) << "FastSim neutron module enabled";
}
}
if (simparam.useZDCFastSim && !simparam.ZDCFastSimModelPathProton.empty() && !simparam.ZDCFastSimModelScalesProton.empty()) {
auto modelScalesProton = o2::zdc::fastsim::loadScales(simparam.ZDCFastSimModelScalesProton);
if (!modelScalesProton.has_value()) {
LOG(error) << "Error while reading model scales from: "
<< "'" << simparam.ZDCFastSimModelScalesProton << "'";
LOG(error) << "FastSim module disabled";
} else {
mModelScalerProton->setScales(modelScalesProton->first, modelScalesProton->second);
mFastSimModelProton = new o2::zdc::fastsim::ConditionalModelSimulation(simparam.ZDCFastSimModelPathProton, 1);
LOG(info) << "FastSim proton module enabled";
}
}
}
}
#endif
}
//_____________________________________________________________________________
Detector::Detector(const Detector& rhs)
: o2::base::DetImpl<Detector>(rhs),
mHits(new std::vector<o2::zdc::Hit>)
{
}
//_____________________________________________________________________________
#ifdef ZDC_FASTSIM_ONNX
Detector::~Detector()
{
delete (mFastSimClassifier);
delete (mFastSimModelNeutron);
delete (mFastSimModelProton);
delete (mClassifierScaler);
delete (mModelScalerNeutron);
delete (mModelScalerProton);
}
#endif
//_____________________________________________________________________________
template <typename T>
int loadLightTable(T& table, int beta, int NRADBINS, std::string filename)
{
// Retrieve the light yield table
std::string data;
std::ifstream input(filename);
//std::cout << " ********* Reading data from light table " << filename << std::endl;
int radiusbin = 0;
int anglebin = 0;
int counter = 0;
float value;
if (input.is_open()) {
while (input >> value) {
counter++;
table[beta][anglebin][radiusbin] = value;
//printf(" %f ", value);
radiusbin++;
if (radiusbin % NRADBINS == 0) {
radiusbin = 0;
anglebin++;
//printf("\n");
}
}
LOG(debug) << "Read " << counter << " values from ZDC data file " << filename;
input.close();
return counter;
} else {
LOG(error) << "Could not open file " << filename;
return 0;
}
}
//_____________________________________________________________________________
void Detector::InitializeO2Detector()
{
// Define the list of sensitive volumes
defineSensitiveVolumes();
std::string inputDir;
const char* aliceO2env = std::getenv("O2_ROOT");
if (aliceO2env) {
inputDir = std::string(aliceO2env);
}
inputDir += "/share/Detectors/ZDC/simulation/data/";
//ZN case
loadLightTable(mLightTableZN, 0, ZNRADIUSBINS, inputDir + "light22620362207s");
loadLightTable(mLightTableZN, 1, ZNRADIUSBINS, inputDir + "light22620362208s");
loadLightTable(mLightTableZN, 2, ZNRADIUSBINS, inputDir + "light22620362209s");
auto elements = loadLightTable(mLightTableZN, 3, ZNRADIUSBINS, inputDir + "light22620362210s");
assert(elements == ZNRADIUSBINS * ANGLEBINS);
// check a few values to test correctness of reading from file light22620362207s
/*assert(std::abs(mLightTableZN[0][ZNRADIUSBINS - 1][0] - 1.39742) < 1.E-4); // beta=0; radius = ZNRADIUSBINS - 1; anglebin = 2;
assert(std::abs(mLightTableZN[0][ZNRADIUSBINS - 1][1] - .45017) < 1.E-4); // beta=1; radius = ZNRADIUSBINS - 1; anglebin = 2;
assert(std::abs(mLightTableZN[0][0][2] - .47985) < 1.E-4); // beta=0; radius = 0; anglebin = 2;
assert(std::abs(mLightTableZN[0][0][11] - .01358) < 1.E-4); // beta=0; radius = 0; anglebin = 11;
*/
//ZP case
loadLightTable(mLightTableZP, 0, ZPRADIUSBINS, inputDir + "light22620552207s");
loadLightTable(mLightTableZP, 1, ZPRADIUSBINS, inputDir + "light22620552208s");
loadLightTable(mLightTableZP, 2, ZPRADIUSBINS, inputDir + "light22620552209s");
elements = loadLightTable(mLightTableZP, 3, ZPRADIUSBINS, inputDir + "light22620552210s");
assert(elements == ZPRADIUSBINS * ANGLEBINS);
}
//_____________________________________________________________________________
void Detector::ConstructGeometry()
{
LOG(debug) << "Creating ZDC geometry\n";
createMaterials();
createAsideBeamLine();
createCsideBeamLine();
createMagnets();
createDetectors();
}
//_____________________________________________________________________________
void Detector::defineSensitiveVolumes()
{
LOG(info) << "defining sensitive for ZDC";
auto vol = gGeoManager->GetVolume("ZNENV");
if (vol) {
AddSensitiveVolume(vol);
mZNENVVolID = vol->GetNumber(); // initialize id
AddSensitiveVolume(gGeoManager->GetVolume("ZNF1"));
AddSensitiveVolume(gGeoManager->GetVolume("ZNF2"));
AddSensitiveVolume(gGeoManager->GetVolume("ZNF3"));
AddSensitiveVolume(gGeoManager->GetVolume("ZNF4"));
} else {
LOG(fatal) << "can't find volume ZNENV";
}
vol = gGeoManager->GetVolume("ZPENV");
if (vol) {
AddSensitiveVolume(vol);
mZPENVVolID = vol->GetNumber(); // initialize id
AddSensitiveVolume(gGeoManager->GetVolume("ZPF1"));
AddSensitiveVolume(gGeoManager->GetVolume("ZPF2"));
AddSensitiveVolume(gGeoManager->GetVolume("ZPF3"));
AddSensitiveVolume(gGeoManager->GetVolume("ZPF4"));
} else {
LOG(fatal) << "can't find volume ZPENV";
}
// em calorimeter
vol = gGeoManager->GetVolume("ZEM ");
if (vol) {
AddSensitiveVolume(vol);
mZEMVolID = vol->GetNumber();
AddSensitiveVolume(gGeoManager->GetVolume("ZEMF"));
} else {
LOG(fatal) << "can't find volume ZEM";
}
}
// determines detectorID and sectorID from volume and coordinates
void Detector::getDetIDandSecID(TString const& volname, math_utils::Vector3D<float> const& x,
math_utils::Vector3D<float>& xDet, int& detector, int& sector) const
{
if (volname.BeginsWith("ZN")) {
// for the neutron calorimeter
if (x.Z() > 0) {
detector = ZNA;
xDet = -(x - math_utils::Vector3D<float>(Geometry::ZNAPOSITION[0], Geometry::ZNAPOSITION[1], Geometry::ZNAPOSITION[2]));
} else if (x.Z() < 0) {
detector = ZNC;
xDet = x - math_utils::Vector3D<float>(Geometry::ZNCPOSITION[0], Geometry::ZNCPOSITION[1], Geometry::ZNCPOSITION[2]);
}
// now determine sector/tower
if (xDet.X() <= 0.) {
if (xDet.Y() <= 0.) {
sector = Ch1;
} else {
sector = Ch3;
}
} else {
if (xDet.Y() <= 0.) {
sector = Ch2;
} else {
sector = Ch4;
}
}
return;
} else if (volname.BeginsWith("ZP")) {
// proton calorimeter
if (x.Z() > 0) {
detector = ZPA; // (NB -> DIFFERENT FROM AliRoot!!!)
xDet = -(x - math_utils::Vector3D<float>(Geometry::ZPAPOSITION[0], Geometry::ZPAPOSITION[1], Geometry::ZPAPOSITION[2]));
} else if (x.Z() < 0) {
detector = ZPC; // (NB -> DIFFERENT FROM AliRoot!!!)
xDet = x - math_utils::Vector3D<float>(Geometry::ZPCPOSITION[0], Geometry::ZPCPOSITION[1], Geometry::ZPCPOSITION[2]);
}
// determine sector/tower
if (xDet.X() >= Geometry::ZPDIMENSION[0]) {
xDet.SetX(Geometry::ZPDIMENSION[0] - 0.01);
} else if (xDet.X() <= -Geometry::ZPDIMENSION[0]) {
xDet.SetX(-Geometry::ZPDIMENSION[0] + 0.01);
}
float xTow = 2. * xDet.X() / (Geometry::ZPDIMENSION[0]);
for (int i = 1; i <= 4; i++) {
if (xTow >= (i - 3) && xTow < (i - 2)) {
sector = i;
break;
}
}
return;
} else if (volname.BeginsWith("ZE")) {
// electromagnetic calorimeter
detector = ZEM;
xDet = x - math_utils::Vector3D<float>(Geometry::ZEMPOSITION[0], Geometry::ZEMPOSITION[1], Geometry::ZEMPOSITION[2]);
sector = (x.X() > 0.) ? Ch1 : Ch2;
return;
}
assert(false);
}
//_____________________________________________________________________________
void Detector::resetHitIndices()
{
// reinit hit buffer to null (because we make new hits for each principal track)
for (int det = 0; det < NUMDETS; ++det) {
for (int sec = 0; sec < NUMSECS; ++sec) {
mCurrentHitsIndices[det][sec] = -1;
}
}
// Summed variables are set to 0
mTotLightPMC = 0;
mTotLightPMQ = 0;
}
void Detector::flushSpatialResponse()
{
if (o2::zdc::ZDCSimParam::Instance().recordSpatialResponse) {
auto c = mNeutronResponseImage.getPhotonsPerChannel();
std::fstream output("o2sim-FullSimResult", std::fstream::out | std::fstream::app);
output << c[0] << " " << c[1] << " " << c[2] << " " << c[3] << " " << c[4] << "\n";
output.close();
// only write non-trivial image pairs
if (mNeutronResponseImage.getPhotonSum() > 0 || mProtonResponseImage.getPhotonSum() > 0) {
mResponses.push_back(std::make_pair(mCurrentPrincipalParticle,
std::make_pair(mNeutronResponseImage, mProtonResponseImage)));
}
mNeutronResponseImage.reset();
mProtonResponseImage.reset();
}
}
// quick estimates the time of flight to reach this detector (located at z)
// just based on primary particle properties
// Meant for the neutron / proton detectors which sit a large z so that speed
// is essentially the speed in z-direction.
double estimateTimeOfFlight(TParticle const& part, double z /* needs to be in meters */)
{
const auto m = part.GetMass();
constexpr auto SPEED_OF_LIGHT = 299792458.; // m/s
if (m == 0.) {
return z / SPEED_OF_LIGHT;
} else {
TLorentzVector lorentz; // could be made member var
part.Momentum(lorentz);
const auto gamma = lorentz.Gamma();
const auto speed = SPEED_OF_LIGHT * std::sqrt(1. - 1. / (gamma * gamma));
return z / speed; // could refine this
}
}
//_____________________________________________________________________________
Bool_t Detector::ProcessHits(FairVolume* v)
{
// Method called from MC stepping for the sensitive volumes
TString volname = fMC->CurrentVolName();
float x[3] = {0., 0., 0.};
fMC->TrackPosition(x[0], x[1], x[2]);
// determine detectorID and sectorID
int detector = -1;
int sector = -1;
math_utils::Vector3D<float> xImp;
getDetIDandSecID(volname, math_utils::Vector3D<float>(x[0], x[1], x[2]), xImp, detector, sector);
auto stack = (o2::data::Stack*)fMC->GetStack();
int trackn = stack->GetCurrentTrackNumber();
// find out if we are entering into the detector NEU or PRO for the first time
int volID, copy;
volID = fMC->CurrentVolID(copy);
//printf("\t ---> track %d in vol. %d %d (volID %d) mother %d \n",
//trackn, detector, sector, volID, stack->GetCurrentTrack()->GetMother(0));
// If the particle is in a ZN or ZP fiber connected to the common PMT
// then the assigned sector is 0 (PMC) NB-> does not work for ZEM
if ((fMC->CurrentMedium() == mMediumPMCid) && (detector != ZEM)) {
sector = 0;
}
//printf("ProcessHits: x=(%f, %f, %f) \n",x[0], x[1], x[2]);
//printf("\tDET %d SEC %d -> XImpact=(%f, %f, %f)\n",detector,sector, xImp.X(), xImp.Y(), xImp.Z());
if ((volID == mZNENVVolID || volID == mZPENVVolID || volID == mZEMVolID)) {
// there is nothing more to do here as we are not
// in the fiber volumes
return false;
}
float p[3] = {0., 0., 0.};
float trackenergy = 0.;
fMC->TrackMomentum(p[0], p[1], p[2], trackenergy);
float eDep = fMC->Edep();
int pdgCode = fMC->TrackPid();
float lightoutput = 0.;
auto currentMediumid = fMC->CurrentMedium();
int nphe = 0;
if (((currentMediumid == mMediumPMCid) || (currentMediumid == mMediumPMQid))) {
if (eDep) {
int ibeta = 0, iangle = 0, iradius = 0;
Bool_t isLightProduced = calculateTableIndexes(ibeta, iangle, iradius);
if (isLightProduced) {
int charge = 0;
if (pdgCode < 10000) {
charge = fMC->TrackCharge();
} else {
charge = TMath::Abs(pdgCode / 10000 - 100000);
}
//look into the light tables if the particle is charged
if (TMath::Abs(charge) > 0) {
if (detector == 1 || detector == 4) {
iradius = std::min((int)Geometry::ZNFIBREDIAMETER, iradius);
lightoutput = charge * charge * mLightTableZN[ibeta][iangle][iradius];
//printf(" \t ZNtableEntry[%d %d %d] = %1.5f -> lightoutput %f\n", ibeta, iangle, iradius, mLightTableZN[ibeta][iangle][iradius], lightoutput);
} else {
iradius = std::min((int)Geometry::ZPFIBREDIAMETER, iradius);
lightoutput = charge * charge * mLightTableZP[ibeta][iangle][iradius];
//printf(" \t ZPtableEntry[%d %d %d] = %1.5f -> lightoutput %f\n", ibeta, iangle, iradius, mLightTableZP[ibeta][iangle][iradius], lightoutput);
}
if (lightoutput > 0) {
nphe = gRandom->Poisson(lightoutput);
//printf(" \t\t-> nphe %d \n", nphe);
}
}
}
}
}
auto tof = 1.e09 * fMC->TrackTime(); //TOF in ns
if (o2::zdc::ZDCSimParam::Instance().recordSpatialResponse) {
// some diagnostic; trying to really get the pixel fired
if (nphe > 0) {
if (detector == ZNA || detector == ZNC) {
mNeutronResponseImage.setDetectorID(detector);
mNeutronResponseImage.addPhoton(x[0], x[1], nphe);
mNeutronResponseImage.setHitTime(tof);
}
if (detector == ZPA || detector == ZPC) {
mProtonResponseImage.setDetectorID(detector);
mProtonResponseImage.addPhoton(x[0], x[1], nphe);
mProtonResponseImage.setHitTime(tof);
}
}
}
// A new hit is created when there is nothing yet for this det + sector
if (mCurrentHitsIndices[detector - 1][sector] == -1) {
bool issecondary = trackn != stack->getCurrentPrimaryIndex();
//if(!issecondary) printf(" !!! primary track (index %d)\n",stack->getCurrentPrimaryIndex());
mTotLightPMC = mTotLightPMQ = 0;
if (currentMediumid == mMediumPMCid) {
mTotLightPMC = nphe;
} else if (currentMediumid == mMediumPMQid) {
mTotLightPMQ = nphe;
}
math_utils::Vector3D<float> pos(x[0], x[1], x[2]);
math_utils::Vector3D<float> mom(p[0], p[1], p[2]);
addHit(trackn, mLastPrincipalTrackEntered, issecondary, trackenergy, detector, sector,
pos, mom, tof, xImp, eDep, mTotLightPMC, mTotLightPMQ);
stack->addHit(GetDetId());
mCurrentHitsIndices[detector - 1][sector] = mHits->size() - 1;
mXImpact = xImp;
//printf("### NEW HIT CREATED in vol %d %d for track %d (mother: %d) \t light %1.0f %1.0f\n",
//detector, sector, trackn, stack->GetCurrentTrack()->GetFirstMother(), mTotLightPMC, mTotLightPMQ);
return true;
} else {
auto& curHit = (*mHits)[mCurrentHitsIndices[detector - 1][sector]];
// summing variables that needs to be updated (Eloss and light yield)
curHit.setNoNumContributingSteps(curHit.getNumContributingSteps() + 1);
int nPMC{0}, nPMQ{0};
if (currentMediumid == mMediumPMCid) {
mTotLightPMC += nphe;
nPMC = nphe;
} else if (currentMediumid == mMediumPMQid) {
mTotLightPMQ += nphe;
nPMQ = nphe;
}
float incenloss = curHit.GetEnergyLoss() + eDep;
if (nphe > 0) {
curHit.SetEnergyLoss(incenloss);
curHit.setPMCLightYield(curHit.getPMCLightYield() + nPMC);
curHit.setPMQLightYield(curHit.getPMQLightYield() + nPMQ);
//printf(" >>> Hit updated in vol %d %d for track %d (mother: %d) \t light %1.0f %1.0f \n",
//detector, sector, trackn, stack->GetCurrentTrack()->GetFirstMother(), curHit.getPMCLightYield(), curHit.getPMQLightYield());
}
return true;
}
return false;
}
// function to create hit structure from a SpatialResponseImage
// idea is to use this from a fast sim generating the response
bool Detector::createHitsFromImage(SpatialPhotonResponse const& image, int detector)
{
// one image will make one hit per sector
math_utils::Vector3D<float> xImp(0., 0., 0.); // good value
const int Nx = image.getNx();
const int Ny = image.getNy();
const auto& pixels = image.getImageData();
// could be put inside the image class
auto determineSectorID = [Nx, Ny](int detector, int x, int y) {
if (detector == ZNA || detector == ZNC) {
if ((x + y) % 2 == 0) {
return (int)Common;
}
if (x < Nx / 2) {
if (y < Ny / 2) {
return (int)Ch1;
} else {
return (int)Ch3;
}
} else {
if (y >= Ny / 2) {
return (int)Ch4;
} else {
return (int)Ch2;
}
}
}
if (detector == ZPA || detector == ZPC) {
if ((x + y) % 2 == 0) {
return (int)Common;
}
auto i = (int)(4.f * x / Nx);
return (int)(i + 1);
}
return -1;
};
auto determineMediumID = [this](int detector, int x, int y) {
// it is a simple checkerboard pattern
return ((x + y) % 2 == 0) ? mMediumPMCid : mMediumPMQid;
};
// loop over x = columns
for (int x = 0; x < Nx; ++x) {
// loop over y = rows
for (int y = 0; y < Ny; ++y) {
// get sector
int sector = determineSectorID(detector, x, y);
// get medium PMQ and PMC
int currentMediumid = determineMediumID(detector, x, y);
// LOG(info) << " x " << x << " y " << y << " sec " << sector << " medium " << currentMediumid;
int nphe = pixels[x][y];
float tof = 0.; // needs to be in nanoseconds ---> to be filled later on (should be meta-data of image or calculated otherwise)
float trackenergy = 0; // energy of the primary (need to fill good value)
createOrAddHit(detector,
sector,
currentMediumid,
0 /*issecondary ---> don't know in fast sim */,
nphe,
0 /* trackn */,
0 /* parent */,
tof,
trackenergy,
xImp,
0. /* eDep */, 0 /* x */, 0. /* y */, 0. /* z */, 0. /* px */, 0. /* py */, 0. /* pz */);
} // end loop over y
} // end loop over x
return true;
} // end function
//_____________________________________________________________________________
o2::zdc::Hit* Detector::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)
{
LOG(debug4) << "Adding hit for track " << trackID << " X (" << pos.X() << ", " << pos.Y() << ", "
<< pos.Z() << ") P (" << mom.X() << ", " << mom.Y() << ", " << mom.Z() << ") Ekin "
<< primaryEnergy << " lightPMC " << nphePMC << " lightPMQ " << nphePMQ << std::endl;
mHits->emplace_back(trackID, parentID, sFlag, primaryEnergy, detID, secID, pos, mom,
tof, xImpact, energyloss, nphePMC, nphePMQ);
return &(mHits->back());
}
//_____________________________________________________________________________
void Detector::createMaterials()
{
int32_t ifield = 2;
float fieldm = 10.0;
o2::base::Detector::initFieldTrackingParams(ifield, fieldm);
LOG(info) << "Detector::CreateMaterials >>>>> magnetic field: type " << ifield << " max " << fieldm << "\n";
// ******** MATERIAL DEFINITION ********
// --- W alloy -> ZN passive material
float aW[3] = {183.85, 55.85, 58.71};
float zW[3] = {74., 26., 28.};
float wW[3] = {0.93, 0.03, 0.04};
float dW = 17.6;
// --- Brass (CuZn) -> ZP passive material
float aCuZn[2] = {63.546, 65.39};
float zCuZn[2] = {29., 30.};
float wCuZn[2] = {0.63, 0.37};
float dCuZn = 8.48;
// --- SiO2 -> fibres
float aq[2] = {28.0855, 15.9994};
float zq[2] = {14., 8.};
float wq[2] = {1., 2.};
float dq = 2.64;
// --- Lead -> ZEM passive material
float aPb = 207.2;
float zPb = 82.;
float dPb = 11.35;
float radPb = 6.37 / dPb;
float absPb = 199.6 / dPb;
// --- Copper -> beam pipe
float aCu = 63.546;
float zCu = 29.;
float dCu = 8.96;
float radCu = 12.86 / dCu;
float absCu = 137.3 / dCu;
// int32_t nCu = 1.10;
// --- Iron -> beam pipe
float aFe = 55.845;
float zFe = 26.;
float dFe = 7.874;
float radFe = 13.84 / dFe;
float absFe = 132.1 / dFe;
// --- Aluminum -> beam pipe
float aAl = 26.98;
float zAl = 13.;
float dAl = 2.699;
float radAl = 24.01 / dAl;
float absAl = 107.2 / dAl;
// --- Carbon -> beam pipe
float aCarb = 12.01;
float zCarb = 6.;
float dCarb = 2.265;
float radCarb = 18.8;
float absCarb = 49.9;
// --- Residual gas -> inside beam pipe
float aResGas[3] = {1.008, 12.0107, 15.9994};
float zResGas[3] = {1., 6., 8.};
float wResGas[3] = {0.28, 0.28, 0.44};
float dResGas = 3.2E-14;
// --- Air
float aAir[4] = {12.0107, 14.0067, 15.9994, 39.948};
float zAir[4] = {6., 7., 8., 18.};
float wAir[4] = {0.000124, 0.755267, 0.231781, 0.012827};
float dAir = 1.20479E-3;
// ******** TRACKING MEDIA PARAMETERS ********
int32_t notactiveMed = 0, sensMed = 1; // sensitive or not sensitive medium
// field integration 0 no field -1 user in guswim 1 Runge Kutta 2 helix 3 const field along z
int32_t inofld = 0; // Max. field value (no field)
int32_t ifld = 2; //TODO: ????CHECK!!!! secondo me va -1!!!!!
float nofieldm = 0.;
float maxnofld = 0.; // max field value (no field)
float maxfld = 45.; // max field value (with field)
float tmaxnofd = 0.; // max deflection angle due to magnetic field in one step
float tmaxfd = 0.1; // max deflection angle due to magnetic field in one step
float deemax = -1.; // maximum fractional energy loss in one step 0<deemax<=1
float epsil = 0.001; // tracking precision [cm]
float stemax = 1.; // max step allowed [cm] ????CHECK!!!!
float stmin = 0.01; // minimum step due to continuous processes [cm] (negative value: choose it automatically) ????CHECK!!!! 0.01 in aliroot
// ******** MATERIAL DEFINITION ********
Mixture(0, "Walloy$", aW, zW, dW, 3, wW);
Mixture(1, "CuZn$", aCuZn, zCuZn, dCuZn, 2, wCuZn);
Mixture(2, "SiO2$", aq, zq, dq, -2, wq);
Material(3, "Pb $", aPb, zPb, dPb, radPb, absPb);
Material(4, "Cu $", aCu, zCu, dCu, radCu, absCu);
Material(5, "Fe $", aFe, zFe, dFe, radFe, absFe);
Material(6, "Al $", aAl, zAl, dAl, radAl, absAl);
Material(7, "graphite$", aCarb, zCarb, dCarb, radCarb, absCarb);
Mixture(8, "residualGas$", aResGas, zResGas, dResGas, 3, wResGas);
Mixture(9, "Air$", aAir, zAir, dAir, 4, wAir);
// ******** MEDIUM DEFINITION ********
Medium(kWalloy, "Walloy$", 0, notactiveMed, inofld, nofieldm, tmaxnofd, stemax, deemax, epsil, stmin);
Medium(kCuZn, "CuZn$", 1, notactiveMed, inofld, nofieldm, tmaxnofd, stemax, deemax, epsil, stmin);
Medium(kSiO2pmc, "quartzPMC$", 2, sensMed, inofld, nofieldm, tmaxnofd, stemax, deemax, epsil, stmin);
Medium(kSiO2pmq, "quartzPMQ$", 2, sensMed, inofld, nofieldm, tmaxnofd, stemax, deemax, epsil, stmin);
Medium(kPb, "Lead$", 3, notactiveMed, inofld, nofieldm, tmaxnofd, stemax, deemax, epsil, stmin);
Medium(kCu, "Copper$", 4, notactiveMed, inofld, nofieldm, tmaxnofd, stemax, deemax, epsil, stmin);
Medium(kCuLumi, "CopperLowTh$", 4, notactiveMed, inofld, nofieldm, tmaxnofd, stemax, deemax, epsil, stmin);
Medium(kFe, "Iron$", 5, notactiveMed, inofld, nofieldm, tmaxnofd, stemax, deemax, epsil, stmin);
Medium(kFeLowTh, "IronLowTh$", 5, notactiveMed, inofld, nofieldm, tmaxnofd, stemax, deemax, epsil, stmin);
Medium(kAl, "Aluminum$", 6, notactiveMed, inofld, nofieldm, tmaxnofd, stemax, deemax, epsil, stmin);
Medium(kGraphite, "Graphite$", 7, notactiveMed, inofld, nofieldm, tmaxnofd, stemax, deemax, epsil, stmin);
Medium(kVoidNoField, "VoidNoField$", 8, notactiveMed, inofld, nofieldm, tmaxnofd, stemax, deemax, epsil, stmin);
Medium(kVoidwField, "VoidwField$", 8, notactiveMed, ifld, maxfld, tmaxfd, stemax, deemax, epsil, stmin);
Medium(kAir, "Air$", 9, notactiveMed, inofld, nofieldm, tmaxnofd, stemax, deemax, epsil, stmin);
}
//_____________________________________________________________________________
void Detector::createAsideBeamLine()
{
double tubpar[3] = {0., 0., 0};
float boxpar[3] = {0., 0., 0};
double tubspar[5] = {0., 0., 0., 0., 0.};
double conpar[15] = {0.}; // all elements will be 0
float zA = 1910.4;
conpar[0] = 0.;
conpar[1] = 360.;
conpar[2] = 2.;
conpar[3] = zA;
conpar[4] = 0.;
conpar[5] = 55.;
conpar[6] = 13500.;
conpar[7] = 0.;
conpar[8] = 55.;
TVirtualMC::GetMC()->Gsvolu("ZDCA", "PCON", getMediumID(kVoidNoField), conpar, 9);
TVirtualMC::GetMC()->Gspos("ZDCA", 1, "cave", 0., 0., 0., 0, "ONLY");
// BEAM PIPE from 19.10 m to inner triplet beginning (22.965 m)
tubpar[0] = 6.0 / 2.;
tubpar[1] = 6.4 / 2.;
tubpar[2] = (386.28 - 0.18) / 2.;
TVirtualMC::GetMC()->Gsvolu("QA01", "TUBE", getMediumID(kFe), tubpar, 3);
TVirtualMC::GetMC()->Gspos("QA01", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
zA += 2. * tubpar[2];
// -- FIRST SECTION OF THE BEAM PIPE (from beginning of inner triplet to beginning of D1)
tubpar[0] = 6.3 / 2.;
tubpar[1] = 6.7 / 2.;
tubpar[2] = 3541.8 / 2.;
TVirtualMC::GetMC()->Gsvolu("QA02", "TUBE", getMediumID(kFe), tubpar, 3);
TVirtualMC::GetMC()->Gspos("QA02", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
zA += 2. * tubpar[2];
// -- SECOND SECTION OF THE BEAM PIPE (from the beginning of D1 to the beginning of D2)
// FROM (MAGNETIC) BEGINNING OF D1 TO THE (MAGNETIC) END OF D1 + 126.5 cm
// CYLINDRICAL PIPE of diameter increasing from 6.75 cm up to 8.0 cm
// from magnetic end :
// 1) 80.1 cm still with ID = 6.75 radial beam screen
// 2) 2.5 cm conical section from ID = 6.75 to ID = 8.0 cm
// 3) 43.9 cm straight section (tube) with ID = 8.0 cm
tubpar[0] = 6.75 / 2.;
tubpar[1] = 7.15 / 2.;
tubpar[2] = (945.0 + 80.1) / 2.;
TVirtualMC::GetMC()->Gsvolu("QA03", "TUBE", getMediumID(kFe), tubpar, 3);
TVirtualMC::GetMC()->Gspos("QA03", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
zA += 2. * tubpar[2];
// Transition Cone from ID=67.5 mm to ID=80 mm
conpar[0] = 2.5 / 2.;
conpar[1] = 6.75 / 2.;
conpar[2] = 7.15 / 2.;
conpar[3] = 8.0 / 2.;
conpar[4] = 8.4 / 2.;
TVirtualMC::GetMC()->Gsvolu("QA04", "CONE", getMediumID(kFe), conpar, 5);
TVirtualMC::GetMC()->Gspos("QA04", 1, "ZDCA", 0., 0., conpar[0] + zA, 0, "ONLY");
zA += 2. * conpar[0];
tubpar[0] = 8.0 / 2.;
tubpar[1] = 8.4 / 2.;
tubpar[2] = (43.9 + 20. + 28.5 + 28.5) / 2.;
TVirtualMC::GetMC()->Gsvolu("QA05", "TUBE", getMediumID(kFe), tubpar, 3);
TVirtualMC::GetMC()->Gspos("QA05", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
zA += 2. * tubpar[2];
// Second section of VAEHI (transition cone from ID=80mm to ID=98mm)
conpar[0] = 4.0 / 2.;
conpar[1] = 8.0 / 2.;
conpar[2] = 8.4 / 2.;
conpar[3] = 9.8 / 2.;
conpar[4] = 10.2 / 2.;
TVirtualMC::GetMC()->Gsvolu("QAV1", "CONE", getMediumID(kFe), conpar, 5);
TVirtualMC::GetMC()->Gspos("QAV1", 1, "ZDCA", 0., 0., conpar[0] + zA, 0, "ONLY");
zA += 2. * conpar[0];
//Third section of VAEHI (transition cone from ID=98mm to ID=90mm)
conpar[0] = 1.0 / 2.;
conpar[1] = 9.8 / 2.;
conpar[2] = 10.2 / 2.;
conpar[3] = 9.0 / 2.;
conpar[4] = 9.4 / 2.;
TVirtualMC::GetMC()->Gsvolu("QAV2", "CONE", getMediumID(kFe), conpar, 5);
TVirtualMC::GetMC()->Gspos("QAV2", 1, "ZDCA", 0., 0., conpar[0] + zA, 0, "ONLY");
zA += 2. * conpar[0];
// Fourth section of VAEHI (tube ID=90mm)
tubpar[0] = 9.0 / 2.;
tubpar[1] = 9.4 / 2.;
tubpar[2] = 31.0 / 2.;
TVirtualMC::GetMC()->Gsvolu("QAV3", "TUBE", getMediumID(kFe), tubpar, 3);
TVirtualMC::GetMC()->Gspos("QAV3", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
zA += 2. * tubpar[2];
//---------------------------- TCDD beginning ----------------------------------
// space for the insertion of the collimator TCDD (2 m)
// TCDD ZONE - 1st volume
conpar[0] = 1.3 / 2.;
conpar[1] = 9.0 / 2.;
conpar[2] = 13.0 / 2.;
conpar[3] = 9.6 / 2.;
conpar[4] = 13.0 / 2.;
TVirtualMC::GetMC()->Gsvolu("Q01T", "CONE", getMediumID(kFe), conpar, 5);
TVirtualMC::GetMC()->Gspos("Q01T", 1, "ZDCA", 0., 0., conpar[0] + zA, 0, "ONLY");
zA += 2. * conpar[0];
// TCDD ZONE - 2nd volume
tubpar[0] = 9.6 / 2.;
tubpar[1] = 10.0 / 2.;
tubpar[2] = 1.0 / 2.;
TVirtualMC::GetMC()->Gsvolu("Q02T", "TUBE", getMediumID(kFe), tubpar, 3);
TVirtualMC::GetMC()->Gspos("Q02T", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
zA += 2. * tubpar[2];
// TCDD ZONE - third volume
conpar[0] = 9.04 / 2.;
conpar[1] = 9.6 / 2.;
conpar[2] = 10.0 / 2.;
conpar[3] = 13.8 / 2.;
conpar[4] = 14.2 / 2.;
TVirtualMC::GetMC()->Gsvolu("Q03T", "CONE", getMediumID(kFe), conpar, 5);
TVirtualMC::GetMC()->Gspos("Q03T", 1, "ZDCA", 0., 0., conpar[0] + zA, 0, "ONLY");
zA += 2. * conpar[0];
// TCDD ZONE - 4th volume
tubpar[0] = 13.8 / 2.;
tubpar[1] = 14.2 / 2.;
tubpar[2] = 38.6 / 2.;
TVirtualMC::GetMC()->Gsvolu("Q04T", "TUBE", getMediumID(kFe), tubpar, 3);
TVirtualMC::GetMC()->Gspos("Q04T", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
zA += 2. * tubpar[2];
// TCDD ZONE - 5th volume
tubpar[0] = 21.0 / 2.;
tubpar[1] = 21.4 / 2.;
tubpar[2] = 100.12 / 2.;
TVirtualMC::GetMC()->Gsvolu("Q05T", "TUBE", getMediumID(kFe), tubpar, 3);
TVirtualMC::GetMC()->Gspos("Q05T", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
zA += 2. * tubpar[2];
// TCDD ZONE - 6th volume
tubpar[0] = 13.8 / 2.;
tubpar[1] = 14.2 / 2.;
tubpar[2] = 38.6 / 2.;
TVirtualMC::GetMC()->Gsvolu("Q06T", "TUBE", getMediumID(kFe), tubpar, 3);
TVirtualMC::GetMC()->Gspos("Q06T", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
zA += 2. * tubpar[2];
// TCDD ZONE - 7th volume
conpar[0] = 11.34 / 2.;
conpar[1] = 13.8 / 2.;
conpar[2] = 14.2 / 2.;
conpar[3] = 18.0 / 2.;
conpar[4] = 18.4 / 2.;
TVirtualMC::GetMC()->Gsvolu("Q07T", "CONE", getMediumID(kFe), conpar, 5);
TVirtualMC::GetMC()->Gspos("Q07T", 1, "ZDCA", 0., 0., conpar[0] + zA, 0, "ONLY");
zA += 2. * conpar[0];
// Upper section : one single phi segment of a tube
// 5 parameters for tubs: inner radius = 0.,
// outer radius = 7. cm, half length = 50 cm
// phi1 = 0., phi2 = 180.
tubspar[0] = 0.0 / 2.;
tubspar[1] = 14.0 / 2.;
tubspar[2] = 100.0 / 2.;
tubspar[3] = 0.;
tubspar[4] = 180.;
TVirtualMC::GetMC()->Gsvolu("Q08T", "TUBS", getMediumID(kFe), tubspar, 5);
// rectangular beam pipe inside TCDD upper section (Vacuum)
boxpar[0] = 7.0 / 2.;
boxpar[1] = 2.2 / 2.;
boxpar[2] = 100. / 2.;
TVirtualMC::GetMC()->Gsvolu("Q09T", "BOX ", getMediumID(kVoidNoField), boxpar, 3);
// positioning vacuum box in the upper section of TCDD
TVirtualMC::GetMC()->Gspos("Q09T", 1, "Q08T", 0., 1.1, 0., 0, "ONLY");
// lower section : one single phi segment of a tube
tubspar[0] = 0.0 / 2.;
tubspar[1] = 14.0 / 2.;
tubspar[2] = 100.0 / 2.;
tubspar[3] = 180.;
tubspar[4] = 360.;
TVirtualMC::GetMC()->Gsvolu("Q10T", "TUBS", getMediumID(kFe), tubspar, 5);
// rectangular beam pipe inside TCDD lower section (Vacuum)
boxpar[0] = 7.0 / 2.;
boxpar[1] = 2.2 / 2.;
boxpar[2] = 100. / 2.;
TVirtualMC::GetMC()->Gsvolu("Q11T", "BOX ", getMediumID(kVoidNoField), boxpar, 3);
// positioning vacuum box in the lower section of TCDD
TVirtualMC::GetMC()->Gspos("Q11T", 1, "Q10T", 0., -1.1, 0., 0, "ONLY");
// positioning TCDD elements in ZDCA, (inside TCDD volume)
// TODO: think about making those parameters tunable/settable from outside
double TCDDAperturePos = 2.2;
double TCDDApertureNeg = 2.4;
TVirtualMC::GetMC()->Gspos("Q08T", 1, "ZDCA", 0., TCDDAperturePos, -100. + zA, 0, "ONLY");
TVirtualMC::GetMC()->Gspos("Q10T", 1, "ZDCA", 0., -TCDDApertureNeg, -100. + zA, 0, "ONLY");
// RF screen
boxpar[0] = 0.2 / 2.;
boxpar[1] = 4.0 / 2.;
boxpar[2] = 100. / 2.;
TVirtualMC::GetMC()->Gsvolu("Q12T", "BOX ", getMediumID(kFe), boxpar, 3);
// positioning RF screen at both sides of TCDD
TVirtualMC::GetMC()->Gspos("Q12T", 1, "ZDCA", tubspar[1] + boxpar[0], 0., -100. + zA, 0, "ONLY");
TVirtualMC::GetMC()->Gspos("Q12T", 2, "ZDCA", -tubspar[1] - boxpar[0], 0., -100. + zA, 0, "ONLY");
//---------------------------- TCDD end ---------------------------------------
// The following elliptical tube 180 mm x 70 mm (obtained positioning the void QA06 in QA07)
// represents VAMTF + first part of VCTCP (93 mm)
tubpar[0] = 18.4 / 2.;
tubpar[1] = 7.4 / 2.;
tubpar[2] = (78 + 9.3) / 2.;
TVirtualMC::GetMC()->Gsvolu("QA06", "ELTU", getMediumID(kFe), tubpar, 3);
// AliRoot: temporary replace with a scaled tube (AG) ????????????
/*TGeoTube *tubeQA06 = new TGeoTube(0.,tubpar[0],tubpar[2]);
TGeoScale *scaleQA06 = new TGeoScale(1., tubpar[1]/tubpar[0], 1.);
TGeoScaledShape *sshapeQA06 = new TGeoScaledShape(tubeQA06, scaleQA06);
new TGeoVolume("QA06", sshapeQA06, gGeoManager->GetMedium(getMediumID(kVoidNoField)));*/
tubpar[0] = 18.0 / 2.;
tubpar[1] = 7.0 / 2.;
tubpar[2] = (78 + 9.3) / 2.;
TVirtualMC::GetMC()->Gsvolu("QA07", "ELTU", getMediumID(kVoidNoField), tubpar, 3);
// temporary replace with a scaled tube (AG) ????????????
/*TGeoTube *tubeQA07 = new TGeoTube(0.,tubpar[0],tubpar[2]);
TGeoScale *scaleQA07 = new TGeoScale(1., tubpar[1]/tubpar[0], 1.);
TGeoScaledShape *sshapeQA07 = new TGeoScaledShape(tubeQA07, scaleQA07);
new TGeoVolume("QA07", sshapeQA07, gGeoManager->GetMedium(getMediumID(k10]));*/
TVirtualMC::GetMC()->Gspos("QA06", 1, "ZDCA", 0., 0., tubpar[2] + zA, 0, "ONLY");
TVirtualMC::GetMC()->Gspos("QA07", 1, "QA06", 0., 0., 0., 0, "ONLY");
zA += 2. * tubpar[2];
// VCTCP second part: transition cone from ID=180 to ID=212.7
conpar[0] = 31.5 / 2.;
conpar[1] = 18.0 / 2.;
conpar[2] = 18.6 / 2.;
conpar[3] = 21.27 / 2.;
conpar[4] = 21.87 / 2.;
TVirtualMC::GetMC()->Gsvolu("QA08", "CONE", getMediumID(kFe), conpar, 5);