1 #if !defined( __CINT__) || defined(__MAKECINT__)
11 #include <AliCDBManager.h>
12 #include <../TRD/AliTRDCalibra.h>
17 void AliTRDMergeFilesHisto2D(const char* variablecali, const char* nome, const char* dire){
19 // After having simulated and reconstructed events in subrepertories 000%d of dire
20 // this macro searchs in the subdirectories the file TRD.calibration.root
21 // takes the 2D histos and merge them
22 // nome is the name of the file where the sum will be written
23 // variablecali can be: CH2d, PH2d, PRF2d
34 const char *name="TRD.calibration.root";
35 const char *patterndir="0";
36 const char *namesubdir = 0x0;
39 //Open the current directory
40 void * dircu = gSystem->OpenDirectory(dire);
41 while((namesubdir = gSystem->GetDirEntry(dircu))) {
42 if(strstr(namesubdir,patterndir)) {
43 sprintf(dir,"%s/%s",dire,namesubdir);
44 printf("process subdirectories: %s\n",dir);
46 //full name of the file and tree
47 char fullname[255] = "";
49 sprintf(fullname,"%s/%s",dir,name);
50 printf("Process file: %s\n",fullname);
51 TFile *file = (TFile *) TFile::Open(fullname,"READ");
53 TH2 *histo = (TH2 *) file->Get(variablecali);
54 histo->SetDirectory(0);
56 if(j == 0) histosum = histo;
57 else histosum->Add(histo,1);
61 }//loop in the current directory
64 //Open a file to put the histosum
65 TFile *fout = TFile::Open((const char*) nome ,"UPDATE");
66 fout->WriteTObject(histosum,histosum->GetName(),(Option_t *) "kOverWrite");