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