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"
22 using namespace EmcalHLTConst;
27 AliHLTEMCALMapper::AliHLTEMCALMapper(const unsigned long specification ) : AliHLTCaloMapper(specification)
29 InitAltroMapping(specification);
30 InitDDLSpecificationMapping();
31 fIsInitializedMapping = true; //CRAP PTH, must check is the initilization actually went ok
35 AliHLTEMCALMapper::~AliHLTEMCALMapper()
42 AliHLTEMCALMapper::InitAltroMapping(const unsigned long specification )
44 char *base = getenv("ALICE_ROOT");
55 sprintf(fFilepath, "%s/EMCAL/mapping/%s", base, DDL2RcuMapFileName( GetDDLFromSpec( specification ) ) );
56 cout << __FILE__ <<":"<< __LINE__ <<"mapping filename is " << fFilepath << endl;
57 // sprintf(fFilepath,"%s/PHOS/mapping/RCU0.data", base);
58 FILE *fp = fopen(fFilepath, "r");
61 res = fscanf(fp, "%d\n", &nChannels);
62 res = fscanf(fp, "%d\n", &maxaddr);
63 fHw2geomapPtr = new fAltromap[maxaddr +1];
65 for(int i=0; i< maxaddr + 1 ; i ++)
67 fHw2geomapPtr[i].fXCol = 0;
68 fHw2geomapPtr[i].fZRow = 0;
69 fHw2geomapPtr[i].fGain = 0;
71 for(int i=0; i<nChannels; i ++)
73 res = fscanf(fp, "%d %d %d %d\n", &tmpHwaddr, &tmpXCol, &tmpZRow, &tmpGain);
75 // cout << __FILE__ << __LINE__ << " tmpHwaddr = " << tmpHwaddr << ", tmpXCol = " << (int)tmpXCol << ", tmpZRow = "<< (int)tmpZRow << ", tmpGain= "<< (int)tmpGain << endl;
79 fHw2geomapPtr[tmpHwaddr].fXCol = (char)tmpXCol;
80 fHw2geomapPtr[tmpHwaddr].fZRow = (char)tmpZRow;
81 fHw2geomapPtr[tmpHwaddr].fGain = (char)tmpGain;
84 fIsInitializedMapping = true;
89 cout << __FUNCTION__ << ":"<<__FILE__<<":"<< __LINE__ << "ERROR, could not open mapping file %s" << fFilepath << endl;
90 fIsInitializedMapping = false;
95 fIsInitializedMapping = false;
101 AliHLTEMCALMapper::InitDDLSpecificationMapping()
103 fSpecificationMapPtr = new fDDLSpecificationMap[EmcalHLTConst::NMODULES*EmcalHLTConst::NRCUSPERMODULE];
105 for(Int_t ddl = 0; ddl < EmcalHLTConst::NMODULES*EmcalHLTConst::NRCUSPERMODULE; ddl++)
107 fSpecificationMapPtr[ddl].fModId = ddl/EmcalHLTConst::NRCUSPERMODULE;
108 fSpecificationMapPtr[ddl].fRcuX = 0;
109 fSpecificationMapPtr[ddl].fRcuZ = ddl%2;
110 // fSpecificationMapPtr[ddl].fRcuZOffset = NZROWSRCU*(fSpecificationMapPtr[ddl].fRcuZ);
111 // fSpecificationMapPtr[ddl].fRcuXOffset = NXCOLUMNSRCU*(fSpecificationMapPtr[ddl].fRcuX);
121 AliHLTEMCALMapper::DDL2RcuMapFileName(const int ddlIndex) const //0=4608, 1=4607 etc...
123 static char rname[256];
126 if ( ddlIndex%NRCUSPERSECTOR <2)
135 sprintf(rname,"RCU%d%c.data", ddlIndex/NRCUSPERSECTOR, tmpSide );
137 // rname.fSector = ddlIndex/NRCUSPERSECTOR;
143 AliHLTEMCALMapper::GetSpecFromDDLIndex( const int ddlindex )
145 return ( (unsigned long)1 << ddlindex ));
150 AliHLTEMCALMapper::GlobalX2ModuleId( const int globalX )
152 return globalX/NXCOLUMNSMOD;
158 AliHLTEMCALMapper::GlobalZ2ModuleId( const int globalZ )
160 return globalZ/NZROWSMOD;
167 AliHLTEMCALMapper::Global2ModuleId( const int globalZ, const int globalX )