#include <TSystem.h>
#include <TFile.h>
#include <TKey.h>
+#include <TGrid.h>
+#include <TGridResult.h>
#include "AliRawReaderChain.h"
#include "AliRawVEvent.h"
+#include "AliLog.h"
ClassImp(AliRawReaderChain)
+TString AliRawReaderChain::fgSearchPath = "/alice/data";
+
AliRawReaderChain::AliRawReaderChain() :
AliRawReaderRoot(),
fChain(NULL)
// create raw-reader objects which takes as an input a root chain
// from a root file collection
- if (!fChain) fIsValid = kFALSE;
+ if (!fChain) {
+ fIsValid = kFALSE;
+ return;
+ }
fChain->SetBranchStatus("*",1);
fChain->SetBranchAddress("rawevent",&fEvent,&fBranch);
// create raw-reader objects which takes as an input a root chain
// from a root file collection
- if (!elist) fIsValid = kFALSE;
+ if (!elist) {
+ fIsValid = kFALSE;
+ return;
+ }
fChain = new TChain("RAW");
fChain->SetBranchAddress("rawevent",&fEvent,&fBranch);
}
+AliRawReaderChain::AliRawReaderChain(Int_t runNumber) :
+ AliRawReaderRoot(),
+ fChain(NULL)
+{
+// create raw-reader objects which takes as an input a root chain
+// with the raw-data files for a given run
+// It queries alien FC in order to do that and therefore
+// it needs alien API to be enabled
+
+ if (runNumber <= 0) {
+ Error("AliRawReaderChain","Bad run number:%d",runNumber);
+ fIsValid = kFALSE;
+ }
+
+ if (!gGrid) TGrid::Connect("alien://");
+ if (!gGrid) {
+ fIsValid = kFALSE;
+ return;
+ }
+
+ if (fgSearchPath.IsNull()) fgSearchPath = "/alice/data";
+ TGridResult *res = gGrid->Query(fgSearchPath.Data(),Form("%09d/raw/*%09d*.root",runNumber,runNumber));
+ Int_t nFiles = res->GetEntries();
+ if (!nFiles) {
+ Error("AliRawReaderChain","No raw-data files found for run %d",runNumber);
+ fIsValid = kFALSE;
+ delete res;
+ return;
+ }
+
+ fChain = new TChain("RAW");
+ for (Int_t i = 0; i < nFiles; i++) {
+ TString filename = res->GetKey(i, "turl");
+ if(filename == "") continue;
+ fChain->Add(filename.Data());
+ }
+ delete res;
+
+ fChain->SetBranchStatus("*",1);
+ fChain->SetBranchAddress("rawevent",&fEvent,&fBranch);
+}
+
+
AliRawReaderChain::AliRawReaderChain(const AliRawReaderChain& rawReader) :
AliRawReaderRoot(rawReader),
fChain(rawReader.fChain)
return fChain->GetEntries();
}
+
+void AliRawReaderChain::SetSearchPath(const char* path)
+{
+ // set alien query search path
+ AliInfoGeneral("SetSearchPath",Form("Setting search path to \"%s\" (was \"%s\")",path,fgSearchPath.Data()));
+ fgSearchPath = path;
+}