]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/EMCAL/AliHLTEMCALMapper.cxx
Add a task to a train
[u/mrichter/AliRoot.git] / HLT / EMCAL / AliHLTEMCALMapper.cxx
CommitLineData
2f0cecb4 1// $Id$
2
88b2ce82 3/**************************************************************************
4 * This file is property of and copyright by the Experimental Nuclear *
5 * Physics Group, Dep. of Physics *
6 * University of Oslo, Norway, 2007 *
7 * *
8 * Author: Per Thomas Hille <perthi@fys.uio.no> for the ALICE HLT Project.*
9 * Contributors are mentioned in the code where appropriate. *
10 * Please report bugs to perthi@fys.uio.no *
11 * *
12 * Permission to use, copy, modify and distribute this software and its *
13 * documentation strictly for non-commercial purposes is hereby granted *
14 * without fee, provided that the above copyright notice appears in all *
15 * copies and that both the copyright notice and this permission notice *
16 * appear in the supporting documentation. The authors make no claims *
17 * about the suitability of this software for any purpose. It is *
18 * provided "as is" without express or implied warranty. *
19 **************************************************************************/
dc3d3428 20
88b2ce82 21#include "AliHLTEMCALMapper.h"
b850c417 22#include "assert.h"
dc3d3428 23#include "AliHLTCaloConstants.h"
4d6be4cd 24
dc3d3428 25using EMCAL::NXCOLUMNSMOD;
26using EMCAL::NZROWSMOD;
27using EMCAL::NMODULES;
28using EMCAL::NRCUSPERMODULE;
29using EMCAL::NRCUSPERSECTOR;
f67ce0df 30using EMCAL::MAXHWADDR;
d468be51 31using EMCAL::MAXCHANNELS;
b850c417 32
1a57dd60 33AliHLTEMCALMapper::AliHLTEMCALMapper(const unsigned long specification ) : AliHLTCaloMapper(specification, "EMCAL")
88b2ce82 34{
b850c417 35 fCellSize = 6;
4d6be4cd 36 InitAltroMapping(specification);
88b2ce82 37 InitDDLSpecificationMapping();
76ffc0ce 38 fIsInitializedMapping = true; //CRAP PTH, must check if the initilization actually went ok
88b2ce82 39}
40
4d6be4cd 41
88b2ce82 42AliHLTEMCALMapper::~AliHLTEMCALMapper()
43{
548c4774 44
88b2ce82 45}
1a51306a 46
b850c417 47
b850c417 48void
49AliHLTEMCALMapper::GetLocalCoord(const int channelId, Float_t* localCoord) const
50{
51 localCoord[0] = ( ( Float_t )(channelId&0x3f) - NXCOLUMNSMOD/2) * fCellSize;
52 localCoord[1] = ( (Float_t)((channelId >> 6)&0x3f) - NZROWSMOD/2) * fCellSize;
53}
88b2ce82 54
55
44175a17 56Bool_t
4d6be4cd 57AliHLTEMCALMapper::InitAltroMapping(const unsigned long specification )
88b2ce82 58{
88b2ce82 59 char *base = getenv("ALICE_ROOT");
4d6be4cd 60 int nChannels = 0;
f67ce0df 61 int maxaddr = 0; // keep as dummy for now
4d6be4cd 62 int tmpHwaddr = 0;
88b2ce82 63 int tmpZRow = 0;
64 int tmpXCol = 0;
65 int tmpGain = 0;
66 int res = 0;
67
68 if(base !=0)
69 {
1a51306a 70 snprintf(fFilepath,FILEPATHMAXLENGTH,"%s/EMCAL/mapping/%s", base, DDL2RcuMapFileName( GetDDLFromSpec( specification ) ) );
71 snprintf(fFilepath, FILEPATHMAXLENGTH,"%s/EMCAL/mapping/%s", base, DDL2RcuMapFileName( GetDDLFromSpec( specification ) ) );
b850c417 72
88b2ce82 73 FILE *fp = fopen(fFilepath, "r");
74 if(fp != 0)
75 {
4d6be4cd 76 res = fscanf(fp, "%d\n", &nChannels);
77 res = fscanf(fp, "%d\n", &maxaddr);
f67ce0df 78 // fHw2geomapPtr = new fAltromap[maxaddr +1];
79 fHw2geomapPtr = new fAltromap[MAXHWADDR +1];
80
81 for(int i=0; i< MAXHWADDR + 1 ; i ++)
82 //for(int i=0; i< maxaddr + 1 ; i ++)
88b2ce82 83 {
84 fHw2geomapPtr[i].fXCol = 0;
85 fHw2geomapPtr[i].fZRow = 0;
86 fHw2geomapPtr[i].fGain = 0;
87 }
d468be51 88 // MAXCHANNELS
5a6eb7ff 89 if( nChannels > 0 && nChannels <= MAXCHANNELS )
88b2ce82 90 {
d468be51 91 for(int i=0; i<nChannels; i ++)
88b2ce82 92 {
d468be51 93 res = fscanf(fp, "%d %d %d %d\n", &tmpHwaddr, &tmpXCol, &tmpZRow, &tmpGain);
94
95 if(tmpGain < 2)
f67ce0df 96 {
e1c486ae 97 if( tmpHwaddr <= MAXHWADDR && tmpHwaddr >= 0 )
d468be51 98 {
99 fHw2geomapPtr[tmpHwaddr].fXCol = (char)tmpXCol;
100 fHw2geomapPtr[tmpHwaddr].fZRow = (char)tmpZRow;
101 fHw2geomapPtr[tmpHwaddr].fGain = (char)tmpGain;
102 }
103 }
104 }
105 fIsInitializedMapping = true;
106 }
107 else
108 {
109 fIsInitializedMapping = false;
88b2ce82 110 }
88b2ce82 111 fclose(fp);
112 }
113 else
114 {
4d6be4cd 115 fIsInitializedMapping = false;
88b2ce82 116 }
117 }
118 else
119 {
120 fIsInitializedMapping = false;
121 }
f92dcf21 122
123 return fIsInitializedMapping;
88b2ce82 124}
125
126
127void
128AliHLTEMCALMapper::InitDDLSpecificationMapping()
129{
2f0cecb4 130 if (fSpecificationMapPtr) delete [] fSpecificationMapPtr;
dc3d3428 131 fSpecificationMapPtr = new fDDLSpecificationMap[NMODULES*NRCUSPERMODULE];
88b2ce82 132
dc3d3428 133 for(Int_t ddl = 0; ddl < NMODULES*NRCUSPERMODULE; ddl++)
88b2ce82 134 {
dc3d3428 135 fSpecificationMapPtr[ddl].fModId = ddl/( NRCUSPERMODULE );
88b2ce82 136 }
137}
138
4d6be4cd 139const char*
140AliHLTEMCALMapper::DDL2RcuMapFileName(const int ddlIndex) const //0=4608, 1=4607 etc...
88b2ce82 141{
197e0087 142 const int rnamelen=256;
143 static char rname[rnamelen];
4d6be4cd 144 char tmpSide;
145
146 if ( ddlIndex%NRCUSPERSECTOR <2)
147 {
148 tmpSide = 'A';
149 }
150 else
151 {
152 tmpSide = 'C';
153 }
b850c417 154 int tmprcuindex = ddlIndex%2;
197e0087 155 snprintf(rname, rnamelen, "RCU%d%c.data", tmprcuindex, tmpSide );
b850c417 156 //sprintf(rname,"RCU%d%c.data", ddlIndex/NRCUSPERSECTOR, tmpSide );
4d6be4cd 157 return rname;
88b2ce82 158}
4d6be4cd 159