Deleting unneeded objects
[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
fea9b334 46 AliDebug(2,Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", nRun,
5a8e8156 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//---------------------------------------------------------------
92339a90 62void AliZDCDataDCS::ProcessData(TMap& aliasMap)
5a8e8156 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){
fea9b334 71 AliWarning(Form("Alias %s not found!", fAliasNames[j].Data()));
5a8e8156 72 continue;
73 }
74 Introduce(j, aliasArr);
75
c630de47 76 if(aliasArr->GetEntries()<=2){
fea9b334 77 AliWarning(Form("Alias %s has just %d entries!",
5a8e8156 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());
c43818e0 91 fCalibData[ne] = val[ne];
92 fTimeStamp[ne] = time[ne];
5a8e8156 93 ne++;
94 }
5a8e8156 95
ea628de7 96// if(j>=4) CreateGraph(j, aliasArr->GetEntries(), time, val); // fill graphs
5a8e8156 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
c43e6d35 115 fAliasNames[0] = "ZDC_ZNA_POS.actual.position";
116 fAliasNames[1] = "ZDC_ZPA_POS.actual.position";
117 fAliasNames[2] = "ZDC_ZNC_POS.actual.position";
118 fAliasNames[3] = "ZDC_ZPC_POS.actual.position";
b39b8493 119 //
c43e6d35 120 fAliasNames[4] = "ZDC_ZNA_HV0.actual.vMon";
121 fAliasNames[5] = "ZDC_ZNA_HV1.actual.vMon";
122 fAliasNames[6] = "ZDC_ZNA_HV2.actual.vMon";
123 fAliasNames[7] = "ZDC_ZNA_HV3.actual.vMon";
124 fAliasNames[8] = "ZDC_ZNA_HV4.actual.vMon";
b39b8493 125 //
c43e6d35 126 fAliasNames[9] = "ZDC_ZPA_HV0.actual.vMon";
127 fAliasNames[10] = "ZDC_ZPA_HV1.actual.vMon";
128 fAliasNames[11] = "ZDC_ZPA_HV2.actual.vMon";
129 fAliasNames[12] = "ZDC_ZPA_HV3.actual.vMon";
130 fAliasNames[13] = "ZDC_ZPA_HV4.actual.vMon";
b39b8493 131 //
c43e6d35 132 fAliasNames[14] = "ZDC_ZNC_HV0.actual.vMon";
133 fAliasNames[15] = "ZDC_ZNC_HV1.actual.vMon";
134 fAliasNames[16] = "ZDC_ZNC_HV2.actual.vMon";
135 fAliasNames[17] = "ZDC_ZNC_HV3.actual.vMon";
136 fAliasNames[18] = "ZDC_ZNC_HV4.actual.vMon";
b39b8493 137 //
c43e6d35 138 fAliasNames[19] = "ZDC_ZPC_HV0.actual.vMon";
139 fAliasNames[20] = "ZDC_ZPC_HV1.actual.vMon";
140 fAliasNames[21] = "ZDC_ZPC_HV2.actual.vMon";
141 fAliasNames[22] = "ZDC_ZPC_HV3.actual.vMon";
142 fAliasNames[23] = "ZDC_ZPC_HV4.actual.vMon";
b39b8493 143 //
c43e6d35 144 fAliasNames[24] = "ZDC_ZEM_HV0.actual.vMon";
145 fAliasNames[25] = "ZDC_ZEM_HV1.actual.vMon";
c0aec6f6 146 //
20a3b76c 147 fAliasNames[26] = "ZDC_REFA_HV.actual.vMon";
148 fAliasNames[27] = "ZDC_REFC_HV.actual.vMon";
b39b8493 149
64a7c78d 150}
151
152//---------------------------------------------------------------
5a8e8156 153void AliZDCDataDCS::Introduce(UInt_t numAlias, const TObjArray* aliasArr)
154{
155 // Getting array of DCS aliases
156
457a440d 157 int entries = aliasArr->GetEntries();
fea9b334 158 AliDebug(2,Form("************ Alias: %s **********",fAliasNames[numAlias].Data()));
159 AliDebug(2,Form(" %d DP values collected",entries));
64a7c78d 160
161}
162
163
164//---------------------------------------------------------------
165void AliZDCDataDCS::CreateGraph(int i, int dim, const Double_t *x, const Double_t *y)
166{
167
5a8e8156 168 // Create graphics
169
170 TGraph *gr = new(fGraphs[fGraphs.GetEntriesFast()]) TGraph(dim, x, y);
64a7c78d 171
5a8e8156 172 gr->GetXaxis()->SetTimeDisplay(1);
173 gr->SetTitle(fAliasNames[i].Data());
fea9b334 174// AliDebug(2,Form("Array entries: %d",fGraphs.GetEntriesFast()));
64a7c78d 175
176
177}
178
179//---------------------------------------------------------------
180void AliZDCDataDCS::Draw(const Option_t* /*option*/)
181{
5a8e8156 182 // Draw graphics
64a7c78d 183
184 fIsProcessed=1;
185 if(!fIsProcessed) return;
186
187 if(fGraphs.GetEntries()==0) return;
188
189 TCanvas *cg1;
730c9d5b 190 TString canvas1Name="ZN1_HVs";
64a7c78d 191 cg1=new TCanvas(canvas1Name,canvas1Name,40,40,600,600);
192 cg1->Divide(2,2);
193 cg1->cd(1);
730c9d5b 194 ((TGraph*) fGraphs.UncheckedAt(0))->SetMarkerStyle(20);
195 ((TGraph*) fGraphs.UncheckedAt(0))->Draw("ALP");
64a7c78d 196 cg1->cd(2);
730c9d5b 197 ((TGraph*) fGraphs.UncheckedAt(1))->SetMarkerStyle(20);
198 ((TGraph*) fGraphs.UncheckedAt(1))->Draw("ALP");
64a7c78d 199 cg1->cd(3);
730c9d5b 200 ((TGraph*) fGraphs.UncheckedAt(2))->SetMarkerStyle(20);
201 ((TGraph*) fGraphs.UncheckedAt(2))->Draw("ALP");
64a7c78d 202 cg1->cd(4);
730c9d5b 203 ((TGraph*) fGraphs.UncheckedAt(3))->SetMarkerStyle(20);
204 ((TGraph*) fGraphs.UncheckedAt(3))->Draw("ALP");
205
206 TCanvas *cg2;
207 TString canvas2Name="ZP1_HVs";
208 cg2=new TCanvas(canvas2Name,canvas2Name,80,80,600,600);
209 cg2->Divide(2,2);
210 cg2->cd(1);
211 ((TGraph*) fGraphs.UncheckedAt(5))->SetMarkerStyle(20);
212 ((TGraph*) fGraphs.UncheckedAt(5))->Draw("ALP");
213 cg2->cd(2);
214 ((TGraph*) fGraphs.UncheckedAt(6))->SetMarkerStyle(20);
215 ((TGraph*) fGraphs.UncheckedAt(6))->Draw("ALP");
216 cg2->cd(3);
217 ((TGraph*) fGraphs.UncheckedAt(7))->SetMarkerStyle(20);
218 ((TGraph*) fGraphs.UncheckedAt(7))->Draw("ALP");
219 cg2->cd(4);
220 ((TGraph*) fGraphs.UncheckedAt(8))->SetMarkerStyle(20);
221 ((TGraph*) fGraphs.UncheckedAt(8))->Draw("ALP");
64a7c78d 222
223}
224