]> git.uio.no Git - u/mrichter/AliRoot.git/blame - VZERO/AliVZERODataDCS.cxx
warning fix
[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>
28#include <TH1F.h>
76b6018a 29
30class TH2;
31class AliCDBMetaData;
32class TDatime;
33
34// AliVZERODataDCS class
35// main aim to introduce the aliases for the VZERO DCS
36// data points to be then
37// stored in the OCDB, and to process them.
38// ProcessData() method called by VZEROPreprocessor
39
40ClassImp(AliVZERODataDCS)
41
42//_____________________________________________________________________________
43AliVZERODataDCS::AliVZERODataDCS():
44 TObject(),
45 fRun(0),
46 fStartTime(0),
47 fEndTime(0),
48 fGraphs("TGraph",kNGraphs),
49 fIsProcessed(kFALSE)
50{
51 // Default constructor
7495d2be 52 for(int i=0;i<kNHvChannel;i++) fDeadChannel[i] = kFALSE;
76b6018a 53}
54
55//_____________________________________________________________________________
56AliVZERODataDCS::AliVZERODataDCS(Int_t nRun, UInt_t startTime, UInt_t endTime):
57 TObject(),
58 fRun(nRun),
59 fStartTime(startTime),
60 fEndTime(endTime),
61 fGraphs("TGraph",kNGraphs),
62 fIsProcessed(kFALSE)
63{
64
65 // constructor with arguments
7495d2be 66 for(int i=0;i<kNHvChannel;i++) fDeadChannel[i] = kFALSE;
76b6018a 67
68 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", nRun,
69 TTimeStamp(startTime).AsString(),
70 TTimeStamp(endTime).AsString()));
71
72 Init();
73
74}
75
76//_____________________________________________________________________________
77AliVZERODataDCS::~AliVZERODataDCS() {
78
79 // destructor
80 fGraphs.Clear("C");
81
82}
83
84//_____________________________________________________________________________
85void AliVZERODataDCS::ProcessData(TMap& aliasMap){
86
87 // method to process the data
88
89 if(!(fAliasNames[0])) Init();
90
91 TObjArray *aliasArr;
92 AliDCSValue* aValue;
93
94 // starting loop on aliases
95 for(int iAlias=0; iAlias<kNAliases; iAlias++){
96
97 aliasArr = (TObjArray*) aliasMap.GetValue(fAliasNames[iAlias].Data());
98 if(!aliasArr){
99 AliError(Form("Alias %s not found!", fAliasNames[iAlias].Data()));
100 return;
101 }
102
fad64858 103 //Introduce(iAlias, aliasArr);
76b6018a 104
105 if(aliasArr->GetEntries()<2){
106 AliError(Form("Alias %s has just %d entries!",
107 fAliasNames[iAlias].Data(),aliasArr->GetEntries()));
108 continue;
109 }
110
111 TIter iterarray(aliasArr);
112
113 Int_t nentries = aliasArr->GetEntries();
114
80663cb8 115 Double_t *times = new Double_t[nentries];
116 Double_t *values = new Double_t[nentries];
76b6018a 117
118 UInt_t iValue=0;
d2f86b51 119 Float_t variation = 0.0;
120
76b6018a 121 while((aValue = (AliDCSValue*) iterarray.Next())) {
80663cb8 122 values[iValue] = aValue->GetFloat();
7495d2be 123 if(iValue>0) {
7495d2be 124 if(values[iValue-1]>0.) variation = TMath::Abs(values[iValue]-values[iValue-1])/values[iValue-1];
125 if(variation > 0.10) fDeadChannel[GetOfflineChannel(iAlias)] = kTRUE;
126 }
80663cb8 127 times[iValue] = (Double_t) (aValue->GetTimeStamp());
128 fHv[iAlias]->Fill(values[iValue]);
7495d2be 129 printf("%s %f Dead=%d\n",fAliasNames[iAlias].Data(),values[iValue],fDeadChannel[GetOfflineChannel(iAlias)]);
76b6018a 130 iValue++;
131 }
80663cb8 132 CreateGraph(iAlias, aliasArr->GetEntries(), times, values); // fill graphs
76b6018a 133
80663cb8 134 delete[] values;
135 delete[] times;
76b6018a 136 }
137
138 // calculate mean and rms of the first two histos
ebee0db9 139 // and convert index to aliroot channel
76b6018a 140 for(int i=0;i<kNAliases;i++){
ebee0db9 141 Int_t iChannel = GetOfflineChannel(i);
142 fMeanHV[iChannel] = fHv[i]->GetMean();
143 fWidthHV[iChannel] = fHv[i]->GetRMS();
76b6018a 144 }
76b6018a 145
146 fIsProcessed=kTRUE;
147}
148
149//_____________________________________________________________________________
150void AliVZERODataDCS::Init(){
151
152 // initialization of aliases and DCS data
153
154 TString sindex;
155 int iAlias = 0;
156
157 for(int iSide = 0; iSide<2 ; iSide++){
158 for(int iRing = 0; iRing<4 ; iRing++){
159 for(int iSector = 0; iSector<8 ; iSector++){
160 if(iSide == 0) fAliasNames[iAlias] = "V00/HV/V0A/SECTOR";
161 else fAliasNames[iAlias] = "V00/HV/V0C/SECTOR";
162 sindex.Form("%d/RING%d",iSector,iRing);
163 fAliasNames[iAlias] += sindex;
164
165 fHv[iAlias] = new TH1F(fAliasNames[iAlias].Data(),fAliasNames[iAlias].Data(), 2000, kHvMin, kHvMax);
166 fHv[iAlias]->GetXaxis()->SetTitle("Hv");
167 iAlias++;
168 }
169 }
170 }
171 if(iAlias!=kNAliases)
172 AliError(Form("Number of DCS Aliases defined not correct"));
173
174}
175
176//_____________________________________________________________________________
177void AliVZERODataDCS::Introduce(UInt_t numAlias, const TObjArray* aliasArr)const
178{
179
180 // method to introduce new aliases
181
c61a7285 182 int entries=aliasArr->GetEntries();
76b6018a 183 AliInfo(Form("************ Alias: %s **********",fAliasNames[numAlias].Data()));
184 AliInfo(Form(" %d DP values collected",entries));
185
186}
187
188//_____________________________________________________________________________
189void AliVZERODataDCS::CreateGraph(int i, int dim, const Double_t *x, const Double_t *y)
190{
191
192 // Create graphics
193
194 TGraph *gr = new(fGraphs[fGraphs.GetEntriesFast()]) TGraph(dim, x, y);
195
196 gr->GetXaxis()->SetTimeDisplay(1);
197 gr->SetTitle(fAliasNames[i].Data());
198
199 AliInfo(Form("Array entries: %d",fGraphs.GetEntriesFast()));
200
201}
202
203
204//_____________________________________________________________________________
205void AliVZERODataDCS::Draw(const Option_t* /*option*/)
206{
207// Draw all histos and graphs
208
209 if(!fIsProcessed) return;
210
211 if(fGraphs.GetEntries()==0) return;
212
80663cb8 213 TString canvasName;
76b6018a 214 TCanvas *cHV[8];
215
216 for(int iSide = 0 ;iSide<2;iSide++){
217 for(int iRing=0;iRing<4;iRing++){
80663cb8 218 if(iSide == 0) canvasName = "V0A_Ring";
219 else canvasName = "V0C_Ring";
220 canvasName += iRing;
76b6018a 221 int iCanvas = iSide*4 + iRing;
80663cb8 222 cHV[iCanvas] = new TCanvas(canvasName,canvasName);
76b6018a 223 cHV[iCanvas]->Divide(3,3);
224 for(int iSector=0;iSector<8;iSector++){
225 cHV[iCanvas]->cd(iSector+1);
226 int iChannel = iSide*32 + iRing*8 + iSector;
227 ((TGraph*) fGraphs.UncheckedAt(iChannel))->SetMarkerStyle(20);
228 ((TGraph*) fGraphs.UncheckedAt(iChannel))->Draw("ALP");
229
230 }
231
232 }
233 }
234
235}
236