+/**************************************************************************
+ * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
+ * *
+ * Author: The ALICE Off-line Project. *
+ * Contributors are mentioned in the code where appropriate. *
+ * *
+ * Permission to use, copy, modify and distribute this software and its *
+ * documentation strictly for non-commercial purposes is hereby granted *
+ * without fee, provided that the above copyright notice appears in all *
+ * copies and that both the copyright notice and this permission notice * * appear in the supporting documentation. The authors make no claims *
+ * about the suitability of this software for any purpose. It is *
+ * provided "as is" without express or implied warranty. *
+ **************************************************************************/
+
+/*
+$Log: AliT0DataDCS.cxx,v $
+ Revision 2008/01/30
+Fetching data points from DCS, calculating mean and storing data to Reference DB
+
+ Version 1.1 2006/10
+Preliminary test version (T.Malkiewicz)
+*/
+
#include "AliT0DataDCS.h"
#include "AliCDBMetaData.h"
#include <TStyle.h>
#include <TCanvas.h>
+// AliT0DataDCS class
+// declaring DCS aliases for T0
+// fetching T0 data points from DCS,
+// calculating mean values for the entire run
+// and storing the result to Reference DB
+
ClassImp(AliT0DataDCS)
//---------------------------------------------------------------
AliT0DataDCS::AliT0DataDCS():
TObject(),
- fRun(0),
+ fRun(0),
fStartTime(0),
fEndTime(0),
- fGraphs("TGraph",kNGraphs),
fIsProcessed(kFALSE)
{
- for(int i=0;i<kNHistos;i++) fHv[i]=0x0;
- fFunc = 0;
}
//---------------------------------------------------------------
fRun(nRun),
fStartTime(startTime),
fEndTime(endTime),
- fGraphs("TGraph",kNGraphs),
fIsProcessed(kFALSE)
{
AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", nRun,
TTimeStamp(startTime).AsString(),
TTimeStamp(endTime).AsString()));
- fFunc = 0;
Init();
}
//---------------------------------------------------------------
AliT0DataDCS::~AliT0DataDCS() {
- for(int i=0;i<kNHistos;i++) {delete fHv[i]; fHv[i]=0;}
- fGraphs.Clear("C");
- fFunc=0;
}
//---------------------------------------------------------------
Bool_t AliT0DataDCS::ProcessData(TMap& aliasMap)
{
-/* ** TM 23.11.2007 for testing preprocessor **
- if(!(fHv[0])) Init();
-
- TObjArray *aliasArr;
- AliDCSValue* aValue;
- for(int j=0; j<kNAliases; j++)
- {
- aliasArr = (TObjArray*) aliasMap.GetValue(fAliasNames[j].Data());
- if(!aliasArr)
- {
- AliError(Form("Alias %s not found!", fAliasNames[j].Data()));
- continue;
- }
- Introduce(j, aliasArr);
-
- if(aliasArr->GetEntries()<2)
- {
- AliError(Form("Alias %s has just %d entries!",
- fAliasNames[j].Data(),aliasArr->GetEntries()));
- continue;
- }
-
-// TM, 6.10.2007
- TIter iterarray(aliasArr);
-
- Double_t *time = new Double_t[aliasArr->GetEntries()];
- Double_t *val = new Double_t[aliasArr->GetEntries()];
-
- UInt_t ne=0;
- while ((aValue = (AliDCSValue*) iterarray.Next()))
- {
- val[ne] = aValue->GetFloat();
- time[ne] = (Double_t) (aValue->GetTimeStamp());
- // fill histos (alias 0-2)
- if(j < 3) fHv[j]->Fill(val[ne]);
- ne++;
- }
- // fill graphs (alias 3-5)
- if(j >= 3) CreateGraph(j, aliasArr->GetEntries(), time, val);
- delete[] val;
- delete[] time;
-
-// TM, 21.11.2007
- TObjArray *aliasArr;
- // AliDCSValue *aValue;
-//TM, 19.11.2007 Float_t t00_a_hv_imon[12]={0,0,0,0,0,0,0,0,0,0,0,0};
-//TM, 19.11.2007 Float_t t00_a_hv_vmon[12]={0,0,0,0,0,0,0,0,0,0,0,0};
-//TM, 19.11.2007 Float_t t00_a_lv_imon[2]={0,0};
-//TM, 19.11.2007 Float_t t00_a_lv_vmon[2]={0,0};
-//TM, 19.11.2007 Float_t t00_c_hv_imon[12]={0,0,0,0,0,0,0,0,0,0,0,0};
-//TM, 19.11.2007 Float_t t00_c_hv_vmon[12]={0,0,0,0,0,0,0,0,0,0,0,0};
-//TM, 19.11.2007 Float_t t00_c_lv_imon[2]={0,0};
-//TM, 19.11.2007 Float_t t00_c_lv_vmon[2]={0,0};
-//TM, 19.11.2007 Float_t t00_a_cfd_thre[12]={0,0,0,0,0,0,0,0,0,0,0,0};
-//TM, 19.11.2007 Float_t t00_a_cfd_walk[12]={0,0,0,0,0,0,0,0,0,0,0,0};
-//TM, 19.11.2007 Float_t t00_c_cfd_thre[12]={0,0,0,0,0,0,0,0,0,0,0,0};
-//TM, 19.11.2007 Float_t t00_c_cfd_walk[12]={0,0,0,0,0,0,0,0,0,0,0,0};
- Float_t t00_ac_scaler[32]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
-//TM, 19.11.2007 Float_t t00_ac_trm[20]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
-//TM, 19.11.2007 Float_t t00_ac_drm= 0;
-
- for(int j=0; j<32; j++)
- {
- TString aliasName =Form("t00_ac_scaler_%d",j);
-//TM, 19.11.2007 TString aliasName =Form("t00_a_hv_imon_%d",j);
-//TM, 19.11.2007 TString aliasName1 =Form("t00_a_hv_vmon_%d",j);
-//TM, 19.11.2007 TString aliasName2 =Form("t00_c_hv_imon_%d",j);
-//TM, 19.11.2007 TString aliasName3 =Form("t00_c_hv_vmon_%d",j);
-//TM, 19.11.2007 TString aliasName4 =Form("t00_a_cfd_thre_%d",j);
-//TM, 19.11.2007 TString aliasName5 =Form("t00_a_cfd_walk_%d",j);
-//TM, 19.11.2007 TString aliasName6 =Form("t00_c_cfd_thre_%d",j);
-//TM, 19.11.2007 TString aliasName7 =Form("t00_c_cfd_walk_%d",j);
-
- printf("aliasname: %s\n",aliasName.Data());
- aliasArr = dynamic_cast<TObjArray*> (dcsAliasMap->GetValue(aliasName.Data()));
- if(!aliasArr){
- AliError(Form("Alias %s not found!", aliasName.Data()));
+ Float_t t0_scaler[32];
+ Int_t aliasEntr[32];
+ TObjArray *aliasArr;
+ for(int j=0; j<kNAliases; j++)
+ {
+ for (Int_t k=0;k<32;k++)
+ {
+ t0_scaler[k]=0;
+ aliasEntr[k]=0;
+ }
+ aliasArr = (TObjArray*) aliasMap.GetValue(fAliasNames[j].Data());
+ if(!aliasArr)
+ {
+ AliError(Form("Alias %s not found!", fAliasNames[j].Data()));
continue;
- }
- AliDCSValue *aValue=dynamic_cast<AliDCSValue*> (aliasArr->At(0));
- // printf("I'm here! %f %x\n", aValue->GetFloat(), aValue->GetTimeStamp());
- // TM, 6.10.2007 hv[j]= aValue->GetFloat()*100;
- //Float_t timestamp= (Float_t) (aValue->GetTimeStamp());
- // printf("hello! hv = %f timestamp = %f\n" ,hv[j], timestamp);
-
-
- }
-
-** ** */
-
-/* TM, 6.10.2007
-
- // calculate mean and rms of the first two histos
- for(int i=0;i<kNHistos;i++)
- {
- fMean[i] = fHv[i]->GetMean();
- fWidth[i] = fHv[i]->GetRMS();
- }
-
- // pol1 fit of the first graph
- if(fGraphs.GetEntries() > 0)
- {
- ((TGraph*) fGraphs.UncheckedAt(0))->Fit("pol1");
- fFunc = ((TGraph*) fGraphs.UncheckedAt(0))->GetFunction("pol1");
- }
-*/
-
+ }
+ if(aliasArr->GetEntries()<2)
+ {
+ AliError(Form("Alias %s has just %d entries!",
+ fAliasNames[j].Data(),aliasArr->GetEntries()));
+ continue;
+ }
+ aliasEntr[j] = aliasArr->GetEntries();
+ for(int l=0; l<aliasEntr[j]; l++)
+ {
+ AliDCSValue *aValue=dynamic_cast<AliDCSValue*> (aliasArr->At(l));
+ t0_scaler[j]+= aValue->GetFloat();
+ }
+ fScalerMean[j] = t0_scaler[j] / aliasEntr[j] ;
+ }
fIsProcessed=kTRUE;
return kTRUE;
}
//---------------------------------------------------------------
void AliT0DataDCS::Init()
{
-
- TH1::AddDirectory(kFALSE);
-
- fGraphs.SetOwner(1);
-
+ TString sindex;
for(int i=0;i<kNAliases;i++)
{
- fAliasNames[i] = "DCSAlias";
- fAliasNames[i] += i;
+ fAliasNames[i] = "t00_ac_scaler_";
+ sindex.Form("%02d",i);
+ fAliasNames[i] += sindex;
}
-/* TM, 6.10.2007
- for(int i=0;i<kNHistos;i++)
- {
- fHv[i] = new TH1F(fAliasNames[i].Data(),fAliasNames[i].Data(), 20, kHvMin, kHvMax);
- fHv[i]->GetXaxis()->SetTitle("Hv");
- }
-*/
}
//---------------------------------------------------------------
}
-//---------------------------------------------------------------
-/* TM, 6.10.2007
-void AliT0DataDCS::CreateGraph(int i, int dim, const Double_t *x, const Double_t *y)
-{
-
- TGraph *gr = new(fGraphs[fGraphs.GetEntriesFast()]) TGraph(dim, x, y);
-
- gr->GetXaxis()->SetTimeDisplay(1);
- gr->SetTitle(fAliasNames[i].Data());
-
- AliInfo(Form("Array entries: %d",fGraphs.GetEntriesFast()));
-
-
-}
-
-*/
-
-//---------------------------------------------------------------
-/* TM, 6.10.2007
-
- void AliT0DataDCS::Draw(const Option_t* )
- {
- // Draw all histos and graphs
-
- if(!fIsProcessed) return;
- TCanvas *ch;
- TString canvasHistoName="Histos";
- ch=new TCanvas(canvasHistoName,canvasHistoName,20,20,600,600);
- ch->Divide(2,2);
- ch->cd(1);
- fHv[0]->Draw();
- ch->cd(2);
- fHv[1]->Draw();
- ch->cd(3);
- fHv[2]->Draw();
- if(fGraphs.GetEntries() == 0) return;
-
- TCanvas *cg;
- TString canvasGraphName="Graphs";
- cg=new TCanvas(canvasGraphName,canvasGraphName,40,40,600,600);
- cg->Divide(2,2);
- cg->cd(1);
- ((TGraph*) fGraphs.UncheckedAt(0))->Draw("alp");
-
- cg->cd(2);
- ((TGraph*) fGraphs.UncheckedAt(1))->Draw("alp");
- cg->cd(3);
- ((TGraph*) fGraphs.UncheckedAt(2))->Draw("alp");
-
- if(fFunc)
- {
- cg->cd(4);
- fFunc->Draw("l");
- }
- }
-*/