+//_____________________________________________________________________
+void CreateChain(const anaModes mode, TChain * chain, TChain * chainxs)
+{
+ //Fills chain with data
+ TString ocwd = gSystem->WorkingDirectory();
+
+ //---------------------------------------
+ // Local files analysis
+ //---------------------------------------
+ if(mode == mLocal){
+ //If you want to add several ESD files sitting in a common directory INDIR
+ //Specify as environmental variables the directory (INDIR), the number of files
+ //to analyze (NFILES) and the pattern name of the directories with files (PATTERN)
+
+ if(gSystem->Getenv("INDIR"))
+ kInDir = gSystem->Getenv("INDIR") ;
+ else cout<<"INDIR not set, use default: "<<kInDir<<endl;
+
+ if(gSystem->Getenv("PATTERN"))
+ kPattern = gSystem->Getenv("PATTERN") ;
+ else cout<<"PATTERN not set, use default: "<<kPattern<<endl;
+
+ if(gSystem->Getenv("NFILES"))
+ kFile = atoi(gSystem->Getenv("NFILES")) ;
+ else cout<<"NFILES not set, use default: "<<kFile<<endl;
+
+ //Check if env variables are set and are correct
+ if ( kInDir && kFile) {
+ printf("Get %d files from directory %s\n",kFile,kInDir);
+ if ( ! gSystem->cd(kInDir) ) {//check if ESDs directory exist
+ printf("%s does not exist\n", kInDir) ;
+ return ;
+ }
+
+ //if(gSystem->Getenv("XSFILE"))
+ //kXSFileName = gSystem->Getenv("XSFILE") ;
+ //else cout<<" XS file name not set, use default: "<<kXSFileName<<endl;
+ char * kGener = gSystem->Getenv("GENER");
+ if(kGener) {
+ cout<<"GENER "<<kGener<<endl;
+ if (!strcmp(kGener,"PYTHIA")) kXSFileName = "pyxsec.root";
+ else if(!strcmp(kGener,"HERWIG")) kXSFileName = "hexsec.root";
+ else cout<<" UNKNOWN GENER, use default: "<<kXSFileName<<endl;
+ }
+ else cout<<" GENER not set, use default xs file name: "<<kXSFileName<<endl;
+
+ cout<<"INDIR : "<<kInDir <<endl;
+ cout<<"NFILES : "<<kFile <<endl;
+ cout<<"PATTERN : "<<kPattern <<endl;
+ cout<<"XSFILE : "<<kXSFileName<<endl;
+
+ TString datafile="";
+ if (kInputData == "ESD") datafile = "AliESDs.root" ;
+ else if(kInputData.Contains("AOD")) datafile = "AliAOD.root" ;
+ else if(kInputData == "MC") datafile = "galice.root" ;
+
+ //Loop on ESD/AOD/MC files, add them to chain
+ Int_t event =0;
+ Int_t skipped=0 ;
+ char file[120] ;
+ char filexs[120] ;
+
+ for (event = 0 ; event < kFile ; event++) {
+ sprintf(file, "%s/%s%d/%s", kInDir,kPattern,event,datafile.Data()) ;
+ sprintf(filexs, "%s/%s%d/%s", kInDir,kPattern,event,kXSFileName) ;
+ TFile * fData = 0 ;
+ //Check if file exists and add it, if not skip it
+ if ( fData = TFile::Open(file)) {
+ if ( fData->Get(kTreeName) ) {
+ printf("++++ Adding %s\n", file) ;
+ chain->AddFile(file);
+ chainxs->Add(filexs) ;
+ }
+ }
+ else {
+ printf("---- Skipping %s\n", file) ;
+ skipped++ ;
+ }
+ }
+ }
+ else {
+ TString input = "AliESDs.root" ;
+ cout<<">>>>>> No list added, take a single file <<<<<<<<< "<<input<<endl;
+ chain->AddFile(input);
+ }
+
+ }// local files analysis
+
+ //------------------------------
+ // GRID xml files
+ //------------------------------
+ else if(mode == mGRID){
+ //Get colection file. It is specified by the environmental
+ //variable XML
+