]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/PHOS/AliHLTPHOSMapper.cxx
Updating CMake files
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSMapper.cxx
index 4c7cfece301b5e84b6ef2911af78107db593c0cf..85197c7622bacd1a03b2d44ff2468eecf69723f1 100644 (file)
 //
 
 #include "AliHLTPHOSMapper.h"
+#include "AliHLTPHOSConstants.h"
+#include "AliHLTLogging.h"
+#include "Rtypes.h"
+#include "unistd.h"
+#include <iostream>
 
-
-AliHLTPHOSMapper::AliHLTPHOSMapper() : AliHLTPHOSBase(), fHw2geomapPtr(0)
+using namespace PhosHLTConst;
+AliHLTPHOSMapper::AliHLTPHOSMapper():  AliHLTLogging(), 
+                                      fHw2geomapPtr(0),
+                                      fIsInitializedMapping(false),
+                                      fSpecificationMapPtr(0)
 {
-  //  printf("\nCreating new mapper\n");
   InitAltroMapping(); 
+  InitDDLSpecificationMapping();
 }
 
 
@@ -43,7 +51,7 @@ AliHLTPHOSMapper::InitAltroMapping()
 {
   // Loads mapping between Altro addresses and geometrical addresses from file
 
-  char filename[256];
+  //  char filename[256];
   char *base =  getenv("ALICE_ROOT");
   int nChannels = 0;
   int maxaddr = 0;
@@ -54,16 +62,13 @@ AliHLTPHOSMapper::InitAltroMapping()
 
   if(base !=0)
     {
-      sprintf(filename,"%s/PHOS/mapping/RCU0.data", base);
-
-      FILE *fp = fopen(filename, "r");
+      sprintf(fFilepath,"%s/PHOS/mapping/RCU0.data", base);
+      
+      FILE *fp = fopen(fFilepath, "r");
       if(fp != 0)
        {
-         cout << "mapping file found" << endl;
          fscanf(fp, "%d", &nChannels);
          fscanf(fp, "%d", &maxaddr);
-         printf("nChannels = %d", nChannels);
-         printf("maxaddr = %d", maxaddr);
          fHw2geomapPtr = new fAltromap[maxaddr +1]; 
 
          for(int i=0; i< maxaddr + 1 ; i ++)
@@ -80,18 +85,115 @@ AliHLTPHOSMapper::InitAltroMapping()
              fHw2geomapPtr[tmpHwaddr].fZRow   = tmpZRow;
              fHw2geomapPtr[tmpHwaddr].fGain  = tmpGain;
            }
-         
+         fIsInitializedMapping = true;   
+         fclose(fp);
        }
       else
        {
-         cout << "ERROR could not find mapping file" << endl;
+         fIsInitializedMapping = false;          
        }
-
     }
   else
     {
-      printf("AliHLTPHOSMapper::InitAltroMapping(), ERROR environment ALICE_ROOT is not set, cannot find mapping file");
+      fIsInitializedMapping = false;
     }
-
 } 
 
+void
+AliHLTPHOSMapper::InitDDLSpecificationMapping()
+{
+  fSpecificationMapPtr = new fDDLSpecificationMap[PhosHLTConst::N_MODULES*PhosHLTConst::N_RCUS_PER_MODULE];
+  for(Int_t ddl = 0; ddl < PhosHLTConst::N_MODULES*PhosHLTConst::N_RCUS_PER_MODULE; ddl++)
+    {
+      
+      fSpecificationMapPtr[ddl].fModId = ddl/PhosHLTConst::N_RCUS_PER_MODULE;
+      
+      if(ddl%4 == 0)
+       {
+         fSpecificationMapPtr[ddl].fRcuX = 0; 
+         fSpecificationMapPtr[ddl].fRcuZ = 0;
+       }
+      
+      else if(ddl%4 == 1)
+       {
+         fSpecificationMapPtr[ddl].fRcuX = 0; 
+         fSpecificationMapPtr[ddl].fRcuZ = 1;
+       }
+      
+      else if( ddl%4 == 2)
+       {
+         fSpecificationMapPtr[ddl].fRcuX = 1; 
+         fSpecificationMapPtr[ddl].fRcuZ = 0;
+       }
+      else
+       {
+         fSpecificationMapPtr[ddl].fRcuX = 1; 
+         fSpecificationMapPtr[ddl].fRcuZ = 1;
+       }
+      
+      fSpecificationMapPtr[ddl].fRcuZOffset = N_ZROWS_RCU*(fSpecificationMapPtr[ddl].fRcuZ);
+      fSpecificationMapPtr[ddl].fRcuXOffset = N_XCOLUMNS_RCU*(fSpecificationMapPtr[ddl].fRcuX);
+    }
+}
+
+
+bool 
+AliHLTPHOSMapper::GetIsInitializedMapping()
+{
+  return  fIsInitializedMapping;
+}
+
+
+char* 
+AliHLTPHOSMapper::GetFilePath()
+{
+  return  fFilepath;
+}
+
+UShort_t
+AliHLTPHOSMapper::GetChannelID(Int_t specification, Int_t hwAddress)
+{
+  
+  Short_t index = 0;
+
+  if(specification == 0x00001) index = 0;
+  else if(specification == 0x00002) index = 1;
+  else if(specification == 0x00004) index = 2;
+  else if(specification == 0x00008) index = 3;
+
+  else if(specification == 0x00010) index = 4;
+  else if(specification == 0x00020) index = 5;
+  else if(specification == 0x00040) index = 6;
+  else if(specification == 0x00080) index = 7;
+
+  else if(specification == 0x00100) index = 8;
+  else if(specification == 0x00200) index = 9;
+  else if(specification == 0x00400) index = 10;
+  else if(specification == 0x00800) index = 11;
+
+  else if(specification == 0x01000) index = 12;
+  else if(specification == 0x02000) index = 13;
+  else if(specification == 0x04000) index = 14;
+  else if(specification == 0x08000) index = 15;
+
+  else if(specification == 0x10000) index = 16;
+  else if(specification == 0x20000) index = 17;
+  else if(specification == 0x40000) index = 18;
+  else if(specification == 0x80000) index = 19;
+
+  else HLTError("Specification 0x%X not consistent with single DDL in PHOS", specification);
+
+  return ((fHw2geomapPtr[hwAddress].fXCol + fSpecificationMapPtr[index].fRcuXOffset) |
+         ((fHw2geomapPtr[hwAddress].fZRow + fSpecificationMapPtr[index].fRcuZOffset) << 6) |
+         (fHw2geomapPtr[hwAddress].fGain << 12) |
+         fSpecificationMapPtr[index].fModId << 13);
+}
+
+void
+AliHLTPHOSMapper::GetChannelCoord(UShort_t channelId, UShort_t* channelCoord)
+{
+  channelCoord[0] = channelId&0x3f;
+  channelCoord[1] = (channelId >> 6)&0x3f;
+  channelCoord[2] = (channelId >> 12)&0x1;
+  channelCoord[3] = (channelId >> 13)&0x1f;
+}