]> git.uio.no Git - u/mrichter/AliRoot.git/blame - VZERO/AliVZERODataDCS.cxx
replace abort by AliFatal
[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),
e20f4da1 51 fCtpStartTime(0),
52 fCtpEndTime(0),
d5deaaa5 53 fGraphs("TGraph",kNGraphs),
54 fFEEParameters(NULL),
76b6018a 55 fIsProcessed(kFALSE)
d5deaaa5 56
76b6018a 57{
58 // Default constructor
33e193fc 59 for(int i=0;i<kNHvChannel;i++) {
60 fDeadChannel[i] = kFALSE;
61 fMeanHV[i] = 100.0;
62 fWidthHV[i] = 0.0;
127e0d90 63 fHv[i] = NULL;
33e193fc 64 }
76b6018a 65}
66
67//_____________________________________________________________________________
e20f4da1 68AliVZERODataDCS::AliVZERODataDCS(Int_t nRun, UInt_t startTime, UInt_t endTime, UInt_t daqStartTime, UInt_t daqEndTime, UInt_t ctpStartTime, UInt_t ctpEndTime):
76b6018a 69 TObject(),
70 fRun(nRun),
71 fStartTime(startTime),
72 fEndTime(endTime),
3b757990 73 fDaqStartTime(daqStartTime),
74 fDaqEndTime(daqEndTime),
e20f4da1 75 fCtpStartTime(ctpStartTime),
76 fCtpEndTime(ctpEndTime),
d5deaaa5 77 fGraphs("TGraph",kNGraphs),
78 fFEEParameters(new TMap()),
76b6018a 79 fIsProcessed(kFALSE)
d5deaaa5 80
76b6018a 81{
82
83 // constructor with arguments
33e193fc 84 for(int i=0;i<kNHvChannel;i++) {
85 fDeadChannel[i] = kFALSE;
86 fMeanHV[i] = 100.0;
87 fWidthHV[i] = 0.0;
88 }
e20f4da1 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,
d5deaaa5 90 TTimeStamp(startTime).AsString(),
3b757990 91 TTimeStamp(endTime).AsString(),
92 TTimeStamp(daqStartTime).AsString(),
e20f4da1 93 TTimeStamp(daqEndTime).AsString(),
94 TTimeStamp(ctpStartTime).AsString(),
95 TTimeStamp(ctpEndTime).AsString()
96 ));
d5deaaa5 97
98 fFEEParameters->SetOwnerValue();
76b6018a 99 Init();
100
101}
102
103//_____________________________________________________________________________
104AliVZERODataDCS::~AliVZERODataDCS() {
105
106 // destructor
107 fGraphs.Clear("C");
d5deaaa5 108 delete fFEEParameters;
76b6018a 109
110}
111
112//_____________________________________________________________________________
75f53676 113Bool_t AliVZERODataDCS::ProcessData(TMap& aliasMap){
76b6018a 114
115 // method to process the data
75f53676 116 Bool_t success = kTRUE;
76b6018a 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()));
75f53676 129 success = kFALSE;
263a0103 130 continue;
76b6018a 131 }
132
fad64858 133 //Introduce(iAlias, aliasArr);
76b6018a 134
135 if(aliasArr->GetEntries()<2){
d5deaaa5 136 AliWarning(Form("Alias %s has just %d entries!",
76b6018a 137 fAliasNames[iAlias].Data(),aliasArr->GetEntries()));
76b6018a 138 }
139
140 TIter iterarray(aliasArr);
d5deaaa5 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())) {
3b757990 152 UInt_t currentTime = aValue->GetTimeStamp();
e20f4da1 153 if(currentTime>fCtpEndTime) break;
56b45b3b 154
155 values[iValue] = aValue->GetFloat();
3b757990 156 times[iValue] = (Double_t) (currentTime);
157
d5deaaa5 158 if(iValue>0) {
159 if(values[iValue-1]>0.) variation = TMath::Abs(values[iValue]-values[iValue-1])/values[iValue-1];
56b45b3b 160 if(variation > 0.01) fDeadChannel[GetOfflineChannel(iAlias)] = kTRUE;
d5deaaa5 161 }
d5deaaa5 162 fHv[iAlias]->Fill(values[iValue]);
e20f4da1 163 printf("%s : %s : %f Dead=%d\n",fAliasNames[iAlias].Data(),TTimeStamp(currentTime).AsString(),values[iValue],fDeadChannel[GetOfflineChannel(iAlias)]);
d5deaaa5 164 iValue++;
165 }
166 CreateGraph(iAlias, aliasArr->GetEntries(), times, values); // fill graphs
167
263a0103 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
d5deaaa5 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 }
76b6018a 181 }
182
76b6018a 183 fIsProcessed=kTRUE;
75f53676 184
185 return success;
76b6018a 186}
187
188//_____________________________________________________________________________
189void AliVZERODataDCS::Init(){
190
191 // initialization of aliases and DCS data
192
193 TString sindex;
194 int iAlias = 0;
195
196 for(int iSide = 0; iSide<2 ; iSide++){
197 for(int iRing = 0; iRing<4 ; iRing++){
198 for(int iSector = 0; iSector<8 ; iSector++){
199 if(iSide == 0) fAliasNames[iAlias] = "V00/HV/V0A/SECTOR";
200 else fAliasNames[iAlias] = "V00/HV/V0C/SECTOR";
201 sindex.Form("%d/RING%d",iSector,iRing);
202 fAliasNames[iAlias] += sindex;
203
1646eccd 204 fHv[iAlias] = new TH1F(fAliasNames[iAlias].Data(),fAliasNames[iAlias].Data(), 3000, kHvMin, kHvMax);
76b6018a 205 fHv[iAlias]->GetXaxis()->SetTitle("Hv");
206 iAlias++;
207 }
208 }
209 }
d5deaaa5 210
211 // Time Resolution Parameters
212
213 for(int iCIU = 0; iCIU<8 ; iCIU++){
214 fAliasNames[iAlias++] = Form("V00/FEE/CIU%d/TimeResolution",iCIU);
215 fAliasNames[iAlias++] = Form("V00/FEE/CIU%d/WidthResolution",iCIU);
216 }
217
32cd3fdc 218 // HPTDC parameters
219 for(int iCIU = 0; iCIU<8 ; iCIU++){
220 fAliasNames[iAlias++] = Form("V00/FEE/CIU%d/MatchWindow",iCIU);
221 fAliasNames[iAlias++] = Form("V00/FEE/CIU%d/SearchWindow",iCIU);
222 fAliasNames[iAlias++] = Form("V00/FEE/CIU%d/TriggerCountOffset",iCIU);
223 fAliasNames[iAlias++] = Form("V00/FEE/CIU%d/RollOver",iCIU);
224 }
225
57c7500a 226 for(int iCIU = 0; iCIU<8 ; iCIU++){
227 for(int iCh=1;iCh<=8;iCh++){
228 fAliasNames[iAlias++] = Form("V00/FEE/CIU%d/DelayHit%d",iCIU,iCh);
229 }
230 }
231
6e2c3e87 232 for(int iCIU = 0; iCIU<8 ; iCIU++){
233 for(int iCh=1;iCh<=8;iCh++){
234 fAliasNames[iAlias++] = Form("V00/FEE/CIU%d/DiscriThr%d",iCIU,iCh);
235 }
236 }
237
76b6018a 238 if(iAlias!=kNAliases)
239 AliError(Form("Number of DCS Aliases defined not correct"));
240
241}
242
243//_____________________________________________________________________________
244void AliVZERODataDCS::Introduce(UInt_t numAlias, const TObjArray* aliasArr)const
245{
246
247 // method to introduce new aliases
248
c61a7285 249 int entries=aliasArr->GetEntries();
76b6018a 250 AliInfo(Form("************ Alias: %s **********",fAliasNames[numAlias].Data()));
251 AliInfo(Form(" %d DP values collected",entries));
252
253}
254
255//_____________________________________________________________________________
256void AliVZERODataDCS::CreateGraph(int i, int dim, const Double_t *x, const Double_t *y)
257{
258
259 // Create graphics
260
261 TGraph *gr = new(fGraphs[fGraphs.GetEntriesFast()]) TGraph(dim, x, y);
262
263 gr->GetXaxis()->SetTimeDisplay(1);
264 gr->SetTitle(fAliasNames[i].Data());
265
266 AliInfo(Form("Array entries: %d",fGraphs.GetEntriesFast()));
267
268}
269
270
271//_____________________________________________________________________________
272void AliVZERODataDCS::Draw(const Option_t* /*option*/)
273{
274// Draw all histos and graphs
275
276 if(!fIsProcessed) return;
277
278 if(fGraphs.GetEntries()==0) return;
279
80663cb8 280 TString canvasName;
76b6018a 281 TCanvas *cHV[8];
282
283 for(int iSide = 0 ;iSide<2;iSide++){
284 for(int iRing=0;iRing<4;iRing++){
80663cb8 285 if(iSide == 0) canvasName = "V0A_Ring";
286 else canvasName = "V0C_Ring";
287 canvasName += iRing;
76b6018a 288 int iCanvas = iSide*4 + iRing;
80663cb8 289 cHV[iCanvas] = new TCanvas(canvasName,canvasName);
76b6018a 290 cHV[iCanvas]->Divide(3,3);
291 for(int iSector=0;iSector<8;iSector++){
292 cHV[iCanvas]->cd(iSector+1);
293 int iChannel = iSide*32 + iRing*8 + iSector;
294 ((TGraph*) fGraphs.UncheckedAt(iChannel))->SetMarkerStyle(20);
295 ((TGraph*) fGraphs.UncheckedAt(iChannel))->Draw("ALP");
296
297 }
298
299 }
300 }
301
302}
303