Minor changes
[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 <TCanvas.h>
14 #include <TDatime.h>
15 #include <TGraph.h>
16 #include <TH1.h>
17 #include <TObjString.h>
18 #include <TStyle.h>
19 #include <TTimeStamp.h>
20
21 ClassImp(AliZDCDataDCS)
22
23 //---------------------------------------------------------------
24 AliZDCDataDCS::AliZDCDataDCS():
25    TObject(),
26    fRun(0),
27    fStartTime(0),
28    fEndTime(0),
29    fGraphs("TGraph",kNGraphs),
30    fIsProcessed(kFALSE)
31 {
32   // Default constructor
33 }
34
35 //---------------------------------------------------------------
36 AliZDCDataDCS::AliZDCDataDCS(Int_t nRun, UInt_t startTime, UInt_t endTime):
37    TObject(),
38    fRun(nRun),
39    fStartTime(startTime),
40    fEndTime(endTime),
41    fGraphs("TGraph",kNGraphs),
42    fIsProcessed(kFALSE)
43 {
44    // Standard constructor
45    
46    AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", nRun,
47    TTimeStamp(startTime).AsString(),
48    TTimeStamp(endTime).AsString()));
49
50    Init();
51
52 }
53
54 //---------------------------------------------------------------
55 AliZDCDataDCS::~AliZDCDataDCS() 
56 {
57   // Destructor
58   fGraphs.Clear("C");
59 }
60
61 //---------------------------------------------------------------
62 void AliZDCDataDCS::ProcessData(TMap& aliasMap)
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){
71         AliError(Form("Alias %s not found!", fAliasNames[j].Data()));
72         continue;
73       }
74       Introduce(j, aliasArr);
75
76       if(aliasArr->GetEntries()<=2){
77         AliError(Form("Alias %s has just %d entries!",
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());
91         fCalibData[ne] = val[ne];
92         fTimeStamp[ne] = time[ne];
93         ne++;
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    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";
119    //
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";
125    //
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";
131    //
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";
137    //
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";
143    //
144    fAliasNames[24]  = "ZDC_ZEM_HV0.actual.vMon";
145    fAliasNames[25]  = "ZDC_ZEM_HV1.actual.vMon";
146    //
147    fAliasNames[26]  = "ZDC_REFA_HV.actual.vMon";
148    fAliasNames[27]  = "ZDC_REFC_HV.actual.vMon";
149  
150 }
151
152 //---------------------------------------------------------------
153 void AliZDCDataDCS::Introduce(UInt_t numAlias, const TObjArray* aliasArr)
154 {
155    // Getting array of DCS aliases
156    
157    int entries = aliasArr->GetEntries();
158    AliInfo(Form("************ Alias: %s **********",fAliasNames[numAlias].Data()));
159    AliInfo(Form("          %d DP values collected",entries));
160
161 }
162
163
164 //---------------------------------------------------------------
165 void AliZDCDataDCS::CreateGraph(int i, int dim, const Double_t *x, const Double_t *y)
166 {
167
168    // Create graphics
169    
170    TGraph *gr = new(fGraphs[fGraphs.GetEntriesFast()]) TGraph(dim, x, y);
171
172    gr->GetXaxis()->SetTimeDisplay(1);
173    gr->SetTitle(fAliasNames[i].Data());
174 //   AliInfo(Form("Array entries: %d",fGraphs.GetEntriesFast()));
175
176
177 }
178
179 //---------------------------------------------------------------
180 void AliZDCDataDCS::Draw(const Option_t* /*option*/)
181 {
182   // Draw graphics
183
184   fIsProcessed=1;
185   if(!fIsProcessed) return;
186   
187   if(fGraphs.GetEntries()==0)  return;
188   
189   TCanvas *cg1;
190   TString canvas1Name="ZN1_HVs";
191   cg1=new TCanvas(canvas1Name,canvas1Name,40,40,600,600);
192   cg1->Divide(2,2);
193   cg1->cd(1);
194   ((TGraph*) fGraphs.UncheckedAt(0))->SetMarkerStyle(20);
195   ((TGraph*) fGraphs.UncheckedAt(0))->Draw("ALP");
196   cg1->cd(2);
197   ((TGraph*) fGraphs.UncheckedAt(1))->SetMarkerStyle(20);
198   ((TGraph*) fGraphs.UncheckedAt(1))->Draw("ALP");
199   cg1->cd(3);
200   ((TGraph*) fGraphs.UncheckedAt(2))->SetMarkerStyle(20);
201   ((TGraph*) fGraphs.UncheckedAt(2))->Draw("ALP");
202   cg1->cd(4);
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");
222  
223 }
224