#include <AliGeomManager.h>
#include <AliCDBManager.h>
#include <AliCDBEntry.h>
+
+#include <AliOADBContainer.h>
+#include <AliTOFPIDParams.h>
+
#include <AliT0CalibSeasonTimeShift.h>
#include "AliTOFTenderSupply.h"
AliTOFTenderSupply::AliTOFTenderSupply() :
AliTenderSupply(),
fESDpid(0x0),
+ fTenderNoAction(kTRUE),
fIsMC(kFALSE),
- fTimeZeroType(AliESDpid::kBest_T0),
fCorrectExpTimes(kTRUE),
fCorrectTRDBug(kFALSE),
fLHC10dPatch(kFALSE),
fAutomaticSettings(kTRUE),
fRecoPass(0),
fUserRecoPass(0),
+ fForceCorrectTRDBug(kFALSE),
+ fTOFPIDParams(0x0),
fTOFCalib(0x0),
fTOFT0maker(0x0),
- fTOFres(100.),
fT0IntercalibrationShift(0),
fGeomSet(kFALSE),
fIsEnteringInTRD(kFALSE),
AliTOFTenderSupply::AliTOFTenderSupply(const char *name, const AliTender *tender) :
AliTenderSupply(name,tender),
fESDpid(0x0),
+ fTenderNoAction(kTRUE),
fIsMC(kFALSE),
- fTimeZeroType(AliESDpid::kBest_T0),
fCorrectExpTimes(kTRUE),
fCorrectTRDBug(kFALSE),
fLHC10dPatch(kFALSE),
fAutomaticSettings(kTRUE),
fRecoPass(0),
fUserRecoPass(0),
+ fForceCorrectTRDBug(kFALSE),
+ fTOFPIDParams(0x0),
fTOFCalib(0x0),
fTOFT0maker(0x0),
- fTOFres(100.),
fT0IntercalibrationShift(0),
fGeomSet(kFALSE),
fIsEnteringInTRD(kFALSE),
void AliTOFTenderSupply::Init()
{
- Bool_t tenderUnsupported = kFALSE;
+ fTenderNoAction = kFALSE;
// Initialise TOF tender (this is called at each detected run change)
AliLog::SetClassDebugLevel("AliTOFTenderSupply",10);
else fRecoPass = fUserRecoPass;
}
if (run<114737) {
- tenderUnsupported = kTRUE;
+ fTenderNoAction = kTRUE;
}
else if (run>=114737&&run<=117223) { //period="LHC10B";
if (fRecoPass == 2) {fCorrectExpTimes=kTRUE; fCorrectTRDBug=kFALSE;}
else if (fRecoPass == 3) {fCorrectExpTimes=kFALSE; fCorrectTRDBug=kTRUE;}
fLHC10dPatch=kFALSE;
- fTOFres=100.;
- fTimeZeroType=AliESDpid::kTOF_T0;
fT0IntercalibrationShift = 0;
- fT0DetectorAdjust=kTRUE;
+ fT0DetectorAdjust=kFALSE; // it was kTRUE
}
else if (run>=118503&&run<=121040) { //period="LHC10C";
if (fRecoPass == 2) {fCorrectExpTimes=kTRUE; fCorrectTRDBug=kFALSE;}
else if (fRecoPass == 3) {fCorrectExpTimes=kFALSE; fCorrectTRDBug=kTRUE;}
fLHC10dPatch=kFALSE;
- fTOFres=100.;
- fTimeZeroType=AliESDpid::kTOF_T0;
fT0IntercalibrationShift = 0;
fT0DetectorAdjust=kFALSE;
}
else if (run>=122195&&run<=126437) { //period="LHC10D";
fCorrectExpTimes=kFALSE;
fLHC10dPatch=kTRUE;
- fTOFres=100.;
- fTimeZeroType=AliESDpid::kBest_T0;
fT0IntercalibrationShift = 0;
- fT0DetectorAdjust=kTRUE;
+ fT0DetectorAdjust=kFALSE; // it was kTRUE
}
else if (run>=127719&&run<=130850) { //period="LHC10E";
fCorrectExpTimes=kFALSE;
fLHC10dPatch=kFALSE;
- fTOFres=100.;
- fTimeZeroType=AliESDpid::kBest_T0;
fT0IntercalibrationShift = 30.;
- fT0DetectorAdjust=kTRUE;
+ fT0DetectorAdjust=kFALSE; // it was kTRUE
}
else if (run>=133004&&run<=135029) { //period="LHC10F";
- fCorrectExpTimes=kFALSE;
- fLHC10dPatch=kFALSE;
- fTOFres=100.;
- fTimeZeroType=AliESDpid::kBest_T0;
- fT0IntercalibrationShift = 0.;
- fT0DetectorAdjust=kTRUE;
- AliWarning("TOF tender not supported for LHC10F period!! Settings are just a guess!!");
+ fTenderNoAction=kTRUE;
}
else if (run>=135654&&run<=136377) { //period="LHC10G";
- fCorrectExpTimes=kFALSE;
- fLHC10dPatch=kFALSE;
- fTOFres=100.;
- fTimeZeroType=AliESDpid::kBest_T0;
- fT0IntercalibrationShift = 0.;
- fT0DetectorAdjust=kTRUE;
- AliWarning("TOF tender not supported for LHC10G period!! Settings are just a guess!!");
+ fTenderNoAction=kTRUE;
}
else if (run>=136851&&run<=139517) { //period="LHC10H" - pass2;
fCorrectExpTimes=kFALSE;
fLHC10dPatch=kFALSE;
- fTOFres=90.;
- fTimeZeroType=AliESDpid::kTOF_T0;
fT0IntercalibrationShift = 0.;
- fT0DetectorAdjust=kTRUE;
+ fT0DetectorAdjust=kFALSE; // it was kTRUE
}
else if (run>=139699) { //period="LHC11A";
- /*
- fCorrectExpTimes=kFALSE;
- fLHC10dPatch=kFALSE;
- fTOFres=100.;
- fTimeZeroType=AliESDpid::kBest_T0;
- fT0IntercalibrationShift = 0.;
- fT0DetectorAdjust=kFALSE;
- AliWarning("TOF tender not supported for LHC11A period!! Settings are just a guess!!");
- */
- AliError("TOF tender not supported for 2011 data!!!!!");
- tenderUnsupported = kTRUE;
+ fTenderNoAction=kTRUE;
}
}
- if (tenderUnsupported) {
+ if (fTenderNoAction) {
AliInfo(" |---------------------------------------------------------------------------|");
AliInfo(" | |");
- AliInfo(Form(" | TOF tender is not supported for run %d |",run));
- AliInfo(" | You cannot use TOF tender for this run, your results can be spoiled |");
- AliInfo(" | Check TOF tender usage for run/periods at: |");
+ AliInfo(Form(" | TOF tender is not supported for run %d |",run));
+ AliInfo(" | TOF tender will do nothing. |");
+ AliInfo(" | Check TOF tender usage for run/periods at: |");
AliInfo(" | https://twiki.cern.ch/twiki/bin/view/ALICE/TOF. |");
AliInfo(" |---------------------------------------------------------------------------|");
AliInfo(" ");
- AliFatal(" ------- TOF tender not to be used in this run, issuing FATAL error -------- ");
+ return;
}
+
+ // Load from OADB TOF resolution
+ LoadTOFPIDParams(run);
+
// Check if another tender wagon already created the esd pid object
// if not we create it and set it to the ESD input handler
fESDpid=fTender->GetESDhandler()->GetESDpid();
// Configure TOFT0 maker class
// if (!fTOFT0maker) fTOFT0maker = new AliTOFT0maker(fESDpid,fTOFCalib); // create if needed
if (!fTOFT0maker) fTOFT0maker = new AliTOFT0maker(fESDpid); // without passing AliTOFCalib it uses the diamond
- fTOFT0maker->SetTimeResolution(fTOFres); // set TOF resolution for the PID
+ fTOFT0maker->SetTimeResolution(fTOFPIDParams->GetTOFresolution()); // set TOF resolution for the PID
fTOFT0maker->SetTOFT0algorithm(2);
AliInfo("|******************************************************|");
AliInfo(Form("| Correct Exp Times : %d |",fCorrectExpTimes));
AliInfo(Form("| Correct TRD Bug : %d |",fCorrectTRDBug));
AliInfo(Form("| LHC10d patch : %d |",fLHC10dPatch));
- AliInfo(Form("| TOF resolution for TOFT0 maker : %5.2f (ps) |",fTOFres));
- AliInfo(Form("| timeZero selection : %d |",fTimeZeroType));
+ AliInfo(Form("| TOF resolution for TOFT0 maker : %5.2f (ps) |",fTOFPIDParams->GetTOFresolution()));
AliInfo(Form("| MC flag : %d |",fIsMC));
- AliInfo(Form("| T0 detector offsets applied : %d |",fT0DetectorAdjust));
- AliInfo(Form("| TOF/T0 intecalibration shift : %5.2f (ps) |",fT0IntercalibrationShift));
+ // AliInfo(Form("| T0 detector offsets applied : %d |",fT0DetectorAdjust));
+ // AliInfo(Form("| TOF/T0 intercalibration shift : %5.2f (ps) |",fT0IntercalibrationShift));
AliInfo("|******************************************************|");
if (fTender->RunChanged()){
- Init();
+ Init();
+ if (fTenderNoAction) return;
Int_t versionNumber = GetOCDBVersion(fTender->GetRun());
fTOFCalib->SetRunParamsSpecificVersion(versionNumber);
fTOFCalib->Init(fTender->GetRun());
if(event->GetT0TOF()){ // read T0 detector correction from OCDB
- // OCDB instance
- if (fT0DetectorAdjust) {
- AliCDBManager* ocdbMan = AliCDBManager::Instance();
- ocdbMan->SetRun(fTender->GetRun());
- AliCDBEntry *entry = ocdbMan->Get("T0/Calib/TimeAdjust/");
- if(entry) {
- AliT0CalibSeasonTimeShift *clb = (AliT0CalibSeasonTimeShift*) entry->GetObject();
- Float_t *t0means= clb->GetT0Means();
- // Float_t *t0sigmas = clb->GetT0Sigmas();
- fT0shift[0] = t0means[0] + fT0IntercalibrationShift;
- fT0shift[1] = t0means[1] + fT0IntercalibrationShift;
- fT0shift[2] = t0means[2] + fT0IntercalibrationShift;
- fT0shift[3] = t0means[3] + fT0IntercalibrationShift;
+ // OCDB instance
+ if (fT0DetectorAdjust) {
+ AliCDBManager* ocdbMan = AliCDBManager::Instance();
+ ocdbMan->SetRun(fTender->GetRun());
+ AliCDBEntry *entry = ocdbMan->Get("T0/Calib/TimeAdjust/");
+ if(entry) {
+ AliT0CalibSeasonTimeShift *clb = (AliT0CalibSeasonTimeShift*) entry->GetObject();
+ Float_t *t0means= clb->GetT0Means();
+ // Float_t *t0sigmas = clb->GetT0Sigmas();
+ fT0shift[0] = t0means[0] + fT0IntercalibrationShift;
+ fT0shift[1] = t0means[1] + fT0IntercalibrationShift;
+ fT0shift[2] = t0means[2] + fT0IntercalibrationShift;
+ fT0shift[3] = t0means[3] + fT0IntercalibrationShift;
+ } else {
+ for (Int_t i=0;i<4;i++) fT0shift[i]=0;
+ AliWarning("TofTender no T0 entry found T0shift set to 0");
+ }
} else {
for (Int_t i=0;i<4;i++) fT0shift[i]=0;
- AliWarning("TofTender no T0 entry found T0shift set to 0");
}
- } else {
- for (Int_t i=0;i<4;i++) fT0shift[i]=0;
- }
}
}
+ if (fTenderNoAction) return;
fTOFCalib->CalibrateESD(event); //recalculate TOF signal (no harm for MC, see settings inside init)
// patches for various reconstruction bugs
if (fLHC10dPatch && !(fIsMC)) RecomputeTExp(event); // LHC10d pass2: fake full TRD geometry
- if (fCorrectTRDBug && !(fIsMC)) FixTRDBug(event); // LHC10b,c pass3: wrong TRD dE/dx
+ if ( (fCorrectTRDBug && !(fIsMC)) || (fForceCorrectTRDBug)) FixTRDBug(event); // LHC10b,c pass3: wrong TRD dE/dx
Double_t startTime = 0.;
- if(fIsMC) startTime = fTOFCalib->TuneForMC(event,fTOFres); // this is for old MC when we didn't jitter startTime in MC
+ if (fIsMC) startTime = fTOFCalib->TuneForMC(event,fTOFPIDParams->GetTOFresolution()); // this is for old MC when we didn't jitter startTime in MC
if (fDebugLevel > 1) Printf(" TofTender: startTime %f",startTime);
if (fDebugLevel > 1) Printf(" TofTender: T0 time (orig) %f %f %f",event->GetT0TOF(0),event->GetT0TOF(1),event->GetT0TOF(2));
if (event->GetT0TOF(1) == 0) event->SetT0TOF(1, 99999.);
if (event->GetT0TOF(2) == 0) event->SetT0TOF(2, 99999.);
- if(!fIsMC){ // data: apply shifts to align around Zero
- event->SetT0TOF(0,event->GetT0TOF(0) - fT0shift[0]);
- event->SetT0TOF(1,event->GetT0TOF(1) - fT0shift[1]);
- event->SetT0TOF(2,event->GetT0TOF(2) - fT0shift[2]);
- } else {
+ if (fT0DetectorAdjust) {
+ if(!fIsMC){ // data: apply shifts to align around Zero
+ event->SetT0TOF(0,event->GetT0TOF(0) - fT0shift[0]);
+ event->SetT0TOF(1,event->GetT0TOF(1) - fT0shift[1]);
+ event->SetT0TOF(2,event->GetT0TOF(2) - fT0shift[2]);
+ } else {
// MC: add smearing for realistic T0A and T0C resolution
- Double_t defResolutionT0A = 33.; // in future we will get this from ESDrun data structure or via OCDB
- Double_t defResolutionT0C = 30.; // for the moment we don't trust them
- if ( (fgT0Aresolution > defResolutionT0A) && (event->GetT0TOF(1)<90000.) ) { // add smearing only if signal is there
- Double_t addedSmearingT0A = TMath::Sqrt(fgT0Aresolution*fgT0Aresolution - defResolutionT0A*defResolutionT0A);
- Double_t smearingT0A = gRandom->Gaus(0.,addedSmearingT0A);
- event->SetT0TOF(1,event->GetT0TOF(1) + smearingT0A);
- }
- if ( (fgT0Cresolution > defResolutionT0C) && (event->GetT0TOF(2)<90000.) ) { // add smearing only if signal is there
+ Double_t defResolutionT0A = 33.; // in future we will get this from ESDrun data structure or via OCDB
+ Double_t defResolutionT0C = 30.; // for the moment we don't trust them
+ if ( (fgT0Aresolution > defResolutionT0A) && (event->GetT0TOF(1)<90000.) ) { // add smearing only if signal is there
+ Double_t addedSmearingT0A = TMath::Sqrt(fgT0Aresolution*fgT0Aresolution - defResolutionT0A*defResolutionT0A);
+ Double_t smearingT0A = gRandom->Gaus(0.,addedSmearingT0A);
+ event->SetT0TOF(1,event->GetT0TOF(1) + smearingT0A);
+ }
+ if ( (fgT0Cresolution > defResolutionT0C) && (event->GetT0TOF(2)<90000.) ) { // add smearing only if signal is there
Double_t addedSmearingT0C = TMath::Sqrt(fgT0Cresolution*fgT0Cresolution - defResolutionT0C*defResolutionT0C);
Double_t smearingT0C = gRandom->Gaus(0.,addedSmearingT0C);
event->SetT0TOF(2,event->GetT0TOF(2) + smearingT0C);
+ }
+ if (event->GetT0TOF(0)<90000.) { // we recompute the AND only if it is already there...
+ Double_t smearedT0AC = (event->GetT0TOF(1)+event->GetT0TOF(2))/2.;
+ event->SetT0TOF(0,smearedT0AC);
+ }
+ if (fDebugLevel > 1) Printf(" TofTender: T0 time (postSmear) %f %f %f",event->GetT0TOF(0),event->GetT0TOF(1),event->GetT0TOF(2));
+ // add finally the timeZero offset also to the T0 detector information
+ event->SetT0TOF(0,event->GetT0TOF(0) + startTime);
+ event->SetT0TOF(1,event->GetT0TOF(1) + startTime);
+ event->SetT0TOF(2,event->GetT0TOF(2) + startTime);
+ if (fDebugLevel > 1) Printf(" TofTender: T0 time (postStart) %f %f %f",event->GetT0TOF(0),event->GetT0TOF(1),event->GetT0TOF(2));
}
- if (event->GetT0TOF(0)<90000.) { // we recompute the AND only if it is already there...
- Double_t smearedT0AC = (event->GetT0TOF(1)+event->GetT0TOF(2))/2.;
- event->SetT0TOF(0,smearedT0AC);
- }
- if (fDebugLevel > 1) Printf(" TofTender: T0 time (postSmear) %f %f %f",event->GetT0TOF(0),event->GetT0TOF(1),event->GetT0TOF(2));
- // add finally the timeZero offset also to the T0 detector information
- event->SetT0TOF(0,event->GetT0TOF(0) + startTime);
- event->SetT0TOF(1,event->GetT0TOF(1) + startTime);
- event->SetT0TOF(2,event->GetT0TOF(2) + startTime);
- if (fDebugLevel > 1) Printf(" TofTender: T0 time (postStart) %f %f %f",event->GetT0TOF(0),event->GetT0TOF(1),event->GetT0TOF(2));
}
// after shifts adjust (data) or smearing+offset (MC) we 'clean' to default if signals not there
if(event->GetT0TOF(0) > 900000) event->SetT0TOF(0, 999999.);
fTOFT0maker->ComputeT0TOF(event);
fTOFT0maker->WriteInESD(event);
- //set preferred startTime
- fESDpid->SetTOFResponse(event, (AliESDpid::EStartTimeType_t)fTimeZeroType);
+ // set preferred startTime: this is now done via AliPIDResponseTask
+ fESDpid->SetTOFResponse(event, (AliESDpid::EStartTimeType_t)fTOFPIDParams->GetStartTimeMethod());
// recalculate PID probabilities
// this is for safety, especially if the user doesn't attach a PID tender after TOF tender
fRecoPass=2;
} else if (fileName.Contains("pass3") ) {
fRecoPass=3;
+ } else if (fileName.Contains("pass4") ) {
+ fRecoPass=4;
+ } else if (fileName.Contains("pass5") ) {
+ fRecoPass=5;
+ } else if (fileName.Contains("pass6") ) {
+ fRecoPass=6;
}
if (fRecoPass == 0) {
AliInfo(Form("From file name %s reco pass cannot be detected",fileName.Data()));
}
return verNo;
}
+
+
+//__________________________________________________________________________
+void AliTOFTenderSupply::LoadTOFPIDParams(Int_t runNumber)
+{
+ //
+ // Load the TOF pid params from the OADB
+ //
+
+ if (fTOFPIDParams) delete fTOFPIDParams;
+ fTOFPIDParams=0x0;
+
+ TFile *oadbf = new TFile("$ALICE_ROOT/OADB/COMMON/PID/data/TOFPIDParams.root");
+ if (oadbf && oadbf->IsOpen()) {
+ AliInfo("Loading TOF Params from $ALICE_ROOT/OADB/COMMON/PID/data/TOFPIDParams.root");
+ AliOADBContainer *oadbc = (AliOADBContainer *)oadbf->Get("TOFoadb");
+ if (oadbc) fTOFPIDParams = dynamic_cast<AliTOFPIDParams *>(oadbc->GetObject(runNumber,"TOFparams"));
+ oadbf->Close();
+ delete oadbc;
+ }
+ delete oadbf;
+
+ if (!fTOFPIDParams) {
+ AliError("TOFPIDParams.root not found in $ALICE_ROOT/OADB/COMMON/PID/data !!");
+ fTOFPIDParams = new AliTOFPIDParams;
+ fTOFPIDParams->SetTOFresolution(90.);
+ fTOFPIDParams->SetStartTimeMethod(AliESDpid::kTOF_T0);
+ }
+}