]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - T0/AliT0Preprocessor.cxx
fixes for crashing SHUTLLE
[u/mrichter/AliRoot.git] / T0 / AliT0Preprocessor.cxx
index f55572d6c996055e4cad788bd8a5ca2a7dc8bd7a..d9158dcc8b8684a7e61db1388709e805bdedde67 100644 (file)
@@ -17,7 +17,7 @@
 $Log: AliT0Preprocessor.cxx,v $
 Revision 1.8  2007/12/07 15:22:51  alla
 bug fixed by Alberto
-
 Revision 1.7  2007/12/06 16:35:24  alla
 new bugs fixed by Tomek
 
@@ -30,6 +30,12 @@ Preprocessor storing data to OCDB (T.Malkiewicz)
 Version 1.1  2006/10   
 Preliminary test version (T.Malkiewicz)
 */   
+// T0 preprocessor:
+// 1) takes data from DCS and passes it to the class AliTOFDataDCS 
+// for processing and writes the result to the Reference DB.
+// 2) takes data form DAQ (both from Laser Calibration and Physics runs), 
+// processes it, and stores either to OCDB or to Reference DB.
+
 
 #include "AliT0Preprocessor.h"
 #include "AliT0DataDCS.h"
@@ -46,19 +52,17 @@ Preliminary test version (T.Malkiewicz)
 #include <TNamed.h>
 #include "AliT0Dqclass.h"
 
-// T0 preprocessor:
-// 1) takes data from DCS and passes it to the class AliTOFDataDCS 
-// for processing and writes the result to the Reference DB.
-// 2) takes data form DAQ (both from Laser Calibration and Physics runs), 
-// processes it, and stores either to OCDB or to Reference DB.
-
 
 ClassImp(AliT0Preprocessor)
 
 //____________________________________________________
-AliT0Preprocessor::AliT0Preprocessor(AliShuttleInterface* shuttle) : AliPreprocessor("T00", shuttle), fData(0)
+AliT0Preprocessor::AliT0Preprocessor(AliShuttleInterface* shuttle) : 
+  AliPreprocessor("T00", shuttle), 
+  fData(0)
 {
   //constructor
+  AddRunType("PHYSICS");
+  AddRunType("STANDALONE");
 }
 //____________________________________________________
 
@@ -79,23 +83,26 @@ void AliT0Preprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
 }
 //____________________________________________________
 
