Skip to content

Commit

Permalink
Merge pull request alisw#180 from miranov25/master
Browse files Browse the repository at this point in the history
PWGPP-6: Add checkLevel -  AliXRDPROOFtoolkit::MakeChain
  • Loading branch information
alibuild authored May 9, 2017
2 parents b7801aa + 162673a commit ea03964
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
25 changes: 19 additions & 6 deletions TPC/TPCbase/AliXRDPROOFtoolkit.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ ClassImp(AliXRDPROOFtoolkit)



TChain* AliXRDPROOFtoolkit::MakeChain(const char*fileIn, const char * treeName, const char *fName, Int_t maxFiles, Int_t startFile)
TChain* AliXRDPROOFtoolkit::MakeChain(const char*fileIn, const char * treeName, const char *fName, Int_t maxFiles, Int_t startFile, Int_t checkLevel)
{
/// Create a chain of files using the file 'fileIn' as input list
/// where one line per root file is expected
Expand All @@ -98,12 +98,17 @@ TChain* AliXRDPROOFtoolkit::MakeChain(const char*fileIn, const char * treeName,
/// maxFiles : maximum number of files in the chain
/// -1 (default) add all possible files starting from 'startFile'
/// startFile: position of the first file, starting with 0
TString finput=fileIn;
if (checkLevel>0){
FilterList(fileIn,TString::Format("* %s",treeName).Data(), checkLevel);
finput+=".Good";
}

TChain* chain = new TChain(treeName);

// Open the input stream
ifstream in;
in.open(fileIn);
in.open(finput.Data());

// Read the input list of files and add them to the chain
TString currentFile;
Expand Down Expand Up @@ -133,21 +138,26 @@ TChain* AliXRDPROOFtoolkit::MakeChain(const char*fileIn, const char * treeName,
return chain;
}

TChain* AliXRDPROOFtoolkit::MakeChainRandom(const char*fileIn, const char * treeName,const char *fName, Int_t maxFiles, Int_t startFile)
TChain* AliXRDPROOFtoolkit::MakeChainRandom(const char*fileIn, const char * treeName,const char *fName, Int_t maxFiles, Int_t startFile, Int_t checkLevel)
{
/// Create a TDSet - files are in random order
///
/// filein - input list text file
/// treename - containg tree
/// maxFiles - maximum number of files included
TString finput=fileIn;
if (checkLevel>0){
FilterList(fileIn,TString::Format("* %s",treeName).Data(), checkLevel);
finput+=".Good";
}

TObjArray array(10000);

TChain* chain = new TChain(treeName);

// Open the input stream
ifstream in;
in.open(fileIn);
in.open(finput.Data());

// Read the input list of files and add them to the chain
TString currentFile;
Expand Down Expand Up @@ -286,9 +296,9 @@ Int_t AliXRDPROOFtoolkit::CheckTreeInFile(const char*fileName,const char*treeNa
/// return value = 0 - Check things OK
/// -1 - file not exist or not accesible
/// -2 - file is zombie
/// -3 - tree not present
/// -3 - tree not present
/// -4 - branch not present

/// -5 - no branhes
TFile * file = TFile::Open(fileName);
if (!file) { return -1;}
if (file->IsZombie()) {file->Close(); delete file; return -2;};
Expand All @@ -301,6 +311,9 @@ Int_t AliXRDPROOFtoolkit::CheckTreeInFile(const char*fileName,const char*treeNa
}
TTree * tree = (TTree*)file->Get(treeName);
if (!tree) {file->Close(); delete file; return -3;}
if (tree->GetListOfBranches()==NULL) return -5;
if (tree->GetListOfBranches()->GetEntries()==0) return -5;

TBranch * branch = 0;
if (branchName) {
branch = tree->GetBranch(branchName);
Expand Down
4 changes: 2 additions & 2 deletions TPC/TPCbase/AliXRDPROOFtoolkit.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class AliXRDPROOFtoolkit : public TObject
{
public :
AliXRDPROOFtoolkit ();
static TChain * MakeChain(const char*fileIn, const char * treeName, const char *fName=0, Int_t maxFiles=-1, Int_t startFile=0);
static TChain * MakeChainRandom(const char*fileIn, const char * treeName, const char *fName=0, Int_t maxFiles=-1, Int_t startFile=0);
static TChain * MakeChain(const char*fileIn, const char * treeName, const char *fName=0, Int_t maxFiles=-1, Int_t startFile=0, Int_t checkLevel=0);
static TChain * MakeChainRandom(const char*fileIn, const char * treeName, const char *fName=0, Int_t maxFiles=-1, Int_t startFile=0, Int_t checkLevel=0);
TDSet * MakeSet(const char*fileIn, const char * treeName, const char *fName=0, Int_t maxFiles=-1);
TDSet * MakeSetRandom(const char*fileIn, const char * treeName,const char *fName=0, Int_t maxFiles=-1);
static Bool_t FilterList(const char*inputList, const char*fileList, Int_t checkLevel);
Expand Down

0 comments on commit ea03964

Please sign in to comment.