]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/AliTOFPreprocessor.cxx
Status flag implemented as UChar_t
[u/mrichter/AliRoot.git] / TOF / AliTOFPreprocessor.cxx
index 11a9929695c765b780dba1fb694e82424287bdc7..bc3b44746b44bd86c3018f3e194019641c633350 100644 (file)
 
 #include "AliCDBMetaData.h"
 #include "AliLog.h"
-#include "AliTOFCalOnline.h"
 #include "AliTOFChannelOnline.h"
 #include "AliTOFDataDCS.h"
-#include "AliTOFGeometryV5.h"
+#include "AliTOFGeometry.h"
 #include "AliTOFPreprocessor.h"
 
 class TF1;
@@ -61,10 +60,11 @@ AliTOFPreprocessor::AliTOFPreprocessor(AliShuttleInterface* shuttle) :
   fData(0),
   fh2(0),
   fCal(0),
-  fTOFGeometry(0),
+  fNChannels(0),
   fStoreRefData(kTRUE)
 {
   // constructor
+
 }
 
 //_____________________________________________________________________________
@@ -72,14 +72,19 @@ AliTOFPreprocessor::AliTOFPreprocessor(AliShuttleInterface* shuttle) :
 AliTOFPreprocessor::~AliTOFPreprocessor()
 {
   // destructor
-  delete fData;
-  fData = 0;
-  delete fh2;
-  fh2 = 0;
-  delete fCal;
-  fCal = 0;
-  delete fTOFGeometry;
-  fTOFGeometry = 0;
+  if (fData){
+    delete fData;
+    fData = 0;
+  }
+  if (fh2){
+    delete fh2;
+    fh2 = 0;
+  }
+  if (fCal){
+    //    fCal->Clear();
+    delete fCal;
+    fCal = 0;
+  }
 }
 
 //______________________________________________________________________________
@@ -96,9 +101,13 @@ void AliTOFPreprocessor::Initialize(Int_t run, UInt_t startTime,
 
        fData = new AliTOFDataDCS(fRun, fStartTime, fEndTime);
        fh2 = 0x0;
-       fTOFGeometry = new AliTOFGeometryV5();
-       fCal = new AliTOFCalOnline(fTOFGeometry);
-       fCal->CreateArray();
+       fNChannels = AliTOFGeometry::NSectors()*(2*(AliTOFGeometry::NStripC()+AliTOFGeometry::NStripB())+AliTOFGeometry::NStripA())*AliTOFGeometry::NpadZ()*AliTOFGeometry::NpadX();
+       fCal = new TObjArray(fNChannels);
+       fCal->SetOwner();
+       for (Int_t ich = 0; ich<fNChannels; ich ++){
+         AliTOFChannelOnline * calChOnline = new AliTOFChannelOnline();
+         fCal->AddAt(calChOnline,ich);
+       }
 }
 
 //_____________________________________________________________________________
@@ -108,19 +117,21 @@ UInt_t AliTOFPreprocessor::Process(TMap* dcsAliasMap)
   // Fills data into a AliTOFDataDCS object
   // return codes:
   // return=0 : all ok
-  // return=1 : no DCS input data
-  // return=2 : no DCS processed data was stored
-  // return=3 : no DAQ input for Ref Data
-  // return=4 : failed to store Ref data
-  // return=5 : failed to retrieve DAQ data for calibration 
-  // return=6 : problems in histos in the input DAQ file 
-  // return=7 : failed to store Online Delays
+  // return=1 : no DCS input data Map
+  // return=2 : no DCS input data processing
+  // return=3 : no DCS processed data was stored in Ref Data
+  // return=4 : no DAQ input for Ref Data
+  // return=5 : failed to store Ref Data
+  // return=6 : failed to retrieve DAQ data for calibration 
+  // return=7 : problems in histos in the input DAQ file 
+  // return=8 : failed to store Online Delays
 
   TH1::AddDirectory(0);
 
-  Bool_t resultDCS=kTRUE;
-  Bool_t resultDAQ=kTRUE;
-  Bool_t resultDAQRef=kTRUE;
+  Bool_t resultDCSMap=kFALSE;
+  Bool_t resultDCSStore=kFALSE;
+  Bool_t resultDAQ=kFALSE;
+  Bool_t resultDAQRef=kFALSE;
 
   // processing DCS
 
