]>
Commit | Line | Data |
---|---|---|
0bca1a77 | 1 | #if !defined(__CINT__) || defined(__MAKECINT__) |
2 | #include <TFile.h> | |
3 | #include <TFileMerger.h> | |
4 | #include <TAlienFile.h> | |
5 | //#include <TExec.h> | |
6 | #include <TSystem.h> | |
7 | #include <TGrid.h> | |
8 | #include <TGridResult.h> | |
9 | #include <Riostream.h> | |
10 | #include <TObjArray.h> | |
11 | #include <TClass.h> | |
12 | #endif | |
88522cc1 | 13 | void ReadQASDD(Int_t runNb = 101498,Int_t year=2009,Char_t period[10]="LHC09c",Char_t pass[8]="pass1",Int_t maxfiles=300,Char_t filetosearch[50]="Merged.QA.Data.root",Char_t initfileout[50]="File.QA") |
0bca1a77 | 14 | { |
15 | ||
2a250bc5 | 16 | //****************** Connection to alien ***************************************** |
17 | gSystem->Load("libNetx.so") ; | |
18 | gSystem->Load("libRAliEn.so"); | |
0bca1a77 | 19 | TGrid::Connect("alien://",0,0,"t"); |
20 | //TGrid *gGrid = TGrid::Connect("alien"); | |
21 | if(!gGrid||!gGrid->IsConnected()) { | |
22 | printf("gGrid not found! exit macro\n"); | |
23 | return; | |
24 | } | |
25 | ||
26 | TFileMerger merger; | |
27 | merger.SetFastMethod(kTRUE); | |
28 | Char_t fileName[100]; | |
29 | Char_t directory[100]; | |
30 | sprintf(fileName,"%s.%i.%s.%s.Run.%i.root",initfileout,year,period,pass,runNb); | |
31 | merger.OutputFile(fileName);//metto il nome del file QA | |
32 | //sprintf(directory,"local://%s",gSystem->pwd()); | |
33 | Char_t path[200]; | |
34 | ||
35 | sprintf(path,"/alice/data/%04i/%s/%09i/ESDs/%s/%02i%09i*.*",year,period,runNb,pass,year-2000,runNb); | |
36 | printf("path %s\n",path); | |
37 | ||
38 | TGridResult *gr = gGrid->Query(path,filetosearch); | |
39 | if (gr->GetEntries() < 1) { | |
40 | printf("In this run there are not QA files: Exit macro\n"); | |
41 | return; | |
42 | } | |
43 | else{printf("================>%d files found\n", gr->GetEntries());} | |
44 | ||
45 | Int_t mergedFiles = 0; | |
46 | Int_t nFiles = gr->GetEntries(); | |
88522cc1 | 47 | if(nFiles>maxfiles) nFiles=maxfiles; |
48 | for (Int_t i = 3; i <nFiles ; i++) { | |
2a250bc5 | 49 | printf("File %i/%i\n",i+1,nFiles); |
50 | sprintf(directory,"%s",gr->GetKey(i,"turl")); | |
51 | printf("%s\n\n", directory); | |
52 | if(i==0) | |
53 | { | |
54 | TFile *checkfile=TFile::Open(directory); | |
55 | if(checkfile->GetKey("ITS")==0x0){ | |
56 | printf("file: %s \n Run %d, In this run ITS QA has not been executed.-- Exit macro\n",directory, runNb); | |
57 | break; | |
58 | //mergedFiles=-1; | |
59 | } | |
60 | checkfile->Close(); | |
61 | delete checkfile; | |
62 | checkfile=NULL; | |
63 | } | |
64 | if (merger.AddFile(directory)) | |
65 | mergedFiles++; | |
0bca1a77 | 66 | } |
2a250bc5 | 67 | // ------------------------------in this section we create a file that will contain the number of chunks to normalize later |
68 | if(mergedFiles>0){ | |
69 | FILE * pChunkNumber; | |
70 | pChunkNumber = fopen ("ChunkNumber.txt","w+"); | |
71 | fprintf (pChunkNumber, "%f\n", mergedFiles); | |
72 | fclose (pChunkNumber); | |
73 | ||
74 | //printf("Add done\n"); | |
75 | if(merger.Merge()==kTRUE){ | |
76 | printf("merged %d files\n", mergedFiles); | |
77 | printf("output written on %s\n", fileName); | |
78 | printf("Merge done!\n"); | |
79 | } | |
80 | else{printf("no files merged\n");return;} | |
81 | } | |
0bca1a77 | 82 | else{printf("no files merged\n");return;} |
0bca1a77 | 83 | } |