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 **************************************************************************/
19 #include "AliHLTEMCALMapper.h"
21 //#include "AliHLTEMCALConstant.h"
22 // #include "AliHLTCaloConstant.h"
26 //using namespace EmcalHLTConst;
28 #include "AliHLTCaloConstants.h"
30 using EMCAL::NXCOLUMNSMOD;
31 using EMCAL::NZROWSMOD;
32 using EMCAL::NMODULES;
33 using EMCAL::NRCUSPERMODULE;
34 using EMCAL::NRCUSPERSECTOR;
36 AliHLTEMCALMapper::AliHLTEMCALMapper(const unsigned long specification ) : AliHLTCaloMapper(specification, "EMCAL")
39 InitAltroMapping(specification);
40 InitDDLSpecificationMapping();
41 fIsInitializedMapping = true; //CRAP PTH, must check if the initilization actually went ok
45 AliHLTEMCALMapper::~AliHLTEMCALMapper()
52 AliHLTEMCALMapper::GetLocalCoord(const int channelId, Float_t* localCoord) const
54 localCoord[0] = ( ( Float_t )(channelId&0x3f) - NXCOLUMNSMOD/2) * fCellSize;
55 localCoord[1] = ( (Float_t)((channelId >> 6)&0x3f) - NZROWSMOD/2) * fCellSize;
60 AliHLTEMCALMapper::InitAltroMapping(const unsigned long specification )
62 char *base = getenv("ALICE_ROOT");
73 sprintf(fFilepath, "%s/EMCAL/mapping/%s", base, DDL2RcuMapFileName( GetDDLFromSpec( specification ) ) );
74 sprintf(fFilepath, "%s/EMCAL/mapping/%s", base, DDL2RcuMapFileName( GetDDLFromSpec( specification ) ) );
76 FILE *fp = fopen(fFilepath, "r");
79 res = fscanf(fp, "%d\n", &nChannels);
80 res = fscanf(fp, "%d\n", &maxaddr);
81 fHw2geomapPtr = new fAltromap[maxaddr +1];
83 for(int i=0; i< maxaddr + 1 ; i ++)
85 fHw2geomapPtr[i].fXCol = 0;
86 fHw2geomapPtr[i].fZRow = 0;
87 fHw2geomapPtr[i].fGain = 0;
89 for(int i=0; i<nChannels; i ++)
91 res = fscanf(fp, "%d %d %d %d\n", &tmpHwaddr, &tmpXCol, &tmpZRow, &tmpGain);
95 fHw2geomapPtr[tmpHwaddr].fXCol = (char)tmpXCol;
96 fHw2geomapPtr[tmpHwaddr].fZRow = (char)tmpZRow;
97 fHw2geomapPtr[tmpHwaddr].fGain = (char)tmpGain;
100 fIsInitializedMapping = true;
105 fIsInitializedMapping = false;
110 fIsInitializedMapping = false;
113 return fIsInitializedMapping;
118 AliHLTEMCALMapper::InitDDLSpecificationMapping()
120 fSpecificationMapPtr = new fDDLSpecificationMap[NMODULES*NRCUSPERMODULE];
122 for(Int_t ddl = 0; ddl < NMODULES*NRCUSPERMODULE; ddl++)
124 fSpecificationMapPtr[ddl].fModId = ddl/( NRCUSPERMODULE );
129 AliHLTEMCALMapper::DDL2RcuMapFileName(const int ddlIndex) const //0=4608, 1=4607 etc...
131 static char rname[256];
134 if ( ddlIndex%NRCUSPERSECTOR <2)
142 int tmprcuindex = ddlIndex%2;
143 sprintf(rname,"RCU%d%c.data", tmprcuindex, tmpSide );
144 //sprintf(rname,"RCU%d%c.data", ddlIndex/NRCUSPERSECTOR, tmpSide );