]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliFMDMap.cxx
Fix for copy/paste error
[u/mrichter/AliRoot.git] / STEER / AliFMDMap.cxx
index f5b0406993b5ed643ee151869b72a5e851815e19..1b8ce2a0505c4275391bec94221bea98b5af70fe 100755 (executable)
 //
 #include "AliFMDMap.h"         // ALIFMDMAP_H
 #include "AliLog.h"
+//#include <TClass.h>
+//#include <TBuffer.h>
+#include <TFile.h>
+#include <TList.h>
+#include <TStreamerInfo.h>
 
 //____________________________________________________________________
 ClassImp(AliFMDMap)
@@ -33,10 +38,10 @@ ClassImp(AliFMDMap)
 #endif
 
 //____________________________________________________________________
-AliFMDMap::AliFMDMap(size_t maxDet, 
-                    size_t maxRing, 
-                    size_t maxSec, 
-                    size_t maxStr)
+AliFMDMap::AliFMDMap(UShort_t maxDet, 
+                    UShort_t maxRing, 
+                    UShort_t maxSec, 
+                    UShort_t maxStr)
   : fMaxDetectors(maxDet), 
     fMaxRings(maxRing), 
     fMaxSectors(maxSec), 
@@ -49,26 +54,39 @@ AliFMDMap::AliFMDMap(size_t maxDet,
   //     maxRinf      Maximum # of rings
   //     maxSec       Maximum # of sectors
   //     maxStr       Maximum # of strips
+  SetBit(kNeedUShort, kFALSE);
 }
 
+//____________________________________________________________________
+void
+AliFMDMap::CheckNeedUShort(TFile* file) 
+{
+  if (!file) return;
+  TObject* o = file->GetStreamerInfoList()->FindObject("AliFMDMap");
+  if (!o) return;
+  TStreamerInfo* info = static_cast<TStreamerInfo*>(o);
+  if (info->GetClassVersion() == 2) SetBit(kNeedUShort);
+}
 //____________________________________________________________________
 Int_t 
-AliFMDMap::CheckIndex(size_t det, Char_t ring, size_t sec, size_t str) const
+AliFMDMap::CheckIndex(UShort_t det, Char_t ring, UShort_t sec, UShort_t str) const
 {
   // Check that the index supplied is OK.   Returns true index, or -1
   // on error. 
   if (det < 1) return -1;
-  size_t ringi = (ring == 'I' ||  ring == 'i' ? 0 : 1);
-  size_t idx = 
+  UShort_t ringi = (ring == 'I' ||  ring == 'i' ? 0 : 1);
+  Int_t idx = 
     (str + fMaxStrips * (sec + fMaxSectors * (ringi + fMaxRings * (det-1))));
-  if (idx >= fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips) return -1;
+  if (TestBit(kNeedUShort)) idx = UShort_t(idx);
+  if (idx < 0 || idx >= fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips) 
+    return -1;
   return idx;
 }
 
     
 //____________________________________________________________________
-size_t 
-AliFMDMap::CalcIndex(size_t det, Char_t ring, size_t sec, size_t str) const
+Int_t 
+AliFMDMap::CalcIndex(UShort_t det, Char_t ring, UShort_t sec, UShort_t str) const
 {
   // Calculate index into storage from arguments. 
   // 
@@ -82,7 +100,7 @@ AliFMDMap::CalcIndex(size_t det, Char_t ring, size_t sec, size_t str) const
   //
   Int_t idx = CheckIndex(det, ring, sec, str);
   if (idx < 0) {
-    size_t ringi = (ring == 'I' ||  ring == 'i' ? 0 : 1);
+    UShort_t ringi = (ring == 'I' ||  ring == 'i' ? 0 : 1);
     AliFatal(Form("Index (%d,'%c',%d,%d) out of bounds, "
                  "in particular the %s index ", 
                  det, ring, sec, str, 
@@ -91,9 +109,30 @@ AliFMDMap::CalcIndex(size_t det, Char_t ring, size_t sec, size_t str) const
                    (sec >= fMaxSectors ? "Sector" : "Strip")))));
     return 0;
   }
-  return size_t(idx);
+  return idx;
 }
 
+#if 0
+//___________________________________________________________________
+void AliFMDMap::Streamer(TBuffer &R__b)
+{
+  // Stream an object of class AliFMDMap.
+  // This is overridden so that we can know the version of the object
+  // that we are reading in.  In this way, we can fix problems that
+  // might occur in the class. 
+  if (R__b.IsReading()) {
+    // read the class version from the buffer
+    UInt_t R__s, R__c;
+    Version_t version = R__b.ReadVersion(&R__s, &R__c, this->Class());
+    TFile *file = (TFile*)R__b.GetParent();
+    if (file && file->GetVersion() < 30000) version = -1; 
+    AliFMDMap::Class()->ReadBuffer(R__b, this, version, R__s, R__c);
+    if (version == 2) SetBit(kNeedUShort);
+  } else {
+    AliFMDMap::Class()->WriteBuffer(R__b, this);
+  }
+}
+#endif
 
 //___________________________________________________________________
 //