...also histos are now correctly booked
[u/mrichter/AliRoot.git] / ACORDE / AliACORDEDataDCS.cxx
CommitLineData
3b181530 1/****************************************************
2
3 AliACORDEDataDCS class
4 create to make a pointer to the
5 ACORDE data DCS points
6
7 Author: Pedro Gonzalez (CIEMAT, Madrid)
8 ACORDE-DCS creator: Mario Ivan Martinez Hdez
9 <mim@fcfm.buap.mx>
10
11 Last update: Fix of coding violations
12 Mario Rodriguez C. (FCFM-BUAP)
13 <mrodrigu@mail.cern.ch>
14
15*****************************************************/
749347ef 16#include "AliACORDEDataDCS.h"
17
18#include "AliCDBMetaData.h"
19#include "AliDCSValue.h"
20#include "AliLog.h"
21
22#include <TTimeStamp.h>
23#include <TObjString.h>
24#include <TH2F.h>
25#include <TProfile.h>
26#include <TGraph.h>
27#include <TDatime.h>
28#include <TStyle.h>
29#include <TCanvas.h>
30
31ClassImp(AliACORDEDataDCS)
32
33//---------------------------------------------------------------
34AliACORDEDataDCS::AliACORDEDataDCS():
35 TObject(),
36 fRun(0),
37 fStartTime(0),
38 fEndTime(0),
39 fGraphs("TGraph",kNGraphs),
5d8a7578 40 fFunc(0),
749347ef 41 fIsProcessed(kFALSE)
42{
ea3dd546 43 for(int i=0;i<kNHistos;i++)
44 {
45 fHv[i]=0x0;
46 fMean[i] = fWidth[i] = 0.0;
47 }
5d8a7578 48
749347ef 49}
50
51//---------------------------------------------------------------
52AliACORDEDataDCS::AliACORDEDataDCS(Int_t nRun, UInt_t startTime, UInt_t endTime):
53 TObject(),
54 fRun(nRun),
55 fStartTime(startTime),
56 fEndTime(endTime),
57 fGraphs("TGraph",kNGraphs),
5d8a7578 58 fFunc(0),
749347ef 59 fIsProcessed(kFALSE)
60{
3b181530 61// Init of class AliACORDEDataDCS
62// Gettin the TimeStamp an put it on a string
63
749347ef 64 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", nRun,
65 TTimeStamp(startTime).AsString(),
66 TTimeStamp(endTime).AsString()));
67
5d8a7578 68
749347ef 69 Init();
70
71}
72
73//---------------------------------------------------------------
74AliACORDEDataDCS::~AliACORDEDataDCS() {
75
392813bf 76 for(int i=0;i<kNHistos;i++)
77 {
78 delete fHv[i]; fHv[i]=0;
79 }
749347ef 80 fGraphs.Clear("C");
81 fFunc=0;
82}
5d8a7578 83//---------------------------------------------------------------
84
85AliACORDEDataDCS::AliACORDEDataDCS(const AliACORDEDataDCS & data):
86TObject(),
87fRun(0),
88fStartTime(0),
89fEndTime(0),
90fGraphs("TGraph",kNGraphs),
91fFunc(0),
92fIsProcessed(kFALSE)
93{
3b181530 94// Setting the initial values
95// fRUn, Start of Run, End of Run, IsProcessed
5d8a7578 96
97 fRun=data.fRun;
98 fStartTime=data.fStartTime;
99 fEndTime=data.fEndTime;
100 fFunc=data.fFunc;
101 fIsProcessed=data.fIsProcessed;
102
103
104 for(int i=0;i<kNAliases;i++){fAliasNames[i] = data.fAliasNames[i];}
105
392813bf 106 for(int i=0;i<kNHistos;i++)
107 {
108 fHv[i]=data.fHv[i];
109 fMean[i]=data.fMean[i];
110 fWidth[i]=data.fWidth[i];
111 }
5d8a7578 112
749347ef 113
5d8a7578 114
115
116}
117//--------------------------------------------------------------
118AliACORDEDataDCS& AliACORDEDataDCS:: operator=(const AliACORDEDataDCS & data) {
119
120
121 this->fRun=data.fRun;
122 this->fStartTime=data.fStartTime;
123 this->fEndTime=data.fEndTime;
124 this->fFunc=data.fFunc;
125 this->fIsProcessed=data.fIsProcessed;
126
127
128 for(int i=0;i<kNAliases;i++){this->fAliasNames[i] = data.fAliasNames[i];}
129
392813bf 130 for(int i=0;i<kNHistos;i++)
131 {
132 this->fHv[i]=data.fHv[i];
133 }
5d8a7578 134
135
136 return *this;
137
138}
749347ef 139//---------------------------------------------------------------
3b181530 140void AliACORDEDataDCS::ProcessData(TMap& aliasMap)
141{
142// Process of the data from the aliases DCS-data points
749347ef 143
144 if(!(fHv[0])) Init();
145
146 TObjArray *aliasArr;
147 AliDCSValue* aValue;
148
149 for(int j=0; j<kNAliases; j++)
150 {
151 aliasArr = (TObjArray*) aliasMap.GetValue(fAliasNames[j].Data());
152 if(!aliasArr)
153 {
154 AliError(Form("Alias %s not found!", fAliasNames[j].Data()));
155 continue;
156 }
157 Introduce(j, aliasArr);
158
159 if(aliasArr->GetEntries()<2)
160 {
ea3dd546 161 AliError(Form("Alias %s has just %d entries!",
749347ef 162 fAliasNames[j].Data(),aliasArr->GetEntries()));
163 continue;
164 }
165
166 TIter iterarray(aliasArr);
167
168 Double_t *time = new Double_t[aliasArr->GetEntries()];
169 Double_t *val = new Double_t[aliasArr->GetEntries()];
170
171 UInt_t ne=0;
172
173 while ((aValue = (AliDCSValue*) iterarray.Next()))
174 {
175 val[ne] = aValue->GetFloat();
176 time[ne] = (Double_t) (aValue->GetTimeStamp());
177 fHv[j]->Fill(val[ne]);
178 ne++;
179 }
180
181
182
183 CreateGraph(j, aliasArr->GetEntries(), time, val);
184 delete[] val;
185 delete[] time;
186 }
187
188
189 // calculate mean and rms of the first two histos
190 for(int i=0;i<kNHistos;i++)
191 {
192 fMean[i] = fHv[i]->GetMean();
193 fWidth[i] = fHv[i]->GetRMS();
194 }
195
196
197 fIsProcessed=kTRUE;
198
199
200}
201
202//---------------------------------------------------------------
3b181530 203void AliACORDEDataDCS::Init()
204{
205// Init of AliACORDEDatDCS procedure
206// Loop over the aliases
749347ef 207
208 TH1::AddDirectory(kFALSE);
209
210 fGraphs.SetOwner(1);
211
212 TString aliasName;
213
214 for(int i=0;i<kNAliases;i++){
215
216 aliasName.Form("ACO_HV_MODULE%02d_VMON",i);
217 fAliasNames[i] = aliasName;
218 }
219
220 for(int i=0;i<kNHistos;i++)
221 {
222 fHv[i] = new TH1F(fAliasNames[i].Data(),fAliasNames[i].Data(), 20, kHvMin, kHvMax);
223 fHv[i]->GetXaxis()->SetTitle("Hv");
224 }
225}
226
227//---------------------------------------------------------------
228void AliACORDEDataDCS::Introduce(UInt_t numAlias, const TObjArray* aliasArr)
229{
230
231 int entries=aliasArr->GetEntries();
232 AliInfo(Form("************ Alias: %s **********",fAliasNames[numAlias].Data()));
233 AliInfo(Form(" %d DP values collected",entries));
234
235}
236
237//---------------------------------------------------------------
238void AliACORDEDataDCS::CreateGraph(int i, int dim, const Double_t *x, const Double_t *y)
239{
3b181530 240// Create the plots for the ACORDE DCS
749347ef 241
242 TGraph *gr = new(fGraphs[fGraphs.GetEntriesFast()]) TGraph(dim, x, y);
243
244 gr->GetXaxis()->SetTimeDisplay(1);
245 gr->SetTitle(fAliasNames[i].Data());
246
247 AliInfo(Form("Array entries: %d",fGraphs.GetEntriesFast()));
248
249
250}
251
252//---------------------------------------------------------------
253void AliACORDEDataDCS::Draw(const Option_t* /*option*/)
254{
255// Draw all histos and graphs
256
257 if(!fIsProcessed) return;
258
259 TString canvasHistoName;
260 TCanvas *ch[10];
261
262 for (int i=0;i<10;i++)
263 {
264 canvasHistoName.Form("ACO_HV_MODULE");
265 ch[i]=new TCanvas(canvasHistoName,canvasHistoName,20,20,600,600);
266 ch[i]->Divide(2,3);
267
268 for(int j=0;j<6;j++)
269 {
270 ch[i]->cd(j+1);
271 ((TGraph*) fGraphs.UncheckedAt(i*6+j))->SetMarkerStyle(20);
272 ((TGraph*) fGraphs.UncheckedAt(i*6+j))->Draw("alp");
273 }
274
275 }
276
277
278}
279