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