Fixed Effective C++ warnings
[u/mrichter/AliRoot.git] / ZDC / AliZDCDataDCS.cxx
CommitLineData
64a7c78d 1#include "AliZDCDataDCS.h"
2
3#include "AliCDBMetaData.h"
4#include "AliDCSValue.h"
5#include "AliLog.h"
6
7#include <TTimeStamp.h>
8#include <TObjString.h>
9#include <TGraph.h>
10#include <TDatime.h>
11#include <TStyle.h>
12#include <TCanvas.h>
13
14ClassImp(AliZDCDataDCS)
15
16//---------------------------------------------------------------
17AliZDCDataDCS::AliZDCDataDCS():
18 TObject(),
19 fRun(0),
20 fStartTime(0),
21 fEndTime(0),
22 fGraphs("TGraph",kNGraphs),
23 fIsProcessed(kFALSE)
24{}
25
26//---------------------------------------------------------------
27AliZDCDataDCS::AliZDCDataDCS(Int_t nRun, UInt_t startTime, UInt_t endTime):
28 TObject(),
29 fRun(nRun),
30 fStartTime(startTime),
31 fEndTime(endTime),
32 fGraphs("TGraph",kNGraphs),
33 fIsProcessed(kFALSE)
34{
35 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", nRun,
36 TTimeStamp(startTime).AsString(),
37 TTimeStamp(endTime).AsString()));
38
39 Init();
40
41}
42
43//---------------------------------------------------------------
44AliZDCDataDCS::~AliZDCDataDCS() {
45
46 fGraphs.Clear("C");
47}
48
49//---------------------------------------------------------------
31af5828 50void AliZDCDataDCS::ProcessData(TMap& aliasMap, Float_t *fCalibData){
64a7c78d 51
52 TObjArray *aliasArr;
53 AliDCSValue* aValue;
31af5828 54 for(int j=0; j<kNAliases; j++){
55 aliasArr = (TObjArray*) aliasMap.GetValue(fAliasNames[j].Data());
56 if(!aliasArr){
57 AliError(Form("Alias %s not found!", fAliasNames[j].Data()));
58 continue;
59 }
60 Introduce(j, aliasArr);
61
62 if(aliasArr->GetEntries()<2){
63 AliError(Form("Alias %s has just %d entries!",
64 fAliasNames[j].Data(),aliasArr->GetEntries()));
65 continue;
66 }
67
68 TIter iterarray(aliasArr);
69
70 Double_t *time = new Double_t[aliasArr->GetEntries()];
71 Double_t *val = new Double_t[aliasArr->GetEntries()];
72
73 UInt_t ne=0;
74 while((aValue = (AliDCSValue*) iterarray.Next())) {
75 val[ne] = aValue->GetFloat();
76 time[ne] = (Double_t) (aValue->GetTimeStamp());
77 fCalibData[ne] = val[ne];
78 ne++;
79 }
80 //
81
82 //
83 if(j>=4) CreateGraph(j, aliasArr->GetEntries(), time, val); // fill graphs
84 //
85 delete[] val;
86 delete[] time;
64a7c78d 87 }
31af5828 88 //
64a7c78d 89 fIsProcessed=kTRUE;
90
91
92}
93
94//---------------------------------------------------------------
95void AliZDCDataDCS::Init(){
96
97 TH1::AddDirectory(kFALSE);
98
99 fGraphs.SetOwner(1);
100
101 for(int i=0;i<kNAliases;i++){
730c9d5b 102 if(i<4){
64a7c78d 103 fAliasNames[i] = "ZDC.Position";
730c9d5b 104 fAliasNames[i] += i;
64a7c78d 105 }
730c9d5b 106 else{
107 fAliasNames[i] = "ZDC.HVValue";
108 fAliasNames[i] += i-4;
109 }
64a7c78d 110 }
111
112}
113
114//---------------------------------------------------------------
115void AliZDCDataDCS::Introduce(UInt_t numAlias, const TObjArray* aliasArr){
116
117 int entries=aliasArr->GetEntries();
118 AliInfo(Form("************ Alias: %s **********",fAliasNames[numAlias].Data()));
119 AliInfo(Form(" %d DP values collected",entries));
120
121}
122
123
124//---------------------------------------------------------------
125void AliZDCDataDCS::CreateGraph(int i, int dim, const Double_t *x, const Double_t *y)
126{
127
128 TGraph *gr = new(fGraphs[fGraphs.GetEntriesFast()]) TGraph(dim, x, y);
129
130 gr->GetXaxis()->SetTimeDisplay(1);
131 gr->SetTitle(fAliasNames[i].Data());
132
133 AliInfo(Form("Array entries: %d",fGraphs.GetEntriesFast()));
134
135
136}
137
138//---------------------------------------------------------------
139void AliZDCDataDCS::Draw(const Option_t* /*option*/)
140{
141// Draw graphs
142
143 fIsProcessed=1;
144 if(!fIsProcessed) return;
145
146 if(fGraphs.GetEntries()==0) return;
147
148 TCanvas *cg1;
730c9d5b 149 TString canvas1Name="ZN1_HVs";
64a7c78d 150 cg1=new TCanvas(canvas1Name,canvas1Name,40,40,600,600);
151 cg1->Divide(2,2);
152 cg1->cd(1);
730c9d5b 153 ((TGraph*) fGraphs.UncheckedAt(0))->SetMarkerStyle(20);
154 ((TGraph*) fGraphs.UncheckedAt(0))->Draw("ALP");
64a7c78d 155 cg1->cd(2);
730c9d5b 156 ((TGraph*) fGraphs.UncheckedAt(1))->SetMarkerStyle(20);
157 ((TGraph*) fGraphs.UncheckedAt(1))->Draw("ALP");
64a7c78d 158 cg1->cd(3);
730c9d5b 159 ((TGraph*) fGraphs.UncheckedAt(2))->SetMarkerStyle(20);
160 ((TGraph*) fGraphs.UncheckedAt(2))->Draw("ALP");
64a7c78d 161 cg1->cd(4);
730c9d5b 162 ((TGraph*) fGraphs.UncheckedAt(3))->SetMarkerStyle(20);
163 ((TGraph*) fGraphs.UncheckedAt(3))->Draw("ALP");
164
165 TCanvas *cg2;
166 TString canvas2Name="ZP1_HVs";
167 cg2=new TCanvas(canvas2Name,canvas2Name,80,80,600,600);
168 cg2->Divide(2,2);
169 cg2->cd(1);
170 ((TGraph*) fGraphs.UncheckedAt(5))->SetMarkerStyle(20);
171 ((TGraph*) fGraphs.UncheckedAt(5))->Draw("ALP");
172 cg2->cd(2);
173 ((TGraph*) fGraphs.UncheckedAt(6))->SetMarkerStyle(20);
174 ((TGraph*) fGraphs.UncheckedAt(6))->Draw("ALP");
175 cg2->cd(3);
176 ((TGraph*) fGraphs.UncheckedAt(7))->SetMarkerStyle(20);
177 ((TGraph*) fGraphs.UncheckedAt(7))->Draw("ALP");
178 cg2->cd(4);
179 ((TGraph*) fGraphs.UncheckedAt(8))->SetMarkerStyle(20);
180 ((TGraph*) fGraphs.UncheckedAt(8))->Draw("ALP");
64a7c78d 181
182}
183