]>
Commit | Line | Data |
---|---|---|
3b181530 | 1 | /**************************************************** |
2 | ||
3 | AliACORDEDataDCS class | |
4 | create to make a pointer to the | |
5 | ACORDE data DCS points | |
6 | ||
7 | Author: Pedro Gonzalez (CIEMAT, Madrid) | |
8 | ACORDE-DCS creator: Mario Ivan Martinez Hdez | |
9 | <mim@fcfm.buap.mx> | |
10 | ||
11 | Last update: Fix of coding violations | |
12 | Mario Rodriguez C. (FCFM-BUAP) | |
13 | <mrodrigu@mail.cern.ch> | |
14 | ||
15 | *****************************************************/ | |
749347ef | 16 | #include "AliACORDEDataDCS.h" |
17 | ||
18 | #include "AliCDBMetaData.h" | |
19 | #include "AliDCSValue.h" | |
20 | #include "AliLog.h" | |
21 | ||
22 | #include <TTimeStamp.h> | |
23 | #include <TObjString.h> | |
24 | #include <TH2F.h> | |
25 | #include <TProfile.h> | |
26 | #include <TGraph.h> | |
27 | #include <TDatime.h> | |
28 | #include <TStyle.h> | |
29 | #include <TCanvas.h> | |
30 | ||
31 | ClassImp(AliACORDEDataDCS) | |
32 | ||
33 | //--------------------------------------------------------------- | |
34 | AliACORDEDataDCS::AliACORDEDataDCS(): | |
35 | TObject(), | |
36 | fRun(0), | |
37 | fStartTime(0), | |
38 | fEndTime(0), | |
39 | fGraphs("TGraph",kNGraphs), | |
5d8a7578 | 40 | fFunc(0), |
749347ef | 41 | fIsProcessed(kFALSE) |
42 | { | |
ea3dd546 | 43 | for(int i=0;i<kNHistos;i++) |
44 | { | |
45 | fHv[i]=0x0; | |
46 | fMean[i] = fWidth[i] = 0.0; | |
47 | } | |
5d8a7578 | 48 | |
749347ef | 49 | } |
50 | ||
51 | //--------------------------------------------------------------- | |
52 | AliACORDEDataDCS::AliACORDEDataDCS(Int_t nRun, UInt_t startTime, UInt_t endTime): | |
53 | TObject(), | |
54 | fRun(nRun), | |
55 | fStartTime(startTime), | |
56 | fEndTime(endTime), | |
57 | fGraphs("TGraph",kNGraphs), | |
5d8a7578 | 58 | fFunc(0), |
749347ef | 59 | fIsProcessed(kFALSE) |
60 | { | |
3b181530 | 61 | // Init of class AliACORDEDataDCS |
62 | // Gettin the TimeStamp an put it on a string | |
63 | ||
749347ef | 64 | AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", nRun, |
65 | TTimeStamp(startTime).AsString(), | |
66 | TTimeStamp(endTime).AsString())); | |
67 | ||
5d8a7578 | 68 | |
749347ef | 69 | Init(); |
70 | ||
71 | } | |
72 | ||
73 | //--------------------------------------------------------------- | |
74 | AliACORDEDataDCS::~AliACORDEDataDCS() { | |
75 | ||
392813bf | 76 | for(int i=0;i<kNHistos;i++) |
77 | { | |
78 | delete fHv[i]; fHv[i]=0; | |
79 | } | |
749347ef | 80 | fGraphs.Clear("C"); |
81 | fFunc=0; | |
82 | } | |
5d8a7578 | 83 | //--------------------------------------------------------------- |
84 | ||
85 | AliACORDEDataDCS::AliACORDEDataDCS(const AliACORDEDataDCS & data): | |
86 | TObject(), | |
87 | fRun(0), | |
88 | fStartTime(0), | |
89 | fEndTime(0), | |
90 | fGraphs("TGraph",kNGraphs), | |
91 | fFunc(0), | |
92 | fIsProcessed(kFALSE) | |
93 | { | |
3b181530 | 94 | // Setting the initial values |
95 | // fRUn, Start of Run, End of Run, IsProcessed | |
5d8a7578 | 96 | |
97 | fRun=data.fRun; | |
98 | fStartTime=data.fStartTime; | |
99 | fEndTime=data.fEndTime; | |
100 | fFunc=data.fFunc; | |
101 | fIsProcessed=data.fIsProcessed; | |
102 | ||
103 | ||
104 | for(int i=0;i<kNAliases;i++){fAliasNames[i] = data.fAliasNames[i];} | |
105 | ||
392813bf | 106 | for(int i=0;i<kNHistos;i++) |
107 | { | |
108 | fHv[i]=data.fHv[i]; | |
109 | fMean[i]=data.fMean[i]; | |
110 | fWidth[i]=data.fWidth[i]; | |
111 | } | |
5d8a7578 | 112 | |
749347ef | 113 | |
5d8a7578 | 114 | |
115 | ||
116 | } | |
117 | //-------------------------------------------------------------- | |
118 | AliACORDEDataDCS& AliACORDEDataDCS:: operator=(const AliACORDEDataDCS & data) { | |
119 | ||
81f0f392 | 120 | // use ctor copy |
5d8a7578 | 121 | |
81f0f392 | 122 | if (&data == this) return *this; |
5d8a7578 | 123 | |
81f0f392 | 124 | new (this) AliACORDEDataDCS(data); |
125 | return *this; | |
5d8a7578 | 126 | |
127 | } | |
749347ef | 128 | //--------------------------------------------------------------- |
3b181530 | 129 | void AliACORDEDataDCS::ProcessData(TMap& aliasMap) |
130 | { | |
131 | // Process of the data from the aliases DCS-data points | |
749347ef | 132 | |
133 | if(!(fHv[0])) Init(); | |
134 | ||
135 | TObjArray *aliasArr; | |
136 | AliDCSValue* aValue; | |
137 | ||
138 | for(int j=0; j<kNAliases; j++) | |
139 | { | |
140 | aliasArr = (TObjArray*) aliasMap.GetValue(fAliasNames[j].Data()); | |
141 | if(!aliasArr) | |
142 | { | |
143 | AliError(Form("Alias %s not found!", fAliasNames[j].Data())); | |
144 | continue; | |
145 | } | |
146 | Introduce(j, aliasArr); | |
147 | ||
148 | if(aliasArr->GetEntries()<2) | |
149 | { | |
ea3dd546 | 150 | AliError(Form("Alias %s has just %d entries!", |
749347ef | 151 | fAliasNames[j].Data(),aliasArr->GetEntries())); |
152 | continue; | |
153 | } | |
154 | ||
155 | TIter iterarray(aliasArr); | |
156 | ||
157 | Double_t *time = new Double_t[aliasArr->GetEntries()]; | |
158 | Double_t *val = new Double_t[aliasArr->GetEntries()]; | |
159 | ||
160 | UInt_t ne=0; | |
161 | ||
162 | while ((aValue = (AliDCSValue*) iterarray.Next())) | |
163 | { | |
164 | val[ne] = aValue->GetFloat(); | |
165 | time[ne] = (Double_t) (aValue->GetTimeStamp()); | |
166 | fHv[j]->Fill(val[ne]); | |
167 | ne++; | |
168 | } | |
169 | ||
170 | ||
171 | ||
172 | CreateGraph(j, aliasArr->GetEntries(), time, val); | |
173 | delete[] val; | |
174 | delete[] time; | |
175 | } | |
176 | ||
177 | ||
178 | // calculate mean and rms of the first two histos | |
179 | for(int i=0;i<kNHistos;i++) | |
180 | { | |
181 | fMean[i] = fHv[i]->GetMean(); | |
182 | fWidth[i] = fHv[i]->GetRMS(); | |
183 | } | |
184 | ||
185 | ||
186 | fIsProcessed=kTRUE; | |
187 | ||
188 | ||
189 | } | |
190 | ||
191 | //--------------------------------------------------------------- | |
3b181530 | 192 | void AliACORDEDataDCS::Init() |
193 | { | |
194 | // Init of AliACORDEDatDCS procedure | |
195 | // Loop over the aliases | |
749347ef | 196 | |
197 | TH1::AddDirectory(kFALSE); | |
198 | ||
199 | fGraphs.SetOwner(1); | |
200 | ||
201 | TString aliasName; | |
202 | ||
203 | for(int i=0;i<kNAliases;i++){ | |
204 | ||
205 | aliasName.Form("ACO_HV_MODULE%02d_VMON",i); | |
206 | fAliasNames[i] = aliasName; | |
207 | } | |
208 | ||
209 | for(int i=0;i<kNHistos;i++) | |
210 | { | |
211 | fHv[i] = new TH1F(fAliasNames[i].Data(),fAliasNames[i].Data(), 20, kHvMin, kHvMax); | |
212 | fHv[i]->GetXaxis()->SetTitle("Hv"); | |
213 | } | |
214 | } | |
215 | ||
216 | //--------------------------------------------------------------- | |
217 | void AliACORDEDataDCS::Introduce(UInt_t numAlias, const TObjArray* aliasArr) | |
218 | { | |
219 | ||
220 | int entries=aliasArr->GetEntries(); | |
221 | AliInfo(Form("************ Alias: %s **********",fAliasNames[numAlias].Data())); | |
222 | AliInfo(Form(" %d DP values collected",entries)); | |
223 | ||
224 | } | |
225 | ||
226 | //--------------------------------------------------------------- | |
227 | void AliACORDEDataDCS::CreateGraph(int i, int dim, const Double_t *x, const Double_t *y) | |
228 | { | |
3b181530 | 229 | // Create the plots for the ACORDE DCS |
749347ef | 230 | |
231 | TGraph *gr = new(fGraphs[fGraphs.GetEntriesFast()]) TGraph(dim, x, y); | |
232 | ||
233 | gr->GetXaxis()->SetTimeDisplay(1); | |
234 | gr->SetTitle(fAliasNames[i].Data()); | |
235 | ||
236 | AliInfo(Form("Array entries: %d",fGraphs.GetEntriesFast())); | |
237 | ||
238 | ||
239 | } | |
240 | ||
241 | //--------------------------------------------------------------- | |
242 | void AliACORDEDataDCS::Draw(const Option_t* /*option*/) | |
243 | { | |
244 | // Draw all histos and graphs | |
245 | ||
246 | if(!fIsProcessed) return; | |
247 | ||
248 | TString canvasHistoName; | |
249 | TCanvas *ch[10]; | |
250 | ||
251 | for (int i=0;i<10;i++) | |
252 | { | |
253 | canvasHistoName.Form("ACO_HV_MODULE"); | |
254 | ch[i]=new TCanvas(canvasHistoName,canvasHistoName,20,20,600,600); | |
255 | ch[i]->Divide(2,3); | |
256 | ||
257 | for(int j=0;j<6;j++) | |
258 | { | |
259 | ch[i]->cd(j+1); | |
260 | ((TGraph*) fGraphs.UncheckedAt(i*6+j))->SetMarkerStyle(20); | |
261 | ((TGraph*) fGraphs.UncheckedAt(i*6+j))->Draw("alp"); | |
262 | } | |
263 | ||
264 | } | |
265 | ||
266 | ||
267 | } | |
268 |