]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/CALO/AliHLTCaloMapper.cxx
- adding new clusterizer class. Basic algorithm that uses a NxN matrix centered aroun...
[u/mrichter/AliRoot.git] / HLT / CALO / AliHLTCaloMapper.cxx
1 // $Id: AliHLTCalorimeterMapper.cxx 34622 2009-09-04 13:22:01Z odjuvsla $
2
3 /**************************************************************************
4  * This file is property of and copyright by the Experimental Nuclear     *
5  * Physics Group, Dep. of Physics                                         *
6  * University of Oslo, Norway, 2006                                       *
7  *                                                                        * 
8  * Author: Per Thomas Hille perthi@fys.uio.no for the ALICE DCS Project.  *
9  * Contributors are mentioned in the code where appropriate.              *
10  * Please report bugs to perthi@fys.uio.no                                * 
11  *                                                                        *
12  * Permission to use, copy, modify and distribute this software and its   *
13  * documentation strictly for non-commercial purposes is hereby granted   *
14  * without fee, provided that the above copyright notice appears in all   *
15  * copies and that both the copyright notice and this permission notice   *
16  * appear in the supporting documentation. The authors make no claims     *
17  * about the suitability of this software for any purpose. It is          *
18  * provided "as is" without express or implied warranty.                  *
19  **************************************************************************/
20
21 //
22 // Mapping class fro mapping
23 // from hardware address to geometrical address
24 //
25 //
26
27 #include "AliHLTCaloMapper.h"
28 #include "AliHLTLogging.h"
29 #include "Rtypes.h"
30 #include "unistd.h"
31 #include <iostream>
32 #include "AliHLTCaloCoordinate.h"
33 #include "AliHLTCaloConstantsHandler.h"
34
35 //#include "AliHLTCaloConstants.h"
36
37
38 //typedef AliHLTCaloConstantsHandler::fCaloConstants->GetCELLSTEP()  CELLSTEP;
39
40 //#define fCaloConstants->GetCELLSTEP() CELLSTEP 
41
42
43
44 //typedef CELLSTEP  fCaloConstants->GetCELLSTEP();
45
46 ClassImp(AliHLTCaloMapper);
47
48 AliHLTCaloMapper::AliHLTCaloMapper( const unsigned long  specification , TString det) :  
49   AliHLTCaloConstantsHandler(det),
50   AliHLTLogging(), 
51   fHw2geomapPtr(0),
52   fCellSize(0),
53   fSpecification(specification),
54   fIsInitializedMapping(false),
55   fSpecificationMapPtr(0)
56 {  
57   //see header file for class documentation
58 }
59
60
61 AliHLTCaloMapper::~AliHLTCaloMapper()
62 {
63   delete []  fHw2geomapPtr;
64   fHw2geomapPtr = 0;
65 }
66
67
68 //void AliHLTCaloMapper::InitAltroMapping(){
69   //Virtual base class
70 //}
71
72 //void AliHLTCaloMapper::InitDDLSpecificationMapping() {
73   //Virtual base class
74 //}
75
76
77
78 bool 
79 AliHLTCaloMapper::GetIsInitializedMapping()
80 {
81   return  fIsInitializedMapping;
82 }
83
84
85 char* 
86 AliHLTCaloMapper::GetFilePath()
87 {
88   return  fFilepath;
89 }
90
91
92 int 
93 AliHLTCaloMapper::GetChannelID(const AliHLTUInt32_t spec, const Int_t hadd)
94 {
95   Short_t index = GetDDLFromSpec(spec);
96   if( index < 0 )
97     {
98       HLTError("Specification 0x%X not consistent with single DDL in PHOS", spec);
99       return index;
100     }
101   else
102     {
103       return ((fHw2geomapPtr[hadd].fXCol   ) |
104               ((fHw2geomapPtr[hadd].fZRow  ) << 6) |
105               (fHw2geomapPtr[hadd].fGain << 12) |
106               fSpecificationMapPtr[index].fModId << 13);
107     }
108 }
109
110
111 void
112 AliHLTCaloMapper::GetChannelCoord(const UShort_t channelId, UShort_t* channelCoord)
113 {
114   channelCoord[0] = channelId&0x3f;
115   channelCoord[1] = (channelId >> 6)&0x3f;
116   channelCoord[2] = (channelId >> 12)&0x1;
117   channelCoord[3] = (channelId >> 13)&0x1f;
118   //  printf("Channel ID: 0x%X Coordinates: x = %d, z = %d, gain = %d\n", channelId, channelCoord[0], channelCoord[1], channelCoord[2]);
119 }
120
121 void
122 AliHLTCaloMapper::ChannelId2Coordinate(const int channelId,    AliHLTCaloCoordinate &channelCoord)
123 {
124   channelCoord.fX = channelId&0x3f;
125   channelCoord.fZ = (channelId >> 6)&0x3f;
126   channelCoord.fGain = (channelId >> 12)&0x1;
127   channelCoord.fModuleId  = (channelId >> 13)&0x1f;
128   //  printf("Channel ID: 0x%X Coordinates: x = %d, z = %d, gain = %d\n", channelId, channelCoord[0], channelCoord[1], channelCoord[2]);
129 }
130
131
132 void
133 AliHLTCaloMapper::GetLocalCoord(const int channelId, Float_t* localCoord) const
134 {
135   localCoord[0] = (static_cast<Float_t>(channelId&0x3f) - fCaloConstants->GetNXCOLUMNSMOD()/2)* fCaloConstants->GetCELLSTEP();
136   //  localCoord[0] = (static_cast<Float_t>(channelId&0x3f) - fCaloConstants->GetNXCOLUMNSMOD()/2)*CELLSTEP; 
137   localCoord[1] = (static_cast<Float_t>((channelId >> 6)&0x3f) - fCaloConstants->GetNZROWSMOD()/2) * fCaloConstants->GetCELLSTEP();
138   //  printf("Local coordinates: x = %f, z = %f\n", channelCoord[0], channelCoord[1]);
139 }
140
141
142 int  
143 AliHLTCaloMapper::GetDDLFromSpec( const AliHLTUInt32_t spec )
144 {
145   int tmpIndex = -1;
146   for(int i=0; i < 32; i++ )
147     {
148       if (spec >> i ==1)
149         {
150           tmpIndex = i;
151           break;
152         }
153     }
154    if(  tmpIndex  < 0)
155     {
156       //   HLTError("Specification %d, not consistent with any DDL in PHOS or EMCAL", spec  );
157     }
158
159   return tmpIndex;
160 }
161
162
163 Int_t 
164 AliHLTCaloMapper::GetModuleFromSpec(Int_t specification)
165 {
166   Int_t module = -1;
167       
168   if(specification & 0xf) module = 0;
169   else if((specification >> 4) & 0xf) module = 1;
170   else if((specification >> 8) & 0xf) module = 2;
171   else if((specification >> 12) & 0xf) module = 3;
172   else if((specification >> 16) & 0xf) module = 4;
173  
174   else HLTError("Specification 0x%X not consistent with single module in PHOS", specification);
175
176   return module;
177 }
178
179
180 unsigned long 
181 AliHLTCaloMapper::GetSpecFromDDLIndex( const int ddlindex )
182 {
183   int iret = (unsigned long)1  <<  ddlindex;  
184
185   //  return  ((unsigned long)1)  <<  ddlindex ) ;
186
187   return iret;
188
189 }
190