1. Re-organization of function calls in TestPreprocessor to make it more meaningful.
[u/mrichter/AliRoot.git] / SHUTTLE / test / AliTPCDataDCS.cxx
index 89d12d2..4c12bbf 100644 (file)
@@ -49,8 +49,8 @@ AliTPCDataDCS::AliTPCDataDCS():
 {
 // default constructor
 
-       for(int i=0;i<kNHistos;i++) fHv[i]=0x0;
-        fFunc = 0;
+       for(int i=0;i<kNHistos;i++) fHv[i]=0;
+       fFunc=0;
 }
 
 //---------------------------------------------------------------
@@ -68,8 +68,8 @@ AliTPCDataDCS::AliTPCDataDCS(Int_t nRun, UInt_t startTime, UInt_t endTime):
        TTimeStamp(startTime).AsString(),
        TTimeStamp(endTime).AsString()));
 
-        fFunc = 0;
-       Init();
+       for(int i=0;i<kNHistos;i++) fHv[i]=0;
+       fFunc=0;
 
 }
 
@@ -78,17 +78,51 @@ AliTPCDataDCS::~AliTPCDataDCS()
 {
 // destructor
 
-       for(int i=0;i<kNHistos;i++) {delete fHv[i]; fHv[i]=0;}
+       Clean();
+}
+
+//---------------------------------------------------------------
+void AliTPCDataDCS::Clean()
+{
+// destructor
+
+       for(int i=0;i<kNHistos;i++) {
+               if(fHv[i]) delete fHv[i];
+               fHv[i]=0;
+       }
        fGraphs.Clear("C");
+       if(fFunc) delete fFunc;
        fFunc=0;
 }
 
+//---------------------------------------------------------------
+void AliTPCDataDCS::Init()
+{
+// Init alias names and histos
+
+       TH1::AddDirectory(kFALSE);
+
+       fGraphs.SetOwner(1);
+
+       for(int i=0;i<kNAliases;i++){
+               fAliasNames[i] = "TpcHvSect0";
+               fAliasNames[i] += i;
+               fAliasNames[i] += ".FloatValue";
+       }
+
+       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");
+       }
+}
+
 //---------------------------------------------------------------
 void AliTPCDataDCS::ProcessData(TMap& aliasMap)
 {
 // process TMap of alias values retrieved from the DCS archive DB
 
-       if(!(fHv[0])) Init();
+       Clean();
+       Init();
 
        TObjArray *aliasArr;
        AliDCSValue* aValue;
@@ -113,7 +147,7 @@ void AliTPCDataDCS::ProcessData(TMap& aliasMap)
 
                UInt_t ne=0;
                while ((aValue = (AliDCSValue*) iterarray.Next())) {
-               val[ne] = aValue->GetSimpleValue().GetFloat();
+               val[ne] = aValue->GetFloat();
                time[ne] = (Double_t) (aValue->GetTimeStamp());
                // fill histos (alias 0-2)
                if(j < 3) fHv[j]->Fill(val[ne]);
@@ -132,37 +166,16 @@ void AliTPCDataDCS::ProcessData(TMap& aliasMap)
        }
 
        // pol1 fit of the first graph
-       if(fGraphs.GetEntries() > 0){
-               ((TGraph*) fGraphs.UncheckedAt(0))->Fit("pol1");
-               fFunc = ((TGraph*) fGraphs.UncheckedAt(0))->GetFunction("pol1");
-       }
+//     if(fGraphs.GetEntries() > 0){
+//             ((TGraph*) fGraphs.UncheckedAt(0))->Fit("pol1");
+//             fFunc = ((TGraph*) fGraphs.UncheckedAt(0))->GetFunction("pol1");
+//     }
 
        fIsProcessed=kTRUE;
 
 
 }
 
-//---------------------------------------------------------------
-void AliTPCDataDCS::Init()
-{
-// Init alias names and histos
-
-       TH1::AddDirectory(kFALSE);
-
-       fGraphs.SetOwner(1);
-
-       for(int i=0;i<kNAliases;i++){
-               fAliasNames[i] = "TpcHvSect0";
-               fAliasNames[i] += i;
-               fAliasNames[i] += ".FloatValue";
-       }
-
-       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");
-       }
-}
-
 //---------------------------------------------------------------
 void AliTPCDataDCS::Introduce(UInt_t numAlias, const TObjArray* aliasArr)
 {