X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=EMCAL%2FAliEMCALGeometry.cxx;h=e4d7eabc729541acebe165ce1fc6bc026e2a91da;hb=c4227ef74f0f39b68584382959b9350ada8918bf;hp=de3e7ceb8ff0213ab41b22e6b18af59e939d53b8;hpb=126215a53eb5f39df0bba6f05fd92078d7160f81;p=u%2Fmrichter%2FAliRoot.git diff --git a/EMCAL/AliEMCALGeometry.cxx b/EMCAL/AliEMCALGeometry.cxx index de3e7ceb8ff..e4d7eabc729 100644 --- a/EMCAL/AliEMCALGeometry.cxx +++ b/EMCAL/AliEMCALGeometry.cxx @@ -40,7 +40,9 @@ // the sizes updated with last information from production // drawing (end of October 2010). // -// EMCAL_COMPLETEV1: Same fixes as FIRSTYEAR and 10 SM instead of 10+2 half SM +// EMCAL_COMPLETEV1: Same fixes as FIRSTYEAR and 10 SM instead of 10 + 2 one_third SM, for 2011 runs +// +// EMCAL_COMPLETE12SMV1: contains 12 SM for runs from year 2012 and on // // EMCAL_WSUC (Wayne State test stand) // = no definite equivalent in old notation, was only used by @@ -80,7 +82,7 @@ // You have to use just the correct name of geometry. If name is empty string the // default name of geometry will be used. // -// AliEMCALGeometry* geom = new AliEMCALGeometry("EMCAL_COMPLETEV1","EMCAL"); +// AliEMCALGeometry* geom = new AliEMCALGeometry("EMCAL_COMPLETE12SMV1","EMCAL"); // TGeoManager::Import("geometry.root"); // // MC: If you work with MC data you have to get geometry the next way: @@ -104,6 +106,7 @@ //#include // --- AliRoot header files --- +#include "AliLog.h" #include "AliEMCALGeometry.h" #include "AliEMCALShishKebabTrd1Module.h" @@ -111,7 +114,7 @@ ClassImp(AliEMCALGeometry) // these initialisations are needed for a singleton AliEMCALGeometry *AliEMCALGeometry::fgGeom = 0; -const Char_t* AliEMCALGeometry::fgkDefaultGeometryName = "EMCAL_COMPLETEV1"; +const Char_t* AliEMCALGeometry::fgkDefaultGeometryName = "EMCAL_COMPLETE12SMV1"; //____________________________________________________________________________ AliEMCALGeometry::AliEMCALGeometry(): @@ -157,6 +160,7 @@ AliEMCALGeometry::AliEMCALGeometry(const AliEMCALGeometry & geo) fIPDistance(geo.fIPDistance),fLongModuleSize(geo.fLongModuleSize),fShellThickness(geo.fShellThickness), fZLength(geo.fZLength),fSampling(geo.fSampling),fUseExternalMatrices(geo.fUseExternalMatrices) { + // Copy constarctor fEnvelop[0] = geo.fEnvelop[0]; fEnvelop[1] = geo.fEnvelop[1]; fEnvelop[2] = geo.fEnvelop[2]; @@ -186,7 +190,6 @@ AliEMCALGeometry::AliEMCALGeometry(const Text_t* name, const Text_t* title, fIPDistance(0.),fLongModuleSize(0.),fShellThickness(0.), fZLength(0.),fSampling(0.), fUseExternalMatrices(kFALSE) { - // ctor only for normal usage fEMCGeometry = new AliEMCALEMCGeometry(name,title,mcname,mctitle); @@ -253,7 +256,8 @@ AliEMCALGeometry::AliEMCALGeometry(const Text_t* name, const Text_t* title, } //____________________________________________________________________________ -AliEMCALGeometry & AliEMCALGeometry::operator = (const AliEMCALGeometry & /*rvalue*/) { +AliEMCALGeometry & AliEMCALGeometry::operator = (const AliEMCALGeometry & /*rvalue*/) +{ //assing operator Fatal("assignment operator", "not implemented") ; return *this ; @@ -273,12 +277,13 @@ AliEMCALGeometry::~AliEMCALGeometry(void) delete fkSModuleMatrix[smod] ; fkSModuleMatrix[smod]=0 ; } - delete fEMCGeometry; fEMCGeometry = 0 ; + delete fEMCGeometry; // fEMCGeometry = 0 ; } } //______________________________________________________________________ -AliEMCALGeometry * AliEMCALGeometry::GetInstance(){ +AliEMCALGeometry * AliEMCALGeometry::GetInstance() +{ // Returns the pointer of the unique instance AliEMCALGeometry * rv = static_cast( fgGeom ); @@ -287,7 +292,8 @@ AliEMCALGeometry * AliEMCALGeometry::GetInstance(){ //______________________________________________________________________ AliEMCALGeometry* AliEMCALGeometry::GetInstance(const Text_t* name, const Text_t* title, - const Text_t* mcname, const Text_t* mctitle ){ + const Text_t* mcname, const Text_t* mctitle ) +{ // Returns the pointer of the unique instance AliEMCALGeometry * rv = 0; @@ -338,12 +344,12 @@ void AliEMCALGeometry::GetGlobal(const Double_t *loc, Double_t *glob, int ind) c // matrix stored by the geometry manager (allows for misaligned // geometry) - const TGeoHMatrix* m = GetMatrixForSuperModule(ind); - if(m) { - m->LocalToMaster(loc, glob); - } else { - AliFatal("Geo matrixes are not loaded \n") ; - } + const TGeoHMatrix* m = GetMatrixForSuperModule(ind); + if(m) { + m->LocalToMaster(loc, glob); + } else { + AliFatal("Geo matrixes are not loaded \n") ; + } } //________________________________________________________________________________________________ @@ -369,9 +375,8 @@ void AliEMCALGeometry::GetGlobal(Int_t absId , double glob[3]) const glob[0]=glob[1]=glob[2]=0.0; // bad case if(RelPosCellInSModule(absId, loc)) { GetCellIndex(absId, nSupMod, nModule, nIphi, nIeta); - - const TGeoHMatrix* m = GetMatrixForSuperModule(nSupMod); - if(m) { + const TGeoHMatrix* m = GetMatrixForSuperModule(nSupMod); + if(m) { m->LocalToMaster(loc, glob); } else { AliFatal("Geo matrixes are not loaded \n") ; @@ -387,10 +392,8 @@ void AliEMCALGeometry::GetGlobal(Int_t absId , TVector3 &vglob) const GetGlobal(absId, glob); vglob.SetXYZ(glob[0], glob[1], glob[2]); - } - //______________________________________________________________________ void AliEMCALGeometry::PrintCellIndexes(Int_t absId, int pri, const char *tit) const { @@ -457,8 +460,10 @@ Int_t AliEMCALGeometry::GetAbsCellId(Int_t nSupMod, Int_t nModule, Int_t nIphi, // 0 <= nIeta < fNETAdiv // 0 <= absid < fNCells static Int_t id=0; // have to change from 0 to fNCells-1 - if(fKey110DEG == 1 && nSupMod >= 10) { // 110 degree case; last two supermodules + if(fKey110DEG == 1 && nSupMod >= 10 && !fGeoName.Contains("12SMV1")) { // 110 degree case; last two supermodules halfsupermodules id = fNCellsInSupMod*10 + (fNCellsInSupMod/2)*(nSupMod-10); + } else if(fKey110DEG == 1 && nSupMod >= 10 && fGeoName.Contains("12SMV1")) { // 110 degree case; last two supermodules 1/3 supermodules + id = fNCellsInSupMod*10 + (fNCellsInSupMod/3)*(nSupMod-10); } else { id = fNCellsInSupMod*nSupMod; } @@ -495,6 +500,16 @@ void AliEMCALGeometry::GetModuleIndexesFromCellIndexesInSModule(Int_t nSupMod, Int_t AliEMCALGeometry::GetAbsCellIdFromCellIndexes(Int_t nSupMod, Int_t iphi, Int_t ieta) const { // Transition from super module number(nSupMod) and cell indexes (ieta,iphi) to absId + + // Check if the indeces correspond to existing SM or tower indeces + if(iphi < 0 || iphi >= AliEMCALGeoParams::fgkEMCALRows || + ieta < 0 || ieta >= AliEMCALGeoParams::fgkEMCALCols || + nSupMod < 0 || nSupMod >= GetNumberOfSuperModules() ) + { + AliDebug(1,Form("Wrong cell indexes : SM %d, column (eta) %d, row (phi) %d", nSupMod,ieta,iphi)); + return -1 ; + } + static Int_t ietam=-1, iphim=-1, nModule=-1; static Int_t nIeta=-1, nIphi=-1; // cell indexes in module @@ -503,7 +518,7 @@ Int_t AliEMCALGeometry::GetAbsCellIdFromCellIndexes(Int_t nSupMod, Int_t iphi, nIeta = ieta%fNETAdiv; nIeta = fNETAdiv - 1 - nIeta; nIphi = iphi%fNPHIdiv; - + return GetAbsCellId(nSupMod, nModule, nIphi, nIeta); } @@ -546,10 +561,14 @@ Bool_t AliEMCALGeometry::GetAbsCellIdFromEtaPhi(Double_t eta, Double_t phi, Int_ phi = TVector2::Phi_0_2pi(phi); phiLoc = phi - fPhiCentersOfSM[nSupMod/2]; nphi = fPhiCentersOfCells.GetSize(); - if(nSupMod>=10) { - phiLoc = phi - 190.*TMath::DegToRad(); + if(nSupMod>=10 && !fGeoName.Contains("12SMV1")) { + phiLoc = phi - 190.*TMath::DegToRad(); // half-size case... the reference for the loc is still 190 deg..? nphi /= 2; } + if(nSupMod>=10 && fGeoName.Contains("12SMV1")) { + // in the one_third case the variable fPhiCentersOfSM behaves like for the full_module. + nphi /= 3; + } dmin = TMath::Abs(fPhiCentersOfCells[0]-phiLoc); iphi = 0; @@ -559,7 +578,7 @@ Bool_t AliEMCALGeometry::GetAbsCellIdFromEtaPhi(Double_t eta, Double_t phi, Int_ dmin = d; iphi = i; } - // printf(" i %i : d %f : dmin %f : fPhiCentersOfCells[i] %f \n", i, d, dmin, fPhiCentersOfCells[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 AliDebug(2,Form(" iphi %i : dmin %f (phi %f, phiLoc %f ) ", iphi, dmin, phi, phiLoc)); @@ -576,19 +595,11 @@ Bool_t AliEMCALGeometry::GetAbsCellIdFromEtaPhi(Double_t eta, Double_t phi, Int_ } } AliDebug(2,Form(" ieta %i : dmin %f (eta=%f) : nSupMod %i ", ieta, dmin, eta, nSupMod)); - - if(eta<0) iphi = (nphi-1) - iphi; - - //patch for mapping following alice convention - if(nSupMod%2 == 0) - ieta = (fCentersOfCellsEtaDir.GetSize()-1)-ieta;// 47-ieta, revert the ordering on A side in order to keep convention. - else { - if(nSupMod<10) - iphi = (fCentersOfCellsPhiDir.GetSize()-1) -iphi;// 23-iphi, revert the ordering on C side in order to keep convention. - else - iphi = (fCentersOfCellsPhiDir.GetSize()/2-1)-iphi;// 11-iphi, revert the ordering on C side in order to keep convention. - } - + + //patch for mapping following alice convention + if(nSupMod%2 == 0) + ieta = (fCentersOfCellsEtaDir.GetSize()-1)-ieta;// 47-ieta, revert the ordering on A side in order to keep convention. + absId = GetAbsCellIdFromCellIndexes(nSupMod, iphi, ieta); return kTRUE; @@ -622,10 +633,13 @@ Bool_t AliEMCALGeometry::GetCellIndex(Int_t absId,Int_t &nSupMod,Int_t &nModule, if(!CheckAbsCellId(absId)) return kFALSE; sm10 = fNCellsInSupMod*10; - if(fKey110DEG == 1 && absId >= sm10) { // 110 degree case; last two supermodules + if(fKey110DEG == 1 && absId >= sm10 && !fGeoName.Contains("12SMV1")) { // 110 degree case; last two supermodules are halfsupermodules nSupMod = (absId-sm10) / (fNCellsInSupMod/2) + 10; tmp = (absId-sm10) % (fNCellsInSupMod/2); - } else { + } else if(fKey110DEG == 1 && absId >= sm10 && fGeoName.Contains("12SMV1")) { // 110 degree case; last two supermodules are 1/3 supermodules + nSupMod = (absId-sm10) / (fNCellsInSupMod/3) + 10; + tmp = (absId-sm10) % (fNCellsInSupMod/3); + } else { nSupMod = absId / fNCellsInSupMod; tmp = absId % fNCellsInSupMod; } @@ -659,8 +673,9 @@ void AliEMCALGeometry::GetModulePhiEtaIndexInSModule(Int_t nSupMod, Int_t nModul // iphim - have to change from 0 to nphi-1 (fNPhi-1 or fNPhi/2-1) static Int_t nphi=-1; - if(fKey110DEG == 1 && nSupMod>=10) nphi = fNPhi/2; - else nphi = fNPhi; + if(fKey110DEG == 1 && nSupMod>=10 && !fGeoName.Contains("12SMV1") ) nphi = fNPhi/2; // halfSM + else if(fKey110DEG == 1 && nSupMod>=10 && fGeoName.Contains("12SMV1") ) nphi = fNPhi/3; // 1/3 SM + else nphi = fNPhi; // full SM ietam = nModule/nphi; iphim = nModule%nphi; @@ -679,7 +694,7 @@ int &iphi, int &ieta) const // nIphi - cell number in phi driection inside module; 0<= nIphi < fNPHIdiv; // nIeta - cell number in eta driection inside module; 0<= nIeta < fNETAdiv; // - // OUT: + // OUT: // ieta, iphi - indexes of cell(tower) in two dimensional grid of SM // ieta - have to change from 0 to (fNZ*fNETAdiv-1) // iphi - have to change from 0 to (fNPhi*fNPHIdiv-1 or fNPhi*fNPHIdiv/2-1) @@ -696,7 +711,6 @@ int &iphi, int &ieta) const nSupMod, nModule, nIphi, nIeta, ieta, iphi)); } - // Methods for AliEMCALRecPoint - Feb 19, 2006 //________________________________________________________________________________________________ Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, Double_t &xr, Double_t &yr, Double_t &zr) const @@ -711,8 +725,15 @@ Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, Double_t &xr, Double_t // xr,yr,zr - x,y,z coordinates of cell with absId inside SM // Shift index taking into account the difference between standard SM - // and SM of half size in phi direction - const Int_t kphiIndexShift = fCentersOfCellsPhiDir.GetSize()/4; // Nov 22, 2006; was 6 for cas 2X2 + // and SM of half (or one third) size in phi direction + + Int_t workaround; // a small trick to be able to define the const variable kphiIndexShift + //if half, two parts, 1/4 wide, should be remove. In case of one_third SM, the two parts to be removed are 1/3 each + if(fKey110DEG == 1 && !fGeoName.Contains("12SMV1")) workaround=4; // half SM case + else workaround=3; // one third of SM case + const Int_t kphiIndexShift = fCentersOfCellsPhiDir.GetSize()/workaround; + const Int_t kphiRangeSmallSM = fCentersOfCellsPhiDir.GetSize()-2*kphiIndexShift; + static Int_t nSupMod=-1, nModule=-1, nIphi=-1, nIeta=-1, iphi=-1, ieta=-1; if(!CheckAbsCellId(absId)) return kFALSE; @@ -735,7 +756,7 @@ Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, Double_t &xr, Double_t } else { if(nSupMod%2 != 0) - iphi2 = (fCentersOfCellsPhiDir.GetSize()/2-1)-iphi;// 11-iphi, revert the ordering on C side in order to keep convention. + iphi2 = (kphiRangeSmallSM-1)-iphi;// 11-iphi [1/2SM] or 7-iphi [1/3SM], revert the ordering on C side in order to keep convention. yr = fCentersOfCellsPhiDir.At(iphi2 + kphiIndexShift); } AliDebug(1,Form("absId %i nSupMod %i iphi %i ieta %i xr %f yr %f zr %f ",absId,nSupMod,iphi,ieta,xr,yr,zr)); @@ -787,8 +808,15 @@ Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, Double_t distEff, Doub // xr,yr,zr - x,y,z coordinates of cell with absId inside SM // Shift index taking into account the difference between standard SM - // and SM of half size in phi direction - const Int_t kphiIndexShift = fCentersOfCellsPhiDir.GetSize()/4; // Nov 22, 2006; was 6 for cas 2X2 + // and SM of half (or one third) size in phi direction + + Int_t workaround; // a small trick to be able to define the const variable kphiIndexShift + //if half, two parts, 1/4 wide, should be remove. In case of one_third SM, the two parts to be removed are 1/3 each + if(fKey110DEG == 1 && !fGeoName.Contains("12SMV1")) workaround=4; // half SM case + else workaround=3; // one third of SM case + const Int_t kphiIndexShift = fCentersOfCellsPhiDir.GetSize()/workaround; + const Int_t kphiRangeSmallSM = fCentersOfCellsPhiDir.GetSize()-2*kphiIndexShift; + static Int_t nSupMod=0, nModule=-1, nIphi=-1, nIeta=-1, iphi=-1, ieta=-1; static Int_t iphim=-1, ietam=-1; static AliEMCALShishKebabTrd1Module *mod = 0; @@ -818,9 +846,9 @@ Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, Double_t distEff, Doub yr = fCentersOfCellsPhiDir.At(iphi2); } else { - if(nSupMod%2 != 0) - iphi2 = (fCentersOfCellsPhiDir.GetSize()/2-1)-iphi;// 11-iphi, revert the ordering on C side in order to keep convention. - yr = fCentersOfCellsPhiDir.At(iphi2 + kphiIndexShift); + if(nSupMod%2 != 0) + iphi2 = (kphiRangeSmallSM-1)-iphi;// 11-iphi [1/2SM] or 7-iphi [1/3SM], revert the ordering on C side in order to keep convention. + yr = fCentersOfCellsPhiDir.At(iphi2 + kphiIndexShift); } AliDebug(1,Form("absId %i nSupMod %i iphi %i ieta %i xr %f yr %f zr %f ",absId,nSupMod,iphi,ieta,xr,yr,zr)); @@ -828,7 +856,6 @@ Bool_t AliEMCALGeometry::RelPosCellInSModule(Int_t absId, Double_t distEff, Doub return kTRUE; } - //________________________________________________________________________________________________ void AliEMCALGeometry::CreateListOfTrd1Modules() { @@ -944,7 +971,6 @@ void AliEMCALGeometry::CreateListOfTrd1Modules() } - //________________________________________________________________________________________________ AliEMCALShishKebabTrd1Module* AliEMCALGeometry::GetShishKebabModule(Int_t neta) const { @@ -990,7 +1016,6 @@ void AliEMCALGeometry::PrintGeometryGeoUtils() printf(" ind %2.2i : y %8.3f : phi %7.5f(%6.2f) \n", i, fCentersOfCellsPhiDir.At(i), phi, phi*TMath::RadToDeg()); } - } //____________________________________________________________________________ @@ -1102,7 +1127,8 @@ void AliEMCALGeometry::ImpactOnEmcal(TVector3 vtx, Double_t theta, Double_t phi, } //_____________________________________________________________________________ -Bool_t AliEMCALGeometry::IsInEMCAL(Double_t x, Double_t y, Double_t z) const { +Bool_t AliEMCALGeometry::IsInEMCAL(Double_t x, Double_t y, Double_t z) const +{ // Checks whether point is inside the EMCal volume, used in AliEMCALv*.cxx // // Code uses cylindrical approximation made of inner radius (for speed) @@ -1133,7 +1159,8 @@ Bool_t AliEMCALGeometry::IsInEMCAL(Double_t x, Double_t y, Double_t z) const { //________________________________________________________________________________________________ Int_t AliEMCALGeometry::GetAbsTRUNumberFromNumberInSm(const Int_t row, const Int_t col, const Int_t sm) const -{ // Nov 6, 2007 +{ + // Nov 6, 2007 // Get TRU absolute number from column, row and Super Module number Int_t itru = row + col*fEMCGeometry->GetNModulesInTRUPhi() + sm*fEMCGeometry->GetNTRU(); // printf(" GetAbsTRUNumberFromNumberInSm : row %2i col %2i sm %2i -> itru %2i\n", row, col, sm, itru); @@ -1143,88 +1170,76 @@ Int_t AliEMCALGeometry::GetAbsTRUNumberFromNumberInSm(const Int_t row, const Int //________________________________________________________________________________________________ Bool_t AliEMCALGeometry::GetAbsFastORIndexFromTRU(const Int_t iTRU, const Int_t iADC, Int_t& id) const { - //Trigger mapping method, get FastOr Index from TRU + //Trigger mapping method, get FastOr Index from TRU if (iTRU > 31 || iTRU < 0 || iADC > 95 || iADC < 0) - { - AliError("TRU out of range!"); - return kFALSE; - } - - id = ( iTRU % 2 ) ? iADC%4 + 4 * (23 - int(iADC/4)) : (3 - iADC%4) + 4 * int(iADC/4); - - id += iTRU * 96; + { + AliError("TRU out of range!"); + return kFALSE; + } - return kTRUE; + id = ( iTRU % 2 ) ? iADC%4 + 4 * (23 - int(iADC/4)) : (3 - iADC%4) + 4 * int(iADC/4); + id += iTRU * 96; + return kTRUE; } //________________________________________________________________________________________________ Bool_t AliEMCALGeometry::GetTRUFromAbsFastORIndex(const Int_t id, Int_t& iTRU, Int_t& iADC) const { + //Trigger mapping method, get TRU number from FastOr Index - //Trigger mapping method, get TRU number from FastOr Index - - if (id > 3071 || id < 0) - { - AliError("Id out of range!"); - return kFALSE; - } - - iTRU = id / 96; - - iADC = id % 96; - - iADC = ( iTRU % 2 ) ? iADC%4 + 4 * (23 - int(iADC/4)) : (3 - iADC%4) + 4 * int(iADC/4); + if (id > 3071 || id < 0) + { + AliError("Id out of range!"); + return kFALSE; + } - return kTRUE; + iTRU = id / 96; + iADC = id % 96; + iADC = ( iTRU % 2 ) ? iADC%4 + 4 * (23 - int(iADC/4)) : (3 - iADC%4) + 4 * int(iADC/4); + return kTRUE; } //________________________________________________________________________________________________ Bool_t AliEMCALGeometry::GetPositionInTRUFromAbsFastORIndex(const Int_t id, Int_t& iTRU, Int_t& iEta, Int_t& iPhi) const { - //Trigger mapping method, get position in TRU from FasOr Index + //Trigger mapping method, get position in TRU from FasOr Index - Int_t iADC=-1; - if (!GetTRUFromAbsFastORIndex(id, iTRU, iADC)) return kFALSE; + Int_t iADC=-1; + if (!GetTRUFromAbsFastORIndex(id, iTRU, iADC)) return kFALSE; - Int_t x = iADC / 4; - Int_t y = iADC % 4; - - if ( iTRU % 2 ) // C side - { - iEta = 23 - x; - iPhi = y; - } - else // A side - { - iEta = x; - iPhi = 3 - y; - } - - return kTRUE; + Int_t x = iADC / 4; + Int_t y = iADC % 4; + if ( iTRU % 2 ) // C side + { + iEta = 23 - x; + iPhi = y; + } + else // A side + { + iEta = x; + iPhi = 3 - y; + } + return kTRUE; } //________________________________________________________________________________________________ Bool_t AliEMCALGeometry::GetPositionInSMFromAbsFastORIndex(const Int_t id, Int_t& iSM, Int_t& iEta, Int_t& iPhi) const { - //Trigger mapping method, get position in Super Module from FasOr Index + //Trigger mapping method, get position in Super Module from FasOr Index - Int_t iTRU=-1; - - if (!GetPositionInTRUFromAbsFastORIndex(id, iTRU, iEta, iPhi)) return kFALSE; - - if (iTRU % 2) // C side - { - iSM = 2 * ( int( int(iTRU / 2) / 3 ) ) + 1; - } - else // A side - { - iSM = 2 * ( int( int(iTRU / 2) / 3 ) ); - } - - iPhi += 4 * int((iTRU % 6) / 2); - - return kTRUE; + Int_t iTRU=-1; + if (!GetPositionInTRUFromAbsFastORIndex(id, iTRU, iEta, iPhi)) return kFALSE; + if (iTRU % 2) // C side + { + iSM = 2 * ( int( int(iTRU / 2) / 3 ) ) + 1; + } + else // A side + { + iSM = 2 * ( int( int(iTRU / 2) / 3 ) ); + } + iPhi += 4 * int((iTRU % 6) / 2); + return kTRUE; } //________________________________________________________________________________________________ @@ -1232,34 +1247,27 @@ Bool_t AliEMCALGeometry::GetPositionInEMCALFromAbsFastORIndex(const Int_t id, In { //Trigger mapping method, get position in EMCAL from FastOR index - Int_t iSM=-1; - - if (GetPositionInSMFromAbsFastORIndex(id, iSM, iEta, iPhi)) - { - if (iSM % 2) iEta += 24; - - iPhi += 12 * int(iSM / 2); - - return kTRUE; - } - - return kFALSE; + Int_t iSM=-1; + if (GetPositionInSMFromAbsFastORIndex(id, iSM, iEta, iPhi)) + { + if (iSM % 2) iEta += 24; + iPhi += 12 * int(iSM / 2); + return kTRUE; + } + return kFALSE; } //________________________________________________________________________________________________ Bool_t AliEMCALGeometry::GetAbsFastORIndexFromPositionInTRU(const Int_t iTRU, const Int_t iEta, const Int_t iPhi, Int_t& id) const { - //Trigger mapping method, get Index if FastOr from Position in TRU - - if (iTRU < 0 || iTRU > 31 || iEta < 0 || iEta > 23 || iPhi < 0 || iPhi > 3) - { - AliError("Out of range!"); - return kFALSE; - } - - id = iPhi + 4 * iEta + iTRU * 96; - - return kTRUE; + //Trigger mapping method, get Index if FastOr from Position in TRU + if (iTRU < 0 || iTRU > 31 || iEta < 0 || iEta > 23 || iPhi < 0 || iPhi > 3) + { + AliError("Out of range!"); + return kFALSE; + } + id = iPhi + 4 * iEta + iTRU * 96; + return kTRUE; } //________________________________________________________________________________________________ @@ -1267,24 +1275,20 @@ Bool_t AliEMCALGeometry::GetAbsFastORIndexFromPositionInSM(const Int_t iSM, con { //Trigger mapping method, from position in SM Index get FastOR index - if (iSM < 0 || iSM > 11 || iEta < 0 || iEta > 23 || iPhi < 0 || iPhi > 11) - { - AliError("Out of range!"); - return kFALSE; - } - - Int_t x = iEta; - Int_t y = iPhi % 4; - - Int_t iOff = (iSM % 2) ? 1 : 0; - Int_t iTRU = 2 * int(iPhi / 4) + 6 * int(iSM / 2) + iOff; - - if (GetAbsFastORIndexFromPositionInTRU(iTRU, x, y, id)) - { - return kTRUE; - } - - return kFALSE; + if (iSM < 0 || iSM > 11 || iEta < 0 || iEta > 23 || iPhi < 0 || iPhi > 11) + { + AliError("Out of range!"); + return kFALSE; + } + Int_t x = iEta; + Int_t y = iPhi % 4; + Int_t iOff = (iSM % 2) ? 1 : 0; + Int_t iTRU = 2 * int(iPhi / 4) + 6 * int(iSM / 2) + iOff; + if (GetAbsFastORIndexFromPositionInTRU(iTRU, x, y, id)) + { + return kTRUE; + } + return kFALSE; } //________________________________________________________________________________________________ @@ -1292,21 +1296,18 @@ Bool_t AliEMCALGeometry::GetAbsFastORIndexFromPositionInEMCAL(const Int_t iEta, { //Trigger mapping method, from position in EMCAL Index get FastOR index - if (iEta < 0 || iEta > 47 || iPhi < 0 || iPhi > 63 ) - { - AliError("Out of range!"); - return kFALSE; - } - - if (fFastOR2DMap[iEta][iPhi] == -1) - { - AliError("Invalid index!"); - return kFALSE; - } - - id = fFastOR2DMap[iEta][iPhi]; - - return kTRUE; + if (iEta < 0 || iEta > 47 || iPhi < 0 || iPhi > 63 ) + { + AliError(Form("Out of range! eta: %2d phi: %2d", iEta, iPhi)); + return kFALSE; + } + if (fFastOR2DMap[iEta][iPhi] == -1) + { + AliError("Invalid index!"); + return kFALSE; + } + id = fFastOR2DMap[iEta][iPhi]; + return kTRUE; } //________________________________________________________________________________________________ @@ -1314,18 +1315,14 @@ Bool_t AliEMCALGeometry::GetFastORIndexFromCellIndex(const Int_t id, Int_t& idx) { //Trigger mapping method, from cell index get FastOR index - Int_t iSupMod, nModule, nIphi, nIeta, iphim, ietam; - - Bool_t isOK = GetCellIndex( id, iSupMod, nModule, nIphi, nIeta ); - - GetModulePhiEtaIndexInSModule( iSupMod, nModule, iphim, ietam ); - - if (isOK && GetAbsFastORIndexFromPositionInSM(iSupMod, ietam, iphim, idx)) - { - return kTRUE; - } - - return kFALSE; + Int_t iSupMod, nModule, nIphi, nIeta, iphim, ietam; + Bool_t isOK = GetCellIndex( id, iSupMod, nModule, nIphi, nIeta ); + GetModulePhiEtaIndexInSModule( iSupMod, nModule, iphim, ietam ); + if (isOK && GetAbsFastORIndexFromPositionInSM(iSupMod, ietam, iphim, idx)) + { + return kTRUE; + } + return kFALSE; } //________________________________________________________________________________________________ @@ -1334,23 +1331,20 @@ Bool_t AliEMCALGeometry::GetCellIndexFromFastORIndex(const Int_t id, Int_t idx[4 //Trigger mapping method, from FASTOR index get cell index Int_t iSM=-1, iEta=-1, iPhi=-1; - if (GetPositionInSMFromAbsFastORIndex(id, iSM, iEta, iPhi)) - { - Int_t ix = 2 * iEta; - Int_t iy = 2 * iPhi; - - for (Int_t i=0; i<2; i++) - { - for (Int_t j=0; j<2; j++) - { - idx[2*i+j] = GetAbsCellIdFromCellIndexes(iSM, iy + i, ix + j); - } - } - - return kTRUE; - } - - return kFALSE; + if (GetPositionInSMFromAbsFastORIndex(id, iSM, iEta, iPhi)) + { + Int_t ix = 2 * iEta; + Int_t iy = 2 * iPhi; + for (Int_t i=0; i<2; i++) + { + for (Int_t j=0; j<2; j++) + { + idx[2*i+j] = GetAbsCellIdFromCellIndexes(iSM, iy + i, ix + j); + } + } + return kTRUE; + } + return kFALSE; } //________________________________________________________________________________________________ @@ -1358,15 +1352,13 @@ Bool_t AliEMCALGeometry::GetTRUIndexFromSTUIndex(const Int_t id, Int_t& idx) con { //Trigger mapping method, from STU index get TRU index - if (id > 31 || id < 0) - { - AliError(Form("TRU index out of range: %d",id)); - return kFALSE; - } - - idx = (id > 15) ? 2 * (31 - id) : 2 * (15 - id) + 1; - - return kTRUE; + if (id > 31 || id < 0) + { + AliError(Form("TRU index out of range: %d",id)); + return kFALSE; + } + idx = (id > 15) ? 2 * (31 - id) : 2 * (15 - id) + 1; + return kTRUE; } //________________________________________________________________________________________________ @@ -1374,93 +1366,158 @@ Int_t AliEMCALGeometry::GetTRUIndexFromSTUIndex(const Int_t id) const { //Trigger mapping method, from STU index get TRU index - if (id > 31 || id < 0) - { - AliError(Form("TRU index out of range: %d",id)); - } + if (id > 31 || id < 0) + { + AliError(Form("TRU index out of range: %d",id)); + } + Int_t idx = (id > 15) ? 2 * (31 - id) : 2 * (15 - id) + 1; + return idx; +} + +//________________________________________________________________________________________________ +void AliEMCALGeometry::BuildFastOR2DMap() +{ + // Needed by STU + + for (Int_t i = 0; i < 32; i++) + { + for (Int_t j = 0; j < 24; j++) + { + for (Int_t k = 0; k < 4; k++) + { + Int_t id; + if (GetAbsFastORIndexFromPositionInTRU(i, j, k, id)) + { + Int_t x = j, y = k + 4 * int(i / 2); + if (i % 2) x += 24; + fFastOR2DMap[x][y] = id; + } + } + } + } +} + +//________________________________________________________________________________________________ +Bool_t AliEMCALGeometry::GetTRUIndexFromOnlineIndex(const Int_t id, Int_t& idx) const +{ + //Trigger mapping method, from STU index get TRU index + + if (id > 31 || id < 0) + { + AliError(Form("TRU index out of range: %d",id)); + return kFALSE; + } + if (id == 31) { + idx = 31; + return kTRUE; + } + idx = ((id % 6) < 3) ? 6 * int(id / 6) + 2 * (id % 3) : 6 * int(id / 6) + 2 * (2 - (id % 3)) + 1; + return kTRUE; +} + +//________________________________________________________________________________________________ +Int_t AliEMCALGeometry::GetTRUIndexFromOnlineIndex(const Int_t id) const +{ + //Trigger mapping method, from STU index get TRU index - Int_t idx = (id > 15) ? 2 * (31 - id) : 2 * (15 - id) + 1; + if (id > 31 || id < 0) + { + AliError(Form("TRU index out of range: %d",id)); + } + if (id == 31) { + return 31; + } + Int_t idx = ((id % 6) < 3) ? 6 * int(id / 6) + 2 * (id % 3) : 6 * int(id / 6) + 2 * (2 - (id % 3)) + 1; + return idx; +} + +//________________________________________________________________________________________________ +Bool_t AliEMCALGeometry::GetOnlineIndexFromTRUIndex(const Int_t id, Int_t& idx) const +{ + //Trigger mapping method, from STU index get TRU index - return idx; + if (id > 31 || id < 0) + { + AliError(Form("TRU index out of range: %d",id)); + return kFALSE; + } + if (id == 31) { + idx = 31; + return kTRUE; + } + idx = (id % 2) ? int((6 - (id % 6)) / 2) + 3 * (2 * int(id / 6) + 1) : 3 * int(id / 6) + int(id / 2); + return kTRUE; } //________________________________________________________________________________________________ -void AliEMCALGeometry::BuildFastOR2DMap() +Int_t AliEMCALGeometry::GetOnlineIndexFromTRUIndex(const Int_t id) const { - // Needed by STU - for (Int_t i = 0; i < 32; i++) - { - for (Int_t j = 0; j < 24; j++) - { - for (Int_t k = 0; k < 4; k++) - { - Int_t id; - if (GetAbsFastORIndexFromPositionInTRU(i, j, k, id)) - { - Int_t x = j, y = k + 4 * int(i / 2); - - if (i % 2) x += 24; - - fFastOR2DMap[x][y] = id; - } - } - } - } + //Trigger mapping method, from STU index get TRU index + + if (id > 31 || id < 0) + { + AliError(Form("TRU index out of range: %d",id)); + } + if (id == 31) { + return 31; + } + Int_t idx = (id % 2) ? int((6 - (id % 6)) / 2) + 3 * (2 * int(id / 6) + 1) : 3 * int(id / 6) + int(id / 2); + return idx; } //________________________________________________________________________________________________ Bool_t AliEMCALGeometry::GetFastORIndexFromL0Index(const Int_t iTRU, const Int_t id, Int_t idx[], const Int_t size) const { //Trigger mapping method, from L0 index get FastOR index - if (size <= 0 ||size > 4) - { - AliError("Size not supported!"); - return kFALSE; - } + + if (size <= 0 ||size > 4) + { + AliError("Size not supported!"); + return kFALSE; + } - Int_t motif[4] = {0, 1, 4, 5}; - - switch (size) - { - case 1: // Cosmic trigger - if (!GetAbsFastORIndexFromTRU(iTRU, id, idx[1])) return kFALSE; - break; - case 4: // 4 x 4 - for (Int_t k = 0; k < 4; k++) - { - Int_t iADC = motif[k] + 4 * int(id / 3) + (id % 3); + Int_t motif[4] = {0, 1, 4, 5}; + switch (size) + { + case 1: // Cosmic trigger + if (!GetAbsFastORIndexFromTRU(iTRU, id, idx[1])) return kFALSE; + break; + case 4: // 4 x 4 + for (Int_t k = 0; k < 4; k++) + { + Int_t iADC = motif[k] + 4 * int(id / 3) + (id % 3); - if (!GetAbsFastORIndexFromTRU(iTRU, iADC, idx[k])) return kFALSE; - } - break; - default: - break; - } + if (!GetAbsFastORIndexFromTRU(iTRU, iADC, idx[k])) return kFALSE; + } + break; + default: + break; + } - return kTRUE; + return kTRUE; } //____________________________________________________________________________ -const TGeoHMatrix * AliEMCALGeometry::GetMatrixForSuperModule(Int_t smod) const { - - //Provides shift-rotation matrix for EMCAL +const TGeoHMatrix * AliEMCALGeometry::GetMatrixForSuperModule(Int_t smod) const +{ + //Provides shift-rotation matrix for EMCAL - if(smod < 0 || smod > fEMCGeometry->GetNumberOfSuperModules()) - AliFatal(Form("Wrong supermodule index -> %d",smod)); + if(smod < 0 || smod > fEMCGeometry->GetNumberOfSuperModules()) + AliFatal(Form("Wrong supermodule index -> %d",smod)); - //If GeoManager exists, take matrixes from it + //If GeoManager exists, take matrixes from it - // - // if(fKey110DEG && ind>=10) { - // } - // - // if(!gGeoManager->cd(volpath.Data())) - // AliFatal(Form("AliEMCALGeometry::GeoManager cannot find path %s!",volpath.Data())); - // - // TGeoHMatrix* m = gGeoManager->GetCurrentMatrix(); + // + // if(fKey110DEG && ind>=10) { + // } + // + // if(!gGeoManager->cd(volpath.Data())) + // AliFatal(Form("AliEMCALGeometry::GeoManager cannot find path %s!",volpath.Data())); + // + // TGeoHMatrix* m = gGeoManager->GetCurrentMatrix(); //Use matrices set externally - if(!gGeoManager || (gGeoManager && fUseExternalMatrices)){ + if(!gGeoManager || (gGeoManager && fUseExternalMatrices)){ if(fkSModuleMatrix[smod]){ return fkSModuleMatrix[smod] ; } @@ -1474,31 +1531,35 @@ const TGeoHMatrix * AliEMCALGeometry::GetMatrixForSuperModule(Int_t smod) const } }//external matrices - if(gGeoManager){ + if(gGeoManager){ const Int_t buffersize = 255; - char path[buffersize] ; - snprintf(path,buffersize,"/ALIC_1/XEN1_1/SMOD_%d",smod+1) ; - //TString volpath = "ALIC_1/XEN1_1/SMOD_"; - //volpath += smod+1; - - if(fKey110DEG && smod >= 10){ - snprintf(path,buffersize,"/ALIC_1/XEN1_1/SM10_%d",smod-10+1) ; - //volpath = "ALIC_1/XEN1_1/SM10_"; - //volpath += smod-10+1; - } - if (!gGeoManager->cd(path)){ - AliFatal(Form("Geo manager can not find path %s!\n",path)); - } - return gGeoManager->GetCurrentMatrix(); - } - - return 0 ; + char path[buffersize] ; + snprintf(path,buffersize,"/ALIC_1/XEN1_1/SMOD_%d",smod+1) ; + //TString volpath = "ALIC_1/XEN1_1/SMOD_"; + //volpath += smod+1; + + if(fKey110DEG && smod >= 10 && !fGeoName.Contains("12SMV1") ){ + snprintf(path,buffersize,"/ALIC_1/XEN1_1/SM10_%d",smod-10+1) ; + //volpath = "ALIC_1/XEN1_1/SM10_"; + //volpath += smod-10+1; + } + if(fKey110DEG && smod >= 10 && fGeoName.Contains("12SMV1") ){ + snprintf(path,buffersize,"/ALIC_1/XEN1_1/SM3rd_%d",smod-10+1) ; + //volpath = "ALIC_1/XEN1_1/SM10_"; + //volpath += smod-10+1; + } + if (!gGeoManager->cd(path)){ + AliFatal(Form("Geo manager can not find path %s!\n",path)); + } + return gGeoManager->GetCurrentMatrix(); + } + + return 0 ; } //______________________________________________________________________ void AliEMCALGeometry::GetModulePhiEtaIndexInSModuleFromTRUIndex(Int_t itru, Int_t iphitru, Int_t ietatru, Int_t &iphiSM, Int_t &ietaSM) const { - // This method transforms the (eta,phi) index of module in a // TRU matrix into Super Module (eta,phi) index. @@ -1510,20 +1571,18 @@ void AliEMCALGeometry::GetModulePhiEtaIndexInSModuleFromTRUIndex(Int_t itru, Int iphiSM = fEMCGeometry->GetNModulesInTRUPhi()*row + iphitru ; ietaSM = fEMCGeometry->GetNModulesInTRUEta()*col + ietatru ; - //printf(" GetModulePhiEtaIndexInSModuleFromTRUIndex : itru %2i iphitru %2i ietatru %2i iphiSM %2i ietaSM %2i \n", - // itru, iphitru, ietatru, iphiSM, ietaSM); } //__________________________________________________________________________________________________________________ void AliEMCALGeometry::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 -{ //Transform clusters cell position into global with alternative method, taking into account the depth calculation. +{ + //Transform clusters cell position into global with alternative method, taking into account the depth calculation. //Input are: the tower indeces, // supermodule, // particle type (photon 0, electron 1, hadron 2 ) // misalignment shifts to global position in case of need. // Federico.Ronchetti@cern.ch - // To use in a print later Float_t droworg = drow; @@ -1558,7 +1617,7 @@ void AliEMCALGeometry::RecalculateTowerPosition(Float_t drow, Float_t dcol, cons Int_t istrip = 0; Float_t z0 = 0; Float_t zb = 0; - Float_t z_is = 0; + Float_t zIs = 0; Float_t x,y,z; // return variables in terry's RF @@ -1601,16 +1660,16 @@ void AliEMCALGeometry::RecalculateTowerPosition(Float_t drow, Float_t dcol, cons teta1 = TMath::DegToRad() * (is*1.5 + 0.75); if(is==0) - z_is = z_is + 2*dz*TMath::Cos(teta1); + zIs = zIs + 2*dz*TMath::Cos(teta1); else - z_is = z_is + 2*dz*TMath::Cos(teta1) + 2*dz*TMath::Sin(teta1)*TMath::Tan(teta1-0.75*TMath::DegToRad()); + zIs = zIs + 2*dz*TMath::Cos(teta1) + 2*dz*TMath::Sin(teta1)*TMath::Tan(teta1-0.75*TMath::DegToRad()); } z0 = dz*(dcol-2*istrip+0.5); zb = (2*dz-z0-depth*TMath::Tan(teta1)); - z = z_is - zb*TMath::Cos(teta1); + z = zIs - zb*TMath::Cos(teta1); y = depth/TMath::Cos(teta1) + zb*TMath::Sin(teta1); x = (drow + 0.5)*dx; @@ -1645,11 +1704,19 @@ void AliEMCALGeometry::RecalculateTowerPosition(Float_t drow, Float_t dcol, cons global[1] = dglobal[1] ; global[2] = dglobal[2] ; } - - } else{ AliFatal("Geometry boxes information, check that geometry.root is loaded\n"); } - +} + +void AliEMCALGeometry::SetMisalMatrix(const TGeoHMatrix * m, Int_t smod) +{ + // Method to set shift-rotational matrixes from ESDHeader + // Move from header due to coding violations : Dec 2,2011 by PAI + fUseExternalMatrices = kTRUE; + + if (smod >= 0 && smod < fEMCGeometry->GetNumberOfSuperModules()){ + if(!fkSModuleMatrix[smod]) fkSModuleMatrix[smod] = new TGeoHMatrix(*m) ; //Set only if not set yet + } else AliFatal(Form("Wrong supermodule index -> %d",smod)); }