@@ -130,24 +141,31 @@ UInt_t AliTOFPreprocessor::Process(TMap* dcsAliasMap)
   }
   else {
   // The processing of the DCS input data is forwarded to AliTOFDataDCS
-    fData->ProcessData(*dcsAliasMap);
-    AliCDBMetaData metaDataDCS;
-    metaDataDCS.SetBeamPeriod(0);
-    metaDataDCS.SetResponsible("Chiara Zampolli");
-    metaDataDCS.SetComment("This preprocessor fills an AliTOFDataDCS object.");
-    AliInfo("Storing DCS Data");
-    resultDCS = Store("Calib","DCSData",fData, &metaDataDCS);
-    if (!resultDCS){
-      Log("Some problems occurred while storing DCS data processing results, TOF exiting from Shuttle");
+    resultDCSMap=fData->ProcessData(*dcsAliasMap);
+    if(!resultDCSMap){
+      Log("Some problems occurred while processing DCS data, TOF exiting from Shuttle");
       return 2;// return error Code for processed DCS data not stored 
     }
+    else{
+      AliCDBMetaData metaDataDCS;
+      metaDataDCS.SetBeamPeriod(0);
+      metaDataDCS.SetResponsible("Chiara Zampolli");
+      metaDataDCS.SetComment("This preprocessor fills an AliTOFDataDCS object.");
+      AliInfo("Storing DCS Data");
+      resultDCSStore = StoreReferenceData("Calib","DCSData",fData, &metaDataDCS);
+      if (!resultDCSStore){
+       Log("Some problems occurred while storing DCS data results in Reference Data, TOF exiting from Shuttle");
+       return 3;// return error Code for processed DCS data not stored 
+                // in reference data
+       
+      }
+    }
   }
-
-  AliInfo("Surviving");
+  
   // processing DAQ
-
+  
   TFile * daqFile=0x0;
-
+  
   if(fStoreRefData){
     //retrieving data at Run level
     TList* list = GetFileSources(kDAQ, "RUNLevel");
@@ -172,7 +190,7 @@ UInt_t AliTOFPreprocessor::Process(TMap* dcsAliasMap)
            resultDAQRef = StoreReferenceData("Calib","DAQData",fh2, &metaDataHisto);
            if (!resultDAQRef){
              Log("some problems occurred::No Reference Data stored, TOF exiting from Shuttle");
-             return 4;//return error code for failure in storing Ref Data 
+             return 5;//return error code for failure in storing Ref Data 
            }
            daqFile->Close();
            delete daqFile;
@@ -180,13 +198,13 @@ UInt_t AliTOFPreprocessor::Process(TMap* dcsAliasMap)
          
          else{
            Log("The input data file from DAQ (run-level) was not found, TOF exiting from Shuttle "); 
-           return 3;//return error code for failure in retrieving Ref Data 
+           return 4;//return error code for failure in retrieving Ref Data 
          }
        }
       }
     else{
       Log("The input data file list from DAQ (run-level) was not found, TOF exiting from Shuttle "); 
-      return 3;//return error code for failure in retrieving Ref Data 
+      return 4;//return error code for failure in retrieving Ref Data 
     }  
   }
 
@@ -208,21 +226,21 @@ UInt_t AliTOFPreprocessor::Process(TMap* dcsAliasMap)
          AliInfo(Form("Got the file %s, now we can extract some values.", fileName.Data()));
 
          daqFile = new TFile(fileName.Data(),"READ");
+         if (fh2) delete fh2;
          fh2 = (TH2S*) daqFile->Get("htoftot");
          if (!fh2){
            Log("some problems occurred:: No histo retrieved, TOF exiting from Shuttle");
            delete daqFile;
-           return 6; //return error code for histograms not existing/junky
+           return 7; //return error code for histograms not existing/junky
          }
          else {
            static const Int_t kSize=fh2->GetNbinsX();
            static const Int_t kNBins=fh2->GetNbinsY();
            static const Double_t kXBinmin=fh2->GetYaxis()->GetBinLowEdge(1);
-           Int_t npads = fCal->NPads();
-           if (kSize != npads){
+           if (kSize != fNChannels){
              Log(" number of bins along x different from number of pads, found only a subset of the histograms, TOF exiting from Shuttle");
              delete daqFile;
-              return 6; //return error code for histograms not existing/junky
+              return 7; //return error code for histograms not existing/junky
            }
            for (Int_t ich=0;ich<kSize;ich++){
              TH1S *h1 = new TH1S("h1","h1",kNBins,kXBinmin-0.5,kNBins*1.+kXBinmin-0.5);
@@ -258,9 +276,9 @@ UInt_t AliTOFPreprocessor::Process(TMap* dcsAliasMap)
              sumw2=sumw2/nent; //<x^2>
              Double_t rmsmean= 0;
              rmsmean = TMath::Sqrt((sumw2-mean*mean)/nent);
-             if (ich<npads) {
-               AliTOFChannelOnline * ch = fCal->GetChannel(ich);
-               ch->SetDelay(mean);
+             if (ich<fNChannels) {
+               AliTOFChannelOnline * ch = (AliTOFChannelOnline *)fCal->At(ich);
+               ch->SetDelay((Double_t)mean*AliTOFGeometry::TdcBinWidth()*1.E-3);  // delay in ns
              }
            delete h1;
            h1=0x0;
@@ -273,21 +291,21 @@ UInt_t AliTOFPreprocessor::Process(TMap* dcsAliasMap)
          metaData.SetResponsible("Chiara Zampolli");
          metaData.SetComment("This preprocessor fills an AliTOFCal object.");
          AliInfo("Storing Calibration Data");
-         resultDAQ = Store("Calib","OnlineDelay",fCal, &metaData);
+         resultDAQ = Store("Calib","ParOnline",fCal, &metaData);
           if(!resultDAQ){
            Log("Some problems occurred while storing DAQ data processing results");
-           return 7;//return error code for problems in storing DAQ data 
+           return 8;//return error code for problems in storing DAQ data 
          }
        }
        else{
          Log("The Cumulative data file from DAQ does not exist, TOF exiting from Shuttle"); 
-          return 5;//return error code for problems in retrieving DAQ data 
+          return 6;//return error code for problems in retrieving DAQ data 
        }
       }
     }
   else{
     Log("Problem: no list for Cumulative data file from DAQ was found, TOF exiting from Shuttle");
-    return 5; //return error code for problems in retrieving DAQ data 
+    return 6; //return error code for problems in retrieving DAQ data 
   }
 
   daqFile=0;