First implementation of EMCAL trigger QA from Nicola Arbor
[u/mrichter/AliRoot.git] / ZDC / PlotPedestalsvsTime.C
CommitLineData
8d03668d 1#if !defined(__CINT__) || defined(__MAKECINT__)
2#include <Riostream.h>
3#include <TSystem.h>
4#include <TRandom.h>
5#include <TROOT.h>
6#include <TStyle.h>
7#include <TCanvas.h>
8#include <TGraphErrors.h>
9#include <TGrid.h>
10#include <TFile.h>
11#include "AliCDBEntry.h"
12#include "AliCDBGrid.h"
13#include "AliCDBId.h"
14#include "AliCDBLocal.h"
15#include "AliCDBManager.h"
16#include "AliCDBMetaData.h"
17#include "AliCDBPath.h"
18#include "AliCDBRunRange.h"
19#include "AliCDBStorage.h"
20#include "AliDCSValue.h"
21#include "AliZDC.h"
22#include "AliZDCv3.h"
23#include "AliZDCPedestals.h"
24#include "AliZDCEnCalib.h"
25#include "AliZDCTowerCalib.h"
26#include "AliZDCChMap.h"
27#include "AliZDCLaserCalib.h"
28#include "AliZDCMBCalib.h"
29#include "AliZDCDataDCS.h"
30
31#endif
32
33
dcb6916a 34void PlotPedestalsvsTime(Int_t year=2011, Int_t firstRun=141820,
35 Int_t lastRun=146900, Int_t ipedGainChain=0)
8d03668d 36{
37
38
39 TGrid::Connect("alien:",0,0,"t");
40 gSystem->Exec(Form("gbbox find \"/alice/data/%d/OCDB/ZDC/Calib/Pedestals/\" \"Run*.root\" > calibAlienFiles.txt",year));
41 FILE* listruns=fopen("calibAlienFiles.txt","r");
42
43 const int kNchannels=24;
44 TGraphErrors* graph[24];
45 for(Int_t i=0; i<kNchannels; i++){
46 graph[i] = new TGraphErrors(0);
47 char name[50], title[50];
48 sprintf(name,"graph%d",i); sprintf(title,"Pedestal ch.%d vs. run#",i);
49 graph[i]->SetName("graph"); graph[i]->SetTitle("title");
50 }
51
52 Char_t filnam[200], filnamalien[200];
53 Int_t iPoint=0;
54 Int_t nrun, nrun2, nv, ns;
55
56 while(!feof(listruns)){
57 int st = fscanf(listruns,"%s\n",filnam);
58 Char_t directory[100];
59 sprintf(directory,"/alice/data/%d",year);
60 if(!strstr(filnam,directory)) continue;
61 sscanf(filnam,"/alice/data/%d/OCDB/ZDC/Calib/Pedestals/Run%d_%d_v%d_s%d.root",&year,&nrun,&nrun2,&nv,&ns);
62 if(nrun<firstRun) continue;
63 if(nrun>lastRun) continue;
64 sprintf(filnamalien,"alien://%s",filnam);
65 printf("Opening file: %s\n",filnam);
66 TFile *f = TFile::Open(filnamalien);
67 AliCDBEntry *entry = (AliCDBEntry*)f->Get("AliCDBEntry");
68 AliZDCPedestals *calibdata = dynamic_cast<AliZDCPedestals*> (entry->GetObject());
69
70 for(int i=0; i<kNchannels; i++){
c015fa8d 71 if(ipedGainChain==0){
72 graph[i]->SetPoint(iPoint, (Double_t)nrun, calibdata->GetMeanPed(i));
73 graph[i]->SetPointError(iPoint, 0., calibdata->GetMeanPedWidth(i));
74 }
75 else{
76 graph[i]->SetPoint(iPoint, (Double_t)nrun, calibdata->GetMeanPed(i+kNchannels));
77 graph[i]->SetPointError(iPoint, 0., calibdata->GetMeanPedWidth(i+kNchannels));
78 }
8d03668d 79 }
80 iPoint++;
81 f->Close();
82 }
83
84 TFile *outfile=new TFile(Form("Calib%dVsTime.root",year),"recreate");
85 outfile->cd();
86 for(int i=0; i<kNchannels; i++) graph[i]->Write();
87 outfile->Close();
88
89 //***********************************************************
90 // #### ROOT initialization
91 gROOT->Reset();
92 gStyle->SetCanvasColor(10);
93 gStyle->SetFrameFillColor(10);
94 gStyle->SetOptTitle(0);
95 gStyle->SetOptStat(1111);
96 gStyle->SetOptFit(0);
97 gStyle->SetTitleTextColor(4);
98 gStyle->SetStatTextColor(4);
99 gStyle->SetStatX(0.92);
100 gStyle->SetStatY(0.92);
101 gStyle->SetLineColor(1);
102 gStyle->SetPalette(1);
103 gStyle->SetPadTopMargin(0.05);
104 gStyle->SetPadRightMargin(0.05);
105 gStyle->SetPadBottomMargin(0.09);
106 gStyle->SetPadLeftMargin(0.09);
107 gStyle->SetTitleOffset(1.1,"Y");
108 // *************************************************************
109
dcb6916a 110 TCanvas *cHadPeds = new TCanvas("cHadPeds","Hadronic ZDC pedestals",0,0,1000,800);
8d03668d 111 cHadPeds->Divide(5,4);
112 for(int ic=0; ic<5; ic++){
113 // *** ZNC pedestals
114 cHadPeds->cd(ic+1);
115 //
c015fa8d 116 TH1F *haxis1=0;
dcb6916a 117 if(ipedGainChain==0){
118 if(ic==0) haxis1 = gPad->DrawFrame(firstRun-100, 80, lastRun+100, 100);
119 else haxis1 = gPad->DrawFrame(firstRun-100, 50, lastRun+100, 70);
120 }
121 else{
122 if(ic==0) haxis1 = gPad->DrawFrame(firstRun-100, 500, lastRun+100, 800);
123 else haxis1 = gPad->DrawFrame(firstRun-100, 300, lastRun+100, 600);
124 }
8d03668d 125 haxis1->GetXaxis()->SetNoExponent();
126 haxis1->SetXTitle("RUN no.");
127 haxis1->SetYTitle("ZNC pedestals");
128 //
129 graph[ic]->SetMarkerStyle(20);
130 graph[ic]->SetMarkerColor(kBlue);
c015fa8d 131 graph[ic]->Draw("P, SAME");
8d03668d 132 // *** ZPC pedestals
133 cHadPeds->cd(ic+6);
134 //
c015fa8d 135 TH1F *haxis2=0;
dcb6916a 136 if(ipedGainChain==0) haxis2= gPad->DrawFrame(firstRun-100, 55, lastRun+100, 85);
137 else haxis2 = gPad->DrawFrame(firstRun-100, 400, lastRun+100, 700);
8d03668d 138 haxis2->GetXaxis()->SetNoExponent();
139 haxis2->SetXTitle("RUN no.");
140 haxis2->SetYTitle("ZPC pedestals");
141 //
142 graph[ic+5]->SetMarkerStyle(21);
143 graph[ic+5]->SetMarkerColor(kBlue+3);
c015fa8d 144 graph[ic+5]->Draw("P, SAME");
8d03668d 145 // *** ZNA pedestals
146 cHadPeds->cd(ic+11);
147 //
c015fa8d 148 TH1F *haxis3=0;
dcb6916a 149 if(ipedGainChain==0) haxis3 = gPad->DrawFrame(firstRun-100, 35, lastRun+100, 85);
150 else haxis3 = gPad->DrawFrame(firstRun-100, 300, lastRun+100, 700);
8d03668d 151 haxis3->GetXaxis()->SetNoExponent();
152 haxis3->SetXTitle("RUN no.");
153 haxis3->SetYTitle("ZNA pedestals");
154 //
155 graph[ic+12]->SetMarkerStyle(20);
156 graph[ic+12]->SetMarkerColor(kRed);
c015fa8d 157 graph[ic+12]->Draw("P, SAME");
8d03668d 158 // *** ZPA pedestals
159 cHadPeds->cd(ic+16);
160 //
c015fa8d 161 TH1F *haxis4=0;
dcb6916a 162 if(ipedGainChain==0) haxis4 = gPad->DrawFrame(firstRun-100, 40, lastRun+100, 80);
163 else haxis4 = gPad->DrawFrame(firstRun-100, 300, lastRun+100, 600);
8d03668d 164 haxis4->GetXaxis()->SetNoExponent();
165 haxis4->SetXTitle("RUN no.");
166 haxis4->SetYTitle("ZPA pedestals");
167 //
168 graph[ic+17]->SetMarkerStyle(21);
169 graph[ic+17]->SetMarkerColor(kRed+1);
c015fa8d 170 graph[ic+17]->Draw("P, SAME");
8d03668d 171 }
172 cHadPeds->SaveAs("ZDCPedvsTime1.gif");
173
174 TCanvas *cothPeds = new TCanvas("cothPeds","ZEM + Ref. pedestals",800,0,600,600);
175 cothPeds->Divide(2,2);
176 for(int ic=0; ic<2; ic++){
177 // *** ZEM pedestals
178 cothPeds->cd(ic+1);
179 //
c015fa8d 180 TH1F *haxis5=0;
dcb6916a 181 if(ipedGainChain==0) haxis5 = gPad->DrawFrame(firstRun-100, 30, lastRun+20, 70);
182 else haxis5 = gPad->DrawFrame(firstRun-100, 250, lastRun+100, 550);
8d03668d 183 haxis5->GetXaxis()->SetNoExponent();
184 haxis5->SetXTitle("RUN no.");
185 haxis5->SetYTitle("ZEM pedestals");
186 //
4e7117ba 187 graph[ic+10]->SetMarkerStyle(22);
188 graph[ic+10]->SetMarkerColor(kGreen+1);
c015fa8d 189 graph[ic+10]->Draw("P, SAME");
8d03668d 190 // *** Ref. pedestals
191 cothPeds->cd(ic+3);
192 //
c015fa8d 193 TH1F *haxis6=0;
dcb6916a 194 if(ipedGainChain==0) haxis6 = gPad->DrawFrame(firstRun-100, 50, lastRun+100, 90);
195 else haxis6 = gPad->DrawFrame(firstRun-100, 400, lastRun+100, 700);
8d03668d 196 haxis6->GetXaxis()->SetNoExponent();
197 haxis6->SetXTitle("RUN no.");
198 haxis6->SetYTitle("PMRef. pedestals");
199 //
200 graph[ic+22]->SetMarkerStyle(23);
201 graph[ic+22]->SetMarkerColor(kGreen+4);
c015fa8d 202 graph[ic+22]->Draw("P, SAME");
8d03668d 203 }
204 cothPeds->SaveAs("ZDCPedvsTime2.gif");
205
206}