]>
Commit | Line | Data |
---|---|---|
2bb7b766 | 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 | // | |
17 | // This class is a container for the data queried from DAQ's logbook and logbook_shuttle tables. | |
18 | // It holds the run number, the start time and end time of the run, | |
19 | // and the array of the detectors' status (Unprocessed, Inactive, Failed, Done) | |
20 | ||
21 | #include "AliShuttleLogbookEntry.h" | |
22 | #include "AliLog.h" | |
23 | #include "TTimeStamp.h" | |
eba76848 | 24 | #include <TString.h> |
25 | #include <TObjString.h> | |
26 | #include <TMap.h> | |
2bb7b766 | 27 | |
28 | ClassImp(AliShuttleLogbookEntry) | |
29 | ||
30 | //______________________________________________________________________________________________ | |
31 | AliShuttleLogbookEntry::AliShuttleLogbookEntry() : | |
32 | TObject(), | |
33 | fRun(-1), | |
eba76848 | 34 | fRunParameters(0) |
2bb7b766 | 35 | { |
36 | // default constructor | |
37 | ||
eba76848 | 38 | const UInt_t nDet = AliShuttleInterface::NDetectors(); |
2bb7b766 | 39 | memset(fDetectorStatus, kUnprocessed, nDet*sizeof(Status)); |
eba76848 | 40 | fRunParameters.SetOwner(1); |
2bb7b766 | 41 | } |
42 | ||
43 | //______________________________________________________________________________________________ | |
eba76848 | 44 | AliShuttleLogbookEntry::AliShuttleLogbookEntry(Int_t run, Status* status) : |
2bb7b766 | 45 | TObject(), |
46 | fRun(run), | |
eba76848 | 47 | fRunParameters(0) |
2bb7b766 | 48 | { |
eba76848 | 49 | // default constructor |
2bb7b766 | 50 | |
eba76848 | 51 | const UInt_t nDet = AliShuttleInterface::NDetectors(); |
2bb7b766 | 52 | memset(fDetectorStatus, kUnprocessed, nDet*sizeof(Status)); |
53 | if(status) SetDetectorStatus(status); | |
eba76848 | 54 | fRunParameters.SetOwner(1); |
2bb7b766 | 55 | } |
56 | ||
57 | //______________________________________________________________________________________________ | |
58 | AliShuttleLogbookEntry::~AliShuttleLogbookEntry() { | |
59 | // destructor | |
60 | ||
2bb7b766 | 61 | } |
62 | ||
63 | //______________________________________________________________________________________________ | |
64 | AliShuttleLogbookEntry::AliShuttleLogbookEntry(const AliShuttleLogbookEntry &c) : | |
65 | TObject(), | |
66 | fRun(c.fRun), | |
eba76848 | 67 | fRunParameters(0) |
2bb7b766 | 68 | { |
69 | // copy constructor | |
70 | ||
eba76848 | 71 | SetDetectorStatus(c.GetDetectorStatus()); |
72 | fRunParameters.SetOwner(1); | |
73 | TIter iter(c.fRunParameters.GetTable()); | |
74 | TPair* aPair = 0; | |
75 | while((aPair = dynamic_cast<TPair*>(iter.Next()))){ | |
76 | TObjString* aKey= dynamic_cast<TObjString*>(aPair->Key()); | |
77 | TObjString* aValue= dynamic_cast<TObjString*>(aPair->Value()); | |
78 | fRunParameters.Add(aKey->Clone(), aValue->Clone()); | |
79 | } | |
80 | ||
2bb7b766 | 81 | } |
82 | ||
83 | //______________________________________________________________________________________________ | |
84 | AliShuttleLogbookEntry &AliShuttleLogbookEntry::operator=(const AliShuttleLogbookEntry &c) | |
85 | { | |
86 | // assigment operator | |
87 | ||
88 | if (this != &c) | |
89 | ((AliShuttleLogbookEntry &) c).Copy(*this); | |
90 | return *this; | |
91 | } | |
92 | ||
93 | //______________________________________________________________________________________________ | |
94 | void AliShuttleLogbookEntry::Copy(TObject& c) const | |
95 | { | |
96 | // copy function | |
97 | ||
98 | AliShuttleLogbookEntry& target = (AliShuttleLogbookEntry &) c; | |
99 | ||
100 | target.fRun = fRun; | |
eba76848 | 101 | target.fRunParameters.SetOwner(1); |
102 | TIter iter(fRunParameters.GetTable()); | |
103 | TPair* aPair = 0; | |
104 | while((aPair = dynamic_cast<TPair*>(iter.Next()))){ | |
105 | TObjString* aKey= dynamic_cast<TObjString*>(aPair->Key()); | |
106 | TObjString* aValue= dynamic_cast<TObjString*>(aPair->Value()); | |
107 | target.fRunParameters.Add(aKey->Clone(), aValue->Clone()); | |
108 | } | |
2bb7b766 | 109 | |
110 | target.SetDetectorStatus(GetDetectorStatus()); | |
111 | } | |
112 | ||
113 | //______________________________________________________________________________________________ | |
eba76848 | 114 | AliShuttleLogbookEntry::Status AliShuttleLogbookEntry::GetDetectorStatus(const char* detName) const |
2bb7b766 | 115 | { |
116 | // get detector status from detector code | |
117 | ||
eba76848 | 118 | return GetDetectorStatus(AliShuttleInterface::GetDetPos(detName)); |
2bb7b766 | 119 | } |
120 | ||
121 | //______________________________________________________________________________________________ | |
122 | AliShuttleLogbookEntry::Status AliShuttleLogbookEntry::GetDetectorStatus(Int_t detPos) const | |
123 | { | |
124 | // get detector status from detector code | |
125 | ||
eba76848 | 126 | if(detPos < 0 || detPos >= (Int_t) AliShuttleInterface::NDetectors()) { |
2bb7b766 | 127 | AliError(Form("Invalid parameter: %d", detPos)); |
128 | return kUnprocessed; | |
129 | } | |
130 | return fDetectorStatus[detPos]; | |
131 | } | |
132 | ||
133 | //______________________________________________________________________________________________ | |
eba76848 | 134 | void AliShuttleLogbookEntry::SetDetectorStatus(const char* detName, Status status) |
2bb7b766 | 135 | { |
136 | // set detector status from detector code | |
137 | ||
eba76848 | 138 | Int_t detPos = AliShuttleInterface::GetDetPos(detName); |
2bb7b766 | 139 | if(detPos<0) return; |
140 | SetDetectorStatus(detPos, status); | |
141 | } | |
142 | ||
eba76848 | 143 | //______________________________________________________________________________________________ |
144 | void AliShuttleLogbookEntry::SetDetectorStatus(const char* detName, const char* statusName) | |
145 | { | |
146 | // set detector status from detector code | |
147 | ||
148 | Int_t detPos = AliShuttleInterface::GetDetPos(detName); | |
149 | if(detPos<0) return; | |
150 | SetDetectorStatus(detPos, statusName); | |
151 | } | |
152 | ||
2bb7b766 | 153 | //______________________________________________________________________________________________ |
154 | void AliShuttleLogbookEntry::SetDetectorStatus(Status* status) | |
155 | { | |
156 | // set detector status from detector code | |
157 | ||
eba76848 | 158 | for(UInt_t i=0; i < AliShuttleInterface::NDetectors(); i++){ |
2bb7b766 | 159 | fDetectorStatus[i] = status[i]; |
160 | } | |
161 | } | |
162 | ||
163 | //______________________________________________________________________________________________ | |
164 | void AliShuttleLogbookEntry::SetDetectorStatus(UInt_t detPos, Status status) | |
165 | { | |
166 | // set detector status from detector code | |
167 | ||
eba76848 | 168 | if(detPos >= AliShuttleInterface::NDetectors()) { |
169 | AliError(Form("Shuttle has only %d subdetectors!", AliShuttleInterface::NDetectors())); | |
2bb7b766 | 170 | return; |
171 | } | |
172 | fDetectorStatus[detPos] = status; | |
173 | } | |
174 | ||
eba76848 | 175 | //______________________________________________________________________________________________ |
176 | void AliShuttleLogbookEntry::SetDetectorStatus(UInt_t detPos, const char* statusName) | |
177 | { | |
178 | // set detector status from detector code | |
179 | ||
180 | if(detPos >= AliShuttleInterface::NDetectors()) { | |
181 | AliError(Form("Shuttle has only %d subdetectors!", AliShuttleInterface::NDetectors())); | |
182 | return; | |
183 | } | |
184 | TString statusString(statusName); | |
185 | if(statusString.Contains("UNPROCESSED", TString::kIgnoreCase)){ | |
186 | SetDetectorStatus(detPos, kUnprocessed); | |
187 | } else if (statusString.Contains("INACTIVE", TString::kIgnoreCase)) { | |
188 | SetDetectorStatus(detPos, kInactive); | |
189 | } else if (statusString.Contains("FAILED", TString::kIgnoreCase)) { | |
190 | SetDetectorStatus(detPos, kFailed); | |
191 | } else if (statusString.Contains("DONE", TString::kIgnoreCase)) { | |
192 | SetDetectorStatus(detPos, kDone); | |
193 | } else { | |
194 | AliError(Form("Invalid status name: %s", statusName)); | |
195 | } | |
196 | } | |
197 | ||
2bb7b766 | 198 | //______________________________________________________________________________________________ |
199 | Bool_t AliShuttleLogbookEntry::IsDone() const{ | |
200 | // return TRUE if all subdetectors are in status DONE, FAILED or INACTIVE | |
201 | ||
eba76848 | 202 | for(UInt_t i=0; i < AliShuttleInterface::NDetectors(); i++){ |
2bb7b766 | 203 | if(fDetectorStatus[i] == kUnprocessed) return kFALSE; |
204 | } | |
205 | return kTRUE; | |
206 | } | |
207 | ||
208 | //______________________________________________________________________________________________ | |
209 | const char* AliShuttleLogbookEntry::GetDetectorStatusName(Status status) | |
210 | { | |
211 | // returns a name (string) of the detector status | |
212 | ||
eba76848 | 213 | switch (status){ |
214 | case kUnprocessed: return "UNPROCESSED"; | |
215 | case kInactive: return "INACTIVE"; | |
216 | case kFailed: return "FAILED"; | |
217 | case kDone: return "DONE"; | |
218 | } | |
219 | return 0; | |
220 | ||
2bb7b766 | 221 | } |
222 | ||
223 | //______________________________________________________________________________________________ | |
eba76848 | 224 | void AliShuttleLogbookEntry::Print(Option_t* option) const |
2bb7b766 | 225 | { |
226 | // print current shuttle logbook entry | |
227 | ||
228 | TString message = "\n*** Run parameters ***\n"; | |
eba76848 | 229 | TTimeStamp startTimeStamp(GetStartTime()); |
230 | TTimeStamp endTimeStamp(GetEndTime()); | |
2bb7b766 | 231 | message += Form("\tRun \t\t%d\n", fRun); |
232 | message += Form("\tStarted \t%s\n", startTimeStamp.AsString("s")); | |
233 | message += Form("\tFinished \t%s\n", endTimeStamp.AsString("s")); | |
234 | message += "\n*** Detector status ***\n"; | |
235 | ||
eba76848 | 236 | for(UInt_t i=0; i < AliShuttleInterface::NDetectors(); i++) |
237 | message += Form("\t%2d - %s: %s\n", i, AliShuttleInterface::GetDetName(i), | |
2bb7b766 | 238 | GetDetectorStatusName(fDetectorStatus[i])); |
239 | ||
eba76848 | 240 | AliInfo(Form("option: %s",option)); |
241 | TString optionStr(option); | |
242 | if(optionStr=="all"){ | |
243 | message += "\nPrinting full list of run parameters\n"; | |
244 | message += "\tParameter Value\n"; | |
245 | TIter iter(fRunParameters.GetTable()); | |
246 | TPair* aPair = 0; | |
247 | while((aPair = dynamic_cast<TPair*>(iter.Next()))){ | |
248 | TObjString* aKey= dynamic_cast<TObjString*>(aPair->Key()); | |
249 | TObjString* aValue= dynamic_cast<TObjString*>(aPair->Value()); | |
250 | TString keyStr=aKey->GetName(); | |
251 | if(keyStr != "log"){ | |
252 | message += Form("\t%s ", aKey->GetName()); | |
253 | if(keyStr.Length()<30) message.Append(' ', 30-keyStr.Length()); | |
254 | message += Form("%s\n", aValue->GetName()); | |
255 | } else { | |
256 | message += "\tlog ...\n"; | |
2bb7b766 | 257 | } |
258 | } | |
2bb7b766 | 259 | } |
260 | ||
eba76848 | 261 | AliInfo(Form("%s",message.Data())); |
2bb7b766 | 262 | } |
2bb7b766 | 263 | //______________________________________________________________________________________________ |
eba76848 | 264 | void AliShuttleLogbookEntry::SetRunParameter(const char* key, const char* value){ |
265 | // set a run parameter (read from the DAQ logbook) | |
2bb7b766 | 266 | |
eba76848 | 267 | TObjString* keyObj = new TObjString(key); |
268 | if (fRunParameters.Contains(key)) { | |
269 | AliWarning(Form("Parameter %s already existing and it will be replaced.", key)); | |
270 | delete fRunParameters.Remove(keyObj); | |
2bb7b766 | 271 | |
2bb7b766 | 272 | } |
eba76848 | 273 | fRunParameters.Add(keyObj, new TObjString(value)); |
274 | AliDebug(2, Form("Number of parameters: %d", fRunParameters.GetEntries())); | |
2bb7b766 | 275 | } |
2bb7b766 | 276 | //______________________________________________________________________________________________ |
eba76848 | 277 | const char* AliShuttleLogbookEntry::GetRunParameter(const char* key) const{ |
278 | // get a run parameter | |
2bb7b766 | 279 | |
eba76848 | 280 | TObjString* value = dynamic_cast<TObjString*> (fRunParameters.GetValue(key)); |
281 | if(!value) { | |
282 | AliError(Form("No such parameter: %s", key)); | |
283 | return 0; | |
2bb7b766 | 284 | } |
eba76848 | 285 | return value->GetName(); |
2bb7b766 | 286 | } |