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() :
36 // default constructor
38 const UInt_t nDet = AliShuttleInterface::NDetectors();
39 memset(fDetectorStatus, kUnprocessed, nDet*sizeof(Status));
40 fRunParameters.SetOwner(1);
43 //______________________________________________________________________________________________
44 AliShuttleLogbookEntry::AliShuttleLogbookEntry(Int_t run, Status* status) :
49 // default constructor
51 const UInt_t nDet = AliShuttleInterface::NDetectors();
52 memset(fDetectorStatus, kUnprocessed, nDet*sizeof(Status));
53 if(status) SetDetectorStatus(status);
54 fRunParameters.SetOwner(1);
57 //______________________________________________________________________________________________
58 AliShuttleLogbookEntry::~AliShuttleLogbookEntry() {
63 //______________________________________________________________________________________________
64 AliShuttleLogbookEntry::AliShuttleLogbookEntry(const AliShuttleLogbookEntry &c) :
71 SetDetectorStatus(c.GetDetectorStatus());
72 fRunParameters.SetOwner(1);
73 TIter iter(c.fRunParameters.GetTable());
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());
83 //______________________________________________________________________________________________
84 AliShuttleLogbookEntry &AliShuttleLogbookEntry::operator=(const AliShuttleLogbookEntry &c)
89 ((AliShuttleLogbookEntry &) c).Copy(*this);
93 //______________________________________________________________________________________________
94 void AliShuttleLogbookEntry::Copy(TObject& c) const
98 AliShuttleLogbookEntry& target = (AliShuttleLogbookEntry &) c;
101 target.fRunParameters.SetOwner(1);
102 TIter iter(fRunParameters.GetTable());
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());
110 target.SetDetectorStatus(GetDetectorStatus());
113 //______________________________________________________________________________________________
114 AliShuttleLogbookEntry::Status AliShuttleLogbookEntry::GetDetectorStatus(const char* detName) const
116 // get detector status from detector code
118 return GetDetectorStatus(AliShuttleInterface::GetDetPos(detName));
121 //______________________________________________________________________________________________
122 AliShuttleLogbookEntry::Status AliShuttleLogbookEntry::GetDetectorStatus(Int_t detPos) const
124 // get detector status from detector code
126 if(detPos < 0 || detPos >= (Int_t) AliShuttleInterface::NDetectors()) {
127 AliError(Form("Invalid parameter: %d", detPos));
130 return fDetectorStatus[detPos];
133 //______________________________________________________________________________________________
134 void AliShuttleLogbookEntry::SetDetectorStatus(const char* detName, Status status)
136 // set detector status from detector code
138 Int_t detPos = AliShuttleInterface::GetDetPos(detName);
140 SetDetectorStatus(detPos, status);
143 //______________________________________________________________________________________________
144 void AliShuttleLogbookEntry::SetDetectorStatus(const char* detName, const char* statusName)
146 // set detector status from detector code
148 Int_t detPos = AliShuttleInterface::GetDetPos(detName);
150 SetDetectorStatus(detPos, statusName);
153 //______________________________________________________________________________________________
154 void AliShuttleLogbookEntry::SetDetectorStatus(Status* status)
156 // set detector status from detector code
158 for(UInt_t i=0; i < AliShuttleInterface::NDetectors(); i++){
159 fDetectorStatus[i] = status[i];
163 //______________________________________________________________________________________________
164 void AliShuttleLogbookEntry::SetDetectorStatus(UInt_t detPos, Status status)
166 // set detector status from detector code
168 if(detPos >= AliShuttleInterface::NDetectors()) {
169 AliError(Form("Shuttle has only %d subdetectors!", AliShuttleInterface::NDetectors()));
172 fDetectorStatus[detPos] = status;
175 //______________________________________________________________________________________________
176 void AliShuttleLogbookEntry::SetDetectorStatus(UInt_t detPos, const char* statusName)
178 // set detector status from detector code
180 if(detPos >= AliShuttleInterface::NDetectors()) {
181 AliError(Form("Shuttle has only %d subdetectors!", AliShuttleInterface::NDetectors()));
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);
194 AliError(Form("Invalid status name: %s", statusName));
198 //______________________________________________________________________________________________
199 Bool_t AliShuttleLogbookEntry::IsDone() const{
200 // return TRUE if all subdetectors are in status DONE, FAILED or INACTIVE
202 for(UInt_t i=0; i < AliShuttleInterface::NDetectors(); i++){
203 if(fDetectorStatus[i] == kUnprocessed) return kFALSE;
208 //______________________________________________________________________________________________
209 const char* AliShuttleLogbookEntry::GetDetectorStatusName(Status status)
211 // returns a name (string) of the detector status
214 case kUnprocessed: return "UNPROCESSED";
215 case kInactive: return "INACTIVE";
216 case kFailed: return "FAILED";
217 case kDone: return "DONE";
223 //______________________________________________________________________________________________
224 void AliShuttleLogbookEntry::Print(Option_t* option) const
226 // print current shuttle logbook entry
228 TString message = "\n*** Run parameters ***\n";
229 TTimeStamp startTimeStamp(GetStartTime());
230 TTimeStamp endTimeStamp(GetEndTime());
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";
236 for(UInt_t i=0; i < AliShuttleInterface::NDetectors(); i++)
237 message += Form("\t%2d - %s: %s\n", i, AliShuttleInterface::GetDetName(i),
238 GetDetectorStatusName(fDetectorStatus[i]));
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());
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();
252 message += Form("\t%s ", aKey->GetName());
253 if(keyStr.Length()<30) message.Append(' ', 30-keyStr.Length());
254 message += Form("%s\n", aValue->GetName());
256 message += "\tlog ...\n";
261 AliInfo(Form("%s",message.Data()));
263 //______________________________________________________________________________________________
264 void AliShuttleLogbookEntry::SetRunParameter(const char* key, const char* value){
265 // set a run parameter (read from the DAQ logbook)
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);
273 fRunParameters.Add(keyObj, new TObjString(value));
274 AliDebug(2, Form("Number of parameters: %d", fRunParameters.GetEntries()));
276 //______________________________________________________________________________________________
277 const char* AliShuttleLogbookEntry::GetRunParameter(const char* key) const{
278 // get a run parameter
280 TObjString* value = dynamic_cast<TObjString*> (fRunParameters.GetValue(key));
282 AliError(Form("No such parameter: %s", key));
285 return value->GetName();