]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/CALO/AliHLTCaloMapper.cxx
removed string operation and coverity fix.
[u/mrichter/AliRoot.git] / HLT / CALO / AliHLTCaloMapper.cxx
CommitLineData
178dd351 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"
4f4b7ba4 33#include "AliHLTCaloConstantsHandler.h"
76ffc0ce 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();
178dd351 45
4f4b7ba4 46ClassImp(AliHLTCaloMapper);
178dd351 47
77f350f7 48AliHLTCaloMapper::AliHLTCaloMapper( const unsigned long specification , TString det) :
4f4b7ba4 49 AliHLTCaloConstantsHandler(det),
f92dcf21 50 AliHLTLogging(),
77f350f7 51 fHw2geomapPtr(0),
52 fCellSize(0),
53 fSpecification(specification),
54 fIsInitializedMapping(false),
4d2d113d 55 fSpecificationMapPtr(0),
56 fCaloDet(det)
178dd351 57{
58 //see header file for class documentation
fe4e0365 59 fFilepath[0] = '\0';
178dd351 60}
61
62
63AliHLTCaloMapper::~AliHLTCaloMapper()
64{
178dd351 65 delete [] fHw2geomapPtr;
66 fHw2geomapPtr = 0;
67}
68
69
70//void AliHLTCaloMapper::InitAltroMapping(){
71 //Virtual base class
72//}
73
74//void AliHLTCaloMapper::InitDDLSpecificationMapping() {
75 //Virtual base class
76//}
77
78
79
80bool
81AliHLTCaloMapper::GetIsInitializedMapping()
82{
178dd351 83 return fIsInitializedMapping;
84}
85
86
87char*
88AliHLTCaloMapper::GetFilePath()
89{
178dd351 90 return fFilepath;
91}
92
93
77f350f7 94int
95AliHLTCaloMapper::GetChannelID(const AliHLTUInt32_t spec, const Int_t hadd)
96{
97 Short_t index = GetDDLFromSpec(spec);
98 if( index < 0 )
99 {
f137c3c5 100 HLTError("Specification 0x%X not consistent with single DDL in PHOS", spec);
77f350f7 101 return index;
102 }
103 else
104 {
105 return ((fHw2geomapPtr[hadd].fXCol ) |
106 ((fHw2geomapPtr[hadd].fZRow ) << 6) |
107 (fHw2geomapPtr[hadd].fGain << 12) |
108 fSpecificationMapPtr[index].fModId << 13);
109 }
110}
111
112
77f350f7 113void
114AliHLTCaloMapper::GetChannelCoord(const UShort_t channelId, UShort_t* channelCoord)
115{
116 channelCoord[0] = channelId&0x3f;
117 channelCoord[1] = (channelId >> 6)&0x3f;
118 channelCoord[2] = (channelId >> 12)&0x1;
119 channelCoord[3] = (channelId >> 13)&0x1f;
ad44d760 120 // printf("Channel ID: 0x%X Coordinates: x = %d, z = %d, gain = %d\n", channelId, channelCoord[0], channelCoord[1], channelCoord[2]);
77f350f7 121}
122
178dd351 123void
b850c417 124AliHLTCaloMapper::ChannelId2Coordinate(const int channelId, AliHLTCaloCoordinate &channelCoord)
178dd351 125{
178dd351 126 channelCoord.fX = channelId&0x3f;
127 channelCoord.fZ = (channelId >> 6)&0x3f;
128 channelCoord.fGain = (channelId >> 12)&0x1;
129 channelCoord.fModuleId = (channelId >> 13)&0x1f;
130 // printf("Channel ID: 0x%X Coordinates: x = %d, z = %d, gain = %d\n", channelId, channelCoord[0], channelCoord[1], channelCoord[2]);
131}
3800a654 132
133
77f350f7 134void
135AliHLTCaloMapper::GetLocalCoord(const int channelId, Float_t* localCoord) const
136{
137 localCoord[0] = (static_cast<Float_t>(channelId&0x3f) - fCaloConstants->GetNXCOLUMNSMOD()/2)* fCaloConstants->GetCELLSTEP();
76ffc0ce 138 // localCoord[0] = (static_cast<Float_t>(channelId&0x3f) - fCaloConstants->GetNXCOLUMNSMOD()/2)*CELLSTEP;
77f350f7 139 localCoord[1] = (static_cast<Float_t>((channelId >> 6)&0x3f) - fCaloConstants->GetNZROWSMOD()/2) * fCaloConstants->GetCELLSTEP();
140 // printf("Local coordinates: x = %f, z = %f\n", channelCoord[0], channelCoord[1]);
141}
142
143
3800a654 144int
145AliHLTCaloMapper::GetDDLFromSpec( const AliHLTUInt32_t spec )
146{
147 int tmpIndex = -1;
148 for(int i=0; i < 32; i++ )
149 {
150 if (spec >> i ==1)
151 {
152 tmpIndex = i;
153 break;
154 }
155 }
156 if( tmpIndex < 0)
157 {
158 // HLTError("Specification %d, not consistent with any DDL in PHOS or EMCAL", spec );
159 }
f137c3c5 160
3800a654 161 return tmpIndex;
162}
163
b850c417 164
77f350f7 165Int_t
4d2d113d 166AliHLTCaloMapper::GetModuleFromSpec(UInt_t specification)
3800a654 167{
4d2d113d 168
169 Int_t module = -1;
723e5d31 170 // get rid of too much string operations
171
172 // if (fCaloDet.CompareTo("PHOS") == 0) {
173
174 if (fCaloDet[0]=='P') {
175 // P = is the short for PHOS
4d2d113d 176 // 1 module = 4 bits
177 if(specification & 0xf) module = 0;
178 else if((specification >> 4) & 0xf) module = 1;
179 else if((specification >> 8) & 0xf) module = 2;
180 else if((specification >> 12) & 0xf) module = 3;
181 else if((specification >> 16) & 0xf) module = 4;
182 else {
183 HLTDebug("Specification 0x%X not consistent with single module in PHOS", specification);
184 }
185
186 return module;
62b6c2f0 187 }
723e5d31 188 //else if (fCaloDet.CompareTo("EMCAL") == 0) {
189 else if (fCaloDet[0]=='E') {
190
191 // E = is the short for EMCAL
4d2d113d 192 // 1 module = 2 bits
193 if(specification & 0x3) module = 0;
194 else if((specification >> 2) & 0x3) module = 1;
195 else if((specification >> 4) & 0x3) module = 2;
196 else if((specification >> 6) & 0x3) module = 3;
197 else if((specification >> 8) & 0x3) module = 4;
198 else if((specification >> 10) & 0x3) module = 5;
199 else if((specification >> 12) & 0x3) module = 6;
200 else if((specification >> 14) & 0x3) module = 7;
201 else if((specification >> 16) & 0x3) module = 8;
202 else if((specification >> 18) & 0x3) module = 9;
203 else {
204 HLTDebug("Specification 0x%X not consistent with single module in EMCAL", specification);
205 }
206 return module;
207
208 } else {
209 HLTDebug("Specification 0x%X not consistent with single module in EMCAL or PHOS", specification);
210 }
723e5d31 211 return module;
3800a654 212}
213
214
3800a654 215unsigned long
216AliHLTCaloMapper::GetSpecFromDDLIndex( const int ddlindex )
217{
218 int iret = (unsigned long)1 << ddlindex;
219
220 // return ((unsigned long)1) << ddlindex ) ;
221
222 return iret;
223
224}
225