Fix by Ruben
[u/mrichter/AliRoot.git] / ZDC / PlotTDCcalibvsTime.C
CommitLineData
f286e6ab 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 <TH1F.h>
12#include "AliCDBEntry.h"
13#include "AliCDBGrid.h"
14#include "AliCDBId.h"
15#include "AliCDBLocal.h"
16#include "AliCDBManager.h"
17#include "AliCDBMetaData.h"
18#include "AliCDBPath.h"
19#include "AliCDBRunRange.h"
20#include "AliCDBStorage.h"
21#include "AliDCSValue.h"
22#include "AliZDC.h"
23#include "AliZDCv3.h"
24#include "AliZDCTDCCalib.h"
25
26#endif
27
28
29void PlotTDCcalibvsTime(Int_t year=2011, Int_t firstRun=166000,
690daef7 30 Int_t lastRun=169000)
f286e6ab 31{
32
33
34 TGrid::Connect("alien:",0,0,"t");
690daef7 35 gSystem->Exec(Form("gbbox find \"/alice/data/%d/OCDB/ZDC/Calib/TDCCalib/\" \"Run*.root\" > TDCcalibAlienFiles.txt",year));
36 FILE* listruns=fopen("TDCcalibAlienFiles.txt","r");
f286e6ab 37
38 const int kNchannels=6;
39 TGraphErrors* graph[6];
40 for(Int_t i=0; i<kNchannels; i++){
41 graph[i] = new TGraphErrors(0);
42 char name[50], title[50];
690daef7 43 sprintf(name,"graph%d",i); sprintf(title,"TDC.%d vs. run#",i);
f286e6ab 44 graph[i]->SetName("graph"); graph[i]->SetTitle("title");
45 }
46
47 Char_t filnam[200], filnamalien[200];
48 Int_t iPoint=0;
49 Int_t nrun, nrun2, nv, ns;
50
51 while(!feof(listruns)){
52 int st = fscanf(listruns,"%s\n",filnam);
53 Char_t directory[100];
54 sprintf(directory,"/alice/data/%d",year);
690daef7 55 printf(" Checking for %s\n",filnam);
f286e6ab 56 if(!strstr(filnam,directory)) continue;
57 sscanf(filnam,"/alice/data/%d/OCDB/ZDC/Calib/TDCCalib/Run%d_%d_v%d_s%d.root",&year,&nrun,&nrun2,&nv,&ns);
58 if(nrun<firstRun) continue;
59 if(nrun>lastRun) continue;
60 sprintf(filnamalien,"alien://%s",filnam);
61 printf("Opening file: %s\n",filnam);
62 TFile *f = TFile::Open(filnamalien);
63 AliCDBEntry *entry = (AliCDBEntry*)f->Get("AliCDBEntry");
64 AliZDCTDCCalib *calibdata = dynamic_cast<AliZDCTDCCalib*> (entry->GetObject());
65
66 for(int i=0; i<kNchannels; i++){
690daef7 67 graph[i]->SetPoint(iPoint, (Double_t)nrun, calibdata->GetMeanTDC(i));
f286e6ab 68 graph[i]->SetPointError(iPoint, 0., calibdata->GetWidthTDC(i));
69 }
70 iPoint++;
71 f->Close();
72 }
73
74 TFile *outfile=new TFile(Form("TDCCalib%dVsTime.root",year),"recreate");
75 outfile->cd();
76 for(int i=0; i<kNchannels; i++) graph[i]->Write();
77 outfile->Close();
78
79 //***********************************************************
80 // #### ROOT initialization
81 gROOT->Reset();
82 gStyle->SetCanvasColor(10);
83 gStyle->SetFrameFillColor(10);
84 gStyle->SetOptTitle(0);
85 gStyle->SetOptStat(1111);
86 gStyle->SetOptFit(0);
87 gStyle->SetTitleTextColor(4);
88 gStyle->SetStatTextColor(4);
89 gStyle->SetStatX(0.92);
90 gStyle->SetStatY(0.92);
91 gStyle->SetLineColor(1);
92 gStyle->SetPalette(1);
93 gStyle->SetPadTopMargin(0.05);
94 gStyle->SetPadRightMargin(0.05);
95 gStyle->SetPadBottomMargin(0.09);
96 gStyle->SetPadLeftMargin(0.09);
97 gStyle->SetTitleOffset(1.1,"Y");
98 // *************************************************************
99
690daef7 100 TCanvas *cHadPeds = new TCanvas("cHadPeds","TDC mean values",0,0,1000,800);
f286e6ab 101 cHadPeds->Divide(3,2);
102 for(int ic=0; ic<6; ic++){
103 // *** ZNC pedestals
104 cHadPeds->cd(ic+1);
105 //
690daef7 106 TH1F *haxis1 = gPad->DrawFrame(firstRun-100, -100, lastRun+100, -10);
f286e6ab 107 haxis1->GetXaxis()->SetNoExponent();
108 haxis1->SetXTitle("RUN no.");
109 if(ic==0) haxis1->SetYTitle("ZNC TDC calib");
110 else if(ic==1) haxis1->SetYTitle("ZNA TDC calib");
111 else if(ic==2) haxis1->SetYTitle("ZPC TDC calib");
112 else if(ic==3) haxis1->SetYTitle("ZPA TDC calib");
113 else if(ic==4) haxis1->SetYTitle("ZEM1 TDC calib");
114 else if(ic==5) haxis1->SetYTitle("ZEM2 TDC calib");
115 //
116 graph[ic]->SetMarkerStyle(20);
117 graph[ic]->SetMarkerColor(kAzure+ic);
118 graph[ic]->Draw("P, SAME");
f286e6ab 119 }
690daef7 120 cHadPeds->SaveAs("ZDCTDCvsTime.gif");
121 cHadPeds->SaveAs("ZDCTDCvsTime.C");
f286e6ab 122
123
124}