]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/EMCAL/AliHLTEMCALMapper.cxx
testing git svn
[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 "AliHLTEMCALConstants.h"
21
22
23
24 using namespace EmcalHLTConst;
25
26 //AliHLTCaloMapper
27
28
29 AliHLTEMCALMapper::AliHLTEMCALMapper(const unsigned long specification ) : AliHLTCaloMapper(specification) 
30 {
31   InitAltroMapping(specification);
32   InitDDLSpecificationMapping();
33   fIsInitializedMapping = true; //CRAP PTH, must check is the initilization actually went ok
34 }
35
36
37 AliHLTEMCALMapper::~AliHLTEMCALMapper()
38 {
39
40 }
41
42
43 void 
44 AliHLTEMCALMapper::InitAltroMapping(const unsigned long specification )
45 {
46   char *base =  getenv("ALICE_ROOT");
47   int  nChannels = 0;
48   int  maxaddr = 0;
49   int  tmpHwaddr = 0;
50   int tmpZRow = 0;
51   int tmpXCol = 0;
52   int tmpGain = 0;
53   int res = 0; 
54   
55   if(base !=0)
56     {
57       sprintf(fFilepath, "%s/EMCAL/mapping/%s", base,   DDL2RcuMapFileName( GetDDLFromSpec( specification ) ) ); 
58       cout << __FILE__ <<":"<< __LINE__ <<"mapping filename is " <<  fFilepath << endl;
59         // sprintf(fFilepath,"%s/PHOS/mapping/RCU0.data", base);
60       FILE *fp = fopen(fFilepath, "r");
61       if(fp != 0)
62         {
63           res = fscanf(fp, "%d\n", &nChannels);
64           res = fscanf(fp, "%d\n", &maxaddr);
65           fHw2geomapPtr = new fAltromap[maxaddr +1]; 
66
67           for(int i=0; i< maxaddr + 1 ; i ++)
68             {
69               fHw2geomapPtr[i].fXCol = 0;
70               fHw2geomapPtr[i].fZRow = 0;
71               fHw2geomapPtr[i].fGain = 0;
72             }
73           for(int i=0; i<nChannels; i ++)
74             {
75               res = fscanf(fp, "%d %d %d %d\n", &tmpHwaddr, &tmpXCol, &tmpZRow,  &tmpGain);
76               
77               //              cout << __FILE__ << __LINE__ << "  tmpHwaddr  = " << tmpHwaddr << ", tmpXCol = " << (int)tmpXCol <<  ", tmpZRow = "<< (int)tmpZRow <<  ", tmpGain= "<< (int)tmpGain << endl;
78               
79               if(tmpGain < 2)
80                 {
81                   fHw2geomapPtr[tmpHwaddr].fXCol   = (char)tmpXCol;
82                   fHw2geomapPtr[tmpHwaddr].fZRow   = (char)tmpZRow;
83                   fHw2geomapPtr[tmpHwaddr].fGain  =  (char)tmpGain;
84                 } 
85             }
86           fIsInitializedMapping = true;   
87           fclose(fp);
88         }
89       else
90         {
91           cout << __FUNCTION__ << ":"<<__FILE__<<":"<< __LINE__ << "ERROR, could not open mapping file %s" <<  fFilepath << endl;
92           fIsInitializedMapping = false;          
93         }
94     }
95   else
96     {
97       fIsInitializedMapping = false;
98     }
99 }
100
101
102 void 
103 AliHLTEMCALMapper::InitDDLSpecificationMapping()
104 {
105   fSpecificationMapPtr = new fDDLSpecificationMap[EmcalHLTConst::NMODULES*EmcalHLTConst::NRCUSPERMODULE];
106   
107   for(Int_t ddl = 0; ddl < EmcalHLTConst::NMODULES*EmcalHLTConst::NRCUSPERMODULE; ddl++)
108     {
109       fSpecificationMapPtr[ddl].fModId = ddl/EmcalHLTConst::NRCUSPERMODULE;
110       fSpecificationMapPtr[ddl].fRcuX = 0; 
111       fSpecificationMapPtr[ddl].fRcuZ = ddl%2; 
112       //      fSpecificationMapPtr[ddl].fRcuZOffset = NZROWSRCU*(fSpecificationMapPtr[ddl].fRcuZ);
113       //      fSpecificationMapPtr[ddl].fRcuXOffset = NXCOLUMNSRCU*(fSpecificationMapPtr[ddl].fRcuX);
114     }
115 }
116
117
118
119 //RCU1C.data
120
121
122 const char* 
123 AliHLTEMCALMapper::DDL2RcuMapFileName(const int ddlIndex) const //0=4608, 1=4607 etc...
124 {
125   static char rname[256];
126   char tmpSide;
127   
128   if ( ddlIndex%NRCUSPERSECTOR <2)
129     {
130       tmpSide  = 'A';
131     }
132   else
133     {
134       tmpSide  = 'C';
135     }
136   
137   sprintf(rname,"RCU%d%c.data", ddlIndex/NRCUSPERSECTOR, tmpSide );
138   return rname;
139   // rname.fSector = ddlIndex/NRCUSPERSECTOR;
140 }
141  
142
143 /*
144 unsigned long 
145 AliHLTEMCALMapper::GetSpecFromDDLIndex( const int ddlindex )
146 {
147   return ( (unsigned long)1  <<  ddlindex ));
148 }
149 */
150
151 /*
152 AliHLTEMCALMapper::GlobalX2ModuleId( const int globalX )
153 {
154   return globalX/NXCOLUMNSMOD;  
155 }
156 */
157
158  /*
159 static  const int 
160 AliHLTEMCALMapper::GlobalZ2ModuleId( const int globalZ )
161 {
162   return globalZ/NZROWSMOD;
163   }
164  */
165
166
167   /*
168  const int 
169  AliHLTEMCALMapper::Global2ModuleId( const int globalZ,  const int globalX )
170 {
171   int tmpModX = 
172  
173 }
174   */