]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSGeometry.cxx
- changes to make the clusterisation work for EMCAL
[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 AliHLTLogging(),
26 fGeoUtils(0)
27 {
28  // See header file for class documentation
29  GetGeometryFromCDB();
30 }
31
32 AliHLTPHOSGeometry::~AliHLTPHOSGeometry()
33 {
34 // See header file for class documentation
35 }
36
37 void AliHLTPHOSGeometry::GetGlobalCoordinates ( AliHLTCaloRecPointDataStruct& recPoint, AliHLTCaloGlobalCoordinate& globalCoord )
38 {
39    // See header file for class documentation
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    ConvertRecPointCoordinates(x, z);
50
51    TVector3 coord;
52    fGeoUtils->Local2Global(fCaloConstants->GetNMODULES() - recPoint.fModule, x, z, coord);
53    
54    globalCoord.fX = coord[0];
55    globalCoord.fY = coord[1];
56    globalCoord.fZ = coord[2];
57    
58 }
59
60 void AliHLTPHOSGeometry::ConvertRecPointCoordinates(Float_t &x, Float_t &z) const
61 {
62    // See header file for class documentation
63
64    x = (x - fCaloConstants->GetNXCOLUMNSMOD()/2)*fCaloConstants->GetCELLSTEP();
65    z = (z - fCaloConstants->GetNZROWSMOD()/2)*fCaloConstants->GetCELLSTEP();
66 }
67
68 int AliHLTPHOSGeometry::GetGeometryFromCDB()
69 {
70    // See header file for documentation
71
72    AliCDBPath path("GRP","Geometry","Data");
73    if(path.GetPath())
74     {
75       //      HLTInfo("configure from entry %s", path.GetPath());
76       AliCDBEntry *pEntry = AliCDBManager::Instance()->Get(path/*,GetRunNo()*/);
77       if (pEntry) 
78         {
79           if(!fGeoUtils) 
80             {
81               delete fGeoUtils;
82               fGeoUtils = 0;
83             }
84
85           gGeoManager = (TGeoManager*) pEntry->GetObject();
86 //        HLTError("gGeoManager = 0x%x", gGeoManager);
87           if(gGeoManager)
88             {
89               fGeoUtils = new AliPHOSGeoUtils("PHOS", "noCPV");
90             }
91         }
92       else
93         {
94 //          HLTError("can not fetch object \"%s\" from OCDB", path);
95         }
96     }
97     return 0;
98 }
99
100
101 void AliHLTPHOSGeometry::GetCellAbsId ( UInt_t module, UInt_t x, UInt_t z, Int_t& AbsId ) 
102   {
103       // See header file for class documentation
104       if(!fGeoUtils)
105       {
106          Logging(kHLTLogError, "HLT", "PHOS", "AliHLTPHOSGeometry::GetCellAbsId: no geometry initialised");
107          return;
108       }
109       fGeoUtils->RelPosToAbsId(module, x, z, AbsId);
110   }
111