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"
23 using namespace EmcalHLTConst;
28 AliHLTEMCALMapper::AliHLTEMCALMapper(const unsigned long specification ) : AliHLTCaloMapper(specification, "EMCAL")
31 InitAltroMapping(specification);
32 InitDDLSpecificationMapping();
33 fIsInitializedMapping = true; //CRAP PTH, must check is the initilization actually went ok
37 AliHLTEMCALMapper::~AliHLTEMCALMapper()
44 // channelCoord[0] = (static_cast<Float_t>(channelId&0x3f) - NXCOLUMNSMOD/2)* fCellStep;
45 // channelCoord[1] = (static_cast<Float_t>((channelId >> 6)&0x3f) - NZROWSMOD/2) * fCellStep;
48 AliHLTEMCALMapper::GetLocalCoord(const int channelId, Float_t* localCoord) const
50 localCoord[0] = ( ( Float_t )(channelId&0x3f) - NXCOLUMNSMOD/2) * fCellSize;
51 localCoord[1] = ( (Float_t)((channelId >> 6)&0x3f) - NZROWSMOD/2) * fCellSize;
56 AliHLTEMCALMapper::InitAltroMapping(const unsigned long specification )
58 char *base = getenv("ALICE_ROOT");
69 // int tmpddlindex = GetDDLFromSpec( specification )%2;
71 sprintf(fFilepath, "%s/EMCAL/mapping/%s", base, DDL2RcuMapFileName( GetDDLFromSpec( specification ) ) );
72 sprintf(fFilepath, "%s/EMCAL/mapping/%s", base, DDL2RcuMapFileName( GetDDLFromSpec( specification ) ) );
74 // assert("DDL spec is %d", GetDDLFromSpec( specification ) );
76 cout << __FILE__ <<":"<< __LINE__ <<"DDL spec is " << GetDDLFromSpec( specification ) << endl;
77 cout << __FILE__ <<":"<< __LINE__ <<"mapping filename is " << fFilepath << endl;
78 // sprintf(fFilepath,"%s/PHOS/mapping/RCU0.data", base);
79 FILE *fp = fopen(fFilepath, "r");
82 res = fscanf(fp, "%d\n", &nChannels);
83 res = fscanf(fp, "%d\n", &maxaddr);
84 fHw2geomapPtr = new fAltromap[maxaddr +1];
86 for(int i=0; i< maxaddr + 1 ; i ++)
88 fHw2geomapPtr[i].fXCol = 0;
89 fHw2geomapPtr[i].fZRow = 0;
90 fHw2geomapPtr[i].fGain = 0;
92 for(int i=0; i<nChannels; i ++)
94 res = fscanf(fp, "%d %d %d %d\n", &tmpHwaddr, &tmpXCol, &tmpZRow, &tmpGain);
96 // cout << __FILE__ << __LINE__ << " tmpHwaddr = " << tmpHwaddr << ", tmpXCol = " << (int)tmpXCol << ", tmpZRow = "<< (int)tmpZRow << ", tmpGain= "<< (int)tmpGain << endl;
100 fHw2geomapPtr[tmpHwaddr].fXCol = (char)tmpXCol;
101 fHw2geomapPtr[tmpHwaddr].fZRow = (char)tmpZRow;
102 fHw2geomapPtr[tmpHwaddr].fGain = (char)tmpGain;
105 fIsInitializedMapping = true;
110 cout << __FUNCTION__ << ":"<<__FILE__<<":"<< __LINE__ << "ERROR, could not open mapping file %s" << fFilepath << endl;
111 fIsInitializedMapping = false;
116 fIsInitializedMapping = false;
122 AliHLTEMCALMapper::InitDDLSpecificationMapping()
124 fSpecificationMapPtr = new fDDLSpecificationMap[EmcalHLTConst::NMODULES*EmcalHLTConst::NRCUSPERMODULE];
126 for(Int_t ddl = 0; ddl < EmcalHLTConst::NMODULES*EmcalHLTConst::NRCUSPERMODULE; ddl++)
128 fSpecificationMapPtr[ddl].fModId = ddl/(EmcalHLTConst::NRCUSPERMODULE);
133 AliHLTEMCALMapper::DDL2RcuMapFileName(const int ddlIndex) const //0=4608, 1=4607 etc...
135 static char rname[256];
138 if ( ddlIndex%NRCUSPERSECTOR <2)
146 int tmprcuindex = ddlIndex%2;
147 sprintf(rname,"RCU%d%c.data", tmprcuindex, tmpSide );
148 //sprintf(rname,"RCU%d%c.data", ddlIndex/NRCUSPERSECTOR, tmpSide );