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