add static functions for external configuration
[u/mrichter/AliRoot.git] / TOF / AliTOFAnalysisTaskCalibPass0.cxx
index fb754b6f98ff8da920836f044ae379c4dc1efd23..c2647dd7240ef0580c6ca6b5576d59b32bf8a084 100644 (file)
@@ -52,8 +52,10 @@ ClassImp(AliTOFAnalysisTaskCalibPass0)
 //_______________________________________________________
 
 const Int_t AliTOFAnalysisTaskCalibPass0::fgkMaxNumberOfPoints = 10000; // max number of points
-const Double_t AliTOFAnalysisTaskCalibPass0::fgkMinVertexIntegral = 1000.;
-const Double_t AliTOFAnalysisTaskCalibPass0::fgkMinDeltatIntegral = 20000.;
+Double_t AliTOFAnalysisTaskCalibPass0::fgMinVertexIntegral = 100.;
+Double_t AliTOFAnalysisTaskCalibPass0::fgMinDeltatIntegral = 2000.;
+Double_t AliTOFAnalysisTaskCalibPass0::fgMinVertexIntegralSample = 1000.;
+Double_t AliTOFAnalysisTaskCalibPass0::fgMinDeltatIntegralSample = 20000.;
 
 //_______________________________________________________
   
@@ -347,39 +349,53 @@ AliTOFAnalysisTaskCalibPass0::ProcessOutput(const Char_t *filename, const Char_t
     AliError(Form("cannot open output file %s", filename));
     return kFALSE;
   }
