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