]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - T0/AliT0Preprocessor.cxx
AliTPCLaserTrack.cxx - max snp cut added
[u/mrichter/AliRoot.git] / T0 / AliT0Preprocessor.cxx
index d9158dcc8b8684a7e61db1388709e805bdedde67..637f32747f310f9c46d0ffbaae43154245bbaca4 100644 (file)
@@ -44,6 +44,7 @@ Preliminary test version (T.Malkiewicz)
 
 #include "AliCDBMetaData.h"
 #include "AliDCSValue.h"
+#include "AliCDBEntry.h"
 #include "AliLog.h"
 
 #include <TTimeStamp.h>
@@ -51,6 +52,7 @@ Preliminary test version (T.Malkiewicz)
 #include <TObjString.h>
 #include <TNamed.h>
 #include "AliT0Dqclass.h"
+#include "TClass.h"
 
 
 ClassImp(AliT0Preprocessor)
@@ -63,6 +65,7 @@ AliT0Preprocessor::AliT0Preprocessor(AliShuttleInterface* shuttle) :
   //constructor
   AddRunType("PHYSICS");
   AddRunType("STANDALONE");
+  //  AddRunType("LASER");
 }
 //____________________________________________________
 
@@ -79,7 +82,7 @@ void AliT0Preprocessor::Initialize(Int_t run, UInt_t startTime, UInt_t endTime)
   // Creates AliT0DataDCS object
   AliPreprocessor::Initialize(run, startTime, endTime);
   AliInfo(Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s", run, TTimeStamp(startTime).AsString(), TTimeStamp(endTime).AsString()));
-  fData = new AliT0DataDCS(fRun, fStartTime, fEndTime);
+  fData = new AliT0DataDCS(fRun, fStartTime, fEndTime, GetStartTimeDCSQuery(), GetEndTimeDCSQuery());
 }
 //____________________________________________________
 
