AliRoot Core  v5-06-30 (35d6c57)
 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 <AliXRDPROOFtoolkit.h>
56 
57 
61 
62 
63 
64 //______________________________________________________________________________
66  TObject () ,
67  fVerbose(kFALSE), // verbso mode - print command
68  fUserName(""), // user name
69  fUserGroup(0) // user group info
70 {
71  //
72  //
73  //
74  fUserGroup = gSystem->GetUserInfo();
75  fUserName = fUserGroup->fUser;
76  fVerbose=1;
77 }
78 
79 
80 
81 
82 
83 TChain* AliXRDPROOFtoolkit::MakeChain(const char*fileIn, const char * treeName, const char *fName, Int_t maxFiles, Int_t startFile)
84 {
94 
95  TChain* chain = new TChain(treeName);
96 
97  // Open the input stream
98  ifstream in;
99  in.open(fileIn);
100 
101  // Read the input list of files and add them to the chain
102  TString currentFile;
103  Int_t counter=0;
104  while(in.good()) {
105  in >> currentFile;
106  if (fName) {
107  currentFile+="#";
108  currentFile+=fName;
109  }
110  if (!currentFile.Contains("root")) continue; // protection
111  ++counter;
112  if (counter<=startFile) continue;
113  if ((maxFiles>0) && (counter>maxFiles+startFile)) break;
114 
115  TFile * f = TFile::Open(currentFile.Data());
116  if (f){
117  chain->Add(currentFile.Data());
118  }
119 
120  delete f;
121  }
122 
123  in.close();
124 
125  return chain;
126 }
127 
128 TChain* AliXRDPROOFtoolkit::MakeChainRandom(const char*fileIn, const char * treeName,const char *fName, Int_t maxFiles, Int_t startFile)
129 {
135 
136  TObjArray array(10000);
137 
138  TChain* chain = new TChain(treeName);
139 
140  // Open the input stream
141  ifstream in;
142  in.open(fileIn);
143 
144  // Read the input list of files and add them to the chain
145  TString currentFile;
146  Int_t counter=0;
147  while(in.good()) {
148  in >> currentFile;
149  if (fName) {
150  currentFile+="#";
151  currentFile+=fName;
152  }
153  if (!currentFile.Contains("root")) continue; // protection
154  counter++;
155  // chain->Add(currentFile.Data());
156  array.AddLast(new TObjString(currentFile));
157  }
158  in.close();
159  Int_t entries = array.GetEntries();
160  printf("Number of entries\t%d\n",entries);
161  //
162  //
163  //
164  Double_t *randomI = new Double_t[entries];
165  Int_t *indexes = new Int_t[entries];
166  for (Int_t i=0;i<entries; i++) randomI[i]=gRandom->Rndm();
167  TMath::Sort(entries,randomI,indexes);
168 
169  for (Int_t i=startFile; (i<startFile+maxFiles) && (i<entries); i++){
170  Int_t ifile = indexes[i];
171  if (ifile<entries && (array.At(ifile)) && array.At(ifile)->TestBit(TObject::kCannotPick)==kFALSE){
172  printf("%d\t%d\t%s\n",i, ifile, array.At(ifile)->GetName());
173  chain->Add(array.At(ifile)->GetName());
174  array.At(ifile)->SetBit(TObject::kCannotPick);
175  }
176  }
177  return chain;
178 }
179 
180 
181 
182 TDSet* AliXRDPROOFtoolkit::MakeSet(const char*fileIn, const char * treeName, const char *fName, Int_t maxFiles)
183 {
188 
189  TDSet* chain = new TDSet(treeName);
190 
191  // Open the input stream
192  ifstream in;
193  in.open(fileIn);
194 
195  // Read the input list of files and add them to the chain
196  TString currentFile;
197  Int_t counter=0;
198  while(in.good()) {
199  in >> currentFile;
200  if (fName) {
201  currentFile+="#";
202  currentFile+=fName;
203  }
204  if (!currentFile.Contains("root")) continue; // protection
205  counter++;
206  if (maxFiles>0 && counter>maxFiles) break;
207  chain->Add(currentFile.Data());
208  }
209 
210  in.close();
211  chain->Validate();
212  return chain;
213 }
214 
215 
216 TDSet* AliXRDPROOFtoolkit::MakeSetRandom(const char*fileIn, const char * treeName, const char *fName, Int_t maxFiles)
217 {
223 
224  TObjArray array(10000);
225 
226  TDSet* chain = new TDSet(treeName);
227 
228  // Open the input stream
229  ifstream in;
230  in.open(fileIn);
231 
232  // Read the input list of files and add them to the chain
233  TString currentFile;
234  Int_t counter=0;
235  while(in.good()) {
236  in >> currentFile;
237  if (fName) {
238  currentFile+="#";
239  currentFile+=fName;
240  }
241  if (!currentFile.Contains("root")) continue; // protection
242  counter++;
243  // chain->Add(currentFile.Data());
244  array.AddLast(new TObjString(currentFile));
245  }
246  in.close();
247  Int_t entries = array.GetEntries();
248  printf("Number of entries\t%d",entries);
249  if (maxFiles<0) maxFiles=entries;
250  if (maxFiles>entries) maxFiles=entries;
251  for (Int_t i=0; i<maxFiles; i++){
252  Int_t ifile = TMath::Nint(gRandom->Rndm()*Float_t(entries));
253  if (ifile<entries && (array.At(ifile)) && array.At(ifile)->TestBit(TObject::kCannotPick)==kFALSE){
254  printf("%d\t%d\t%s\n",i, ifile, array.At(ifile)->GetName());
255  chain->Add(array.At(ifile)->GetName());
256  array.At(ifile)->SetBit(TObject::kCannotPick);
257  }
258  }
259 
260 
261  chain->Validate();
262  return chain;
263 }
264 
265 
266 
267 
268 
269 
270 
271 Int_t AliXRDPROOFtoolkit::CheckTreeInFile(const char*fileName,const char*treeName, Int_t debugLevel, const char *branchName){
283 
284  TFile * file = TFile::Open(fileName);
285  if (!file) { return -1;}
286  if (file->IsZombie()) {file->Close(); delete file; return -2;};
287 
288  TString TrName(treeName);
289  if (TrName=="*") {
290  //cout <<" treename ==== *"<<endl;;
291  file->Close(); delete file;
292  return 0;
293  }
294  TTree * tree = (TTree*)file->Get(treeName);
295  if (!tree) {file->Close(); delete file; return -3;}
296  TBranch * branch = 0;
297  if (branchName) {
298  branch = tree->GetBranch(branchName);
299  if (!branch) {file->Close(); delete file; return -4;}
300  }
301  //
302  if (debugLevel==1 && tree->GetEntries()==0 ) return 1; //empty
303 
304  tree->SetBranchStatus("*",1);
305  try {
306  if (debugLevel>1){
307  Int_t entries = tree->GetEntries();
308  for (Int_t i=0;i<entries; i++){
309  if (branch) branch->GetEntry(i);
310  else tree->GetEntry();
311  }
312  }
313  }catch ( ... ) {
314  printf("PROBLEM\n");
315  // never catched - as there is no exception in the ROOT IO
316  file->Close(); delete file;
317  return 1 ;
318  }
319 
320  file->Close(); delete file;
321  return 0;
322 }
323 
324 
325 Bool_t AliXRDPROOFtoolkit::FilterList(const char*inputList, const char*fileList, Int_t checkLevel){
341 
342  gEnv->SetValue("TFile.Recover", 0);
343  //
344  fstream finput;
345  finput.open(inputList, ios_base::in);
346  fstream focGood;
347  fstream focBad;
348  focGood.open(Form("%s.Good",inputList), ios_base::out|ios_base::trunc);
349  focBad.open(Form("%s.Bad",inputList), ios_base::out|ios_base::trunc);
350  //
351  if(!finput.is_open()) {
352  cout<<"Can't open file "<<inputList<<endl;
353  return kFALSE;
354  }
355  //
356  // Read the input list of files and add them to the chain
357  //
358  TObjArray *array = (TString(fileList)).Tokenize(" ");
359  TString currentFile;
360  Int_t counter=0;
361  while(finput.good()) {
362  finput >> currentFile;
363  if (!currentFile.Contains("root")) continue; // protection
364  if (currentFile.Contains("alien://")){
365  focGood<<currentFile<<endl;
366  continue;
367  }
368  Bool_t isZip = currentFile.Contains("#");
369  const char * dirname = gSystem->DirName(currentFile.Data());
370  Int_t status = 0;
371  //
372  for (Int_t i=0; i<array->GetEntries(); i+=2){
373  char fname[1000];
374  if (!isZip){
375  snprintf(fname,1000, "%s/%s",dirname,array->At(i)->GetName());
376  if (((TObjString*)array->At(i))->String().Contains("*")){
377  snprintf(fname,1000, "%s", currentFile.Data());
378  }
379  }
380  if (isZip) {
381  const char * fileName = gSystem->BaseName(currentFile.Data());
382  TString fstring=fileName;
383  fstring[fstring.First("#")]=0;
384  snprintf(fname,1000, "%s/%s#%s",dirname,fstring.Data(),array->At(i)->GetName());
385  printf(fname, "To check %s%s#%s\n",dirname,fstring.Data(),array->At(i)->GetName());
386  }
387 
388  printf("\nFile to be checked %s\n",fname);
389  //cout <<"\n arguments: "<< array->At(i+1)->GetName()<<" "<<checkLevel<<endl;
390  Int_t cstatus = CheckTreeInFile(fname, array->At(i+1)->GetName(), checkLevel,0);
391  //printf(" CheckTreeInFile returns %d",cstatus);
392  if (cstatus!=0) {
393  status = cstatus;
394  break;
395  }
396  }
397  if (status==0){
398  focGood<<currentFile<<endl;
399  }else{
400  focBad<<currentFile<<endl;
401  }
402  counter++;
403  }
404  finput.close();
405  delete array;
406  return kTRUE;
407 }
408 
409 
410 Bool_t AliXRDPROOFtoolkit::FilterListZip(const char*inputList, const char*fileList, Int_t checkLevel){
426 
427  fstream finput;
428  finput.open(inputList, ios_base::in);
429  fstream focGood;
430  fstream focBad;
431  focGood.open(Form("%s.Good",inputList), ios_base::out|ios_base::trunc);
432  focBad.open(Form("%s.Bad",inputList), ios_base::out|ios_base::trunc);
433  //
434  if(!finput.is_open()) {
435  cout<<"Can't open file "<<inputList<<endl;
436  return kFALSE;
437  }
438  //
439  // Read the input list of files and add them to the chain
440  //
441  TObjArray *array = (TString(fileList)).Tokenize(" ");
442  TString currentFile;
443  Int_t counter=0;
444  while(finput.good()) {
445  finput >> currentFile;
446  if (!currentFile.Contains("root")) continue; // protection
447  if (currentFile.Contains("alien://")){
448  focGood<<currentFile<<endl;
449  continue;
450  }
451  //Bool_t isZip = currentFile.Contains("#");
452  const char * dirname = gSystem->DirName(currentFile.Data());
453  const char * fileName = gSystem->BaseName(currentFile.Data());
454  TString fstring=fileName;
455  fstring[fstring.First("#")]=0;
456  Int_t status = 0;
457  for (Int_t i=0; i<array->GetEntries(); i+=2){
458  char fname[1000];
459  //if (isZip) sprintf(fname,
460  snprintf(fname,1000, "%s/%s#%s",dirname,fstring.Data(),array->At(i)->GetName());
461  printf(fname, "To check %s%s#%s\n",dirname,fstring.Data(),array->At(i)->GetName());
462  //cout <<"\n arguments: "<< array->At(i+1)->GetName()<<" "<<checkLevel<<endl;
463  Int_t cstatus = CheckTreeInFile(fname, array->At(i+1)->GetName(), checkLevel,0);
464  //printf(" CheckTreeInFile returns %d",cstatus);
465  if (cstatus!=0) {
466  status = cstatus;
467  break;
468  }
469  }
470  if (status==0){
471  focGood<<currentFile<<endl;
472  }else{
473  focBad<<currentFile<<endl;
474  }
475  counter++;
476  }
477  finput.close();
478  return kTRUE;
479 }
480 
481 
482 
483 
484 
485 Bool_t AliXRDPROOFtoolkit::XRDCopyDir(const char * idir, const char * files, const char *odir, Bool_t /*zip*/){
496 
497  TString str(files);
498  TObjArray * array = str.Tokenize(" ");
499  Int_t nfiles = array->GetEntries();
500  char infile[1000];
501  char outfile[1000];
502  Bool_t succes=kTRUE;
503  for (Int_t ifile =0; ifile<nfiles; ifile++){
504  snprintf(infile,1000,"%s/%s", idir, array->At(ifile)->GetName());
505  snprintf(outfile,1000,"%s/%s", odir, array->At(ifile)->GetName());
506  printf("%s - %s\n",infile, outfile);
507  Bool_t result = TFile::Cp(infile,outfile);
508  succes &= result;
509  }
510  delete array;
511  return succes;
512 }
513 
514 
515 
516 void AliXRDPROOFtoolkit::JoinTreesIndex(const char * outputFile, const char * outputTree, const char *indexName, const char *inputTrees, Int_t debugLevel){
561 
562  TFile * fout = new TFile(outputFile,"recreate");
563  fout->cd();
564  TTree *joinTree=new TTree(outputTree,outputTree);
565  //
566  // 1. Define setup. parse definition string
567  //
568  TObjArray *arrayInput = TString(inputTrees).Tokenize("+");
569  Int_t nTrees = arrayInput->GetEntries();
570  TObjArray * arrayFile = new TObjArray(nTrees); // array of TFiles with trees
571  TObjArray * arrayTrees = new TObjArray(nTrees); // array of trees
572  TObjArray * arrayNames = new TObjArray(nTrees); // name of tree
573  TObjArray * arrayRunID = new TObjArray(nTrees); // name of tree
574  TArrayI arrayEnableTree(nTrees);
575  for (Int_t i=0; i<2; i++) printf("\n");
576  printf("Joing query\n");
577  arrayInput->Print();
578  for (Int_t i=0; i<2; i++) printf("\n");
579  {for (Int_t itree=0; itree<nTrees; itree++){
580  //
581  TObjArray *description = TString(arrayInput->At(itree)->GetName()).Tokenize("#");
582  if (description->GetEntries()<4) {
583  printf("Fatal: Invalid description: %s\n", arrayInput->At(itree)->GetName());
584  continue;
585  }
586  TFile * f = TFile::Open(description->At(4)->GetName());
587  if (!f){
588  printf("Fatal: Invalid description: fileName %s\n", description->At(4)->GetName());
589  delete arrayInput;
590  return;
591  }
592  arrayFile->AddAt(f,itree);
593  TTree * tree = (TTree*)f->Get(description->At(3)->GetName());
594  if (!tree){
595  printf("Fatal: Invalid description. Tree name\t%s\n", description->At(3)->GetName());
596  delete arrayInput;
597  return;
598  }
599  tree->SetCacheSize(400000000);
600  //
601  arrayTrees->AddAt(tree,itree);
602  //
603  arrayRunID->AddAt(new TObjString(description->At(2)->GetName()),itree);
604  arrayNames->AddAt(new TObjString(description->At(1)->GetName()),itree);
605  arrayEnableTree[itree]=atoi(description->At(0)->GetName());
606 
607  }}
608  //
609  delete arrayInput;
610  // 2. Make the run list
611  //
612  //
613  map<int, int> runMap;
614  map<int, int> *runMapTree = new map<int, int>[nTrees];
615  //map<int, int> runMapTree[nTrees];
616  {for (Int_t itree=0; itree<nTrees; itree++){
617  TTree * tree = (TTree*)arrayTrees->At(itree);
618  Int_t entries=tree->GetEntries();
619  char query[2000];
620  snprintf(query,2000,"%s:Entry$", arrayRunID->At(itree)->GetName());
621  entries = tree->Draw(query,"","goff");
622  for (Int_t ientry=0;ientry<entries; ientry++){
623  Int_t irun=Int_t(tree->GetV1()[ientry]);
624  // Int_t entryNr=Int_t(tree->GetV2()[ientry]);
625  if (arrayEnableTree[itree]>0) runMap[irun]+=1;
626  runMapTree[itree][irun]=ientry;
627  if (debugLevel>0) printf("%s\t%d\t%d\n",tree->GetName(), irun, runMapTree[itree][irun]);
628  }
629  }
630  }
631  //
632  // 3. Make join tree
633  //
634  Int_t jrun=0;
635  fout->cd();
636  joinTree->Branch(indexName, &jrun,Form("%s/I",indexName));
637  Int_t *status=new Int_t[nTrees];
638  char *brName = new char[10000];
639  char *brTitle= new char[10000];
640  //
641 
642  {for (Int_t itree=0; itree<nTrees; itree++){
643  TTree * tree = (TTree*)arrayTrees->At(itree);
644  tree->GetEntry(1);
645  TString treeName=arrayNames->At(itree)->GetName();
646  if (treeName.Length()>0){
647  joinTree->Branch(Form("%s.status",treeName.Data()), &status[itree],Form("%s.status/I",treeName.Data()));
648  }else{
649  joinTree->Branch("status", &status[itree],"status/I");
650  }
651  //
652  Int_t nbranches= tree->GetListOfBranches()->GetEntries();
653  for (Int_t ibr=0; ibr<nbranches; ibr++){
654  TBranch * br = (TBranch*)(tree->GetListOfBranches()->At(ibr));
655  if (treeName.Length()>0){
656  sprintf(brName,"%s.%s",treeName.Data(), br->GetName());
657  sprintf(brTitle,"%s.%s",treeName.Data(), br->GetTitle());
658  }else{
659  sprintf(brName,"%s",br->GetName());
660  sprintf(brTitle,"%s",br->GetTitle());
661  }
662  void* addr = 0;
663  TString className=br->GetClassName();
664  if (className.Length()==0){
665  TString str(br->GetTitle());
666  if (str[str.Length()-1]=='I') addr=new Int_t;
667  if (str[str.Length()-1]=='F') addr=new Float_t;
668  if (str[str.Length()-1]=='D') addr=new Double_t;
669  if (str[str.Length()-1]=='C') addr=new Char_t[10000];
670  if (addr) joinTree->Branch(brName, addr, brTitle);
671  br->SetAddress(addr);
672  }else{
673  TClass cclass(className);
674  TObject **addrClass = new TObject *;
675  (*addrClass)=0;
676  printf("%s\t%s\n",br->GetName(), className.Data());
677  br->SetAddress(addrClass);
678  br->GetEntry(0);
679  joinTree->Branch(brName,addrClass);
680  }
681  }
682  }
683  }
684  joinTree->Write();
685  //
686  // 4. Fill the trees
687  //
688  map<int, int>::iterator riter;
689  {for (riter=runMap.begin(); riter != runMap.end(); ++riter){
690  printf("%d\t%d\t", riter->first, riter->second);
691  jrun=riter->first;
692  for (Int_t itree=0; itree<nTrees; itree++){
693  TTree * tree = (TTree*)arrayTrees->At(itree);
694  Int_t entry= runMapTree[itree][jrun];
695  status[itree]=(entry>0)?1:0;
696  if (entry>=0) tree->GetEntry(entry);
697  printf("%d\t",entry);
698  //
699  }
700  joinTree->Fill();
701  printf("\n");
702  }}
703  fout->cd();
704  joinTree->Write(outputTree);
705  fout->Close();
706 
707 }
708 
709 
710 
711 void AliXRDPROOFtoolkit::CacheFileList(const char * fileIn, const char* cachePrefix){
717 
718  /*
719  fileIn = "TPCCPass1.list";
720  cachePrefix = "";
721  */
722  ifstream fin;
723  fin.open(fileIn);
724  ofstream fout;
725  fout.open(Form("%s.cache",fileIn));
726  ofstream foutLog;
727  foutLog.open(Form("%s.cacheLog",fileIn));
728  // Read the input list of files and add them to the chain
729  TString currentFile;
730  TString cacheFile;
731  //Int_t counter=0;
732  {while(fin.good()) {
733  TTimeStamp s;
734  TString fname;
735  fin >> currentFile;
736  fname=currentFile;
737  fname.ReplaceAll("-","_");
738  fname.ReplaceAll("/","_");
739  fname.ReplaceAll(":","_");
740  fname.ReplaceAll("~","_");
741  cacheFile=cachePrefix;
742  cacheFile+=fname;
743  printf("%s\t%s\n",currentFile.Data(),cacheFile.Data());
744  if (TFile::Cp(currentFile.Data(),cacheFile.Data())){
745  fout<<cacheFile.Data()<<"\n";
746  foutLog<<s.AsString();
747  foutLog<<cacheFile.Data()<<"n";
748  }else{
749  foutLog<<"Copy failed"<<currentFile.Data()<<cacheFile.Data()<<"\n";
750  }
751  }}
752  fout.close();
753  foutLog.close();
754 }
755 
756 
757 
758 void AliXRDPROOFtoolkit::MakeTreeFromList(const char *fout, const char * treeOut, const char * treeIn, const char * flist, Bool_t debug){
769 
770  if (debug>0){
771  printf("MakeTreeFromList\n");
772  printf("fout=%s\n",fout);
773  printf("treeOut=%s\n",treeOut);
774  printf("treeIn=%s\n",treeIn);
775  printf("fileList=%s\n",flist);
776  }
777  ifstream fin;
778  fin.open(flist);
779  ofstream foutLog;
780  foutLog.open(Form("%s.chainLog",flist));
781  // Read the input list of files and add them to the chain
782  TString currentFile;
783  Int_t counter=0;
784  Int_t nbranches=0;
785  {while(fin.good()) {
786  fin >> currentFile;
787  TFile * f = TFile::Open(currentFile.Data());
788  foutLog<<"Opening file"<<currentFile.Data();
789  if (!f) {
790  foutLog<<"Error opening file\t"<<currentFile<<"\n";
791  cout<<"Error opening file\t"<<currentFile<<"\n";
792  continue;
793  }
794  TTree * tree = (TTree*)f->Get(treeIn);
795  if (!tree) {
796  foutLog<<"Error opening tree\t"<<currentFile<<treeIn<<"\n";
797  cout<<"Error opening tree\t"<<currentFile<<treeIn<<"\n";
798  f->ls();
799  continue;
800  }
801  if (tree->GetListOfBranches()==0){
802  foutLog<<"Error opening tree\t"<<currentFile<<treeIn<<"\n";
803  cout<<"Error opening tree\t"<<currentFile<<treeIn<<"\n";
804  continue;
805  }
806  Int_t nbranchesCurrent = tree->GetListOfBranches()->GetEntries();
807  if ( nbranches ==0 ) nbranches=nbranchesCurrent;
808  if ( nbranches!=nbranchesCurrent){
809  foutLog<<"Error tree layout\t"<<currentFile<<" \t"<<treeIn<<" \t"<<nbranches<<" \t"<<nbranchesCurrent<<"\n";
810  cout<<"Error tree layout\t" <<currentFile<<" \t"<<treeIn<<" \t"<<nbranches<<" \t"<<nbranchesCurrent<<"\n";
811  }
812  counter++;
813  }
814  }
815  foutLog<<"Number of files"<<counter<<"\n";
816  cout<< "Number of files"<<counter<<"\n";
817  //
818 
819  TChain * chain = AliXRDPROOFtoolkit::MakeChain(flist,treeIn,0,1000000000,0);
820  Bool_t status=kTRUE;
821  if (!chain) status=kFALSE;
822  if (chain->GetEntries()==0) status=kFALSE;
823  if (!status){
824  printf("Incorrect list (%s) or trees (%s)", flist,treeIn);
825  return;
826  }
827  TFile *fileOut= TFile::Open(fout, "recreate");
828  TTree * tree = chain->CopyTree("1");
829  fileOut->cd();
830  tree->Write(treeOut);
831  delete tree;
832  fileOut->Close();
833  delete fileOut;
834 }
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))
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 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)