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 "AliHLTCaloConstants.h"
23 using EMCAL::NXCOLUMNSMOD;
24 using EMCAL::NZROWSMOD;
25 using EMCAL::NMODULES;
26 using EMCAL::NRCUSPERMODULE;
27 using EMCAL::NRCUSPERSECTOR;
28 using EMCAL::MAXHWADDR;
29 using EMCAL::MAXCHANNELS;
31 AliHLTEMCALMapper::AliHLTEMCALMapper(const unsigned long specification ) : AliHLTCaloMapper(specification, "EMCAL")
34 InitAltroMapping(specification);
35 InitDDLSpecificationMapping();
36 fIsInitializedMapping = true; //CRAP PTH, must check if the initilization actually went ok
40 AliHLTEMCALMapper::~AliHLTEMCALMapper()
47 AliHLTEMCALMapper::GetLocalCoord(const int channelId, Float_t* localCoord) const
49 localCoord[0] = ( ( Float_t )(channelId&0x3f) - NXCOLUMNSMOD/2) * fCellSize;
50 localCoord[1] = ( (Float_t)((channelId >> 6)&0x3f) - NZROWSMOD/2) * fCellSize;
55 AliHLTEMCALMapper::InitAltroMapping(const unsigned long specification )
57 char *base = getenv("ALICE_ROOT");
59 int maxaddr = 0; // keep as dummy for now
68 snprintf(fFilepath,FILEPATHMAXLENGTH,"%s/EMCAL/mapping/%s", base, DDL2RcuMapFileName( GetDDLFromSpec( specification ) ) );
69 snprintf(fFilepath, FILEPATHMAXLENGTH,"%s/EMCAL/mapping/%s", base, DDL2RcuMapFileName( GetDDLFromSpec( specification ) ) );
71 FILE *fp = fopen(fFilepath, "r");
74 res = fscanf(fp, "%d\n", &nChannels);
75 res = fscanf(fp, "%d\n", &maxaddr);
76 // fHw2geomapPtr = new fAltromap[maxaddr +1];
77 fHw2geomapPtr = new fAltromap[MAXHWADDR +1];
79 for(int i=0; i< MAXHWADDR + 1 ; i ++)
80 //for(int i=0; i< maxaddr + 1 ; i ++)
82 fHw2geomapPtr[i].fXCol = 0;
83 fHw2geomapPtr[i].fZRow = 0;
84 fHw2geomapPtr[i].fGain = 0;
87 if( nChannels > 0 && nChannels <= MAXCHANNELS )
89 for(int i=0; i<nChannels; i ++)
91 res = fscanf(fp, "%d %d %d %d\n", &tmpHwaddr, &tmpXCol, &tmpZRow, &tmpGain);
95 if( tmpHwaddr <= MAXHWADDR && tmpHwaddr >= 0 )
97 fHw2geomapPtr[tmpHwaddr].fXCol = (char)tmpXCol;
98 fHw2geomapPtr[tmpHwaddr].fZRow = (char)tmpZRow;
99 fHw2geomapPtr[tmpHwaddr].fGain = (char)tmpGain;
103 fIsInitializedMapping = true;
107 fIsInitializedMapping = false;
113 fIsInitializedMapping = false;
118 fIsInitializedMapping = false;
121 return fIsInitializedMapping;
126 AliHLTEMCALMapper::InitDDLSpecificationMapping()
128 fSpecificationMapPtr = new fDDLSpecificationMap[NMODULES*NRCUSPERMODULE];
130 for(Int_t ddl = 0; ddl < NMODULES*NRCUSPERMODULE; ddl++)
132 fSpecificationMapPtr[ddl].fModId = ddl/( NRCUSPERMODULE );
137 AliHLTEMCALMapper::DDL2RcuMapFileName(const int ddlIndex) const //0=4608, 1=4607 etc...
139 const int rnamelen=256;
140 static char rname[rnamelen];
143 if ( ddlIndex%NRCUSPERSECTOR <2)
151 int tmprcuindex = ddlIndex%2;
152 snprintf(rname, rnamelen, "RCU%d%c.data", tmprcuindex, tmpSide );
153 //sprintf(rname,"RCU%d%c.data", ddlIndex/NRCUSPERSECTOR, tmpSide );