]>
Commit | Line | Data |
---|---|---|
581ebeaa | 1 | /* |
32743ed6 | 2 | // Macro for merging of the calibration classes: |
3 | // marain.ivanov@cern.ch | |
4 | // // | |
5 | // // | |
6 | // Example usage: | |
7 | // 1. Make a list of the calibration files | |
8 | // 2. Load libraries | |
9 | // 3. Merge - the output is stored in the current directory | |
10 | // // | |
11 | // | |
12 | gSystem->AddIncludePath("-I$ALICE_ROOT/TPC") | |
13 | gSystem->Load("libANALYSIS"); | |
14 | gSystem->Load("libTPCcalib"); | |
15 | .L $ALICE_ROOT/TPC/macros/CalibFileMerger.C+g | |
16 | // CalibFileMerger(); | |
581ebeaa | 17 | */ |
18 | ||
6a59221c | 19 | #include <fstream> |
32743ed6 | 20 | #include "TSystem.h" |
6a59221c | 21 | #include "TFile.h" |
22 | #include "TObjArray.h" | |
23 | #include "AliSysInfo.h" | |
24 | #include "AliTPCcalibBase.h" | |
581ebeaa | 25 | |
32743ed6 | 26 | void CalibFileMerger(const char *oname, Int_t nmax=1000,const char* filename = "mergelist.txt") { |
581ebeaa | 27 | |
32743ed6 | 28 | gSystem->Load("libANALYSIS"); |
29 | gSystem->Load("libTPCcalib"); | |
6a59221c | 30 | TObjArray * mergeArray= 0; |
31 | // | |
581ebeaa | 32 | // Open the input stream |
33 | ifstream in; | |
34 | in.open(filename); | |
35 | ||
36 | // Read the input list of files | |
37 | TString objfile; | |
38 | Int_t counter=0; | |
39 | while(in.good()) { | |
40 | in >> objfile; | |
41 | if (!objfile.Contains("root")) continue; // protection | |
42 | TFile currentFile(objfile.Data()); | |
6a59221c | 43 | printf("Open file:Counter\t%d\tMerging file %s\n",counter,objfile.Data()); |
581ebeaa | 44 | TObjArray * carray = (TObjArray*)currentFile.Get("TPCCalib"); |
32743ed6 | 45 | if (!carray) { |
46 | carray = new TObjArray; | |
47 | TList *farr = currentFile.GetListOfKeys(); | |
48 | if (!farr) continue; | |
49 | for (Int_t ical=0; ical<farr->GetEntries(); ical++){ | |
50 | if (!farr->At(ical)) continue; | |
51 | TObject *obj = currentFile.Get(farr->At(ical)->GetName()); | |
52 | if (obj) carray->AddLast(obj); | |
53 | AliSysInfo::AddStamp(farr->At(ical)->GetName(),1,ical,counter); | |
54 | // reading entries | |
55 | } | |
56 | if (carray->GetEntries()==0) continue; | |
57 | } | |
58 | ||
581ebeaa | 59 | if (!mergeArray) { mergeArray = carray; continue;} |
60 | printf("Counter\t%d\tMerging file %s\n",counter,objfile.Data()); | |
61 | for (Int_t icalib=0; icalib<mergeArray->GetEntries(); icalib++){ | |
62 | AliTPCcalibBase *calib = ( AliTPCcalibBase *)mergeArray->At(icalib); | |
63 | //disable calib align | |
32743ed6 | 64 | if (!calib->InheritsFrom("AliTPCcalibBase")) continue; |
65 | if (calib->InheritsFrom("AliTPCcalibTrigger")) continue; // too big | |
66 | // | |
67 | // if (counter>50&&counter%2>0){ | |
68 | // if (calib->InheritsFrom("AliTPCcalibCosmic")) continue; // too big | |
69 | // } | |
70 | // if (counter>100&&counter%4>0){ | |
71 | // if (calib->InheritsFrom("AliTPCcalibCosmic")) continue; // too big | |
72 | // } | |
73 | // if (counter>200&&counter%8>0){ | |
74 | // if (calib->InheritsFrom("AliTPCcalibCosmic")) continue; // too big | |
75 | // } | |
6a59221c | 76 | if (!calib) continue; |
77 | printf("Merging\t%s\n",calib->GetName()); | |
78 | TObjArray toMerge(1); | |
79 | TObject *objectMerge = carray->FindObject(calib->GetName()); | |
80 | if (!objectMerge) { | |
81 | printf("Object not found\n"); | |
82 | continue; | |
83 | } | |
84 | toMerge.AddAt(objectMerge,0); | |
85 | toMerge.SetOwner(kFALSE); | |
86 | calib->Merge(&toMerge); | |
32743ed6 | 87 | AliSysInfo::AddStamp(calib->GetName(),2,icalib,counter); |
581ebeaa | 88 | } |
6a59221c | 89 | AliSysInfo::AddStamp(objfile.Data(),counter,counter,counter); |
32743ed6 | 90 | if (carray){ |
91 | carray->SetOwner(kTRUE); | |
92 | carray->Delete(); | |
93 | // for (Int_t i=0; i<carray->GetEntriesFast(); i++){ | |
94 | // TObject *o = carray->At(i); | |
95 | // if (!o) continue; | |
96 | // printf("Delete %s\n",o->GetName()); | |
97 | // AliSysInfo::AddStamp(o->GetName(),3,i,counter); | |
98 | // delete o; | |
99 | // } | |
100 | delete carray; | |
101 | } | |
581ebeaa | 102 | counter++; |
6a59221c | 103 | currentFile.Close(); |
104 | if (counter>nmax) break; | |
581ebeaa | 105 | } |
106 | ||
107 | in.close(); | |
32743ed6 | 108 | if (mergeArray){ |
109 | for (Int_t icalib=0; icalib<mergeArray->GetEntries(); icalib++){ | |
110 | TFile * output = new TFile(oname, "UPDATE"); | |
111 | TObject * obj = mergeArray->At(icalib); | |
112 | if (!obj) continue; | |
113 | obj->Write(); | |
114 | delete obj; | |
115 | output->Close(); | |
116 | } | |
117 | } | |
581ebeaa | 118 | // |
32743ed6 | 119 | // problem to stop root |
120 | // Make suicide | |
121 | // | |
122 | printf("Kill ourself\n"); | |
123 | printf("Kill ourself\n"); | |
124 | printf("Kill ourself\n"); | |
125 | printf("Kill ourself\n"); | |
126 | gSystem->Exec(Form("kill -9 %d",gSystem->GetPid())); | |
581ebeaa | 127 | } |
128 | ||
581ebeaa | 129 |