@@ -88,9 +91,12 @@ Bool_t AliT0Preprocessor::ProcessDCS(){
        TString runType = GetRunType();
        Log(Form("ProcessDCS - RunType: %s",runType.Data()));
 
-       if((runType == "STANDALONE")||(runType == "PHYSICS")){
-         //            return kFALSE;
-               return kTRUE;
+       if((runType == "STANDALONE")||
+          (runType == "PHYSICS") ) {
+          //     || (runType == "LASER")){
+
+         //      return kFALSE;
+               return kTRUE;
        }else{
        return kFALSE;
        }
@@ -137,28 +143,90 @@ UInt_t AliT0Preprocessor::ProcessDCSDataPoints(TMap* dcsAliasMap){
 
 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)
-        {
-            TIter iter(list);
-            TObjString *source;
-            while ((source = dynamic_cast<TObjString *> (iter.Next())))
-            {
-              const char *laserFile = GetFile(kDAQ, "LASER", source->GetName());
-              if (laserFile)
+  Log("Processing Laser calibration - Walk Correction");
+  
+  //Retrieve the last T0 calibration object
+
+  Float_t parqtcold[24][2], parledold[24][2],parqtcnew[24][2], parlednew[24][2] , goodled[24][2], goodqtc[24][2];
+
+  //  std::cout<<"sizeof "<<sizeof(parqtcold)<<std::endl;
+  memset(parqtcold, 0, sizeof(parqtcold));
+  memset(parqtcnew, 0, sizeof(parqtcnew));
+  memset(parledold, 0, sizeof(parledold));
+  memset(parlednew, 0, sizeof(parlednew));
+  Int_t iStore=0;
+
+
+  AliT0CalibWalk* clb=0;
+  AliCDBEntry* entryCalib = GetFromOCDB("Calib", "Slewing_Walk");
+  if(!entryCalib)
+    Log(Form("Cannot find any AliCDBEntry for [Calib, SlewingWalk]!"));
+  else {
+    clb =dynamic_cast<AliT0CalibWalk*>(entryCalib->GetObject());
+    for(Int_t i=0; i<24; i++)
+      {
+       for(Int_t ipar=0; ipar<2; ipar++)
+         {
+           //    std::cout<<"parqtcold "<<parqtcold[i][ipar]<<std::endl;
+           parqtcold[i][ipar] = clb->GetQTCpar(i,ipar);
+           parledold[i][ipar] = clb->GetLEDpar(i, ipar);
+           goodqtc[i][ipar] = 999;
+           goodled[i][ipar] = 999;
+           //    std:: cout<<" old "<<i<<" "<<ipar<<" qtc "<< parqtcold[i][ipar]<<" led "<<parledold[i][ipar]<< std::endl;
+         }
+      }
+  }
+
+
+    Bool_t resultLaser=kFALSE;
+    //processing DAQ
+    TList* list = GetFileSources(kDAQ, "LASER");
+    if (list)
+      {
+       TIter iter(list);
+       TObjString *source;
+       while ((source = dynamic_cast<TObjString *> (iter.Next())))
+         {
+           const char *laserFile = GetFile(kDAQ, "LASER", source->GetName());
+           if (laserFile)
               {
                 Log(Form("File with Id LASER found in source %s!", source->GetName()));
                 AliT0CalibWalk *laser = new AliT0CalibWalk();
                 laser->MakeWalkCorrGraph(laserFile);
-                AliCDBMetaData metaData;
-                metaData.SetBeamPeriod(0);
+               //check difference with what was before
+               if(laser && clb ){
+                 iStore = 1;                           
+                 for(Int_t i=0; i<24; i++)
+                   {
+                     for(Int_t ifit=0; ifit<2; ifit++)
+                       {
+                         parqtcnew[i][ifit] = laser->GetQTCpar(i,ifit);
+                         if( parqtcold[i][ifit] != 0 && parqtcnew[i][ifit] !=0) 
+                           {
+                             goodqtc[i][ifit] = 
+                               (parqtcnew[i][ifit] - parqtcold[i][ifit])/parqtcold[i][ifit];
+                             //                               std::cout<<"qtc "<<i<<" "<<ifit<<" "<< goodqtc[i][ifit]<< std::endl;
+                           }
+                         parlednew[i][ifit] = laser->GetLEDpar(i,ifit);
+                         if(parledold[i][ifit] != 0 && parlednew[i][ifit]!= 0 ) 
+                           {
+                             goodled[i][ifit]= 
+                               (parlednew[i][ifit] - parledold[i][ifit])/parledold[i][ifit];   
+                             //                               std::cout<<"led "<<i<<" "<<ifit<<" "<< goodled[i][ifit]<< std::endl;
+                           }                   
+                         //      if(TMath::Abs(goodqtc[i][ifit])>0.1 || 
+                         //         TMath::Abs(goodled[i][ifit])>0.1) 
+                         //        iStore = 0;
+                       }
+                   }
+               }
+
+               AliCDBMetaData metaData;
+               metaData.SetBeamPeriod(0);
                 metaData.SetResponsible("Tomek&Michal");
                 metaData.SetComment("Walk correction from laser runs.");
-               resultLaser=Store("Calib","Slewing_Walk", laser, &metaData, 0, 1);
+               if( iStore>0)
+                 resultLaser=Store("Calib","Slewing_Walk", laser, &metaData, 0, 1);
                 delete laser;
                Log(Form("resultLaser = %d",resultLaser));
               }
@@ -179,12 +247,13 @@ UInt_t AliT0Preprocessor::ProcessLaser(){
          }
        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");
@@ -199,12 +268,18 @@ UInt_t AliT0Preprocessor::ProcessPhysics(){
               {
                 AliT0CalibTimeEq *online = new AliT0CalibTimeEq();
                 online->Reset();
-                online->ComputeOnlineParams(filePhys);
+                Bool_t writeok = online->ComputeOnlineParams(filePhys);
                 AliCDBMetaData metaData;
                 metaData.SetBeamPeriod(0);
-                metaData.SetResponsible("Tomek&Michal");
+                metaData.SetResponsible("Alla Maevskaya");
                 metaData.SetComment("Time equalizing result.");
-                resultOnline = Store("Calib","TimeDelay", online, &metaData, 0, 1);
+
+                if (writeok) resultOnline = Store("Calib","TimeDelay", online, &metaData, 0, 1);
+               else {
+                 
+                 Log(Form("writeok = %d not enough data for equalizing",resultOnline));
+                 return 0;
+               }                 
                Log(Form("resultOnline = %d",resultOnline));
                 delete online;
               }
@@ -228,53 +303,6 @@ UInt_t AliT0Preprocessor::ProcessPhysics(){
 }
 //____________________________________________________
 
-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:
@@ -286,32 +314,41 @@ UInt_t AliT0Preprocessor::Process(TMap* dcsAliasMap )
   // 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;
+  // return=8 : not enough data for equalizing
+  Bool_t dcsDP = ProcessDCS();
+  Log(Form("dcsDP = %d",dcsDP));       
+  TString runType = GetRunType();
+  Log(Form("RunType: %s",runType.Data()));
+  //processing
+  if(runType == "STANDALONE"){
+    if(dcsDP==1){
+      Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
+      return iresultDCS;
+    }
+  }
+  /*
+  if(runType == "LASER"){
+    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();
+    if(dcsDP==1){
+      Int_t iresultDCS = ProcessDCSDataPoints(dcsAliasMap);
+      return iresultDCS;
+    }
+    Log(Form("iresultPhysics = %d",iresultPhysics));
+         return iresultPhysics; 
+      }
+  
+       
+       
+       return 0;
 }