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