update trending infrastructure
[u/mrichter/AliRoot.git] / PWGPP / TRD / macros / makeTrendingDB.C
CommitLineData
847569f2 1void makeTrendingDB(const Char_t *fl)
2{
3// Make trending of variable list "tl" from trending file list "fl"
4// The trending value list should be formated "var1:var2:var3"
5// The trending file from the list should be found on a path formated "your path"/runId/TRD.PerformanceTrend.root
6 gSystem->Load("libANALYSIS.so");
7 gSystem->Load("libANALYSISalice.so");
8 gSystem->Load("libTENDER.so");
9 gSystem->Load("libCORRFW.so");
10 gSystem->Load("libPWGPP.so");
11 gSystem->Load("libPWGmuon.so");
12
13 const Int_t nt(45);
14 const Char_t *tvn[nt][2] = {
15 {"TRDcheckDET_NTracksEvent", "<N_{track}/Event>"},
16 {"TRDcheckDET_NTracksEventRMS", "RMS(N_{track}/Event)"},
17 {"TRDcheckDET_NTracksSector", "<N_{track}/Sector>"},
18 {"TRDcheckDET_NClustersTrack", "<N_{cls}/Track>"},
19 {"TRDcheckDET_NClustersTrackRMS", "RMS(N_{cls}/Track)"},
20 {"TRDcheckDET_NClustersTracklet", "<N_{cls}/Tracklet>"},
21 {"TRDcheckDET_NClustersTrackletRMS", "RMS(N_{cls}/Tracklet)"},
22 {"TRDcheckDET_NTrackletsTrack", "<N_{tracklet}/Track>"},
23 {"TRDcheckDET_NTrackletsTrackRMS", "RMS(N_{tracklet}/Track)"},
24 {"TRDcheckDET_ChargeTracklet", "<dQdl>"},
25 {"TRDcheckDET_ChargeTrackletRMS", "RMS(dQdl)"},
26 {"TRDcheckDET_PHplateau", "Plateau(<PH>)"},
27 {"TRDcheckDET_PHslope", "Slope(<PH>)"},
28 {"TRDcheckDET_PHamplificationPeak", "Peak(<PH>)"},
29//=======================================================
30 {"TRDresolution_TrkInY", "#Deltay (TrkIn)"},
31 {"TRDresolution_TrkInYn", "#Deltay^{-} (TrkIn)"},
32 {"TRDresolution_TrkInYp", "#Deltay^{+} (TrkIn)"},
33 {"TRDresolution_TrkInRCZ", "#Deltaz (TrkIn)"},
34 {"TRDresolution_TrkInPhn", "#Delta#phi^{-} (TrkIn)"},
35 {"TRDresolution_TrkInPhp", "#Delta#phi^{+} (TrkIn)"},
36 {"TRDresolution_TrkInQp0", "MPV(dQdl^{e+}) (TrkIn)"},
37 {"TRDresolution_TrkInQp1", "MPV(dQdl^{#mu+}) (TrkIn)"},
38 {"TRDresolution_TrkInQp2", "MPV(dQdl^{#pi+}) (TrkIn)"},
39 {"TRDresolution_TrkInQp3", "MPV(dQdl^{K+}) (TrkIn)"},
40 {"TRDresolution_TrkInQp4", "MPV(dQdl^{p+}) (TrkIn)"},
41 {"TRDresolution_TrkInQn0", "MPV(dQdl^{e-}) (TrkIn)"},
42 {"TRDresolution_TrkInQn1", "MPV(dQdl^{#mu-}) (TrkIn)"},
43 {"TRDresolution_TrkInQn2", "MPV(dQdl^{#pi-}) (TrkIn)"},
44 {"TRDresolution_TrkInQn3", "MPV(dQdl^{K-}) (TrkIn)"},
45 {"TRDresolution_TrkInQn4", "MPV(dQdl^{p-}) (TrkIn)"},
46 {"TRDresolution_TrkInQ0", "MPV(dQdl^{e}) (TrkIn)"},
47 {"TRDresolution_TrkInQ1", "MPV(dQdl^{#mu}) (TrkIn)"},
48 {"TRDresolution_TrkInQ2", "MPV(dQdl^{#pi}) (TrkIn)"},
49 {"TRDresolution_TrkInQ3", "MPV(dQdl^{K}) (TrkIn)"},
50 {"TRDresolution_TrkInQ4", "MPV(dQdl^{p}) (TrkIn)"},
51 {"TRDresolution_TrkInQSp0", "<dQdl^{e+}> (TrkIn)"},
52 {"TRDresolution_TrkInQSp1", "<dQdl^{#mu+}> (TrkIn)"},
53 {"TRDresolution_TrkInQSp2", "<dQdl^{pi+}> (TrkIn)"},
54 {"TRDresolution_TrkInQSp3", "<dQdl^{K+}> (TrkIn)"},
55 {"TRDresolution_TrkInQSp4", "<dQdl^{p+}> (TrkIn)"},
56 {"TRDresolution_TrkInQSn0", "<dQdl^{e-}> (TrkIn)"},
57 {"TRDresolution_TrkInQSn1", "<dQdl^{#mu-}> (TrkIn)"},
58 {"TRDresolution_TrkInQSn2", "<dQdl^{#pi-}> (TrkIn)"},
59 {"TRDresolution_TrkInQSn3", "<dQdl^{K-}> (TrkIn)"},
60 {"TRDresolution_TrkInQSn4", "<dQdl^{p-}> (TrkIn)"}
61 };
62 const char *resName[] = {"Markus Fasel", "Alexandru Bercuci"},
63 *resMail[] = {"M.Fasel@gsi.de", "A.Bercuci@gsi.de"};
64 const char *notName[] = {"Julian Book", "Hans Beck", "Ionut Arsene", "Raphaelle Bailache", "Christoph Blume"},
65 *notMail[] = {"jbook@ikf.uni-frankfurt.de", "hbeck@ikf.uni-frankfurt.de", "I.C.Arsene@gsi.de", "R.Bailhache@gsi.de", "blume@ikf.uni-frankfurt.de"};
66
67 TFile *fDB = TFile::Open("TRD.TrendDB.root", "RECREATE");
68 TTree *tDB = new TTree("trend", "Reference Trend Values");
69 Double_t val[nt];
70 for(Int_t it(0); it<nt; it++) tDB->Branch(tvn[it][0], &val[it], Form("%s/D", tvn[it][0]));
71 gROOT->cd();
72
73 AliTRDtrendValue *tv(NULL);
74 FILE *fp = fopen(fl, "rt");
75 TString sfp;
76 while(sfp.Gets(fp)){
77 if(!TFile::Open(sfp.Data())) continue;
78 for(Int_t it(0); it<nt; it++){
79 val[it] = -999;
80 if(!(tv = (AliTRDtrendValue*)gFile->Get(tvn[it][0]))) {
81 Warning("makeTrendingDB()", "Missing %s", tvn[it][0]);
82 continue;
83 }
84 val[it] = tv->GetVal();
85 }
86 gFile->Close();
87 tDB->Fill();
88 }
89
90
91// TFile *fDB = TFile::Open("TRD.TrendDB.root");
92// TTree *tDB = (TTree*)gFile->Get("trend");
93// Double_t val[nt];
94// for(Int_t it(0); it<nt; it++) tDB->SetBranchAddress(tvn[it][0], &val[it]);
95// gROOT->cd();
96
97 TString res[] = {Form("%s/%s", resName[0], resMail[0]), Form("%s/%s", resName[1], resMail[1])};
98 TString notifiable;
99 for(Int_t inot(0); inot<5; inot++){
100 notifiable+=notName[inot];
101 notifiable+="/";
102 notifiable+=notMail[inot];
103 if(inot<4) notifiable+=",";
104 }
105 AliTRDtrendingManager *tm = AliTRDtrendingManager::Instance();
106 TCanvas *c = new TCanvas("c", "Trend Distrib.", 10, 10, 500, 500);
107 for(Int_t it(0); it<nt; it++){
108 tDB->Draw(tvn[it][0]);
109 TH1 *h = (TH1*)gROOT->FindObject("htemp");
110 h->Fit("gaus", "WQ");
111 c->Modified(); c->Update(); c->SaveAs(Form("%s.gif", tvn[it][0]));
112
113 // write trending value to manager
114 TF1 *f = h->GetFunction("gaus");
115 printf("%s %f[%f] %f[%f]\n", tvn[it][0], h->GetMean(), f->GetParameter(1), h->GetRMS(), f->GetParameter(2));
116 tm->AddValue(tvn[it][0], h->GetMean()/*f->GetParameter(1)*/, h->GetRMS()/*f->GetParameter(2)*/,
117 tvn[it][1], res[it>13], notifiable);
118 }
119 tm->Terminate();
120
121 fDB->cd();
122 tDB->Write();
123 fDB->Close();
124}