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