AliPhysics  9b6b435 (9b6b435)
AliOADBForward.h
Go to the documentation of this file.
1 // -*- mode: C++ -*-
2 #ifndef ALIOADBFORWARD_H
3 #define ALIOADBFORWARD_H
4 #include <TNamed.h>
5 #include <TString.h>
6 #include <TMap.h>
7 class TFile;
8 class TTree;
9 class TBrowser;
10 class TList;
11 
15 class AliOADBForward : public TObject
16 {
17 public:
18  //=== Options ======================================================
24  kDefault = 0,
28  kExact = 1,
32  kNewest = 2,
37  kNear = 3,
43  kOlder = 4,
49  kNewer = 5
50  };
58  static const char* Mode2String(ERunSelectMode mode);
66  static ERunSelectMode String2Mode(const TString& str);
79  enum {
85  kMaxNearDistance = 1000000,
87  };
88  //=== Entry ========================================================
93  class Entry : public TObject
94  {
95  public:
107  Entry(ULong_t runNo = 0,
108  UShort_t sys = 0,
109  UShort_t sNN = 0,
110  Short_t field = 0,
111  Bool_t mc = false,
112  Bool_t sat = false,
113  TObject* o = 0);
119  Entry(const Entry& o);
123  virtual ~Entry() {}
131  Entry& operator=(const Entry& o);
137  const char* GetTitle() const;
143  void Print(Option_t* option="") const; //*MENU*
144  ULong_t fRunNo; // Run number
145  UShort_t fSys; // Collision system (1: pp, 2: pbpb, 3: ppb)
146  UShort_t fSNN; // Center of mass energy
147  Short_t fField; // L3 magnetic field
148  Bool_t fMC; // True if only for MC
149  Bool_t fSatellite; // Satelitte events
150  TObject* fData; // Correction object
151  UInt_t fTimestamp; // When the object was stored
152  ULong_t fAliROOTRevision; // Revision of AliROOT used
153  TString fAuthor; // Author of calibration/correction
154 
155  ClassDef(Entry,2); // Entry in PWGLF/Forward OADB
156  };
157 
158  //=== Table ========================================================
164  class Table : public TObject
165  {
166  public:
176  Table(TTree* tree, Bool_t isNew, ERunSelectMode mode=kNear);
182  Table(const Table& other);
188  ~Table();
196  Table& operator=(const Table& other);
202  void SetVerbose(Bool_t verb=true) { fVerbose = verb; }
208  void SetEnableFallBack(Bool_t use=true) { fFallBack = use; }
209  // -----------------------------------------------------------------
215  const Char_t* GetTableName() const;
221  const Char_t* GetName() const;
222 
223  // -----------------------------------------------------------------
233  Bool_t Update();
239  Bool_t Close();
240  /* @} */
241  // -----------------------------------------------------------------
260  Int_t Query(ULong_t runNo = 0,
262  UShort_t sys = 0,
263  UShort_t sNN = 0,
264  Short_t fld = kInvalidField,
265  Bool_t mc = false,
266  Bool_t sat = false) const;
276  Int_t Query(ULong_t runNo,
278  const TString& q) const;
294  Bool_t Insert(TObject* o,
295  ULong_t runNo,
296  UShort_t sys,
297  UShort_t sNN,
298  Short_t field,
299  Bool_t mc=false,
300  Bool_t sat=false,
301  ULong_t aliRev=0,
302  const TString& author="");
331  Int_t GetEntry(ULong_t run = 0,
332  ERunSelectMode mode = kNear,
333  UShort_t sys = 0,
334  UShort_t sNN = 0,
335  Short_t fld = 0,
336  Bool_t mc = false,
337  Bool_t sat = false) const;
366  Entry* Get(ULong_t run = 0,
367  ERunSelectMode mode = kNear,
368  UShort_t sys = 0,
369  UShort_t sNN = 0,
370  Short_t fld = 0,
371  Bool_t mc = false,
372  Bool_t sat = false) const;
395  TObject* GetData(ULong_t run = 0,
396  ERunSelectMode mode = kNear,
397  UShort_t sys = 0,
398  UShort_t sNN = 0,
399  Short_t fld = 0,
400  Bool_t mc = false,
401  Bool_t sat = false) const;
402  /* @} */
408  void Print(Option_t* option="") const; //*MENU*
412  void Browse(TBrowser* b);
420  Bool_t IsOpen(Bool_t rw=false) const;
421 
422  TTree* fTree; // Our tree
423  Entry* fEntry; // Entry cache
424  Bool_t fVerbose; // To be verbose or not
425  ERunSelectMode fMode; // Run query mode
426  Bool_t fFallBack; // Enable fall-back
427 
428  ClassDef(Table,1);
429  };
430  // === Interface ===================================================
434  AliOADBForward();
439  ~AliOADBForward();
440  // --- Open/close/update -------------------------------------------
460  Bool_t Open(const TString& fileName,
461  const TString& tables = "*",
462  Bool_t rw = false,
463  Bool_t verb = false,
464  Bool_t fallback= false);
480  Bool_t Open(TFile* file,
481  const TString& tables,
482  Bool_t rw = false,
483  Bool_t verb = false,
484  Bool_t fallback= false);
491  Bool_t Close();
497  Bool_t Update();
498  /* @} */
499  // --- Queries -----------------------------------------------------
527  Entry* Get(const TString& table,
528  ULong_t run = 0,
530  UShort_t sys = 0,
531  UShort_t sNN = 0,
532  Short_t fld = 0,
533  Bool_t mc = false,
534  Bool_t sat = false) const;
558  TObject* GetData(const TString& table,
559  ULong_t run = 0,
561  UShort_t sys = 0,
562  UShort_t sNN = 0,
563  Short_t fld = 0,
564  Bool_t mc = false,
565  Bool_t sat = false) const;
566  // --- Insert ------------------------------------------------------
583  Bool_t Insert(const TString& table,
584  TObject* o,
585  ULong_t runNo,
586  UShort_t sys,
587  UShort_t sNN,
588  Short_t field,
589  Bool_t mc=false,
590  Bool_t sat=false,
591  ULong_t aliRev=0,
592  const TString& author="");
610  Bool_t CopyEntry(const TString& table,
611  ULong_t oldRunNo,
612  UShort_t oldSys,
613  UShort_t oldSNN,
614  Short_t oldField,
615  ULong_t newRunNo,
616  UShort_t newSys,
617  UShort_t newSNN,
618  Short_t newField,
619  Bool_t mc,
620  Bool_t sat);
621  /* @} */
627  void Print(const Option_t* option="") const; //*MENU*
633  void Browse(TBrowser* b);
641  Table* FindTable(const TString& name, Bool_t quite=false) const;
648  const TMap& GetTables() const { return fTables; }
649 protected:
657  Int_t GetFiles(TList& files) const;
669  Table* GetTableFromFile(TFile* file, Bool_t rw,
670  const TString& name,
671  const TString& mode) const;
672 
686  void OpenTable(TFile* file, Bool_t rw, const TString& name,
687  const TString& mode, Bool_t verb, Bool_t fallback);
695  static void AppendToQuery(TString& q, const TString& s, Bool_t andNotOr=true);
707  static TString Conditions(UShort_t sys = 0,
708  UShort_t sNN = 0,
709  Short_t fld = kInvalidField,
710  Bool_t mc = false,
711  Bool_t sat = false);
712  TMap fTables;
713  ClassDef(AliOADBForward,0); // PWGLF/Forward OADB interface
714 
715 public:
716  // =================================================================
721  static void TestGet(AliOADBForward& t,
722  const TString& table,
723  ULong_t runNo = 0,
724  ERunSelectMode mode = kNear,
725  UShort_t sys = 2,
726  UShort_t sNN = 2760,
727  Short_t fld = -5,
728  Bool_t mc = false,
729  Bool_t sat = false);
730  static void TestInsert(AliOADBForward& t,
731  const TString& table,
732  ULong_t runNo = 0,
733  UShort_t sys = 2,
734  UShort_t sNN = 2760,
735  Short_t fld = -5,
736  Bool_t mc = false,
737  Bool_t sat = false);
738  static void Test();
739  /* @} */
740 };
741 
742 #endif
743 /* Local Variables:
744  * mode: C++
745  * End:
746  */
ULong_t fAliROOTRevision
UShort_t fSys
void Print(Option_t *option="") const
UShort_t fSNN
TString fileName
void OpenTable(TFile *file, Bool_t rw, const TString &name, const TString &mode, Bool_t verb, Bool_t fallback)
static void AppendToQuery(TString &q, const TString &s, Bool_t andNotOr=true)
char Char_t
Definition: External.C:18
static const char * Mode2String(ERunSelectMode mode)
static TString Conditions(UShort_t sys=0, UShort_t sNN=0, Short_t fld=kInvalidField, Bool_t mc=false, Bool_t sat=false)
Entry(ULong_t runNo=0, UShort_t sys=0, UShort_t sNN=0, Short_t field=0, Bool_t mc=false, Bool_t sat=false, TObject *o=0)
static void Test()
Table * FindTable(const TString &name, Bool_t quite=false) const
static void TestInsert(AliOADBForward &t, const TString &table, ULong_t runNo=0, UShort_t sys=2, UShort_t sNN=2760, Short_t fld=-5, Bool_t mc=false, Bool_t sat=false)
TString fAuthor
static ERunSelectMode String2Mode(const TString &str)
ULong_t fRunNo
Bool_t CopyEntry(const TString &table, ULong_t oldRunNo, UShort_t oldSys, UShort_t oldSNN, Short_t oldField, ULong_t newRunNo, UShort_t newSys, UShort_t newSNN, Short_t newField, Bool_t mc, Bool_t sat)
int Int_t
Definition: External.C:63
Bool_t fMC
unsigned int UInt_t
Definition: External.C:33
const TMap & GetTables() const
void SetVerbose(Bool_t verb=true)
void SetEnableFallBack(Bool_t use=true)
Int_t GetFiles(TList &files) const
unsigned long ULong_t
Definition: External.C:38
Int_t mode
Definition: anaM.C:41
const char * GetTitle() const
Bool_t fSatellite
virtual ~Entry()
short Short_t
Definition: External.C:23
static void TestGet(AliOADBForward &t, const TString &table, ULong_t runNo=0, ERunSelectMode mode=kNear, UShort_t sys=2, UShort_t sNN=2760, Short_t fld=-5, Bool_t mc=false, Bool_t sat=false)
void Browse(TBrowser *b)
Entry & operator=(const Entry &o)
TFile * file
TList with histograms for a given trigger.
Bool_t Insert(const TString &table, TObject *o, ULong_t runNo, UShort_t sys, UShort_t sNN, Short_t field, Bool_t mc=false, Bool_t sat=false, ULong_t aliRev=0, const TString &author="")
Entry * Get(const TString &table, ULong_t run=0, ERunSelectMode mode=kNear, UShort_t sys=0, UShort_t sNN=0, Short_t fld=0, Bool_t mc=false, Bool_t sat=false) const
TObject * GetData(const TString &table, ULong_t run=0, ERunSelectMode mode=kNear, UShort_t sys=0, UShort_t sNN=0, Short_t fld=0, Bool_t mc=false, Bool_t sat=false) const
unsigned short UShort_t
Definition: External.C:28
static ERunSelectMode Int2Mode(Int_t mode)
const char Option_t
Definition: External.C:48
UInt_t fTimestamp
ERunSelectMode fMode
bool Bool_t
Definition: External.C:53
Short_t fField
Bool_t Open(const TString &fileName, const TString &tables="*", Bool_t rw=false, Bool_t verb=false, Bool_t fallback=false)
Table * GetTableFromFile(TFile *file, Bool_t rw, const TString &name, const TString &mode) const
TObject * fData