]>
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" |
77f350f7 | 34 | #include "AliHLTCaloConstants.h" |
178dd351 | 35 | |
4f4b7ba4 | 36 | ClassImp(AliHLTCaloMapper); |
178dd351 | 37 | |
77f350f7 | 38 | AliHLTCaloMapper::AliHLTCaloMapper( const unsigned long specification , TString det) : |
39 | AliHLTLogging(), | |
4f4b7ba4 | 40 | AliHLTCaloConstantsHandler(det), |
77f350f7 | 41 | fHw2geomapPtr(0), |
42 | fCellSize(0), | |
43 | fSpecification(specification), | |
44 | fIsInitializedMapping(false), | |
4f4b7ba4 | 45 | fSpecificationMapPtr(0) |
178dd351 | 46 | { |
47 | //see header file for class documentation | |
48 | } | |
49 | ||
50 | ||
51 | AliHLTCaloMapper::~AliHLTCaloMapper() | |
52 | { | |
178dd351 | 53 | delete [] fHw2geomapPtr; |
54 | fHw2geomapPtr = 0; | |
55 | } | |
56 | ||
57 | ||
58 | //void AliHLTCaloMapper::InitAltroMapping(){ | |
59 | //Virtual base class | |
60 | //} | |
61 | ||
62 | //void AliHLTCaloMapper::InitDDLSpecificationMapping() { | |
63 | //Virtual base class | |
64 | //} | |
65 | ||
66 | ||
67 | ||
68 | bool | |
69 | AliHLTCaloMapper::GetIsInitializedMapping() | |
70 | { | |
178dd351 | 71 | return fIsInitializedMapping; |
72 | } | |
73 | ||
74 | ||
75 | char* | |
76 | AliHLTCaloMapper::GetFilePath() | |
77 | { | |
178dd351 | 78 | return fFilepath; |
79 | } | |
80 | ||
81 | ||
77f350f7 | 82 | int |
83 | AliHLTCaloMapper::GetChannelID(const AliHLTUInt32_t spec, const Int_t hadd) | |
84 | { | |
85 | Short_t index = GetDDLFromSpec(spec); | |
86 | if( index < 0 ) | |
87 | { | |
88 | // HLTError("Specification 0x%X not consistent with single DDL in PHOS", spec); | |
89 | return index; | |
90 | } | |
91 | else | |
92 | { | |
93 | return ((fHw2geomapPtr[hadd].fXCol ) | | |
94 | ((fHw2geomapPtr[hadd].fZRow ) << 6) | | |
95 | (fHw2geomapPtr[hadd].fGain << 12) | | |
96 | fSpecificationMapPtr[index].fModId << 13); | |
97 | } | |
98 | } | |
99 | ||
100 | ||
101 | ||
102 | // UShort_t | |
103 | // AliHLTCaloMapper::GetChannelID(Int_t specification, Int_t hwAddress) | |
104 | // { | |
105 | ||
106 | // Short_t index = 0; | |
107 | ||
108 | // if(specification == 0x00001) index = 0; | |
109 | // else if(specification == 0x00002) index = 1; | |
110 | // else if(specification == 0x00004) index = 2; | |
111 | // else if(specification == 0x00008) index = 3; | |
112 | ||
113 | // else if(specification == 0x00010) index = 4; | |
114 | // else if(specification == 0x00020) index = 5; | |
115 | // else if(specification == 0x00040) index = 6; | |
116 | // else if(specification == 0x00080) index = 7; | |
117 | ||
118 | // else if(specification == 0x00100) index = 8; | |
119 | // else if(specification == 0x00200) index = 9; | |
120 | // else if(specification == 0x00400) index = 10; | |
121 | // else if(specification == 0x00800) index = 11; | |
122 | ||
123 | // else if(specification == 0x01000) index = 12; | |
124 | // else if(specification == 0x02000) index = 13; | |
125 | // else if(specification == 0x04000) index = 14; | |
126 | // else if(specification == 0x08000) index = 15; | |
127 | ||
128 | // else if(specification == 0x10000) index = 16; | |
129 | // else if(specification == 0x20000) index = 17; | |
130 | // else if(specification == 0x40000) index = 18; | |
131 | // else if(specification == 0x80000) index = 19; | |
132 | ||
133 | // else HLTError("Specification 0x%X not consistent with single DDL in PHOS", specification); | |
134 | // // HLTError("Channel ID: 0x%X Coordinates: x = %d, z = %d, gain = %d", ((fHw2geomapPtr[hwAddress].fXCol + fSpecificationMapPtr[index].fRcuXOffset) |((fHw2geomapPtr[hwAddress].fZRow + fSpecificationMapPtr[index].fRcuZOffset) << 6) | (fHw2geomapPtr[hwAddress].fGain << 12) | fSpecificationMapPtr[index].fModId << 13), | |
135 | // // fHw2geomapPtr[hwAddress].fXCol, | |
136 | // // fHw2geomapPtr[hwAddress].fZRow, | |
137 | // // fHw2geomapPtr[hwAddress].fGain); | |
138 | // return ((fHw2geomapPtr[hwAddress].fXCol + fSpecificationMapPtr[index].fRcuXOffset) | | |
139 | // ((fHw2geomapPtr[hwAddress].fZRow + fSpecificationMapPtr[index].fRcuZOffset) << 6) | | |
140 | // (fHw2geomapPtr[hwAddress].fGain << 12) | | |
141 | // fSpecificationMapPtr[index].fModId << 13); | |
142 | // } | |
143 | ||
144 | ||
145 | void | |
146 | AliHLTCaloMapper::GetChannelCoord(const UShort_t channelId, UShort_t* channelCoord) | |
147 | { | |
148 | channelCoord[0] = channelId&0x3f; | |
149 | channelCoord[1] = (channelId >> 6)&0x3f; | |
150 | channelCoord[2] = (channelId >> 12)&0x1; | |
151 | channelCoord[3] = (channelId >> 13)&0x1f; | |
152 | // printf("Channel ID: 0x%X Coordinates: x = %d, z = %d, gain = %d\n", channelId, channelCoord[0], channelCoord[1], channelCoord[2]); | |
153 | } | |
154 | ||
178dd351 | 155 | void |
b850c417 | 156 | AliHLTCaloMapper::ChannelId2Coordinate(const int channelId, AliHLTCaloCoordinate &channelCoord) |
178dd351 | 157 | { |
178dd351 | 158 | channelCoord.fX = channelId&0x3f; |
159 | channelCoord.fZ = (channelId >> 6)&0x3f; | |
160 | channelCoord.fGain = (channelId >> 12)&0x1; | |
161 | channelCoord.fModuleId = (channelId >> 13)&0x1f; | |
162 | // printf("Channel ID: 0x%X Coordinates: x = %d, z = %d, gain = %d\n", channelId, channelCoord[0], channelCoord[1], channelCoord[2]); | |
163 | } | |
3800a654 | 164 | |
165 | ||
77f350f7 | 166 | void |
167 | AliHLTCaloMapper::GetLocalCoord(const int channelId, Float_t* localCoord) const | |
168 | { | |
169 | localCoord[0] = (static_cast<Float_t>(channelId&0x3f) - fCaloConstants->GetNXCOLUMNSMOD()/2)* fCaloConstants->GetCELLSTEP(); | |
170 | localCoord[1] = (static_cast<Float_t>((channelId >> 6)&0x3f) - fCaloConstants->GetNZROWSMOD()/2) * fCaloConstants->GetCELLSTEP(); | |
171 | // printf("Local coordinates: x = %f, z = %f\n", channelCoord[0], channelCoord[1]); | |
172 | } | |
173 | ||
174 | ||
3800a654 | 175 | int |
176 | AliHLTCaloMapper::GetDDLFromSpec( const AliHLTUInt32_t spec ) | |
177 | { | |
178 | int tmpIndex = -1; | |
179 | for(int i=0; i < 32; i++ ) | |
180 | { | |
181 | if (spec >> i ==1) | |
182 | { | |
183 | tmpIndex = i; | |
184 | break; | |
185 | } | |
186 | } | |
187 | if( tmpIndex < 0) | |
188 | { | |
189 | // HLTError("Specification %d, not consistent with any DDL in PHOS or EMCAL", spec ); | |
190 | } | |
191 | return tmpIndex; | |
192 | } | |
193 | ||
b850c417 | 194 | |
77f350f7 | 195 | Int_t |
196 | AliHLTCaloMapper::GetModuleFromSpec(Int_t specification) | |
3800a654 | 197 | { |
77f350f7 | 198 | Int_t module = -1; |
199 | ||
200 | if(specification & 0xf) module = 0; | |
201 | else if((specification >> 4) & 0xf) module = 1; | |
202 | else if((specification >> 8) & 0xf) module = 2; | |
203 | else if((specification >> 12) & 0xf) module = 3; | |
204 | else if((specification >> 16) & 0xf) module = 4; | |
205 | ||
206 | else HLTError("Specification 0x%X not consistent with single module in PHOS", specification); | |
207 | ||
208 | return module; | |
3800a654 | 209 | } |
210 | ||
211 | ||
3800a654 | 212 | unsigned long |
213 | AliHLTCaloMapper::GetSpecFromDDLIndex( const int ddlindex ) | |
214 | { | |
215 | int iret = (unsigned long)1 << ddlindex; | |
216 | ||
217 | // return ((unsigned long)1) << ddlindex ) ; | |
218 | ||
219 | return iret; | |
220 | ||
221 | } | |
222 |