20#include <RtypesCore.h>
28#include <TJAlienCredentials.h>
30#include <fairlogger/Logger.h>
45#include <TGeoManager.h>
46#include <TGeoMatrix.h>
48#include <boost/algorithm/string/predicate.hpp>
56 : mGeoName(geo.mGeoName),
57 mKey110DEG(geo.mKey110DEG),
58 mnSupModInDCAL(geo.mnSupModInDCAL),
59 mNCellsInSupMod(geo.mNCellsInSupMod),
60 mNETAdiv(geo.mNETAdiv),
61 mNPHIdiv(geo.mNPHIdiv),
62 mNCellsInModule(geo.mNCellsInModule),
63 mPhiBoundariesOfSM(geo.mPhiBoundariesOfSM),
64 mPhiCentersOfSM(geo.mPhiCentersOfSM),
65 mPhiCentersOfSMSec(geo.mPhiCentersOfSMSec),
66 mPhiCentersOfCells(geo.mPhiCentersOfCells),
67 mCentersOfCellsEtaDir(geo.mCentersOfCellsEtaDir),
68 mCentersOfCellsPhiDir(geo.mCentersOfCellsPhiDir),
69 mEtaCentersOfCells(geo.mEtaCentersOfCells),
72 mCentersOfCellsXDir(geo.mCentersOfCellsXDir),
73 mEnvelop(geo.mEnvelop),
74 mArm1EtaMin(geo.mArm1EtaMin),
75 mArm1EtaMax(geo.mArm1EtaMax),
76 mArm1PhiMin(geo.mArm1PhiMin),
77 mArm1PhiMax(geo.mArm1PhiMax),
78 mEtaMaxOfTRD1(geo.mEtaMaxOfTRD1),
79 mDCALPhiMin(geo.mDCALPhiMin),
80 mDCALPhiMax(geo.mDCALPhiMax),
81 mEMCALPhiMax(geo.mEMCALPhiMax),
82 mDCALStandardPhiMax(geo.mDCALStandardPhiMax),
83 mDCALInnerExtandedEta(geo.mDCALInnerExtandedEta),
84 mDCALInnerEdge(geo.mDCALInnerEdge),
85 mShishKebabTrd1Modules(geo.mShishKebabTrd1Modules),
87 mPhiModuleSize(geo.mPhiModuleSize),
88 mEtaModuleSize(geo.mEtaModuleSize),
89 mPhiTileSize(geo.mPhiTileSize),
90 mEtaTileSize(geo.mEtaTileSize),
92 mIPDistance(geo.mIPDistance),
93 mLongModuleSize(geo.mLongModuleSize),
94 mShellThickness(geo.mShellThickness),
95 mZLength(geo.mZLength),
96 mSampling(geo.mSampling),
97 mECPbRadThickness(geo.mECPbRadThickness),
98 mECScintThick(geo.mECScintThick),
99 mNECLayers(geo.mNECLayers),
100 mNumberOfSuperModules(geo.mNumberOfSuperModules),
101 mEMCSMSystem(geo.mEMCSMSystem),
102 mFrontSteelStrip(geo.mFrontSteelStrip),
103 mLateralSteelStrip(geo.mLateralSteelStrip),
104 mPassiveScintThick(geo.mPassiveScintThick),
105 mPhiSuperModule(geo.mPhiSuperModule),
106 mNPhiSuperModule(geo.mNPhiSuperModule),
107 mTrd1Angle(geo.mTrd1Angle),
108 m2Trd1Dx2(geo.m2Trd1Dx2),
109 mPhiGapForSM(geo.mPhiGapForSM),
110 mTrd1AlFrontThick(geo.mTrd1AlFrontThick),
111 mTrd1BondPaperThick(geo.mTrd1BondPaperThick),
114 mSteelFrontThick(geo.mSteelFrontThick),
115 mCellIndexLookup(geo.mCellIndexLookup)
127 for (
auto icell = 0; icell <
mNCells; icell++) {
136 LOG(fatal) <<
"assignment operator, not implemented";
143 LOG(error) <<
"Do not call delete on me";
164 const std::string_view mctitle)
167 if (
name.length() == 0) {
175 LOG(info) <<
"\n current geometry is " << sGeom->
GetName() <<
" : you should not call " <<
name;
183 const std::string_view mcname,
const std::string_view mctitle)
185 using boost::algorithm::contains;
189 if (runNumber >= 104064 && runNumber < 140000) {
193 if (contains(geoName,
"FIRSTYEARV1") && geoName != std::string(
"")) {
194 LOG(info) <<
"o2::emcal::Geometry::GetInstanceFromRunNumber() *** ATTENTION *** \n"
195 <<
"\t Specified geometry name <<" << geoName <<
">> for run " << runNumber
196 <<
" is not considered! \n"
197 <<
"\t In use <<EMCAL_FIRSTYEARV1>>, check run number and year";
200 <<
"o2::emcal::Geometry::GetInstanceFromRunNumber() - Initialized geometry with name <<EMCAL_FIRSTYEARV1>>";
205 if (runNumber >= 140000 && runNumber <= 170593) {
208 if (contains(geoName,
"COMPLETEV1") && geoName != std::string(
"")) {
209 LOG(info) <<
"o2::emcal::Geometry::GetInstanceFromRunNumber() *** ATTENTION *** \n"
210 <<
"\t Specified geometry name <<" << geoName <<
">> for run " << runNumber
211 <<
" is not considered! \n"
212 <<
"\t In use <<EMCAL_COMPLETEV1>>, check run number and year";
215 <<
"o2::emcal::Geometry::GetInstanceFromRunNumber() - Initialized geometry with name <<EMCAL_COMPLETEV1>>";
219 if (runNumber > 176000 && runNumber <= 197692) {
223 if (contains(geoName,
"COMPLETE12SMV1") && geoName != std::string(
"")) {
224 LOG(info) <<
"o2::emcal::Geometry::GetInstanceFromRunNumber() *** ATTENTION *** \n"
225 <<
"\t Specified geometry name <<" << geoName <<
" >> for run " << runNumber
226 <<
" is not considered! \n"
227 <<
"\t In use <<EMCAL_COMPLETE12SMV1>>, check run number and year";
229 LOG(info) <<
"o2::emcal::Geometry::GetInstanceFromRunNumber() - Initialized geometry with name "
230 "<<EMCAL_COMPLETE12SMV1>>";
237 if (contains(geoName,
"DCAL_8SM") && geoName != std::string(
"")) {
238 LOG(info) <<
"o2::emcal::Geometry::GetInstanceFromRunNumber() *** ATTENTION *** \n"
239 <<
"\t Specified geometry name <<" << geoName <<
">> for run " << runNumber
240 <<
" is not considered! \n"
241 <<
"\t In use <<EMCAL_COMPLETE12SMV1_DCAL_8SM>>, check run number and year";
243 LOG(info) <<
"o2::emcal::Geometry::GetInstanceFromRunNumber() - Initialized geometry with name "
244 "<<EMCAL_COMPLETE12SMV1_DCAL_8SM>>";
255 using boost::algorithm::contains;
275 Float_t samplingFactorTranportModel = 1.;
279 if (contains(mcname,
"Geant3") || contains(mcname,
"Fluka")) {
280 samplingFactorTranportModel = 1.;
281 }
else if (contains(mcname,
"Geant4")) {
282 std::string physicslist = mctitle.substr(mctitle.find(
":") + 2).data();
283 LOG(info) <<
"Selected physics list: " << physicslist;
288 samplingFactorTranportModel = 0.81;
289 if (physicslist ==
"FTFP_BERT_EMV+optical") {
290 samplingFactorTranportModel = 0.821;
291 }
else if (physicslist ==
"FTFP_BERT_EMV+optical+biasing" || physicslist ==
"FTFP_INCLXX_EMV+optical") {
292 samplingFactorTranportModel = 0.81;
296 LOG(info) <<
"MC modeler <" << mcname <<
">, Title <" << mctitle <<
">: Sampling " << std::setw(2)
297 << std::setprecision(3) <<
mSampling <<
", model fraction with respect to G3 "
298 << samplingFactorTranportModel <<
", final sampling " <<
mSampling * samplingFactorTranportModel;
300 mSampling *= samplingFactorTranportModel;
305 using boost::algorithm::contains;
311 if (contains(
mGeoName,
"SHISH_77_TRD1_2X2_FINAL_110DEG")) {
324 if (!(contains(
mGeoName,
"EMCAL_PDC06") || contains(
mGeoName,
"EMCAL_WSUC") || contains(
mGeoName,
"EMCAL_COMPLETE") ||
325 contains(
mGeoName,
"EMCAL_COMPLETEV1") || contains(
mGeoName,
"EMCAL_COMPLETE12SMV1") ||
326 contains(
mGeoName,
"EMCAL_FIRSTYEAR") || contains(
mGeoName,
"EMCAL_FIRSTYEARV1"))) {
327 LOG(fatal) <<
"Init, " <<
mGeoName <<
" is an undefined geometry!\n";
335 if (contains(
mGeoName,
"COMPLETEV1")) {
340 if (contains(
mGeoName,
"DCAL_DEV")) {
342 }
else if (contains(
mGeoName,
"DCAL_8SM")) {
344 }
else if (contains(
mGeoName,
"DCAL")) {
399 if (contains(
mGeoName,
"FIRSTYEAR")) {
404 if (contains(
mGeoName,
"FIRSTYEARV1") || contains(
mGeoName,
"COMPLETEV1") || contains(
mGeoName,
"COMPLETE12SMV1")) {
419 if (contains(
mGeoName,
"COMPLETEV1")) {
422 }
else if (contains(
mGeoName,
"COMPLETE12SMV1")) {
429 if (contains(
mGeoName,
"DCAL_8SM")) {
431 }
else if (contains(
mGeoName,
"DCAL_DEV")) {
452 for (
int i = 0;
i < 2;
i++) {
456 }
else if (contains(
mGeoName,
"FIRSTYEAR")) {
457 for (
int i = 0;
i < 4;
i++) {
462 for (
int i = 0;
i < 10;
i++) {
471 for (
int i = 0;
i < 2;
i++) {
488 for (
int i = 0;
i < 2;
i++) {
514 LOG(error) <<
"Uknown SuperModule Type !!\n";
596 const double INNNER_EXTENDED_PHI =
599 TMath::Tan((TMath::Pi() / 2. - 8 *
mTrd1Angle * TMath::DegToRad() +
624 LOG(error) <<
"Unkown SM Type!!\n";
643 m->LocalToMaster(loc.data(), glob.data());
645 LOG(fatal) <<
"Geo matrixes are not loaded \n";
651 std::array<double, 3> tglob{}, tloc{};
652 vloc.GetXYZ(tloc.data());
654 vglob.SetXYZ(tglob[0], tglob[1], tglob[2]);
659 std::array<double, 3> loc{};
660 std::ranges::fill(glob, 0.0);
663 loc[0] = cellpos.X();
664 loc[1] = cellpos.Y();
665 loc[2] = cellpos.Z();
674 m->LocalToMaster(loc.data(), glob.data());
676 LOG(fatal) <<
"Geo matrixes are not loaded \n";
682 std::array<double, 3> glob{};
685 vglob.SetXYZ(glob[0], glob[1], glob[2]);
692 return std::make_tuple(vglob.Eta(), vglob.Phi());
703 for (
int i = 0;
i < supermoduleID;
i++) {
727 cellid += etaInModule;
739 int moduleEta = etaInSupermodule /
mNETAdiv,
740 modulePhi = phiInSupermodule /
mNPHIdiv,
741 moduleID = moduleEta * nModulesInSMPhi + modulePhi;
742 int etaInModule = etaInSupermodule %
mNETAdiv,
743 phiInModule = phiInSupermodule %
mNPHIdiv;
745 return std::make_tuple(phiInModule, etaInModule, moduleID);
753 LOG(
debug) <<
"Wrong cell indexes : SM " << nSupMod <<
", column (eta) " << ieta <<
", row (phi) " << iphi;
762 return GetAbsCellId(nSupMod, std::get<2>(indexmod), nIphi, nIeta);
782 for (
int isec = 0; isec < sector; isec++) {
788 return std::make_tuple(
row,
col);
793 if (col < 0 || col >= 4 *
GetNEta()) {
806 if (rowSM < nphism) {
842 Int_t colInModule = colSM %
mNETAdiv,
844 colInModule =
mNETAdiv - 1 - colInModule;
845 return std::make_tuple(
supermodule, std::get<2>(indexmod), rowInMOdule, colInModule);
864 phi = TVector2::Phi_0_2pi(phi);
867 for (Int_t
i = 0;
i < nphism;
i++) {
876 const Int_t nEtaThird =
GetNEta() / 3;
877 if (TMath::Abs(eta) < nEtaThird *
mTrd1Angle * TMath::DegToRad()) {
882 LOG(
debug) <<
"eta " << eta <<
" phi " << phi <<
" (" << std::setw(5) << std::setprecision(2)
883 << phi * TMath::RadToDeg() <<
") : nSupMod " << nSupMod <<
": #bound " <<
i;
895 phi = TVector2::Phi_0_2pi(phi);
913 for (Int_t
i = 1;
i < nphi;
i++) {
922 LOG(debug2) <<
" iphi " << iphi <<
" : dmin " << dmin <<
" (phi " << phi <<
", phiLoc " << phiLoc <<
")\n";
925 Double_t absEta = TMath::Abs(eta);
927 etaShift = iphi * neta,
933 for (Int_t
i = ieta + 1;
i < neta;
i++) {
945 LOG(debug2) <<
" ieta " << ieta <<
" : dmin " << dmin <<
" (eta=" << eta <<
") : nSupMod " << nSupMod;
950 ieta = (neta - 1) - ieta;
969 for (nSupMod = -1;
test >= 0;) {
994 return std::make_tuple(nSupMod, nModule, nIphi, nIeta);
1009 int nModulesInPhi = -1;
1012 nModulesInPhi =
mNPhi / 2;
1016 nModulesInPhi =
mNPhi / 3;
1019 nModulesInPhi =
mNPhi;
1022 return std::make_tuple(moduleID % nModulesInPhi, moduleID / nModulesInPhi);
1026 int etaInModule)
const
1031 int etaInSupermodule = etaOfModule *
mNETAdiv + (
mNETAdiv - 1 - etaInModule);
1032 int phiInSupermodule = phiOfModule *
mNPHIdiv + phiInModule;
1034 if (phiInSupermodule < 0 || etaInSupermodule < 0) {
1035 LOG(
debug) <<
" Supermodule " << supermoduleID <<
", Module " << moduleID <<
" (phi " << phiInModule <<
", eta " << etaInModule <<
")"
1036 <<
" => in Supermodule: eta " << etaInSupermodule <<
", phi " << phiInSupermodule;
1038 return std::make_tuple(phiInSupermodule, etaInSupermodule);
1054 row += supermoduleID / 2 * (24 + 1);
1057 column += supermoduleID % 2 * 48;
1059 column += supermoduleID % 2 * (48 + 1);
1062 return std::make_tuple(
static_cast<short>(
row),
static_cast<short>(column));
1067 if (supermoduleID == 13 || supermoduleID == 15 || supermoduleID == 17) {
1070 }
else if (supermoduleID == 18 || supermoduleID == 19) {
1074 return {iphi, ieta};
1079 if (supermoduleID == 13 || supermoduleID == 15 || supermoduleID == 17) {
1082 }
else if (supermoduleID == 18 || supermoduleID == 19) {
1086 return {iphi, ieta};
1096 Double_t xr = 0, yr = 0, zr = 0;
1103 Int_t nSupMod = std::get<0>(cellindex), nModule = std::get<1>(cellindex), phiInModule = std::get<2>(cellindex), etaInModule = std::get<3>(cellindex);
1105 Int_t iphi = std::get<0>(indexinsm), ieta = std::get<1>(indexinsm);
1109 if (nSupMod % 2 == 0) {
1126 if (nSupMod % 2 != 0) {
1127 iphi2 = (phiindex / 3 - 1) - iphi;
1131 if (nSupMod % 2 != 0) {
1132 iphi2 = (phiindex / 2 - 1) - iphi;
1137 if (nSupMod % 2 != 0) {
1138 iphi2 = (phiindex - 1) - iphi;
1143 LOG(
debug) <<
"absId " << absId <<
" nSupMod " << nSupMod <<
" iphi " << iphi <<
" ieta " << ieta <<
" xr " << xr
1144 <<
" yr " << yr <<
" zr " << zr;
1145 return {xr, yr, zr};
1152 Double_t xr = 0, yr = 0, zr = 0;
1155 Int_t kDCalshift = 8;
1157 Int_t iphim = -1, ietam = -1;
1164 Int_t nSupMod = std::get<0>(cellindex), nModule = std::get<1>(cellindex), phiInModule = std::get<2>(cellindex), etaInModule = std::get<3>(cellindex);
1166 iphim = std::get<0>(indmodep);
1167 ietam = std::get<1>(indmodep);
1169 Int_t iphi = std::get<0>(indexinsm), ieta = std::get<1>(indexinsm);
1172 if (nSupMod % 2 == 0) {
1175 if (etaInModule == 0) {
1183 ietam += kDCalshift;
1196 if (nSupMod % 2 != 0) {
1197 iphi2 = (nphiIndex / 3 - 1) - iphi;
1201 if (nSupMod % 2 != 0) {
1202 iphi2 = (nphiIndex / 2 - 1) - iphi;
1207 if (nSupMod % 2 != 0) {
1208 iphi2 = (nphiIndex - 1) - iphi;
1213 LOG(
debug) <<
"absId " << absId <<
" nSupMod " << nSupMod <<
" iphi " << iphi <<
" ieta " << ieta <<
" xr " << xr
1214 <<
" yr " << yr <<
" zr " << zr;
1215 return {xr, yr, zr};
1220 LOG(debug2) <<
" o2::emcal::Geometry::CreateListOfTrd1Modules() started\n";
1223 for (
int iz = 0; iz <
mNZ; iz++) {
1232 LOG(debug2) <<
" Already exits :\n";
1250 Int_t ieta = 0, nModule = 0;
1251 Double_t xr = 0., zr = 0., theta = 0., phi = 0., eta = 0.,
r = 0.,
x = 0.,
y = 0.;
1253 Double_t ytCenterModule = 0.0, ytCenterCell = 0.0;
1259 for (Int_t it = 0; it <
mNPhi; it++) {
1261 for (Int_t ic = 0; ic <
mNPHIdiv; ic++) {
1263 ytCenterCell = ytCenterModule +
mPhiTileSize * (2 * ic - 1) / 2.;
1265 ytCenterCell = ytCenterModule +
mPhiTileSize * (ic - 1);
1267 ytCenterCell = ytCenterModule;
1273 phi = TMath::ATan2(ytCenterCell, r0);
1276 LOG(debug2) <<
" ind " << std::setw(2) << std::setprecision(2) << ind <<
" : y " << std::setw(8)
1288 for (Int_t it = 0; it <
mNZ; it++) {
1290 nModule =
mNPhi * it;
1291 for (Int_t ic = 0; ic <
mNETAdiv; ic++) {
1295 ieta = std::get<1>(indexinsm);
1300 ieta = std::get<1>(indexinsm);
1305 ieta = std::get<1>(indexinsm);
1313 r = TMath::Sqrt(
x *
x +
y *
y + zr * zr);
1314 theta = TMath::ACos(zr /
r);
1325 LOG(debug2) <<
" ind " << std::setw(2) << std::setprecision(2) <<
i + 1 <<
" : z " << std::setw(8)
1345 ImpactOnEmcal({particle->Vx(), particle->Vy(), particle->Vz()}, particle->Theta(), particle->Phi(), absID, vimpact);
1358 vimpact.SetXYZ(0, 0, 0);
1360 if (phi == 0 || theta == 0) {
1365 Double_t factor = (
mIPDistance - vtx.Y()) / p.Y();
1366 direction = vtx + factor * p;
1373 std::array<double, 3> loc{}, loc2{}, loc3{};
1374 std::array<double, 3> glob{}, glob2{}, glob3{};
1385 Int_t nSupMod = std::get<0>(cellindex), nModule = std::get<1>(cellindex), phiInModule = std::get<2>(cellindex),
1386 etaInModule = std::get<3>(cellindex);
1388 Int_t phiInModule2 = -1, etaInModule2 = -1, absId2 = -1, absId3 = -1;
1389 if (etaInModule == 0) {
1394 absId2 =
GetAbsCellId(nSupMod, nModule, phiInModule, etaInModule2);
1395 if (phiInModule == 0) {
1400 absId3 =
GetAbsCellId(nSupMod, nModule, phiInModule2, etaInModule);
1421 m->LocalToMaster(loc.data(), glob.data());
1422 m->LocalToMaster(loc2.data(), glob2.data());
1423 m->LocalToMaster(loc3.data(), glob3.data());
1425 LOG(fatal) <<
"Geo matrixes are not loaded \n";
1429 Double_t
a = glob[1] * (glob2[2] - glob3[2]) + glob2[1] * (glob3[2] - glob[2]) + glob3[1] * (glob[2] - glob2[2]);
1430 Double_t
b = glob[2] * (glob2[0] - glob3[0]) + glob2[2] * (glob3[0] - glob[0]) + glob3[2] * (glob[0] - glob2[0]);
1431 Double_t
c = glob[0] * (glob2[1] - glob3[1]) + glob2[0] * (glob3[1] - glob[1]) + glob3[0] * (glob[1] - glob2[1]);
1432 Double_t d = glob[0] * (glob2[1] * glob3[2] - glob3[1] * glob2[2]) +
1433 glob2[0] * (glob3[1] * glob[2] - glob[1] * glob3[2]) +
1434 glob3[0] * (glob[1] * glob2[2] - glob2[1] * glob[2]);
1439 Double_t norm = TMath::Sqrt(
a *
a +
b *
b +
c *
c);
1440 std::array<double, 3> glob4{};
1443 if (point.Dot(dir) < 0) {
1446 glob4[0] = glob[0] - dist *
a / norm;
1447 glob4[1] = glob[1] - dist *
b / norm;
1448 glob4[2] = glob[2] - dist *
c / norm;
1449 d = glob4[0] *
a + glob4[1] *
b + glob4[2] *
c;
1454 Double_t den =
a * (vtx.X() - direction.X()) +
b * (vtx.Y() - direction.Y()) +
c * (vtx.Z() - direction.Z());
1456 LOG(error) <<
"ImpactOnEmcal() No solution :\n";
1460 Double_t
length =
a * vtx.X() +
b * vtx.Y() +
c * vtx.Z() + d;
1463 vimpact.SetXYZ(vtx.X() +
length * (direction.X() - vtx.X()), vtx.Y() +
length * (direction.Y() - vtx.Y()),
1464 vtx.Z() +
length * (direction.Z() - vtx.Z()));
1467 vimpact.SetXYZ(vimpact.Z() + dist *
a / norm, vimpact.Y() + dist *
b / norm, vimpact.Z() + dist *
c / norm);
1488 Double_t
r = sqrt(pnt.X() * pnt.X() + pnt.Y() * pnt.Y());
1493 Double_t theta = TMath::ATan2(
r, pnt.Z());
1498 eta = -TMath::Log(TMath::Tan(theta / 2.));
1504 Double_t phi = TMath::ATan2(pnt.Y(), pnt.X()) * 180. / TMath::Pi();
1524 LOG(fatal) <<
"Wrong supermodule index -> " << smod;
1529 LOG(info) <<
"Loading EMCAL misalignment matrix for SM " << smod <<
" from GeoManager.";
1532 LOG(fatal) <<
"Cannot find EMCAL misalignment matrices! Recover them either: \n"
1533 <<
"\t - importing TGeoManager from file geometry.root or \n"
1534 <<
"\t - from OADB in file OADB/EMCAL/EMCALlocal2master.root or \n"
1535 <<
"\t - from OCDB in directory OCDB/EMCAL/Align/Data/ or \n"
1536 <<
"\t - from AliESDs (not in AliAOD) via AliESDRun::GetEMCALMatrix(Int_t superModIndex). \n"
1537 <<
"Store them via AliEMCALGeometry::SetMisalMatrix(Int_t superModIndex)";
1547 LOG(fatal) <<
"Wrong supermodule index -> " << smod;
1559 for (Int_t
i = 0;
i < smod + 1;
i++) {
1569 TString smName =
"";
1582 LOG(error) <<
"Unkown SM Type!!\n";
1585 std::string
path = fmt::format(
"/cave/barrel_1/{}_{}", smName.Data(), smOrder);
1587 if (!gGeoManager->cd(
path.c_str())) {
1588 LOG(fatal) <<
"Geo manager can not find path " <<
path <<
"!\n";
1591 return gGeoManager->GetCurrentMatrix();
1595 std::span<const float, 15> misaligTransShifts, std::span<const float, 15> misaligRotShifts,
1596 std::span<float, 3> global)
const
1607 gGeoManager->cd(
"/cave/barrel_1/");
1608 TGeoNode* geoXEn1 = gGeoManager->GetCurrentNode();
1609 std::vector<TGeoNodeMatrix*> geoSM(nSMod);
1610 std::vector<TGeoVolume*> geoSMVol(nSMod);
1611 std::vector<TGeoShape*> geoSMShape(nSMod);
1612 std::vector<TGeoBBox*> geoBox(nSMod);
1613 std::vector<TGeoMatrix*> geoSMMatrix(nSMod);
1615 for (
int iSM = 0; iSM < nSMod; iSM++) {
1616 geoSM[iSM] =
dynamic_cast<TGeoNodeMatrix*
>(geoXEn1->GetDaughter(iSM));
1617 geoSMVol[iSM] = geoSM[iSM]->GetVolume();
1618 geoSMShape[iSM] = geoSMVol[iSM]->GetShape();
1619 geoBox[iSM] =
dynamic_cast<TGeoBBox*
>(geoSMShape[iSM]);
1620 geoSMMatrix[iSM] = geoSM[iSM]->GetMatrix();
1648 if (dcol >= 47.5 || dcol < -0.5) {
1649 LOG(error) <<
"Bad tower coordinate dcol=" << dcol <<
", where dcol >= 47.5 || dcol<-0.5; org: " << dcolorg;
1652 if (drow >= 23.5 || drow < -0.5) {
1653 LOG(error) <<
"Bad tower coordinate drow=" << drow <<
", where drow >= 23.5 || drow<-0.5; org: " << droworg;
1656 if (sm >= nSMod || sm < 0) {
1657 LOG(error) <<
"Bad SM number sm=" << nSMod <<
", where sm >= " << sm <<
" || sm < 0\n";
1661 istrip =
int((dcol + 0.5) / 2);
1664 teta1 = TMath::DegToRad() * istrip * 1.5;
1669 for (
int is = 0; is <= istrip; is++) {
1670 teta1 = TMath::DegToRad() * (is * 1.5 + 0.75);
1672 zIs = zIs + 2 * dz * TMath::Cos(teta1);
1675 zIs + 2 * dz * TMath::Cos(teta1) + 2 * dz * TMath::Sin(teta1) * TMath::Tan(teta1 - 0.75 * TMath::DegToRad());
1679 z0 = dz * (dcol - 2 * istrip + 0.5);
1680 zb = (2 * dz - z0 -
depth * TMath::Tan(teta1));
1682 z = zIs - zb * TMath::Cos(teta1);
1683 y =
depth / TMath::Cos(teta1) + zb * TMath::Sin(teta1);
1685 x = (drow + 0.5) * dx;
1690 double xx =
y - geoBox[sm]->GetDX();
1691 double yy = -
x + geoBox[sm]->GetDY();
1692 double zz =
z - geoBox[sm]->GetDZ();
1693 const std::array<double, 3> localIn = {xx, yy, zz};
1694 std::array<double, 3> dglobal{};
1698 geoSMMatrix[sm]->LocalToMaster(localIn.data(), dglobal.data());
1703 if (sm == 2 || sm == 3) {
1704 global[0] = dglobal[0] + misaligTransShifts[3] + misaligRotShifts[3] * TMath::Sin(TMath::DegToRad() * 20);
1705 global[1] = dglobal[1] + misaligTransShifts[4] + misaligRotShifts[4] * TMath::Cos(TMath::DegToRad() * 20);
1706 global[2] = dglobal[2] + misaligTransShifts[5];
1707 }
else if (sm == 0 || sm == 1) {
1708 global[0] = dglobal[0] + misaligTransShifts[0];
1709 global[1] = dglobal[1] + misaligTransShifts[1];
1710 global[2] = dglobal[2] + misaligTransShifts[2];
1712 LOG(info) <<
"Careful, correction not implemented yet!\n";
1713 global[0] = dglobal[0];
1714 global[1] = dglobal[1];
1715 global[2] = dglobal[2];
1718 LOG(fatal) <<
"Geometry boxes information, check that geometry.root is loaded\n";
1729 LOG(fatal) <<
"Wrong supermodule index -> " << smod << std::endl;
1735 LOG(info) <<
"Using CCDB to obtain EMCal alignment.";
1737 std::map<std::string, std::string> metadata;
1738 api.
init(
"http://alice-ccdb.cern.ch");
1742 auto* mat =
dynamic_cast<TGeoHMatrix*
>(matrices->At(iSM));
1747 LOG(info) <<
"Could not obtain Alignment Matrix for SM " << iSM;
1772 int i = nsupmod / 2;
1778 int i = nsupmod / 2;
1803 auto supermoduleID = std::get<0>(cellindex);
1806 int row = std::get<0>(etaphishift),
col = std::get<1>(etaphishift);
1808 int ddlInSupermoudel = -1;
1810 ddlInSupermoudel = 0;
1811 }
else if ((8 <=
row &&
row < 16 && 24 <=
col &&
col < 48) || (16 <=
row &&
row < 24)) {
1812 ddlInSupermoudel = 1;
1814 if (supermoduleID % 2 == 1) {
1815 ddlInSupermoudel = 1 - ddlInSupermoudel;
1818 return std::make_tuple(supermoduleID * 2 + ddlInSupermoudel,
row,
col);
1827 if (absId1 == absId2) {
1828 return {
false, rowDiff, colDiff};
1835 return {
false, rowDiff, colDiff};
1839 const auto [smUnused1, iTower1, iIphi1, iIeta1] =
GetCellIndex(absId1);
1842 const auto [smUnused2, iTower2, iIphi2, iIeta2] =
GetCellIndex(absId2);
1846 const int tcardRow0 = row1 - row1 % 8;
1847 const int tcardCol0 = col1 - col1 % 2;
1850 const int rowOffset = row2 - tcardRow0;
1851 const int colOffset = col2 - tcardCol0;
1854 rowDiff = row1 - row2;
1855 colDiff = col1 - col2;
1857 const bool sameTCard = (rowOffset >= 0 && rowOffset < 8 &&
1858 colOffset >= 0 && colOffset < 2);
1859 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.
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 mDCALInnerEdge
Inner edge for DCAL.
void CreateListOfTrd1Modules()
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
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
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.
void GetGlobal(std::span< const double, 3 > loc, std::span< double, 3 > glob, int iSM) const
Figure out the global coordinates from local coordinates on a supermodule.
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 RecalculateTowerPosition(Float_t drow, Float_t dcol, const Int_t sm, const Float_t depth, std::span< const float, 15 > misaligTransShifts, std::span< const float, 15 > misaligRotShifts, std::span< float, 3 > global) const
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...
std::array< float, 3 > mParSM
SM sizes as in GEANT (TRD1)
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
std::array< const TGeoHMatrix *, EMCAL_MODULES > SMODULEMATRIX
Orientations of EMCAL super modules.
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.
std::array< float, 3 > mEnvelop
The GEANT TUB for the detector.
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_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"