1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 //____________________________________________________________________
20 // Base class for caches of per-strip information.
21 // This is used to index a strip.
22 // Data stored depends on derived class.
23 // This class provides some common infra-structure.
24 // Derived classes sould define Reset, and operator().
26 #include "AliFMDMap.h" // ALIFMDMAP_H
29 //#include <TBuffer.h>
32 #include <TStreamerInfo.h>
34 //____________________________________________________________________
37 ; // This is here to keep Emacs for indenting the next line
40 //____________________________________________________________________
41 AliFMDMap::AliFMDMap(UShort_t maxDet,
45 : fMaxDetectors(maxDet),
53 // maxDet Maximum # of detectors
54 // maxRinf Maximum # of rings
55 // maxSec Maximum # of sectors
56 // maxStr Maximum # of strips
57 SetBit(kNeedUShort, kFALSE);
60 //____________________________________________________________________
62 AliFMDMap::CheckNeedUShort(TFile* file)
65 TObject* o = file->GetStreamerInfoList()->FindObject("AliFMDMap");
67 TStreamerInfo* info = static_cast<TStreamerInfo*>(o);
68 if (info->GetClassVersion() == 2) SetBit(kNeedUShort);
70 //____________________________________________________________________
72 AliFMDMap::CheckIndex(UShort_t det, Char_t ring, UShort_t sec, UShort_t str) const
74 // Check that the index supplied is OK. Returns true index, or -1
76 if (det < 1) return -1;
77 UShort_t ringi = (ring == 'I' || ring == 'i' ? 0 : 1);
79 (str + fMaxStrips * (sec + fMaxSectors * (ringi + fMaxRings * (det-1))));
80 if (TestBit(kNeedUShort)) idx = UShort_t(idx);
81 if (idx < 0 || idx >= fMaxDetectors * fMaxRings * fMaxSectors * fMaxStrips)
87 //____________________________________________________________________
89 AliFMDMap::CalcIndex(UShort_t det, Char_t ring, UShort_t sec, UShort_t str) const
91 // Calculate index into storage from arguments.
99 // Returns appropriate index into storage
101 Int_t idx = CheckIndex(det, ring, sec, str);
103 UShort_t ringi = (ring == 'I' || ring == 'i' ? 0 : 1);
104 AliFatal(Form("Index (%d,'%c',%d,%d) out of bounds, "
105 "in particular the %s index ",
107 (det > fMaxDetectors ? "Detector" :
108 (ringi >= fMaxRings ? "Ring" :
109 (sec >= fMaxSectors ? "Sector" : "Strip")))));
116 //___________________________________________________________________
117 void AliFMDMap::Streamer(TBuffer &R__b)
119 // Stream an object of class AliFMDMap.
120 // This is overridden so that we can know the version of the object
121 // that we are reading in. In this way, we can fix problems that
122 // might occur in the class.
123 if (R__b.IsReading()) {
124 // read the class version from the buffer
126 Version_t version = R__b.ReadVersion(&R__s, &R__c, this->Class());
127 TFile *file = (TFile*)R__b.GetParent();
128 if (file && file->GetVersion() < 30000) version = -1;
129 AliFMDMap::Class()->ReadBuffer(R__b, this, version, R__s, R__c);
130 if (version == 2) SetBit(kNeedUShort);
132 AliFMDMap::Class()->WriteBuffer(R__b, this);
137 //___________________________________________________________________