]> git.uio.no Git - u/mrichter/AliRoot.git/blob - OADB/PWGLF/FORWARD/FMDEVENTPLANE/macros/UpdateEventplaneOADB.C
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / OADB / PWGLF / FORWARD / FMDEVENTPLANE / macros / UpdateEventplaneOADB.C
1 void UpdateEventplaneOADB(TString oadbname, const char* updatename, Int_t runBegin = 0, Int_t runEnd = 0)
2 {
3
4   Bool_t newcont = kFALSE;
5   
6   if (!runBegin || !runEnd) newcont = kTRUE;
7   
8   TFile* oadb = 0; 
9   if (oadbname.Length() > 0.) oadb = TFile::Open(oadbname, "READ");
10   TFile* in   = TFile::Open(updatename);
11
12   AliOADBContainer* cont = 0;
13   if (oadb) cont = (AliOADBContainer*)oadb->Get("FMDphidist");
14   if (!cont) {
15     if (newcont) cont = new AliOADBContainer("FMDphidist");
16     else         Fatal("Something is wrong. There is no container, but you supplied a runrange...\n");
17   }
18
19   TList* list   = (TList*)in->Get("Forward");
20   TList* eplist = (TList*)list->FindObject("fmdEventPlaneFinder");
21   TH1D*  hist   = (TH1D*) eplist->FindObject("hPhiDist");
22
23   if (!newcont) {
24     hist->SetName(Form("%d-%d", runBegin, runEnd));
25     cont->AppendObject(hist, runBegin, runEnd);
26   }
27   else {
28     hist->SetName("Default");
29     cont->AddDefaultObject(hist);
30   }
31
32   TFile* out = TFile::Open("new_fmdEPoadb.root", "RECREATE");
33   out->Close();
34
35   cont->WriteToFile("new_fmdEPoadb.root");
36
37   Printf("Wrote new OADB object to file new_%s, please check that everything is OK and replace the old file", oadbname);
38
39   out = TFile::Open("new_fmdEPoadb.root");
40   new TBrowser();
41
42 }