]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HLT/EMCAL/AliHLTEMCALMapper.cxx
Optimisation
[u/mrichter/AliRoot.git] / HLT / EMCAL / AliHLTEMCALMapper.cxx
index 87fbdc1148c3bd3a558b9d769a4ca3aff6db432a..efda341a25709dd147a4fcb2571b0129c3093c7c 100644 (file)
  * about the suitability of this software for any purpose. It is          *
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
+
 #include "AliHLTEMCALMapper.h"
 
-#include "AliHLTEMCALConstants.h"
+//#include "AliHLTEMCALConstant.h"
+// #include "AliHLTCaloConstant.h"
+
+#include "assert.h"
 
-using namespace EmcalHLTConst;
+//using namespace EmcalHLTConst;
 
-//AliHLTCaloMapper
+#include "AliHLTCaloConstants.h"
 
+using EMCAL::NXCOLUMNSMOD;
+using EMCAL::NZROWSMOD;
+using EMCAL::NMODULES;
+using EMCAL::NRCUSPERMODULE;
+using EMCAL::NRCUSPERSECTOR;
 
-AliHLTEMCALMapper::AliHLTEMCALMapper(const unsigned long specification ) : AliHLTCaloMapper(specification
+AliHLTEMCALMapper::AliHLTEMCALMapper(const unsigned long specification ) : AliHLTCaloMapper(specification, "EMCAL")
 {
+  fCellSize = 6;
   InitAltroMapping(specification);
   InitDDLSpecificationMapping();
-  fIsInitializedMapping = true; //CRAP PTH, must check is the initilization actually went ok
+  fIsInitializedMapping = true; //CRAP PTH, must check if the initilization actually went ok
 }
 
 
@@ -36,9 +46,17 @@ AliHLTEMCALMapper::~AliHLTEMCALMapper()
 {
 
 }
-
+  
 
 void 
+AliHLTEMCALMapper::GetLocalCoord(const int channelId, Float_t* localCoord) const
+{
+  localCoord[0] = ( ( Float_t )(channelId&0x3f) - NXCOLUMNSMOD/2)  * fCellSize;
+  localCoord[1] = ( (Float_t)((channelId >> 6)&0x3f) - NZROWSMOD/2) * fCellSize;
+}
+
+
+Bool_t 
 AliHLTEMCALMapper::InitAltroMapping(const unsigned long specification )
 {
   char *base =  getenv("ALICE_ROOT");
@@ -53,8 +71,8 @@ AliHLTEMCALMapper::InitAltroMapping(const unsigned long specification )
   if(base !=0)
     {
       sprintf(fFilepath, "%s/EMCAL/mapping/%s", base,   DDL2RcuMapFileName( GetDDLFromSpec( specification ) ) ); 
-      cout << __FILE__ <<":"<< __LINE__ <<"mapping filename is " <<  fFilepath << endl;
-       // sprintf(fFilepath,"%s/PHOS/mapping/RCU0.data", base);
+      sprintf(fFilepath, "%s/EMCAL/mapping/%s", base,   DDL2RcuMapFileName( GetDDLFromSpec( specification ) ) ); 
+
       FILE *fp = fopen(fFilepath, "r");
       if(fp != 0)
        {
@@ -72,8 +90,6 @@ AliHLTEMCALMapper::InitAltroMapping(const unsigned long specification )
            {
              res = fscanf(fp, "%d %d %d %d\n", &tmpHwaddr, &tmpXCol, &tmpZRow,  &tmpGain);
              
-             //              cout << __FILE__ << __LINE__ << "  tmpHwaddr  = " << tmpHwaddr << ", tmpXCol = " << (int)tmpXCol <<  ", tmpZRow = "<< (int)tmpZRow <<  ", tmpGain= "<< (int)tmpGain << endl;
-             
              if(tmpGain < 2)
                {
                  fHw2geomapPtr[tmpHwaddr].fXCol   = (char)tmpXCol;
@@ -86,7 +102,6 @@ AliHLTEMCALMapper::InitAltroMapping(const unsigned long specification )
        }
       else
        {
-         cout << __FUNCTION__ << ":"<<__FILE__<<":"<< __LINE__ << "ERROR, could not open mapping file %s" <<  fFilepath << endl;
          fIsInitializedMapping = false;          
        }
     }
@@ -94,29 +109,22 @@ AliHLTEMCALMapper::InitAltroMapping(const unsigned long specification )
     {
       fIsInitializedMapping = false;
     }
+    
+    return fIsInitializedMapping;
 }
 
 
 void 
 AliHLTEMCALMapper::InitDDLSpecificationMapping()
 {
-  fSpecificationMapPtr = new fDDLSpecificationMap[EmcalHLTConst::NMODULES*EmcalHLTConst::NRCUSPERMODULE];
+  fSpecificationMapPtr = new fDDLSpecificationMap[NMODULES*NRCUSPERMODULE];
   
-  for(Int_t ddl = 0; ddl < EmcalHLTConst::NMODULES*EmcalHLTConst::NRCUSPERMODULE; ddl++)
+  for(Int_t ddl = 0; ddl < NMODULES*NRCUSPERMODULE; ddl++)
     {
-      fSpecificationMapPtr[ddl].fModId = ddl/EmcalHLTConst::NRCUSPERMODULE;
-      fSpecificationMapPtr[ddl].fRcuX = 0; 
-      fSpecificationMapPtr[ddl].fRcuZ = ddl%2; 
-      //      fSpecificationMapPtr[ddl].fRcuZOffset = NZROWSRCU*(fSpecificationMapPtr[ddl].fRcuZ);
-      //      fSpecificationMapPtr[ddl].fRcuXOffset = NXCOLUMNSRCU*(fSpecificationMapPtr[ddl].fRcuX);
+      fSpecificationMapPtr[ddl].fModId = ddl/( NRCUSPERMODULE );
     }
 }
 
-
-
-//RCU1C.data
-
-
 const char* 
 AliHLTEMCALMapper::DDL2RcuMapFileName(const int ddlIndex) const //0=4608, 1=4607 etc...
 {
@@ -131,42 +139,9 @@ AliHLTEMCALMapper::DDL2RcuMapFileName(const int ddlIndex) const //0=4608, 1=4607
     {
       tmpSide  = 'C';
     }
-  
-  sprintf(rname,"RCU%d%c.data", ddlIndex/NRCUSPERSECTOR, tmpSide );
+  int tmprcuindex = ddlIndex%2;
+  sprintf(rname,"RCU%d%c.data",  tmprcuindex,  tmpSide );
+  //sprintf(rname,"RCU%d%c.data", ddlIndex/NRCUSPERSECTOR, tmpSide );
   return rname;
-  // rname.fSector = ddlIndex/NRCUSPERSECTOR;
-}
-
-/*
-unsigned long 
-AliHLTEMCALMapper::GetSpecFromDDLIndex( const int ddlindex )
-{
-  return ( (unsigned long)1  <<  ddlindex ));
-}
-*/
-
-/*
-AliHLTEMCALMapper::GlobalX2ModuleId( const int globalX )
-{
-  return globalX/NXCOLUMNSMOD;  
 }
-*/
-
- /*
-static  const int 
-AliHLTEMCALMapper::GlobalZ2ModuleId( const int globalZ )
-{
-  return globalZ/NZROWSMOD;
-  }
- */
-
-
-  /*
- const int 
- AliHLTEMCALMapper::Global2ModuleId( const int globalZ,  const int globalX )
-{
-  int tmpModX = 
  
-}
-  */