//_______________________________________________________
+const Char_t *AliTOFAnalysisTaskCalibPass0::fgkStatusCodeName[AliTOFAnalysisTaskCalibPass0::kNStatusCodes] = {
+ "ok",
+ "input error",
+ "data error",
+ "not active",
+ "low statistics",
+ "no measurement",
+ "store error"
+};
+
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.;
//_______________________________________________________
AliTOFAnalysisTaskCalibPass0::AliTOFAnalysisTaskCalibPass0() :
AliAnalysisTaskSE("TOFCalib-Pass0"),
+ fStatus(kOk),
fInitFlag(kFALSE),
fEventSelectionFlag(kFALSE),
fVertexSelectionFlag(kFALSE),
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;
}
//_______________________________________________________
+Int_t
+AliTOFAnalysisTaskCalibPass0::GetStatus()
+{
+ /*
+ * get status
+ */
+
+ switch (fStatus) {
+
+ /* OK, return zero */
+ case kOk:
+ return 0;
+ break;
+
+ /* non-fatal error, return negative status */
+ case kNotActive:
+ case kLowStatistics:
+ case kNoMeasurement:
+ return -fStatus;
+ break;
+
+ /* fatal error, return positive status */
+ case kInputError:
+ case kDataError:
+ case kStoreError:
+ return fStatus;
+ break;
+
+ /* anything else, return negative large number */
+ default:
+ return -999;
+ break;
+ }
+
+ /* should never arrive here, anyway return negative large number */
+ return -999;
+}
+
+//_______________________________________________________
+
Bool_t
AliTOFAnalysisTaskCalibPass0::ProcessOutput(const Char_t *filename, const Char_t *dbString)
{
* process output
*/
+ Int_t ret = DoProcessOutput(filename, dbString);
+ Int_t status = GetStatus();
+ if (status == 0) {
+ AliInfo(Form("TOF calibration successful: %s (status=%d)", fgkStatusCodeName[fStatus], status));
+ }
+ else if (status > 0) {
+ AliInfo(Form("TOF calibration failed: %s (status=%d)", fgkStatusCodeName[fStatus], status));
+ }
+ else if (status < 0) {
+ AliInfo(Form("TOF calibration failed (expected): %s (status=%d)", fgkStatusCodeName[fStatus], status));
+ }
+
+ return ret;
+}
+
+//_______________________________________________________
+
+Bool_t
+AliTOFAnalysisTaskCalibPass0::DoProcessOutput(const Char_t *filename, const Char_t *dbString)
+{
+ /*
+ * do process output
+ */
+
+ /* reset status to OK */
+ fStatus = kOk;
+
/* open file */
TFile *file = TFile::Open(filename);
if (!file || !file->IsOpen()) {
AliError(Form("cannot open output file %s", filename));
+ fStatus = kInputError;
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));
+ fStatus = kInputError;
return kFALSE;
}
- TH2F *histoDeltatTimestamp = (TH2F *)list->FindObject("hHistoDeltatTimestamp");
if (!histoDeltatTimestamp) {
AliError(Form("cannot get \"hHistoDeltatTimestamp\" object from file %s", filename));
+ fStatus = kInputError;
return kFALSE;
}
- TH2F *histoDeltazEta = (TH2F *)list->FindObject("hHistoDeltazEta");
if (!histoDeltazEta) {
AliError(Form("cannot get \"hHistoDeltazEta\" object from file %s", filename));
+ fStatus = kInputError;
return kFALSE;
}
- TH2F *histoDeltazCosTheta = (TH2F *)list->FindObject("hHistoDeltazCosTheta");
if (!histoDeltazCosTheta) {
AliError(Form("cannot get \"hHistoDeltazCosTheta\" object from file %s", filename));
+ fStatus = kInputError;
return kFALSE;
}
- TH2F *histoAcceptedTracksEtaPt = (TH2F *)list->FindObject("hHistoAcceptedTracksEtaPt");
if (!histoAcceptedTracksEtaPt) {
AliError(Form("cannot get \"hHistoAccptedTracksEtaPt\" object from file %s", filename));
+ fStatus = kInputError;
return kFALSE;
}
- TH2F *histoMatchedTracksEtaPt = (TH2F *)list->FindObject("hHistoMatchedTracksEtaPt");
if (!histoMatchedTracksEtaPt) {
AliError(Form("cannot get \"hHistoMatchedTracksEtaPt\" object from file %s", filename));
+ fStatus = kInputError;
return kFALSE;
}
+
/* check matching performance */
if (!CheckMatchingPerformance(histoDeltazEta, histoAcceptedTracksEtaPt, histoMatchedTracksEtaPt)) {
AliError("error while checking matching efficiency");
strarr = str.Tokenize(",");
if (!strarr) {
AliError("problems whith tokenize histogram title");
+ fStatus = kDataError;
return kFALSE;
}
ostr = (TObjString *)strarr->At(0);
if (!ostr) {
AliError("problems while getting run number from histogram title");
+ fStatus = kDataError;
return kFALSE;
}
str = ostr->GetString();
if (!str.BeginsWith("run:")) {
AliError("problems while getting run number from histogram title");
+ fStatus = kDataError;
return kFALSE;
}
str.Remove(0, 5);
Int_t runNb = atoi(str.Data());
if (runNb <= 0) {
AliError(Form("bad run number: %d", runNb));
+ fStatus = kDataError;
return kFALSE;
}
AliInfo(Form("got run number: %d", runNb));
ostr = (TObjString *)strarr->At(1);
if (!ostr) {
AliError("problems while getting start timestamp from histogram title");
+ fStatus = kDataError;
return kFALSE;
}
str = ostr->GetString();
str.Remove(0, 1); /* remove empty space at the beginning */
if (!str.BeginsWith("startTimestamp:")) {
AliError("problems while getting start timestamp from histogram title");
+ fStatus = kDataError;
return kFALSE;
}
str.Remove(0, 16);
UInt_t startTimestamp = atoi(str.Data());
if (startTimestamp <= 0) {
AliError(Form("bad start timestamp: %d", startTimestamp));
+ fStatus = kDataError;
return kFALSE;
}
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 */
TH1D *histoVertexTimestamppx = histoVertexTimestamp->ProjectionX("histoVertexTimestamppx");
TH1D *histoDeltatTimestamppx = histoDeltatTimestamp->ProjectionX("histoDeltatTimestamppx");
+ /* check statistics */
+ if (histoVertexTimestamppx->Integral() < fgMinVertexIntegral ||
+ histoDeltatTimestamppx->Integral() < fgMinDeltatIntegral) {
+ fStatus = kLowStatistics;
+ return kFALSE;
+ }
+
/* define mix and max time bin */
Int_t minBin = histoVertexTimestamppx->FindFirstBinAbove(0);
Int_t maxBin = histoVertexTimestamppx->FindLastBinAbove(0);
/* 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);
/* check points */
if (nPoints <= 0) {
AliError("no measurement available, quit");
+ fStatus = kNoMeasurement;
return kFALSE;
}
AliInfo(Form("average time-zero = %f", averageTimeZero / nPoints));
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;
obj.SetRunNb(run);
obj.SetRunFirstPoint(runFirstPoint);
obj.SetRunLastPoint(runLastPoint);
+ obj.SetUseLHCClockPhase(useBPTX);
/*** CREATE OCDB ENTRY ***/
if (!dbString) {
AliError("cannot store object because of NULL string");
+ fStatus = kStoreError;
return kFALSE;
}
AliCDBStorage *sto = cdb->GetStorage(dbString);
if (!sto) {
AliError(Form("cannot get storage %s", dbString));
+ fStatus = kStoreError;
return kFALSE;
}
AliCDBId id("TOF/Calib/RunParams", runNb, runNb);
md.SetAliRootVersion(gSystem->Getenv("ARVERSION"));
md.SetBeamPeriod(0);
if (!sto->Put(&obj, id, &md)) {
+ fStatus = kStoreError;
AliError(Form("error while putting object in storage %s", dbString));
+ return kFALSE;
}
/* success */