1 // $Id: AliHLTCalorimeterMapper.cxx 34622 2009-09-04 13:22:01Z odjuvsla $
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 *
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 *
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 **************************************************************************/
22 // Mapping class fro mapping
23 // from hardware address to geometrical address
27 #include "AliHLTCaloMapper.h"
28 #include "AliHLTLogging.h"
32 #include "AliHLTCaloCoordinate.h"
33 #include "AliHLTCaloConstantsHandler.h"
35 //#include "AliHLTCaloConstants.h"
38 //typedef AliHLTCaloConstantsHandler::fCaloConstants->GetCELLSTEP() CELLSTEP;
40 //#define fCaloConstants->GetCELLSTEP() CELLSTEP
44 //typedef CELLSTEP fCaloConstants->GetCELLSTEP();
46 ClassImp(AliHLTCaloMapper);
48 AliHLTCaloMapper::AliHLTCaloMapper( const unsigned long specification , TString det) :
49 AliHLTCaloConstantsHandler(det),
53 fSpecification(specification),
54 fIsInitializedMapping(false),
55 fSpecificationMapPtr(0),
58 //see header file for class documentation
63 AliHLTCaloMapper::~AliHLTCaloMapper()
65 if (fSpecificationMapPtr) delete [] fSpecificationMapPtr;
66 fSpecificationMapPtr = NULL;
67 if (fHw2geomapPtr) delete [] fHw2geomapPtr;
72 //void AliHLTCaloMapper::InitAltroMapping(){
76 //void AliHLTCaloMapper::InitDDLSpecificationMapping() {
83 AliHLTCaloMapper::GetIsInitializedMapping()
85 return fIsInitializedMapping;
90 AliHLTCaloMapper::GetFilePath()
97 AliHLTCaloMapper::GetChannelID(const AliHLTUInt32_t spec, const Int_t hadd)
99 Short_t index = GetDDLFromSpec(spec);
102 HLTError("Specification 0x%X not consistent with single DDL in PHOS", spec);
107 return ((fHw2geomapPtr[hadd].fXCol ) |
108 ((fHw2geomapPtr[hadd].fZRow ) << 6) |
109 (fHw2geomapPtr[hadd].fGain << 12) |
110 fSpecificationMapPtr[index].fModId << 13);
116 AliHLTCaloMapper::GetChannelCoord(const UShort_t channelId, UShort_t* channelCoord)
118 channelCoord[0] = channelId&0x3f;
119 channelCoord[1] = (channelId >> 6)&0x3f;
120 channelCoord[2] = (channelId >> 12)&0x1;
121 channelCoord[3] = (channelId >> 13)&0x1f;
122 // printf("Channel ID: 0x%X Coordinates: x = %d, z = %d, gain = %d\n", channelId, channelCoord[0], channelCoord[1], channelCoord[2]);
126 AliHLTCaloMapper::ChannelId2Coordinate(const int channelId, AliHLTCaloCoordinate &channelCoord)
128 channelCoord.fX = channelId&0x3f;
129 channelCoord.fZ = (channelId >> 6)&0x3f;
130 channelCoord.fGain = (channelId >> 12)&0x1;
131 channelCoord.fModuleId = (channelId >> 13)&0x1f;
132 // printf("Channel ID: 0x%X Coordinates: x = %d, z = %d, gain = %d\n", channelId, channelCoord[0], channelCoord[1], channelCoord[2]);
137 AliHLTCaloMapper::GetLocalCoord(const int channelId, Float_t* localCoord) const
139 localCoord[0] = (static_cast<Float_t>(channelId&0x3f) - fCaloConstants->GetNXCOLUMNSMOD()/2)* fCaloConstants->GetCELLSTEP();
140 // localCoord[0] = (static_cast<Float_t>(channelId&0x3f) - fCaloConstants->GetNXCOLUMNSMOD()/2)*CELLSTEP;
141 localCoord[1] = (static_cast<Float_t>((channelId >> 6)&0x3f) - fCaloConstants->GetNZROWSMOD()/2) * fCaloConstants->GetCELLSTEP();
142 // printf("Local coordinates: x = %f, z = %f\n", channelCoord[0], channelCoord[1]);
147 AliHLTCaloMapper::GetDDLFromSpec( const AliHLTUInt32_t spec )
150 for(int i=0; i < 32; i++ )
160 // HLTError("Specification %d, not consistent with any DDL in PHOS or EMCAL", spec );
168 AliHLTCaloMapper::GetModuleFromSpec(UInt_t specification)
172 // get rid of too much string operations
174 // if (fCaloDet.CompareTo("PHOS") == 0) {
176 if (fCaloDet[0]=='P') {
177 // P = is the short for PHOS
179 if(specification & 0xf) module = 0;
180 else if((specification >> 4) & 0xf) module = 1;
181 else if((specification >> 8) & 0xf) module = 2;
182 else if((specification >> 12) & 0xf) module = 3;
183 else if((specification >> 16) & 0xf) module = 4;
185 HLTDebug("Specification 0x%X not consistent with single module in PHOS", specification);
190 //else if (fCaloDet.CompareTo("EMCAL") == 0) {
191 else if (fCaloDet[0]=='E') {
193 // E = is the short for EMCAL
195 if(specification & 0x3) module = 0;
196 else if((specification >> 2) & 0x3) module = 1;
197 else if((specification >> 4) & 0x3) module = 2;
198 else if((specification >> 6) & 0x3) module = 3;
199 else if((specification >> 8) & 0x3) module = 4;
200 else if((specification >> 10) & 0x3) module = 5;
201 else if((specification >> 12) & 0x3) module = 6;
202 else if((specification >> 14) & 0x3) module = 7;
203 else if((specification >> 16) & 0x3) module = 8;
204 else if((specification >> 18) & 0x3) module = 9;
206 HLTDebug("Specification 0x%X not consistent with single module in EMCAL", specification);
211 HLTDebug("Specification 0x%X not consistent with single module in EMCAL or PHOS", specification);
218 AliHLTCaloMapper::GetSpecFromDDLIndex( const int ddlindex )
220 int iret = (unsigned long)1 << ddlindex;
222 // return ((unsigned long)1) << ddlindex ) ;