]>
Commit | Line | Data |
---|---|---|
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 | 46 | ClassImp(AliHLTCaloMapper); |
178dd351 | 47 | |
77f350f7 | 48 | AliHLTCaloMapper::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), | |
4f4b7ba4 | 55 | fSpecificationMapPtr(0) |
178dd351 | 56 | { |
57 | //see header file for class documentation | |
fe4e0365 | 58 | fFilepath[0] = '\0'; |
178dd351 | 59 | } |
60 | ||
61 | ||
62 | AliHLTCaloMapper::~AliHLTCaloMapper() | |
63 | { | |
178dd351 | 64 | delete [] fHw2geomapPtr; |
65 | fHw2geomapPtr = 0; | |
66 | } | |
67 | ||
68 | ||
69 | //void AliHLTCaloMapper::InitAltroMapping(){ | |
70 | //Virtual base class | |
71 | //} | |
72 | ||
73 | //void AliHLTCaloMapper::InitDDLSpecificationMapping() { | |
74 | //Virtual base class | |
75 | //} | |
76 | ||
77 | ||
78 | ||
79 | bool | |
80 | AliHLTCaloMapper::GetIsInitializedMapping() | |
81 | { | |
178dd351 | 82 | return fIsInitializedMapping; |
83 | } | |
84 | ||
85 | ||
86 | char* | |
87 | AliHLTCaloMapper::GetFilePath() | |
88 | { | |
178dd351 | 89 | return fFilepath; |
90 | } | |
91 | ||
92 | ||
77f350f7 | 93 | int |
94 | AliHLTCaloMapper::GetChannelID(const AliHLTUInt32_t spec, const Int_t hadd) | |
95 | { | |
96 | Short_t index = GetDDLFromSpec(spec); | |
97 | if( index < 0 ) | |
98 | { | |
f137c3c5 | 99 | HLTError("Specification 0x%X not consistent with single DDL in PHOS", spec); |
77f350f7 | 100 | return index; |
101 | } | |
102 | else | |
103 | { | |
104 | return ((fHw2geomapPtr[hadd].fXCol ) | | |
105 | ((fHw2geomapPtr[hadd].fZRow ) << 6) | | |
106 | (fHw2geomapPtr[hadd].fGain << 12) | | |
107 | fSpecificationMapPtr[index].fModId << 13); | |
108 | } | |
109 | } | |
110 | ||
111 | ||
77f350f7 | 112 | void |
113 | AliHLTCaloMapper::GetChannelCoord(const UShort_t channelId, UShort_t* channelCoord) | |
114 | { | |
115 | channelCoord[0] = channelId&0x3f; | |
116 | channelCoord[1] = (channelId >> 6)&0x3f; | |
117 | channelCoord[2] = (channelId >> 12)&0x1; | |
118 | channelCoord[3] = (channelId >> 13)&0x1f; | |
ad44d760 | 119 | // printf("Channel ID: 0x%X Coordinates: x = %d, z = %d, gain = %d\n", channelId, channelCoord[0], channelCoord[1], channelCoord[2]); |
77f350f7 | 120 | } |
121 | ||
178dd351 | 122 | void |
b850c417 | 123 | AliHLTCaloMapper::ChannelId2Coordinate(const int channelId, AliHLTCaloCoordinate &channelCoord) |
178dd351 | 124 | { |
178dd351 | 125 | channelCoord.fX = channelId&0x3f; |
126 | channelCoord.fZ = (channelId >> 6)&0x3f; | |
127 | channelCoord.fGain = (channelId >> 12)&0x1; | |
128 | channelCoord.fModuleId = (channelId >> 13)&0x1f; | |
129 | // printf("Channel ID: 0x%X Coordinates: x = %d, z = %d, gain = %d\n", channelId, channelCoord[0], channelCoord[1], channelCoord[2]); | |
130 | } | |
3800a654 | 131 | |
132 | ||
77f350f7 | 133 | void |
134 | AliHLTCaloMapper::GetLocalCoord(const int channelId, Float_t* localCoord) const | |
135 | { | |
136 | localCoord[0] = (static_cast<Float_t>(channelId&0x3f) - fCaloConstants->GetNXCOLUMNSMOD()/2)* fCaloConstants->GetCELLSTEP(); | |
76ffc0ce | 137 | // localCoord[0] = (static_cast<Float_t>(channelId&0x3f) - fCaloConstants->GetNXCOLUMNSMOD()/2)*CELLSTEP; |
77f350f7 | 138 | localCoord[1] = (static_cast<Float_t>((channelId >> 6)&0x3f) - fCaloConstants->GetNZROWSMOD()/2) * fCaloConstants->GetCELLSTEP(); |
139 | // printf("Local coordinates: x = %f, z = %f\n", channelCoord[0], channelCoord[1]); | |
140 | } | |
141 | ||
142 | ||
3800a654 | 143 | int |
144 | AliHLTCaloMapper::GetDDLFromSpec( const AliHLTUInt32_t spec ) | |
145 | { | |
146 | int tmpIndex = -1; | |
147 | for(int i=0; i < 32; i++ ) | |
148 | { | |
149 | if (spec >> i ==1) | |
150 | { | |
151 | tmpIndex = i; | |
152 | break; | |
153 | } | |
154 | } | |
155 | if( tmpIndex < 0) | |
156 | { | |
157 | // HLTError("Specification %d, not consistent with any DDL in PHOS or EMCAL", spec ); | |
158 | } | |
f137c3c5 | 159 | |
3800a654 | 160 | return tmpIndex; |
161 | } | |
162 | ||
b850c417 | 163 | |
77f350f7 | 164 | Int_t |
165 | AliHLTCaloMapper::GetModuleFromSpec(Int_t specification) | |
3800a654 | 166 | { |
77f350f7 | 167 | Int_t module = -1; |
168 | ||
169 | if(specification & 0xf) module = 0; | |
170 | else if((specification >> 4) & 0xf) module = 1; | |
171 | else if((specification >> 8) & 0xf) module = 2; | |
172 | else if((specification >> 12) & 0xf) module = 3; | |
173 | else if((specification >> 16) & 0xf) module = 4; | |
174 | ||
175 | else HLTError("Specification 0x%X not consistent with single module in PHOS", specification); | |
176 | ||
177 | return module; | |
3800a654 | 178 | } |
179 | ||
180 | ||
3800a654 | 181 | unsigned long |
182 | AliHLTCaloMapper::GetSpecFromDDLIndex( const int ddlindex ) | |
183 | { | |
184 | int iret = (unsigned long)1 << ddlindex; | |
185 | ||
186 | // return ((unsigned long)1) << ddlindex ) ; | |
187 | ||
188 | return iret; | |
189 | ||
190 | } | |
191 |