]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Fixes to AliFMDAltroMapping and AliFMDParameters to allow
authorcholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 6 Sep 2008 14:06:33 +0000 (14:06 +0000)
committercholm <cholm@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sat, 6 Sep 2008 14:06:33 +0000 (14:06 +0000)
faster reading of RAW data.   The rest of the changes reflect
the changes in the two mentioned classes.

Peter, please back-port to the release - we need this
to speed up our DAs to a reasonable time.  Thank you.

FMD/AliFMDAltroMapping.cxx
FMD/AliFMDAltroMapping.h
FMD/AliFMDGainDA.cxx
FMD/AliFMDParameters.cxx
FMD/AliFMDParameters.h
FMD/AliFMDQADataMakerRec.cxx
FMD/AliFMDRawReader.cxx
FMD/AliFMDRawWriter.cxx
FMD/scripts/TestAltroMapping.C

index bdd3ca01fa8ebc1285cf7929a96a25ce44e864e5..2e6cdab02e7ef08544cfea22086984e3e5ebbabd 100644 (file)
@@ -37,6 +37,7 @@
 #include "AliFMDAltroMapping.h"                // ALIFMDALTROMAPPING_H
 #include "AliFMDParameters.h"
 #include "AliLog.h"
+#include "AliFMDDebug.h"
 #include <iostream>
 #include <iomanip>
 
@@ -69,26 +70,11 @@ AliFMDAltroMapping::CreateInvMapping()
   return kTRUE;
 }
 
-//____________________________________________________________________
-Bool_t 
-AliFMDAltroMapping::Hardware2Detector(UInt_t    ddl, UInt_t    addr, 
-                                     UShort_t& det, Char_t&   ring, 
-                                     UShort_t& sec, Short_t&  str) const
-{
-  // Translate a hardware address to detector coordinates. 
-  // 
-  // See also Hardware2Detector that accepts 4 inputs 
-  UInt_t board =  (addr >> 7) & 0x1F;
-  UInt_t altro =  (addr >> 4) & 0x7;
-  UInt_t chan  =  (addr & 0xf);
-  return Hardware2Detector(ddl, board, altro, chan, det, ring, sec, str);
-}
 
 //____________________________________________________________________
 Bool_t 
