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"
24 using namespace EmcalHLTConst;
29 AliHLTEMCALMapper::AliHLTEMCALMapper(const unsigned long specification ) : AliHLTCaloMapper(specification)
31 InitAltroMapping(specification);
32 InitDDLSpecificationMapping();
33 fIsInitializedMapping = true; //CRAP PTH, must check is the initilization actually went ok
37 AliHLTEMCALMapper::~AliHLTEMCALMapper()
44 AliHLTEMCALMapper::InitAltroMapping(const unsigned long specification )
46 char *base = getenv("ALICE_ROOT");
57 sprintf(fFilepath, "%s/EMCAL/mapping/%s", base, DDL2RcuMapFileName( GetDDLFromSpec( specification ) ) );
58 cout << __FILE__ <<":"<< __LINE__ <<"mapping filename is " << fFilepath << endl;
59 // sprintf(fFilepath,"%s/PHOS/mapping/RCU0.data", base);
60 FILE *fp = fopen(fFilepath, "r");
63 res = fscanf(fp, "%d\n", &nChannels);
64 res = fscanf(fp, "%d\n", &maxaddr);
65 fHw2geomapPtr = new fAltromap[maxaddr +1];
67 for(int i=0; i< maxaddr + 1 ; i ++)
69 fHw2geomapPtr[i].fXCol = 0;
70 fHw2geomapPtr[i].fZRow = 0;
71 fHw2geomapPtr[i].fGain = 0;
73 for(int i=0; i<nChannels; i ++)
75 res = fscanf(fp, "%d %d %d %d\n", &tmpHwaddr, &tmpXCol, &tmpZRow, &tmpGain);
77 // cout << __FILE__ << __LINE__ << " tmpHwaddr = " << tmpHwaddr << ", tmpXCol = " << (int)tmpXCol << ", tmpZRow = "<< (int)tmpZRow << ", tmpGain= "<< (int)tmpGain << endl;
81 fHw2geomapPtr[tmpHwaddr].fXCol = (char)tmpXCol;
82 fHw2geomapPtr[tmpHwaddr].fZRow = (char)tmpZRow;
83 fHw2geomapPtr[tmpHwaddr].fGain = (char)tmpGain;
86 fIsInitializedMapping = true;
91 cout << __FUNCTION__ << ":"<<__FILE__<<":"<< __LINE__ << "ERROR, could not open mapping file %s" << fFilepath << endl;
92 fIsInitializedMapping = false;
97 fIsInitializedMapping = false;
103 AliHLTEMCALMapper::InitDDLSpecificationMapping()
105 fSpecificationMapPtr = new fDDLSpecificationMap[EmcalHLTConst::NMODULES*EmcalHLTConst::NRCUSPERMODULE];
107 for(Int_t ddl = 0; ddl < EmcalHLTConst::NMODULES*EmcalHLTConst::NRCUSPERMODULE; ddl++)
109 fSpecificationMapPtr[ddl].fModId = ddl/EmcalHLTConst::NRCUSPERMODULE;
110 fSpecificationMapPtr[ddl].fRcuX = 0;
111 fSpecificationMapPtr[ddl].fRcuZ = ddl%2;
112 // fSpecificationMapPtr[ddl].fRcuZOffset = NZROWSRCU*(fSpecificationMapPtr[ddl].fRcuZ);
113 // fSpecificationMapPtr[ddl].fRcuXOffset = NXCOLUMNSRCU*(fSpecificationMapPtr[ddl].fRcuX);
123 AliHLTEMCALMapper::DDL2RcuMapFileName(const int ddlIndex) const //0=4608, 1=4607 etc...
125 static char rname[256];
128 if ( ddlIndex%NRCUSPERSECTOR <2)
137 sprintf(rname,"RCU%d%c.data", ddlIndex/NRCUSPERSECTOR, tmpSide );
139 // rname.fSector = ddlIndex/NRCUSPERSECTOR;
145 AliHLTEMCALMapper::GetSpecFromDDLIndex( const int ddlindex )
147 return ( (unsigned long)1 << ddlindex ));
152 AliHLTEMCALMapper::GlobalX2ModuleId( const int globalX )
154 return globalX/NXCOLUMNSMOD;
160 AliHLTEMCALMapper::GlobalZ2ModuleId( const int globalZ )
162 return globalZ/NZROWSMOD;
169 AliHLTEMCALMapper::Global2ModuleId( const int globalZ, const int globalX )