-  /* get histo list */
-  TList *list = (TList *)file->Get("Histos");
-  if (!list) {
-    AliError(Form("cannot get \"Histos\" list from file %s", filename));
-    return kFALSE;
+  /* get histograms */
+  TList *list = (TList *)file->Get("TOFHistos");
+  TH2F *histoVertexTimestamp = NULL;
+  TH2F *histoDeltatTimestamp = NULL;
+  TH2F *histoDeltazEta = NULL;
+  TH2F *histoDeltazCosTheta = NULL;
+  TH2F *histoAcceptedTracksEtaPt = NULL;
+  TH2F *histoMatchedTracksEtaPt = NULL;
+  if (list) {
+    AliInfo(Form("getting histograms from \"Histos\" list from file %s", filename));
+    histoVertexTimestamp = (TH2F *)list->FindObject("hHistoVertexTimestamp");
+    histoDeltatTimestamp = (TH2F *)list->FindObject("hHistoDeltatTimestamp");
+    histoDeltazEta = (TH2F *)list->FindObject("hHistoDeltazEta");
+    histoDeltazCosTheta = (TH2F *)list->FindObject("hHistoDeltazCosTheta");
+    histoAcceptedTracksEtaPt = (TH2F *)list->FindObject("hHistoAcceptedTracksEtaPt");
+    histoMatchedTracksEtaPt = (TH2F *)list->FindObject("hHistoMatchedTracksEtaPt");
+  }
+  else {
+    AliInfo(Form("getting histograms directly from file %s", filename));
+    histoVertexTimestamp = (TH2F *)file->Get("hHistoVertexTimestamp");
+    histoDeltatTimestamp = (TH2F *)file->Get("hHistoDeltatTimestamp");
+    histoDeltazEta = (TH2F *)file->Get("hHistoDeltazEta");
+    histoDeltazCosTheta = (TH2F *)file->Get("hHistoDeltazCosTheta");
+    histoAcceptedTracksEtaPt = (TH2F *)file->Get("hHistoAcceptedTracksEtaPt");
+    histoMatchedTracksEtaPt = (TH2F *)file->Get("hHistoMatchedTracksEtaPt");
   }
-  /* get histos */
-  TH2F *histoVertexTimestamp = (TH2F *)list->FindObject("hHistoVertexTimestamp");
+  /* check histos */ 
   if (!histoVertexTimestamp) {
     AliError(Form("cannot get \"hHistoVertexTimestamp\" object from file %s", filename));
     return kFALSE;
   }
-  TH2F *histoDeltatTimestamp = (TH2F *)list->FindObject("hHistoDeltatTimestamp");
   if (!histoDeltatTimestamp) {
     AliError(Form("cannot get \"hHistoDeltatTimestamp\" object from file %s", filename));
     return kFALSE;
   }
-  TH2F *histoDeltazEta = (TH2F *)list->FindObject("hHistoDeltazEta");
   if (!histoDeltazEta) {
     AliError(Form("cannot get \"hHistoDeltazEta\" object from file %s", filename));
     return kFALSE;
   }
-  TH2F *histoDeltazCosTheta = (TH2F *)list->FindObject("hHistoDeltazCosTheta");
   if (!histoDeltazCosTheta) {
     AliError(Form("cannot get \"hHistoDeltazCosTheta\" object from file %s", filename));
     return kFALSE;
   }
-  TH2F *histoAcceptedTracksEtaPt = (TH2F *)list->FindObject("hHistoAcceptedTracksEtaPt");
   if (!histoAcceptedTracksEtaPt) {
     AliError(Form("cannot get \"hHistoAccptedTracksEtaPt\" object from file %s", filename));
     return kFALSE;
   }
-  TH2F *histoMatchedTracksEtaPt = (TH2F *)list->FindObject("hHistoMatchedTracksEtaPt");
   if (!histoMatchedTracksEtaPt) {
     AliError(Form("cannot get \"hHistoMatchedTracksEtaPt\" object from file %s", filename));
     return kFALSE;
@@ -511,14 +527,14 @@ AliTOFAnalysisTaskCalibPass0::CalibrateAndStore(TH2F *histoVertexTimestamp, TH2F
     /* define time window */
     Int_t startBin = ibin;
     Int_t endBin = ibin;
-    while(histoVertexTimestamppx->Integral(startBin, endBin) < fgkMinVertexIntegral ||
-         histoDeltatTimestamppx->Integral(startBin, endBin) < fgkMinDeltatIntegral) {
+    while(histoVertexTimestamppx->Integral(startBin, endBin) < fgMinVertexIntegralSample ||
+         histoDeltatTimestamppx->Integral(startBin, endBin) < fgMinDeltatIntegralSample) {
       if (endBin < maxBin) endBin++;
       else if (startBin > minBin) startBin--;
       else break;
     }
-    if (histoVertexTimestamppx->Integral(startBin, endBin) <= 0 ||
-        histoDeltatTimestamppx->Integral(startBin, endBin) <= 0) continue;
+    if (histoVertexTimestamppx->Integral(startBin, endBin) < fgMinVertexIntegral ||
+        histoDeltatTimestamppx->Integral(startBin, endBin) < fgMinDeltatIntegral) continue;
     Float_t startTime = histoVertexTimestamppx->GetBinLowEdge(startBin);
     Float_t endTime = histoVertexTimestamppx->GetBinLowEdge(endBin + 1);
     Float_t vertexIntegral = histoVertexTimestamppx->Integral(startBin, endBin);
@@ -611,7 +627,7 @@ AliTOFAnalysisTaskCalibPass0::CalibrateAndStore(TH2F *histoVertexTimestamp, TH2F
   Float_t tofReso[fgkMaxNumberOfPoints];
   Float_t t0Spread[fgkMaxNumberOfPoints];
   for (Int_t ipoint = 0; ipoint < nPoints; ipoint++) {
-    timestamp[ipoint] = time[ipoint] + (Float_t)startTimestamp;
+    timestamp[ipoint] = (UInt_t)time[ipoint] + startTimestamp;
     t0[ipoint] = timeZeroMean[ipoint];
     tofReso[ipoint] = timeZeroSigma[ipoint];
     t0Spread[ipoint] = vertexSigma[ipoint] / 2.99792457999999984e-02;