]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSGeometry.cxx
updated macros for Kaon Femto analysis
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSGeometry.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Authors: Oystein Djuvsland <oysteind@ift.uib.no>                       *
5  *                                                                        *
6  * Permission to use, copy, modify and distribute this software and its   *
7  * documentation strictly for non-commercial purposes is hereby granted   *
8  * without fee, provided that the above copyright notice appears in all   *
9  * copies and that both the copyright notice and this permission notice   *
10  * appear in the supporting documentation. The authors make no claims     *
11  * about the suitability of this software for any purpose. It is          *
12  * provided "as is" without express or implied warranty.                  *
13  **************************************************************************
14 */
15
16 #include "AliHLTPHOSGeometry.h"
17 #include "AliPHOSGeoUtils.h"
18 #include "TGeoManager.h"
19 #include "AliCDBManager.h"
20 #include "AliCDBEntry.h"
21 #include "TVector3.h"
22
23 AliHLTPHOSGeometry::AliHLTPHOSGeometry() :
24 AliHLTCaloGeometry("PHOS"),
25 fGeoUtils(0)
26 {
27  // See header file for class documentation
28  
29 }
30
31 AliHLTPHOSGeometry::~AliHLTPHOSGeometry()
32 {
33 // See header file for class documentation
34 }
35 // FR: PHOS doesn't use iParticle for now
36 void AliHLTPHOSGeometry::GetGlobalCoordinates ( AliHLTCaloRecPointDataStruct& recPoint, AliHLTCaloGlobalCoordinate& globalCoord, Int_t /* iParticle */ )
37 {
38    // See header file for class documentation
39    if(!fIsInitialised) { InitialiseGeometry(); }
40    if(!fGeoUtils) 
41    {
42       Logging(kHLTLogError, "HLT", "PHOS", "AliHLTPHOSGeometry::GetGlobalCoordinates: no geometry initialised");
43       return;
44    }
45
46    Float_t x = recPoint.fX;
47    Float_t z = recPoint.fZ;
48    
49
50    ConvertRecPointCoordinates(x, z);
51    
52    TVector3 coord;
53    fGeoUtils->Local2Global(fCaloConstants->GetNMODULES() - recPoint.fModule, x, z, coord);
54    
55
56    globalCoord.fX = coord[0];
57    globalCoord.fY = coord[1];
58    globalCoord.fZ = coord[2];
59    
60 }
61
62 void AliHLTPHOSGeometry::ConvertRecPointCoordinates(Float_t &x, Float_t &z) const
63 {
64    // See header file for class documentation
65    x = (x - (float)(fCaloConstants->GetNXCOLUMNSMOD())/2)*fCaloConstants->GetCELLSTEP();
66    z = (z - ((float)(fCaloConstants->GetNZROWSMOD()))/2)*fCaloConstants->GetCELLSTEP();
67 }
68
69 int AliHLTPHOSGeometry::GetGeometryFromCDB()
70 {
71    // See header file for documentation
72
73    AliCDBPath path("GRP","Geometry","Data");
74    if(path.GetPath())
75     {
76       //      HLTInfo("configure from entry %s", path.GetPath());
77       AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
78       if (pEntry) 
79         {
80           if(fGeoUtils) 
81             {
82               delete fGeoUtils;
83               fGeoUtils = 0;
84             }
85           
86           if(!gGeoManager) gGeoManager = (TGeoManager*) pEntry->GetObject();
87           
88           if(gGeoManager)
89             {
90               fGeoUtils = new AliPHOSGeoUtils("PHOS", "noCPV");
91               if(fGeoUtils) fIsInitialised = kTRUE;
92             }
93             else
94             {
95                HLTError("can not get gGeoManager from OCDB");
96             }
97         }
98       else
99         {
100             HLTError("can not fetch object \"%s\" from OCDB", path.GetPath().Data());
101         }
102     }
103     return 0;
104 }
105
106
107 void AliHLTPHOSGeometry::GetCellAbsId ( UInt_t module, UInt_t x, UInt_t z, Int_t& AbsId ) 
108   {
109       // See header file for class documentation
110       if(!fGeoUtils)
111       {
112          Logging(kHLTLogError, "HLT", "PHOS", "AliHLTPHOSGeometry::GetCellAbsId: no geometry initialised");
113          return;
114       }
115       fGeoUtils->RelPosToAbsId(module, x, z, AbsId);
116   }
117
118 void AliHLTPHOSGeometry::GetLocalCoordinatesFromAbsId(Int_t absId, Int_t& module, Int_t& x, Int_t& z)
119 {
120   Int_t rel[4];
121   fGeoUtils->AbsToRelNumbering(absId, rel);
122   module = rel[0]-1;
123   z = rel[2];
124   x = rel[3];
125 }