]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliMetaData.cxx
Added customised streamer to AliMUONSt12QuadrantSegmentation (to get correct behavio...
[u/mrichter/AliRoot.git] / STEER / AliMetaData.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16 /* $Id$ */
17
18 ///////////////////////////////////////////////////////////////////////////////
19 //                                                                           //
20 // meta data of run dependent objects                                        //
21 //                                                                           //
22 ///////////////////////////////////////////////////////////////////////////////
23
24
25 #include <TRegexp.h>
26
27 #include "AliMetaData.h"
28
29
30 ClassImp(AliMetaData)
31
32
33 //_____________________________________________________________________________
34 AliMetaData::AliMetaData() :
35   TObject(),
36   fName(""),
37   fFirstRun(-1),
38   fLastRun(-1),
39   fVersion(-1)
40 {
41 // default constructor
42 // the default values mean no selection
43
44 }
45
46 //_____________________________________________________________________________
47 AliMetaData::AliMetaData(const char* name, Int_t firstRun, Int_t lastRun, 
48                          Int_t version) :
49   TObject(),
50   fName(name),
51   fFirstRun(firstRun),
52   fLastRun(lastRun),
53   fVersion(version)
54 {
55 // constructor
56
57 }
58
59
60 //_____________________________________________________________________________
61 AliMetaData::AliMetaData(const AliMetaData& entry) :
62   TObject(entry),
63   fName(entry.fName),
64   fFirstRun(entry.fFirstRun),
65   fLastRun(entry.fLastRun),
66   fVersion(entry.fVersion)
67 {
68 // copy constructor
69
70 }
71
72 //_____________________________________________________________________________
73 AliMetaData& AliMetaData::operator = (const AliMetaData& entry)
74 {
75 // assignment operator
76
77   fName = entry.fName;
78   fFirstRun = entry.fFirstRun;
79   fLastRun = entry.fLastRun;
80   fVersion = entry.fVersion;
81   return *this;
82 }
83
84
85
86 //_____________________________________________________________________________
87 const char* AliMetaData::GetName() const
88 {
89 // get the name
90
91   return fName.Data();
92 }
93
94
95 //_____________________________________________________________________________
96 Bool_t AliMetaData::IsValid(Int_t runNumber, AliMetaData* metaData) const
97 {
98 // check the validity of the object
99
100   if ((fFirstRun >= 0) && (runNumber < fFirstRun)) return kFALSE;
101   if ((fLastRun >= 0) && (runNumber > fLastRun)) return kFALSE;
102   if (metaData) {
103     if ((metaData->fVersion >= 0) && (metaData->fVersion != fVersion)) 
104       return kFALSE;
105   }
106   return kTRUE;
107 }
108
109 //_____________________________________________________________________________
110 Int_t AliMetaData::Compare(const TObject* object) const
111 {
112 // check whether this is prefered to object
113
114   if (!object || !object->InheritsFrom(AliMetaData::Class())) return 1;
115   if (fVersion < ((AliMetaData*)object)->GetVersion()) return -1;
116   if (fVersion > ((AliMetaData*)object)->GetVersion()) return 1;
117   return 0;
118 }
119
120 //_____________________________________________________________________________
121 Bool_t AliMetaData::Matches(const char* name, Int_t runNumber) const
122 {
123 // check whether name and run number match with this meta data
124
125   if ((fFirstRun >= 0) && (runNumber < fFirstRun)) return kFALSE;
126   if ((fLastRun >= 0) && (runNumber > fLastRun)) return kFALSE;
127   if (TString(name).Contains(TRegexp(fName))) return kTRUE;
128   return kTRUE;
129 }
130
131
132 //_____________________________________________________________________________
133 Bool_t operator == (const AliMetaData& entry1, const AliMetaData& entry2)
134 {
135 // compare two DB entries
136
137   if (strcmp(entry1.GetName(), entry2.GetName()) != 0) return kFALSE;
138   if (entry1.GetFirstRun() != entry2.GetFirstRun()) return kFALSE;
139   if (entry1.GetLastRun() != entry2.GetLastRun()) return kFALSE;
140   if (entry1.GetVersion() != entry2.GetVersion()) return kFALSE;
141   return kTRUE;
142 }