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