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;
30 AliHLTEMCALMapper::AliHLTEMCALMapper(const unsigned long specification ) : AliHLTCaloMapper(specification)
33 InitAltroMapping(specification);
34 InitDDLSpecificationMapping();
35 fIsInitializedMapping = true; //CRAP PTH, must check is the initilization actually went ok
39 AliHLTEMCALMapper::~AliHLTEMCALMapper()
46 // channelCoord[0] = (static_cast<Float_t>(channelId&0x3f) - NXCOLUMNSMOD/2)* fCellStep;
47 // channelCoord[1] = (static_cast<Float_t>((channelId >> 6)&0x3f) - NZROWSMOD/2) * fCellStep;
50 AliHLTEMCALMapper::GetLocalCoord(const int channelId, Float_t* localCoord) const
52 localCoord[0] = ( ( Float_t )(channelId&0x3f) - NXCOLUMNSMOD/2) * fCellSize;
53 localCoord[1] = ( (Float_t)((channelId >> 6)&0x3f) - NZROWSMOD/2) * fCellSize;
58 AliHLTEMCALMapper::InitAltroMapping(const unsigned long specification )
60 char *base = getenv("ALICE_ROOT");
71 // int tmpddlindex = GetDDLFromSpec( specification )%2;
73 sprintf(fFilepath, "%s/EMCAL/mapping/%s", base, DDL2RcuMapFileName( GetDDLFromSpec( specification ) ) );
74 sprintf(fFilepath, "%s/EMCAL/mapping/%s", base, DDL2RcuMapFileName( GetDDLFromSpec( specification ) ) );
76 // assert("DDL spec is %d", GetDDLFromSpec( specification ) );
78 cout << __FILE__ <<":"<< __LINE__ <<"DDL spec is " << GetDDLFromSpec( specification ) << endl;
79 cout << __FILE__ <<":"<< __LINE__ <<"mapping filename is " << fFilepath << endl;
80 // sprintf(fFilepath,"%s/PHOS/mapping/RCU0.data", base);
81 FILE *fp = fopen(fFilepath, "r");
84 res = fscanf(fp, "%d\n", &nChannels);
85 res = fscanf(fp, "%d\n", &maxaddr);
86 fHw2geomapPtr = new fAltromap[maxaddr +1];
88 for(int i=0; i< maxaddr + 1 ; i ++)
90 fHw2geomapPtr[i].fXCol = 0;
91 fHw2geomapPtr[i].fZRow = 0;
92 fHw2geomapPtr[i].fGain = 0;
94 for(int i=0; i<nChannels; i ++)
96 res = fscanf(fp, "%d %d %d %d\n", &tmpHwaddr, &tmpXCol, &tmpZRow, &tmpGain);
98 // cout << __FILE__ << __LINE__ << " tmpHwaddr = " << tmpHwaddr << ", tmpXCol = " << (int)tmpXCol << ", tmpZRow = "<< (int)tmpZRow << ", tmpGain= "<< (int)tmpGain << endl;
102 fHw2geomapPtr[tmpHwaddr].fXCol = (char)tmpXCol;
103 fHw2geomapPtr[tmpHwaddr].fZRow = (char)tmpZRow;
104 fHw2geomapPtr[tmpHwaddr].fGain = (char)tmpGain;
107 fIsInitializedMapping = true;
112 cout << __FUNCTION__ << ":"<<__FILE__<<":"<< __LINE__ << "ERROR, could not open mapping file %s" << fFilepath << endl;
113 fIsInitializedMapping = false;
118 fIsInitializedMapping = false;
124 AliHLTEMCALMapper::InitDDLSpecificationMapping()
126 fSpecificationMapPtr = new fDDLSpecificationMap[EmcalHLTConst::NMODULES*EmcalHLTConst::NRCUSPERMODULE];
128 for(Int_t ddl = 0; ddl < EmcalHLTConst::NMODULES*EmcalHLTConst::NRCUSPERMODULE; ddl++)
130 fSpecificationMapPtr[ddl].fModId = ddl/(EmcalHLTConst::NRCUSPERMODULE);
135 AliHLTEMCALMapper::DDL2RcuMapFileName(const int ddlIndex) const //0=4608, 1=4607 etc...
137 static char rname[256];
140 if ( ddlIndex%NRCUSPERSECTOR <2)
148 int tmprcuindex = ddlIndex%2;
149 sprintf(rname,"RCU%d%c.data", tmprcuindex, tmpSide );
150 //sprintf(rname,"RCU%d%c.data", ddlIndex/NRCUSPERSECTOR, tmpSide );