]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/EMCAL/AliHLTEMCALMapper.cxx
Cosmetics
[u/mrichter/AliRoot.git] / HLT / EMCAL / AliHLTEMCALMapper.cxx
CommitLineData
88b2ce82 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 *
5 * *
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 *
9 * *
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"
19
4f4b7ba4 20#include "AliHLTEMCALConstant.h"
76ffc0ce 21
b850c417 22#include "assert.h"
f808bdf6 23
88b2ce82 24using namespace EmcalHLTConst;
25
88b2ce82 26
4d6be4cd 27
b850c417 28
1a57dd60 29AliHLTEMCALMapper::AliHLTEMCALMapper(const unsigned long specification ) : AliHLTCaloMapper(specification, "EMCAL")
88b2ce82 30{
b850c417 31 fCellSize = 6;
4d6be4cd 32 InitAltroMapping(specification);
88b2ce82 33 InitDDLSpecificationMapping();
76ffc0ce 34 fIsInitializedMapping = true; //CRAP PTH, must check if the initilization actually went ok
88b2ce82 35}
36
4d6be4cd 37
88b2ce82 38AliHLTEMCALMapper::~AliHLTEMCALMapper()
39{
40
41}
b850c417 42
43
b850c417 44void
45AliHLTEMCALMapper::GetLocalCoord(const int channelId, Float_t* localCoord) const
46{
47 localCoord[0] = ( ( Float_t )(channelId&0x3f) - NXCOLUMNSMOD/2) * fCellSize;
48 localCoord[1] = ( (Float_t)((channelId >> 6)&0x3f) - NZROWSMOD/2) * fCellSize;
49}
88b2ce82 50
51
44175a17 52Bool_t
4d6be4cd 53AliHLTEMCALMapper::InitAltroMapping(const unsigned long specification )
88b2ce82 54{
88b2ce82 55 char *base = getenv("ALICE_ROOT");
4d6be4cd 56 int nChannels = 0;
57 int maxaddr = 0;
58 int tmpHwaddr = 0;
88b2ce82 59 int tmpZRow = 0;
60 int tmpXCol = 0;
61 int tmpGain = 0;
62 int res = 0;
63
64 if(base !=0)
65 {
4d6be4cd 66 sprintf(fFilepath, "%s/EMCAL/mapping/%s", base, DDL2RcuMapFileName( GetDDLFromSpec( specification ) ) );
b850c417 67 sprintf(fFilepath, "%s/EMCAL/mapping/%s", base, DDL2RcuMapFileName( GetDDLFromSpec( specification ) ) );
68
88b2ce82 69 FILE *fp = fopen(fFilepath, "r");
70 if(fp != 0)
71 {
4d6be4cd 72 res = fscanf(fp, "%d\n", &nChannels);
73 res = fscanf(fp, "%d\n", &maxaddr);
88b2ce82 74 fHw2geomapPtr = new fAltromap[maxaddr +1];
75
76 for(int i=0; i< maxaddr + 1 ; i ++)
77 {
78 fHw2geomapPtr[i].fXCol = 0;
79 fHw2geomapPtr[i].fZRow = 0;
80 fHw2geomapPtr[i].fGain = 0;
81 }
82 for(int i=0; i<nChannels; i ++)
83 {
84 res = fscanf(fp, "%d %d %d %d\n", &tmpHwaddr, &tmpXCol, &tmpZRow, &tmpGain);
4d6be4cd 85
88b2ce82 86 if(tmpGain < 2)
87 {
4d6be4cd 88 fHw2geomapPtr[tmpHwaddr].fXCol = (char)tmpXCol;
89 fHw2geomapPtr[tmpHwaddr].fZRow = (char)tmpZRow;
90 fHw2geomapPtr[tmpHwaddr].fGain = (char)tmpGain;
88b2ce82 91 }
92 }
93 fIsInitializedMapping = true;
94 fclose(fp);
95 }
96 else
97 {
4d6be4cd 98 fIsInitializedMapping = false;
88b2ce82 99 }
100 }
101 else
102 {
103 fIsInitializedMapping = false;
104 }
f92dcf21 105
106 return fIsInitializedMapping;
88b2ce82 107}
108
109
110void
111AliHLTEMCALMapper::InitDDLSpecificationMapping()
112{
113 fSpecificationMapPtr = new fDDLSpecificationMap[EmcalHLTConst::NMODULES*EmcalHLTConst::NRCUSPERMODULE];
114
115 for(Int_t ddl = 0; ddl < EmcalHLTConst::NMODULES*EmcalHLTConst::NRCUSPERMODULE; ddl++)
116 {
b850c417 117 fSpecificationMapPtr[ddl].fModId = ddl/(EmcalHLTConst::NRCUSPERMODULE);
88b2ce82 118 }
119}
120
4d6be4cd 121const char*
122AliHLTEMCALMapper::DDL2RcuMapFileName(const int ddlIndex) const //0=4608, 1=4607 etc...
88b2ce82 123{
4d6be4cd 124 static char rname[256];
125 char tmpSide;
126
127 if ( ddlIndex%NRCUSPERSECTOR <2)
128 {
129 tmpSide = 'A';
130 }
131 else
132 {
133 tmpSide = 'C';
134 }
b850c417 135 int tmprcuindex = ddlIndex%2;
136 sprintf(rname,"RCU%d%c.data", tmprcuindex, tmpSide );
137 //sprintf(rname,"RCU%d%c.data", ddlIndex/NRCUSPERSECTOR, tmpSide );
4d6be4cd 138 return rname;
88b2ce82 139}
4d6be4cd 140