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