-AliFMDAltroMapping::Hardware2Detector(UInt_t    ddl,   UInt_t    board, 
-                                     UInt_t    altro, UInt_t    chan,
-                                     UShort_t& det,   Char_t&   ring, 
+AliFMDAltroMapping::Channel2StripBase(UShort_t  board, UShort_t  altro, 
+                                     UShort_t  chan,  Char_t&   ring, 
                                      UShort_t& sec,   Short_t&  str) const
 {
   // Translate a hardware address to detector coordinates. 
@@ -161,8 +147,7 @@ AliFMDAltroMapping::Hardware2Detector(UInt_t    ddl,   UInt_t    board,
   // return the first strip, as seen by the ALTRO channel, in the
   // given range.  
   //
-  det          =  ddl + 1;
-  ring         =  (board % 2) == 0 ? 'I' : 'O';
+  ring         =  Board2Ring(board);
   switch (ring) {
   case 'i':
   case 'I':
@@ -178,35 +163,63 @@ AliFMDAltroMapping::Hardware2Detector(UInt_t    ddl,   UInt_t    board,
     break;
   }
   if (sec % 2) str += 127;
+  // AliFMDDebug(1, ("%02x/%x/%x Base strip = %d", board, altro, chan, str));
   return kTRUE;
 }
 
+//____________________________________________________________________
+void
+AliFMDAltroMapping::Timebin2Strip(UShort_t  sec,         
+                                 UShort_t  timebin,
+                                 UShort_t  preSamples, 
+                                 UShort_t  sampleRate, 
+                                 Short_t&  stripOff,      
+                                 UShort_t& sample) const
+{
+  // Compute the strip off-set in the current channel from the sector
+  // and timebin.   Also needed for this computation is the basic
+  // offset in timebins, as well as the sample rat. 
+  UShort_t t =  (timebin - preSamples);
+  sample     =  (t % sampleRate);
+  t          -= sample;
+  stripOff   =  (sec % 2 ? -1 : 1) * t / sampleRate;
+}
+
+#if 0
 //____________________________________________________________________
 Bool_t 
-AliFMDAltroMapping::Hardware2Detector(UInt_t    ddl,       UInt_t   addr,
-                                     UShort_t  timebin,   UShort_t preSamples, 
-                                     UShort_t  sampleRate,
-                                     UShort_t& det,       Char_t&   ring, 
-                                     UShort_t& sec,       Short_t&  str,
-                                     UShort_t& sam) const
+AliFMDAltroMapping::Hardware2Detector(UInt_t    ddl,   UInt_t    board, 
+                                     UInt_t    altro, UInt_t    chan,
+                                     UShort_t& det,   Char_t&   ring, 
+                                     UShort_t& sec,   Short_t&  str) const
+{
+  // See also Hardware2Detector that requires 3 inputs 
+  det = DDL2Detector(ddl);
+  return Channel2StripBase(board, altro, chan, ring, sec, str);
+}
+
+
+//____________________________________________________________________
+Bool_t 
+AliFMDAltroMapping::Hardware2Detector(UInt_t    ddl, UInt_t    addr, 
+                                     UShort_t& det, Char_t&   ring, 
+                                     UShort_t& sec, Short_t&  str) const
 {
   // Translate a hardware address to detector coordinates. 
   // 
   // See also Hardware2Detector that accepts 4 inputs 
-  UInt_t board =  (addr >> 7) & 0x1F;
-  UInt_t altro =  (addr >> 4) & 0x7;
-  UInt_t chan  =  (addr & 0xf);
-  return Hardware2Detector(ddl, board, altro, chan, 
-                          timebin, preSamples, sampleRate, 
-                          det, ring, sec, str, sam);
+  UShort_t board, altro, chan;
+  ChannelAddress(addr, board, altro, chan);
+  return Hardware2Detector(ddl,board, altro, chan, det,ring, sec, str);
 }
+#endif 
 
 //____________________________________________________________________
 Bool_t 
-AliFMDAltroMapping::Hardware2Detector(UInt_t    ddl,     UInt_t    board, 
-                                     UInt_t    altro,   UInt_t    chan,
-                                     UInt_t    timebin, UInt_t    preSamples,
-                                     UInt_t    sampleRate,
+AliFMDAltroMapping::Hardware2Detector(UShort_t  ddl,     UShort_t    board, 
+                                     UShort_t  altro,   UShort_t    chan,
+                                     UShort_t  timebin, UShort_t    preSamples,
+                                     UShort_t  sampleRate,
                                      UShort_t& det,     Char_t&   ring, 
                                      UShort_t& sec,     Short_t&  str,
                                      UShort_t& sam) const
@@ -215,29 +228,74 @@ AliFMDAltroMapping::Hardware2Detector(UInt_t    ddl,     UInt_t    board,
   // to detector coordinates and sample number.  Note, that this
   // conversion depends on the oversampling rate and the number of
   // pre-samples 
-  if (!Hardware2Detector(ddl, board, altro, chan, det, ring, sec, str))
+  Short_t  baseStrip, stripOffset, tdet  = DDL2Detector(ddl);
+  if (tdet < 0) return kFALSE;
+  det = tdet;
+  if (!Channel2StripBase(board, altro, chan, ring, sec, baseStrip)) 
     return kFALSE;
-  UShort_t t =  (timebin - preSamples);
-  sam        =  (t % sampleRate);
-  t          -= sam;
-  str        += (sec % 2 ? -1 : 1) * t / sampleRate;
-  // if (sec % 2) sam = sampleRate - 1 - sam;
+  Timebin2Strip(sec, timebin, preSamples, sampleRate, stripOffset, sam);
 #if 0
-  AliFMDDebug(3, ("%d/0x%02x/0x%x/0x%x/%04d -> FMD%d%c[%02d,%03d]-%d"
-                 " (pre=%2d, rate=%d)", 
-                 ddl, board, altro, chan, timebin, 
-                 det, ring, sec, str, sam, preSamples, sampleRate));
+  AliFMDDebug(1, ("0x%x/0x%02x/0x%x/0x%x/%04d -> FMD%d%c[%2d,%3d]-%d "
+                 "(pre=%d,rate=%d,base=%3d,off=%3d)", 
+                 ddl, 
+                 board, 
+                 altro, 
+                 chan, 
+                 timebin, 
+                 det, 
+                 ring, 
+                 sec, 
+                 str, 
+                 sam,
+                 preSamples, 
+                 sampleRate,
+                 baseStrip, 
+                 stripOffset));
 #endif
+  str = baseStrip + stripOffset;
   return kTRUE;
 }
 
-
 //____________________________________________________________________
 Bool_t 
-AliFMDAltroMapping::Detector2Hardware(UShort_t  det,   Char_t    ring, 
-                                     UShort_t  sec,   UShort_t  str,
-                                     UInt_t&   ddl,   UInt_t&   board,
-                                     UInt_t&   altro, UInt_t&   chan) const
+AliFMDAltroMapping::Hardware2Detector(UShort_t  ddl,       UShort_t addr,
+                                     UShort_t  timebin,   UShort_t preSamples, 
+                                     UShort_t  sampleRate,
+                                     UShort_t& det,       Char_t&   ring, 
+                                     UShort_t& sec,       Short_t&  str,
+                                     UShort_t& sam) const
+{
+  // Translate a hardware address to detector coordinates. 
+  // 
+  // See also Hardware2Detector that accepts 4 inputs 
+  UShort_t board, altro, chan;
+  ChannelAddress(addr, board, altro, chan);
+  return Hardware2Detector(ddl, board, altro, chan, 
+                          timebin, preSamples, sampleRate, 
+                          det, ring, sec, str, sam);
+}
+
+
+//____________________________________________________________________
+Short_t
+AliFMDAltroMapping::Sector2Board(Char_t ring, UShort_t sec) const
+{
+  switch (ring) { 
+  case 'I': 
+  case 'i':
+    return (sec / 10) * 16;
+  case 'O': 
+  case 'o': 
+    return (sec / 20) * 16 + 1;
+  }
+  return -1;
+}
+
+//_____________________________________________ _______________________
+Bool_t
+AliFMDAltroMapping::Strip2Channel(Char_t    ring,  UShort_t  sec,   
+                                 UShort_t  str,   UShort_t& board,
+                                 UShort_t& altro, UShort_t& chan) const
 {
   // Translate detector coordinates to a hardware address.
   // The ddl is simply 
@@ -319,7 +377,6 @@ AliFMDAltroMapping::Detector2Hardware(UShort_t  det,   Char_t    ring,
   // With this information, we can decode the detector coordinates to
   // give us a unique hardware address 
   //
-  ddl          =  (det - 1);
   UInt_t tmp   = 0;
   switch (ring) {
   case 'I':
@@ -340,41 +397,64 @@ AliFMDAltroMapping::Detector2Hardware(UShort_t  det,   Char_t    ring,
   return kTRUE;
 }
 
+//_____________________________________________ _______________________
+UShort_t
+AliFMDAltroMapping::Strip2Timebin(UShort_t sec, UShort_t strip, 
+                                 UShort_t sam, UShort_t preSamples, 
+                                 UShort_t sampleRate) const
+{
+  UShort_t timebin = preSamples;
+  if (sec % 2)  timebin += (127 - (strip % 128)) * sampleRate;
+  else          timebin += (strip % 128) * sampleRate;
+  timebin += sam;
+  return timebin;
+}
+
+#if 0
+//_____________________________________________ _______________________
+Bool_t 
+AliFMDAltroMapping::Detector2Hardware(UShort_t  det,   Char_t    ring, 
+                                     UShort_t  sec,   UShort_t  str,
+                                     UShort_t& ddl,   UShort_t& board,
+                                     UShort_t& altro, UShort_t& chan) const
+{
+  ddl =  Detector2DDL(det);
+  return Strip2Channel(ring, sec, str, board, altro, chan);
+}
+
+
 //____________________________________________________________________
 Bool_t 
 AliFMDAltroMapping::Detector2Hardware(UShort_t  det, Char_t    ring, 
                                      UShort_t  sec, UShort_t  str,
-                                     UInt_t&   ddl, UInt_t&   addr) const
+                                     UShort_t& ddl, UShort_t& addr) const
 {
   // Translate detector coordinates to a hardware address.  
   // 
   // See also Detector2Hardware that returns 4 parameters.  
-  UInt_t board = 0;
-  UInt_t altro = 0;
-  UInt_t chan  = 0;
+  UShort_t board = 0;
+  UShort_t altro = 0;
+  UShort_t chan  = 0;
   if (!Detector2Hardware(det,ring,sec,str,ddl,board,altro,chan)) return kFALSE;
-  addr =  chan + (altro << 4) + (board << 7);
+  addr =  ChannelAddress(board, altro, chan);
   return kTRUE;
 }
+#endif
 
 //____________________________________________________________________
 Bool_t 
 AliFMDAltroMapping::Detector2Hardware(UShort_t  det,        Char_t    ring, 
                                      UShort_t  sec,        UShort_t  str,
                                      UShort_t  sam, 
-                                     UShort_t  preSamples, UShort_t sampleRate,
-                                     UInt_t&   ddl,        UInt_t&   board, 
-                                     UInt_t&   altro,      UInt_t&   channel, 
+                                     UShort_t  preSamples, 
+                                     UShort_t  sampleRate,
+                                     UShort_t& ddl,        UShort_t& board, 
+                                     UShort_t& altro,      UShort_t& channel, 
                                      UShort_t& timebin) const
 {
-  if (!Detector2Hardware(det,ring,sec,str,ddl,board,altro,channel)) 
-    return kFALSE;
-  timebin = preSamples;
-  if (sec % 2) 
-    timebin += (127 - (str % 128)) * sampleRate;
-  else 
-    timebin += (str % 128) * sampleRate;
-  timebin += sam;
+  ddl = Detector2DDL(det);
+  if (!Strip2Channel(ring,sec,str,board,altro,channel)) return kFALSE;
+  timebin = Strip2Timebin(sec, str, sam, preSamples, sampleRate);
   return kTRUE;
 }
 
@@ -385,20 +465,37 @@ AliFMDAltroMapping::Detector2Hardware(UShort_t  det,        Char_t   ring,
                                      UShort_t  sec,        UShort_t str,
                                      UShort_t  sam, 
                                      UShort_t  preSamples, UShort_t sampleRate,
-                                     UInt_t&   ddl,        UInt_t&  hwaddr, 
+                                     UShort_t& ddl,        UShort_t&  hwaddr, 
                                      UShort_t& timebin) const
 {
-  UInt_t board = 0;
-  UInt_t altro = 0;
-  UInt_t chan  = 0;
+  UShort_t board = 0;
+  UShort_t altro = 0;
+  UShort_t chan  = 0;
   if (!Detector2Hardware(det, ring, sec, str, sam, 
                         preSamples, sampleRate, 
                         ddl, board, altro, chan, timebin)) return kFALSE;
-  hwaddr =  chan + (altro << 4) + (board << 7);
+  hwaddr =  ChannelAddress(board, altro, chan);
   return kTRUE;
 }
 
       
+//____________________________________________________________________
+UInt_t 
+AliFMDAltroMapping::ChannelAddress(UShort_t board, UShort_t altro, 
+                                  UShort_t channel) const
+{
+  return (((board & 0x1F) << 7) | ((altro & 0x7) << 4) | (channel & 0xF));
+}
+
+//____________________________________________________________________
+void 
+AliFMDAltroMapping::ChannelAddress(UShort_t hwaddr, UShort_t& board, 
+                                  UShort_t& altro, UShort_t& channel) const
+{
+  board   = ((hwaddr >> 7) & 0x1F);
+  altro   = ((hwaddr >> 4) & 0x07);
+  channel = ((hwaddr >> 0) & 0x0F);
+}
 
 //____________________________________________________________________
 Int_t
@@ -413,11 +510,10 @@ AliFMDAltroMapping::GetHWAddress(Int_t sec, Int_t str, Int_t ring)
   //   pad     | strip
   //   sector  | ring 
   //
-  UInt_t ddl, hwaddr;
   Char_t r = Char_t(ring);
-  if (!Detector2Hardware(1, r, sec, str, ddl, hwaddr)) 
-    return -1;
-  return hwaddr;
+  UShort_t board, altro, channel;
+  Strip2Channel(r, sec, str, board, altro, channel);
+  return ChannelAddress(board, altro, channel);
 }
 
 //____________________________________________________________________
@@ -433,13 +529,13 @@ AliFMDAltroMapping::GetPadRow(Int_t hwaddr) const
   //   pad     | strip
   //   sector  | ring 
   //
-  UShort_t det;
   Char_t   ring;
-  UShort_t sec;
-  Short_t  str;
-  Int_t    ddl = 0;
-  if (!Hardware2Detector(ddl, hwaddr, det, ring, sec, str)) return -1;
-  return Int_t(sec);
+  UShort_t board, altro, channel, sector;
+  Short_t  baseStrip;
+  ChannelAddress(hwaddr, board, altro, channel);
+  if (!Channel2StripBase(board, altro, channel, ring, sector, baseStrip))
+    return -1;
+  return Int_t(sector);
 }
 
 //____________________________________________________________________
@@ -455,13 +551,13 @@ AliFMDAltroMapping::GetPad(Int_t hwaddr) const
   //   pad     | strip
   //   sector  | ring 
   //
-  UShort_t det;
   Char_t   ring;
-  UShort_t sec;
-  Short_t  str;
-  Int_t    ddl = 0;
-  if (!Hardware2Detector(ddl, hwaddr, det, ring, sec, str)) return -1;
-  return Int_t(str);
+  UShort_t board, altro, channel, sector;
+  Short_t  baseStrip;
+  ChannelAddress(hwaddr, board, altro, channel);
+  if (!Channel2StripBase(board, altro, channel, ring, sector, baseStrip))
+    return -1;
+  return Int_t(baseStrip);
 }
   
 //____________________________________________________________________
@@ -477,12 +573,12 @@ AliFMDAltroMapping::GetSector(Int_t hwaddr) const
   //   pad     | strip
   //   sector  | ring 
   //
-  UShort_t det;
   Char_t   ring;
-  UShort_t sec;
-  Short_t  str;
-  Int_t    ddl = 0;
-  if (!Hardware2Detector(ddl, hwaddr, det, ring, sec, str)) return -1;
+  UShort_t board, altro, channel, sector;
+  Short_t  baseStrip;
+  ChannelAddress(hwaddr, board, altro, channel);
+  if (!Channel2StripBase(board, altro, channel, ring, sector, baseStrip))
+    return -1;
   return Int_t(ring);
 }
 
@@ -492,9 +588,9 @@ AliFMDAltroMapping::Print(Option_t* option) const
 {
   TString opt(option);
   opt.ToLower();
-  UInt_t ddl, board, chip, chan, addr;
+  UShort_t ddl, board, chip, chan, addr;
   UShort_t det, sec;
-  Short_t str;
+  Short_t  strBase;
   Char_t   rng;
   
   if (opt.Contains("hw") || opt.Contains("hardware")) { 
@@ -504,23 +600,24 @@ AliFMDAltroMapping::Print(Option_t* option) const
     for (ddl = 0; ddl <= 2; ddl++) { 
       Int_t  boards[] = { 0, 16, (ddl == 0 ? 32 : 1), 17, 32};
       Int_t* ptr      = boards;
+      det             = DDL2Detector(ddl);
       while ((board = *(ptr++)) < 32) { 
        for (chip = 0; chip <= 2; chip++) { 
-         UInt_t nchan = (chip == 1 ? 8 : 16);
+         UShort_t nchan = (chip == 1 ? 8 : 16);
          for (chan = 0; chan < nchan; chan++) { 
-           Hardware2Detector(ddl, board, chip, chan, det, rng, sec, str);
-           addr = ((board & 0x1f) << 7) | ((chip & 0x7) << 4) | (chan & 0xf);
+           Channel2StripBase(board, chip, chan, rng, sec, strBase);
+           addr = ChannelAddress(board, chip, chan);
            std::cout << " "  
-                     << std::setw(3) << ddl   << " | " 
-                     << std::setfill('0')     << std::hex << " 0x"
-                     << std::setw(2) << board << " |  0x"
-                     << std::setw(1) << chip  << " |  0x"
-                     << std::setw(1) << chan  << " |   0x" 
-                     << std::setw(3) << addr  << " | " 
-                     << std::setfill(' ')     << std::dec << " FMD" 
-                     << std::setw(1) << det << rng << "[" 
-                     << std::setw(2) << sec << "," << std::setw(3) << str
-                     << "]" << std::endl;
+                     << std::setw(3) << ddl     << " | " 
+                     << std::setfill('0')       << std::hex << " 0x"
+                     << std::setw(2) << board   << " |  0x"
+                     << std::setw(1) << chip    << " |  0x"
+                     << std::setw(1) << chan    << " |   0x" 
+                     << std::setw(3) << addr    << " | " 
+                     << std::setfill(' ')       << std::dec << " FMD" 
+                     << std::setw(1) << det     << rng << "[" 
+                     << std::setw(2) << sec     << "," 
+                     << std::setw(3) << strBase << "]" << std::endl;
          } // for chan ...
          if (chip == 2 && *ptr >= 32) continue;
          std::cout << "     +       +      +      +         +              " 
@@ -538,24 +635,24 @@ AliFMDAltroMapping::Print(Option_t* option) const
     for (det = 1; det <= 3; det++) { 
       Char_t  rings[] = { 'I', (det == 1 ? '\0' : 'O'),'\0' };
       Char_t* ptr     = rings;
+      ddl             = Detector2DDL(det);
       while ((rng = *(ptr++)) != '\0') { 
        UShort_t nsec = (rng == 'I' ?  20 :  40);
        UShort_t nstr = (rng == 'I' ? 512 : 256);
        for (sec = 0; sec < nsec; sec++) { 
-         for (str = 0; str < nstr; str += 128) {
-           ddl = board = chip = chan;
-           Detector2Hardware(det,rng,sec,str,ddl,board,chip,chan);
-           addr = ((board & 0x1f) << 7) | ((chip & 0x7) << 4) | (chan & 0xf);
-           std::cout << std::setfill(' ')     << std::dec << " FMD" 
-                     << std::setw(1) << det   << rng      << "[" 
-                     << std::setw(2) << sec   << "," 
-                     << std::setw(3) << str   << "] | " 
-                     << std::setw(3) << ddl   << " |  0x"
-                     << std::setfill('0')     << std::hex  
-                     << std::setw(2) << board << " |  0x"
-                     << std::setw(1) << chip  << " |  0x"
-                     << std::setw(1) << chan  << " |   0x" 
-                     << std::setw(3) << addr  << std::endl;
+         for (strBase = 0; strBase < nstr; strBase += 128) {
+           Strip2Channel(rng, sec, strBase, board, chip, chan);
+           addr = ChannelAddress(board, chip, chan);
+           std::cout << std::setfill(' ')         << std::dec << " FMD" 
+                     << std::setw(1) << det       << rng      << "[" 
+                     << std::setw(2) << sec       << "," 
+                     << std::setw(3) << strBase   << "] | " 
+                     << std::setw(3) << ddl       << " |  0x"
+                     << std::setfill('0')         << std::hex  
+                     << std::setw(2) << board     << " |  0x"
+                     << std::setw(1) << chip      << " |  0x"
+                     << std::setw(1) << chan      << " |   0x" 
+                     << std::setw(3) << addr      << std::endl;
          } // for str ...
        } // for sec ... 
        if (*ptr == '\0') continue;
index c4d57830fa35a7d1e44ce2f86f5749375f06a23a..b7a2a755eb5d1aed12d7ba5fa52cf65dba763258 100644 (file)
@@ -56,6 +56,46 @@ public:
   AliFMDAltroMapping();
   /** Destructor */
   virtual ~AliFMDAltroMapping() {}
+  /** Return detector number corresponding to given DDL number 
+      @param ddl DDL number 
+      @return Detector number */ 
+  Short_t DDL2Detector(UInt_t ddl) const { return (ddl<=2 ? ddl + 1 : -1); }
+  /** Return the ring identifier corresponding to a board number 
+      @param board Board number 
+      @return Ring identifier */ 
+  Char_t Board2Ring(UShort_t board) const { return (board%2)?'O':'I'; }
+
+  /** Return the strip base number corresponding to a channel address 
+      @param board   Board number
+      @param altro   Altro number 
+      @param channel Channel number 
+      @param ring    On return, the ring ID 
+      @param sec     On return, the sector number 
+      @param strip   On return, the strip base offset 
+      @return @c true on success */ 
+  Bool_t Channel2StripBase(UShort_t  board, UShort_t  altro, 
+                          UShort_t  chan,  Char_t&   ring, 
+                          UShort_t& sec,   Short_t&  str) const;
+  /** Return the strip, sample corresponding to a timebin 
+      @param sec        Sector
+      @param timebin    Time bin 
+      @param preSamples Number of pre-samples 
+      @param sampleRate Oversampling rate 
+      @param strip      On return, the strip number in this channel
+      @param sam        On return, the sample number */ 
+  void Timebin2Strip(UShort_t sec,        UShort_t  timebin,
+                    UShort_t preSamples, UShort_t  sampleRate, 
+                    Short_t& strip,      UShort_t& sample) const;
+
+#if 0  
+  /** Map a hardware address into a detector index. 
+      @param hwaddr Hardware address.  
+      @param ring   On return, the ring ID
+      @param sec    On return, the sector #
+      @param str    On return, the base of strip #
+      @return @c true on success, false otherwise */
+  Bool_t Hardware2Detector(UInt_t    hwaddr, 
+                          Char_t&   ring, UShort_t& sec, Short_t& str) const;
   /** Map a hardware address into a detector index. 
       @param ddl    Hardware DDL number 
       @param hwaddr Hardware address.  
@@ -67,6 +107,21 @@ public:
   Bool_t Hardware2Detector(UInt_t    ddl, UInt_t    hwaddr, 
                           UShort_t& det, Char_t&   ring, 
                           UShort_t& sec, Short_t& str) const;
+  /** Map a hardware address into a detector index. 
+      @param ddl     Hardware DDL number 
+      @param board   FEC number
+      @param altro   ALTRO number 
+      @param channel Channel number 
+      @param det     On return, the detector #
+      @param ring    On return, the ring ID
+      @param sec     On return, the sector #
+      @param str     On return, the base of strip #
+      @return @c true on success, false otherwise */
+  Bool_t Hardware2Detector(UInt_t    ddl,   UInt_t    board, 
+                          UInt_t    altro, UInt_t    channel,
+                          UShort_t& det,   Char_t&   ring, 
+                          UShort_t& sec,   Short_t&  str) const;
+#endif
   /** Map a hardware address into a detector index. 
       @param ddl        Hardware DDL number 
       @param hwaddr     Hardware address.  
@@ -79,26 +134,12 @@ public:
       @param str        On return, the base of strip #
       @param sam        On return, the sample number for this strip
       @return @c true on success, false otherwise */
-  Bool_t Hardware2Detector(UInt_t    ddl,        UInt_t    hwaddr, 
+  Bool_t Hardware2Detector(UShort_t  ddl,        UShort_t hwaddr, 
                           UShort_t  timebin,    UShort_t preSamples, 
                           UShort_t  sampleRate,
                           UShort_t& det,        Char_t&   ring, 
                           UShort_t& sec,        Short_t&  str,
                           UShort_t& sam) const;
-  /** Map a hardware address into a detector index. 
-      @param ddl     Hardware DDL number 
-      @param board   FEC number
-      @param altro   ALTRO number 
-      @param channel Channel number 
-      @param det     On return, the detector #
-      @param ring    On return, the ring ID
-      @param sec     On return, the sector #
-      @param str     On return, the base of strip #
-      @return @c true on success, false otherwise */
-  Bool_t Hardware2Detector(UInt_t    ddl,   UInt_t    board, 
-                          UInt_t    altro, UInt_t    channel,
-                          UShort_t& det,   Char_t&   ring, 
-                          UShort_t& sec,   Short_t&  str) const;
   /** Map a hardware address into a detector index. 
       @param ddl        Hardware DDL number 
       @param board      FEC number
@@ -113,13 +154,48 @@ public:
       @param str        On return, the base of strip #
       @param sam        On return, the sample number for this strip
       @return @c true on success, false otherwise */
-  Bool_t Hardware2Detector(UInt_t    ddl,        UInt_t    board, 
-                          UInt_t    altro,      UInt_t    chan,
-                          UInt_t    timebin,    UInt_t    preSamples,
-                          UInt_t    sampleRate,
+  Bool_t Hardware2Detector(UShort_t  ddl,        UShort_t  board, 
+                          UShort_t  altro,      UShort_t  chan,
+                          UShort_t  timebin,    UShort_t  preSamples,
+                          UShort_t  sampleRate,
                           UShort_t& det,        Char_t&   ring, 
                           UShort_t& sec,        Short_t&  str,
                           UShort_t& sam) const;
+
+
+
+  /** Return DDL number corresponding to given detector number 
+      @param det Detector number 
+      @return DDL number */ 
+  UShort_t Detector2DDL(UShort_t det) const { return det - 1; }
+  /** Return board address corresponding to a sector 
+      @param ring  Ring identifier 
+      @param sec   Sector number 
+      @return The board number, or negative number in case of failure */
+  Short_t Sector2Board(Char_t ring, UShort_t sec) const;
+    /** Convert strip address to a channel address. 
+      @param ring  Ring identifier 
+      @param sec   Sector number 
+      @param str   Strip number 
+      @param board On return, contains the board number 
+      @param altro On return, contains the altro number 
+      @param chan  On return, contains the channel number 
+      @return @c true on success. */
+  Bool_t Strip2Channel(Char_t    ring,  UShort_t  sec,   
+                      UShort_t  str,   UShort_t& board,
+                      UShort_t& altro, UShort_t& chan) const;
+  /** Get the timebin correspoding to a strip and sample 
+      @param sec        Sector number 
+      @param str        Strip number 
+      @param sam        Sample number 
+      @param preSamples Number of pre-samples. 
+      @param sampleRate The over-sampling rate 
+      @return the timebin corresponding to the passed strip */
+  UShort_t Strip2Timebin(UShort_t sec, UShort_t strip, 
+                        UShort_t sam, UShort_t preSamples, 
+                        UShort_t sampleRate) const;
+  
+#if 0  
   /** Map a detector index into a hardware address. 
       @param det     The detector #
       @param ring    The ring ID
@@ -132,8 +208,20 @@ public:
       @return @c true on success, false otherwise */
   Bool_t Detector2Hardware(UShort_t  det,   Char_t    ring, 
                           UShort_t  sec,   UShort_t  str,
-                          UInt_t&   ddl,   UInt_t&   board, 
-                          UInt_t&   altro, UInt_t&   channel) const;
+                          UShort_t& ddl,   UShort_t& board, 
+                          UShort_t& altro, UShort_t& channel) const;
+  /** Map a detector index into a hardware address. 
+      @param det    The detector #
+      @param ring   The ring ID
+      @param sec    The sector #
+      @param str    The strip #
+      @param ddl    On return, hardware DDL number 
+      @param hwaddr On return, hardware address.  
+      @return @c true on success, false otherwise */
+  Bool_t Detector2Hardware(UShort_t  det, Char_t    ring, 
+                          UShort_t  sec, UShort_t  str,
+                          UShort_t& ddl, UShort_t&   hwaddr) const;
+#endif
   /** Map a detector index into a hardware address. 
       @param det         The detector #
       @param ring        The ring ID
@@ -151,21 +239,10 @@ public:
   Bool_t Detector2Hardware(UShort_t  det,        Char_t    ring, 
                           UShort_t  sec,        UShort_t  str,
                           UShort_t  sam, 
-                          UShort_t  preSamples, UShort_t sampleRate,
-                          UInt_t&   ddl,        UInt_t&   board, 
-                          UInt_t&   altro,      UInt_t&   channel, 
+                          UShort_t  preSamples, UShort_t  sampleRate,
+                          UShort_t& ddl,        UShort_t& board, 
+                          UShort_t& altro,      UShort_t& channel, 
                           UShort_t& timebin) const;
-  /** Map a detector index into a hardware address. 
-      @param det    The detector #
-      @param ring   The ring ID
-      @param sec    The sector #
-      @param str    The strip #
-      @param ddl    On return, hardware DDL number 
-      @param hwaddr On return, hardware address.  
-      @return @c true on success, false otherwise */
-  Bool_t Detector2Hardware(UShort_t  det, Char_t    ring, 
-                          UShort_t  sec, UShort_t  str,
-                          UInt_t&   ddl, UInt_t&   hwaddr) const;
   /** Map a detector index into a hardware address. 
       @param det         The detector #
       @param ring        The ring ID
@@ -181,9 +258,22 @@ public:
   Bool_t Detector2Hardware(UShort_t  det,        Char_t    ring, 
                           UShort_t  sec,        UShort_t  str,
                           UShort_t  sam, 
-                          UShort_t  preSamples, UShort_t sampleRate,
-                          UInt_t&   ddl,        UInt_t&   hwaddr, 
+                          UShort_t  preSamples, UShort_t  sampleRate,
+                          UShort_t& ddl,        UShort_t& hwaddr, 
                           UShort_t& timebin) const;
+  /** Convert board, chip, channel to a hardware address 
+      @param board   Board number 
+      @param altro   Altro number 
+      @param channel Channel number 
+      @return hardware address of a channel */ 
+  UInt_t ChannelAddress(UShort_t board, UShort_t altro, UShort_t channel) const;
+  /** Convert a channel address to board, altro, channel fields 
+      @param hwaddr  Channel address
+      @param board   On return, the Board number 
+      @param altro   On return, the Altro number 
+      @param channel On return, the Channel number */
+  void ChannelAddress(UShort_t hwaddr, UShort_t& board, UShort_t& altro, 
+                     UShort_t& channel) const;
   /** convert a partial detector index into a hardware address
       @param sector Sector number
       @param str    Strip number
index d5cfc57d5ed23d3417aa6c8492c25b32d296d7e1..d4b285107808a491c78b7fb760b534d10b699293 100644 (file)
@@ -37,6 +37,7 @@
 #include "TMath.h"
 #include "TGraphErrors.h"
 #include "AliFMDParameters.h"
+#include "AliFMDAltroMapping.h"
 
 //_____________________________________________________________________
 ClassImp(AliFMDGainDA)
@@ -306,14 +307,17 @@ void AliFMDGainDA::UpdatePulseAndADC(UShort_t det,
 {
   
   AliFMDParameters* pars = AliFMDParameters::Instance();
-  UInt_t ddl, board,chip,ch;
-  pars->Detector2Hardware(det,ring,sec,strip,ddl,board,chip,ch);
+  // UInt_t ddl, board,chip,ch;
+  UShort_t board = pars->GetAltroMap()->Sector2Board(ring, sec);
+  // pars->Detector2Hardware(det,ring,sec,strip,ddl,board,chip,ch);
+  /// pars->GetAltroMap()->Strip2Channel(
   Int_t halfring = GetHalfringIndex(det,ring,board/16);
   
   if(GetCurrentEvent()> (fNumberOfStripsPerChip*fEventsPerChannel.At(halfring)))
     return;
   if(strip % fNumberOfStripsPerChip) return;
-  if(((GetCurrentEvent()) % fPulseLength.At(halfring)) && GetCurrentEvent() > 0) return;
+  if(((GetCurrentEvent()) % fPulseLength.At(halfring)) 
+     && GetCurrentEvent() > 0) return;
      
   Int_t vaChip = strip/fNumberOfStripsPerChip; 
   TH1S* hChannel = GetChannelHistogram(det,ring,sec,vaChip);
@@ -325,7 +329,8 @@ void AliFMDGainDA::UpdatePulseAndADC(UShort_t det,
   }
   Double_t mean      = hChannel->GetMean();
   Double_t rms       = hChannel->GetRMS();
-  Double_t pulse     = Double_t(fCurrentPulse.At(halfring)) * fPulseSize.At(halfring);
+  Double_t pulse     = (Double_t(fCurrentPulse.At(halfring)) 
+                       * fPulseSize.At(halfring));
   Int_t    firstBin  = hChannel->GetXaxis()->GetFirst();
   Int_t    lastBin   = hChannel->GetXaxis()->GetLast();
   hChannel->GetXaxis()->SetRangeUser(mean-4*rms,mean+4*rms);
@@ -335,7 +340,10 @@ void AliFMDGainDA::UpdatePulseAndADC(UShort_t det,
   
   hChannel->GetXaxis()->SetRange(firstBin,lastBin);
   
-  Int_t channelNumber = strip + (GetCurrentEvent()-1)/((fPulseLength.At(halfring)*fHighPulse)/fPulseSize.At(halfring)); 
+  Int_t channelNumber = (strip + 
+                        (GetCurrentEvent()-1)
+                        / ((fPulseLength.At(halfring)*fHighPulse)
+                           / fPulseSize.At(halfring))); 
   
   TGraphErrors* channel = GetChannel(det,ring,sec,channelNumber);
   
index bbed9b2f0e4d9c355a247d10688dd4f73fbf1839..5694f654f7e193273b25e9c2bc416f2a13c0888f 100644 (file)
@@ -251,7 +251,7 @@ AliFMDParameters::Draw(Option_t* option)
       for (UShort_t sec = 0; sec < nSector; sec++) {
        for (UShort_t str = 0; str < nStrip; str++) {
          Int_t idx = DET2IDX(det, ring, sec, str);
-         UInt_t ddl, addr;
+         UShort_t ddl, addr, time, sam=0;
          Double_t val = 0;
          switch (what) {
          case kLocalPulseGain:       // Path to PulseGain calib object
@@ -267,7 +267,7 @@ AliFMDParameters::Draw(Option_t* option)
          case kLocalSampleRate:      // Path to SampleRate calib object
             val = GetSampleRate(det,ring,sec,str); break;
          case kLocalAltroMap:        // Path to AltroMap calib object
-           Detector2Hardware(det,ring,sec,str, ddl, addr); 
+           Detector2Hardware(det,ring,sec,str,sam,ddl,addr,time); 
             val = addr; break;
          case kLocalZeroSuppression: // Path to ZeroSuppression cal object
             val = GetZeroSuppression(det,ring,sec,str); break;
@@ -435,8 +435,8 @@ AliFMDParameters::Print(Option_t* option) const
            std::cout << "dead" << std::endl;
            continue;
          }
-         UInt_t ddl, addr;
-         Detector2Hardware(det, ring, sec, str, ddl, addr);
+         UShort_t ddl, addr, time, sam=0;
+         Detector2Hardware(det, ring, sec, str, sam, ddl, addr, time);
          std::cout << std::setw(7) << GetPedestal(det, ring, sec, str) 
                    << "+/-" << std::setw(7) 
                    << GetPedestalWidth(det, ring, sec, str) 
@@ -733,33 +733,24 @@ AliFMDParameters::GetAltroMap() const
 
 //____________________________________________________________________
 Bool_t 
-AliFMDParameters::Hardware2Detector(UInt_t    ddl,       UInt_t   addr,
+AliFMDParameters::Hardware2Detector(UShort_t  ddl,       UShort_t addr,
                                    UShort_t  timebin,   
-                                   UShort_t& det,       Char_t&   ring, 
+                                   UShort_t& det,       Char_t&  ring, 
                                    UShort_t& sec,       Short_t& str,
                                    UShort_t& sam) const
 {
   // Translate a hardware address to detector coordinates. 
   // 
   // See also Hardware2Detector that accepts 4 inputs 
-  if (!Hardware2Detector(ddl, addr, det, ring, sec, str)) return kFALSE;
-  UShort_t preSamples = GetPreSamples(det, ring, sec, str);
-  UShort_t sampleRate = GetSampleRate(det, ring, sec, str);
-  if (!fAltroMap->Hardware2Detector(ddl, addr, timebin, 
-                                   preSamples, sampleRate,
-                                   det, ring, sec, str, sam)) return kFALSE;
-  AliFMDDebug(50, ("%d/0x%02x/0x%x/0x%x/%04d -> FMD%d%c[%02d,%03d]-%d"
-                 " (pre=%2d, rate=%d)", 
-                 ddl, ((addr >> 7) & 0x1F), ((addr >> 4) & 0x7), addr & 0xF,
-                 timebin, det, ring, sec, str, sam, preSamples, sampleRate));
-  // str += GetMinStrip(det,ring,sec,str);
-  return kTRUE;
-  
+  if (!fAltroMap) return kFALSE;
+  UShort_t board, chip, chan;
+  fAltroMap->ChannelAddress(addr, board, chip, chan);
+  return Hardware2Detector(ddl,board,chip,chan,timebin,det,ring,sec,str,sam);
 }
 //____________________________________________________________________
 Bool_t 
-AliFMDParameters::Hardware2Detector(UInt_t    ddl,       UInt_t   board,
-                                   UInt_t    chip,      UInt_t   chan,
+AliFMDParameters::Hardware2Detector(UShort_t    ddl,       UShort_t   board,
+                                   UShort_t    chip,      UShort_t   chan,
                                    UShort_t  timebin,   
                                    UShort_t& det,       Char_t&   ring, 
                                    UShort_t& sec,       Short_t& str,
@@ -768,20 +759,28 @@ AliFMDParameters::Hardware2Detector(UInt_t    ddl,       UInt_t   board,
   // Translate a hardware address to detector coordinates. 
   // 
   // See also Hardware2Detector that accepts 4 inputs 
-  if (!Hardware2Detector(ddl,board,chip,chan,det,ring,sec,str)) return kFALSE;
-  UShort_t preSamples = GetPreSamples(det, ring, sec, str);
-  UShort_t sampleRate = GetSampleRate(det, ring, sec, str);
-  if (!fAltroMap->Hardware2Detector(ddl, board, chip, chan, timebin,
-                                   preSamples, sampleRate,
-                                   det, ring, sec, str, sam)) return kFALSE;
-  // str += GetMinStrip(det,ring,sec,str);
+  if (!fAltroMap) return kFALSE;
+  if (fAltroMap->DDL2Detector(ddl) < 0) return kFALSE;
+  Short_t stripBase = 0;
+  if (!fAltroMap->Channel2StripBase(board,chip,chan, ring, sec, stripBase)) 
+    return kFALSE;
+  UShort_t preSamples = GetPreSamples(det, ring, sec, stripBase);
+  UShort_t sampleRate = GetSampleRate(det, ring, sec, stripBase);
+  Short_t stripOff = 0;
+  fAltroMap->Timebin2Strip(sec, timebin, preSamples, sampleRate, stripOff, sam);
+  str = stripBase + stripOff;
+  AliFMDDebug(50, ("%d/0x%02x/0x%x/0x%x/%04d -> FMD%d%c[%02d,%03d]-%d"
+                 " (pre=%2d, rate=%d)", 
+                  ddl, board, chip, chan, timebin, 
+                  det, ring, sec, str, sam, preSamples, sampleRate));
   return kTRUE;
 }
 
+#if 0
 //__________________________________________________________________
 Bool_t
-AliFMDParameters::Hardware2Detector(UInt_t    ddl,  UInt_t    board, 
-                                   UInt_t    chip, UInt_t    chan,
+AliFMDParameters::Hardware2Detector(UShort_t    ddl,  UShort_t    board, 
+                                   UShort_t    chip, UShort_t    chan,
                                    UShort_t& det,  Char_t&   ring, 
                                    UShort_t& sec,  Short_t& str) const
 {
@@ -791,7 +790,7 @@ AliFMDParameters::Hardware2Detector(UInt_t    ddl,  UInt_t    board,
 }
 //__________________________________________________________________
 Bool_t
-AliFMDParameters::Hardware2Detector(UInt_t    ddl,  UInt_t    addr, 
+AliFMDParameters::Hardware2Detector(UShort_t    ddl,  UShort_t    addr, 
                                    UShort_t& det,  Char_t&   ring, 
                                    UShort_t& sec,  Short_t& str) const
 {
@@ -799,14 +798,15 @@ AliFMDParameters::Hardware2Detector(UInt_t    ddl,  UInt_t    addr,
   if (!fAltroMap) return kFALSE;
   return fAltroMap->Hardware2Detector(ddl, addr, det, ring, sec, str);
 }
+#endif
 
 //____________________________________________________________________
 Bool_t 
 AliFMDParameters::Detector2Hardware(UShort_t  det,        Char_t    ring, 
                                    UShort_t  sec,        UShort_t  str,
                                    UShort_t  sam, 
-                                   UInt_t&   ddl,        UInt_t&   board, 
-                                   UInt_t&   altro,      UInt_t&   channel, 
+                                   UShort_t& ddl,        UShort_t& board, 
+                                   UShort_t& altro,      UShort_t& channel, 
                                    UShort_t& timebin) const
 {
   if (!fAltroMap) return kFALSE;
@@ -820,24 +820,12 @@ AliFMDParameters::Detector2Hardware(UShort_t  det,        Char_t    ring,
 
   
 
-//__________________________________________________________________
-Bool_t
-AliFMDParameters::Detector2Hardware(UShort_t det,  Char_t   ring, 
-                                   UShort_t sec,  UShort_t str, 
-                                   UInt_t&  ddl,  UInt_t&  board, 
-                                   UInt_t&  chip, UInt_t&  chan) const
-{
-  // Map detector index to hardware address
-  if (!fAltroMap) return kFALSE;
-  return fAltroMap->Detector2Hardware(det,ring,sec,str, ddl,board,chip,chan);
-}
-
 //____________________________________________________________________
 Bool_t 
 AliFMDParameters::Detector2Hardware(UShort_t  det,        Char_t    ring, 
                                    UShort_t  sec,        UShort_t  str,
                                    UShort_t  sam, 
-                                   UInt_t&   ddl,        UInt_t&   addr,
+                                   UShort_t&   ddl,        UShort_t&   addr,
                                    UShort_t& timebin) const
 {
   if (!fAltroMap) return kFALSE;
@@ -849,17 +837,30 @@ AliFMDParameters::Detector2Hardware(UShort_t  det,        Char_t    ring,
                                      ddl, addr, timebin);
 }
 
+#if 0
+//__________________________________________________________________
+Bool_t
+AliFMDParameters::Detector2Hardware(UShort_t det,  Char_t   ring, 
+                                   UShort_t sec,  UShort_t str, 
+                                   UShort_t&  ddl,  UShort_t&  board, 
+                                   UShort_t&  chip, UShort_t&  chan) const
+{
+  // Map detector index to hardware address
+  if (!fAltroMap) return kFALSE;
+  return fAltroMap->Detector2Hardware(det,ring,sec,str, ddl,board,chip,chan);
+}
+
 //__________________________________________________________________
 Bool_t
 AliFMDParameters::Detector2Hardware(UShort_t det, Char_t   ring, 
                                    UShort_t sec, UShort_t str, 
-                                   UInt_t&  ddl, UInt_t&  addr) const
+                                   UShort_t&  ddl, UShort_t&  addr) const
 {
   // Map detector index to hardware address
   if (!fAltroMap) return kFALSE;
   return fAltroMap->Detector2Hardware(det, ring, sec, str, ddl, addr);
 }
-
+#endif
 
 //__________________________________________________________________
 Float_t
index 3e2ac16272ea67c69e37477039235052b142ea4f..0cf5a5c0ff9c15a847c20fd65ed19c48c00136fd 100644 (file)
@@ -314,26 +314,12 @@ public:
       @param str        On return, the base of strip #
       @param sam        On return, the sample number for this strip
       @return @c true on success, false otherwise */
-  Bool_t Hardware2Detector(UInt_t    ddl,        UInt_t    board, 
-                          UInt_t    altro,      UInt_t    chan,
+  Bool_t Hardware2Detector(UShort_t    ddl,        UShort_t    board, 
+                          UShort_t    altro,      UShort_t    chan,
                           UShort_t  timebin,   
                           UShort_t& det,        Char_t&   ring, 
                           UShort_t& sec,        Short_t& str,
                           UShort_t& sam) const;
-  /** Translate hardware address to detector coordinates 
-      @param ddl      DDL number 
-      @param board    Board address
-      @param chip     Chip #
-      @param channel  Channel #
-      @param det      On return, Detector # (1-3)
-      @param ring     On return, Ring ID ('I' or 'O')
-      @param sec      On return, Sector number (0-39)
-      @param str      On return, Strip number (0-511)
-      @return @c true on success. */
-  Bool_t   Hardware2Detector(UInt_t ddl,    UInt_t    board, 
-                            UInt_t chip,   UInt_t    channel, 
-                            UShort_t& det, Char_t&   ring, 
-                            UShort_t& sec, Short_t& str) const;
   /** Map a hardware address into a detector index. 
       @param ddl        Hardware DDL number 
       @param hwaddr     Hardware address.  
@@ -344,11 +330,26 @@ public:
       @param str        On return, the base of strip #
       @param sam        On return, the sample number for this strip
       @return @c true on success, false otherwise */
-  Bool_t Hardware2Detector(UInt_t    ddl,        UInt_t    hwaddr, 
+  Bool_t Hardware2Detector(UShort_t    ddl,        UShort_t    hwaddr, 
                           UShort_t  timebin,    
                           UShort_t& det,        Char_t&   ring, 
                           UShort_t& sec,        Short_t& str,
                           UShort_t& sam) const;
+#if 0
+  /** Translate hardware address to detector coordinates 
+      @param ddl      DDL number 
+      @param board    Board address
+      @param chip     Chip #
+      @param channel  Channel #
+      @param det      On return, Detector # (1-3)
+      @param ring     On return, Ring ID ('I' or 'O')
+      @param sec      On return, Sector number (0-39)
+      @param str      On return, Strip number (0-511)
+      @return @c true on success. */
+  Bool_t   Hardware2Detector(UShort_t ddl,    UShort_t    board, 
+                            UShort_t chip,   UShort_t    channel, 
+                            UShort_t& det, Char_t&   ring, 
+                            UShort_t& sec, Short_t& str) const;
   /** Translate hardware address to detector coordinates 
       @param ddl      DDL number 
       @param addr     Hardware address
@@ -357,8 +358,9 @@ public:
       @param sec      On return, Sector number (0-39)
       @param str      On return, Strip number (0-511)
       @return @c true on success. */
-  Bool_t   Hardware2Detector(UInt_t ddl, UInt_t addr, UShort_t& det,
+  Bool_t   Hardware2Detector(UShort_t ddl, UShort_t addr, UShort_t& det,
                             Char_t& ring, UShort_t& sec, Short_t& str) const;
+#endif
 
   /** Map a detector index into a hardware address. 
       @param det         The detector #
@@ -375,23 +377,9 @@ public:
   Bool_t Detector2Hardware(UShort_t  det,        Char_t    ring, 
                           UShort_t  sec,        UShort_t  str,
                           UShort_t  sam, 
-                          UInt_t&   ddl,        UInt_t&   board, 
-                          UInt_t&   altro,      UInt_t&   channel, 
+                          UShort_t&   ddl,        UShort_t&   board, 
+                          UShort_t&   altro,      UShort_t&   channel, 
                           UShort_t& timebin) const;
-  /** Translate detector coordinates to hardware address 
-      @param det      Detector # (1-3)
-      @param ring     Ring ID ('I' or 'O')
-      @param sec      Sector number (0-39)
-      @param str      Strip number (0-511)
-      @param ddl      On return, DDL number 
-      @param board    On return, Board address
-      @param chip     On return, Chip #
-      @param channel  On return, Channel #
-      @return @c true on success. */
-  Bool_t   Detector2Hardware(UShort_t det, Char_t ring, 
-                            UShort_t sec, UShort_t str, 
-                            UInt_t& ddl,  UInt_t& board,
-                            UInt_t& chip, UInt_t& channel) const;
   /** Map a detector index into a hardware address. 
       @param det         The detector #
       @param ring        The ring ID
@@ -405,8 +393,23 @@ public:
   Bool_t Detector2Hardware(UShort_t  det,        Char_t    ring, 
                           UShort_t  sec,        UShort_t  str,
                           UShort_t  sam, 
-                          UInt_t&   ddl,        UInt_t&   hwaddr, 
+                          UShort_t&   ddl,        UShort_t&   hwaddr, 
                           UShort_t& timebin) const;
+#if 0
+  /** Translate detector coordinates to hardware address 
+      @param det      Detector # (1-3)
+      @param ring     Ring ID ('I' or 'O')
+      @param sec      Sector number (0-39)
+      @param str      Strip number (0-511)
+      @param ddl      On return, DDL number 
+      @param board    On return, Board address
+      @param chip     On return, Chip #
+      @param channel  On return, Channel #
+      @return @c true on success. */
+  Bool_t   Detector2Hardware(UShort_t det, Char_t ring, 
+                            UShort_t sec, UShort_t str, 
+                            UShort_t& ddl,  UShort_t& board,
+                            UShort_t& chip, UShort_t& channel) const;
   /** Translate detector coordinates to hardware address 
       @param det      Detector # (1-3)
       @param ring     Ring ID ('I' or 'O')
@@ -416,7 +419,8 @@ public:
       @param addr     On return, Hardware address
       @return @c true on success. */
   Bool_t   Detector2Hardware(UShort_t det, Char_t ring, UShort_t sec, 
-                            UShort_t str, UInt_t& ddl, UInt_t& addr) const;
+                            UShort_t str, UShort_t& ddl, UShort_t& addr) const;
+#endif
   /** Get the map that translates hardware to detector coordinates 
       @return Get the map that translates hardware to detector
       coordinates */ 
index dba6af4bf85e8e5cc2c1d593c1ba166f8fb28370..86f937377ca56e805bda31b815c2e1acdac1d0d9 100644 (file)
@@ -30,6 +30,7 @@
 #include "AliFMDParameters.h"
 #include "AliFMDRawReader.h"
 #include "AliRawReader.h"
+#include "AliFMDAltroMapping.h"
 
 //_____________________________________________________________________
 // This is the class that collects the QA data for the FMD during
@@ -241,14 +242,13 @@ void AliFMDQADataMakerRec::MakeRaws(AliRawReader* rawReader)
   fmdReader.ReadAdcs(digitsAddress);
   for(Int_t i=0;i<digitsAddress->GetEntriesFast();i++) {
     //Raw ADC counts
-    AliFMDDigit* digit = static_cast<AliFMDDigit*>(digitsAddress->At(i));
-    UShort_t det = digit->Detector();
-    Char_t ring  = digit->Ring();
-    UShort_t sec = digit->Sector();
-    UShort_t strip = digit->Strip();
-    UInt_t ddl, board, chip, channel;
-    AliFMDParameters* pars = AliFMDParameters::Instance();
-    pars->Detector2Hardware(det,ring,sec,strip,ddl,board,chip,channel);
+    AliFMDDigit*      digit = static_cast<AliFMDDigit*>(digitsAddress->At(i));
+    UShort_t          det   = digit->Detector();
+    Char_t            ring  = digit->Ring();
+    UShort_t          sec   = digit->Sector();
+    // UShort_t strip = digit->Strip();
+    AliFMDParameters* pars  = AliFMDParameters::Instance();
+    Short_t           board = pars->GetAltroMap()->Sector2Board(ring, sec);
     
     Int_t index1 = GetHalfringIndex(det, ring, 0, 1);
     GetRawsData(index1)->Fill(digit->Counts());
index 5290eeb32f6e1a9fb9343107458248bbd63231a7..898fe4377713c13e3f9c6cafdac420ef0859b042 100644 (file)
@@ -56,6 +56,7 @@
 #include "AliFMDDebug.h"
 #include "AliFMDCalibSampleRate.h"
 #include "AliFMDCalibStripRange.h"
+#include "AliFMDAltroMapping.h"
 // #include "AliFMDAltroIO.h"  // ALIFMDALTROIO_H 
 #include <TArrayS.h>           // ROOT_TArrayS
 #include <TTree.h>             // ROOT_TTree
@@ -123,8 +124,9 @@ AliFMDRawReader::ReadAdcs(TClonesArray* array)
   //    return kFALSE;
   //  }
   // Get sample rate 
-  AliFMDParameters* pars = AliFMDParameters::Instance();
-  AliFMDRawStream input(fReader);
+  AliFMDParameters*     pars = AliFMDParameters::Instance();
+  AliFMDAltroMapping*   map  = pars->GetAltroMap();
+  AliFMDRawStream       input(fReader);
   AliFMDDebug(5, ("Setting 7 word headers"));
   input.SetShortDataHeader(!pars->HasCompleteHeader());
 
@@ -151,11 +153,15 @@ AliFMDRawReader::ReadAdcs(TClonesArray* array)
 
     AliFMDDebug(5, ("Read channel 0x%x of size %d", hwaddr, last));
 
-    UShort_t det, sec, samp;
+    UShort_t det, sec, samp, board, chip, channel;
     Short_t strbase;
     Char_t   ring;
     
-    if (!pars->Hardware2Detector(ddl, hwaddr, det, ring, sec, strbase)) {
+    
+    if (map->DDL2Detector(ddl) < 0) break;
+    det = map->DDL2Detector(ddl);
+    map->ChannelAddress(hwaddr, board, chip, channel);
+    if (!map->Channel2StripBase(board, chip, channel, ring, sec, strbase)) {
       AliError(Form("Failed to get detector id from DDL %d, "
                    "hardware address 0x%03x", ddl, hwaddr));
       continue;
@@ -170,12 +176,9 @@ AliFMDRawReader::ReadAdcs(TClonesArray* array)
     for (size_t i = 0; i < last; i++) {
       // if (i < preSamp) continue;
 
-      Short_t  str = strbase;
-            
-      UShort_t t  =  (i - preSamp);
-      samp        =  (t % rate);
-      t          -= samp;
-      str        += (sec % 2 ? -1 : 1) * t / rate;
+      Short_t  stroff = 0;
+      map->Timebin2Strip(sec, i, preSamp, rate, stroff, samp);
+      Short_t  str    = strbase + stroff;
       
       AliFMDDebug(10, ("0x%04x/0x%03x/%04d maps to FMD%d%c[%2d,%3d]-%d", 
                      ddl, hwaddr, i, det, ring, sec, str, samp));
@@ -423,7 +426,8 @@ Bool_t AliFMDRawReader::ReadSODevent(AliFMDCalibSampleRate* sampleRate,
   UInt_t strip_high[18];
   UInt_t pulse_size[18];
   UInt_t pulse_length[18];  
-  AliFMDParameters* param = AliFMDParameters::Instance();
+  AliFMDParameters*   param = AliFMDParameters::Instance();
+  AliFMDAltroMapping* map   = param->GetAltroMap();
   
   while(fReader->ReadNextData(fData)) {
     
@@ -619,8 +623,8 @@ Bool_t AliFMDRawReader::ReadSODevent(AliFMDCalibSampleRate* sampleRate,
       if(ddl==0 && (i==1 || i==3)) continue;
 
       UInt_t chip =0, channel=0;
-      param->Hardware2Detector(ddl,boards[i],chip,channel,
-                              det,ring,sector,strip);
+      det = map->DDL2Detector(ddl);
+      map->Channel2StripBase(boards[i], chip, channel, ring, sector, strip);
      
       UInt_t samplerate = 1;
       if(sample_clk[boards[i]] == 0) {
index 4b3c448f085d607a29a789869d9a67bc817eb289..3cae675b1e01a04c26a46fbc897abb5d9a3be5f5 100644 (file)
@@ -206,9 +206,7 @@ AliFMDRawWriter::WriteDigits(TClonesArray* digits)
     Char_t   ring   = digit->Ring();
     UShort_t sector = digit->Sector();
     UShort_t strip  = digit->Strip();
-    UInt_t   ddl;
-    UInt_t   addr;  
-    UShort_t time;
+    UShort_t ddl, addr, time;
 
     AliFMDDebug(15, ("Processing digit # %5d FMD%d%c[%2d,%3d]", 
                    i, det, ring, sector, strip));
index 23722e79ec90bfc85fa0f780d0b3c73b7fef5a66..9bfc44b54c15df6dd690de0e10b58131562c2430 100644 (file)
@@ -13,6 +13,7 @@
 # include <FMD/AliFMDAltroMapping.h>
 // # include <FMD/AliFMDUShortMap.h>
 // # include <FMD/AliFMDBoolMap.h>
+# include <AliLog.h>
 # include <TError.h>
 # include <iostream>
 #endif
@@ -124,13 +125,14 @@ CheckTrans(UShort_t det, Char_t ring, UShort_t sec, UShort_t str, UShort_t sam,
 /** @ingroup ALTRO_test
  */
 void
-TestAltroMapping(Int_t min=2, Int_t max=0)
+TestAltroMapping(Int_t min=1, Int_t max=3)
 {
+  // AliLog::SetModuleDebugLevel("FMD", 1);
   // if (min < 1 || min > 3) min = 1;
   if (max < min)          max = min;
   // AliFMDParameters* param = AliFMDParameters::Instance();
   AliFMDAltroMapping m;
-  UShort_t presamp  = 0;
+  UShort_t presamp  = 19;
   UShort_t oversamp = 4;
 
   for (UShort_t det = min; det <= max; det++) {
@@ -141,7 +143,7 @@ TestAltroMapping(Int_t min=2, Int_t max=0)
       for (UShort_t sec = 0; sec < nsec; sec++) {
        for (Short_t str = 0; str < nstr; str ++ /*= 128*/) {
          for(UShort_t sam = 0; sam < oversamp; sam++) {
-           UInt_t ddl, hwaddr;
+           UShort_t ddl, hwaddr;
            UShort_t timebin;
            if (!m.Detector2Hardware(det, ring, sec, str, sam, 
                                     presamp, oversamp,