1 /**************************************************************************
2 * This file is property of and copyright by the Experimental Nuclear *
3 * Physics Group, Dep. of Physics *
4 * University of Oslo, Norway, 2007 *
6 * Author: Per Thomas Hille <perthi@fys.uio.no> for the ALICE HLT Project.*
7 * Contributors are mentioned in the code where appropriate. *
8 * Please report bugs to perthi@fys.uio.no *
10 * Permission to use, copy, modify and distribute this software and its *
11 * documentation strictly for non-commercial purposes is hereby granted *
12 * without fee, provided that the above copyright notice appears in all *
13 * copies and that both the copyright notice and this permission notice *
14 * appear in the supporting documentation. The authors make no claims *
15 * about the suitability of this software for any purpose. It is *
16 * provided "as is" without express or implied warranty. *
17 **************************************************************************/
18 #include "AliHLTEMCALMapper.h"
20 #include "AliHLTEMCALConstants.h"
22 using namespace EmcalHLTConst;
26 AliHLTEMCALMapper::AliHLTEMCALMapper()
29 InitDDLSpecificationMapping();
30 fIsInitializedMapping = true; //CRAP PTH, must check is the initilization actually went ok
33 AliHLTEMCALMapper::~AliHLTEMCALMapper()
41 AliHLTEMCALMapper::InitAltroMapping()
43 // Loads mapping between Altro addresses and geometrical addresses from file
44 // char filename[256];
45 char *base = getenv("ALICE_ROOT");
56 sprintf(fFilepath,"%s/PHOS/mapping/RCU0.data", base);
57 FILE *fp = fopen(fFilepath, "r");
60 res = fscanf(fp, "%d", &nChannels);
61 res = fscanf(fp, "%d", &maxaddr);
62 fHw2geomapPtr = new fAltromap[maxaddr +1];
64 for(int i=0; i< maxaddr + 1 ; i ++)
66 fHw2geomapPtr[i].fXCol = 0;
67 fHw2geomapPtr[i].fZRow = 0;
68 fHw2geomapPtr[i].fGain = 0;
70 for(int i=0; i<nChannels; i ++)
72 res = fscanf(fp, "%d %d %d %d\n", &tmpHwaddr, &tmpXCol, &tmpZRow, &tmpGain);
75 fHw2geomapPtr[tmpHwaddr].fXCol = tmpXCol;
76 fHw2geomapPtr[tmpHwaddr].fZRow = tmpZRow;
77 fHw2geomapPtr[tmpHwaddr].fGain = tmpGain;
80 fIsInitializedMapping = true;
85 fIsInitializedMapping = false;
90 fIsInitializedMapping = false;
98 AliHLTEMCALMapper::InitDDLSpecificationMapping()
100 fSpecificationMapPtr = new fDDLSpecificationMap[EmcalHLTConst::NMODULES*EmcalHLTConst::NRCUSPERMODULE];
102 for(Int_t ddl = 0; ddl < EmcalHLTConst::NMODULES*EmcalHLTConst::NRCUSPERMODULE; ddl++)
105 fSpecificationMapPtr[ddl].fModId = ddl/EmcalHLTConst::NRCUSPERMODULE;
109 fSpecificationMapPtr[ddl].fRcuX = 0;
110 fSpecificationMapPtr[ddl].fRcuZ = 0;
115 fSpecificationMapPtr[ddl].fRcuX = 1;
116 fSpecificationMapPtr[ddl].fRcuZ = 0;
121 fSpecificationMapPtr[ddl].fRcuX = 2;
122 fSpecificationMapPtr[ddl].fRcuZ = 0;
126 fSpecificationMapPtr[ddl].fRcuX = 3;
127 fSpecificationMapPtr[ddl].fRcuZ = 0;
130 fSpecificationMapPtr[ddl].fRcuZOffset = NZROWSRCU*(fSpecificationMapPtr[ddl].fRcuZ);
131 fSpecificationMapPtr[ddl].fRcuXOffset = NXCOLUMNSRCU*(fSpecificationMapPtr[ddl].fRcuX);
137 AliHLTEMCALMapper::GetDDLFromSpec( const AliHLTUInt32_t specification )
140 if(specification == 0x00001) index = 0;
141 else if(specification == 0x00002) index = 1;
142 else if(specification == 0x00004) index = 2;
143 else if(specification == 0x00008) index = 3;
145 else if(specification == 0x00010) index = 4;
146 else if(specification == 0x00020) index = 5;
147 else if(specification == 0x00040) index = 6;
148 else if(specification == 0x00080) index = 7;
150 else if(specification == 0x00100) index = 8;
151 else if(specification == 0x00200) index = 9;
152 else if(specification == 0x00400) index = 10;
153 else if(specification == 0x00800) index = 11;
155 else if(specification == 0x01000) index = 12;
156 else if(specification == 0x02000) index = 13;
157 else if(specification == 0x04000) index = 14;
158 else if(specification == 0x08000) index = 15;
160 else if(specification == 0x10000) index = 16;
161 else if(specification == 0x20000) index = 17;
162 else if(specification == 0x40000) index = 18;
163 else if(specification == 0x80000) index = 19;
165 else HLTError("Specification 0x%X not consistent with single DDL in PHOS", specification);
172 AliHLTEMCALMapper::GetChannelID(const AliHLTUInt32_t specification, const Int_t hwAddress )
176 Short_t index = GetDDLFromSpec( specification);
180 HLTError("Specification 0x%X not consistent with single DDL in PHOS", specification);
183 // else HLTError("Specification 0x%X not consistent with single DDL in PHOS", specification);
185 return ((fHw2geomapPtr[hwAddress].fXCol + fSpecificationMapPtr[index].fRcuXOffset) |
186 ((fHw2geomapPtr[hwAddress].fZRow + fSpecificationMapPtr[index].fRcuZOffset) << 6) |
187 (fHw2geomapPtr[hwAddress].fGain << 12) |
188 fSpecificationMapPtr[index].fModId << 13);