this is a relatively large commit to use BPTX clock-phase measurements in
authorrpreghen <rpreghen@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 28 Oct 2011 10:49:44 +0000 (10:49 +0000)
committerrpreghen <rpreghen@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 28 Oct 2011 10:49:44 +0000 (10:49 +0000)
TOF
calibration.

**********************************
AliTOFRunParams calibration object
**********************************
added a new bool data member. if set, the parameters stored in the
object have
been obtained using the BPTX, therefore calibration must use BPTX.
if not set, parameters have been obtained without BPTX and calibration
must go
without BPTX.

*****************************
AliTOFcalib calibration class
*****************************
added reading of BPTX LHCClockPhase OCDB entry.
BPTX measurement is used to calibrate TOF data only if AliTOFRunParams
object
has the flag set (i.e. the params were obtained using BPTX as well) or
if BPTX
use is forced by user (default is not use).
backward compatibility of calibration will be ensured.

****************************
AliTOFPreprocessor (SHUTTLE)
****************************
ProcessT0Fill function modified. Online T0-fill will be computed and
OCDB
updated only if not using BPTX measurement in TOF calibration.
Therefore, as a
new default AliTOFRunParams entry will be put in the OCDB with use BPTX
flag
set, we don't expect to compute and update OCDB with online T0-fill
anymore
after that.

****************************
AliTOFAnalysisTaskCalibPass0
****************************
TOF C-Pass0 calibration code updated to use the BPTX as well and produce
objects with correct flags. C-Pass0 will now compute the residual shift
wrt. BPTX measurement.

TOF/AddTOFAnalysisTaskCalibPass0.C
TOF/AliTOFAnalysisTaskCalibPass0.cxx
TOF/AliTOFPreprocessor.cxx
TOF/AliTOFRunParams.cxx
TOF/AliTOFRunParams.h
TOF/AliTOFcalib.cxx
TOF/AliTOFcalib.h
TOF/MakeCDBEntryRunParams.C

index 57d1bfd14584ee875c1031e0b7e8b22c3e9429e3..ca204ebbc78c391449d5f86a8c82c9e15c5583dd 100644 (file)
@@ -51,6 +51,7 @@ AddTOFAnalysisTaskCalibPass0()
   task->SetVertexCut(25.0);
   /* setup TOF calib */
   task->GetTOFcalib()->SetRemoveMeanT0(kFALSE);
+  task->GetTOFcalib()->SetUseLHCClockPhase(kTRUE);
   task->GetTOFcalib()->SetCalibrateTOFsignal(kTRUE);
   task->GetTOFcalib()->SetCorrectTExp(kFALSE);
   /* setup track cuts */
index 7f857aac2b31a5346a0d1c29c4adfa4f91a40a85..6a21aeb5ea134e125e15669c59f5702630d90e18 100644 (file)
@@ -169,13 +169,15 @@ AliTOFAnalysisTaskCalibPass0::InitRun()
   fInitFlag = kTRUE;
   fRunNumber = runNb;
   
+  Int_t useBPTX = fTOFcalib->GetUseLHCClockPhase() ? 1 : 0;
+
   /* set histo title with run-number and start-time */
-  fHistoVertexTimestamp->SetTitle(Form("run: %d, startTimestamp: %u", fRunNumber, fStartTime));
-  fHistoDeltatTimestamp->SetTitle(Form("run: %d, startTimestamp: %u", fRunNumber, fStartTime));
-  fHistoDeltazEta->SetTitle(Form("run: %d, startTimestamp: %u", fRunNumber, fStartTime));
-  fHistoDeltazCosTheta->SetTitle(Form("run: %d, startTimestamp: %u", fRunNumber, fStartTime));
-  fHistoAcceptedTracksEtaPt->SetTitle(Form("run: %d, startTimestamp: %u", fRunNumber, fStartTime));
-  fHistoMatchedTracksEtaPt->SetTitle(Form("run: %d, startTimestamp: %u", fRunNumber, fStartTime));
+  fHistoVertexTimestamp->SetTitle(Form("run: %d, startTimestamp: %u, BPTX: %d", fRunNumber, fStartTime, useBPTX));
+  fHistoDeltatTimestamp->SetTitle(Form("run: %d, startTimestamp: %u, BPTX: %d", fRunNumber, fStartTime, useBPTX));
+  fHistoDeltazEta->SetTitle(Form("run: %d, startTimestamp: %u, BPTX: %d", fRunNumber, fStartTime, useBPTX));
+  fHistoDeltazCosTheta->SetTitle(Form("run: %d, startTimestamp: %u, BPTX: %d", fRunNumber, fStartTime, useBPTX));
+  fHistoAcceptedTracksEtaPt->SetTitle(Form("run: %d, startTimestamp: %u, BPTX: %d", fRunNumber, fStartTime, useBPTX));
+  fHistoMatchedTracksEtaPt->SetTitle(Form("run: %d, startTimestamp: %u, BPTX: %d", fRunNumber, fStartTime, useBPTX));
   
   return kTRUE;
 }
