sorry fixed now
authoralla <alla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 20 Mar 2011 22:10:01 +0000 (22:10 +0000)
committeralla <alla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Sun, 20 Mar 2011 22:10:01 +0000 (22:10 +0000)
T0/AliT0PreprocessorOffline.cxx

index 0a0e40b..3502903 100644 (file)
 
 
 #include "AliT0PreprocessorOffline.h"
+#include "AliT0RecoParam.h"
 #include "AliT0CalibTimeEq.h"
 #include "AliCDBStorage.h"
 #include "AliCDBMetaData.h"
 #include "AliCDBManager.h"
+#include "AliT0CalibSeasonTimeShift.h"
 
 #include "AliCDBEntry.h"
 #include "AliLog.h"
@@ -41,7 +43,13 @@ ClassImp(AliT0PreprocessorOffline)
 
 //____________________________________________________
 AliT0PreprocessorOffline::AliT0PreprocessorOffline():
-TNamed("AliT0PreprocessorOffline","AliT0PreprocessorOffline")
+TNamed("AliT0PreprocessorOffline","AliT0PreprocessorOffline"),
+  startRun(0),                         // start Run - used to make fast selection in THnSparse
+  endRun(0),                           // end   Run - used to make fast selection in THnSparse
+  startTime(0),                        // startTime - used to make fast selection in THnSparse
+  endTime(0),                          // endTime   - used to make fast selection in THnSparse
+  ocdbStorage("")                  // path to the OCDB storage
+  
 {
   //constructor
 }
@@ -53,19 +61,49 @@ AliT0PreprocessorOffline::~AliT0PreprocessorOffline()
 
 }
 //____________________________________________________
+void AliT0PreprocessorOffline::Process(TString filePhysName, Int_t ustartRun, Int_t uendRun, TString pocdbStorage)
+{
+  CalibOffsetChannels(filePhysName, ustartRun, uendRun, pocdbStorage);
+  CalibT0sPosition(filePhysName, ustartRun, uendRun, pocdbStorage);
+}
 //____________________________________________________
 
-void AliT0PreprocessorOffline::CalibOffsetChannels(TString filePhysName, Int_t ustartRun, Int_t uendRun, TString ocdbStorage)
+void AliT0PreprocessorOffline::CalibOffsetChannels(TString filePhysName, Int_t ustartRun, Int_t uendRun, TString pocdbStorage)
 {
 
-
+  Float_t *timecdb = 0;
+  Int_t badpmt=0;
   //Processing data from DAQ Physics run
   AliInfo("Processing Time Offset between channels");
+
   if (filePhysName)
     {
+   if (pocdbStorage.Length()>0) ocdbStorage=pocdbStorage;
+  else
+  ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
+   //      AliCDBManager* man = AliCDBManager::Instance();
+      // man->SetDefaultStorage("raw://");
+   //   man->SetDefaultStorage("ocdbStorage");
+   //     man->SetRun(ustartRun);
+      AliCDBEntry *entryCalib = AliCDBManager::Instance()->Get("T0/Calib/TimeDelay");
+      if(!entryCalib) {
+       AliWarning(Form("Cannot find any AliCDBEntry for [Calib, TimeDelay]!"));
+       for (Int_t i=0; i<24; i++)  timecdb[i]=999;
+      }
+      else
+       {
+         AliT0CalibTimeEq *clb = (AliT0CalibTimeEq*)entryCalib->GetObject();
+         timecdb = clb->GetTimeEq();
+       }
+      AliCDBEntry *entryCalibreco = AliCDBManager::Instance()->Get("T0/Calib/RecoParam");
+      if(entryCalibreco) {
+       AliT0RecoParam *rpr = (AliT0RecoParam*) entryCalibreco->GetObject();
+       badpmt = rpr->GetRefPoint();
+       printf(" bad PMT %i \n", badpmt);
+      }
       AliT0CalibTimeEq *offline = new AliT0CalibTimeEq();
       offline->Reset();
-      Bool_t writeok = offline->ComputeOfflineParams(filePhysName.Data());
+      Bool_t writeok = offline->ComputeOfflineParams(filePhysName.Data(), timecdb, badpmt);
       AliCDBMetaData metaData;
       metaData.SetBeamPeriod(1);
       metaData.SetResponsible("Alla Maevskaya");
@@ -73,13 +111,13 @@ void AliT0PreprocessorOffline::CalibOffsetChannels(TString filePhysName, Int_t u
       
       if (writeok)  {
        AliCDBId* id1=NULL;
-       id1=new AliCDBId("T0/Calib/TimeDelay", ustartRun, uendRun);
+       id1=new AliCDBId("T0/Calib/TimeDelay", ustartRun, uendRun );
        AliCDBStorage* gStorage = AliCDBManager::Instance()->GetStorage(ocdbStorage);
        gStorage->Put(offline, (*id1), &metaData);
       }
       else {
        
-          AliWarning(Form("writeok = %d not enough data for equalizing",writeok));
+          AliWarning(Form("writeok = %d data is not OK to be in OCDB",writeok));
       }                  
    
       delete offline;
@@ -87,3 +125,27 @@ void AliT0PreprocessorOffline::CalibOffsetChannels(TString filePhysName, Int_t u
        
 
 }
+//-------------------------------------------------------------------------------------
+void AliT0PreprocessorOffline::CalibT0sPosition(TString filePhysName, Int_t ustartRun, Int_t uendRun, TString pocdbStorage)
+{
+ if (filePhysName)
+    {
+      if (pocdbStorage.Length()>0) ocdbStorage=pocdbStorage;
+      else
+       ocdbStorage="local://"+gSystem->GetFromPipe("pwd")+"/OCDB";
+      
+      AliT0CalibSeasonTimeShift *offline = new AliT0CalibSeasonTimeShift();
+      Bool_t writeok = offline->SetT0Par(filePhysName.Data());
+      AliCDBMetaData metaData;
+      metaData.SetBeamPeriod(1);
+      metaData.SetResponsible("Alla Maevskaya");
+      metaData.SetComment("Time equalizing result with slew");
+      
+      if (writeok)  {
+       AliCDBId* id1=NULL;
+       id1=new AliCDBId("T0/Calib/TimeAdjust", ustartRun, uendRun);
+       AliCDBStorage* gStorage = AliCDBManager::Instance()->GetStorage(ocdbStorage);
+       gStorage->Put(offline, (*id1), &metaData);
+      }
+    }
+}