]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
New function StoreRunMetadataFile added to TestShuttle package
authoracolla <acolla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 29 Oct 2007 18:07:14 +0000 (18:07 +0000)
committeracolla <acolla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 29 Oct 2007 18:07:14 +0000 (18:07 +0000)
This function can be used by GRP only. It stores raw data tags merged file to the
raw data folder (e.g. /alice/data/2008/LHC08a/000099999/Raw).

SHUTTLE/TestShuttle/AliTestShuttle.cxx
SHUTTLE/TestShuttle/AliTestShuttle.h
SHUTTLE/TestShuttle/TestPreprocessor.C

index 6817e87063ff188e2832890d116c9ed4661f46ad..9ee1056efdd495f1d328106a393b07362d1d0754 100644 (file)
 
 /*
 $Log$
+Revision 1.14  2007/08/06 12:25:47  acolla
+Function Bool_t GetHLTStatus added to preprocessor. It returns the status of HLT
+read from the run logbook.
+TestShuttle setup updated.
+TRD data point configuration updated.
+
 Revision 1.13  2007/05/30 06:35:21  jgrosseo
 Adding functionality to the Shuttle/TestShuttle:
 o) Function to retrieve list of sources from a given system (GetFileSources with id=0)
@@ -119,6 +125,7 @@ some docs added
 #include <TList.h>
 #include <TObjString.h>
 #include <TSystem.h>
+#include <TTimeStamp.h>
 
 ClassImp(AliTestShuttle)
 
@@ -214,39 +221,121 @@ Bool_t AliTestShuttle::StoreReferenceFile(const char* detector, const char* loca
        // puts it to the Grid FileCatalog
        
        AliCDBManager* man = AliCDBManager::Instance();
-       AliCDBStorage* sto = man->GetStorage(fgkMainRefStorage);
+       AliCDBStorage* sto = man->GetStorage(fgkLocalRefStorage);
        
        TString localBaseFolder = sto->GetBaseFolder();
        
-       TString targetDir;
-       targetDir.Form("%s/%s", localBaseFolder.Data(), detector);
+       TString targetDir = GetRefFilePrefix(localBaseFolder.Data(), detector); 
        
-       TString target;
-       target.Form("%s/%d_%s", targetDir.Data(), fRun, gridFileName);
+       return CopyFileLocally(targetDir, localFile, gridFileName);
+}
+
+//______________________________________________________________________________________________
+Bool_t AliTestShuttle::StoreRunMetadataFile(const char* localFile, const char* gridFileName)
+{
+       //
+       // Stores Run metadata file to the Grid, in the run folder
+       //
+       // Only GRP can call this function.
        
-       Int_t result = gSystem->GetPathInfo(targetDir, 0, (Long64_t*) 0, 0, 0);
-       if (result)
+       AliCDBManager* man = AliCDBManager::Instance();
+       AliCDBStorage* sto = man->GetStorage(fgkLocalRefStorage);
+       
+       TString localBaseFolder = sto->GetBaseFolder();
+       
+       // Build Run level folder
+       // folder = /alice/data/year/lhcPeriod/runNb/Raw
+       
+       TTimeStamp startTime(fStartTime);
+               
+       TString year =  Form("%d",startTime.GetDate());
+       year = year(0,4);
+               
+       TString lhcPeriod = GetRunParameter("LHCperiod");
+       
+       if (lhcPeriod.Length() == 0) 
        {
-               result = gSystem->mkdir(targetDir, kTRUE);
-               if (result != 0)
-               {
-                       Log("SHUTTLE", Form("StoreReferenceFile - Error creating base directory %s", targetDir.Data()));
+               Log("SHUTTLE","StoreRunMetaDataFile - LHCPeriod not found in logbook!");
+               return 0;
+       }
+       
+       // TODO: currently SHUTTLE cannot write in /alice/data/ !!!!!
+       //TString targetDir = Form("%s/GRP/RunMetadata/alice/data/%s/%s/%d/Raw", 
+       //                      localBaseFolder.Data(), year.Data(), 
+       //                      lhcPeriod.Data(), fRun);
+       
+       TString targetDir = Form("%s/GRP/RunMetadata/alice/simulation/%s/%s/%d/Raw", 
+                               localBaseFolder.Data(), year.Data(), 
+                               lhcPeriod.Data(), fRun);
+                                       
+       return CopyFileLocally(targetDir, localFile, gridFileName);
+}
+
+//______________________________________________________________________________________________
+Bool_t AliTestShuttle::CopyFileLocally(TString& targetDir, const char* localFile, const char* gridFileName)
+{
+       //
+       // Stores file locally. Called by StoreReferenceFile and StoreRunMetadataFile
+       //
+       
+       //try to open folder, if it does not exist
+       void* dir = gSystem->OpenDirectory(targetDir.Data());
+       if (dir == NULL) {
+               if (gSystem->mkdir(targetDir.Data(), kTRUE)) {
+                       Log("SHUTTLE", Form("StoreFileLocally - Can't open directory <%s>", targetDir.Data()));
                        return kFALSE;
                }
+
+       } else {
+               gSystem->FreeDirectory(dir);
        }
-               
+
+       TString target = Form("%s/%s", targetDir.Data(), gridFileName);
+       
+       Int_t result = gSystem->GetPathInfo(localFile, 0, (Long64_t*) 0, 0, 0);
+       if (result)
+       {
+               Log("SHUTTLE", Form("StoreFileLocally - %s does not exist", localFile));
+               return kFALSE;
+       }
+
        result = gSystem->CopyFile(localFile, target);
 
        if (result == 0)
        {
-               Log("SHUTTLE", Form("StoreReferenceFile - Stored file %s locally to %s", localFile, target.Data()));
+               Log("SHUTTLE", Form("StoreFileLocally - File %s stored locally to %s", localFile, target.Data()));
                return kTRUE;
        }
        else
        {
-               Log("SHUTTLE", Form("StoreReferenceFile - Storing file %s locally to %s failed with %d", localFile, target.Data(), result));
+               Log("SHUTTLE", Form("StoreFileLocally - Could not store file %s to %s!. Error code = %d", 
+                               localFile, target.Data(), result));
                return kFALSE;
-       }               
+       }       
+
+
+
+}
+
+//______________________________________________________________________________________________
+const char* AliTestShuttle::GetRefFilePrefix(const char* base, const char* detector)
+{
+       //
+       // Get folder name of reference files 
+       //
+
+       TString offDetStr(GetOfflineDetName(detector));
+       TString dir;
+       if (offDetStr == "ITS" || offDetStr == "MUON" || offDetStr == "PHOS")
+       {
+               dir.Form("%s/%s/%s", base, offDetStr.Data(), detector);
+       } else {
+               dir.Form("%s/%s", base, offDetStr.Data());
+       }
+       
+       return dir.Data();
+       
+
 }
 
 //______________________________________________________________________________________________
index 32f98aa1b3bcc507652ec442045902e7ca10f935..9daf8c11e6fabce9f25b4655f79bd9204f683b95 100644 (file)
@@ -39,6 +39,7 @@ class AliTestShuttle : public AliShuttleInterface
                                        Int_t validityStart = 0, Bool_t validityInfinite = kFALSE);
     virtual Bool_t StoreReferenceData(const AliCDBPath& path, TObject* object, AliCDBMetaData* metaData);
     virtual Bool_t StoreReferenceFile(const char* detector, const char* localFile, const char* gridFileName);
+    virtual Bool_t StoreRunMetadataFile(const char* localFile, const char* gridFileName);
     virtual const char* GetFile(Int_t system, const char* detector, const char* id, const char* source);
     virtual TList* GetFileSources(Int_t system, const char* detector, const char* id = 0);
     virtual TList* GetFileIDs(Int_t system, const char* detector, const char* source);
@@ -73,6 +74,9 @@ class AliTestShuttle : public AliShuttleInterface
     TMap* fDcsAliasMap; // DCS data for testing
 
   private:
+    Bool_t CopyFileLocally(TString& targetDir, const char* localFile, const char* gridFileName);
+    const char* GetRefFilePrefix(const char* base, const char* detector);
+    
     ClassDef(AliTestShuttle, 0);
 };
 
index 01e83dc4fc62a7a861a1e96bbc42f95d19ed3d46..5d6d66b6e88c749709699c14573d2bd279120988 100644 (file)
@@ -84,14 +84,6 @@ void TestPreprocessor()
 
   // TODO(5)
   //
-  // The shuttle can read run parameters stored in the DAQ run logbook.
-  // To test it, we must provide the run parameters manually. They will be retrieved in the preprocessor
-  // using GetRunParameter function.
-  shuttle->AddInputRunParameter("totalEvents", "30000");
-  shuttle->AddInputRunParameter("NumberOfGDCs", "15");
-
-  // TODO(6) NEW!
-  //
   // This is for preprocessor that require data from HLT.
   // Since HLT may be switched off, the preprocessor should first query the Run logbook where
   // the HLT status is stored. SHUTTLE implements a shortcut function (GetHLTStatus) that returns
@@ -102,14 +94,14 @@ void TestPreprocessor()
   shuttle->SetInputHLTStatus(hltStatus);
 
 
-  // TODO(7)
+  // TODO(6)
   // Create the preprocessor that should be tested, it registers itself automatically to the shuttle
   AliPreprocessor* test = new AliTestPreprocessor(shuttle);
 
   // Test the preprocessor
   shuttle->Process();
 
-  // TODO(8)
+  // TODO(7)
   // In the preprocessor AliShuttleInterface::Store should be called to put the final
   // data to the CDB. To check if all went fine have a look at the files produced in
   // $ALICE_ROOT/SHUTTLE/TestShuttle/TestCDB/<detector>/SHUTTLE/Data