forked from AliceO2Group/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeometry.cxx
More file actions
1920 lines (1686 loc) · 66.2 KB
/
Geometry.cxx
File metadata and controls
1920 lines (1686 loc) · 66.2 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.
#include "EMCALBase/Geometry.h"
#include <RtypesCore.h>
#include <TMath.h>
#include <TVector3.h>
#include <TMathBase.h>
#include <TVector2.h>
#include <TParticle.h>
#include <TString.h>
#include <TGeoNode.h>
#include <TJAlienCredentials.h>
#include <TObjArray.h>
#include <fairlogger/Logger.h>
#include <cstring>
#include <cctype>
#include <cmath>
#include <iomanip>
#include <ostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <string_view>
#include <tuple>
#include <TGeoBBox.h>
#include <TGeoManager.h>
#include <TGeoMatrix.h>
#include "DataFormatsEMCAL/Constants.h"
#include "EMCALBase/GeometryBase.h"
#include "CCDB/CcdbApi.h"
#include "EMCALBase/ShishKebabTrd1Module.h"
#include "GPUROOTCartesianFwd.h"
#include <boost/algorithm/string/predicate.hpp>
using namespace o2::emcal;
// these initialisations are needed for a singleton
Geometry* Geometry::sGeom = nullptr;
Geometry::Geometry(const Geometry& geo)
: mGeoName(geo.mGeoName),
mKey110DEG(geo.mKey110DEG),
mnSupModInDCAL(geo.mnSupModInDCAL),
mNCellsInSupMod(geo.mNCellsInSupMod),
mNETAdiv(geo.mNETAdiv),
mNPHIdiv(geo.mNPHIdiv),
mNCellsInModule(geo.mNCellsInModule),
mPhiBoundariesOfSM(geo.mPhiBoundariesOfSM),
mPhiCentersOfSM(geo.mPhiCentersOfSM),
mPhiCentersOfSMSec(geo.mPhiCentersOfSMSec),
mPhiCentersOfCells(geo.mPhiCentersOfCells),
mCentersOfCellsEtaDir(geo.mCentersOfCellsEtaDir),
mCentersOfCellsPhiDir(geo.mCentersOfCellsPhiDir),
mEtaCentersOfCells(geo.mEtaCentersOfCells),
mNCells(geo.mNCells),
mNPhi(geo.mNPhi),
mCentersOfCellsXDir(geo.mCentersOfCellsXDir),
mArm1EtaMin(geo.mArm1EtaMin),
mArm1EtaMax(geo.mArm1EtaMax),
mArm1PhiMin(geo.mArm1PhiMin),
mArm1PhiMax(geo.mArm1PhiMax),
mEtaMaxOfTRD1(geo.mEtaMaxOfTRD1),
mDCALPhiMin(geo.mDCALPhiMin),
mDCALPhiMax(geo.mDCALPhiMax),
mEMCALPhiMax(geo.mEMCALPhiMax),
mDCALStandardPhiMax(geo.mDCALStandardPhiMax),
mDCALInnerExtandedEta(geo.mDCALInnerExtandedEta),
mDCALInnerEdge(geo.mDCALInnerEdge),
mShishKebabTrd1Modules(geo.mShishKebabTrd1Modules),
mPhiModuleSize(geo.mPhiModuleSize),
mEtaModuleSize(geo.mEtaModuleSize),
mPhiTileSize(geo.mPhiTileSize),
mEtaTileSize(geo.mEtaTileSize),
mNZ(geo.mNZ),
mIPDistance(geo.mIPDistance),
mLongModuleSize(geo.mLongModuleSize),
mShellThickness(geo.mShellThickness),
mZLength(geo.mZLength),
mSampling(geo.mSampling),
mECPbRadThickness(geo.mECPbRadThickness),
mECScintThick(geo.mECScintThick),
mNECLayers(geo.mNECLayers),
mNumberOfSuperModules(geo.mNumberOfSuperModules),
mEMCSMSystem(geo.mEMCSMSystem),
mFrontSteelStrip(geo.mFrontSteelStrip),
mLateralSteelStrip(geo.mLateralSteelStrip),
mPassiveScintThick(geo.mPassiveScintThick),
mPhiSuperModule(geo.mPhiSuperModule),
mNPhiSuperModule(geo.mNPhiSuperModule),
mTrd1Angle(geo.mTrd1Angle),
m2Trd1Dx2(geo.m2Trd1Dx2),
mPhiGapForSM(geo.mPhiGapForSM),
mTrd1AlFrontThick(geo.mTrd1AlFrontThick),
mTrd1BondPaperThick(geo.mTrd1BondPaperThick),
mILOSS(geo.mILOSS),
mIHADR(geo.mIHADR),
mSteelFrontThick(geo.mSteelFrontThick), // obsolete data member?
mCellIndexLookup(geo.mCellIndexLookup)
{
memcpy(mEnvelop, geo.mEnvelop, sizeof(Float_t) * 3);
memcpy(mParSM, geo.mParSM, sizeof(Float_t) * 3);
memset(SMODULEMATRIX, 0, sizeof(TGeoHMatrix*) * EMCAL_MODULES);
}
Geometry::Geometry(const std::string_view name, const std::string_view mcname, const std::string_view mctitle)
: mGeoName(name),
mKey110DEG(0),
mnSupModInDCAL(0),
mNCellsInSupMod(0),
mNETAdiv(0),
mNPHIdiv(0),
mNCellsInModule(0),
mPhiBoundariesOfSM(),
mPhiCentersOfSM(),
mPhiCentersOfSMSec(),
mPhiCentersOfCells(),
mCentersOfCellsEtaDir(),
mCentersOfCellsPhiDir(),
mEtaCentersOfCells(),
mNCells(0),
mNPhi(0),
mCentersOfCellsXDir(),
mArm1EtaMin(0),
mArm1EtaMax(0),
mArm1PhiMin(0),
mArm1PhiMax(0),
mEtaMaxOfTRD1(0),
mDCALPhiMin(0),
mDCALPhiMax(0),
mEMCALPhiMax(0),
mDCALStandardPhiMax(0),
mDCALInnerExtandedEta(0),
mDCALInnerEdge(0.),
mShishKebabTrd1Modules(),
mPhiModuleSize(0.),
mEtaModuleSize(0.),
mPhiTileSize(0.),
mEtaTileSize(0.),
mNZ(0),
mIPDistance(0.),
mLongModuleSize(0.),
mShellThickness(0.),
mZLength(0.),
mSampling(0.),
mECPbRadThickness(0.),
mECScintThick(0.),
mNECLayers(0),
mNumberOfSuperModules(0),
mEMCSMSystem(),
mFrontSteelStrip(0.),
mLateralSteelStrip(0.),
mPassiveScintThick(0.),
mPhiSuperModule(0),
mNPhiSuperModule(0),
mTrd1Angle(0.),
m2Trd1Dx2(0.),
mPhiGapForSM(0.),
mTrd1AlFrontThick(0.0),
mTrd1BondPaperThick(0.),
mILOSS(-1),
mIHADR(-1),
mSteelFrontThick(0.) // obsolete data member?
{
DefineEMC(mcname, mctitle);
mNCellsInModule = mNPHIdiv * mNETAdiv;
CreateListOfTrd1Modules();
mCellIndexLookup.resize(mNCells);
for (auto icell = 0; icell < mNCells; icell++) {
mCellIndexLookup[icell] = CalculateCellIndex(icell);
}
memset(SMODULEMATRIX, 0, sizeof(TGeoHMatrix*) * EMCAL_MODULES);
LOG(debug) << "Name <<" << name << ">>";
}
Geometry& Geometry::operator=(const Geometry& /*rvalue*/)
{
LOG(fatal) << "assignment operator, not implemented";
return *this;
}
Geometry::~Geometry()
{
if (this == sGeom) {
LOG(error) << "Do not call delete on me";
return;
}
for (Int_t smod = 0; smod < mNumberOfSuperModules; smod++) {
if (SMODULEMATRIX[smod]) {
delete SMODULEMATRIX[smod];
}
}
}
Geometry* Geometry::GetInstance()
{
Geometry* rv = static_cast<Geometry*>(sGeom);
if (!rv) {
throw GeometryNotInitializedException();
}
return rv;
}
Geometry* Geometry::GetInstance(const std::string_view name, const std::string_view mcname,
const std::string_view mctitle)
{
if (!sGeom) {
if (!name.length()) { // get default geometry
sGeom = new Geometry(DEFAULT_GEOMETRY, mcname, mctitle);
} else {
sGeom = new Geometry(name, mcname, mctitle);
} // end if strcmp(name,"")
return sGeom;
} else {
if (sGeom->GetName() != name) {
LOG(info) << "\n current geometry is " << sGeom->GetName() << " : you should not call " << name;
} // end
return sGeom;
} // end if sGeom
return nullptr;
}
Geometry* Geometry::GetInstanceFromRunNumber(Int_t runNumber, const std::string_view geoName,
const std::string_view mcname, const std::string_view mctitle)
{
using boost::algorithm::contains;
// printf("AliEMCALGeometry::GetInstanceFromRunNumber() - run %d, geoName <<%s>> \n",runNumber,geoName.Data());
if (runNumber >= 104064 && runNumber < 140000) {
// 2009-2010 runs
// First year geometry, 4 SM.
if (contains(geoName, "FIRSTYEARV1") && geoName != std::string("")) {
LOG(info) << "o2::emcal::Geometry::GetInstanceFromRunNumber() *** ATTENTION *** \n"
<< "\t Specified geometry name <<" << geoName << ">> for run " << runNumber
<< " is not considered! \n"
<< "\t In use <<EMCAL_FIRSTYEARV1>>, check run number and year";
} else {
LOG(info)
<< "o2::emcal::Geometry::GetInstanceFromRunNumber() - Initialized geometry with name <<EMCAL_FIRSTYEARV1>>";
}
return Geometry::GetInstance("EMCAL_FIRSTYEARV1", mcname, mctitle);
} else if (runNumber >= 140000 && runNumber <= 170593) {
// Almost complete EMCAL geometry, 10 SM. Year 2011 configuration
if (contains(geoName, "COMPLETEV1") && geoName != std::string("")) {
LOG(info) << "o2::emcal::Geometry::GetInstanceFromRunNumber() *** ATTENTION *** \n"
<< "\t Specified geometry name <<" << geoName << ">> for run " << runNumber
<< " is not considered! \n"
<< "\t In use <<EMCAL_COMPLETEV1>>, check run number and year";
} else {
LOG(info)
<< "o2::emcal::Geometry::GetInstanceFromRunNumber() - Initialized geometry with name <<EMCAL_COMPLETEV1>>";
}
return Geometry::GetInstance("EMCAL_COMPLETEV1", mcname, mctitle);
} else if (runNumber > 176000 && runNumber <= 197692) {
// Complete EMCAL geometry, 12 SM. Year 2012 and on
// The last 2 SM were not active, anyway they were there.
if (contains(geoName, "COMPLETE12SMV1") && geoName != std::string("")) {
LOG(info) << "o2::emcal::Geometry::GetInstanceFromRunNumber() *** ATTENTION *** \n"
<< "\t Specified geometry name <<" << geoName << " >> for run " << runNumber
<< " is not considered! \n"
<< "\t In use <<EMCAL_COMPLETE12SMV1>>, check run number and year";
} else {
LOG(info) << "o2::emcal::Geometry::GetInstanceFromRunNumber() - Initialized geometry with name "
"<<EMCAL_COMPLETE12SMV1>>";
}
return Geometry::GetInstance("EMCAL_COMPLETE12SMV1", mcname, mctitle);
} else // Run 2
{
// EMCAL + DCAL geometry, 20 SM. Year 2015 and on
if (contains(geoName, "DCAL_8SM") && geoName != std::string("")) {
LOG(info) << "o2::emcal::Geometry::GetInstanceFromRunNumber() *** ATTENTION *** \n"
<< "\t Specified geometry name <<" << geoName << ">> for run " << runNumber
<< " is not considered! \n"
<< "\t In use <<EMCAL_COMPLETE12SMV1_DCAL_8SM>>, check run number and year";
} else {
LOG(info) << "o2::emcal::Geometry::GetInstanceFromRunNumber() - Initialized geometry with name "
"<<EMCAL_COMPLETE12SMV1_DCAL_8SM>>";
}
return Geometry::GetInstance("EMCAL_COMPLETE12SMV1_DCAL_8SM", mcname, mctitle);
}
}
void Geometry::DefineSamplingFraction(const std::string_view mcname, const std::string_view mctitle)
{
// Jun 05,2006
// Look http://rhic.physics.wayne.edu/~pavlinov/ALICE/SHISHKEBAB/RES/linearityAndResolutionForTRD1.html
// Keep for compatibility
//
using boost::algorithm::contains;
// Sampling factor for G3
mSampling = 10.87; // Default value - Nov 25,2010
if (mNECLayers == 69) { // 10% layer reduction
mSampling = 12.55;
} else if (mNECLayers == 61) { // 20% layer reduction
mSampling = 12.80;
} else if (mNECLayers == 77) {
if (contains(mGeoName, "V1")) {
mSampling = 10.87; // Adding paper sheets and cover plate; Nov 25,2010
} else if (mECScintThick > 0.159 && mECScintThick < 0.161) { // original sampling fraction, equal layers
mSampling = 12.327; // fECScintThick = fECPbRadThickness = 0.160;
} else if (mECScintThick > 0.175 && mECScintThick < 0.177) { // 10% Pb thicknes reduction
mSampling = 10.5; // fECScintThick = 0.176, fECPbRadThickness=0.144;
} else if (mECScintThick > 0.191 && mECScintThick < 0.193) { // 20% Pb thicknes reduction
mSampling = 8.93; // fECScintThick = 0.192, fECPbRadThickness=0.128;
}
}
Float_t samplingFactorTranportModel = 1.;
// Note: The sampling factors are chosen so that results from the simulation
// engines correspond well with testbeam data
if (contains(mcname, "Geant3")) {
samplingFactorTranportModel = 1.; // 0.988 // Do nothing
} else if (contains(mcname, "Fluka")) {
samplingFactorTranportModel = 1.; // To be set
} else if (contains(mcname, "Geant4")) {
std::string physicslist = mctitle.substr(mctitle.find(":") + 2).data();
LOG(info) << "Selected physics list: " << physicslist;
// sampling factors for different Geant4 physics list
// GEANT4 10.7 -> EMCAL-784
// set a default (there may be many physics list strings)
samplingFactorTranportModel = 0.81;
if (physicslist == "FTFP_BERT_EMV+optical") {
samplingFactorTranportModel = 0.821;
} else if (physicslist == "FTFP_BERT_EMV+optical+biasing") {
samplingFactorTranportModel = 0.81;
} else if (physicslist == "FTFP_INCLXX_EMV+optical") {
samplingFactorTranportModel = 0.81;
}
}
LOG(info) << "MC modeler <" << mcname << ">, Title <" << mctitle << ">: Sampling " << std::setw(2)
<< std::setprecision(3) << mSampling << ", model fraction with respect to G3 "
<< samplingFactorTranportModel << ", final sampling " << mSampling * samplingFactorTranportModel;
mSampling *= samplingFactorTranportModel;
}
void Geometry::DefineEMC(std::string_view mcname, std::string_view mctitle)
{
using boost::algorithm::contains;
// geometry
std::transform(mGeoName.begin(), mGeoName.end(), mGeoName.begin(), ::toupper);
// Convert old geometry names to new ones
if (contains(mGeoName, "SHISH_77_TRD1_2X2_FINAL_110DEG")) {
if (contains(mGeoName, "PBTH=0.144") && contains(mGeoName, "SCTH=0.176")) {
mGeoName = "EMCAL_COMPLETE";
} else {
mGeoName = "EMCAL_PDC06";
}
}
if (contains(mGeoName, "WSUC")) {
mGeoName = "EMCAL_WSUC";
}
// check that we have a valid geometry name
if (!(contains(mGeoName, "EMCAL_PDC06") || contains(mGeoName, "EMCAL_WSUC") || contains(mGeoName, "EMCAL_COMPLETE") ||
contains(mGeoName, "EMCAL_COMPLETEV1") || contains(mGeoName, "EMCAL_COMPLETE12SMV1") ||
contains(mGeoName, "EMCAL_FIRSTYEAR") || contains(mGeoName, "EMCAL_FIRSTYEARV1"))) {
LOG(fatal) << "Init, " << mGeoName << " is an undefined geometry!\n";
}
// Option to know whether we have the "half" supermodule(s) or not
mKey110DEG = 0;
if (contains(mGeoName, "COMPLETE") || contains(mGeoName, "PDC06") || contains(mGeoName, "12SM")) {
mKey110DEG = 1; // for GetAbsCellId
}
if (contains(mGeoName, "COMPLETEV1")) {
mKey110DEG = 0;
}
mnSupModInDCAL = 0;
if (contains(mGeoName, "DCAL_DEV")) {
mnSupModInDCAL = 10;
} else if (contains(mGeoName, "DCAL_8SM")) {
mnSupModInDCAL = 8;
} else if (contains(mGeoName, "DCAL")) {
mnSupModInDCAL = 6;
}
// JLK 13-Apr-2008
// default parameters are those of EMCAL_COMPLETE geometry
// all others render variations from these at the end of
// geometry-name specific options
mNumberOfSuperModules = 12; // 12 = 6 * 2 (6 in phi, 2 in Z)
mNPhi = 12; // module granularity in phi within smod (azimuth)
mNZ = 24; // module granularity along Z within smod (eta)
mNPHIdiv = mNETAdiv = 2; // tower granularity within module
mArm1PhiMin = 80.0; // degrees, Starting EMCAL Phi position
mArm1PhiMax = 200.0; // degrees, Ending EMCAL Phi position
mArm1EtaMin = -0.7; // pseudorapidity, Starting EMCAL Eta position
mArm1EtaMax = +0.7; // pseudorapidity, Ending EMCAL Eta position
mIPDistance = 428.0; // cm, radial distance to front face from nominal vertex point
mPhiGapForSM = 2.; // cm, only for final TRD1 geometry
mFrontSteelStrip = 0.025; // 0.025cm = 0.25mm (13-may-05 from V.Petrov)
mPassiveScintThick = 0.8; // 0.8cm = 8mm (13-may-05 from V.Petrov)
mLateralSteelStrip = 0.01; // 0.01cm = 0.1mm (13-may-05 from V.Petrov) - was 0.025
mTrd1Angle = 1.5; // in degrees
mSampling = 1.; // should be calculated with call to DefineSamplingFraction()
mNECLayers = 77; // (13-may-05 from V.Petrov) - can be changed with additional options
mECScintThick = 0.176; // scintillator layer thickness
mECPbRadThickness = 0.144; // lead layer thickness
mPhiModuleSize = 12.26 - mPhiGapForSM / Float_t(mNPhi); // first assumption
mEtaModuleSize = mPhiModuleSize;
mZLength = 700.; // Z coverage (cm)
mPhiSuperModule = 20.; // phi in degree
mDCALInnerEdge = mIPDistance * TMath::Tan(mTrd1Angle * 8. * TMath::DegToRad());
// modifications to the above for PDC06 geometry
if (contains(mGeoName, "PDC06")) { // 18-may-05 - about common structure
mECScintThick = mECPbRadThickness = 0.16; // (13-may-05 from V.Petrov)
}
// modifications to the above for WSUC geometry
if (contains(mGeoName, "WSUC")) { // 18-may-05 - about common structure
mNumberOfSuperModules = 2; // 27-may-05; Nov 24,2010 for TB
mNPhi = mNZ = 4;
mTrd1AlFrontThick = 1.0; // one cm
// Bond paper - two sheets around Sc tile
mTrd1BondPaperThick = 0.01; // 0.01cm = 0.1 mm
mPhiModuleSize = 12.0;
mEtaModuleSize = mPhiModuleSize;
mLateralSteelStrip = 0.015; // 0.015cm = 0.15mm
}
// In 2009-2010 data taking runs only 4 SM, in the upper position.
if (contains(mGeoName, "FIRSTYEAR")) {
mNumberOfSuperModules = 4;
mArm1PhiMax = 120.0;
}
if (contains(mGeoName, "FIRSTYEARV1") || contains(mGeoName, "COMPLETEV1") || contains(mGeoName, "COMPLETE12SMV1")) {
// Oct 26,2010 : First module has tilt = 0.75 degree :
// look to AliEMCALShishKebabTrd1Module::DefineFirstModule(key)
// New sizes from production drawing, added Al front plate.
// The thickness of sampling is change due to existing two sheets of paper.
// Will replace fFrontSteelStrip
mTrd1AlFrontThick = 1.0; // one cm
// Bond paper - two sheets around Sc tile
mTrd1BondPaperThick = 0.01; // 0.01cm = 0.1 mm
mPhiModuleSize = 12.0;
mEtaModuleSize = mPhiModuleSize;
mLateralSteelStrip = 0.015; // 0.015cm = 0.15mm
if (contains(mGeoName, "COMPLETEV1")) {
mNumberOfSuperModules = 10;
mArm1PhiMax = 180.0;
} else if (contains(mGeoName, "COMPLETE12SMV1")) {
mNumberOfSuperModules = 12;
mArm1PhiMax = 200.0;
}
if (contains(mGeoName, "DCAL")) {
mNumberOfSuperModules = 12 + mnSupModInDCAL;
mArm1PhiMax = 320.0;
if (contains(mGeoName, "DCAL_8SM")) {
mArm1PhiMax = 340.0; // degrees, End of DCAL Phi position
} else if (contains(mGeoName, "DCAL_DEV")) {
mArm1PhiMin = 40.0; // degrees, Starting EMCAL(shifted) Phi position
}
mDCALPhiMin = mArm1PhiMax - 10. * mnSupModInDCAL;
}
}
//
// Init EMCal/DCal SMs type array
mEMCSMSystem.clear();
mEMCSMSystem.resize(mNumberOfSuperModules);
for (Int_t i = 0; i < mNumberOfSuperModules; i++) {
mEMCSMSystem[i] = NOT_EXISTENT;
}
Int_t iSM = 0;
//
// BASIC EMCAL SM
if (contains(mGeoName, "WSUC")) {
for (int i = 0; i < 2; i++) {
mEMCSMSystem[iSM] = EMCAL_STANDARD;
iSM++;
}
} else if (contains(mGeoName, "FIRSTYEAR")) {
for (int i = 0; i < 4; i++) {
mEMCSMSystem[iSM] = EMCAL_STANDARD;
iSM++;
}
} else if (contains(mGeoName, "PDC06") || contains(mGeoName, "COMPLETE")) {
for (int i = 0; i < 10; i++) {
mEMCSMSystem[iSM] = EMCAL_STANDARD;
iSM++;
}
}
//
// EMCAL 110SM
if (mKey110DEG && contains(mGeoName, "12SM")) {
for (int i = 0; i < 2; i++) {
mEMCSMSystem[iSM] = EMCAL_HALF;
if (contains(mGeoName, "12SMV1")) {
mEMCSMSystem[iSM] = EMCAL_THIRD;
}
iSM++;
}
}
//
// DCAL SM
if (mnSupModInDCAL && contains(mGeoName, "DCAL")) {
if (contains(mGeoName, "8SM")) {
for (int i = 0; i < mnSupModInDCAL - 2; i++) {
mEMCSMSystem[iSM] = DCAL_STANDARD;
iSM++;
}
for (int i = 0; i < 2; i++) {
mEMCSMSystem[iSM] = DCAL_EXT;
iSM++;
}
} else {
for (int i = 0; i < mnSupModInDCAL; i++) {
mEMCSMSystem[iSM] = DCAL_STANDARD;
iSM++;
}
}
}
// constant for transition absid <--> indexes
mNCellsInModule = mNPHIdiv * mNETAdiv;
mNCellsInSupMod = mNCellsInModule * mNPhi * mNZ;
mNCells = 0;
for (int i = 0; i < mNumberOfSuperModules; i++) {
if (GetSMType(i) == EMCAL_STANDARD) {
mNCells += mNCellsInSupMod;
} else if (GetSMType(i) == EMCAL_HALF) {
mNCells += mNCellsInSupMod / 2;
} else if (GetSMType(i) == EMCAL_THIRD) {
mNCells += mNCellsInSupMod / 3;
} else if (GetSMType(i) == DCAL_STANDARD) {
mNCells += 2 * mNCellsInSupMod / 3;
} else if (GetSMType(i) == DCAL_EXT) {
mNCells += mNCellsInSupMod / 3;
} else {
LOG(error) << "Uknown SuperModule Type !!\n";
}
}
mNPhiSuperModule = mNumberOfSuperModules / 2;
if (mNPhiSuperModule < 1) {
mNPhiSuperModule = 1;
}
mPhiTileSize = mPhiModuleSize / double(mNPHIdiv) - mLateralSteelStrip; // 13-may-05
mEtaTileSize = mEtaModuleSize / double(mNETAdiv) - mLateralSteelStrip; // 13-may-05
mLongModuleSize = mNECLayers * (mECScintThick + mECPbRadThickness);
if (contains(mGeoName, "V1")) {
Double_t ws = mECScintThick + mECPbRadThickness + 2. * mTrd1BondPaperThick; // sampling width
// Number of Pb tiles = Number of Sc tiles - 1
mLongModuleSize = mTrd1AlFrontThick + (ws * mNECLayers - mECPbRadThickness);
}
m2Trd1Dx2 = mEtaModuleSize + 2. * mLongModuleSize * TMath::Tan(mTrd1Angle * TMath::DegToRad() / 2.);
if (!contains(mGeoName, "WSUC")) {
mShellThickness = TMath::Sqrt(mLongModuleSize * mLongModuleSize + m2Trd1Dx2 * m2Trd1Dx2);
}
// These parameters are used to create the mother volume to hold the supermodules
// 2cm padding added to allow for misalignments - JLK 30-May-2008
mEnvelop[0] = mIPDistance - 1.; // mother volume inner radius
mEnvelop[1] = mIPDistance + mShellThickness + 1.; // mother volume outer r.
mEnvelop[2] = mZLength + 2.; // mother volume length
// Local coordinates
mParSM[0] = GetShellThickness() / 2.;
mParSM[1] = GetPhiModuleSize() * GetNPhi() / 2.;
mParSM[2] = mZLength / 4.; // divide by 4 to get half-length of SM
// SM phi boundaries - (0,1),(2,3) ... - has the same boundaries;
mPhiBoundariesOfSM.resize(mNumberOfSuperModules);
mPhiCentersOfSM.resize(mNumberOfSuperModules / 2);
mPhiCentersOfSMSec.resize(mNumberOfSuperModules / 2);
Double_t kfSupermodulePhiWidth = mPhiSuperModule * TMath::DegToRad();
mPhiCentersOfSM[0] = (mArm1PhiMin + mPhiSuperModule / 2.) * TMath::DegToRad(); // Define from First SM
mPhiCentersOfSMSec[0] = mPhiCentersOfSM[0]; // the same in the First SM
mPhiBoundariesOfSM[0] = mPhiCentersOfSM[0] - TMath::ATan2(mParSM[1], mIPDistance); // 1th and 2th modules)
mPhiBoundariesOfSM[1] = mPhiCentersOfSM[0] + TMath::ATan2(mParSM[1], mIPDistance);
if (mNumberOfSuperModules > 2) { // 2 to Max
Int_t tmpSMType = GetSMType(2);
for (int i = 1; i < mNPhiSuperModule; i++) {
mPhiBoundariesOfSM[2 * i] += mPhiBoundariesOfSM[2 * i - 2] + kfSupermodulePhiWidth;
if (tmpSMType == GetSMType(2 * i)) {
mPhiBoundariesOfSM[2 * i + 1] += mPhiBoundariesOfSM[2 * i - 1] + kfSupermodulePhiWidth;
} else {
// changed SM Type, redefine the [2*i+1] Boundaries
tmpSMType = GetSMType(2 * i);
switch (GetSMType(2 * i)) {
case EMCAL_STANDARD:
mPhiBoundariesOfSM[2 * i + 1] = mPhiBoundariesOfSM[2 * i] + kfSupermodulePhiWidth;
break;
case EMCAL_HALF:
mPhiBoundariesOfSM[2 * i + 1] = mPhiBoundariesOfSM[2 * i] + 2. * TMath::ATan2((mParSM[1]) / 2, mIPDistance);
break;
case EMCAL_THIRD:
mPhiBoundariesOfSM[2 * i + 1] = mPhiBoundariesOfSM[2 * i] + 2. * TMath::ATan2((mParSM[1]) / 3, mIPDistance);
break;
case DCAL_STANDARD:
mPhiBoundariesOfSM[2 * i] = (mDCALPhiMin - mArm1PhiMin) * TMath::DegToRad() + mPhiBoundariesOfSM[0];
mPhiBoundariesOfSM[2 * i + 1] = (mDCALPhiMin - mArm1PhiMin) * TMath::DegToRad() + mPhiBoundariesOfSM[1];
break;
case DCAL_EXT:
mPhiBoundariesOfSM[2 * i + 1] = mPhiBoundariesOfSM[2 * i] + 2. * TMath::ATan2((mParSM[1]) / 3, mIPDistance);
break;
default:
break;
};
}
mPhiCentersOfSM[i] = (mPhiBoundariesOfSM[2 * i] + mPhiBoundariesOfSM[2 * i + 1]) / 2.;
mPhiCentersOfSMSec[i] = mPhiBoundariesOfSM[2 * i] + TMath::ATan2(mParSM[1], mIPDistance);
}
}
// inner extend in eta (same as outer part) for DCal (0.189917), //calculated from the smallest gap (1# cell to the
// 80-degree-edge),
const double INNNER_EXTENDED_PHI =
1.102840997; // calculated from the smallest gap (1# cell to the 80-degree-edge), too complicatd to explain...
mDCALInnerExtandedEta = -TMath::Log(
TMath::Tan((TMath::Pi() / 2. - 8 * mTrd1Angle * TMath::DegToRad() +
(TMath::Pi() / 2 - mNZ * mTrd1Angle * TMath::DegToRad() - TMath::ATan(TMath::Exp(mArm1EtaMin)) * 2)) /
2.));
mEMCALPhiMax = mArm1PhiMin;
mDCALPhiMax = mDCALPhiMin; // DCAl extention will not be included
for (Int_t i = 0; i < mNumberOfSuperModules; i += 2) {
switch (GetSMType(i)) {
case EMCAL_STANDARD:
mEMCALPhiMax += 20.;
break;
case EMCAL_HALF:
mEMCALPhiMax += mPhiSuperModule / 2. + INNNER_EXTENDED_PHI;
break;
case EMCAL_THIRD:
mEMCALPhiMax += mPhiSuperModule / 3. + 4.0 * INNNER_EXTENDED_PHI / 3.0;
break;
case DCAL_STANDARD:
mDCALPhiMax += 20.;
mDCALStandardPhiMax = mDCALPhiMax;
break;
case DCAL_EXT:
mDCALPhiMax += mPhiSuperModule / 3. + 4.0 * INNNER_EXTENDED_PHI / 3.0;
break;
default:
LOG(error) << "Unkown SM Type!!\n";
break;
};
}
// for compatible reason
// if(fNumberOfSuperModules == 4) {fEMCALPhiMax = fArm1PhiMax ;}
if (mNumberOfSuperModules == 12) {
mEMCALPhiMax = mArm1PhiMax;
}
// called after setting of scintillator and lead layer parameters
// called now in AliEMCALv0::CreateGeometry() - 15/03/16
// DefineSamplingFraction(mcname,mctitle);
}
void Geometry::GetGlobal(const Double_t* loc, Double_t* glob, int iSM) const
{
const TGeoHMatrix* m = GetMatrixForSuperModule(iSM);
if (m) {
m->LocalToMaster(loc, glob);
} else {
LOG(fatal) << "Geo matrixes are not loaded \n";
}
}
void Geometry::GetGlobal(const TVector3& vloc, TVector3& vglob, int iSM) const
{
Double_t tglob[3], tloc[3];
vloc.GetXYZ(tloc);
GetGlobal(tloc, tglob, iSM);
vglob.SetXYZ(tglob[0], tglob[1], tglob[2]);
}
void Geometry::GetGlobal(Int_t absId, Double_t glob[3]) const
{
double loc[3];
memset(glob, 0, sizeof(Double_t) * 3);
try {
auto cellpos = RelPosCellInSModule(absId);
loc[0] = cellpos.X();
loc[1] = cellpos.Y();
loc[2] = cellpos.Z();
} catch (InvalidCellIDException& e) {
LOG(error) << e.what();
return;
}
Int_t nSupMod = std::get<0>(GetCellIndex(absId));
const TGeoHMatrix* m = GetMatrixForSuperModule(nSupMod);
if (m) {
m->LocalToMaster(loc, glob);
} else {
LOG(fatal) << "Geo matrixes are not loaded \n";
}
}
void Geometry::GetGlobal(Int_t absId, TVector3& vglob) const
{
Double_t glob[3];
GetGlobal(absId, glob);
vglob.SetXYZ(glob[0], glob[1], glob[2]);
}
std::tuple<double, double> Geometry::EtaPhiFromIndex(Int_t absId) const
{
TVector3 vglob;
GetGlobal(absId, vglob);
return std::make_tuple(vglob.Eta(), vglob.Phi());
}
int Geometry::GetAbsCellId(int supermoduleID, int moduleID, int phiInModule, int etaInModule) const
{
// 0 <= nSupMod < fNumberOfSuperModules
// 0 <= nModule < fNPHI * fNZ ( fNPHI * fNZ/2 for fKey110DEG=1)
// 0 <= nIphi < fNPHIdiv
// 0 <= nIeta < fNETAdiv
// 0 <= absid < fNCells
int cellid = 0; // have to change from 0 to fNCells-1
for (int i = 0; i < supermoduleID; i++) {
switch (GetSMType(i)) {
case EMCAL_STANDARD:
cellid += mNCellsInSupMod;
break;
case EMCAL_HALF:
cellid += mNCellsInSupMod / 2;
break;
case EMCAL_THIRD:
cellid += mNCellsInSupMod / 3;
break;
case DCAL_STANDARD:
cellid += 2 * mNCellsInSupMod / 3;
break;
case DCAL_EXT:
cellid += mNCellsInSupMod / 3;
break;
default:
throw InvalidSupermoduleTypeException();
};
}
cellid += mNCellsInModule * moduleID;
cellid += mNPHIdiv * phiInModule;
cellid += etaInModule;
if (!CheckAbsCellId(cellid)) {
throw InvalidCellIDException(cellid);
}
return cellid;
}
std::tuple<int, int, int> Geometry::GetModuleIndexesFromCellIndexesInSModule(int supermoduleID, int phiInSupermodule, int etaInSupermodule) const
{
int nModulesInSMPhi = GetNumberOfModuleInPhiDirection(supermoduleID);
int moduleEta = etaInSupermodule / mNETAdiv,
modulePhi = phiInSupermodule / mNPHIdiv,
moduleID = moduleEta * nModulesInSMPhi + modulePhi;
int etaInModule = etaInSupermodule % mNETAdiv,
phiInModule = phiInSupermodule % mNPHIdiv;
// return std::make_tuple(modulePhi, moduleEta, moduleID);
return std::make_tuple(phiInModule, etaInModule, moduleID);
}
Int_t Geometry::GetAbsCellIdFromCellIndexes(Int_t nSupMod, Int_t iphi, Int_t ieta) const
{
// Check if the indeces correspond to existing SM or tower indeces
if (iphi < 0 || iphi >= EMCAL_ROWS || ieta < 0 || ieta >= EMCAL_COLS || nSupMod < 0 ||
nSupMod >= GetNumberOfSuperModules()) {
LOG(debug) << "Wrong cell indexes : SM " << nSupMod << ", column (eta) " << ieta << ", row (phi) " << iphi;
return -1;
}
auto indexmod = GetModuleIndexesFromCellIndexesInSModule(nSupMod, iphi, ieta);
Int_t nIeta = ieta % mNETAdiv,
nIphi = iphi % mNPHIdiv;
nIeta = mNETAdiv - 1 - nIeta;
return GetAbsCellId(nSupMod, std::get<2>(indexmod), nIphi, nIeta);
}
std::tuple<int, int> Geometry::GlobalRowColFromIndex(int cellID) const
{
if (!CheckAbsCellId(cellID)) {
throw InvalidCellIDException(cellID);
}
auto [supermodule, module, phiInModule, etaInModule] = GetCellIndex(cellID);
auto [row, col] = GetCellPhiEtaIndexInSModule(supermodule, module, phiInModule, etaInModule);
// add offsets (row / col per supermodule)
if (supermodule == 13 || supermodule == 15 || supermodule == 17) {
// DCal odd SMs need shift of the col. index in oder to get the global col. index
col += 16;
}
if (supermodule % 2) {
col += mNZ * 2;
}
int sector = supermodule / 2;
if (sector > 0) {
for (int isec = 0; isec < sector; isec++) {
auto smtype = GetSMType(isec * 2);
auto nphism = (smtype == EMCAL_THIRD || smtype == DCAL_EXT) ? GetNPhi() / 3 : GetNPhi();
row += 2 * nphism;
}
}
return std::make_tuple(row, col);
}
std::tuple<int, int, int> Geometry::GetPositionInSupermoduleFromGlobalRowCol(int row, int col) const
{
if (col < 0 || col >= 4 * GetNEta()) {
throw RowColException(row, col);
}
int side = col < GetNEta() * 2 ? 0 : 1,
colSM = col % (GetNEta() * 2);
int sector = -1,
rowSM = row;
for (int isec = 0; isec < GetNPhiSuperModule(); isec++) {
auto smtype = GetSMType(isec * 2);
auto nphism = GetNPhi() * 2;
if (smtype == EMCAL_THIRD || smtype == DCAL_EXT) {
nphism /= 3;
}
if (rowSM < nphism) {
sector = isec;
break;
}
rowSM -= nphism;
}
if (sector < 0) {
throw RowColException(row, col);
}
int supermodule = sector * 2 + side;
if (supermodule == 13 || supermodule == 15 || supermodule == 17) {
// DCal odd SMs need shift of the col. index as global col index includes PHOS hole
colSM -= 16;
if (colSM < 0) {
throw RowColException(row, col); // Position inside PHOS hole specified
}
}
if (supermodule == 12 || supermodule == 14 || supermodule == 16) {
if (colSM > 32) {
throw RowColException(row, col); // Position inside PHOS hole specified
}
}
return std::make_tuple(supermodule, rowSM, colSM);
}
int Geometry::GetCellAbsIDFromGlobalRowCol(int row, int col) const
{
auto [supermodule, rowSM, colSM] = GetPositionInSupermoduleFromGlobalRowCol(row, col);
return GetAbsCellIdFromCellIndexes(supermodule, rowSM, colSM);
}
std::tuple<int, int, int, int> Geometry::GetCellIndexFromGlobalRowCol(int row, int col) const
{
auto [supermodule, rowSM, colSM] = GetPositionInSupermoduleFromGlobalRowCol(row, col);
auto indexmod = GetModuleIndexesFromCellIndexesInSModule(supermodule, rowSM, colSM);
Int_t colInModule = colSM % mNETAdiv,
rowInMOdule = rowSM % mNPHIdiv;
colInModule = mNETAdiv - 1 - colInModule;
return std::make_tuple(supermodule, std::get<2>(indexmod), rowInMOdule, colInModule);
}
int Geometry::GlobalCol(int cellID) const
{
return std::get<1>(GlobalRowColFromIndex(cellID));
}
int Geometry::GlobalRow(int cellID) const
{
return std::get<0>(GlobalRowColFromIndex(cellID));
}
Int_t Geometry::SuperModuleNumberFromEtaPhi(Double_t eta, Double_t phi) const
{
if (TMath::Abs(eta) > mEtaMaxOfTRD1) {
throw InvalidPositionException(eta, phi);
}
phi = TVector2::Phi_0_2pi(phi); // move phi to (0,2pi) boundaries
Int_t nphism = mNumberOfSuperModules / 2;
Int_t nSupMod = 0;
for (Int_t i = 0; i < nphism; i++) {
LOG(debug) << "Sec " << i << ": Min " << mPhiBoundariesOfSM[2 * i] << ", Max " << mPhiBoundariesOfSM[2 * i + 1];
if (phi >= mPhiBoundariesOfSM[2 * i] && phi <= mPhiBoundariesOfSM[2 * i + 1]) {
nSupMod = 2 * i;
if (eta < 0.0) {
nSupMod++;
}
if (GetSMType(nSupMod) == DCAL_STANDARD) { // Gap between DCAL
if (TMath::Abs(eta) < GetNEta() / 3 * mTrd1Angle * TMath::DegToRad()) {
throw InvalidPositionException(eta, phi);
}
}
LOG(debug) << "eta " << eta << " phi " << phi << " (" << std::setw(5) << std::setprecision(2)
<< phi * TMath::RadToDeg() << ") : nSupMod " << nSupMod << ": #bound " << i;
return nSupMod;
}
}
throw InvalidPositionException(eta, phi);
}
Int_t Geometry::GetAbsCellIdFromEtaPhi(Double_t eta, Double_t phi) const
{
Int_t nSupMod = SuperModuleNumberFromEtaPhi(eta, phi);
// phi index first
phi = TVector2::Phi_0_2pi(phi);
Double_t phiLoc = phi - mPhiCentersOfSMSec[nSupMod / 2];
Int_t nphi = mPhiCentersOfCells.size();
switch (GetSMType(nSupMod)) {
case EMCAL_HALF:
nphi /= 2;
case EMCAL_THIRD:
case DCAL_EXT:
nphi /= 3;
break;
default:
// All other supermodules have full number of cells in phi
break;
};
Double_t dmin = TMath::Abs(mPhiCentersOfCells[0] - phiLoc),
d = 0.;
Int_t iphi = 0;
for (Int_t i = 1; i < nphi; i++) {
d = TMath::Abs(mPhiCentersOfCells[i] - phiLoc);
if (d < dmin) {
dmin = d;
iphi = i;
}
// printf(" i %i : d %f : dmin %f : fPhiCentersOfCells[i] %f \n", i, d, dmin, fPhiCentersOfCells[i]);
}
// odd SM are turned with respect of even SM - reverse indexes
LOG(debug2) << " iphi " << iphi << " : dmin " << dmin << " (phi " << phi << ", phiLoc " << phiLoc << ")\n";
// eta index
Double_t absEta = TMath::Abs(eta);
Int_t neta = mCentersOfCellsEtaDir.size(),
etaShift = iphi * neta,
ieta = 0;
if (GetSMType(nSupMod) == DCAL_STANDARD) {
ieta += 16; // jump 16 cells for DCSM
}
dmin = TMath::Abs(mEtaCentersOfCells[etaShift + ieta] - absEta);
for (Int_t i = ieta + 1; i < neta; i++) {
d = TMath::Abs(mEtaCentersOfCells[i + etaShift] - absEta);
if (d < dmin) {