+// $Id$
+
/**************************************************************************
* This file is property of and copyright by the Experimental Nuclear *
* Physics Group, Dep. of Physics *
#include "AliHLTEMCALMapper.h"
#include "assert.h"
#include "AliHLTCaloConstants.h"
+#include "TString.h"
using EMCAL::NXCOLUMNSMOD;
using EMCAL::NZROWSMOD;
using EMCAL::NMODULES;
using EMCAL::NRCUSPERMODULE;
using EMCAL::NRCUSPERSECTOR;
+using EMCAL::MAXHWADDR;
+using EMCAL::MAXCHANNELS;
AliHLTEMCALMapper::AliHLTEMCALMapper(const unsigned long specification ) : AliHLTCaloMapper(specification, "EMCAL")
{
Bool_t
AliHLTEMCALMapper::InitAltroMapping(const unsigned long specification )
{
- char *base = getenv("ALICE_ROOT");
+ TString base(getenv("ALICE_ROOT"));
int nChannels = 0;
- int maxaddr = 0;
+ int maxaddr = 0; // keep as dummy for now
int tmpHwaddr = 0;
int tmpZRow = 0;
int tmpXCol = 0;
int tmpGain = 0;
int res = 0;
- if(base !=0)
+ if(!base.IsNull())
{
- snprintf(fFilepath,FILEPATHMAXLENGTH,"%s/EMCAL/mapping/%s", base, DDL2RcuMapFileName( GetDDLFromSpec( specification ) ) );
- snprintf(fFilepath, FILEPATHMAXLENGTH,"%s/EMCAL/mapping/%s", base, DDL2RcuMapFileName( GetDDLFromSpec( specification ) ) );
+ snprintf(fFilepath,FILEPATHMAXLENGTH,"%s/EMCAL/mapping/%s", base.Data(), DDL2RcuMapFileName( GetDDLFromSpec( specification ) ) );
+ snprintf(fFilepath, FILEPATHMAXLENGTH,"%s/EMCAL/mapping/%s", base.Data(), DDL2RcuMapFileName( GetDDLFromSpec( specification ) ) );
FILE *fp = fopen(fFilepath, "r");
if(fp != 0)
{
res = fscanf(fp, "%d\n", &nChannels);
res = fscanf(fp, "%d\n", &maxaddr);
- fHw2geomapPtr = new fAltromap[maxaddr +1];
-
- for(int i=0; i< maxaddr + 1 ; i ++)
+ // fHw2geomapPtr = new fAltromap[maxaddr +1];
+ fHw2geomapPtr = new fAltromap[MAXHWADDR +1];
+
+ for(int i=0; i< MAXHWADDR + 1 ; i ++)
+ //for(int i=0; i< maxaddr + 1 ; i ++)
{
fHw2geomapPtr[i].fXCol = 0;
fHw2geomapPtr[i].fZRow = 0;
fHw2geomapPtr[i].fGain = 0;
}
- for(int i=0; i<nChannels; i ++)
+ // MAXCHANNELS
+ if( nChannels > 0 && nChannels <= MAXCHANNELS )
{
- res = fscanf(fp, "%d %d %d %d\n", &tmpHwaddr, &tmpXCol, &tmpZRow, &tmpGain);
-
- if(tmpGain < 2)
+ for(int i=0; i<nChannels; i ++)
{
- fHw2geomapPtr[tmpHwaddr].fXCol = (char)tmpXCol;
- fHw2geomapPtr[tmpHwaddr].fZRow = (char)tmpZRow;
- fHw2geomapPtr[tmpHwaddr].fGain = (char)tmpGain;
- }
+ res = fscanf(fp, "%d %d %d %d\n", &tmpHwaddr, &tmpXCol, &tmpZRow, &tmpGain);
+
+ if(tmpGain < 2)
+ {
+ if( tmpHwaddr <= MAXHWADDR && tmpHwaddr >= 0 )
+ {
+ fHw2geomapPtr[tmpHwaddr].fXCol = (char)tmpXCol;
+ fHw2geomapPtr[tmpHwaddr].fZRow = (char)tmpZRow;
+ fHw2geomapPtr[tmpHwaddr].fGain = (char)tmpGain;
+ }
+ }
+ }
+ fIsInitializedMapping = true;
+ }
+ else
+ {
+ fIsInitializedMapping = false;
}
- fIsInitializedMapping = true;
fclose(fp);
}
else
void
AliHLTEMCALMapper::InitDDLSpecificationMapping()
{
+ if (fSpecificationMapPtr) delete [] fSpecificationMapPtr;
fSpecificationMapPtr = new fDDLSpecificationMap[NMODULES*NRCUSPERMODULE];
for(Int_t ddl = 0; ddl < NMODULES*NRCUSPERMODULE; ddl++)
const char*
AliHLTEMCALMapper::DDL2RcuMapFileName(const int ddlIndex) const //0=4608, 1=4607 etc...
{
- static char rname[256];
+ const int rnamelen=256;
+ static char rname[rnamelen];
char tmpSide;
if ( ddlIndex%NRCUSPERSECTOR <2)
tmpSide = 'C';
}
int tmprcuindex = ddlIndex%2;
- snprintf(rname, FILEPATHMAXLENGTH, "RCU%d%c.data", tmprcuindex, tmpSide );
+ snprintf(rname, rnamelen, "RCU%d%c.data", tmprcuindex, tmpSide );
//sprintf(rname,"RCU%d%c.data", ddlIndex/NRCUSPERSECTOR, tmpSide );
return rname;
}