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