]>
Commit | Line | Data |
---|---|---|
4b4eb769 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | ||
17 | // | |
18 | // This is an example of a container class | |
19 | // of the data retreieved from the DCS archive DB. | |
20 | // It is called by the detector's Preprocessor and | |
21 | // it is stored in the CDB. | |
22 | // | |
23 | ||
24 | #include "AliTPCDataDCS.h" | |
25 | ||
26 | #include "AliCDBMetaData.h" | |
27 | #include "AliDCSValue.h" | |
28 | #include "AliLog.h" | |
29 | ||
30 | #include <TTimeStamp.h> | |
31 | #include <TObjString.h> | |
32 | #include <TH2F.h> | |
33 | #include <TProfile.h> | |
34 | #include <TGraph.h> | |
35 | #include <TDatime.h> | |
36 | #include <TStyle.h> | |
37 | #include <TCanvas.h> | |
38 | ||
39 | ClassImp(AliTPCDataDCS) | |
40 | ||
41 | //--------------------------------------------------------------- | |
42 | AliTPCDataDCS::AliTPCDataDCS(): | |
43 | TObject(), | |
44 | fRun(0), | |
45 | fStartTime(0), | |
46 | fEndTime(0), | |
47 | fGraphs("TGraph",kNGraphs), | |
48 | fIsProcessed(kFALSE) | |
49 | { | |
50 | // default constructor | |
51 | ||
2bb7b766 | 52 | for(int i=0;i<kNHistos;i++) fHv[i]=0; |
53 | fFunc=0; | |
4b4eb769 | 54 | } |
55 | ||
56 | //--------------------------------------------------------------- | |
57 | AliTPCDataDCS::AliTPCDataDCS(Int_t nRun, UInt_t startTime, UInt_t endTime): | |
58 | TObject(), | |
59 | fRun(nRun), | |
60 | fStartTime(startTime), | |
61 | fEndTime(endTime), | |
62 | fGraphs("TGraph",kNGraphs), | |
63 | fIsProcessed(kFALSE) | |
64 | { | |
65 | // constructor | |
66 | ||
67 | AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", nRun, | |
68 | TTimeStamp(startTime).AsString(), | |
69 | TTimeStamp(endTime).AsString())); | |
70 | ||
2bb7b766 | 71 | for(int i=0;i<kNHistos;i++) fHv[i]=0; |
72 | fFunc=0; | |
4b4eb769 | 73 | |
74 | } | |
75 | ||
76 | //--------------------------------------------------------------- | |
77 | AliTPCDataDCS::~AliTPCDataDCS() | |
78 | { | |
79 | // destructor | |
80 | ||
2bb7b766 | 81 | Clean(); |
82 | } | |
83 | ||
84 | //--------------------------------------------------------------- | |
85 | void AliTPCDataDCS::Clean() | |
86 | { | |
87 | // destructor | |
88 | ||
89 | for(int i=0;i<kNHistos;i++) { | |
90 | if(fHv[i]) delete fHv[i]; | |
91 | fHv[i]=0; | |
92 | } | |
4b4eb769 | 93 | fGraphs.Clear("C"); |
2bb7b766 | 94 | if(fFunc) delete fFunc; |
4b4eb769 | 95 | fFunc=0; |
96 | } | |
97 | ||
2bb7b766 | 98 | //--------------------------------------------------------------- |
99 | void AliTPCDataDCS::Init() | |
100 | { | |
101 | // Init alias names and histos | |
102 | ||
103 | TH1::AddDirectory(kFALSE); | |
104 | ||
105 | fGraphs.SetOwner(1); | |
106 | ||
107 | for(int i=0;i<kNAliases;i++){ | |
108 | fAliasNames[i] = "TpcHvSect0"; | |
109 | fAliasNames[i] += i; | |
110 | fAliasNames[i] += ".FloatValue"; | |
111 | } | |
112 | ||
113 | for(int i=0;i<kNHistos;i++){ | |
114 | fHv[i] = new TH1F(fAliasNames[i].Data(),fAliasNames[i].Data(), 20, kHvMin, kHvMax); | |
115 | fHv[i]->GetXaxis()->SetTitle("Hv"); | |
116 | } | |
117 | } | |
118 | ||
4b4eb769 | 119 | //--------------------------------------------------------------- |
120 | void AliTPCDataDCS::ProcessData(TMap& aliasMap) | |
121 | { | |
122 | // process TMap of alias values retrieved from the DCS archive DB | |
123 | ||
2bb7b766 | 124 | Clean(); |
125 | Init(); | |
4b4eb769 | 126 | |
127 | TObjArray *aliasArr; | |
128 | AliDCSValue* aValue; | |
129 | for(int j=0; j<kNAliases; j++){ | |
130 | aliasArr = (TObjArray*) aliasMap.GetValue(fAliasNames[j].Data()); | |
131 | if(!aliasArr){ | |
132 | AliError(Form("Alias %s not found!", fAliasNames[j].Data())); | |
133 | continue; | |
134 | } | |
135 | Introduce(j, aliasArr); | |
136 | ||
137 | if(aliasArr->GetEntries()<2){ | |
138 | AliError(Form("Alias %s has just %d entries!", | |
139 | fAliasNames[j].Data(),aliasArr->GetEntries())); | |
140 | continue; | |
141 | } | |
142 | ||
143 | TIter iterarray(aliasArr); | |
144 | ||
145 | Double_t *time = new Double_t[aliasArr->GetEntries()]; | |
146 | Double_t *val = new Double_t[aliasArr->GetEntries()]; | |
147 | ||
148 | UInt_t ne=0; | |
149 | while ((aValue = (AliDCSValue*) iterarray.Next())) { | |
45a493ce | 150 | val[ne] = aValue->GetFloat(); |
4b4eb769 | 151 | time[ne] = (Double_t) (aValue->GetTimeStamp()); |
152 | // fill histos (alias 0-2) | |
153 | if(j < 3) fHv[j]->Fill(val[ne]); | |
154 | ne++; | |
155 | } | |
156 | // fill graphs (alias 3-5) | |
157 | if(j >= 3) CreateGraph(j, aliasArr->GetEntries(), time, val); | |
158 | delete[] val; | |
159 | delete[] time; | |
160 | } | |
161 | ||
162 | // calculate mean and rms of the first two histos | |
163 | for(int i=0;i<kNHistos;i++){ | |
164 | fMean[i] = fHv[i]->GetMean(); | |
165 | fWidth[i] = fHv[i]->GetRMS(); | |
166 | } | |
167 | ||
168 | // pol1 fit of the first graph | |
2bb7b766 | 169 | // if(fGraphs.GetEntries() > 0){ |
170 | // ((TGraph*) fGraphs.UncheckedAt(0))->Fit("pol1"); | |
171 | // fFunc = ((TGraph*) fGraphs.UncheckedAt(0))->GetFunction("pol1"); | |
172 | // } | |
4b4eb769 | 173 | |
174 | fIsProcessed=kTRUE; | |
175 | ||
176 | ||
177 | } | |
178 | ||
4b4eb769 | 179 | //--------------------------------------------------------------- |
180 | void AliTPCDataDCS::Introduce(UInt_t numAlias, const TObjArray* aliasArr) | |
181 | { | |
182 | // Say something about alias value array being processed | |
183 | ||
184 | int entries=aliasArr->GetEntries(); | |
185 | AliInfo(Form("************ Alias: %s **********",fAliasNames[numAlias].Data())); | |
186 | AliInfo(Form(" %d DP values collected",entries)); | |
187 | ||
188 | } | |
189 | ||
190 | //--------------------------------------------------------------- | |
191 | void AliTPCDataDCS::CreateGraph(int i, int dim, const Double_t *x, const Double_t *y) | |
192 | { | |
193 | // create TGraph to be filled with DP values | |
194 | ||
195 | TGraph *gr = new(fGraphs[fGraphs.GetEntriesFast()]) TGraph(dim, x, y); | |
196 | ||
197 | gr->GetXaxis()->SetTimeDisplay(1); | |
198 | gr->SetTitle(fAliasNames[i].Data()); | |
199 | ||
200 | AliInfo(Form("Array entries: %d",fGraphs.GetEntriesFast())); | |
201 | ||
202 | ||
203 | } | |
204 | ||
205 | //--------------------------------------------------------------- | |
206 | void AliTPCDataDCS::Draw(const Option_t* /*option*/) | |
207 | { | |
208 | // Draw all histos and graphs | |
209 | ||
210 | if(!fIsProcessed) return; | |
211 | ||
212 | TCanvas *ch; | |
213 | TString canvasHistoName="Histos"; | |
214 | ch=new TCanvas(canvasHistoName,canvasHistoName,20,20,600,600); | |
215 | ch->Divide(2,2); | |
216 | ch->cd(1); | |
217 | fHv[0]->Draw(); | |
218 | ch->cd(2); | |
219 | fHv[1]->Draw(); | |
220 | ch->cd(3); | |
221 | fHv[2]->Draw(); | |
222 | ||
223 | ||
224 | if(fGraphs.GetEntries() == 0) return; | |
225 | ||
226 | TCanvas *cg; | |
227 | TString canvasGraphName="Graphs"; | |
228 | cg=new TCanvas(canvasGraphName,canvasGraphName,40,40,600,600); | |
229 | cg->Divide(2,2); | |
230 | cg->cd(1); | |
231 | ((TGraph*) fGraphs.UncheckedAt(0))->Draw("alp"); | |
232 | ||
233 | cg->cd(2); | |
234 | ((TGraph*) fGraphs.UncheckedAt(1))->Draw("alp"); | |
235 | cg->cd(3); | |
236 | ((TGraph*) fGraphs.UncheckedAt(2))->Draw("alp"); | |
237 | ||
238 | if(fFunc){ | |
239 | cg->cd(4); | |
240 | fFunc->Draw("l"); | |
241 | } | |
242 | ||
243 | } | |
244 |