13#include <RtypesCore.h>
21#include <TJAlienCredentials.h>
23#include <fairlogger/Logger.h>
37#include <TGeoManager.h>
38#include <TGeoMatrix.h>
46#include <boost/algorithm/string/predicate.hpp>
54 : mGeoName(geo.mGeoName),
55 mKey110DEG(geo.mKey110DEG),
56 mnSupModInDCAL(geo.mnSupModInDCAL),
57 mNCellsInSupMod(geo.mNCellsInSupMod),
58 mNETAdiv(geo.mNETAdiv),
59 mNPHIdiv(geo.mNPHIdiv),
60 mNCellsInModule(geo.mNCellsInModule),
61 mPhiBoundariesOfSM(geo.mPhiBoundariesOfSM),
62 mPhiCentersOfSM(geo.mPhiCentersOfSM),
63 mPhiCentersOfSMSec(geo.mPhiCentersOfSMSec),
64 mPhiCentersOfCells(geo.mPhiCentersOfCells),
65 mCentersOfCellsEtaDir(geo.mCentersOfCellsEtaDir),
66 mCentersOfCellsPhiDir(geo.mCentersOfCellsPhiDir),
67 mEtaCentersOfCells(geo.mEtaCentersOfCells),
70 mCentersOfCellsXDir(geo.mCentersOfCellsXDir),
71 mArm1EtaMin(geo.mArm1EtaMin),
72 mArm1EtaMax(geo.mArm1EtaMax),
73 mArm1PhiMin(geo.mArm1PhiMin),
74 mArm1PhiMax(geo.mArm1PhiMax),
75 mEtaMaxOfTRD1(geo.mEtaMaxOfTRD1),
76 mDCALPhiMin(geo.mDCALPhiMin),
77 mDCALPhiMax(geo.mDCALPhiMax),
78 mEMCALPhiMax(geo.mEMCALPhiMax),
79 mDCALStandardPhiMax(geo.mDCALStandardPhiMax),
80 mDCALInnerExtandedEta(geo.mDCALInnerExtandedEta),
81 mDCALInnerEdge(geo.mDCALInnerEdge),
82 mShishKebabTrd1Modules(geo.mShishKebabTrd1Modules),
83 mPhiModuleSize(geo.mPhiModuleSize),
84 mEtaModuleSize(geo.mEtaModuleSize),
85 mPhiTileSize(geo.mPhiTileSize),
86 mEtaTileSize(geo.mEtaTileSize),
88 mIPDistance(geo.mIPDistance),
89 mLongModuleSize(geo.mLongModuleSize),
90 mShellThickness(geo.mShellThickness),
91 mZLength(geo.mZLength),
92 mSampling(geo.mSampling),
93 mECPbRadThickness(geo.mECPbRadThickness),
94 mECScintThick(geo.mECScintThick),
95 mNECLayers(geo.mNECLayers),
96 mNumberOfSuperModules(geo.mNumberOfSuperModules),
97 mEMCSMSystem(geo.mEMCSMSystem),
98 mFrontSteelStrip(geo.mFrontSteelStrip),
99 mLateralSteelStrip(geo.mLateralSteelStrip),
100 mPassiveScintThick(geo.mPassiveScintThick),
101 mPhiSuperModule(geo.mPhiSuperModule),
102 mNPhiSuperModule(geo.mNPhiSuperModule),
103 mTrd1Angle(geo.mTrd1Angle),
104 m2Trd1Dx2(geo.m2Trd1Dx2),
105 mPhiGapForSM(geo.mPhiGapForSM),
106 mTrd1AlFrontThick(geo.mTrd1AlFrontThick),
107 mTrd1BondPaperThick(geo.mTrd1BondPaperThick),
110 mSteelFrontThick(geo.mSteelFrontThick),
111 mCellIndexLookup(geo.mCellIndexLookup)
127 mPhiBoundariesOfSM(),
129 mPhiCentersOfSMSec(),
130 mPhiCentersOfCells(),
131 mCentersOfCellsEtaDir(),
132 mCentersOfCellsPhiDir(),
133 mEtaCentersOfCells(),
136 mCentersOfCellsXDir(),
145 mDCALStandardPhiMax(0),
146 mDCALInnerExtandedEta(0),
148 mShishKebabTrd1Modules(),
159 mECPbRadThickness(0.),
162 mNumberOfSuperModules(0),
164 mFrontSteelStrip(0.),
165 mLateralSteelStrip(0.),
166 mPassiveScintThick(0.),
172 mTrd1AlFrontThick(0.0),
173 mTrd1BondPaperThick(0.),
184 for (
auto icell = 0; icell <
mNCells; icell++) {
195 LOG(fatal) <<
"assignment operator, not implemented";
202 LOG(error) <<
"Do not call delete on me";
223 const std::string_view mctitle)
226 if (!
name.length()) {
234 LOG(info) <<
"\n current geometry is " << sGeom->
GetName() <<
" : you should not call " <<
name;
243 const std::string_view mcname,
const std::string_view mctitle)
245 using boost::algorithm::contains;
249 if (runNumber >= 104064 && runNumber < 140000) {
253 if (contains(geoName,
"FIRSTYEARV1") && geoName != std::string(
"")) {
254 LOG(info) <<
"o2::emcal::Geometry::GetInstanceFromRunNumber() *** ATTENTION *** \n"
255 <<
"\t Specified geometry name <<" << geoName <<
">> for run " << runNumber
256 <<
" is not considered! \n"
257 <<
"\t In use <<EMCAL_FIRSTYEARV1>>, check run number and year";
260 <<
"o2::emcal::Geometry::GetInstanceFromRunNumber() - Initialized geometry with name <<EMCAL_FIRSTYEARV1>>";
264 }
else if (runNumber >= 140000 && runNumber <= 170593) {
267 if (contains(geoName,
"COMPLETEV1") && geoName != std::string(
"")) {
268 LOG(info) <<
"o2::emcal::Geometry::GetInstanceFromRunNumber() *** ATTENTION *** \n"
269 <<
"\t Specified geometry name <<" << geoName <<
">> for run " << runNumber
270 <<
" is not considered! \n"
271 <<
"\t In use <<EMCAL_COMPLETEV1>>, check run number and year";
274 <<
"o2::emcal::Geometry::GetInstanceFromRunNumber() - Initialized geometry with name <<EMCAL_COMPLETEV1>>";
277 }
else if (runNumber > 176000 && runNumber <= 197692) {
281 if (contains(geoName,
"COMPLETE12SMV1") && geoName != std::string(
"")) {
282 LOG(info) <<
"o2::emcal::Geometry::GetInstanceFromRunNumber() *** ATTENTION *** \n"
283 <<
"\t Specified geometry name <<" << geoName <<
" >> for run " << runNumber
284 <<
" is not considered! \n"
285 <<
"\t In use <<EMCAL_COMPLETE12SMV1>>, check run number and year";
287 LOG(info) <<
"o2::emcal::Geometry::GetInstanceFromRunNumber() - Initialized geometry with name "
288 "<<EMCAL_COMPLETE12SMV1>>";
295 if (contains(geoName,
"DCAL_8SM") && geoName != std::string(
"")) {
296 LOG(info) <<
"o2::emcal::Geometry::GetInstanceFromRunNumber() *** ATTENTION *** \n"
297 <<
"\t Specified geometry name <<" << geoName <<
">> for run " << runNumber
298 <<
" is not considered! \n"
299 <<
"\t In use <<EMCAL_COMPLETE12SMV1_DCAL_8SM>>, check run number and year";
301 LOG(info) <<
"o2::emcal::Geometry::GetInstanceFromRunNumber() - Initialized geometry with name "
302 "<<EMCAL_COMPLETE12SMV1_DCAL_8SM>>";
314 using boost::algorithm::contains;
334 Float_t samplingFactorTranportModel = 1.;
338 if (contains(mcname,
"Geant3")) {
339 samplingFactorTranportModel = 1.;
340 }
else if (contains(mcname,
"Fluka")) {
341 samplingFactorTranportModel = 1.;
342 }
else if (contains(mcname,
"Geant4")) {
343 std::string physicslist = mctitle.substr(mctitle.find(
":") + 2).data();
344 LOG(info) <<
"Selected physics list: " << physicslist;
349 samplingFactorTranportModel = 0.81;
350 if (physicslist ==
"FTFP_BERT_EMV+optical") {
351 samplingFactorTranportModel = 0.821;
352 }
else if (physicslist ==
"FTFP_BERT_EMV+optical+biasing") {
353 samplingFactorTranportModel = 0.81;
354 }
else if (physicslist ==
"FTFP_INCLXX_EMV+optical") {
355 samplingFactorTranportModel = 0.81;
359 LOG(info) <<
"MC modeler <" << mcname <<
">, Title <" << mctitle <<
">: Sampling " << std::setw(2)
360 << std::setprecision(3) <<
mSampling <<
", model fraction with respect to G3 "
361 << samplingFactorTranportModel <<
", final sampling " <<
mSampling * samplingFactorTranportModel;
363 mSampling *= samplingFactorTranportModel;
368 using boost::algorithm::contains;
374 if (contains(
mGeoName,
"SHISH_77_TRD1_2X2_FINAL_110DEG")) {
387 if (!(contains(
mGeoName,
"EMCAL_PDC06") || contains(
mGeoName,
"EMCAL_WSUC") || contains(
mGeoName,
"EMCAL_COMPLETE") ||
388 contains(
mGeoName,
"EMCAL_COMPLETEV1") || contains(
mGeoName,
"EMCAL_COMPLETE12SMV1") ||
389 contains(
mGeoName,
"EMCAL_FIRSTYEAR") || contains(
mGeoName,
"EMCAL_FIRSTYEARV1"))) {
390 LOG(fatal) <<
"Init, " <<
mGeoName <<
" is an undefined geometry!\n";
398 if (contains(
mGeoName,
"COMPLETEV1")) {
403 if (contains(
mGeoName,
"DCAL_DEV")) {
405 }
else if (contains(
mGeoName,
"DCAL_8SM")) {
407 }
else if (contains(
mGeoName,
"DCAL")) {
462 if (contains(
mGeoName,
"FIRSTYEAR")) {
467 if (contains(
mGeoName,
"FIRSTYEARV1") || contains(
mGeoName,
"COMPLETEV1") || contains(
mGeoName,
"COMPLETE12SMV1")) {
482 if (contains(
mGeoName,
"COMPLETEV1")) {
485 }
else if (contains(
mGeoName,
"COMPLETE12SMV1")) {
492 if (contains(
mGeoName,
"DCAL_8SM")) {
494 }
else if (contains(
mGeoName,
"DCAL_DEV")) {
515 for (
int i = 0;
i < 2;
i++) {
519 }
else if (contains(
mGeoName,
"FIRSTYEAR")) {
520 for (
int i = 0;
i < 4;
i++) {
525 for (
int i = 0;
i < 10;
i++) {
534 for (
int i = 0;
i < 2;
i++) {
551 for (
int i = 0;
i < 2;
i++) {
579 LOG(error) <<
"Uknown SuperModule Type !!\n";
661 const double INNNER_EXTENDED_PHI =
664 TMath::Tan((TMath::Pi() / 2. - 8 *
mTrd1Angle * TMath::DegToRad() +
689 LOG(error) <<
"Unkown SM Type!!\n";
708 m->LocalToMaster(loc, glob);
710 LOG(fatal) <<
"Geo matrixes are not loaded \n";
716 Double_t tglob[3], tloc[3];
719 vglob.SetXYZ(tglob[0], tglob[1], tglob[2]);
726 memset(glob, 0,
sizeof(Double_t) * 3);
729 loc[0] = cellpos.X();
730 loc[1] = cellpos.Y();
731 loc[2] = cellpos.Z();
740 m->LocalToMaster(loc, glob);
742 LOG(fatal) <<
"Geo matrixes are not loaded \n";
751 vglob.SetXYZ(glob[0], glob[1], glob[2]);
758 return std::make_tuple(vglob.Eta(), vglob.Phi());
769 for (
int i = 0;
i < supermoduleID;
i++) {
793 cellid += etaInModule;
805 int moduleEta = etaInSupermodule /
mNETAdiv,
806 modulePhi = phiInSupermodule /
mNPHIdiv,
807 moduleID = moduleEta * nModulesInSMPhi + modulePhi;
808 int etaInModule = etaInSupermodule %
mNETAdiv,
809 phiInModule = phiInSupermodule %
mNPHIdiv;
811 return std::make_tuple(phiInModule, etaInModule, moduleID);
819 LOG(
debug) <<
"Wrong cell indexes : SM " << nSupMod <<
", column (eta) " << ieta <<
", row (phi) " << iphi;
828 return GetAbsCellId(nSupMod, std::get<2>(indexmod), nIphi, nIeta);
848 for (
int isec = 0; isec < sector; isec++) {
854 return std::make_tuple(
row,
col);
859 if (col < 0 || col >= 4 *
GetNEta()) {
872 if (rowSM < nphism) {
908 Int_t colInModule = colSM %
mNETAdiv,
910 colInModule =
mNETAdiv - 1 - colInModule;
911 return std::make_tuple(
supermodule, std::get<2>(indexmod), rowInMOdule, colInModule);
930 phi = TVector2::Phi_0_2pi(phi);
933 for (Int_t
i = 0;
i < nphism;
i++) {
947 LOG(
debug) <<
"eta " << eta <<
" phi " << phi <<
" (" << std::setw(5) << std::setprecision(2)
948 << phi * TMath::RadToDeg() <<
") : nSupMod " << nSupMod <<
": #bound " <<
i;
960 phi = TVector2::Phi_0_2pi(phi);
978 for (Int_t
i = 1;
i < nphi;
i++) {
987 LOG(debug2) <<
" iphi " << iphi <<
" : dmin " << dmin <<
" (phi " << phi <<
", phiLoc " << phiLoc <<
")\n";
990 Double_t absEta = TMath::Abs(eta);
992 etaShift = iphi * neta,
998 for (Int_t
i = ieta + 1;
i < neta;
i++) {
1010 LOG(debug2) <<
" ieta " << ieta <<
" : dmin " << dmin <<
" (eta=" << eta <<
") : nSupMod " << nSupMod;
1015 ieta = (neta - 1) - ieta;
1034 for (nSupMod = -1;
test >= 0;) {
1059 return std::make_tuple(nSupMod, nModule, nIphi, nIeta);
1074 int nModulesInPhi = -1;
1077 nModulesInPhi =
mNPhi / 2;
1081 nModulesInPhi =
mNPhi / 3;
1084 nModulesInPhi =
mNPhi;
1087 return std::make_tuple(
int(moduleID % nModulesInPhi),
int(moduleID / nModulesInPhi));
1091 int etaInModule)
const
1096 int etaInSupermodule = etaOfModule *
mNETAdiv + (
mNETAdiv - 1 - etaInModule);
1097 int phiInSupermodule = phiOfModule *
mNPHIdiv + phiInModule;
1099 if (phiInSupermodule < 0 || etaInSupermodule < 0) {
1100 LOG(
debug) <<
" Supermodule " << supermoduleID <<
", Module " << moduleID <<
" (phi " << phiInModule <<
", eta " << etaInModule <<
")"
1101 <<
" => in Supermodule: eta " << etaInSupermodule <<
", phi " << phiInSupermodule;
1103 return std::make_tuple(phiInSupermodule, etaInSupermodule);
1119 row += supermoduleID / 2 * (24 + 1);
1122 column += supermoduleID % 2 * 48;
1124 column += supermoduleID % 2 * (48 + 1);
1127 return std::make_tuple(
static_cast<short>(
row),
static_cast<short>(column));
1132 if (supermoduleID == 13 || supermoduleID == 15 || supermoduleID == 17) {
1135 }
else if (supermoduleID == 18 || supermoduleID == 19) {
1139 return std::tuple<int, int>(iphi, ieta);
1144 if (supermoduleID == 13 || supermoduleID == 15 || supermoduleID == 17) {
1147 }
else if (supermoduleID == 18 || supermoduleID == 19) {
1151 return std::tuple<int, int>(iphi, ieta);
1161 Double_t xr, yr, zr;
1168 Int_t nSupMod = std::get<0>(cellindex), nModule = std::get<1>(cellindex), nIphi = std::get<2>(cellindex),
1169 nIeta = std::get<3>(cellindex);
1171 Int_t iphi = std::get<0>(indexinsm), ieta = std::get<1>(indexinsm);
1175 if (nSupMod % 2 == 0) {
1192 if (nSupMod % 2 != 0) {
1193 iphi2 = (phiindex / 3 - 1) - iphi;
1197 if (nSupMod % 2 != 0) {
1198 iphi2 = (phiindex / 2 - 1) - iphi;
1203 if (nSupMod % 2 != 0) {
1204 iphi2 = (phiindex / 3 - 1) - iphi;
1208 if (nSupMod % 2 != 0) {
1209 iphi2 = (phiindex - 1) - iphi;
1214 LOG(
debug) <<
"absId " << absId <<
" nSupMod " << nSupMod <<
" iphi " << iphi <<
" ieta " << ieta <<
" xr " << xr
1215 <<
" yr " << yr <<
" zr " << zr;
1223 Double_t xr, yr, zr;
1226 Int_t kDCalshift = 8;
1228 Int_t iphim = -1, ietam = -1;
1235 Int_t nSupMod = std::get<0>(cellindex), nModule = std::get<1>(cellindex), nIphi = std::get<2>(cellindex),
1236 nIeta = std::get<3>(cellindex);
1238 iphim = std::get<0>(indmodep);
1239 ietam = std::get<1>(indmodep);
1241 Int_t iphi = std::get<0>(indexinsm), ieta = std::get<1>(indexinsm);
1244 if (nSupMod % 2 == 0) {
1255 ietam += kDCalshift;
1268 if (nSupMod % 2 != 0) {
1269 iphi2 = (nphiIndex / 3 - 1) - iphi;
1273 if (nSupMod % 2 != 0) {
1274 iphi2 = (nphiIndex / 2 - 1) - iphi;
1279 if (nSupMod % 2 != 0) {
1280 iphi2 = (nphiIndex / 3 - 1) - iphi;
1284 if (nSupMod % 2 != 0) {
1285 iphi2 = (nphiIndex - 1) - iphi;
1290 LOG(
debug) <<
"absId " << absId <<
" nSupMod " << nSupMod <<
" iphi " << iphi <<
" ieta " << ieta <<
" xr " << xr
1291 <<
" yr " << yr <<
" zr " << zr;
1297 LOG(debug2) <<
" o2::emcal::Geometry::CreateListOfTrd1Modules() started\n";
1300 for (
int iz = 0; iz <
mNZ; iz++) {
1309 LOG(debug2) <<
" Already exits :\n";
1327 Int_t ieta = 0, nModule = 0;
1328 Double_t xr = 0., zr = 0., theta = 0., phi = 0., eta = 0.,
r = 0.,
x = 0.,
y = 0.;
1330 Double_t ytCenterModule = 0.0, ytCenterCell = 0.0;
1336 for (Int_t it = 0; it <
mNPhi; it++) {
1338 for (Int_t ic = 0; ic <
mNPHIdiv; ic++) {
1340 ytCenterCell = ytCenterModule +
mPhiTileSize * (2 * ic - 1) / 2.;
1342 ytCenterCell = ytCenterModule +
mPhiTileSize * (ic - 1);
1344 ytCenterCell = ytCenterModule;
1350 phi = TMath::ATan2(ytCenterCell, r0);
1353 LOG(debug2) <<
" ind " << std::setw(2) << std::setprecision(2) << ind <<
" : y " << std::setw(8)
1365 for (Int_t it = 0; it <
mNZ; it++) {
1367 nModule =
mNPhi * it;
1368 for (Int_t ic = 0; ic <
mNETAdiv; ic++) {
1372 ieta = std::get<1>(indexinsm);
1377 ieta = std::get<1>(indexinsm);
1382 ieta = std::get<1>(indexinsm);
1390 r = TMath::Sqrt(
x *
x +
y *
y + zr * zr);
1391 theta = TMath::ACos(zr /
r);
1402 LOG(debug2) <<
" ind " << std::setw(2) << std::setprecision(2) <<
i + 1 <<
" : z " << std::setw(8)
1422 ImpactOnEmcal({particle->Vx(), particle->Vy(), particle->Vz()}, particle->Theta(), particle->Phi(), absID, vimpact);
1435 vimpact.SetXYZ(0, 0, 0);
1437 if (phi == 0 || theta == 0) {
1442 Double_t factor = (
mIPDistance - vtx.Y()) / p.Y();
1443 direction = vtx + factor * p;
1450 Double_t loc[3], loc2[3], loc3[3];
1451 Double_t glob[3] = {}, glob2[3] = {}, glob3[3] = {};
1462 Int_t nSupMod = std::get<0>(cellindex), nModule = std::get<1>(cellindex), nIphi = std::get<2>(cellindex),
1463 nIeta = std::get<3>(cellindex);
1465 Int_t nIphi2 = -1, nIeta2 = -1, absId2 = -1, absId3 = -1;
1471 absId2 =
GetAbsCellId(nSupMod, nModule, nIphi, nIeta2);
1477 absId3 =
GetAbsCellId(nSupMod, nModule, nIphi2, nIeta);
1498 m->LocalToMaster(loc, glob);
1499 m->LocalToMaster(loc2, glob2);
1500 m->LocalToMaster(loc3, glob3);
1502 LOG(fatal) <<
"Geo matrixes are not loaded \n";
1506 Double_t
a = glob[1] * (glob2[2] - glob3[2]) + glob2[1] * (glob3[2] - glob[2]) + glob3[1] * (glob[2] - glob2[2]);
1507 Double_t
b = glob[2] * (glob2[0] - glob3[0]) + glob2[2] * (glob3[0] - glob[0]) + glob3[2] * (glob[0] - glob2[0]);
1508 Double_t
c = glob[0] * (glob2[1] - glob3[1]) + glob2[0] * (glob3[1] - glob[1]) + glob3[0] * (glob[1] - glob2[1]);
1509 Double_t d = glob[0] * (glob2[1] * glob3[2] - glob3[1] * glob2[2]) +
1510 glob2[0] * (glob3[1] * glob[2] - glob[1] * glob3[2]) +
1511 glob3[0] * (glob[1] * glob2[2] - glob2[1] * glob[2]);
1516 Double_t norm = TMath::Sqrt(
a *
a +
b *
b +
c *
c);
1517 Double_t glob4[3] = {};
1520 if (point.Dot(dir) < 0) {
1523 glob4[0] = glob[0] - dist *
a / norm;
1524 glob4[1] = glob[1] - dist *
b / norm;
1525 glob4[2] = glob[2] - dist *
c / norm;
1526 d = glob4[0] *
a + glob4[1] *
b + glob4[2] *
c;
1531 Double_t den =
a * (vtx.X() - direction.X()) +
b * (vtx.Y() - direction.Y()) +
c * (vtx.Z() - direction.Z());
1533 LOG(error) <<
"ImpactOnEmcal() No solution :\n";
1537 Double_t
length =
a * vtx.X() +
b * vtx.Y() +
c * vtx.Z() + d;
1540 vimpact.SetXYZ(vtx.X() +
length * (direction.X() - vtx.X()), vtx.Y() +
length * (direction.Y() - vtx.Y()),
1541 vtx.Z() +
length * (direction.Z() - vtx.Z()));
1544 vimpact.SetXYZ(vimpact.Z() + dist *
a / norm, vimpact.Y() + dist *
b / norm, vimpact.Z() + dist *
c / norm);
1567 Double_t
r = sqrt(pnt.X() * pnt.X() + pnt.Y() * pnt.Y());
1572 Double_t theta = TMath::ATan2(
r, pnt.Z());
1577 eta = -TMath::Log(TMath::Tan(theta / 2.));
1583 Double_t phi = TMath::ATan2(pnt.Y(), pnt.X()) * 180. / TMath::Pi();
1602 LOG(fatal) <<
"Wrong supermodule index -> " << smod;
1607 LOG(info) <<
"Loading EMCAL misalignment matrix for SM " << smod <<
" from GeoManager.";
1610 LOG(fatal) <<
"Cannot find EMCAL misalignment matrices! Recover them either: \n"
1611 <<
"\t - importing TGeoManager from file geometry.root or \n"
1612 <<
"\t - from OADB in file OADB/EMCAL/EMCALlocal2master.root or \n"
1613 <<
"\t - from OCDB in directory OCDB/EMCAL/Align/Data/ or \n"
1614 <<
"\t - from AliESDs (not in AliAOD) via AliESDRun::GetEMCALMatrix(Int_t superModIndex). \n"
1615 <<
"Store them via AliEMCALGeometry::SetMisalMatrix(Int_t superModIndex)";
1625 LOG(fatal) <<
"Wrong supermodule index -> " << smod;
1633 const Int_t buffersize = 255;
1634 char path[buffersize];
1639 for (Int_t
i = 0;
i < smod + 1;
i++) {
1649 TString smName =
"";
1662 LOG(error) <<
"Unkown SM Type!!\n";
1665 snprintf(
path, buffersize,
"/cave/barrel_1/%s_%d", smName.Data(), smOrder);
1667 if (!gGeoManager->cd(
path)) {
1668 LOG(fatal) <<
"Geo manager can not find path " <<
path <<
"!\n";
1671 return gGeoManager->GetCurrentMatrix();
1675 const Float_t misaligTransShifts[15],
const Float_t misaligRotShifts[15],
1687 gGeoManager->cd(
"/cave/barrel_1/");
1688 TGeoNode* geoXEn1 = gGeoManager->GetCurrentNode();
1689 TGeoNodeMatrix* geoSM[nSMod];
1690 TGeoVolume* geoSMVol[nSMod];
1691 TGeoShape* geoSMShape[nSMod];
1692 TGeoBBox* geoBox[nSMod];
1693 TGeoMatrix* geoSMMatrix[nSMod];
1695 for (
int iSM = 0; iSM < nSMod; iSM++) {
1696 geoSM[iSM] =
dynamic_cast<TGeoNodeMatrix*
>(geoXEn1->GetDaughter(iSM));
1697 geoSMVol[iSM] = geoSM[iSM]->GetVolume();
1698 geoSMShape[iSM] = geoSMVol[iSM]->GetShape();
1699 geoBox[iSM] =
dynamic_cast<TGeoBBox*
>(geoSMShape[iSM]);
1700 geoSMMatrix[iSM] = geoSM[iSM]->GetMatrix();
1728 if (dcol >= 47.5 || dcol < -0.5) {
1729 LOG(error) <<
"Bad tower coordinate dcol=" << dcol <<
", where dcol >= 47.5 || dcol<-0.5; org: " << dcolorg;
1732 if (drow >= 23.5 || drow < -0.5) {
1733 LOG(error) <<
"Bad tower coordinate drow=" << drow <<
", where drow >= 23.5 || drow<-0.5; org: " << droworg;
1736 if (sm >= nSMod || sm < 0) {
1737 LOG(error) <<
"Bad SM number sm=" << nSMod <<
", where sm >= " << sm <<
" || sm < 0\n";
1741 istrip =
int((dcol + 0.5) / 2);
1744 teta1 = TMath::DegToRad() * istrip * 1.5;
1749 for (
int is = 0; is <= istrip; is++) {
1750 teta1 = TMath::DegToRad() * (is * 1.5 + 0.75);
1752 zIs = zIs + 2 * dz * TMath::Cos(teta1);
1755 zIs + 2 * dz * TMath::Cos(teta1) + 2 * dz * TMath::Sin(teta1) * TMath::Tan(teta1 - 0.75 * TMath::DegToRad());
1759 z0 = dz * (dcol - 2 * istrip + 0.5);
1760 zb = (2 * dz - z0 -
depth * TMath::Tan(teta1));
1762 z = zIs - zb * TMath::Cos(teta1);
1763 y =
depth / TMath::Cos(teta1) + zb * TMath::Sin(teta1);
1765 x = (drow + 0.5) * dx;
1770 double xx =
y - geoBox[sm]->GetDX();
1771 double yy = -
x + geoBox[sm]->GetDY();
1772 double zz =
z - geoBox[sm]->GetDZ();
1773 const double localIn[3] = {xx, yy, zz};
1778 geoSMMatrix[sm]->LocalToMaster(localIn, dglobal);
1783 if (sm == 2 || sm == 3) {
1784 global[0] = dglobal[0] + misaligTransShifts[3] + misaligRotShifts[3] * TMath::Sin(TMath::DegToRad() * 20);
1785 global[1] = dglobal[1] + misaligTransShifts[4] + misaligRotShifts[4] * TMath::Cos(TMath::DegToRad() * 20);
1786 global[2] = dglobal[2] + misaligTransShifts[5];
1787 }
else if (sm == 0 || sm == 1) {
1788 global[0] = dglobal[0] + misaligTransShifts[0];
1789 global[1] = dglobal[1] + misaligTransShifts[1];
1790 global[2] = dglobal[2] + misaligTransShifts[2];
1792 LOG(info) <<
"Careful, correction not implemented yet!\n";
1793 global[0] = dglobal[0];
1794 global[1] = dglobal[1];
1795 global[2] = dglobal[2];
1798 LOG(fatal) <<
"Geometry boxes information, check that geometry.root is loaded\n";
1809 LOG(fatal) <<
"Wrong supermodule index -> " << smod << std::endl;
1815 LOG(info) <<
"Using CCDB to obtain EMCal alignment.";
1817 std::map<std::string, std::string> metadata;
1818 api.
init(
"http://alice-ccdb.cern.ch");
1822 TGeoHMatrix* mat =
reinterpret_cast<TGeoHMatrix*
>(matrices->At(iSM));
1827 LOG(info) <<
"Could not obtain Alignment Matrix for SM " << iSM;
1852 int i = nsupmod / 2;
1858 int i = nsupmod / 2;
1883 auto supermoduleID = std::get<0>(cellindex);
1886 int row = std::get<0>(etaphishift),
col = std::get<1>(etaphishift);
1888 int ddlInSupermoudel = -1;
1889 if (0 <=
row &&
row < 8) {
1890 ddlInSupermoudel = 0;
1891 }
else if (8 <=
row &&
row < 16 && 0 <=
col &&
col < 24) {
1892 ddlInSupermoudel = 0;
1893 }
else if (8 <=
row &&
row < 16 && 24 <=
col &&
col < 48) {
1894 ddlInSupermoudel = 1;
1895 }
else if (16 <=
row &&
row < 24) {
1896 ddlInSupermoudel = 1;
1898 if (supermoduleID % 2 == 1) {
1899 ddlInSupermoudel = 1 - ddlInSupermoudel;
1902 return std::make_tuple(supermoduleID * 2 + ddlInSupermoudel,
row,
col);
1911 if (absId1 == absId2) {
1912 return {
false, rowDiff, colDiff};
1919 return {
false, rowDiff, colDiff};
1923 const auto [_, iTower1, iIphi1, iIeta1] =
GetCellIndex(absId1);
1926 const auto [__, iTower2, iIphi2, iIeta2] =
GetCellIndex(absId2);
1930 const int tcardRow0 = row1 - row1 % 8;
1931 const int tcardCol0 = col1 - col1 % 2;
1934 const int rowOffset = row2 - tcardRow0;
1935 const int colOffset = col2 - tcardCol0;
1938 rowDiff = row1 - row2;
1939 colDiff = col1 - col2;
1941 const bool sameTCard = (rowOffset >= 0 && rowOffset < 8 &&
1942 colOffset >= 0 && colOffset < 2);
1943 return {sameTCard, rowDiff, colDiff};
void init(std::string const &hosts)
std::enable_if<!std::is_base_of< o2::conf::ConfigurableParam, T >::value, T * >::type retrieveFromTFileAny(std::string const &path, std::map< std::string, std::string > const &metadata, long timestamp=-1, std::map< std::string, std::string > *headers=nullptr, std::string const &etag="", const std::string &createdNotAfter="", const std::string &createdNotBefore="") const
Error handling access to non-initialized geometry.
EMCAL geometry definition.
std::tuple< int, int, int > GetModuleIndexesFromCellIndexesInSModule(int supermoduleID, int phiInSupermodule, int etaInSupermodule) const
Transition from cell indexes (iphi, ieta) to module indexes (iphim, ietam, nModule)
Float_t mFrontSteelStrip
13-may-05
static Geometry * GetInstanceFromRunNumber(Int_t runNumber, const std::string_view="", const std::string_view mcname="TGeant3", const std::string_view mctitle="")
Instanciate geometry depending on the run number. Mostly used in analysis and MC anchors.
Float_t mEtaMaxOfTRD1
Max eta in case of TRD1 geometry (see AliEMCALShishKebabTrd1Module)
Int_t GetSuperModuleNumber(Int_t absId) const
Get cell SM, from absolute ID number.
void RecalculateTowerPosition(Float_t drow, Float_t dcol, const Int_t sm, const Float_t depth, const Float_t misaligTransShifts[15], const Float_t misaligRotShifts[15], Float_t global[3]) const
std::tuple< int, int, int, int > CalculateCellIndex(Int_t absId) const
Calculate cell SM, module numbers from absolute ID number.
Float_t mIPDistance
Radial Distance of the inner surface of the EMCAL.
Float_t mDCALPhiMin
Minimum angular position of DCAL in Phi (degrees)
Float_t mPassiveScintThick
13-may-05
Float_t mPhiTileSize
Size of phi tile.
int GlobalRow(int cellID) const
Get row number of cell in global numbering scheme.
Int_t mNZ
Number of Towers in the Z direction.
Float_t mECScintThick
cm, Thickness of the scintillators
const TGeoHMatrix * GetMatrixForSuperModuleFromGeoManager(Int_t smod) const
Provides shift-rotation matrix for EMCAL from the TGeoManager.
std::tuple< int, int > GetCellPhiEtaIndexInSModule(int supermoduleID, int moduleID, int phiInModule, int etaInModule) const
Get eta-phi indexes of cell in SM.
std::tuple< int, int, int, int > GetCellIndex(Int_t absId) const
Get cell SM, module numbers from absolute ID number.
std::tuple< double, double > GetPhiBoundariesOfSM(Int_t nSupMod) const
Int_t mNECLayers
number of scintillator layers
std::vector< Double_t > mPhiCentersOfCells
[fNPhi*fNPHIdiv] from center of SM (-10. < phi < +10.)
const TGeoHMatrix * GetMatrixForSuperModule(Int_t smod) const
Provides shift-rotation matrix for EMCAL from externally set matrix or from TGeoManager.
Geometry & operator=(const Geometry &rvalue)
Assignment operator.
Float_t GetDCALInnerEdge() const
std::tuple< int, int, int > getOnlineID(int towerID)
Get link ID, row and column from cell ID, have a look here: https://alice.its.cern....
Int_t GetNEta() const
Get the number of modules in supermodule in #eta direction.
Float_t mEtaModuleSize
Eta -> Y.
void SetMisalMatrixFromCcdb(const char *path="Users/m/mhemmer/EMCAL/Config/GeometryAligned", int timestamp=10000) const
Double_t GetPhiCenterOfSMSec(Int_t nsupmod) const
Float_t GetPhiModuleSize() const
Bool_t CheckAbsCellId(Int_t absId) const
Check whether a cell number is valid.
Float_t mZLength
Total length in z direction.
Float_t mEnvelop[3]
The GEANT TUB for the detector.
Float_t mDCALInnerEdge
Inner edge for DCAL.
void CreateListOfTrd1Modules()
Float_t mParSM[3]
SM sizes as in GEANT (TRD1)
Float_t GetShellThickness() const
Int_t mNCellsInModule
Number cell in module.
std::vector< EMCALSMType > mEMCSMSystem
geometry structure
Bool_t IsDCALExtSM(Int_t nSupMod) const
Check if iSupMod is a valid DCal 1/3rd SM.
std::tuple< int, int, int, int > GetCellIndexFromGlobalRowCol(int row, int col) const
Get the cell indices from global position in the EMCAL.
Double_t GetPhiCenterOfSM(Int_t nsupmod) const
const TGeoHMatrix * SMODULEMATRIX[EMCAL_MODULES]
Orientations of EMCAL super modules.
std::tuple< int, int > GetModulePhiEtaIndexInSModule(int supermoduleID, int moduleID) const
Get eta-phi indexes of module in SM.
std::tuple< int, int, int > GetPositionInSupermoduleFromGlobalRowCol(int row, int col) const
Get the posision (row, col) of a global row-col position.
const TGeoHMatrix * GetMatrixForSuperModuleFromArray(Int_t smod) const
Provides shift-rotation matrix for EMCAL from fkSModuleMatrix[smod].
Float_t mTrd1AlFrontThick
Thickness of the Al front plate.
Float_t mSampling
Sampling factor.
Float_t mDCALPhiMax
Maximum angular position of DCAL in Phi (degrees)
Float_t mTrd1BondPaperThick
Thickness of the Bond Paper sheet.
Int_t mNCells
Number of cells in calo.
std::tuple< bool, int, int > areAbsIDsFromSameTCard(int absId1, int absId2) const
Check if 2 cells belong to the same T-Card.
Float_t mArm1PhiMin
Minimum angular position of EMCAL in Phi (degrees)
void SetMisalMatrix(const TGeoHMatrix *m, Int_t smod) const
Int_t mNETAdiv
Number eta division of module.
std::tuple< short, short > GetTopologicalRowColumn(int supermoduleID, int moduleID, int phiInModule, int etaInModule) const
Get topological row and column of cell in SM (same as for clusteriser with artifical gaps)
Float_t mLateralSteelStrip
13-may-05
std::tuple< int, int > GlobalRowColFromIndex(int cellID) const
get (Column,Row) pair of cell in global numbering scheme
Float_t mTrd1Angle
angle in x-z plane (in degree)
Float_t mECPbRadThickness
cm, Thickness of the Pb radiators
void GetGlobal(const Double_t *loc, Double_t *glob, int ind) const
Figure out the global coordinates from local coordinates on a supermodule.
std::vector< Double_t > mEtaCentersOfCells
[fNEta*fNETAdiv*fNPhi*fNPHIdiv], positive direction (eta>0); eta depend from phi position;
int GetAbsCellId(int supermoduleID, int moduleID, int phiInModule, int etaInModule) const
Get cell absolute ID number from location module (2 times 2 cells) of a super module.
Float_t mArm1PhiMax
Maximum angular position of EMCAL in Phi (degrees)
static Geometry * GetInstance()
Get geometry instance. It should have been set before.
std::tuple< double, double > EtaPhiFromIndex(Int_t absId) const
Figure out the eta/phi coordinates of a cell.
Int_t mKey110DEG
For calculation abs cell id; 19-oct-05.
std::vector< Double_t > mPhiCentersOfSMSec
Phi of centers of section where SM lies; size is fNumberOfSuperModules/2.
std::vector< Double_t > mCentersOfCellsEtaDir
Size fNEta*fNETAdiv (for TRD1 only) (eta or z in SM, in cm)
std::string mGeoName
Geometry name string.
Int_t GetNPhiSuperModule() const
int GlobalCol(int cellID) const
Get column number of cell in global numbering scheme.
Float_t mShellThickness
Total thickness in (x,y) direction.
EMCALSMType GetSMType(Int_t nSupMod) const
std::vector< Double_t > mCentersOfCellsPhiDir
Size fNPhi*fNPHIdiv (for TRD1 only) (phi or y in SM, in cm)
Int_t mNPHIdiv
Number phi division of module.
Int_t mnSupModInDCAL
For calculation abs cell id; 06-nov-12.
Float_t mEtaTileSize
Size of eta tile.
int SuperModuleNumberFromEtaPhi(Double_t eta, Double_t phi) const
Given a global eta/phi point check if it belongs to a supermodule covered region.
void DefineEMC(std::string_view mcname, std::string_view mctitle)
Init function of previous class EMCGeometry.
Bool_t IsDCALSM(Int_t nSupMod) const
Check if iSupMod is a valid DCal standard SM.
Bool_t Impact(const TParticle *particle) const
Check if particle falls in the EMCal/DCal geometry.
std::vector< ShishKebabTrd1Module > mShishKebabTrd1Modules
List of modules.
Bool_t IsInEMCAL(const math_utils::Point3D< double > &pnt) const
Checks whether point is inside the EMCal volume.
math_utils::Point3D< double > RelPosCellInSModule(Int_t absId, Double_t distEf) const
Look to see what the relative position inside a given cell is for a recpoint.
const std::string & GetName() const
Float_t mEMCALPhiMax
Maximum angular position of EMCAL in Phi (degrees)
Bool_t IsInDCAL(const math_utils::Point3D< double > &pnt) const
Checks whether point is inside the DCal volume.
Int_t mNPhiSuperModule
9 - number supermodule in phi direction
Float_t mPhiModuleSize
Phi -> X.
Float_t mPhiGapForSM
Gap betweeen supermodules in phi direction.
Geometry()=default
Default constructor. It must be kept public for root persistency purposes, but should never be called...
Float_t m2Trd1Dx2
2*dx2 for TRD1
AcceptanceType_t IsInEMCALOrDCAL(const math_utils::Point3D< double > &pnt) const
Checks whether point is inside the EMCal volume (included DCal)
Int_t GetNumberOfSuperModules() const
Int_t GetNumberOfModuleInPhiDirection(Int_t nSupMod) const
std::tuple< int, int > ShiftOnlineToOfflineCellIndexes(Int_t supermoduleID, Int_t iphi, Int_t ieta) const
Adapt cell indices in supermodule to online indexing.
Float_t mPhiSuperModule
Phi of normal supermodule (20, in degree)
Float_t mArm1EtaMin
Minimum pseudorapidity position of EMCAL in Eta.
void ImpactOnEmcal(const math_utils::Point3D< double > &vtx, Double_t theta, Double_t phi, Int_t &absId, math_utils::Point3D< double > &vimpact) const
Get the impact coordinates on EMCAL.
Int_t GetNPhi() const
Get the number of modules in supermodule in #phi direction.
Float_t mArm1EtaMax
Maximum pseudorapidity position of EMCAL in Eta.
Int_t GetAbsCellIdFromCellIndexes(Int_t nSupMod, Int_t iphi, Int_t ieta) const
Transition from super module number (nSupMod) and cell indexes (ieta,iphi) to cell absolute ID number...
std::vector< Double_t > mCentersOfCellsXDir
Size fNEta*fNETAdiv (for TRD1 only) ( x in SM, in cm)
Int_t mNPhi
Number of Towers in the PHI direction.
const ShishKebabTrd1Module & GetShishKebabModule(Int_t neta) const
Get the Module parameters for a eta.
Int_t mNumberOfSuperModules
default is 12 = 6 * 2
std::tuple< double, double > GetPhiBoundariesOfSMGap(Int_t nPhiSec) const
std::vector< Double_t > mPhiBoundariesOfSM
Phi boundaries of SM in rad; size is fNumberOfSuperModules;.
std::vector< std::tuple< int, int, int, int > > mCellIndexLookup
Lookup table for cell indices.
void DefineSamplingFraction(const std::string_view mcname="", const std::string_view mctitle="")
Set the value of the Sampling used to calibrate the MC hits energy (check)
Float_t mDCALStandardPhiMax
Special edge for the case that DCAL contian extension.
Float_t mLongModuleSize
Size of long module.
int GetAbsCellIdFromEtaPhi(Double_t eta, Double_t phi) const
Get cell absolute ID number from eta and phi location.
Int_t mNCellsInSupMod
Number cell in super module.
int GetCellAbsIDFromGlobalRowCol(int row, int col) const
Get the absolute cell ID from global position in the EMCAL.
std::tuple< int, int > ShiftOfflineToOnlineCellIndexes(Int_t supermoduleID, Int_t iphi, Int_t ieta) const
Adapt cell indices in supermodule to offline indexing.
std::vector< Double_t > mPhiCentersOfSM
Phi of centers of SM; size is fNumberOfSuperModules/2.
Float_t mDCALInnerExtandedEta
DCAL inner edge in Eta (with some extension)
Exception handling non-existing cell IDs.
const char * what() const noexcept final
Access to error message of the exception.
Error Handling when an invalid module ID (outside the limits) is called.
Exception handling errors due to positions not in the EMCAL area.
Exception handling improper or uninitialized supermodule types.
Handling error for invalid positions in row-column space.
Main class for TRD1 geometry of Shish-Kebab case.
void GetCenterOfCellInLocalCoordinateofSM3X3(Int_t ieta, Double_t &xr, Double_t &zr) const
void GetCenterOfCellInLocalCoordinateofSM1X1(Double_t &xr, Double_t &zr) const
Double_t GetMaxEtaOfModule() const
static Double_t ThetaToEta(Double_t theta)
void GetPositionAtCenterCellLine(Int_t ieta, Double_t dist, TVector2 &v) const
const TVector2 & GetCenterOfCellInLocalCoordinateofSM(Int_t ieta) const
Double_t GetRadius() const
GLuint const GLchar * name
GLboolean GLboolean GLboolean b
GLuint GLsizei GLsizei * length
GLint GLint GLsizei GLsizei GLsizei depth
GLsizei const GLchar *const * path
GLboolean GLboolean GLboolean GLboolean a
GLdouble GLdouble GLdouble z
const std::string DEFAULT_GEOMETRY
@ EMCAL_MODULES
Number of modules, 12 for EMCal + 8 for DCAL.
@ EMCAL_ROWS
Number of rows per module for EMCAL.
@ EMCAL_COLS
Number of columns per module for EMCAL.
FIXME: do not use data model tables.
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"