Pass0 task for any period
authoralla <alla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 17 Oct 2011 11:55:08 +0000 (11:55 +0000)
committeralla <alla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 17 Oct 2011 11:55:08 +0000 (11:55 +0000)
T0/AddTaskT0Calib.C
T0/AliT0CalibOffsetChannelsTask.cxx
T0/AliT0CalibOffsetChannelsTask.h

index 0a2317f..20d6e79 100644 (file)
@@ -1,16 +1,6 @@
-/*
 
- This macros setup the TPC calibration task AddTaskTPCCalib
- for Pass0.
- - the run number is required to config TPC OCDB
- The following calibration components are added to the AliTPCAnalysisTaskcalib task:
- 1. AliTPCcalibCalib - redo reconstruction with current calibration
- 2. AliTPCcalibTimeGain - TPC time dependent gain calibration
- 3. AliTPCcalibTime - TPC time dependent drift time calibration
- 4. AliTPCcalibLaser - laser track calibration
 
-*/
+void    readCDB (TObject *task1);
 //_____________________________________________________________________________
 AliAnalysisTask  *AddTaskT0Calib(Int_t runNumber)
 {
@@ -33,9 +23,12 @@ AliAnalysisTask  *AddTaskT0Calib(Int_t runNumber)
   //ConfigOCDB(runNumber);
 
   // setup task
- AliT0CalibOffsetChannelsTask  *task1=new AliT0CalibOffsetChannelsTask("CalibObjectsTrain1");
- // SetupCalibTaskTrain1(task1);
+  AliT0CalibOffsetChannelsTask  *task1 = new AliT0CalibOffsetChannelsTask("CalibObjectsTrain1");
+  readCDB(task1, runNumber);
   mgr->AddTask(task1);
+  
+  //  AliT0AnalysisTaskQA * task2 = new AliT0AnalysisTaskQA("QA task");
+  //    mgr->AddTask(task2);
 
   AliAnalysisDataContainer *cinput1 = mgr->GetCommonInputContainer();
   if (!cinput1) cinput1 = mgr->CreateContainer("cchain",TChain::Class(), 
@@ -46,3 +39,72 @@ AliAnalysisTask  *AddTaskT0Calib(Int_t runNumber)
   mgr->ConnectOutput(task1,1,coutput1);
   return task1;
 }
+//_____________________________________________________________________________
+void    readCDB (TObject *task1,  Int_t runNumber) {
+
+  Float_t zero_timecdb[24]={0};
+  Float_t *timecdb = zero_timecdb;
+  Float_t cfdvalue[24][5];
+  Float_t zero_shiftcdb[4]={0};
+  Float_t *shiftcdb = zero_shiftcdb;
+  AliT0CalibOffsetChannelsTask *mytask = (AliT0CalibOffsetChannelsTask*)task1;
+
+  AliCDBManager* man = AliCDBManager::Instance();
+  man->SetDefaultStorage("raw://");
+  man->SetRun(runNumber);
+  AliCDBEntry *entry = AliCDBManager::Instance()->Get("GRP/CTP/CTPtiming");
+  if (!entry) AliFatal("CTP timing parameters are not found in OCDB !");
+  AliCTPTimeParams *ctpParams = (AliCTPTimeParams*)entry->GetObject();
+  Float_t l1Delay = (Float_t)ctpParams->GetDelayL1L0()*25.0;
+
+  AliCDBEntry *entry1 = AliCDBManager::Instance()->Get("GRP/CTP/TimeAlign");
+  if (!entry1) AliFatal("CTP time-alignment is not found in OCDB !");
+  AliCTPTimeParams *ctpTimeAlign = (AliCTPTimeParams*)entry1->GetObject();
+  l1Delay += ((Float_t)ctpTimeAlign->GetDelayL1L0()*25.0);
+  AliCDBEntry *entry4 = AliCDBManager::Instance()->Get("GRP/Calib/LHCClockPhase");
+  if (!entry4) AliFatal("LHC clock-phase shift is not found in OCDB !");
+  AliLHCClockPhase *phase = (AliLHCClockPhase*)entry4->GetObject();
+  fGRPdelays = l1Delay - phase->GetMeanPhase();
+
+  AliCDBEntry *entryCalib0 = man->Get("T0/Calib/Latency");
+  fLatencyL1 = entryCalib0->GetLatencyL1();
+  fLatencyHPTDC = entryCalib0->GetLatencyHPTDC();
+  AliDebug(2,Form(" LatencyL1 %f latencyHPTDC %f \n",fLatencyL1, fLatencyHPTDC));
+  AliCDBEntry *entryCalib1 = man->Get("T0/Calib/TimeDelay");
+  if(!entryCalib1) {
+    AliError::(Form("Cannot find any AliCDBEntry for [Calib, TimeDelay]!"));
+    return;
+  }
+  else
+    {
+      AliT0CalibTimeEq *clb = (AliT0CalibTimeEq*)entryCalib1->GetObject();
+      timecdb = clb->GetTimeEq();
+      for(Int_t i=0; i<24; i++) 
+       for (Int_t i0=0; i0<5; i0++){
+         cfdvalue[i][i0] = clb->GetCFDvalue(i, i0);
+         if ( i0 ==0) prinf(" CFD value %i %f \n", i, cfdvalue[i][i0]);  
+       }
+    }
+  for (Int_t i=0; i<24; i++) {
+    Float_t cfdmean = cfdvalue[i][0];
+    if( cfdvalue[i][0] < 500 || cfdvalue[i][0] > 50000) cfdmean = ( 1000.*fLatencyHPTDC - 1000.*fLatencyL1 + 1000.*fGRPdelays)/24.4;
+    //  printf(" calulated mean %i %f \n", cfdmean);
+    mytask->SetCFDvalue(i, cfdmean);
+    mytask->SetTimeEq(i, timecdb[i]);
+  } 
+
+  AliCDBEntry *entryCalib2 = man->Get("T0/Calib/TimeAdjust");
+  if(!entryCalib2) {
+     AliError(Form("Cannot find any AliCDBEntry for [Calib, TimeAdjust]!"));
+  }
+ else
+    {
+      AliT0CalibSeasonTimeShift *clb1 = (AliT0CalibSeasonTimeShift*)entryCalib2->GetObject();
+      shiftcdb = clb1->GetT0Means();
+    }
+  
+  for (Int_t i=0; i<4; i++)  mytask->SetT0Means(i,shiftcdb[i]);
+}
index 9b67166..fa48544 100644 (file)
@@ -27,7 +27,7 @@ ClassImp(AliT0CalibOffsetChannelsTask)
 AliT0CalibOffsetChannelsTask::AliT0CalibOffsetChannelsTask() \r
   : AliAnalysisTaskSE(),  fESD(0x0), fTzeroObject(0x0),\r
   fTzeroORA(0x0), fTzeroORC(0x0), fResolution(0x0), fTzeroORAplusORC(0x0),\r
-  fRunNumber(0)\r
+    fRunNumber(0),fRefPMTA(12), fRefPMTC(0)\r
 {\r
   // Constructor\r
 \r
@@ -50,7 +50,7 @@ AliT0CalibOffsetChannelsTask::AliT0CalibOffsetChannelsTask()
 AliT0CalibOffsetChannelsTask::AliT0CalibOffsetChannelsTask(const char *name) \r
   : AliAnalysisTaskSE(name), fESD(0), fTzeroObject(0),\r
   fTzeroORA(0x0), fTzeroORC(0x0), fResolution(0x0), fTzeroORAplusORC(0x0),\r
-    fRunNumber(0)\r
+    fRunNumber(0),fRefPMTA(12), fRefPMTC(0)\r
 {\r
   // Constructor\r
  \r
@@ -113,9 +113,12 @@ AliT0CalibOffsetChannelsTask::~AliT0CalibOffsetChannelsTask()
 void AliT0CalibOffsetChannelsTask::UserCreateOutputObjects()\r
 {\r
   // Create histograms\r
+  Float_t low = fCDBcfds[fRefPMTC] - 500;\r
+  Float_t high = fCDBcfds[fRefPMTA] + 500;\r
+  printf(" AliT0CalibOffsetChannelsTask::UserCreateOutputObjects ::low %f high %f \n", low, high);\r
   for (Int_t i=0; i<24; i++) {\r
     fTimeDiff[i]   = new TH1F (Form("CFD1minCFD%d",i+1),"fTimeDiff",150, -300, 300);\r
-    fCFD[i]        = new TH1F(Form("CFD%d",i+1),"CFD",250, 2000, 3000);//6000, 7000);\r
+    fCFD[i]        = new TH1F(Form("CFD%d",i+1),"CFD",250,low, high);//6000, 7000);\r
     //    fCFD[i]        = new TH1F(Form("CFD%d",i+1),"CFD",250, -1000, 1000);//6000, 7000);\r
   }\r
 \r
@@ -166,8 +169,8 @@ void AliT0CalibOffsetChannelsTask::UserExec(Option_t *)
       fCFD[i]->Fill( time[i] );\r
       //  printf(" time %f ocdb %f \n", time[i],fCDBcfds[i]); \r
       \r
-      if(  time[0] != 0 ) {\r
-       diff =  time[i]-time[0] + fCDBdelays[i];\r
+      if(  time[fRefPMTC] != 0 ) {\r
+       diff =  time[i]-time[fRefPMTC] + fCDBdelays[i];\r
        fTimeDiff[i]->Fill( diff);\r
       }\r
     }\r
@@ -176,8 +179,8 @@ void AliT0CalibOffsetChannelsTask::UserExec(Option_t *)
     if( time[i] != 0 && amp[i]>0.1) {\r
       fCFD[i]->Fill( time[i]);\r
       //  printf(" time %f ocdb %f \n", time[i],fCDBcfds[i]); \r
-       if( time[12] != 0 ) {\r
-       diff =  time[i]-time[12] + fCDBdelays[i];\r
+       if( time[fRefPMTA] != 0 ) {\r
+       diff =  time[i]-time[fRefPMTA] + fCDBdelays[i];\r
        fTimeDiff[i]->Fill( diff);\r
       }\r
     }\r
index c419790..152def4 100644 (file)
@@ -29,7 +29,7 @@ class AliT0CalibOffsetChannelsTask : public AliAnalysisTaskSE {
   void SetTimeEq(Int_t channel, Float_t val) {fCDBdelays[channel]=val;}\r
   Float_t *GetT0Means() { return fCDBT0s;}\r
   void SetT0Means(Int_t ihist, Float_t mean ) {fCDBT0s[ihist]=mean;};\r
-\r
+  void SetRefPMT(Int_t refPMTA = 12, Int_t refPMTC=0) {fRefPMTA = refPMTA; fRefPMTC = refPMTC;};\r
 private:\r
   AliESDEvent *fESD;          //! ESD object\r
   TObjArray   *fTzeroObject;  // array with CFDi-CFD1 and  CFDi\r
@@ -43,6 +43,9 @@ private:
   Float_t fCDBdelays[24];  //time delays from OCDB\r
   Float_t fCDBcfds[24];    // mean CFD from OCDB\r
   Float_t fCDBT0s[4];      //position T0AC, T0A, T0A, resolution\r
+  Int_t fRefPMTA;           // ref. PMT A side \r
+  Int_t fRefPMTC;           // ref. PMT C side\r
\r
 \r
   \r
  \r