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 *
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 *
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 **************************************************************************/
22 // Mapping class fro mapping
23 // from hardware address to geometrical address
27 #include "AliHLTPHOSMapper.h"
28 #include "AliHLTPHOSConstants.h"
29 #include "AliHLTLogging.h"
34 using namespace PhosHLTConst;
35 AliHLTPHOSMapper::AliHLTPHOSMapper(): AliHLTLogging(),
37 fIsInitializedMapping(false),
38 fSpecificationMapPtr(0)
41 InitDDLSpecificationMapping();
45 AliHLTPHOSMapper::~AliHLTPHOSMapper()
47 delete [] fHw2geomapPtr;
52 AliHLTPHOSMapper::InitAltroMapping()
54 // Loads mapping between Altro addresses and geometrical addresses from file
56 // char filename[256];
57 char *base = getenv("ALICE_ROOT");
64 int res = 0; //OD to get rid of warnings
67 sprintf(fFilepath,"%s/PHOS/mapping/RCU0.data", base);
69 FILE *fp = fopen(fFilepath, "r");
72 res = fscanf(fp, "%d", &nChannels);
73 res = fscanf(fp, "%d", &maxaddr);
74 fHw2geomapPtr = new fAltromap[maxaddr +1];
76 for(int i=0; i< maxaddr + 1 ; i ++)
78 fHw2geomapPtr[i].fXCol = 0;
79 fHw2geomapPtr[i].fZRow = 0;
80 fHw2geomapPtr[i].fGain = 0;
83 for(int i=0; i<nChannels; i ++)
85 res = fscanf(fp, "%d %d %d %d\n", &tmpHwaddr, &tmpXCol, &tmpZRow, &tmpGain);
86 fHw2geomapPtr[tmpHwaddr].fXCol = tmpXCol;
87 fHw2geomapPtr[tmpHwaddr].fZRow = tmpZRow;
88 fHw2geomapPtr[tmpHwaddr].fGain = tmpGain;
90 fIsInitializedMapping = true;
95 fIsInitializedMapping = false;
100 fIsInitializedMapping = false;
105 AliHLTPHOSMapper::InitDDLSpecificationMapping()
107 fSpecificationMapPtr = new fDDLSpecificationMap[PhosHLTConst::N_MODULES*PhosHLTConst::N_RCUS_PER_MODULE];
108 for(Int_t ddl = 0; ddl < PhosHLTConst::N_MODULES*PhosHLTConst::N_RCUS_PER_MODULE; ddl++)
111 fSpecificationMapPtr[ddl].fModId = ddl/PhosHLTConst::N_RCUS_PER_MODULE;
115 fSpecificationMapPtr[ddl].fRcuX = 0;
116 fSpecificationMapPtr[ddl].fRcuZ = 0;
121 fSpecificationMapPtr[ddl].fRcuX = 0;
122 fSpecificationMapPtr[ddl].fRcuZ = 1;
127 fSpecificationMapPtr[ddl].fRcuX = 1;
128 fSpecificationMapPtr[ddl].fRcuZ = 0;
132 fSpecificationMapPtr[ddl].fRcuX = 1;
133 fSpecificationMapPtr[ddl].fRcuZ = 1;
136 fSpecificationMapPtr[ddl].fRcuZOffset = N_ZROWS_RCU*(fSpecificationMapPtr[ddl].fRcuZ);
137 fSpecificationMapPtr[ddl].fRcuXOffset = N_XCOLUMNS_RCU*(fSpecificationMapPtr[ddl].fRcuX);
143 AliHLTPHOSMapper::GetIsInitializedMapping()
145 return fIsInitializedMapping;
150 AliHLTPHOSMapper::GetFilePath()
156 AliHLTPHOSMapper::GetChannelID(Int_t specification, Int_t hwAddress)
161 if(specification == 0x00001) index = 0;
162 else if(specification == 0x00002) index = 1;
163 else if(specification == 0x00004) index = 2;
164 else if(specification == 0x00008) index = 3;
166 else if(specification == 0x00010) index = 4;
167 else if(specification == 0x00020) index = 5;
168 else if(specification == 0x00040) index = 6;
169 else if(specification == 0x00080) index = 7;
171 else if(specification == 0x00100) index = 8;
172 else if(specification == 0x00200) index = 9;
173 else if(specification == 0x00400) index = 10;
174 else if(specification == 0x00800) index = 11;
176 else if(specification == 0x01000) index = 12;
177 else if(specification == 0x02000) index = 13;
178 else if(specification == 0x04000) index = 14;
179 else if(specification == 0x08000) index = 15;
181 else if(specification == 0x10000) index = 16;
182 else if(specification == 0x20000) index = 17;
183 else if(specification == 0x40000) index = 18;
184 else if(specification == 0x80000) index = 19;
186 else HLTError("Specification 0x%X not consistent with single DDL in PHOS", specification);
188 return ((fHw2geomapPtr[hwAddress].fXCol + fSpecificationMapPtr[index].fRcuXOffset) |
189 ((fHw2geomapPtr[hwAddress].fZRow + fSpecificationMapPtr[index].fRcuZOffset) << 6) |
190 (fHw2geomapPtr[hwAddress].fGain << 12) |
191 fSpecificationMapPtr[index].fModId << 13);
195 AliHLTPHOSMapper::GetChannelCoord(UShort_t channelId, UShort_t* channelCoord)
197 channelCoord[0] = channelId&0x3f;
198 channelCoord[1] = (channelId >> 6)&0x3f;
199 channelCoord[2] = (channelId >> 12)&0x1;
200 channelCoord[3] = (channelId >> 13)&0x1f;