@@ -589,6 +591,24 @@ AliTOFAnalysisTaskCalibPass0::CalibrateAndStore(TH2F *histoVertexTimestamp, TH2F
   TTimeStamp ts = startTimestamp;
   AliInfo(Form("got start timestamp: %d (%s)", startTimestamp, ts.AsString()));
 
+  /* BPTX */
+  ostr = (TObjString *)strarr->At(2);
+  if (!ostr) {
+    AliError("problems while getting BPTX from histogram title");
+    fStatus = kDataError;
+    return kFALSE;
+  }
+  str = ostr->GetString();
+  str.Remove(0, 1); /* remove empty space at the beginning */
+  if (!str.BeginsWith("BPTX:")) {
+    AliError("problems while getting BPTX from histogram title");
+    fStatus = kDataError;
+    return kFALSE;
+  }
+  str.Remove(0, 6);
+  Bool_t useBPTX = atoi(str.Data());
+  AliInfo(Form("got BPTX: %d", useBPTX));
+
   /*** CALIBRATION STAGE ***/
 
   /* get fit function */
@@ -747,6 +767,7 @@ AliTOFAnalysisTaskCalibPass0::CalibrateAndStore(TH2F *histoVertexTimestamp, TH2F
   obj.SetRunNb(run);
   obj.SetRunFirstPoint(runFirstPoint);
   obj.SetRunLastPoint(runLastPoint);
+  obj.SetUseLHCClockPhase(useBPTX);
   
   /*** CREATE OCDB ENTRY ***/
 
index c78fbe3ea8ab51b8d85ef8c3f846321c8871dbfb..3e46a9de17cc65c7640f6f9de63566bfbf22ea58 100644 (file)
@@ -754,6 +754,21 @@ AliTOFPreprocessor::ProcessT0Fill()
   /* get params from OCDB */
   AliCDBEntry *cdbe = NULL;
 
+  /*
+   * check UseLHCClockPhase flag in RunParams.
+   * if set do nothing and return successfully
+   */
+  cdbe = GetFromOCDB("Calib", "RunParams");
+  if (!cdbe) {
+    Log("cannot get \"RunParams\" entry from OCDB");
+    return 21;
+  }
+  AliTOFRunParams *runparams = (AliTOFRunParams *)cdbe->GetObject();
+  if (runparams->GetUseLHCClockPhase()) {
+    Log("UseLHCClockPhase flag is set in RunParams: online T0-fill not computed");
+    return 0;
+  }
+
   /* 
    * at this stage status object is not on OCDB yet
    * since it will be stored later. nevertheless we
@@ -950,6 +965,7 @@ AliTOFPreprocessor::ProcessT0Fill()
   runParamsObject->SetT0(t0);
   runParamsObject->SetTOFResolution(tofReso);
   runParamsObject->SetT0Spread(t0Spread);
+  runParamsObject->SetUseLHCClockPhase(kFALSE);
 
   /* store reference data */
   if(fStoreRefData){
index 68cbab5e3953f0c759b521a9ca5772a8a3327dec..17ba17e33df797559c0f8f3ee48a509a1c4e928a 100644 (file)
@@ -41,7 +41,8 @@ AliTOFRunParams::AliTOFRunParams() :
   fNRuns(0),
   fRunNb(NULL),
   fRunFirstPoint(NULL),
-  fRunLastPoint(NULL)
+  fRunLastPoint(NULL),
+  fUseLHCClockPhase(kFALSE)
 {
   /*
    * default constructor
@@ -60,7 +61,8 @@ AliTOFRunParams::AliTOFRunParams(Int_t nPoints, Int_t nRuns) :
   fNRuns(nRuns),
   fRunNb(new UInt_t[nRuns]),
   fRunFirstPoint(new UInt_t[nRuns]),
-  fRunLastPoint(new UInt_t[nRuns])
+  fRunLastPoint(new UInt_t[nRuns]),
+  fUseLHCClockPhase(kFALSE)
 {
   /*
    * standard constructor
@@ -96,7 +98,8 @@ AliTOFRunParams::AliTOFRunParams(const AliTOFRunParams &source) :
   fNRuns(source.fNRuns),
   fRunNb(new UInt_t[source.fNRuns]),
   fRunFirstPoint(new UInt_t[source.fNRuns]),
-  fRunLastPoint(new UInt_t[source.fNRuns])
+  fRunLastPoint(new UInt_t[source.fNRuns]),
+  fUseLHCClockPhase(source.fUseLHCClockPhase)
 {
   /*
    * copy constructor
@@ -164,6 +167,8 @@ AliTOFRunParams::operator=(const AliTOFRunParams &source)
     fRunLastPoint[i] = source.fRunLastPoint[i];
   }
 
+  fUseLHCClockPhase = source.fUseLHCClockPhase;
+
   return *this;
 }
 
index f82033e47ef249c9df912bf665060e59ccfd43cc..42f3b0c6262faff6139ce80482146c834cc6b814 100644 (file)
@@ -52,6 +52,8 @@ public TObject
   void SetRunFirstPoint(UInt_t *value) {if (fRunFirstPoint) for (Int_t i = 0; i < fNRuns; i++) fRunFirstPoint[i] = value[i];}; // setter
   void SetRunLastPoint(UInt_t *value) {if (fRunLastPoint) for (Int_t i = 0; i < fNRuns; i++) fRunLastPoint[i] = value[i];}; // setter
 
+  void SetUseLHCClockPhase(Bool_t value) {fUseLHCClockPhase = value;}; // setter
+
   Float_t EvalT0(UInt_t timestamp); // eval T0
   Float_t EvalTOFResolution(UInt_t timestamp); // eval TOF resolution
   Float_t EvalT0Spread(UInt_t timestamp); // eval T0 spread
@@ -60,6 +62,8 @@ public TObject
   Float_t AverageTOFResolution(UInt_t runNb) {return Average(fTOFResolution, runNb);}; // average TOF resolution
   Float_t AverageT0Spread(UInt_t runNb) {return Average(fT0Spread, runNb);}; // average T0 spread
 
+  Bool_t GetUseLHCClockPhase() const {return fUseLHCClockPhase;}; // getter
+
   TGraph *DrawGraphT0(Option_t *option = "") {return DrawGraph(fT0, option);}; // draw graph t0
   TGraph *DrawGraphTOFResolution(Option_t *option = "") {return DrawGraph(fTOFResolution, option);}; // draw graph t0
   TGraph *DrawGraphT0Spread(Option_t *option = "") {return DrawGraph(fT0Spread, option);}; // draw graph t0
@@ -88,8 +92,10 @@ public TObject
   UInt_t *fRunFirstPoint; //[fNRuns] run start point
   UInt_t *fRunLastPoint; //[fNRuns] run last point
 
+  Bool_t fUseLHCClockPhase; // use LHC clockphase
+
 
-  ClassDef(AliTOFRunParams, 2);
+  ClassDef(AliTOFRunParams, 3);
 };
 
 #endif /* ALITOFRUNPARAMS_H */
index e3b9dd6c1eafedf5dcbf3127c8d0c083df1d5d22..09e2cd143256c1f6d4ce68632f59f79b5472f67b 100644 (file)
@@ -118,6 +118,7 @@ author: Chiara Zampolli, zampolli@bo.infn.it
 #include "AliTOFCTPLatency.h"
 #include "AliTOFT0Fill.h"
 #include "AliTOFRunParams.h"
+#include "AliLHCClockPhase.h"
 #include "AliTOFResponseParams.h"
 #include "AliESDEvent.h"
 #include "AliESDtrack.h"
@@ -154,11 +155,13 @@ AliTOFcalib::AliTOFcalib():
   fCTPLatency(NULL),
   fT0Fill(NULL),
   fRunParams(NULL),
+  fLHCClockPhase(NULL),
   fResponseParams(NULL),
   fReadoutEfficiency(NULL),
   fProblematic(NULL),
   fInitFlag(kFALSE),
   fRemoveMeanT0(kTRUE),
+  fUseLHCClockPhase(kFALSE),
   fCalibrateTOFsignal(kTRUE),
   fCorrectTExp(kFALSE)
 { 
@@ -191,11 +194,13 @@ AliTOFcalib::AliTOFcalib(const AliTOFcalib & calib):
   fCTPLatency(NULL),
   fT0Fill(NULL),
   fRunParams(NULL),
+  fLHCClockPhase(NULL),
   fResponseParams(NULL),
   fReadoutEfficiency(NULL),
   fProblematic(NULL),
   fInitFlag(calib.fInitFlag),
   fRemoveMeanT0(calib.fRemoveMeanT0),
+  fUseLHCClockPhase(calib.fUseLHCClockPhase),
   fCalibrateTOFsignal(calib.fCalibrateTOFsignal),
   fCorrectTExp(calib.fCorrectTExp)
 {
@@ -301,6 +306,7 @@ AliTOFcalib& AliTOFcalib::operator=(const AliTOFcalib &calib)
   }
   fInitFlag = calib.fInitFlag;
   fRemoveMeanT0 = calib.fRemoveMeanT0;
+  fUseLHCClockPhase = calib.fUseLHCClockPhase;
   fCalibrateTOFsignal = calib.fCalibrateTOFsignal;
   fCorrectTExp = calib.fCorrectTExp;
 
@@ -2156,6 +2162,29 @@ AliTOFcalib::ReadRunParamsFromCDB(const Char_t *sel , Int_t nrun)
 
 //----------------------------------------------------------------------------
 
+Bool_t
+AliTOFcalib::ReadLHCClockPhaseFromCDB(const Char_t *sel , Int_t nrun)
+{
+  /*
+   * read LHC clock-phase from CDB
+   */
+  
+  AliCDBManager *man = AliCDBManager::Instance();
+  AliCDBEntry *entry = man->Get(Form("%s/LHCClockPhase", sel),nrun);
+  if (!entry) { 
+    AliFatal("No LHCClockPhase entry found in CDB");
+    exit(0);  
+  }
+  fLHCClockPhase =(AliLHCClockPhase *)entry->GetObject();
+  if(!fRunParams){
+    AliFatal("No LHCClockPhase object found in CDB entry");
+    exit(0);  
+  }  
+  return kTRUE; 
+}
+
+//----------------------------------------------------------------------------
+
 Bool_t
 AliTOFcalib::ReadReadoutEfficiencyFromCDB(const Char_t *sel , Int_t nrun)
 {
@@ -2239,6 +2268,11 @@ AliTOFcalib::Init(Int_t run)
     AliError("cannot get \"RunParams\" object from OCDB");
     return kFALSE;
   }
+  /* get LHC clock-phase obj */
+  if (!ReadLHCClockPhaseFromCDB("GRP/Calib", run)) {
+    AliError("cannot get \"LHCClockPhase\" object from OCDB");
+    return kFALSE;
+  }
   /* get readout efficiency obj */
   if (!ReadReadoutEfficiencyFromCDB("TOF/Calib", run)) {
     AliError("cannot get \"ReadoutEfficiency\" object from OCDB");
@@ -2262,6 +2296,13 @@ AliTOFcalib::Init(Int_t run)
   }
   responseFile->Close();
 
+  /* check whether to use the clock phase */
+  if (fRunParams->GetUseLHCClockPhase())
+    fUseLHCClockPhase = kTRUE;
+  if (fUseLHCClockPhase)
+    AliInfo("calibration using BPTX LHC clock-phase");
+
   /* all done */
   fInitFlag = kTRUE;
   return kTRUE;
@@ -2291,9 +2332,12 @@ AliTOFcalib::GetTimeCorrection(Int_t index, Double_t tot, Int_t deltaBC, Int_t l
   Float_t ctpLatency = fCTPLatency->GetCTPLatency();
   Float_t tdcLatencyWindow = fStatus->GetLatencyWindow(index) * 1.e3;
   Float_t timezero = fRunParams->EvalT0(timestamp);
+  Float_t clockphase = fLHCClockPhase->GetPhase(timestamp);
   /* check whether to remove mean T0.
    * useful when one wants to compute mean T0 */
   if (!fRemoveMeanT0) timezero = 0.;
+  /* check whether to use the clock phase */
+  if (fUseLHCClockPhase) timezero -= 1.e3 * clockphase;
 
   /* compute correction */
   Double_t corr = 0.;
index 1c4142154fc47703c128ac6e4317739c6e0618a6..255f09f95dd884b2e2584d826a7d209eda0ca5b7 100644 (file)
@@ -47,6 +47,7 @@ class AliTOFT0Fill;
 class AliTOFRunParams;
 class AliTOFResponseParams;
 class AliESDEvent;
+class AliLHCClockPhase;
 
 class AliTOFcalib:public TTask{
 public:
@@ -148,6 +149,7 @@ public:
   Bool_t ReadCTPLatencyFromCDB(const Char_t *sel, Int_t nrun);
   Bool_t ReadT0FillFromCDB(const Char_t *sel, Int_t nrun);
   Bool_t ReadRunParamsFromCDB(const Char_t *sel, Int_t nrun);
+  Bool_t ReadLHCClockPhaseFromCDB(const Char_t *sel, Int_t nrun);
   Bool_t ReadReadoutEfficiencyFromCDB(const Char_t *sel, Int_t nrun);
   Bool_t ReadProblematicFromCDB(const Char_t *sel, Int_t nrun);
 
@@ -156,6 +158,8 @@ public:
   void CalibrateESD(AliESDEvent *event); // calibrate ESD
   void CalibrateTExp(AliESDEvent *event) const; // calibrate TExp
   void SetRemoveMeanT0(Bool_t value) {fRemoveMeanT0 = value;}; // setter
+  void SetUseLHCClockPhase(Bool_t value) {fUseLHCClockPhase = value;}; // setter
+  Bool_t GetUseLHCClockPhase() const {return fUseLHCClockPhase;}; // getter
   void SetCalibrateTOFsignal(Bool_t value) {fCalibrateTOFsignal = value;}; // setter
   void SetCorrectTExp(Bool_t value) {fCorrectTExp = value;}; // setter
   Bool_t IsChannelEnabled(Int_t index, Bool_t checkEfficiency = kTRUE, Bool_t checkProblematic = kTRUE); // is channel enabled
@@ -190,12 +194,14 @@ private:
   AliTOFCTPLatency *fCTPLatency; // CTP latency
   AliTOFT0Fill *fT0Fill; // T0 fill
   AliTOFRunParams *fRunParams; // run params
+  AliLHCClockPhase *fLHCClockPhase; // LHC clock-phase
   AliTOFResponseParams *fResponseParams; // run params
   TH1F *fReadoutEfficiency; // readout efficiency
   TH1C *fProblematic; // problematic
   
   Bool_t fInitFlag; // init flag
   Bool_t fRemoveMeanT0; // remove mean T0
+  Bool_t fUseLHCClockPhase; // use LHC clock-phase
   Bool_t fCalibrateTOFsignal; // calibrate TOF signal
   Bool_t fCorrectTExp; // correct expected time
 
index d677a8c22af5e5aa8947ebcfd11df023e2e898a3..a877caa9bb282659ec129eae9e062539978f2d4a 100644 (file)
@@ -13,6 +13,7 @@ MakeCDBEntryRunParams(Float_t time0, Float_t reso, Float_t spread = -1., Int_t s
   obj->SetT0(t0);
   obj->SetTOFResolution(tofReso);
   obj->SetT0Spread(t0Spread);
+  obj->SetUseLHCClockPhase(kTRUE);
 
   /* create cdb info */
   AliCDBId id("TOF/Calib/RunParams", startRun, endRun);