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 **************************************************************************/
18 // This is an example of a container class
19 // of the data retreieved from the DCS archive DB.
20 // It is called by the detector's Preprocessor and
21 // it is stored in the CDB.
24 #include "AliTPCDataDCS.h"
26 #include "AliCDBMetaData.h"
27 #include "AliDCSValue.h"
30 #include <TTimeStamp.h>
31 #include <TObjString.h>
39 ClassImp(AliTPCDataDCS)
41 //---------------------------------------------------------------
42 AliTPCDataDCS::AliTPCDataDCS():
47 fGraphs("TGraph",kNGraphs),
50 // default constructor
52 for(int i=0;i<kNHistos;i++) fHv[i]=0;
56 //---------------------------------------------------------------
57 AliTPCDataDCS::AliTPCDataDCS(Int_t nRun, UInt_t startTime, UInt_t endTime):
60 fStartTime(startTime),
62 fGraphs("TGraph",kNGraphs),
67 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", nRun,
68 TTimeStamp(startTime).AsString(),
69 TTimeStamp(endTime).AsString()));
71 for(int i=0;i<kNHistos;i++) fHv[i]=0;
76 //---------------------------------------------------------------
77 AliTPCDataDCS::~AliTPCDataDCS()
84 //---------------------------------------------------------------
85 void AliTPCDataDCS::Clean()
89 for(int i=0;i<kNHistos;i++) {
90 if(fHv[i]) delete fHv[i];
94 if(fFunc) delete fFunc;
98 //---------------------------------------------------------------
99 void AliTPCDataDCS::Init()
101 // Init alias names and histos
103 TH1::AddDirectory(kFALSE);
107 for(int i=0;i<kNAliases;i++){
108 fAliasNames[i] = "TpcHvSect0";
110 fAliasNames[i] += ".FloatValue";
113 for(int i=0;i<kNHistos;i++){
114 fHv[i] = new TH1F(fAliasNames[i].Data(),fAliasNames[i].Data(), 20, kHvMin, kHvMax);
115 fHv[i]->GetXaxis()->SetTitle("Hv");
119 //---------------------------------------------------------------
120 void AliTPCDataDCS::ProcessData(TMap& aliasMap)
122 // process TMap of alias values retrieved from the DCS archive DB
129 for(int j=0; j<kNAliases; j++){
130 aliasArr = (TObjArray*) aliasMap.GetValue(fAliasNames[j].Data());
132 AliError(Form("Alias %s not found!", fAliasNames[j].Data()));
135 Introduce(j, aliasArr);
137 if(aliasArr->GetEntries()<2){
138 AliError(Form("Alias %s has just %d entries!",
139 fAliasNames[j].Data(),aliasArr->GetEntries()));
143 TIter iterarray(aliasArr);
145 Double_t *time = new Double_t[aliasArr->GetEntries()];
146 Double_t *val = new Double_t[aliasArr->GetEntries()];
149 while ((aValue = (AliDCSValue*) iterarray.Next())) {
150 val[ne] = aValue->GetFloat();
151 time[ne] = (Double_t) (aValue->GetTimeStamp());
152 // fill histos (alias 0-2)
153 if(j < 3) fHv[j]->Fill(val[ne]);
156 // fill graphs (alias 3-5)
157 if(j >= 3) CreateGraph(j, aliasArr->GetEntries(), time, val);
162 // calculate mean and rms of the first two histos
163 for(int i=0;i<kNHistos;i++){
164 fMean[i] = fHv[i]->GetMean();
165 fWidth[i] = fHv[i]->GetRMS();
168 // pol1 fit of the first graph
169 // if(fGraphs.GetEntries() > 0){
170 // ((TGraph*) fGraphs.UncheckedAt(0))->Fit("pol1");
171 // fFunc = ((TGraph*) fGraphs.UncheckedAt(0))->GetFunction("pol1");
179 //---------------------------------------------------------------
180 void AliTPCDataDCS::Introduce(UInt_t numAlias, const TObjArray* aliasArr)
182 // Say something about alias value array being processed
184 int entries=aliasArr->GetEntries();
185 AliInfo(Form("************ Alias: %s **********",fAliasNames[numAlias].Data()));
186 AliInfo(Form(" %d DP values collected",entries));
190 //---------------------------------------------------------------
191 void AliTPCDataDCS::CreateGraph(int i, int dim, const Double_t *x, const Double_t *y)
193 // create TGraph to be filled with DP values
195 TGraph *gr = new(fGraphs[fGraphs.GetEntriesFast()]) TGraph(dim, x, y);
197 gr->GetXaxis()->SetTimeDisplay(1);
198 gr->SetTitle(fAliasNames[i].Data());
200 AliInfo(Form("Array entries: %d",fGraphs.GetEntriesFast()));
205 //---------------------------------------------------------------
206 void AliTPCDataDCS::Draw(const Option_t* /*option*/)
208 // Draw all histos and graphs
210 if(!fIsProcessed) return;
213 TString canvasHistoName="Histos";
214 ch=new TCanvas(canvasHistoName,canvasHistoName,20,20,600,600);
224 if(fGraphs.GetEntries() == 0) return;
227 TString canvasGraphName="Graphs";
228 cg=new TCanvas(canvasGraphName,canvasGraphName,40,40,600,600);
231 ((TGraph*) fGraphs.UncheckedAt(0))->Draw("alp");
234 ((TGraph*) fGraphs.UncheckedAt(1))->Draw("alp");
236 ((TGraph*) fGraphs.UncheckedAt(2))->Draw("alp");