-UInt_t AliT0Preprocessor::Process(TMap* dcsAliasMap )
-{
-  // T0 preprocessor return codes:
-  // return=0 : all ok
-  // return=1 : no DCS input data 
-  // return=2 : failed to store DCS data
-  // return=3 : no Laser data (Walk correction)
-  // return=4 : failed to store OCDB time equalized data
-  // return=5 : no DAQ input for OCDB
-  // return=6 : failed to retrieve DAQ data from OCDB
-  // return=7 : failed to store T0 OCDB data
+Bool_t AliT0Preprocessor::ProcessDCS(){
+       // Check whether DCS should be processed or not...
+       TString runType = GetRunType();
+       Log(Form("ProcessDCS - RunType: %s",runType.Data()));
+
+       if((runType == "STANDALONE")||(runType == "PHYSICS")){
+         //            return kFALSE;
+               return kTRUE;
+       }else{
+       return kFALSE;
+       }
+}
+//____________________________________________________
 
+UInt_t AliT0Preprocessor::ProcessDCSDataPoints(TMap* dcsAliasMap){
+       // Fills data into AliT0DataDCS object
+       Log("Processing DCS DP");
        Bool_t resultDCSMap=kFALSE;
        Bool_t resultDCSStore=kFALSE;
-       Bool_t resultLaser=kFALSE;
-       Bool_t resultOnline=kFALSE;  
-     
+
         if(!dcsAliasMap)
         {
           Log("No DCS input data");
@@ -103,7 +110,6 @@ UInt_t AliT0Preprocessor::Process(TMap* dcsAliasMap )
         }
         else
         {
-         
           resultDCSMap=fData->ProcessData(*dcsAliasMap);
           if(!resultDCSMap)
           {
@@ -117,25 +123,27 @@ UInt_t AliT0Preprocessor::Process(TMap* dcsAliasMap )
             metaDataDCS.SetResponsible("Tomasz Malkiewicz");
             metaDataDCS.SetComment("This preprocessor fills an AliTODataDCS object.");
             AliInfo("Storing DCS Data");
-            resultDCSStore = StoreReferenceData("Calib","DCSData", fData, &metaDataDCS);
+            resultDCSStore = StoreReferenceData("Calib","DCSData",fData, &metaDataDCS);
             if (!resultDCSStore)
             {
               Log("Some problems occurred while storing DCS data results in ReferenceDB");
-              //return 2;// return error Code for processed DCS data not stored
+              return 2;// return error Code for processed DCS data not stored
             }
-
           }
         }
+       return 0;
+}
+//____________________________________________________
 
-        // processing DAQ
-
-        TString runType = GetRunType();
-
-        if(runType == "T0_STANDALONE_LASER")
+UInt_t AliT0Preprocessor::ProcessLaser(){
+       // Processing data from DAQ Standalone run
+       Log("Processing Laser calibration - Walk Correction");
+       
+       Bool_t resultLaser=kFALSE;
+       //processing DAQ
+        TList* list = GetFileSources(kDAQ, "LASER");
+        if (list)
         {
-          TList* list = GetFileSources(kDAQ, "LASER");
-          if (list)
-          {
             TIter iter(list);
             TObjString *source;
             while ((source = dynamic_cast<TObjString *> (iter.Next())))
@@ -150,9 +158,9 @@ UInt_t AliT0Preprocessor::Process(TMap* dcsAliasMap )
                 metaData.SetBeamPeriod(0);
                 metaData.SetResponsible("Tomek&Michal");
                 metaData.SetComment("Walk correction from laser runs.");
-               //TObjArray* arrLaser = laser->GetfWalk();
                resultLaser=Store("Calib","Slewing_Walk", laser, &metaData, 0, 1);
                 delete laser;
+               Log(Form("resultLaser = %d",resultLaser));
               }
               else
               {
@@ -169,11 +177,18 @@ UInt_t AliT0Preprocessor::Process(TMap* dcsAliasMap )
                Log("No sources found for id LASER!");
                return 1;
          }
-        }
-        else if(runType == "PHYSICS")
-        {
-          TList* listPhys = GetFileSources(kDAQ, "PHYSICS");
-          if (listPhys)
+       return 0;
+}
+//____________________________________________________
+
+UInt_t AliT0Preprocessor::ProcessPhysics(){
+       //Processing data from DAQ Physics run
+       Log("Processing Physics");
+
+       Bool_t resultOnline=kFALSE; 
+       //processing DAQ
+       TList* listPhys = GetFileSources(kDAQ, "PHYSICS");
+        if (listPhys)
           {
             TIter iter(listPhys);
             TObjString *sourcePhys;
@@ -184,30 +199,119 @@ UInt_t AliT0Preprocessor::Process(TMap* dcsAliasMap )
               {
                 AliT0CalibTimeEq *online = new AliT0CalibTimeEq();
                 online->Reset();
-                online->ComputeOnlineParams("CFD", 20, 4., filePhys);
+                online->ComputeOnlineParams(filePhys);
                 AliCDBMetaData metaData;
                 metaData.SetBeamPeriod(0);
                 metaData.SetResponsible("Tomek&Michal");
                 metaData.SetComment("Time equalizing result.");
                 resultOnline = Store("Calib","TimeDelay", online, &metaData, 0, 1);
+               Log(Form("resultOnline = %d",resultOnline));
                 delete online;
               }
-              else
+               else
               {
                 Log(Form("Could not find file with Id PHYSICS in source %s!", sourcePhys->GetName()));
                 return 1;
               }
+              
             }
             if (!resultOnline)
             {
-              Log("No Laser Data stored");
+              Log("No Data stored");
               return 4;//return error code for failure in storing OCDB Data
             }
           } else {
                Log("No sources found for id PHYSICS!");
                return 1;
          }
-        }
+       return 0;
+}
+//____________________________________________________
+
+UInt_t AliT0Preprocessor::ProcessCosmic(){
+       //Processing data from DAQ Physics run
+       Log("Processing Laser Physics");
+
+       Bool_t resultLaserOnline=kFALSE; 
+       //processing DAQ
+       TList* listLaser = GetFileSources(kDAQ, "COSMIC");
+        if (listLaser)
+          {
+            TIter iter(listLaser);
+            TObjString *sourceLaser;
+            while ((sourceLaser = dynamic_cast<TObjString *> (iter.Next())))
+            {
+              const char *fileLaser = GetFile(kDAQ, "COSMIC", sourceLaser->GetName());
+              if (fileLaser)
+              {
+                AliT0CalibTimeEq *onlineLaser = new AliT0CalibTimeEq();
+                onlineLaser->Reset();
+                onlineLaser->ComputeOnlineParams(fileLaser);
+                AliCDBMetaData metaData;
+                metaData.SetBeamPeriod(0);
+                metaData.SetResponsible("Tomek&Michal");
+                metaData.SetComment("Time equalizing result.");
+                resultLaserOnline = Store("Calib","LaserTimeDelay", onlineLaser, &metaData, 0, 1);
+               Log(Form("resultLaserOnline = %d",resultLaserOnline));
+                delete onlineLaser;
+              }
+               else
+              {
+                Log(Form("Could not find file with Id COSMIC in source %s!", sourceLaser->GetName()));
+                return 0;
+              }
+              
+            }
+            if (!resultLaserOnline)
+            {
+              Log("No Laser Data stored");
+              return 0;//return error code for failure in storing OCDB Data
+            }
+          } else {
+               Log("No sources found for id COSMIC!");
+               return 0;
+         }
+       return 0;
+}
+//____________________________________________________
+
+UInt_t AliT0Preprocessor::Process(TMap* dcsAliasMap )
+{
+  // T0 preprocessor return codes:
+  // return=0 : all ok
+  // return=1 : no DCS input data 
+  // return=2 : failed to store DCS data
+  // return=3 : no Laser data (Walk correction)
+  // return=4 : failed to store OCDB time equalized data
+  // return=5 : no DAQ input for OCDB
+  // return=6 : failed to retrieve DAQ data from OCDB
+  // return=7 : failed to store T0 OCDB data
+       Bool_t dcsDP = ProcessDCS();
+       Log(Form("dcsDP = %d",dcsDP));  
+        TString runType = GetRunType();
+       Log(Form("RunType: %s",runType.Data()));
+       //processing
+       if(runType == "STANDALONE"){
+               Int_t iresultLaser = ProcessLaser();
+                       if(dcsDP==1){
+                       Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
+                       return iresultDCS;
+               }
+               Log(Form("iresultLaser = %d",iresultLaser));
+               return iresultLaser;
+       }
+       else if(runType == "PHYSICS"){
+        Int_t iresultPhysics = ProcessPhysics();
+        //      Int_t iresultCosmic = ProcessCosmic();
+               if(dcsDP==1){
+                       Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
+                       return iresultDCS;
+               }
+               Log(Form("iresultPhysics = %d",iresultPhysics));
+               return iresultPhysics; 
+               //              Log(Form("iresultPhysics =iresultCosmic %d",iresultCosmic));
+               //      return iresultCosmic; 
+      }        
 
   return 0;
 }