]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - SHUTTLE/TestShuttle/AliTestShuttle.cxx
Run type field added in SHUTTLE framework. Run type is read from "run type" logbook...
[u/mrichter/AliRoot.git] / SHUTTLE / TestShuttle / AliTestShuttle.cxx
index 486bbbedc17414f70b8f34b7d6141602bc766286..1459bb3ee437c4699b88ba33aa1b623c010a608c 100644 (file)
 
 /*
 $Log$
+Revision 1.8  2007/02/13 11:22:25  acolla
+Shuttle getters and setters of main/local OCDB/Reference storages, temp and log
+folders moved to AliShuttleInterface
+
+Revision 1.6  2006/11/06 14:22:47  jgrosseo
+major update (Alberto)
+o) reading of run parameters from the logbook
+o) online offline naming conversion
+o) standalone DCSclient package
+
+Revision 1.5  2006/10/02 12:58:52  jgrosseo
+Small interface change in StoreReferenceData
+
 Revision 1.4  2006/08/08 14:19:07  jgrosseo
 Update to shuttle classes (Alberto)
 
@@ -73,8 +86,8 @@ some docs added
 
 #include <TMap.h>
 #include <TList.h>
-#include <TString.h>
 #include <TObjString.h>
+#include <TSystem.h>
 
 ClassImp(AliTestShuttle)
 
@@ -84,13 +97,22 @@ AliTestShuttle::AliTestShuttle(Int_t run, UInt_t startTime, UInt_t endTime) :
   fStartTime(startTime),
   fEndTime(endTime),
   fInputFiles(0),
+  fRunParameters(0),
+  fRunTypeMap(0),
   fPreprocessors(0),
   fDcsAliasMap(0)
 {
   // constructor
 
   fInputFiles = new TMap;
+  fRunParameters = new TMap;
+  fRunTypeMap = new TMap;
   fPreprocessors = new TObjArray;
+
+  fInputFiles->SetOwner(1);
+  fRunParameters->SetOwner(1);
+  fRunTypeMap->SetOwner(1);
+  fPreprocessors->SetOwner(1);
 }
 
 //______________________________________________________________________________________________
@@ -101,6 +123,12 @@ AliTestShuttle::~AliTestShuttle()
   delete fInputFiles;
   fInputFiles = 0;
 
+  delete fRunParameters;
+  fRunParameters = 0;
+
+  delete fRunTypeMap;
+  fRunTypeMap = 0;
+
   delete fPreprocessors;
   fPreprocessors = 0;
 
@@ -133,7 +161,7 @@ UInt_t AliTestShuttle::Store(const AliCDBPath& path, TObject* object, AliCDBMeta
 
   AliCDBId id(path, startRun, endRun);
 
-  return AliCDBManager::Instance()->Put(object, id, metaData);
+  return AliCDBManager::Instance()->GetStorage(fgkMainCDB)->Put(object, id, metaData);
 }
 
 //______________________________________________________________________________________________
@@ -147,7 +175,7 @@ UInt_t AliTestShuttle::StoreReferenceData(const AliCDBPath& path, TObject* objec
 
   AliCDBId id(path, fRun, fRun);
 
-  return AliCDBManager::Instance()->GetStorage("local://ReferenceStorage")->Put(object, id, metaData);
+  return AliCDBManager::Instance()->GetStorage(fgkMainRefStorage)->Put(object, id, metaData);
 }
 
 //______________________________________________________________________________________________
@@ -248,6 +276,36 @@ void AliTestShuttle::AddInputFile(Int_t system, const char* detector, const char
   sourceList->Add(new TObjString(source), new TObjString(fileName));
 }
 
+//______________________________________________________________________________________________
+Bool_t AliTestShuttle::AddInputCDBEntry(AliCDBEntry* entry)
+{
+  // This function adds an object in the OCDB to be later retrieved with GetFromOCDB
+
+       AliCDBStorage *sto = AliCDBManager::Instance()->GetStorage(fgkMainCDB);
+       if (!sto)
+       {
+               Log("SHUTTLE", "GetFromOCDB - Cannot activate main OCDB for query!");
+               return 0;
+       }
+
+       return sto->Put(entry);
+}
+
+//______________________________________________________________________________________________
+AliCDBEntry* AliTestShuttle::GetFromOCDB(const AliCDBPath& path)
+{
+// returns obiect from OCDB valid for current run
+
+       AliCDBStorage *sto = AliCDBManager::Instance()->GetStorage(fgkMainCDB);
+       if (!sto)
+       {
+               Log("SHUTTLE", "GetFromOCDB - Cannot activate main OCDB for query!");
+               return 0;
+       }
+
+       return (AliCDBEntry*) sto->Get(path, fRun);
+}
+
 //______________________________________________________________________________________________
 void AliTestShuttle::Process()
 {
@@ -270,5 +328,89 @@ void AliTestShuttle::RegisterPreprocessor(AliPreprocessor* preprocessor)
 {
   // registers a preprocessor
 
-  fPreprocessors->Add(preprocessor);
+       const char* detName = preprocessor->GetName();
+       if(strcmp("DET", detName) != 0) {
+               if(GetDetPos(detName) < 0)
+                       AliFatal(Form("********** !!!!! Invalid detector name: %s !!!!! **********", detName));
+       }
+
+       fPreprocessors->Add(preprocessor);
+}
+
+//______________________________________________________________________________________________
+void AliTestShuttle::AddInputRunParameter(const char* key, const char* value){
+// set a run parameter (in reality it will be read from the DAQ logbook)
+
+       TObjString* keyObj = new TObjString(key);
+       if (fRunParameters->Contains(key)) {
+               AliWarning(Form("Parameter %s already existing and it will be replaced.", key));
+               delete fRunParameters->Remove(keyObj);
+
+       }
+       fRunParameters->Add(keyObj, new TObjString(value));
+       AliDebug(2, Form("Number of parameters: %d", fRunParameters->
+       GetEntries()));
+}
+
+//______________________________________________________________________________________________
+void AliTestShuttle::AddInputRunType(const char* detCode, const char* runType){
+// set a run type (in reality it will be read from the "run type" logbook)
+
+       if (strcmp("DET", detCode) != 0)
+       {
+               if (GetDetPos(detCode) < 0)
+               {
+                       AliError(Form("Invalid detector name: %s", detCode));
+                       return;
+               }
+       }
+       TObjString* detObj = new TObjString(detCode);
+       if (fRunTypeMap->Contains(detCode)) {
+               AliWarning(Form("Detector %s already inserted: it will be replaced.", detCode));
+               delete fRunTypeMap->Remove(detObj);
+
+       }
+       fRunTypeMap->Add(detObj, new TObjString(runType));
+       AliDebug(2, Form("Number of detectors: %d", fRunTypeMap->GetEntries()));
 }
+
+//______________________________________________________________________________________________
+const char* AliTestShuttle::GetRunType(const char* detCode){
+// get a run parameter
+
+       TObjString* value = dynamic_cast<TObjString*> (fRunTypeMap->GetValue(detCode));
+       if(!value) {
+               AliError(Form("Input run type not set for detector %s!", detCode));
+               return 0;
+       }
+       return value->GetName();
+}
+
+//______________________________________________________________________________________________
+const char* AliTestShuttle::GetRunParameter(const char* key){
+// get a run parameter
+
+       TObjString* value = dynamic_cast<TObjString*> (fRunParameters->GetValue(key));
+       if(!value) {
+               AliError(Form("No such parameter: %s", key));
+               return 0;
+       }
+       return value->GetName();
+}
+
+//______________________________________________________________________________________________
+void AliTestShuttle::SetShuttleTempDir(const char* tmpDir)
+{
+// sets Shuttle temp directory
+
+       fgkShuttleTempDir = gSystem->ExpandPathName(tmpDir);
+}
+
+//______________________________________________________________________________________________
+void AliTestShuttle::SetShuttleLogDir(const char* logDir)
+{
+// sets Shuttle log directory
+
+       fgkShuttleLogDir = gSystem->ExpandPathName(logDir);
+}
+