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 **************************************************************************/
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)
21 #include "AliShuttleLogbookEntry.h"
23 #include "TTimeStamp.h"
25 #include <TObjString.h>
28 ClassImp(AliShuttleLogbookEntry)
30 //______________________________________________________________________________________________
31 AliShuttleLogbookEntry::AliShuttleLogbookEntry() :
37 // default constructor
40 const UInt_t nDet = AliShuttleInterface::NDetectors();
41 memset(fDetectorStatus, kUnprocessed, nDet*sizeof(Status));
42 fRunParameters.SetOwner(1);
45 //______________________________________________________________________________________________
46 AliShuttleLogbookEntry::AliShuttleLogbookEntry(Int_t run, Status* status) :
52 // default constructor
55 const UInt_t nDet = AliShuttleInterface::NDetectors();
56 memset(fDetectorStatus, kUnprocessed, nDet*sizeof(Status));
57 if(status) SetDetectorStatus(status);
58 fRunParameters.SetOwner(1);
61 //______________________________________________________________________________________________
62 AliShuttleLogbookEntry::~AliShuttleLogbookEntry() {
69 //______________________________________________________________________________________________
70 AliShuttleLogbookEntry::AliShuttleLogbookEntry(const AliShuttleLogbookEntry &c) :
79 SetDetectorStatus(c.GetDetectorStatus());
80 fRunParameters.SetOwner(1);
81 TIter iter(c.fRunParameters.GetTable());
83 while((aPair = dynamic_cast<TPair*>(iter.Next()))){
84 TObjString* aKey= dynamic_cast<TObjString*>(aPair->Key());
85 TObjString* aValue= dynamic_cast<TObjString*>(aPair->Value());
86 fRunParameters.Add(aKey->Clone(), aValue->Clone());
90 //______________________________________________________________________________________________
91 AliShuttleLogbookEntry &AliShuttleLogbookEntry::operator=(const AliShuttleLogbookEntry &c)
98 ((AliShuttleLogbookEntry &) c).Copy(*this);
102 //______________________________________________________________________________________________
103 void AliShuttleLogbookEntry::Copy(TObject& c) const
109 AliShuttleLogbookEntry& target = (AliShuttleLogbookEntry &) c;
112 target.fRunParameters.SetOwner(1);
113 TIter iter(fRunParameters.GetTable());
115 while((aPair = dynamic_cast<TPair*>(iter.Next()))){
116 TObjString* aKey= dynamic_cast<TObjString*>(aPair->Key());
117 TObjString* aValue= dynamic_cast<TObjString*>(aPair->Value());
118 target.fRunParameters.Add(aKey->Clone(), aValue->Clone());
121 target.SetDetectorStatus(GetDetectorStatus());
124 //______________________________________________________________________________________________
125 AliShuttleLogbookEntry::Status AliShuttleLogbookEntry::GetDetectorStatus(Int_t detPos) const
128 // get detector status from detector code
131 if(detPos < 0 || detPos >= (Int_t) AliShuttleInterface::NDetectors()) {
132 AliError(Form("Invalid parameter: %d", detPos));
135 return fDetectorStatus[detPos];
138 //______________________________________________________________________________________________
139 void AliShuttleLogbookEntry::SetDetectorStatus(const char* detName, Status status)
142 // set detector status from detector code
145 Int_t detPos = AliShuttleInterface::GetDetPos(detName);
147 SetDetectorStatus(detPos, status);
150 //______________________________________________________________________________________________
151 void AliShuttleLogbookEntry::SetDetectorStatus(const char* detName, const char* statusName)
154 // set detector status from detector code
157 Int_t detPos = AliShuttleInterface::GetDetPos(detName);
159 SetDetectorStatus(detPos, statusName);
162 //______________________________________________________________________________________________
163 void AliShuttleLogbookEntry::SetDetectorStatus(Status* status)
166 // set detector status from detector code
169 for(UInt_t i=0; i < AliShuttleInterface::NDetectors(); i++){
170 fDetectorStatus[i] = status[i];
174 //______________________________________________________________________________________________
175 void AliShuttleLogbookEntry::SetDetectorStatus(UInt_t detPos, Status status)
178 // set detector status from detector code
181 if(detPos >= AliShuttleInterface::NDetectors()) {
182 AliError(Form("Shuttle has only %d subdetectors!", AliShuttleInterface::NDetectors()));
185 fDetectorStatus[detPos] = status;
188 //______________________________________________________________________________________________
189 void AliShuttleLogbookEntry::SetDetectorStatus(UInt_t detPos, const char* statusName)
192 // set detector status from detector code
195 if(detPos >= AliShuttleInterface::NDetectors()) {
196 AliError(Form("Shuttle has only %d subdetectors!", AliShuttleInterface::NDetectors()));
199 TString statusString(statusName);
200 if(statusString.Contains("UNPROCESSED", TString::kIgnoreCase)){
201 SetDetectorStatus(detPos, kUnprocessed);
202 } else if (statusString.Contains("INACTIVE", TString::kIgnoreCase)) {
203 SetDetectorStatus(detPos, kInactive);
204 } else if (statusString.Contains("FAILED", TString::kIgnoreCase)) {
205 SetDetectorStatus(detPos, kFailed);
206 } else if (statusString.Contains("DONE", TString::kIgnoreCase)) {
207 SetDetectorStatus(detPos, kDone);
209 AliError(Form("Invalid status name: %s", statusName));
213 //______________________________________________________________________________________________
214 Bool_t AliShuttleLogbookEntry::IsDone() const{
216 // return TRUE if all subdetectors are in status DONE, FAILED or INACTIVE
219 for(UInt_t i=0; i < AliShuttleInterface::NDetectors(); i++){
220 if(fDetectorStatus[i] == kUnprocessed) return kFALSE;
225 //______________________________________________________________________________________________
226 const char* AliShuttleLogbookEntry::GetDetectorStatusName(Status status)
229 // returns a name (string) of the detector status
233 case kUnprocessed: return "UNPROCESSED";
234 case kInactive: return "INACTIVE";
235 case kFailed: return "FAILED";
236 case kDone: return "DONE";
242 //______________________________________________________________________________________________
243 void AliShuttleLogbookEntry::Print(Option_t* option) const
246 // print current shuttle logbook entry
249 TString message = "\n*** Run parameters ***\n";
250 TTimeStamp startTimeStamp(GetStartTime());
251 TTimeStamp endTimeStamp(GetEndTime());
252 message += Form("\tRun \t\t%d\n", fRun);
253 message += Form("\tStarted \t%s\n", startTimeStamp.AsString("s"));
254 message += Form("\tFinished \t%s\n", endTimeStamp.AsString("s"));
255 message += "\n*** Detector status ***\n";
257 for (UInt_t i=0; i < AliShuttleInterface::NDetectors(); i++)
259 message += Form("\t%2d - %s: %s \n", i, AliShuttleInterface::GetDetName(i),
260 GetDetectorStatusName(fDetectorStatus[i]));
263 AliInfo(Form("option: %s",option));
264 TString optionStr(option);
265 if(optionStr=="all"){
266 message += "\nPrinting full list of run parameters\n";
267 message += "\tParameter Value\n";
268 TIter iter(fRunParameters.GetTable());
270 while((aPair = dynamic_cast<TPair*>(iter.Next()))){
271 TObjString* aKey= dynamic_cast<TObjString*>(aPair->Key());
272 TObjString* aValue= dynamic_cast<TObjString*>(aPair->Value());
273 TString keyStr=aKey->GetName();
275 message += Form("\t%s ", aKey->GetName());
276 if(keyStr.Length()<30) message.Append(' ', 30-keyStr.Length());
277 message += Form("%s\n", aValue->GetName());
279 TString logStr(aValue->GetName(), 100);
280 message += Form("\tlog (first 100 chars) %s \n",logStr.Data());
285 AliInfo(Form("%s",message.Data()));
287 //______________________________________________________________________________________________
288 void AliShuttleLogbookEntry::SetRunParameter(const char* key, const char* value){
290 // set a run parameter (read from the DAQ logbook)
293 TObjString* keyObj = new TObjString(key);
294 if (fRunParameters.Contains(key)) {
295 AliWarning(Form("Parameter %s already existing and it will be replaced.", key));
296 delete fRunParameters.Remove(keyObj);
299 fRunParameters.Add(keyObj, new TObjString(value));
300 AliDebug(2, Form("Number of parameters: %d", fRunParameters.GetEntries()));
302 //______________________________________________________________________________________________
303 const char* AliShuttleLogbookEntry::GetRunParameter(const char* key) const{
305 // get a run parameter
308 TObjString* value = dynamic_cast<TObjString*> (fRunParameters.GetValue(key));
310 AliError(Form("No such parameter: %s", key));
313 return value->GetName();