Fix in the initialization (Gustavo)
[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
a1e17193 13#include <TCanvas.h>
64a7c78d 14#include <TDatime.h>
a1e17193 15#include <TGraph.h>
16#include <TH1.h>
17#include <TObjString.h>
64a7c78d 18#include <TStyle.h>
a1e17193 19#include <TTimeStamp.h>
64a7c78d 20
21ClassImp(AliZDCDataDCS)
22
23//---------------------------------------------------------------
24AliZDCDataDCS::AliZDCDataDCS():
5a8e8156 25 TObject(),
26 fRun(0),
27 fStartTime(0),
28 fEndTime(0),
29 fGraphs("TGraph",kNGraphs),
30 fIsProcessed(kFALSE)
31{
32 // Default constructor
33}
64a7c78d 34
35//---------------------------------------------------------------
36AliZDCDataDCS::AliZDCDataDCS(Int_t nRun, UInt_t startTime, UInt_t endTime):
5a8e8156 37 TObject(),
38 fRun(nRun),
39 fStartTime(startTime),
40 fEndTime(endTime),
41 fGraphs("TGraph",kNGraphs),
42 fIsProcessed(kFALSE)
64a7c78d 43{
5a8e8156 44 // Standard constructor
45
46 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", nRun,
47 TTimeStamp(startTime).AsString(),
48 TTimeStamp(endTime).AsString()));
64a7c78d 49
5a8e8156 50 Init();
64a7c78d 51
52}
53
54//---------------------------------------------------------------
5a8e8156 55AliZDCDataDCS::~AliZDCDataDCS()
56{
57 // Destructor
58 fGraphs.Clear("C");
64a7c78d 59}
60
61//---------------------------------------------------------------
5a8e8156 62void AliZDCDataDCS::ProcessData(TMap& aliasMap, Float_t *fCalibData)
63{
64 // Data processing
65
66 TObjArray *aliasArr;
67 AliDCSValue* aValue;
68 for(int j=0; j<kNAliases; j++){
69 aliasArr = (TObjArray*) aliasMap.GetValue(fAliasNames[j].Data());
70 if(!aliasArr){
71 AliError(Form("Alias %s not found!", fAliasNames[j].Data()));
72 continue;
73 }
74 Introduce(j, aliasArr);
75
76 if(aliasArr->GetEntries()<2){
77 AliError(Form("Alias %s has just %d entries!",
78 fAliasNames[j].Data(),aliasArr->GetEntries()));
79 continue;
80 }
81
82 TIter iterarray(aliasArr);
83
84 Double_t *time = new Double_t[aliasArr->GetEntries()];
85 Double_t *val = new Double_t[aliasArr->GetEntries()];
86
87 UInt_t ne=0;
88 while((aValue = (AliDCSValue*) iterarray.Next())) {
89 val[ne] = aValue->GetFloat();
90 time[ne] = (Double_t) (aValue->GetTimeStamp());
457a440d 91 if(j>=4) fCalibData[ne] = val[ne];
5a8e8156 92 ne++;
93 }
94 //
95
96 //
97 if(j>=4) CreateGraph(j, aliasArr->GetEntries(), time, val); // fill graphs
98 //
99 delete[] val;
100 delete[] time;
101 }
102 //
103 fIsProcessed=kTRUE;
64a7c78d 104
105}
106
107//---------------------------------------------------------------
5a8e8156 108void AliZDCDataDCS::Init()
109{
110 // Initialization
111
112 TH1::AddDirectory(kFALSE);
113
114 fGraphs.SetOwner(1);
115
b39b8493 116 fAliasNames[0] = "ZNA_POS.actual.position";
117 fAliasNames[1] = "ZPA_POS.actual.position";
118 fAliasNames[2] = "ZNC_POS.actual.position";
119 fAliasNames[3] = "ZPC_POS.actual.position";
120 //
121 fAliasNames[4] = "ZNA_HV0.actual.vMon";
122 fAliasNames[5] = "ZNA_HV1.actual.vMon";
123 fAliasNames[6] = "ZNA_HV2.actual.vMon";
124 fAliasNames[7] = "ZNA_HV3.actual.vMon";
125 fAliasNames[8] = "ZNA_HV4.actual.vMon";
126 //
127 fAliasNames[9] = "ZPA_HV0.actual.vMon";
128 fAliasNames[10] = "ZPA_HV1.actual.vMon";
129 fAliasNames[11] = "ZPA_HV2.actual.vMon";
130 fAliasNames[12] = "ZPA_HV3.actual.vMon";
131 fAliasNames[13] = "ZPA_HV4.actual.vMon";
132 //
133 fAliasNames[14] = "ZNC_HV0.actual.vMon";
134 fAliasNames[15] = "ZNC_HV1.actual.vMon";
135 fAliasNames[16] = "ZNC_HV2.actual.vMon";
136 fAliasNames[17] = "ZNC_HV3.actual.vMon";
137 fAliasNames[18] = "ZNC_HV4.actual.vMon";
138 //
139 fAliasNames[19] = "ZPC_HV0.actual.vMon";
140 fAliasNames[20] = "ZPC_HV1.actual.vMon";
141 fAliasNames[21] = "ZPC_HV2.actual.vMon";
142 fAliasNames[22] = "ZPC_HV3.actual.vMon";
143 fAliasNames[23] = "ZPC_HV4.actual.vMon";
144 //
145 fAliasNames[24] = "ZEM_HV0.actual.vMon";
146 fAliasNames[25] = "ZEM_HV1.actual.vMon";
147
64a7c78d 148}
149
150//---------------------------------------------------------------
5a8e8156 151void AliZDCDataDCS::Introduce(UInt_t numAlias, const TObjArray* aliasArr)
152{
153 // Getting array of DCS aliases
154
457a440d 155 int entries = aliasArr->GetEntries();
5a8e8156 156 AliInfo(Form("************ Alias: %s **********",fAliasNames[numAlias].Data()));
157 AliInfo(Form(" %d DP values collected",entries));
64a7c78d 158
159}
160
161
162//---------------------------------------------------------------
163void AliZDCDataDCS::CreateGraph(int i, int dim, const Double_t *x, const Double_t *y)
164{
165
5a8e8156 166 // Create graphics
167
168 TGraph *gr = new(fGraphs[fGraphs.GetEntriesFast()]) TGraph(dim, x, y);
64a7c78d 169
5a8e8156 170 gr->GetXaxis()->SetTimeDisplay(1);
171 gr->SetTitle(fAliasNames[i].Data());
64a7c78d 172
5a8e8156 173 AliInfo(Form("Array entries: %d",fGraphs.GetEntriesFast()));
64a7c78d 174
175
176}
177
178//---------------------------------------------------------------
179void AliZDCDataDCS::Draw(const Option_t* /*option*/)
180{
5a8e8156 181 // Draw graphics
64a7c78d 182
183 fIsProcessed=1;
184 if(!fIsProcessed) return;
185
186 if(fGraphs.GetEntries()==0) return;
187
188 TCanvas *cg1;
730c9d5b 189 TString canvas1Name="ZN1_HVs";
64a7c78d 190 cg1=new TCanvas(canvas1Name,canvas1Name,40,40,600,600);
191 cg1->Divide(2,2);
192 cg1->cd(1);
730c9d5b 193 ((TGraph*) fGraphs.UncheckedAt(0))->SetMarkerStyle(20);
194 ((TGraph*) fGraphs.UncheckedAt(0))->Draw("ALP");
64a7c78d 195 cg1->cd(2);
730c9d5b 196 ((TGraph*) fGraphs.UncheckedAt(1))->SetMarkerStyle(20);
197 ((TGraph*) fGraphs.UncheckedAt(1))->Draw("ALP");
64a7c78d 198 cg1->cd(3);
730c9d5b 199 ((TGraph*) fGraphs.UncheckedAt(2))->SetMarkerStyle(20);
200 ((TGraph*) fGraphs.UncheckedAt(2))->Draw("ALP");
64a7c78d 201 cg1->cd(4);
730c9d5b 202 ((TGraph*) fGraphs.UncheckedAt(3))->SetMarkerStyle(20);
203 ((TGraph*) fGraphs.UncheckedAt(3))->Draw("ALP");
204
205 TCanvas *cg2;
206 TString canvas2Name="ZP1_HVs";
207 cg2=new TCanvas(canvas2Name,canvas2Name,80,80,600,600);
208 cg2->Divide(2,2);
209 cg2->cd(1);
210 ((TGraph*) fGraphs.UncheckedAt(5))->SetMarkerStyle(20);
211 ((TGraph*) fGraphs.UncheckedAt(5))->Draw("ALP");
212 cg2->cd(2);
213 ((TGraph*) fGraphs.UncheckedAt(6))->SetMarkerStyle(20);
214 ((TGraph*) fGraphs.UncheckedAt(6))->Draw("ALP");
215 cg2->cd(3);
216 ((TGraph*) fGraphs.UncheckedAt(7))->SetMarkerStyle(20);
217 ((TGraph*) fGraphs.UncheckedAt(7))->Draw("ALP");
218 cg2->cd(4);
219 ((TGraph*) fGraphs.UncheckedAt(8))->SetMarkerStyle(20);
220 ((TGraph*) fGraphs.UncheckedAt(8))->Draw("ALP");
64a7c78d 221
222}
223