//
#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)
#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),
// 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.
- size_t ringi = (ring == 'I' || ring == 'i' ? 0 : 1);
- size_t idx =
+ if (det < 1) return -1;
+ 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)
+ 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.
//
//
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,
(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
//___________________________________________________________________
//