]>
Commit | Line | Data |
---|---|---|
4188a021 | 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 | #include "AliADDataDCS.h" | |
18 | ||
19 | #include "AliDCSValue.h" | |
20 | #include "AliLog.h" | |
21 | ||
22 | #include <TGraph.h> | |
23 | #include <TAxis.h> | |
24 | #include <TCanvas.h> | |
25 | #include <TTimeStamp.h> | |
26 | #include <TMap.h> | |
27 | #include <TString.h> | |
28 | #include <TObjString.h> | |
29 | #include <TH1F.h> | |
30 | ||
31 | class TH2; | |
32 | class AliCDBMetaData; | |
33 | class TDatime; | |
34 | ||
35 | // AliADDataDCS class | |
36 | // main aim to introduce the aliases for the AD DCS | |
37 | // data points to be then | |
38 | // stored in the OCDB, and to process them. | |
39 | // ProcessData() method called by ADPreprocessor | |
40 | ||
41 | ClassImp(AliADDataDCS) | |
42 | ||
43 | //_____________________________________________________________________________ | |
44 | AliADDataDCS::AliADDataDCS(): | |
45 | TObject(), | |
46 | fRun(0), | |
47 | fStartTime(0), | |
48 | fEndTime(0), | |
49 | fDaqStartTime(0), | |
50 | fDaqEndTime(0), | |
51 | fCtpStartTime(0), | |
52 | fCtpEndTime(0), | |
53 | fGraphs("TGraph",kNGraphs), | |
54 | fFEEParameters(NULL), | |
55 | fIsProcessed(kFALSE) | |
56 | ||
57 | { | |
58 | // Default constructor | |
59 | for(int i=0;i<kNHvChannel;i++) { | |
60 | fDeadChannel[i] = kFALSE; | |
61 | fMeanHV[i] = 100.0; | |
62 | fWidthHV[i] = 0.0; | |
63 | fHv[i] = NULL; | |
64 | } | |
65 | } | |
66 | ||
67 | //_____________________________________________________________________________ | |
68 | AliADDataDCS::AliADDataDCS(Int_t nRun, UInt_t startTime, UInt_t endTime, UInt_t daqStartTime, UInt_t daqEndTime, UInt_t ctpStartTime, UInt_t ctpEndTime): | |
69 | TObject(), | |
70 | fRun(nRun), | |
71 | fStartTime(startTime), | |
72 | fEndTime(endTime), | |
73 | fDaqStartTime(daqStartTime), | |
74 | fDaqEndTime(daqEndTime), | |
75 | fCtpStartTime(ctpStartTime), | |
76 | fCtpEndTime(ctpEndTime), | |
77 | fGraphs("TGraph",kNGraphs), | |
78 | fFEEParameters(new TMap()), | |
79 | fIsProcessed(kFALSE) | |
80 | ||
81 | { | |
82 | ||
83 | // constructor with arguments | |
84 | for(int i=0;i<kNHvChannel;i++) { | |
85 | fDeadChannel[i] = kFALSE; | |
86 | fMeanHV[i] = 100.0; | |
87 | fWidthHV[i] = 0.0; | |
88 | } | |
89 | AliInfo(Form("\n\tRun %d \n\tTime Created %s \n\tTime Completed %s \n\tDAQ start %s \n\tDAQ end %s \n\tCTP start %s \n\tCTP end %s ", nRun, | |
90 | TTimeStamp(startTime).AsString(), | |
91 | TTimeStamp(endTime).AsString(), | |
92 | TTimeStamp(daqStartTime).AsString(), | |
93 | TTimeStamp(daqEndTime).AsString(), | |
94 | TTimeStamp(ctpStartTime).AsString(), | |
95 | TTimeStamp(ctpEndTime).AsString() | |
96 | )); | |
97 | ||
98 | fFEEParameters->SetOwnerValue(); | |
99 | Init(); | |
100 | ||
101 | } | |
102 | ||
103 | //_____________________________________________________________________________ | |
104 | AliADDataDCS::~AliADDataDCS() { | |
105 | ||
106 | // destructor | |
107 | fGraphs.Clear("C"); | |
108 | delete fFEEParameters; | |
109 | ||
110 | } | |
111 | ||
112 | //_____________________________________________________________________________ | |
113 | Bool_t AliADDataDCS::ProcessData(TMap& aliasMap){ | |
114 | ||
115 | // method to process the data | |
116 | Bool_t success = kTRUE; | |
117 | ||
118 | if(!(fAliasNames[0])) Init(); | |
119 | ||
120 | TObjArray *aliasArr; | |
121 | AliDCSValue* aValue; | |
122 | ||
123 | // starting loop on aliases | |
124 | for(int iAlias=0; iAlias<kNAliases; iAlias++){ | |
125 | ||
126 | aliasArr = (TObjArray*) aliasMap.GetValue(fAliasNames[iAlias].Data()); | |
127 | if(!aliasArr){ | |
128 | AliError(Form("Alias %s not found!", fAliasNames[iAlias].Data())); | |
129 | success = kFALSE; | |
130 | continue; | |
131 | } | |
132 | ||
133 | //Introduce(iAlias, aliasArr); | |
134 | ||
135 | if(aliasArr->GetEntries()<2){ | |
136 | AliWarning(Form("Alias %s has just %d entries!", | |
137 | fAliasNames[iAlias].Data(),aliasArr->GetEntries())); | |
138 | } | |
139 | ||
140 | TIter iterarray(aliasArr); | |
141 | ||
142 | if(iAlias<kNHvChannel){ // Treating HV values | |
143 | Int_t nentries = aliasArr->GetEntries(); | |
144 | ||
145 | Double_t *times = new Double_t[nentries]; | |
146 | Double_t *values = new Double_t[nentries]; | |
147 | ||
148 | UInt_t iValue=0; | |
149 | Float_t variation = 0.0; | |
150 | ||
151 | while((aValue = (AliDCSValue*) iterarray.Next())) { | |
152 | UInt_t currentTime = aValue->GetTimeStamp(); | |
153 | //if(currentTime>fCtpEndTime) break; //What is this for? | |
154 | ||
155 | values[iValue] = aValue->GetFloat(); | |
156 | times[iValue] = (Double_t) (currentTime); | |
157 | ||
158 | if(iValue>0) { | |
159 | if(values[iValue-1]>0.) variation = TMath::Abs(values[iValue]-values[iValue-1])/values[iValue-1]; | |
160 | if(variation > 0.01) fDeadChannel[GetOfflineChannel(iAlias)] = kTRUE; | |
161 | } | |
162 | fHv[iAlias]->Fill(values[iValue]); | |
163 | printf("%s : %s : %f Dead=%d\n",fAliasNames[iAlias].Data(),TTimeStamp(currentTime).AsString(),values[iValue],fDeadChannel[GetOfflineChannel(iAlias)]); | |
164 | iValue++; | |
165 | } | |
166 | CreateGraph(iAlias, aliasArr->GetEntries(), times, values); // fill graphs | |
167 | ||
168 | // calculate mean and rms of the first two histos | |
169 | // and convert index to aliroot channel | |
170 | Int_t iChannel = GetOfflineChannel(iAlias); | |
171 | fMeanHV[iChannel] = fHv[iAlias]->GetMean(); | |
172 | fWidthHV[iChannel] = fHv[iAlias]->GetRMS(); | |
173 | ||
174 | delete[] values; | |
175 | delete[] times; | |
176 | } else { // Treating FEE Parameters | |
177 | AliDCSValue * lastVal = NULL; | |
178 | while((aValue = (AliDCSValue*) iterarray.Next())) lastVal = aValue; // Take only the last value | |
179 | fFEEParameters->Add(new TObjString(fAliasNames[iAlias].Data()),lastVal); | |
180 | } | |
181 | } | |
182 | ||
183 | fIsProcessed=kTRUE; | |
184 | ||
185 | return success; | |
186 | } | |
187 | ||
188 | //_____________________________________________________________________________ | |
189 | void AliADDataDCS::Init(){ | |
190 | ||
191 | // initialization of aliases and DCS data | |
192 | ||
193 | TString sindex; | |
194 | int iAlias = 0; | |
195 | ||
f8d28912 | 196 | for(int iPM = 0; iPM<16 ; iPM++){ |
197 | fAliasNames[iAlias] = Form("AD0/HV/PM%d",iPM); | |
4188a021 | 198 | |
f8d28912 | 199 | fHv[iAlias] = new TH1F(fAliasNames[iAlias].Data(),fAliasNames[iAlias].Data(), 3000, kHvMin, kHvMax); |
200 | fHv[iAlias]->GetXaxis()->SetTitle("Hv"); | |
201 | iAlias++; | |
4188a021 | 202 | } |
f8d28912 | 203 | // Time Resolution Parameters |
204 | for(int iCIU = 0; iCIU<2 ; iCIU++){ | |
4188a021 | 205 | fAliasNames[iAlias++] = Form("AD0/FEE/CIU%d/TimeResolution",iCIU); |
206 | fAliasNames[iAlias++] = Form("AD0/FEE/CIU%d/WidthResolution",iCIU); | |
f8d28912 | 207 | } |
208 | // HPTDC parameters | |
209 | for(int iCIU = 0; iCIU<2 ; iCIU++){ | |
210 | fAliasNames[iAlias++] = Form("AD0/FEE/CIU%d/MatchWindow",iCIU); | |
211 | fAliasNames[iAlias++] = Form("AD0/FEE/CIU%d/SearchWindow",iCIU); | |
212 | fAliasNames[iAlias++] = Form("AD0/FEE/CIU%d/TriggerCountOffset",iCIU); | |
213 | fAliasNames[iAlias++] = Form("AD0/FEE/CIU%d/RollOver",iCIU); | |
214 | } | |
4188a021 | 215 | |
f8d28912 | 216 | for(int iCIU = 0; iCIU<2 ; iCIU++){ |
4188a021 | 217 | for(int iCh=1;iCh<=8;iCh++){ |
f8d28912 | 218 | fAliasNames[iAlias++] = Form("AD0/FEE/CIU%d/DelayHit%d",iCIU,iCh); |
4188a021 | 219 | } |
f8d28912 | 220 | } |
4188a021 | 221 | |
f8d28912 | 222 | for(int iCIU = 0; iCIU<2 ; iCIU++){ |
4188a021 | 223 | for(int iCh=1;iCh<=8;iCh++){ |
f8d28912 | 224 | fAliasNames[iAlias++] = Form("AD0/FEE/CIU%d/DiscriThr%d",iCIU,iCh); |
4188a021 | 225 | } |
f8d28912 | 226 | } |
4188a021 | 227 | |
228 | if(iAlias!=kNAliases) | |
229 | AliError(Form("Number of DCS Aliases defined not correct")); | |
230 | ||
231 | } | |
232 | ||
233 | //_____________________________________________________________________________ | |
234 | void AliADDataDCS::Introduce(UInt_t numAlias, const TObjArray* aliasArr)const | |
235 | { | |
236 | ||
237 | // method to introduce new aliases | |
238 | ||
239 | int entries=aliasArr->GetEntries(); | |
240 | AliInfo(Form("************ Alias: %s **********",fAliasNames[numAlias].Data())); | |
241 | AliInfo(Form(" %d DP values collected",entries)); | |
242 | ||
243 | } | |
244 | ||
245 | //_____________________________________________________________________________ | |
246 | void AliADDataDCS::CreateGraph(int i, int dim, const Double_t *x, const Double_t *y) | |
247 | { | |
248 | ||
249 | // Create graphics | |
250 | ||
251 | TGraph *gr = new(fGraphs[fGraphs.GetEntriesFast()]) TGraph(dim, x, y); | |
252 | ||
253 | gr->GetXaxis()->SetTimeDisplay(1); | |
254 | gr->SetTitle(fAliasNames[i].Data()); | |
255 | ||
256 | AliInfo(Form("Array entries: %d",fGraphs.GetEntriesFast())); | |
257 | ||
258 | } | |
259 | ||
260 | ||
261 | //_____________________________________________________________________________ | |
262 | void AliADDataDCS::Draw(const Option_t* /*option*/) | |
263 | { | |
264 | // Draw all histos and graphs | |
265 | ||
266 | if(!fIsProcessed) return; | |
267 | ||
268 | if(fGraphs.GetEntries()==0) return; | |
269 | ||
f8d28912 | 270 | TCanvas *cHV = new TCanvas("AD0_HV","AD0_HV"); |
271 | cHV->Divide(4,4); | |
4188a021 | 272 | |
f8d28912 | 273 | for(int iPM = 0; iPM<16 ; iPM++){ |
274 | cHV->cd(iPM+1); | |
275 | ((TGraph*) fGraphs.UncheckedAt(iPM))->SetMarkerStyle(20); | |
276 | ((TGraph*) fGraphs.UncheckedAt(iPM))->Draw("ALP"); | |
4188a021 | 277 | } |
4188a021 | 278 | } |
279 |