]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/CALO/AliHLTCaloMapper.cxx
00eb99ba09beab288d0dd3420ce985054e2313fb
[u/mrichter/AliRoot.git] / HLT / CALO / AliHLTCaloMapper.cxx
1 // $Id: AliHLTCalorimeterMapper.cxx 34622 2009-09-04 13:22:01Z odjuvsla $
2
3 /**************************************************************************
4  * This file is property of and copyright by the Experimental Nuclear     *
5  * Physics Group, Dep. of Physics                                         *
6  * University of Oslo, Norway, 2006                                       *
7  *                                                                        * 
8  * Author: Per Thomas Hille perthi@fys.uio.no for the ALICE DCS Project.  *
9  * Contributors are mentioned in the code where appropriate.              *
10  * Please report bugs to perthi@fys.uio.no                                * 
11  *                                                                        *
12  * Permission to use, copy, modify and distribute this software and its   *
13  * documentation strictly for non-commercial purposes is hereby granted   *
14  * without fee, provided that the above copyright notice appears in all   *
15  * copies and that both the copyright notice and this permission notice   *
16  * appear in the supporting documentation. The authors make no claims     *
17  * about the suitability of this software for any purpose. It is          *
18  * provided "as is" without express or implied warranty.                  *
19  **************************************************************************/
20
21 //
22 // Mapping class fro mapping
23 // from hardware address to geometrical address
24 //
25 //
26
27 #include "AliHLTCaloMapper.h"
28 #include "AliHLTLogging.h"
29 #include "Rtypes.h"
30 #include "unistd.h"
31 #include <iostream>
32 #include "AliHLTCaloCoordinate.h"
33
34 using namespace CaloHLTConst;
35
36 //ClassImp(AliHLTCaloMapper)
37
38 AliHLTCaloMapper::AliHLTCaloMapper( const unsigned long  specification ) :  AliHLTLogging(), 
39                                                                             fHw2geomapPtr(0),
40                                                                             fCellSize(0),
41                                                                             fSpecification(specification),
42                                                                             fIsInitializedMapping(false),
43                                                                             fSpecificationMapPtr(0)
44 {  
45   //see header file for class documentation
46 }
47
48
49 AliHLTCaloMapper::~AliHLTCaloMapper()
50 {
51   delete []  fHw2geomapPtr;
52   fHw2geomapPtr = 0;
53 }
54
55
56 //void AliHLTCaloMapper::InitAltroMapping(){
57   //Virtual base class
58 //}
59
60 //void AliHLTCaloMapper::InitDDLSpecificationMapping() {
61   //Virtual base class
62 //}
63
64
65
66 bool 
67 AliHLTCaloMapper::GetIsInitializedMapping()
68 {
69   return  fIsInitializedMapping;
70 }
71
72
73 char* 
74 AliHLTCaloMapper::GetFilePath()
75 {
76   return  fFilepath;
77 }
78
79
80 void
81 AliHLTCaloMapper::ChannelId2Coordinate(const int channelId,    AliHLTCaloCoordinate &channelCoord)
82 {
83   channelCoord.fX = channelId&0x3f;
84   channelCoord.fZ = (channelId >> 6)&0x3f;
85   channelCoord.fGain = (channelId >> 12)&0x1;
86   channelCoord.fModuleId  = (channelId >> 13)&0x1f;
87   //  printf("Channel ID: 0x%X Coordinates: x = %d, z = %d, gain = %d\n", channelId, channelCoord[0], channelCoord[1], channelCoord[2]);
88 }
89
90
91 int  
92 AliHLTCaloMapper::GetDDLFromSpec( const AliHLTUInt32_t spec )
93 {
94   int tmpIndex = -1;
95   for(int i=0; i < 32; i++ )
96     {
97       if (spec >> i ==1)
98         {
99           tmpIndex = i;
100           break;
101         }
102     }
103    if(  tmpIndex  < 0)
104     {
105       //   HLTError("Specification %d, not consistent with any DDL in PHOS or EMCAL", spec  );
106     }
107   return tmpIndex;
108 }
109
110
111   
112 // UInt_t 
113 // AliHLTCaloMapper::GetChannelID(const AliHLTUInt32_t spec, const Int_t hadd)
114 int 
115 AliHLTCaloMapper::GetChannelID(const AliHLTUInt32_t spec, const Int_t hadd)
116 {
117   Short_t index = GetDDLFromSpec(spec);
118   if( index < 0 )
119     {
120       //      HLTError("Specification 0x%X not consistent with single DDL in PHOS", spec);
121       return index;
122     }
123   else
124     {
125       return ((fHw2geomapPtr[hadd].fXCol   ) |
126               ((fHw2geomapPtr[hadd].fZRow  ) << 6) |
127               (fHw2geomapPtr[hadd].fGain << 12) |
128               fSpecificationMapPtr[index].fModId << 13);
129     }
130 }
131
132
133
134 unsigned long 
135 AliHLTCaloMapper::GetSpecFromDDLIndex( const int ddlindex )
136 {
137   int iret = (unsigned long)1  <<  ddlindex;  
138
139   //  return  ((unsigned long)1)  <<  ddlindex ) ;
140
141   return iret;
142
143 }
144