]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ZDC/AliZDCDataDCS.cxx
Sligthly updated AliZDCDataDCS.cxx
[u/mrichter/AliRoot.git] / ZDC / AliZDCDataDCS.cxx
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
14 ClassImp(AliZDCDataDCS)
15
16 //---------------------------------------------------------------
17 AliZDCDataDCS::AliZDCDataDCS():
18         TObject(),
19         fRun(0),
20         fStartTime(0),
21         fEndTime(0),
22         fGraphs("TGraph",kNGraphs),
23         fIsProcessed(kFALSE)
24 {}
25
26 //---------------------------------------------------------------
27 AliZDCDataDCS::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 //---------------------------------------------------------------
44 AliZDCDataDCS::~AliZDCDataDCS() {
45
46         fGraphs.Clear("C");
47 }
48
49 //---------------------------------------------------------------
50 void 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->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 //---------------------------------------------------------------
93 void 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                   fAliasNames[i] += i;
103                 }
104                 else{
105                   fAliasNames[i] = "ZDC.HVValue";
106                   fAliasNames[i] += i-4;
107                 }
108                 /*fAliasNames[i] = "DCSAlias";
109                 fAliasNames[i] += i;*/
110         }
111
112 }
113
114 //---------------------------------------------------------------
115 void AliZDCDataDCS::Introduce(UInt_t numAlias, const TObjArray* aliasArr){
116
117         int entries=aliasArr->GetEntries();
118         AliInfo(Form("************ Alias: %s **********",fAliasNames[numAlias].Data()));
119         AliInfo(Form("          %d DP values collected",entries));
120
121 }
122
123
124 //---------------------------------------------------------------
125 void AliZDCDataDCS::CreateGraph(int i, int dim, const Double_t *x, const Double_t *y)
126 {
127
128         TGraph *gr = new(fGraphs[fGraphs.GetEntriesFast()]) TGraph(dim, x, y);
129
130         gr->GetXaxis()->SetTimeDisplay(1);
131         gr->SetTitle(fAliasNames[i].Data());
132
133         AliInfo(Form("Array entries: %d",fGraphs.GetEntriesFast()));
134
135
136 }
137
138 //---------------------------------------------------------------
139 void AliZDCDataDCS::Draw(const Option_t* /*option*/)
140 {
141 // Draw graphs
142
143   fIsProcessed=1;
144   if(!fIsProcessed) return;
145   
146   if(fGraphs.GetEntries()==0)  return;
147   
148   TCanvas *cg1;
149   TString canvas1Name="ZN1_HVs";
150   cg1=new TCanvas(canvas1Name,canvas1Name,40,40,600,600);
151   cg1->Divide(2,2);
152   cg1->cd(1);
153   ((TGraph*) fGraphs.UncheckedAt(0))->SetMarkerStyle(20);
154   ((TGraph*) fGraphs.UncheckedAt(0))->Draw("ALP");
155   cg1->cd(2);
156   ((TGraph*) fGraphs.UncheckedAt(1))->SetMarkerStyle(20);
157   ((TGraph*) fGraphs.UncheckedAt(1))->Draw("ALP");
158   cg1->cd(3);
159   ((TGraph*) fGraphs.UncheckedAt(2))->SetMarkerStyle(20);
160   ((TGraph*) fGraphs.UncheckedAt(2))->Draw("ALP");
161   cg1->cd(4);
162   ((TGraph*) fGraphs.UncheckedAt(3))->SetMarkerStyle(20);
163   ((TGraph*) fGraphs.UncheckedAt(3))->Draw("ALP");
164   
165   TCanvas *cg2;
166   TString canvas2Name="ZP1_HVs";
167   cg2=new TCanvas(canvas2Name,canvas2Name,80,80,600,600);
168   cg2->Divide(2,2);
169   cg2->cd(1);
170   ((TGraph*) fGraphs.UncheckedAt(5))->SetMarkerStyle(20);
171   ((TGraph*) fGraphs.UncheckedAt(5))->Draw("ALP");
172   cg2->cd(2);
173   ((TGraph*) fGraphs.UncheckedAt(6))->SetMarkerStyle(20);
174   ((TGraph*) fGraphs.UncheckedAt(6))->Draw("ALP");
175   cg2->cd(3);
176   ((TGraph*) fGraphs.UncheckedAt(7))->SetMarkerStyle(20);
177   ((TGraph*) fGraphs.UncheckedAt(7))->Draw("ALP");
178   cg2->cd(4);
179   ((TGraph*) fGraphs.UncheckedAt(8))->SetMarkerStyle(20);
180   ((TGraph*) fGraphs.UncheckedAt(8))->Draw("ALP");
181  
182 }
183