1 #include "AliTestDataDCS.h"
3 #include "AliCDBMetaData.h"
4 #include "AliDCSValue.h"
7 #include <TTimeStamp.h>
8 #include <TObjString.h>
16 ClassImp(AliTestDataDCS)
18 //---------------------------------------------------------------
19 AliTestDataDCS::AliTestDataDCS():
24 fGraphs("TGraph",kNGraphs),
27 for(int i=0;i<kNHistos;i++) fHv[i]=0x0;
31 //---------------------------------------------------------------
32 AliTestDataDCS::AliTestDataDCS(Int_t nRun, UInt_t startTime, UInt_t endTime):
35 fStartTime(startTime),
37 fGraphs("TGraph",kNGraphs),
40 AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", nRun,
41 TTimeStamp(startTime).AsString(),
42 TTimeStamp(endTime).AsString()));
49 //---------------------------------------------------------------
50 AliTestDataDCS::~AliTestDataDCS() {
52 for(int i=0;i<kNHistos;i++) {delete fHv[i]; fHv[i]=0;}
57 //---------------------------------------------------------------
58 void AliTestDataDCS::ProcessData(TMap& aliasMap){
64 for(int j=0; j<kNAliases; j++){
65 aliasArr = (TObjArray*) aliasMap.GetValue(fAliasNames[j].Data());
67 AliError(Form("Alias %s not found!", fAliasNames[j].Data()));
70 Introduce(j, aliasArr);
72 if(aliasArr->GetEntries()<2){
73 AliError(Form("Alias %s has just %d entries!",
74 fAliasNames[j].Data(),aliasArr->GetEntries()));
78 TIter iterarray(aliasArr);
80 Double_t *time = new Double_t[aliasArr->GetEntries()];
81 Double_t *val = new Double_t[aliasArr->GetEntries()];
84 while ((aValue = (AliDCSValue*) iterarray.Next())) {
86 val[ne] = aValue->GetFloat();
87 time[ne] = (Double_t) (aValue->GetTimeStamp());
88 // fill histos (alias 0-2)
89 if(j < 3) fHv[j]->Fill(val[ne]);
92 // fill graphs (alias 3-5)
93 if(j >= 3) CreateGraph(j, aliasArr->GetEntries(), time, val);
98 // calculate mean and rms of the first two histos
99 for(int i=0;i<kNHistos;i++){
100 fMean[i] = fHv[i]->GetMean();
101 fWidth[i] = fHv[i]->GetRMS();
104 // pol1 fit of the first graph
105 if(fGraphs.GetEntries() > 0){
106 ((TGraph*) fGraphs.UncheckedAt(0))->Fit("pol1");
107 fFunc = ((TGraph*) fGraphs.UncheckedAt(0))->GetFunction("pol1");
115 //---------------------------------------------------------------
116 void AliTestDataDCS::Init(){
118 TH1::AddDirectory(kFALSE);
122 for(int i=0;i<kNAliases;i++){
123 fAliasNames[i] = "DCSAlias";
127 for(int i=0;i<kNHistos;i++){
128 fHv[i] = new TH1F(fAliasNames[i].Data(),fAliasNames[i].Data(), 20, kHvMin, kHvMax);
129 fHv[i]->GetXaxis()->SetTitle("Hv");
133 //---------------------------------------------------------------
134 void AliTestDataDCS::Introduce(UInt_t numAlias, const TObjArray* aliasArr){
136 int entries=aliasArr->GetEntries();
137 AliInfo(Form("************ Alias: %s **********",fAliasNames[numAlias].Data()));
138 AliInfo(Form(" %d DP values collected",entries));
142 //---------------------------------------------------------------
143 void AliTestDataDCS::CreateGraph(int i, int dim, const Double_t *x, const Double_t *y)
146 TGraph *gr = new(fGraphs[fGraphs.GetEntriesFast()]) TGraph(dim, x, y);
148 gr->GetXaxis()->SetTimeDisplay(1);
149 gr->SetTitle(fAliasNames[i].Data());
151 AliInfo(Form("Array entries: %d",fGraphs.GetEntriesFast()));
156 //---------------------------------------------------------------
157 void AliTestDataDCS::Draw(const Option_t* /*option*/)
159 // Draw all histos and graphs
161 if(!fIsProcessed) return;
164 TString canvasHistoName="Histos";
165 ch=new TCanvas(canvasHistoName,canvasHistoName,20,20,600,600);
175 if(fGraphs.GetEntries() == 0) return;
178 TString canvasGraphName="Graphs";
179 cg=new TCanvas(canvasGraphName,canvasGraphName,40,40,600,600);
182 ((TGraph*) fGraphs.UncheckedAt(0))->Draw("alp");
185 ((TGraph*) fGraphs.UncheckedAt(1))->Draw("alp");
187 ((TGraph*) fGraphs.UncheckedAt(2))->Draw("alp");