1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
21 // Class to simulate the
22 // data coming from DCS
23 // for a test preprocessor
26 #include "AliTestDataDCS.h"
28 #include "AliDCSValue.h"
31 #include <TTimeStamp.h>
34 #include <TObjArray.h>
37 ClassImp(AliTestDataDCS)
39 //---------------------------------------------------------------
40 AliTestDataDCS::AliTestDataDCS():
45 fGraphs("TGraph",kNGraphs),
48 for(int i=0;i<kNHistos;i++) fHv[i]=0x0;
52 //---------------------------------------------------------------
53 AliTestDataDCS::AliTestDataDCS(Int_t nRun, UInt_t startTime, UInt_t endTime):
56 fStartTime(startTime),
58 fGraphs("TGraph",kNGraphs),
66 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", nRun,
67 TTimeStamp(startTime).AsString(),
68 TTimeStamp(endTime).AsString()));
75 //---------------------------------------------------------------
76 AliTestDataDCS::~AliTestDataDCS() {
78 for(int i=0;i<kNHistos;i++) {delete fHv[i]; fHv[i]=0;}
83 //---------------------------------------------------------------
84 void AliTestDataDCS::ProcessData(TMap& aliasMap){
87 // processing the data
94 for(int j=0; j<kNAliases; j++){
95 aliasArr = (TObjArray*) aliasMap.GetValue(fAliasNames[j].Data());
97 AliError(Form("Alias %s not found!", fAliasNames[j].Data()));
100 Introduce(j, aliasArr);
102 if(aliasArr->GetEntries()<2){
103 AliError(Form("Alias %s has just %d entries!",
104 fAliasNames[j].Data(),aliasArr->GetEntries()));
108 TIter iterarray(aliasArr);
110 Double_t *time = new Double_t[aliasArr->GetEntries()];
111 Double_t *val = new Double_t[aliasArr->GetEntries()];
114 while ((aValue = (AliDCSValue*) iterarray.Next())) {
116 val[ne] = aValue->GetFloat();
117 time[ne] = (Double_t) (aValue->GetTimeStamp());
118 // fill histos (alias 0-2)
119 if(j < 3) fHv[j]->Fill(val[ne]);
122 // fill graphs (alias 3-5)
123 if(j >= 3) CreateGraph(j, aliasArr->GetEntries(), time, val);
128 // calculate mean and rms of the first two histos
129 for(int i=0;i<kNHistos;i++){
130 fMean[i] = fHv[i]->GetMean();
131 fWidth[i] = fHv[i]->GetRMS();
134 // pol1 fit of the first graph
135 if(fGraphs.GetEntries() > 0){
136 ((TGraph*) fGraphs.UncheckedAt(0))->Fit("pol1");
137 fFunc = ((TGraph*) fGraphs.UncheckedAt(0))->GetFunction("pol1");
145 //---------------------------------------------------------------
146 void AliTestDataDCS::Init(){
152 TH1::AddDirectory(kFALSE);
156 for(int i=0;i<kNAliases;i++){
157 fAliasNames[i] = "DCSAlias";
161 for(int i=0;i<kNHistos;i++){
162 fHv[i] = new TH1F(fAliasNames[i].Data(),fAliasNames[i].Data(), 20, kHvMin, kHvMax);
163 fHv[i]->GetXaxis()->SetTitle("Hv");
167 //---------------------------------------------------------------
168 void AliTestDataDCS::Introduce(UInt_t numAlias, const TObjArray* aliasArr){
170 int entries=aliasArr->GetEntries();
171 AliInfo(Form("************ Alias: %s **********",fAliasNames[numAlias].Data()));
172 AliInfo(Form(" %d DP values collected",entries));
176 //---------------------------------------------------------------
177 void AliTestDataDCS::CreateGraph(int i, int dim, const Double_t *x, const Double_t *y)
180 TGraph *gr = new(fGraphs[fGraphs.GetEntriesFast()]) TGraph(dim, x, y);
182 gr->GetXaxis()->SetTimeDisplay(1);
183 gr->SetTitle(fAliasNames[i].Data());
185 AliInfo(Form("Array entries: %d",fGraphs.GetEntriesFast()));
190 //---------------------------------------------------------------
191 void AliTestDataDCS::Draw(const Option_t* /*option*/)
194 // Draw all histos and graphs
197 if(!fIsProcessed) return;
200 TString canvasHistoName="Histos";
201 ch=new TCanvas(canvasHistoName,canvasHistoName,20,20,600,600);
211 if(fGraphs.GetEntries() == 0) return;
214 TString canvasGraphName="Graphs";
215 cg=new TCanvas(canvasGraphName,canvasGraphName,40,40,600,600);
218 ((TGraph*) fGraphs.UncheckedAt(0))->Draw("alp");
221 ((TGraph*) fGraphs.UncheckedAt(1))->Draw("alp");
223 ((TGraph*) fGraphs.UncheckedAt(2))->Draw("alp");