ZDC Preprocessor 1st version implemented
[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//---------------------------------------------------------------
50void AliZDCDataDCS::ProcessData(TMap& aliasMap){
51
52 TObjArray *aliasArr;
53 AliDCSValue* aValue;
54 for(int j=4; 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->GetSimpleValue().GetFloat();
76 time[ne] = (Double_t) (aValue->GetTimeStamp());
77 ne++;
78 }
79
80 // fill graphs
81 CreateGraph(j, aliasArr->GetEntries(), time, val);
82 delete[] val;
83 delete[] time;
84 }
85
86
87 fIsProcessed=kTRUE;
88
89
90}
91
92//---------------------------------------------------------------
93void AliZDCDataDCS::Init(){
94
95 TH1::AddDirectory(kFALSE);
96
97 fGraphs.SetOwner(1);
98
99 for(int i=0;i<kNAliases;i++){
100 /*if(i<4){
101 fAliasNames[i] = "ZDC.Position";
102 }
103 else fAliasNames[i] = "ZDC.HVValue";*/
104 fAliasNames[i] = "DCSAlias";
105 fAliasNames[i] += i;
106 }
107
108}
109
110//---------------------------------------------------------------
111void AliZDCDataDCS::Introduce(UInt_t numAlias, const TObjArray* aliasArr){
112
113 int entries=aliasArr->GetEntries();
114 AliInfo(Form("************ Alias: %s **********",fAliasNames[numAlias].Data()));
115 AliInfo(Form(" %d DP values collected",entries));
116
117}
118
119
120//---------------------------------------------------------------
121void AliZDCDataDCS::CreateGraph(int i, int dim, const Double_t *x, const Double_t *y)
122{
123
124 TGraph *gr = new(fGraphs[fGraphs.GetEntriesFast()]) TGraph(dim, x, y);
125
126 gr->GetXaxis()->SetTimeDisplay(1);
127 gr->SetTitle(fAliasNames[i].Data());
128
129 AliInfo(Form("Array entries: %d",fGraphs.GetEntriesFast()));
130
131
132}
133
134//---------------------------------------------------------------
135void AliZDCDataDCS::Draw(const Option_t* /*option*/)
136{
137// Draw graphs
138
139 fIsProcessed=1;
140 if(!fIsProcessed) return;
141
142 if(fGraphs.GetEntries()==0) return;
143
144 TCanvas *cg1;
145 TString canvas1Name="Graphs1";
146 cg1=new TCanvas(canvas1Name,canvas1Name,40,40,600,600);
147 cg1->Divide(2,2);
148 cg1->cd(1);
149 ((TGraph*) fGraphs.UncheckedAt(0))->Draw("AP");
150 cg1->cd(2);
151 ((TGraph*) fGraphs.UncheckedAt(1))->Draw("AP");
152 cg1->cd(3);
153 ((TGraph*) fGraphs.UncheckedAt(2))->Draw("AP");
154 cg1->cd(4);
155 ((TGraph*) fGraphs.UncheckedAt(3))->Draw("AP");
156
157}
158