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 "AliHLTEMCALConstant.h"
24 using namespace EmcalHLTConst;
29 AliHLTEMCALMapper::AliHLTEMCALMapper(const unsigned long specification ) : AliHLTCaloMapper(specification, "EMCAL")
32 InitAltroMapping(specification);
33 InitDDLSpecificationMapping();
34 fIsInitializedMapping = true; //CRAP PTH, must check if the initilization actually went ok
38 AliHLTEMCALMapper::~AliHLTEMCALMapper()
45 AliHLTEMCALMapper::GetLocalCoord(const int channelId, Float_t* localCoord) const
47 localCoord[0] = ( ( Float_t )(channelId&0x3f) - NXCOLUMNSMOD/2) * fCellSize;
48 localCoord[1] = ( (Float_t)((channelId >> 6)&0x3f) - NZROWSMOD/2) * fCellSize;
53 AliHLTEMCALMapper::InitAltroMapping(const unsigned long specification )
55 char *base = getenv("ALICE_ROOT");
66 sprintf(fFilepath, "%s/EMCAL/mapping/%s", base, DDL2RcuMapFileName( GetDDLFromSpec( specification ) ) );
67 sprintf(fFilepath, "%s/EMCAL/mapping/%s", base, DDL2RcuMapFileName( GetDDLFromSpec( specification ) ) );
69 FILE *fp = fopen(fFilepath, "r");
72 res = fscanf(fp, "%d\n", &nChannels);
73 res = fscanf(fp, "%d\n", &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;
82 for(int i=0; i<nChannels; i ++)
84 res = fscanf(fp, "%d %d %d %d\n", &tmpHwaddr, &tmpXCol, &tmpZRow, &tmpGain);
88 fHw2geomapPtr[tmpHwaddr].fXCol = (char)tmpXCol;
89 fHw2geomapPtr[tmpHwaddr].fZRow = (char)tmpZRow;
90 fHw2geomapPtr[tmpHwaddr].fGain = (char)tmpGain;
93 fIsInitializedMapping = true;
98 fIsInitializedMapping = false;
103 fIsInitializedMapping = false;
106 return fIsInitializedMapping;
111 AliHLTEMCALMapper::InitDDLSpecificationMapping()
113 fSpecificationMapPtr = new fDDLSpecificationMap[EmcalHLTConst::NMODULES*EmcalHLTConst::NRCUSPERMODULE];
115 for(Int_t ddl = 0; ddl < EmcalHLTConst::NMODULES*EmcalHLTConst::NRCUSPERMODULE; ddl++)
117 fSpecificationMapPtr[ddl].fModId = ddl/(EmcalHLTConst::NRCUSPERMODULE);
122 AliHLTEMCALMapper::DDL2RcuMapFileName(const int ddlIndex) const //0=4608, 1=4607 etc...
124 static char rname[256];
127 if ( ddlIndex%NRCUSPERSECTOR <2)
135 int tmprcuindex = ddlIndex%2;
136 sprintf(rname,"RCU%d%c.data", tmprcuindex, tmpSide );
137 //sprintf(rname,"RCU%d%c.data", ddlIndex/NRCUSPERSECTOR, tmpSide );