AliRoot Core  da88d91 (da88d91)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliXRDPROOFtoolkit.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 
37 
38 #include <TTree.h>
39 #include <TEnv.h>
40 #include <TString.h>
41 #include <TObjArray.h>
42 #include <TObjString.h>
43 #include <TTree.h>
44 #include <TFile.h>
45 #include <TChain.h>
46 #include <TDSet.h>
47 #include <TH1.h>
48 #include <TGraph.h>
49 #include <TMath.h>
50 #include <TPad.h>
51 #include <exception>
52 #include <fstream>
53 #include <TRandom.h>
54 #include <TTimeStamp.h>
55 #include "TSystem.h"
56 #include "AliXRDPROOFtoolkit.h"
57 #include <iostream>
58 #include <iomanip>
59 
60 using namespace std;
61 
62 
63 
67 
68 
69 
70 //______________________________________________________________________________
72  TObject () ,
73  fVerbose(kFALSE), // verbso mode - print command
74  fUserName(""), // user name
75  fUserGroup(0) // user group info
76 {
77  //
78  //
79  //
80  fUserGroup = gSystem->GetUserInfo();
81  fUserName = fUserGroup->fUser;
82  fVerbose=1;
83 }
84 
85 
86 
87 
88 
89 TChain* AliXRDPROOFtoolkit::MakeChain(const char*fileIn, const char * treeName, const char *fName, Int_t maxFiles, Int_t startFile)
90 {
100 
101  TChain* chain = new TChain(treeName);
102 
103  // Open the input stream
104  ifstream in;
105  in.open(fileIn);
106 
107  // Read the input list of files and add them to the chain
108  TString currentFile;
109  Int_t counter=0;
110  while(in.good()) {
111  in >> currentFile;
112  if (fName) {
113  currentFile+="#";
114  currentFile+=fName;
115  }
116  if (!currentFile.Contains("root")) continue; // protection
117  ++counter;
118  if (counter<=startFile) continue;
119  if ((maxFiles>0) && (counter>maxFiles+startFile)) break;
120 
121  // TFile * f = TFile::Open(currentFile.Data());
122  // if (f){
123  chain->Add(currentFile.Data());
124  // }
125 
126  // delete f;
127  }
128 
129  in.close();
130 
131  return chain;
132 }
133 
134 TChain* AliXRDPROOFtoolkit::MakeChainRandom(const char*fileIn, const char * treeName,const char *fName, Int_t maxFiles, Int_t startFile)
135 {
141 
142  TObjArray array(10000);
143 
144  TChain* chain = new TChain(treeName);
145 
146  // Open the input stream
147  ifstream in;
148  in.open(fileIn);
149 
150  // Read the input list of files and add them to the chain
151  TString currentFile;
152  Int_t counter=0;
153  while(in.good()) {
154  in >> currentFile;
155  if (fName) {
156  currentFile+="#";
157  currentFile+=fName;
158  }
159  if (!currentFile.Contains("root")) continue; // protection
160  counter++;
161  // chain->Add(currentFile.Data());
162  array.AddLast(new TObjString(currentFile));
163  }
164  in.close();
165  Int_t entries = array.GetEntries();
166  printf("Number of entries\t%d\n",entries);
167  //
168  //
169  //
170  Double_t *randomI = new Double_t[entries];
171  Int_t *indexes = new Int_t[entries];
172  for (Int_t i=0;i<entries; i++) randomI[i]=gRandom->Rndm();
173  TMath::Sort(entries,randomI,indexes);
174 
175  for (Int_t i=startFile; (i<startFile+maxFiles) && (i<entries); i++){
176  Int_t ifile = indexes[i];
177  if (ifile<entries && (array.At(ifile)) && array.At(ifile)->TestBit(TObject::kCannotPick)==kFALSE){
178  printf("%d\t%d\t%s\n",i, ifile, array.At(ifile)->GetName());
179  chain->Add(array.At(ifile)->GetName());
180  array.At(ifile)->SetBit(TObject::kCannotPick);
181  }
182  }
183  return chain;
184 }
185 
186 
187 
188 TDSet* AliXRDPROOFtoolkit::MakeSet(const char*fileIn, const char * treeName, const char *fName, Int_t maxFiles)
189 {
194 
195  TDSet* chain = new TDSet(treeName);
196 
197  // Open the input stream
198  ifstream in;
199  in.open(fileIn);
200 
201  // Read the input list of files and add them to the chain
202  TString currentFile;
203  Int_t counter=0;
204  while(in.good()) {
205  in >> currentFile;
206  if (fName) {
207  currentFile+="#";
208  currentFile+=fName;
209  }
210  if (!currentFile.Contains("root")) continue; // protection
211  counter++;
212  if (maxFiles>0 && counter>maxFiles) break;
213  chain->Add(currentFile.Data());
214  }
215 
216  in.close();
217  chain->Validate();
218  return chain;
219 }
220 
221 
222 TDSet* AliXRDPROOFtoolkit::MakeSetRandom(const char*fileIn, const char * treeName, const char *fName, Int_t maxFiles)
223 {
229 
230  TObjArray array(10000);
231 
232  TDSet* chain = new TDSet(treeName);
233 
234  // Open the input stream
235  ifstream in;
236  in.open(fileIn);
237 
238  // Read the input list of files and add them to the chain
239  TString currentFile;
240  Int_t counter=0;
241  while(in.good()) {
242  in >> currentFile;
243  if (fName) {
244  currentFile+="#";
245  currentFile+=fName;
246  }
247  if (!currentFile.Contains("root")) continue; // protection
248  counter++;
249  // chain->Add(currentFile.Data());
250  array.AddLast(new TObjString(currentFile));
251  }
252  in.close();
253  Int_t entries = array.GetEntries();
254  printf("Number of entries\t%d",entries);
255  if (maxFiles<0) maxFiles=entries;
256  if (maxFiles>entries) maxFiles=entries;
257  for (Int_t i=0; i<maxFiles; i++){
258  Int_t ifile = TMath::Nint(gRandom->Rndm()*Float_t(entries));
259  if (ifile<entries && (array.At(ifile)) && array.At(ifile)->TestBit(TObject::kCannotPick)==kFALSE){
260  printf("%d\t%d\t%s\n",i, ifile, array.At(ifile)->GetName());
261  chain->Add(array.At(ifile)->GetName());
262  array.At(ifile)->SetBit(TObject::kCannotPick);
263  }
264  }
265 
266 
267  chain->Validate();
268  return chain;
269 }
270 
271 
272 
273 
274 
275 
276 
277 Int_t AliXRDPROOFtoolkit::CheckTreeInFile(const char*fileName,const char*treeName, Int_t debugLevel, const char *branchName){
289 
290  TFile * file = TFile::Open(fileName);
291  if (!file) { return -1;}
292  if (file->IsZombie()) {file->Close(); delete file; return -2;};
293 
294  TString TrName(treeName);
295  if (TrName=="*") {
296  //cout <<" treename ==== *"<<endl;;
297  file->Close(); delete file;
298  return 0;
299  }
300  TTree * tree = (TTree*)file->Get(treeName);
301  if (!tree) {file->Close(); delete file; return -3;}
302  TBranch * branch = 0;
303  if (branchName) {
304  branch = tree->GetBranch(branchName);
305  if (!branch) {file->Close(); delete file; return -4;}
306  }
307  //
308  if (debugLevel==1 && tree->GetEntries()==0 ) return 1; //empty
309 
310  tree->SetBranchStatus("*",1);
311  try {
312  if (debugLevel>1){
313  Int_t entries = tree->GetEntries();
314  for (Int_t i=0;i<entries; i++){
315  if (branch) branch->GetEntry(i);
316  else tree->GetEntry();
317  }
318  }
319  }catch ( ... ) {
320  printf("PROBLEM\n");
321  // never catched - as there is no exception in the ROOT IO
322  file->Close(); delete file;
323  return 1 ;
324  }
325 
326  file->Close(); delete file;
327  return 0;
328 }
329 
330 
331 Bool_t AliXRDPROOFtoolkit::FilterList(const char*inputList, const char*fileList, Int_t checkLevel){
347 
348  gEnv->SetValue("TFile.Recover", 0);
349  //
350  fstream finput;
351  finput.open(inputList, ios_base::in);
352  fstream focGood;
353  fstream focBad;
354  focGood.open(Form("%s.Good",inputList), ios_base::out|ios_base::trunc);
355  focBad.open(Form("%s.Bad",inputList), ios_base::out|ios_base::trunc);
356  //
357  if(!finput.is_open()) {
358  cout<<"Can't open file "<<inputList<<endl;
359  return kFALSE;
360  }
361  //
362  // Read the input list of files and add them to the chain
363  //
364  TObjArray *array = (TString(fileList)).Tokenize(" ");
365  TString currentFile;
366  Int_t counter=0;
367  while(finput.good()) {
368  finput >> currentFile;
369  if (!currentFile.Contains("root")) continue; // protection
370  if (currentFile.Contains("alien://")){
371  focGood<<currentFile<<endl;
372  continue;
373  }
374  Bool_t isZip = currentFile.Contains("#");
375  const char * dirname = gSystem->DirName(currentFile.Data());
376  Int_t status = 0;
377  //
378  for (Int_t i=0; i<array->GetEntries(); i+=2){
379  char fname[1000];
380  if (!isZip){
381  snprintf(fname,1000, "%s/%s",dirname,array->At(i)->GetName());
382  if (((TObjString*)array->At(i))->String().Contains("*")){
383  snprintf(fname,1000, "%s", currentFile.Data());
384  }
385  }
386  if (isZip) {
387  const char * fileName = gSystem->BaseName(currentFile.Data());
388  TString fstring=fileName;
389  fstring[fstring.First("#")]=0;
390  snprintf(fname,1000, "%s/%s#%s",dirname,fstring.Data(),array->At(i)->GetName());
391  printf(fname, "To check %s%s#%s\n",dirname,fstring.Data(),array->At(i)->GetName());
392  }
393 
394  printf("\nFile to be checked %s\n",fname);
395  //cout <<"\n arguments: "<< array->At(i+1)->GetName()<<" "<<checkLevel<<endl;
396  Int_t cstatus = CheckTreeInFile(fname, array->At(i+1)->GetName(), checkLevel,0);
397  //printf(" CheckTreeInFile returns %d",cstatus);
398  if (cstatus!=0) {
399  status = cstatus;
400  break;
401  }
402  }
403  if (status==0){
404  focGood<<currentFile<<endl;
405  }else{
406  focBad<<currentFile<<endl;
407  }
408  counter++;
409  }
410  finput.close();
411  delete array;
412  return kTRUE;
413 }
414 
415 
416 Bool_t AliXRDPROOFtoolkit::FilterListZip(const char*inputList, const char*fileList, Int_t checkLevel){
432 
433  fstream finput;
434  finput.open(inputList, ios_base::in);
435  fstream focGood;
436  fstream focBad;
437  focGood.open(Form("%s.Good",inputList), ios_base::out|ios_base::trunc);
438  focBad.open(Form("%s.Bad",inputList), ios_base::out|ios_base::trunc);
439  //
440  if(!finput.is_open()) {
441  cout<<"Can't open file "<<inputList<<endl;
442  return kFALSE;
443  }
444  //
445  // Read the input list of files and add them to the chain
446  //
447  TObjArray *array = (TString(fileList)).Tokenize(" ");
448  TString currentFile;
449  Int_t counter=0;
450  while(finput.good()) {
451  finput >> currentFile;
452  if (!currentFile.Contains("root")) continue; // protection
453  if (currentFile.Contains("alien://")){
454  focGood<<currentFile<<endl;
455  continue;
456  }
457  //Bool_t isZip = currentFile.Contains("#");
458  const char * dirname = gSystem->DirName(currentFile.Data());
459  const char * fileName = gSystem->BaseName(currentFile.Data());
460  TString fstring=fileName;
461  fstring[fstring.First("#")]=0;
462  Int_t status = 0;
463  for (Int_t i=0; i<array->GetEntries(); i+=2){
464  char fname[1000];
465  //if (isZip) sprintf(fname,
466  snprintf(fname,1000, "%s/%s#%s",dirname,fstring.Data(),array->At(i)->GetName());
467  printf(fname, "To check %s%s#%s\n",dirname,fstring.Data(),array->At(i)->GetName());
468  //cout <<"\n arguments: "<< array->At(i+1)->GetName()<<" "<<checkLevel<<endl;
469  Int_t cstatus = CheckTreeInFile(fname, array->At(i+1)->GetName(), checkLevel,0);
470  //printf(" CheckTreeInFile returns %d",cstatus);
471  if (cstatus!=0) {
472  status = cstatus;
473  break;
474  }
475  }
476  if (status==0){
477  focGood<<currentFile<<endl;
478  }else{
479  focBad<<currentFile<<endl;
480  }
481  counter++;
482  }
483  finput.close();
484  return kTRUE;
485 }
486 
487 
488 
489 
490 
491 Bool_t AliXRDPROOFtoolkit::XRDCopyDir(const char * idir, const char * files, const char *odir, Bool_t /*zip*/){
502 
503  TString str(files);
504  TObjArray * array = str.Tokenize(" ");
505  Int_t nfiles = array->GetEntries();
506  char infile[1000];
507  char outfile[1000];
508  Bool_t succes=kTRUE;
509  for (Int_t ifile =0; ifile<nfiles; ifile++){
510  snprintf(infile,1000,"%s/%s", idir, array->At(ifile)->GetName());
511  snprintf(outfile,1000,"%s/%s", odir, array->At(ifile)->GetName());
512  printf("%s - %s\n",infile, outfile);
513  Bool_t result = TFile::Cp(infile,outfile);
514  succes &= result;
515  }
516  delete array;
517  return succes;
518 }
519 
520 
521 
522 void AliXRDPROOFtoolkit::JoinTreesIndex(const char * outputFile, const char * outputTree, const char *indexName, const char *inputTrees, Int_t debugLevel){
567 
568  TFile * fout = new TFile(outputFile,"recreate");
569  fout->cd();
570  TTree *joinTree=new TTree(outputTree,outputTree);
571  //
572  // 1. Define setup. parse definition string
573  //
574  TObjArray *arrayInput = TString(inputTrees).Tokenize("+");
575  Int_t nTrees = arrayInput->GetEntries();
576  TObjArray * arrayFile = new TObjArray(nTrees); // array of TFiles with trees
577  TObjArray * arrayTrees = new TObjArray(nTrees); // array of trees
578  TObjArray * arrayNames = new TObjArray(nTrees); // name of tree
579  TObjArray * arrayRunID = new TObjArray(nTrees); // name of tree
580  TArrayI arrayEnableTree(nTrees);
581  for (Int_t i=0; i<2; i++) printf("\n");
582  printf("Joing query\n");
583  arrayInput->Print();
584  for (Int_t i=0; i<2; i++) printf("\n");
585  {for (Int_t itree=0; itree<nTrees; itree++){
586  //
587  TObjArray *description = TString(arrayInput->At(itree)->GetName()).Tokenize("#");
588  if (description->GetEntries()<4) {
589  printf("Fatal: Invalid description: %s\n", arrayInput->At(itree)->GetName());
590  continue;
591  }
592  TFile * f = TFile::Open(description->At(4)->GetName());
593  if (!f){
594  printf("Fatal: Invalid description: fileName %s\n", description->At(4)->GetName());
595  delete arrayInput;
596  return;
597  }
598  arrayFile->AddAt(f,itree);
599  TTree * tree = (TTree*)f->Get(description->At(3)->GetName());
600  if (!tree){
601  printf("Fatal: Invalid description. Tree name\t%s\n", description->At(3)->GetName());
602  delete arrayInput;
603  return;
604  }
605  tree->SetCacheSize(400000000);
606  //
607  arrayTrees->AddAt(tree,itree);
608  //
609  arrayRunID->AddAt(new TObjString(description->At(2)->GetName()),itree);
610  arrayNames->AddAt(new TObjString(description->At(1)->GetName()),itree);
611  arrayEnableTree[itree]=atoi(description->At(0)->GetName());
612 
613  }}
614  //
615  delete arrayInput;
616  // 2. Make the run list
617  //
618  //
619  map<int, int> runMap;
620  map<int, int> *runMapTree = new map<int, int>[nTrees];
621  //map<int, int> runMapTree[nTrees];
622  {for (Int_t itree=0; itree<nTrees; itree++){
623  TTree * tree = (TTree*)arrayTrees->At(itree);
624  Int_t entries=tree->GetEntries();
625  char query[2000];
626  snprintf(query,2000,"%s:Entry$", arrayRunID->At(itree)->GetName());
627  entries = tree->Draw(query,"","goff");
628  for (Int_t ientry=0;ientry<entries; ientry++){
629  Int_t irun=Int_t(tree->GetV1()[ientry]);
630  // Int_t entryNr=Int_t(tree->GetV2()[ientry]);
631  if (arrayEnableTree[itree]>0) runMap[irun]+=1;
632  runMapTree[itree][irun]=ientry;
633  if (debugLevel>0) printf("%s\t%d\t%d\n",tree->GetName(), irun, runMapTree[itree][irun]);
634  }
635  }
636  }
637  //
638  // 3. Make join tree
639  //
640  Int_t jrun=0;
641  fout->cd();
642  joinTree->Branch(indexName, &jrun,Form("%s/I",indexName));
643  Int_t *status=new Int_t[nTrees];
644  char *brName = new char[10000];
645  char *brTitle= new char[10000];
646  //
647 
648  {for (Int_t itree=0; itree<nTrees; itree++){
649  TTree * tree = (TTree*)arrayTrees->At(itree);
650  tree->GetEntry(1);
651  TString treeName=arrayNames->At(itree)->GetName();
652  if (treeName.Length()>0){
653  joinTree->Branch(Form("%s.status",treeName.Data()), &status[itree],Form("%s.status/I",treeName.Data()));
654  }else{
655  joinTree->Branch("status", &status[itree],"status/I");
656  }
657  //
658  Int_t nbranches= tree->GetListOfBranches()->GetEntries();
659  for (Int_t ibr=0; ibr<nbranches; ibr++){
660  TBranch * br = (TBranch*)(tree->GetListOfBranches()->At(ibr));
661  if (treeName.Length()>0){
662  sprintf(brName,"%s.%s",treeName.Data(), br->GetName());
663  sprintf(brTitle,"%s.%s",treeName.Data(), br->GetTitle());
664  }else{
665  sprintf(brName,"%s",br->GetName());
666  sprintf(brTitle,"%s",br->GetTitle());
667  }
668  void* addr = 0;
669  TString className=br->GetClassName();
670  if (className.Length()==0){
671  TString str(br->GetTitle());
672  if (str[str.Length()-1]=='I') addr=new Int_t;
673  if (str[str.Length()-1]=='F') addr=new Float_t;
674  if (str[str.Length()-1]=='D') addr=new Double_t;
675  if (str[str.Length()-1]=='C') addr=new Char_t[10000];
676  if (addr) joinTree->Branch(brName, addr, brTitle);
677  br->SetAddress(addr);
678  }else{
679  TClass cclass(className);
680  TObject **addrClass = new TObject *;
681  (*addrClass)=0;
682  printf("%s\t%s\n",br->GetName(), className.Data());
683  br->SetAddress(addrClass);
684  br->GetEntry(0);
685  joinTree->Branch(brName,addrClass);
686  }
687  }
688  }
689  }
690  joinTree->Write();
691  //
692  // 4. Fill the trees
693  //
694  map<int, int>::iterator riter;
695  {for (riter=runMap.begin(); riter != runMap.end(); ++riter){
696  printf("%d\t%d\t", riter->first, riter->second);
697  jrun=riter->first;
698  for (Int_t itree=0; itree<nTrees; itree++){
699  TTree * tree = (TTree*)arrayTrees->At(itree);
700  Int_t entry= runMapTree[itree][jrun];
701  status[itree]=(entry>0)?1:0;
702  if (entry>=0) tree->GetEntry(entry);
703  printf("%d\t",entry);
704  //
705  }
706  joinTree->Fill();
707  printf("\n");
708  }}
709  fout->cd();
710  joinTree->Write(outputTree);
711  fout->Close();
712 
713 }
714 
715 
716 
717 void AliXRDPROOFtoolkit::CacheFileList(const char * fileIn, const char* cachePrefix){
723 
724  /*
725  fileIn = "TPCCPass1.list";
726  cachePrefix = "";
727  */
728  ifstream fin;
729  fin.open(fileIn);
730  ofstream fout;
731  fout.open(Form("%s.cache",fileIn));
732  ofstream foutLog;
733  foutLog.open(Form("%s.cacheLog",fileIn));
734  // Read the input list of files and add them to the chain
735  TString currentFile;
736  TString cacheFile;
737  //Int_t counter=0;
738  {while(fin.good()) {
739  TTimeStamp s;
740  TString fname;
741  fin >> currentFile;
742  fname=currentFile;
743  fname.ReplaceAll("-","_");
744  fname.ReplaceAll("/","_");
745  fname.ReplaceAll(":","_");
746  fname.ReplaceAll("~","_");
747  cacheFile=cachePrefix;
748  cacheFile+=fname;
749  printf("%s\t%s\n",currentFile.Data(),cacheFile.Data());
750  if (TFile::Cp(currentFile.Data(),cacheFile.Data())){
751  fout<<cacheFile.Data()<<"\n";
752  foutLog<<s.AsString();
753  foutLog<<cacheFile.Data()<<"n";
754  }else{
755  foutLog<<"Copy failed"<<currentFile.Data()<<cacheFile.Data()<<"\n";
756  }
757  }}
758  fout.close();
759  foutLog.close();
760 }
761 
762 
763 
764 void AliXRDPROOFtoolkit::MakeTreeFromList(const char *fout, const char * treeOut, const char * treeIn, const char * flist, Bool_t debug){
775 
776  if (debug>0){
777  printf("MakeTreeFromList\n");
778  printf("fout=%s\n",fout);
779  printf("treeOut=%s\n",treeOut);
780  printf("treeIn=%s\n",treeIn);
781  printf("fileList=%s\n",flist);
782  }
783  ifstream fin;
784  fin.open(flist);
785  ofstream foutLog;
786  foutLog.open(Form("%s.chainLog",flist));
787  // Read the input list of files and add them to the chain
788  TString currentFile;
789  Int_t counter=0;
790  Int_t nbranches=0;
791  {while(fin.good()) {
792  fin >> currentFile;
793  TFile * f = TFile::Open(currentFile.Data());
794  foutLog<<"Opening file"<<currentFile.Data();
795  if (!f) {
796  foutLog<<"Error opening file\t"<<currentFile<<"\n";
797  cout<<"Error opening file\t"<<currentFile<<"\n";
798  continue;
799  }
800  TTree * tree = (TTree*)f->Get(treeIn);
801  if (!tree) {
802  foutLog<<"Error opening tree\t"<<currentFile<<treeIn<<"\n";
803  cout<<"Error opening tree\t"<<currentFile<<treeIn<<"\n";
804  f->ls();
805  continue;
806  }
807  if (tree->GetListOfBranches()==0){
808  foutLog<<"Error opening tree\t"<<currentFile<<treeIn<<"\n";
809  cout<<"Error opening tree\t"<<currentFile<<treeIn<<"\n";
810  continue;
811  }
812  Int_t nbranchesCurrent = tree->GetListOfBranches()->GetEntries();
813  if ( nbranches ==0 ) nbranches=nbranchesCurrent;
814  if ( nbranches!=nbranchesCurrent){
815  foutLog<<"Error tree layout\t"<<currentFile<<" \t"<<treeIn<<" \t"<<nbranches<<" \t"<<nbranchesCurrent<<"\n";
816  cout<<"Error tree layout\t" <<currentFile<<" \t"<<treeIn<<" \t"<<nbranches<<" \t"<<nbranchesCurrent<<"\n";
817  }
818  counter++;
819  }
820  }
821  foutLog<<"Number of files"<<counter<<"\n";
822  cout<< "Number of files"<<counter<<"\n";
823  //
824 
825  TChain * chain = AliXRDPROOFtoolkit::MakeChain(flist,treeIn,0,1000000000,0);
826  Bool_t status=kTRUE;
827  if (!chain) status=kFALSE;
828  if (chain->GetEntries()==0) status=kFALSE;
829  if (!status){
830  printf("Incorrect list (%s) or trees (%s)", flist,treeIn);
831  return;
832  }
833  TFile *fileOut= TFile::Open(fout, "recreate");
834  TTree * tree = chain->CopyTree("1");
835  fileOut->cd();
836  tree->Write(treeOut);
837  delete tree;
838  fileOut->Close();
839  delete fileOut;
840 }
static void JoinTreesIndex(const char *outputFile, const char *outputTree, const char *indexName, const char *inputTrees, Int_t debugLevel)
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
TFile * Open(const char *filename, Long64_t &nevents)
TOOLKIT for chain manipulation:
TDSet * MakeSet(const char *fileIn, const char *treeName, const char *fName=0, Int_t maxFiles=-1)
Bool_t XRDCopyDir(const char *idir, const char *files, const char *odir, Bool_t zip)
static Bool_t FilterListZip(const char *inputList, const char *fileList, Int_t checkLevel)
#define TObjArray
static Bool_t FilterList(const char *inputList, const char *fileList, Int_t checkLevel)
TFile f("CalibObjects.root")
static void CacheFileList(const char *fileIn, const char *cachePrefix)
strP3 Tokenize("+") -> Print()
static void MakeTreeFromList(const char *fout, const char *treeOut, const char *treeIn, const char *flist, Bool_t debug)
TChain * chain
TTree * tree
TObjArray * array
Definition: AnalyzeLaser.C:12
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
TDSet * MakeSetRandom(const char *fileIn, const char *treeName, const char *fName=0, Int_t maxFiles=-1)
TFile * fout
Definition: PlotSys.C:39
static Int_t CheckTreeInFile(const char *fileName, const char *treeName, Int_t debugLevel=0, const char *branchName=0)
static TChain * MakeChainRandom(const char *fileIn, const char *treeName, const char *fName=0, Int_t maxFiles=-1, Int_t startFile=0)
Int_t str
Definition: AliFMDv1.cxx:83
Int_t debugLevel
char * fname
Int_t debug
static TChain * MakeChain(const char *fileIn, const char *treeName, const char *fName=0, Int_t maxFiles=-1, Int_t startFile=0)
return kTRUE
Definition: AliFMDv1.cxx:97