X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=FMD%2FAliFMDGeometry.cxx;h=faceb4688767148d2f01e38425212364e9d6a2f0;hb=1306ba553734c54a4beabd3f8e6ca0d888403dbc;hp=7740c2b9c26bcd3ca6ddaa44a571f384d1ec90ba;hpb=c2fc12580f7bb903a1f061ae3d60882098e8a988;p=u%2Fmrichter%2FAliRoot.git diff --git a/FMD/AliFMDGeometry.cxx b/FMD/AliFMDGeometry.cxx index 7740c2b9c26..faceb468876 100644 --- a/FMD/AliFMDGeometry.cxx +++ b/FMD/AliFMDGeometry.cxx @@ -13,11 +13,12 @@ * provided "as is" without express or implied warranty. * **************************************************************************/ /* $Id$ */ -/** @file AliFMDGeometry.cxx - @author Christian Holm Christensen - @date Mon Mar 27 12:40:37 2006 - @brief Geometry mananger for the FMD -*/ +/** + * @file AliFMDGeometry.cxx + * @author Christian Holm Christensen + * @date Mon Mar 27 12:40:37 2006 + * @brief Geometry mananger for the FMD + */ //____________________________________________________________________ // // Forward Multiplicity Detector based on Silicon wafers. @@ -66,16 +67,17 @@ #include "AliFMD2.h" // ALIFMD2_H #include "AliFMD3.h" // ALIFMD2_H #include "AliRecPoint.h" // ALIRECPOINT_H -#include "AliLog.h" // ALIRECPOINT_H +#include "AliFMDDebug.h" // ALILOG_H #include // ROOT_TVector3 -#include // ROOT_TMatrix -#include // ROOT_TParticle +// #include // ROOT_TMatrix +// #include // ROOT_TParticle #include #include "AliFMDGeometryBuilder.h" -#include +// #include #include #include #include +#include static Int_t FindNodeDepth(const char* name, const char* volname); @@ -92,23 +94,73 @@ AliFMDGeometry* AliFMDGeometry::fgInstance = 0; AliFMDGeometry* AliFMDGeometry::Instance() { - // Return (newly created) singleton instance - if (!fgInstance) fgInstance = new AliFMDGeometry; + // + // singleton access + // + // Return: + // Singleton + // + if (!fgInstance) fgInstance = new AliFMDGeometry("FMD"); return fgInstance; } //____________________________________________________________________ AliFMDGeometry::AliFMDGeometry() + : AliGeometry(), + fIsInitialized(kFALSE), + fInner(0), + fOuter(0), + fFMD1(0), + fFMD2(0), + fFMD3(0), + fUseFMD1(kTRUE), + fUseFMD2(kTRUE), + fUseFMD3(kTRUE), + fIsInitTrans(kFALSE), + fBuilder(0), + fDetectorOff(0), + fModuleOff(0), + fRingOff(0), + fSectorOff(0), + fActive(2), + fDetailed(kTRUE), + fUseAssembly(kTRUE) +{ + // PROTECTED + // + // CTOR + // +} + +//____________________________________________________________________ +AliFMDGeometry::AliFMDGeometry(const char* ) : AliGeometry("FMD", "Forward multiplicity"), - fBuilder(0) + fIsInitialized(kFALSE), + fInner(0), + fOuter(0), + fFMD1(0), + fFMD2(0), + fFMD3(0), + fUseFMD1(kTRUE), + fUseFMD2(kTRUE), + fUseFMD3(kTRUE), + fIsInitTrans(kFALSE), + fBuilder(0), + fDetectorOff(0), + fModuleOff(0), + fRingOff(0), + fSectorOff(0), + fActive(2), + fDetailed(kTRUE), + fUseAssembly(kTRUE) { // PROTECTED - // Default constructor - fUseFMD1 = kTRUE; - fUseFMD2 = kTRUE; - fUseFMD3 = kTRUE; - fDetailed = kTRUE; - fUseAssembly = kTRUE; + // + // CTOR + // + // Parameters: + // name Not used + // fInner = new AliFMDRing('I'); fOuter = new AliFMDRing('O'); fFMD1 = new AliFMD1(fInner); @@ -130,12 +182,23 @@ AliFMDGeometry::AliFMDGeometry(const AliFMDGeometry& other) fUseFMD1(other.fUseFMD1), fUseFMD2(other.fUseFMD2), fUseFMD3(other.fUseFMD3), + fIsInitTrans(other.fIsInitTrans), + fBuilder(other.fBuilder), + fDetectorOff(other.fDetectorOff), + fModuleOff(other.fModuleOff), + fRingOff(other.fRingOff), + fSectorOff(other.fSectorOff), fActive(other.fActive), fDetailed(other.fDetailed), fUseAssembly(other.fUseAssembly) { // PROTECTED - // Copy constructor + // + // Copy CTOR + // + // Parameters: + // other To copy from + // } @@ -145,7 +208,15 @@ AliFMDGeometry& AliFMDGeometry::operator=(const AliFMDGeometry& other) { // PROTECTED + // // Assignment operator + // + // Parameters: + // other To assig from + // Return: + // reference to this. + // + if (&other == this) return *this; fUseFMD1 = other.fUseFMD1; fUseFMD2 = other.fUseFMD2; fUseFMD3 = other.fUseFMD3; @@ -162,7 +233,9 @@ AliFMDGeometry::operator=(const AliFMDGeometry& other) void AliFMDGeometry::Init() { + // // Initialize the the singleton if not done so already + // if (fIsInitialized) return; fInner->Init(); fOuter->Init(); @@ -173,22 +246,31 @@ AliFMDGeometry::Init() //____________________________________________________________________ void -AliFMDGeometry::InitTransformations() +AliFMDGeometry::InitTransformations(Bool_t force) { + // + // Find all local <-> global transforms + // + if (force) fIsInitTrans = kFALSE; + if (fIsInitTrans) return; if (!gGeoManager) { AliError("No TGeoManager defined"); return; } - AliDebug(0, "Initialising transforms for FMD geometry"); + AliFMDDebug(1, ("Initialising transforms for FMD geometry")); if (fFMD1) fFMD1->InitTransformations(); if (fFMD2) fFMD2->InitTransformations(); if (fFMD3) fFMD3->InitTransformations(); + fIsInitTrans = kTRUE; } //____________________________________________________________________ void AliFMDGeometry::Build() { + // + // Make the geometry. This delegates to AliFMDGeometryBuilder + // if (!fBuilder) fBuilder = new AliFMDGeometryBuilder(fDetailed); fBuilder->SetDetailed(fDetailed); fBuilder->UseAssembly(fUseAssembly); @@ -199,9 +281,16 @@ AliFMDGeometry::Build() void AliFMDGeometry::SetActive(Int_t* active, Int_t n) { + // + // Set active volumes + // + // Parameters: + // active Active volume id array + // n elements of @a active + // fActive.Set(n); for (Int_t i = 0; i < n; i++) { - AliDebug(1, Form("Active vol id # %d: %d", i, active[i])); + AliFMDDebug(1, ("Active vol id # %d: %d", i, active[i])); fActive[i] = active[i]; } } @@ -210,6 +299,13 @@ AliFMDGeometry::SetActive(Int_t* active, Int_t n) void AliFMDGeometry::AddActive(Int_t active) { + // + // Add an active volume + // + // Parameters: + // id Register volume @a id to be active + // + // Int_t n = fActive.fN; fActive.Set(n+1); fActive[n] = active; @@ -219,6 +315,14 @@ AliFMDGeometry::AddActive(Int_t active) Bool_t AliFMDGeometry::IsActive(Int_t vol) const { + // + // Check if volume @a vol is marked as active + // + // Parameters: + // vol Volume ID + // Return: + // @c true if @a vol is declared active + // for (Int_t i = 0; i < fActive.fN; i++) if (fActive[i] == vol) return kTRUE; return kFALSE; @@ -228,8 +332,14 @@ AliFMDGeometry::IsActive(Int_t vol) const AliFMDDetector* AliFMDGeometry::GetDetector(Int_t i) const { - // Get the ith detector. i should be one of 1, 2, or 3. If an - // invalid value is passed, 0 (NULL) is returned. + // + // Get description of a sub-detector + // + // Parameters: + // i Sub-detector # + // Return: + // Description of sub-detector, or 0 + // switch (i) { case 1: return fUseFMD1 ? static_cast(fFMD1) : 0; case 2: return fUseFMD2 ? static_cast(fFMD2) : 0; @@ -242,9 +352,16 @@ AliFMDGeometry::GetDetector(Int_t i) const AliFMDRing* AliFMDGeometry::GetRing(Char_t i) const { - // Get the ith ring. i should be one of 'I' or 'O' (case + // + // Get description of a ring, i should be one of 'I' or 'O' (case // insensitive). If an invalid parameter is passed, 0 (NULL) is - // returned. + // returned. + // + // Parameters: + // i Ring id + // Return: + // Description of ring, or 0 + // switch (i) { case 'I': case 'i': return fInner; @@ -258,7 +375,12 @@ AliFMDGeometry::GetRing(Char_t i) const void AliFMDGeometry::Enable(Int_t i) { - // Enable the ith detector. i should be one of 1, 2, or 3 + // + // Enable the ith detector + // + // Parameters: + // i IF true, enable sub-detector @a i + // switch (i) { case 1: fUseFMD1 = kTRUE; break; case 2: fUseFMD2 = kTRUE; break; @@ -270,7 +392,12 @@ AliFMDGeometry::Enable(Int_t i) void AliFMDGeometry::Disable(Int_t i) { - // Disable the ith detector. i should be one of 1, 2, or 3 + // + // Disable the ith detector + // + // Parameters: + // i IF true, disable sub-detector @a i + // switch (i) { case 1: fUseFMD1 = kFALSE; break; case 2: fUseFMD2 = kFALSE; break; @@ -288,9 +415,21 @@ AliFMDGeometry::Detector2XYZ(UShort_t detector, Double_t& y, Double_t& z) const { - // Translate detector coordinates (detector, ring, sector, strip) to - // spatial coordinates (x, y, z) in the master reference frame of - // ALICE. + // + // Translate detector coordinates (detector, ring, sector, strip) + // to spatial coordinates (x, y, z) in the master reference frame + // of ALICE. The member function uses the transformations + // previously obtained from the TGeoManager. + // + // Parameters: + // detector Detector number + // ring Ring id + // sector Sector number + // strip Strip number + // x On return, X coordinate + // y On return, Y coordinate + // z On return, Z coordinate + // AliFMDDetector* det = GetDetector(detector); if (!det) { AliWarning(Form("Unknown detector %d", detector)); @@ -309,12 +448,29 @@ AliFMDGeometry::XYZ2Detector(Double_t x, UShort_t& sector, UShort_t& strip) const { - // Translate spatial coordinates (x,y,z) in the master reference frame of - // ALICE to the detector coordinates (detector, ring, sector, - // strip). Note, that if this method is to be used in - // reconstruction or the like, then the input z-coordinate should be - // corrected for the events interactions points z-coordinate, like + // + // Translate spatial coordinates (x,y,z) in the master reference + // frame of ALICE to the detector coordinates (detector, ring, + // sector, strip). Note, that if this method is to be used in + // reconstruction or the like, then the input z-coordinate should + // be corrected for the events interactions points z-coordinate, + // like + // @code // geom->XYZ2Detector(x,y,z-ipz,d,r,s,t); + // @endcode + // + // Parameters: + // x X coordinate + // y Y coordinate + // z Z coordinate + // detector On return, Detector number + // ring On return, Ring id + // sector On return, Sector number + // strip On return, Strip number + // Return: + // @c false of (@a x, @a y, @a z) is not within this + // detector. + // AliFMDDetector* det = 0; detector = 0; for (int i = 1; i <= 3; i++) { @@ -328,6 +484,43 @@ AliFMDGeometry::XYZ2Detector(Double_t x, return kFALSE; } +//____________________________________________________________________ +Bool_t +AliFMDGeometry::XYZ2REtaPhiTheta(Double_t x, Double_t y, + Double_t z, + Double_t& r, Double_t& eta, + Double_t& phi, Double_t& theta) +{ + + // + // Service function to convert Cartisean XYZ to r, eta, phi, and theta. + // + // Note, that the z input should be corrected for the vertex location + // if needed. + // + // Parameters: + // x Cartisean X coordinate + // y Cartisean Y coordinate + // z Cartisean Z coordinate + // r On return, the radius + // eta On return, the pseudo-rapidity + // phi On return, the azimuthal angle + // theta On return, the polar angle; + // + // Return: + // kTRUE on success, kFALSE in case of problems + // + if (x == 0 && y == 0 && z == 0) return kFALSE; + + // Correct for vertex offset. + phi = TMath::ATan2(y, x); + r = TMath::Sqrt(y * y + x * x); + theta = TMath::ATan2(r, z); + eta = -TMath::Log(TMath::Tan(theta / 2)); + + return kTRUE; +} + //____________________________________________________________________ void @@ -335,9 +528,14 @@ AliFMDGeometry::GetGlobal(const AliRecPoint* p, TVector3& pos, TMatrixF& /* mat */) const { - // Get the global coordinates cooresponding to the reconstructed - // point p. The coordiates is returned in the 3-vector pos passed - // to this member function. The matrix mat is used for rotations. + // + // Get global coordinates cooresponding to a rec point. + // + // Parameters: + // p Reconstructed point. + // pos On return, the position + // mat On return, the material at @a post + // GetGlobal(p, pos); } @@ -345,12 +543,13 @@ AliFMDGeometry::GetGlobal(const AliRecPoint* p, void AliFMDGeometry::GetGlobal(const AliRecPoint* p, TVector3& pos) const { - // Get the global coordinates cooresponding to the reconstructed - // point p. The coordiates is returned in the 3-vector pos passed - // to this member function. Note, as AliRecPoint only has places for - // 3 indicies, it is assumed that the ring hit is an inner ring - - // which obviously needn't be the case. This makes the member - // function pretty darn useless. + // + // Get global coordinates cooresponding to a rec point. + // + // Parameters: + // p Reconstructed point. + // pos On return, the position + // // FIXME: Implement this function to work with outer rings too. Double_t x, y, z; TVector3 local; @@ -366,14 +565,31 @@ AliFMDGeometry::GetGlobal(const AliRecPoint* p, TVector3& pos) const Bool_t AliFMDGeometry::Impact(const TParticle* /* particle */) const { - // Return true, if the particle will hit the active detector - // elements, and false if not. Should be used for fast - // simulations. Note, that the function currently return false - // always. - // FIXME: Implement this function. + // + // Check if particle will hit an active detector element. + // + // @todo implement this function + // + // Parameters: + // particle Track + // Return: + // @c true if @a particle will hit this detector + // return kFALSE; } +//____________________________________________________________________ +void +AliFMDGeometry::SetAlignableVolumes() const +{ + // + // Declare alignable volumes + // + for (Int_t d = 1; d <= 3; d++) + if (GetDetector(d)) GetDetector(d)->SetAlignableVolumes(); +} + + //____________________________________________________________________ void AliFMDGeometry::ExtractGeomInfo() @@ -387,12 +603,13 @@ AliFMDGeometry::ExtractGeomInfo() // and so on - that is, all the geometric information we need for // futher processing, such as simulation, digitization, // reconstruction, etc. - Int_t detectorDepth = FindNodeDepth("FMD1_1", "ALIC"); - Int_t ringDepth = FindNodeDepth(Form("FMDI_%d", Int_t('I')), "ALIC"); - Int_t moduleDepth = FindNodeDepth("FIFV_0", "ALIC"); - Int_t sectorDepth = FindNodeDepth("FISE_1", "ALIC"); + Int_t detectorDepth = FindNodeDepth("F1MT_1", "ALIC"); + Int_t ringDepth = FindNodeDepth(Form("FITV_%d", int('I')), "ALIC"); + Int_t moduleDepth = FindNodeDepth("FIBH_0", "ALIC"); + Int_t sectorDepth = FindNodeDepth("FISC_1", "ALIC"); + fActive.Set(0); fActive.Reset(-1); - AliDebug(1, Form("Geometry depths:\n" + AliFMDDebug(1, ("Geometry depths:\n" " Sector: %d\n" " Module: %d\n" " Ring: %d\n" @@ -432,7 +649,7 @@ AliFMDGeometry::ExtractGeomInfo() if (striVol) AddActive(striVol->GetNumber()); if (stroVol) AddActive(stroVol->GetNumber()); } - AliDebug(1, Form("Geometry offsets:\n" + AliFMDDebug(1, ("Geometry offsets:\n" " Sector: %d\n" " Module: %d\n" " Ring: %d\n" @@ -440,7 +657,7 @@ AliFMDGeometry::ExtractGeomInfo() fSectorOff, fModuleOff, fRingOff, fDetectorOff)); } - +#if 0 //____________________________________________________________________ static Int_t CheckNodes(TGeoNode* node, const char* name, Int_t& lvl) @@ -470,15 +687,31 @@ CheckNodes(TGeoNode* node, const char* name, Int_t& lvl) lvl--; return -1; } +#endif + //____________________________________________________________________ Int_t FindNodeDepth(const char* name, const char* volname) { + // Find the depth of a node TGeoVolume* vol = gGeoManager->GetVolume(volname); if (!vol) { std::cerr << "No top volume defined" << std::endl; return -1; } + + TGeoIterator next(vol); + TGeoNode* node = 0; + TString sName(name); + while ((node = next())) { + if (sName == node->GetName()) { + //std::cout << "Found node " << node->GetName() << " at level " + // << next.GetLevel() << std::endl; + return next.GetLevel(); + } + } + return -1; +#if 0 TObjArray* nodes = vol->GetNodes(); if (!nodes) { std::cerr << "No nodes in top volume" << std::endl; @@ -490,6 +723,7 @@ FindNodeDepth(const char* name, const char* volname) while ((node = static_cast(next()))) if (CheckNodes(node, name, lvl) >= 0) return lvl; return -1; +#endif } //____________________________________________________________________