]>
Commit | Line | Data |
---|---|---|
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" |
ff19b366 | 24 | #include "TString.h" |
4d6be4cd | 25 | |
dc3d3428 | 26 | using EMCAL::NXCOLUMNSMOD; |
27 | using EMCAL::NZROWSMOD; | |
28 | using EMCAL::NMODULES; | |
29 | using EMCAL::NRCUSPERMODULE; | |
30 | using EMCAL::NRCUSPERSECTOR; | |
f67ce0df | 31 | using EMCAL::MAXHWADDR; |
d468be51 | 32 | using EMCAL::MAXCHANNELS; |
b850c417 | 33 | |
1a57dd60 | 34 | AliHLTEMCALMapper::AliHLTEMCALMapper(const unsigned long specification ) : AliHLTCaloMapper(specification, "EMCAL") |
88b2ce82 | 35 | { |
b850c417 | 36 | fCellSize = 6; |
4d6be4cd | 37 | InitAltroMapping(specification); |
88b2ce82 | 38 | InitDDLSpecificationMapping(); |
76ffc0ce | 39 | fIsInitializedMapping = true; //CRAP PTH, must check if the initilization actually went ok |
88b2ce82 | 40 | } |
41 | ||
4d6be4cd | 42 | |
88b2ce82 | 43 | AliHLTEMCALMapper::~AliHLTEMCALMapper() |
44 | { | |
548c4774 | 45 | |
88b2ce82 | 46 | } |
1a51306a | 47 | |
b850c417 | 48 | |
b850c417 | 49 | void |
50 | AliHLTEMCALMapper::GetLocalCoord(const int channelId, Float_t* localCoord) const | |
51 | { | |
52 | localCoord[0] = ( ( Float_t )(channelId&0x3f) - NXCOLUMNSMOD/2) * fCellSize; | |
53 | localCoord[1] = ( (Float_t)((channelId >> 6)&0x3f) - NZROWSMOD/2) * fCellSize; | |
54 | } | |
88b2ce82 | 55 | |
56 | ||
44175a17 | 57 | Bool_t |
4d6be4cd | 58 | AliHLTEMCALMapper::InitAltroMapping(const unsigned long specification ) |
88b2ce82 | 59 | { |
ff19b366 | 60 | TString base(getenv("ALICE_ROOT")); |
4d6be4cd | 61 | int nChannels = 0; |
f67ce0df | 62 | int maxaddr = 0; // keep as dummy for now |
4d6be4cd | 63 | int tmpHwaddr = 0; |
88b2ce82 | 64 | int tmpZRow = 0; |
65 | int tmpXCol = 0; | |
66 | int tmpGain = 0; | |
67 | int res = 0; | |
008e9402 | 68 | fIsInitializedMapping = false; |
88b2ce82 | 69 | |
ff19b366 | 70 | if(!base.IsNull()) |
88b2ce82 | 71 | { |
ff19b366 | 72 | snprintf(fFilepath,FILEPATHMAXLENGTH,"%s/EMCAL/mapping/%s", base.Data(), DDL2RcuMapFileName( GetDDLFromSpec( specification ) ) ); |
73 | snprintf(fFilepath, FILEPATHMAXLENGTH,"%s/EMCAL/mapping/%s", base.Data(), DDL2RcuMapFileName( GetDDLFromSpec( specification ) ) ); | |
b850c417 | 74 | |
88b2ce82 | 75 | FILE *fp = fopen(fFilepath, "r"); |
76 | if(fp != 0) | |
77 | { | |
4d6be4cd | 78 | res = fscanf(fp, "%d\n", &nChannels); |
008e9402 | 79 | if (res!=1) return false; |
4d6be4cd | 80 | res = fscanf(fp, "%d\n", &maxaddr); |
008e9402 | 81 | if (res!=1) return false; |
f67ce0df | 82 | // fHw2geomapPtr = new fAltromap[maxaddr +1]; |
83 | fHw2geomapPtr = new fAltromap[MAXHWADDR +1]; | |
84 | ||
85 | for(int i=0; i< MAXHWADDR + 1 ; i ++) | |
86 | //for(int i=0; i< maxaddr + 1 ; i ++) | |
88b2ce82 | 87 | { |
88 | fHw2geomapPtr[i].fXCol = 0; | |
89 | fHw2geomapPtr[i].fZRow = 0; | |
90 | fHw2geomapPtr[i].fGain = 0; | |
91 | } | |
d468be51 | 92 | // MAXCHANNELS |
5a6eb7ff | 93 | if( nChannels > 0 && nChannels <= MAXCHANNELS ) |
88b2ce82 | 94 | { |
d468be51 | 95 | for(int i=0; i<nChannels; i ++) |
88b2ce82 | 96 | { |
d468be51 | 97 | res = fscanf(fp, "%d %d %d %d\n", &tmpHwaddr, &tmpXCol, &tmpZRow, &tmpGain); |
008e9402 | 98 | if (res!=4) return false; |
d468be51 | 99 | |
100 | if(tmpGain < 2) | |
f67ce0df | 101 | { |
e1c486ae | 102 | if( tmpHwaddr <= MAXHWADDR && tmpHwaddr >= 0 ) |
d468be51 | 103 | { |
104 | fHw2geomapPtr[tmpHwaddr].fXCol = (char)tmpXCol; | |
105 | fHw2geomapPtr[tmpHwaddr].fZRow = (char)tmpZRow; | |
106 | fHw2geomapPtr[tmpHwaddr].fGain = (char)tmpGain; | |
107 | } | |
108 | } | |
109 | } | |
110 | fIsInitializedMapping = true; | |
111 | } | |
112 | else | |
113 | { | |
114 | fIsInitializedMapping = false; | |
88b2ce82 | 115 | } |
88b2ce82 | 116 | fclose(fp); |
117 | } | |
118 | else | |
119 | { | |
4d6be4cd | 120 | fIsInitializedMapping = false; |
88b2ce82 | 121 | } |
122 | } | |
123 | else | |
124 | { | |
125 | fIsInitializedMapping = false; | |
126 | } | |
f92dcf21 | 127 | |
128 | return fIsInitializedMapping; | |
88b2ce82 | 129 | } |
130 | ||
131 | ||
132 | void | |
133 | AliHLTEMCALMapper::InitDDLSpecificationMapping() | |
134 | { | |
2f0cecb4 | 135 | if (fSpecificationMapPtr) delete [] fSpecificationMapPtr; |
dc3d3428 | 136 | fSpecificationMapPtr = new fDDLSpecificationMap[NMODULES*NRCUSPERMODULE]; |
88b2ce82 | 137 | |
dc3d3428 | 138 | for(Int_t ddl = 0; ddl < NMODULES*NRCUSPERMODULE; ddl++) |
88b2ce82 | 139 | { |
dc3d3428 | 140 | fSpecificationMapPtr[ddl].fModId = ddl/( NRCUSPERMODULE ); |
88b2ce82 | 141 | } |
142 | } | |
143 | ||
4d6be4cd | 144 | const char* |
145 | AliHLTEMCALMapper::DDL2RcuMapFileName(const int ddlIndex) const //0=4608, 1=4607 etc... | |
88b2ce82 | 146 | { |
197e0087 | 147 | const int rnamelen=256; |
148 | static char rname[rnamelen]; | |
4d6be4cd | 149 | char tmpSide; |
150 | ||
151 | if ( ddlIndex%NRCUSPERSECTOR <2) | |
152 | { | |
153 | tmpSide = 'A'; | |
154 | } | |
155 | else | |
156 | { | |
157 | tmpSide = 'C'; | |
158 | } | |
b850c417 | 159 | int tmprcuindex = ddlIndex%2; |
197e0087 | 160 | snprintf(rname, rnamelen, "RCU%d%c.data", tmprcuindex, tmpSide ); |
b850c417 | 161 | //sprintf(rname,"RCU%d%c.data", ddlIndex/NRCUSPERSECTOR, tmpSide ); |
4d6be4cd | 162 | return rname; |
88b2ce82 | 163 | } |
4d6be4cd | 164 |