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() :
38 // default constructor
41 const UInt_t nDet = AliShuttleInterface::NDetectors();
42 memset(fDetectorStatus, kUnprocessed, nDet*sizeof(Status));
43 fRunParameters.SetOwner(1);
46 //______________________________________________________________________________________________
47 AliShuttleLogbookEntry::AliShuttleLogbookEntry(Int_t run, Status* status) :
54 // default constructor
57 const UInt_t nDet = AliShuttleInterface::NDetectors();
58 memset(fDetectorStatus, kUnprocessed, nDet*sizeof(Status));
59 if(status) SetDetectorStatus(status);
60 fRunParameters.SetOwner(1);
63 //______________________________________________________________________________________________
64 AliShuttleLogbookEntry::~AliShuttleLogbookEntry() {
68 fRunParameters.DeleteAll();
71 //______________________________________________________________________________________________
72 AliShuttleLogbookEntry::AliShuttleLogbookEntry(const AliShuttleLogbookEntry &c) :
76 fDATestMode(c.fDATestMode)
82 SetDetectorStatus(c.GetDetectorStatus());
83 fRunParameters.SetOwner(1);
84 TIter iter(c.fRunParameters.GetTable());
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());
93 //______________________________________________________________________________________________
94 AliShuttleLogbookEntry &AliShuttleLogbookEntry::operator=(const AliShuttleLogbookEntry &c)
101 ((AliShuttleLogbookEntry &) c).Copy(*this);
105 //______________________________________________________________________________________________
106 void AliShuttleLogbookEntry::Copy(TObject& c) const
112 AliShuttleLogbookEntry& target = (AliShuttleLogbookEntry &) c;
115 target.fRunParameters.SetOwner(1);
116 TIter iter(fRunParameters.GetTable());
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());
124 target.SetDetectorStatus(GetDetectorStatus());
125 target.fDATestMode = fDATestMode;
128 //______________________________________________________________________________________________
129 AliShuttleLogbookEntry::Status AliShuttleLogbookEntry::GetDetectorStatus(Int_t detPos) const
132 // get detector status from detector code
135 if(detPos < 0 || detPos >= (Int_t) AliShuttleInterface::NDetectors()) {
136 AliError(Form("Invalid parameter: %d", detPos));
139 return fDetectorStatus[detPos];
142 //______________________________________________________________________________________________
143 void AliShuttleLogbookEntry::SetDetectorStatus(const char* detName, Status status)
146 // set detector status from detector code
149 Int_t detPos = AliShuttleInterface::GetDetPos(detName);
151 SetDetectorStatus(detPos, status);
154 //______________________________________________________________________________________________
155 void AliShuttleLogbookEntry::SetDetectorStatus(const char* detName, const char* statusName)
158 // set detector status from detector code
161 Int_t detPos = AliShuttleInterface::GetDetPos(detName);
163 SetDetectorStatus(detPos, statusName);
166 //______________________________________________________________________________________________
167 void AliShuttleLogbookEntry::SetDetectorStatus(Status* status)
170 // set detector status from detector code
173 for(UInt_t i=0; i < AliShuttleInterface::NDetectors(); i++){
174 fDetectorStatus[i] = status[i];
178 //______________________________________________________________________________________________
179 void AliShuttleLogbookEntry::SetDetectorStatus(UInt_t detPos, Status status)
182 // set detector status from detector code
185 if(detPos >= AliShuttleInterface::NDetectors()) {
186 AliError(Form("Shuttle has only %d subdetectors!", AliShuttleInterface::NDetectors()));
189 fDetectorStatus[detPos] = status;
192 //______________________________________________________________________________________________
193 void AliShuttleLogbookEntry::SetDetectorStatus(UInt_t detPos, const char* statusName)
196 // set detector status from detector code
199 if(detPos >= AliShuttleInterface::NDetectors()) {
200 AliError(Form("Shuttle has only %d subdetectors!", AliShuttleInterface::NDetectors()));
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);
213 AliError(Form("Invalid status name: %s", statusName));
217 //______________________________________________________________________________________________
218 Bool_t AliShuttleLogbookEntry::IsDone() const{
220 // return TRUE if all subdetectors are in status DONE, FAILED or INACTIVE
223 for(UInt_t i=0; i < AliShuttleInterface::NDetectors(); i++){
224 if(fDetectorStatus[i] == kUnprocessed) return kFALSE;
229 //______________________________________________________________________________________________
230 const char* AliShuttleLogbookEntry::GetDetectorStatusName(Status status)
233 // returns a name (string) of the detector status
237 case kUnprocessed: return "UNPROCESSED";
238 case kInactive: return "INACTIVE";
239 case kFailed: return "FAILED";
240 case kDone: return "DONE";
246 //______________________________________________________________________________________________
247 void AliShuttleLogbookEntry::Print(Option_t* option) const
250 // print current shuttle logbook entry
253 TString message = "\n*** Run parameters ***\n";
254 TTimeStamp startTimeStamp(GetStartTime());
255 TTimeStamp endTimeStamp(GetEndTime());
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";
261 for (UInt_t i=0; i < AliShuttleInterface::NDetectors(); i++)
263 message += Form("\t%2d - %s: %s \n", i, AliShuttleInterface::GetDetName(i),
264 GetDetectorStatusName(fDetectorStatus[i]));
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());
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();
279 message += Form("\t%s ", aKey->GetName());
280 if(keyStr.Length()<30) message.Append(' ', 30-keyStr.Length());
281 message += Form("%s\n", aValue->GetName());
283 TString logStr(aValue->GetName(), 100);
284 message += Form("\tlog (first 100 chars) %s \n",logStr.Data());
289 AliInfo(message.Data());
291 //______________________________________________________________________________________________
292 void AliShuttleLogbookEntry::SetRunParameter(const char* key, const char* value){
294 // set a run parameter (read from the DAQ logbook)
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);
303 fRunParameters.Add(keyObj, new TObjString(value));
304 AliDebug(2, Form("Number of parameters: %d", fRunParameters.GetEntries()));
306 //______________________________________________________________________________________________
307 const char* AliShuttleLogbookEntry::GetRunParameter(const char* key) const{
309 // get a run parameter
312 TObjString* value = dynamic_cast<TObjString*> (fRunParameters.GetValue(key));
314 AliError(Form("No such parameter: %s", key));
317 return value->GetName();