From ee981ab311a29fc5632642fc765ef6a79acba532 Mon Sep 17 00:00:00 2001 From: wiechula Date: Wed, 19 Jan 2011 11:48:45 +0000 Subject: [PATCH] Update of TPC and TOF tender supplies --- ANALYSIS/CMakelibTENDERSupplies.pkg | 4 +- ANALYSIS/PROOF-INF.TENDERSupplies/SETUP.C | 6 +- ANALYSIS/TenderSupplies/AddTaskTender.C | 7 +- .../TenderSupplies/AliTOFTenderSupply.cxx | 351 +++++++++++------- ANALYSIS/TenderSupplies/AliTOFTenderSupply.h | 112 +++--- .../TenderSupplies/AliTPCTenderSupply.cxx | 277 ++++++++++++-- ANALYSIS/TenderSupplies/AliTPCTenderSupply.h | 5 + 7 files changed, 526 insertions(+), 236 deletions(-) diff --git a/ANALYSIS/CMakelibTENDERSupplies.pkg b/ANALYSIS/CMakelibTENDERSupplies.pkg index d2537ab7c3c..a41a6d89af7 100644 --- a/ANALYSIS/CMakelibTENDERSupplies.pkg +++ b/ANALYSIS/CMakelibTENDERSupplies.pkg @@ -31,10 +31,10 @@ string ( REPLACE ".cxx" ".h" HDRS "${SRCS}") set ( DHDR TenderSuppliesLinkDef.h) -set ( EINCLUDE ANALYSIS ANALYSIS/Tender STEER TOF TRD/Cal VZERO ANALYSIS/TenderSupplies) +set ( EINCLUDE ANALYSIS ANALYSIS/Tender STEER TOF TRD/Cal VZERO ANALYSIS/TenderSupplies TPC T0) if( ALICE_TARGET STREQUAL "win32gcc") - set ( PACKSOFLAGS ${SOFLAGS} -L${ALICE_ROOT}/lib/tgt_${ALICE_TARGET} -lSTEERBase -lSTEER -lANALYSIS -lCDB) + set ( PACKSOFLAGS ${SOFLAGS} -L${ALICE_ROOT}/lib/tgt_${ALICE_TARGET} -lSTEERBase -lSTEER -lANALYSIS -lCDB -lT0base -lT0rec -lTPCbase) endif( ALICE_TARGET STREQUAL "win32gcc") diff --git a/ANALYSIS/PROOF-INF.TENDERSupplies/SETUP.C b/ANALYSIS/PROOF-INF.TENDERSupplies/SETUP.C index 1597d04731f..222366c1c16 100644 --- a/ANALYSIS/PROOF-INF.TENDERSupplies/SETUP.C +++ b/ANALYSIS/PROOF-INF.TENDERSupplies/SETUP.C @@ -9,6 +9,8 @@ void SETUP() CheckLoadLibrary("libGeom"); CheckLoadLibrary("libVMC"); CheckLoadLibrary("libMinuit"); + CheckLoadLibrary("libGui"); + CheckLoadLibrary("libXMLParser"); // Load the AliROOT library CheckLoadLibrary("libANALYSIS"); @@ -16,11 +18,13 @@ void SETUP() CheckLoadLibrary("libESD"); CheckLoadLibrary("libCDB"); CheckLoadLibrary("libTENDER"); - //Load libs needed for TOFbase + //Load libs needed for TOF CheckLoadLibrary("libProof"); CheckLoadLibrary("libRAWDatabase"); CheckLoadLibrary("libSTEER"); CheckLoadLibrary("libTOFbase"); + CheckLoadLibrary("libT0base"); + CheckLoadLibrary("libT0rec"); CheckLoadLibrary("libTENDERSupplies"); diff --git a/ANALYSIS/TenderSupplies/AddTaskTender.C b/ANALYSIS/TenderSupplies/AddTaskTender.C index 90a181785f0..ea0b4c9bf5b 100644 --- a/ANALYSIS/TenderSupplies/AddTaskTender.C +++ b/ANALYSIS/TenderSupplies/AddTaskTender.C @@ -34,12 +34,13 @@ AliAnalysisTask *AddTaskTender(Bool_t useV0=kFALSE){ //========= Attach TPC supply ====== AliTPCTenderSupply *tpcSupply=new AliTPCTenderSupply("TPCtender"); tpcSupply->SetDebugLevel(2); - tpcSupply->SetMip(50.); + //tpcSupply->SetMip(50.); tender->AddSupply(tpcSupply); //========= Attach TOF supply ====== - AliTOFTenderSupply *TOFtender = new AliTOFTenderSupply("TOFtender"); - tender->AddSupply(TOFtender); + AliTOFTenderSupply *tofTender = new AliTOFTenderSupply("TOFtender"); + tofTender->SetTimeZeroType(AliESDpid::kTOF_T0); + tender->AddSupply(tofTender); //========= Attach TRD supply ====== AliTRDTenderSupply *trdSupply=new AliTRDTenderSupply("TRDtender"); diff --git a/ANALYSIS/TenderSupplies/AliTOFTenderSupply.cxx b/ANALYSIS/TenderSupplies/AliTOFTenderSupply.cxx index 477c9045058..d2de04aeda1 100644 --- a/ANALYSIS/TenderSupplies/AliTOFTenderSupply.cxx +++ b/ANALYSIS/TenderSupplies/AliTOFTenderSupply.cxx @@ -1,141 +1,210 @@ -/************************************************************************** - * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * - * * - * Author: The ALICE Off-line Project. * - * Contributors are mentioned in the code where appropriate. * - * * - * Permission to use, copy, modify and distribute this software and its * - * documentation strictly for non-commercial purposes is hereby granted * - * without fee, provided that the above copyright notice appears in all * - * copies and that both the copyright notice and this permission notice * - * appear in the supporting documentation. The authors make no claims * - * about the suitability of this software for any purpose. It is * - * provided "as is" without express or implied warranty. * - **************************************************************************/ - - -/////////////////////////////////////////////////////////////////////////////// -// // -// TOF tender: reapply TOF pid on the fly // -// // -/////////////////////////////////////////////////////////////////////////////// -#include -#include -#include -#include -#include -#include - -#include "AliTOFcalib.h" -#include "AliTOFT0maker.h" - -#include "AliTOFTenderSupply.h" - - -AliTOFTenderSupply::AliTOFTenderSupply() : - AliTenderSupply(), - fESDpid(0x0), - fIsMC(kFALSE), - fTOFCalib(0x0), - fTOFT0maker(0x0), - fTOFres(100.) -{ - // - // default ctor - // -} - -//_____________________________________________________ -AliTOFTenderSupply::AliTOFTenderSupply(const char *name, const AliTender *tender) : - AliTenderSupply(name,tender), - fESDpid(0x0), - fIsMC(kFALSE), - fTOFCalib(0x0), - fTOFT0maker(0x0), - fTOFres(100.) -{ - // - // named ctor - // -} - -//_____________________________________________________ -void AliTOFTenderSupply::Init() -{ - // - // Initialise TOF tender - // - - - // - // Setup PID object - // - - // Check if another detector already created the esd pid object - // if not we create it and set it to the ESD input handler - fESDpid=fTender->GetESDhandler()->GetESDpid(); - if (!fESDpid) { - fESDpid=new AliESDpid; - fTender->GetESDhandler()->SetESDpid(fESDpid); - } - - //Set proper resolution in case of MC - AliAnalysisManager *mgr=AliAnalysisManager::GetAnalysisManager(); - if (mgr->GetMCtruthEventHandler()) fIsMC=kTRUE; - - - // - // Create TOF calibration classes - // - if (!fTOFCalib){ - fTOFCalib=new AliTOFcalib(); - fTOFCalib->SetCorrectTExp(kTRUE); // apply a fine tuning on the expected times at low momenta - if(fIsMC) fTOFCalib->SetCalibrateTOFsignal(kFALSE); // no new calibration -// fTOFCalib->Init(); - } - if (!fTOFT0maker) { - fTOFT0maker = new AliTOFT0maker(fESDpid,fTOFCalib); - fTOFT0maker->SetTimeResolution(fTOFres); // set TOF resolution for the PID - } -} - -//_____________________________________________________ -void AliTOFTenderSupply::ProcessEvent() -{ - // - // Reapply pid information - // - - //no corrections for MC - AliAnalysisManager *mgr=AliAnalysisManager::GetAnalysisManager(); - if (mgr->GetMCtruthEventHandler()) return; - - AliESDEvent *event=fTender->GetEvent(); - if (!event) return; - - //recalculate TOF signal - if (fTender->RunChanged()){ - fTOFCalib->Init(fTender->GetRun()); - } - fTOFCalib->CalibrateESD(event); - - if(fIsMC) fTOFT0maker->TuneForMC(event); - - //Calculate event time zero - fTOFT0maker->ComputeT0TOF(event); - fTOFT0maker->ApplyT0TOF(event); - - event->SetT0(0.0); - - // - // recalculate PID probabilities - // - - Int_t ntracks=event->GetNumberOfTracks(); - for(Int_t itrack = 0; itrack < ntracks; itrack++){ - fESDpid->MakeTOFPID(event->GetTrack(itrack),0); - } - -} - - +/************************************************************************** + * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * * + * Author: The ALICE Off-line Project. * + * Contributors are mentioned in the code where appropriate. * + * * + * Permission to use, copy, modify and distribute this software and its * + * documentation strictly for non-commercial purposes is hereby granted * + * without fee, provided that the above copyright notice appears in all * + * copies and that both the copyright notice and this permission notice * + * appear in the supporting documentation. The authors make no claims * + * about the suitability of this software for any purpose. It is * + * provided "as is" without express or implied warranty. * + **************************************************************************/ + + +/////////////////////////////////////////////////////////////////////////////// +// // +// TOF tender: reapply TOF pid on the fly // +// // +/////////////////////////////////////////////////////////////////////////////// +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + +#include "AliTOFTenderSupply.h" + +AliTOFTenderSupply::AliTOFTenderSupply() : + AliTenderSupply(), + fESDpid(0x0), + fIsMC(kFALSE), + fApplyT0(kFALSE), + fTimeZeroType(3), + fCorrectExpTimes(kTRUE), + fTOFCalib(0x0), + fTOFT0maker(0x0), + fTOFres(100.) + + +{ + // + // default ctor + // + + fT0shift[0] = 0; + fT0shift[1] = 0; + fT0shift[2] = 0; + fT0shift[3] = 0; +} + +//_____________________________________________________ +AliTOFTenderSupply::AliTOFTenderSupply(const char *name, const AliTender *tender) : + AliTenderSupply(name,tender), + fESDpid(0x0), + fIsMC(kFALSE), + fApplyT0(kFALSE), + fTimeZeroType(3), + fCorrectExpTimes(kTRUE), + fTOFCalib(0x0), + fTOFT0maker(0x0), + fTOFres(100.) + +{ + // + // named ctor + // + + fT0shift[0] = 0; + fT0shift[1] = 0; + fT0shift[2] = 0; + fT0shift[3] = 0; +} + +//_____________________________________________________ +void AliTOFTenderSupply::Init() +{ + // + // Initialise TOF tender + // + + + // + // Setup PID object + // + + // Check if another detector already created the esd pid object + // if not we create it and set it to the ESD input handler + fESDpid=fTender->GetESDhandler()->GetESDpid(); + if (!fESDpid) { + fESDpid=new AliESDpid; + fTender->GetESDhandler()->SetESDpid(fESDpid); + } + + //Set proper resolution in case of MC + AliAnalysisManager *mgr=AliAnalysisManager::GetAnalysisManager(); + if (mgr->GetMCtruthEventHandler()) fIsMC=kTRUE; + + + // + // Create TOF calibration classes + // + if (!fTOFCalib){ + fTOFCalib=new AliTOFcalib(); + fTOFCalib->SetCorrectTExp(fCorrectExpTimes); // apply a fine tuning on the expected times at low momenta + if(fIsMC) fTOFCalib->SetCalibrateTOFsignal(kFALSE); // no new calibration +// fTOFCalib->Init(); + } + if (!fTOFT0maker) { + fTOFT0maker = new AliTOFT0maker(fESDpid,fTOFCalib); + fTOFT0maker->SetTimeResolution(fTOFres); // set TOF resolution for the PID + printf("tof time res = %f\n",fTOFres); + } +} + +//_____________________________________________________ +void AliTOFTenderSupply::ProcessEvent() +{ + // + // Reapply pid information + // + + //no corrections for MC + AliAnalysisManager *mgr=AliAnalysisManager::GetAnalysisManager(); + if (mgr->GetMCtruthEventHandler()) return; + + AliESDEvent *event=fTender->GetEvent(); + if (!event) return; + + //recalculate TOF signal + if (fTender->RunChanged()){ + fTOFCalib->Init(fTender->GetRun()); + + if(event->GetT0TOF()){ // read T0 detector correction from OCDB + // OCDB instance + 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]; + fT0shift[1] = t0means[1]; + fT0shift[2] = t0means[2]; + fT0shift[3] = t0means[3]; + } + } + } + fTOFCalib->CalibrateESD(event); + + if(fIsMC){ + Float_t t0true = fTOFT0maker->TuneForMC(event); + + if(event->GetT0TOF()){// add the t0 smearing also to the T0 detector information + event->SetT0TOF(0,event->GetT0TOF(0) + t0true); + event->SetT0TOF(1,event->GetT0TOF(1) + t0true); + event->SetT0TOF(2,event->GetT0TOF(2) + t0true); + } + } + + if(event->GetT0TOF()){ // write the T0 detector corrected times + if(event->GetT0TOF(0) == 0) event->SetT0TOF(0, 9999999.); + if(event->GetT0TOF(1) == 0) event->SetT0TOF(1, 99999.); + if(event->GetT0TOF(2) == 0) event->SetT0TOF(2, 99999.); + + event->SetT0TOF(0,event->GetT0TOF(0) - fT0shift[0]); + event->SetT0TOF(1,event->GetT0TOF(1) - fT0shift[1]); + event->SetT0TOF(2,event->GetT0TOF(2) - fT0shift[2]); + + if(event->GetT0TOF(0) > 9000000) event->SetT0TOF(0, 9999999.); + if(event->GetT0TOF(1) > 90000) event->SetT0TOF(1, 99999.); + if(event->GetT0TOF(2) > 90000) event->SetT0TOF(2, 99999.); + } + + //Calculate event time zero + fTOFT0maker->ComputeT0TOF(event); + fTOFT0maker->WriteInESD(event); + + // subtract the T0-TOF information to the TOF times + if(fApplyT0){ + fTOFT0maker->ApplyT0TOF(event); + event->SetT0(0.0); + } + + // + // recalculate PID probabilities + // + + fESDpid->SetTOFResponse(event, (AliESDpid::EStartTimeType_t)fTimeZeroType); + + Int_t ntracks=event->GetNumberOfTracks(); + for(Int_t itrack = 0; itrack < ntracks; itrack++){ + fESDpid->MakeTOFPID(event->GetTrack(itrack),0); + } + + +} + + + diff --git a/ANALYSIS/TenderSupplies/AliTOFTenderSupply.h b/ANALYSIS/TenderSupplies/AliTOFTenderSupply.h index a5126575d11..0fb1f17f9d6 100644 --- a/ANALYSIS/TenderSupplies/AliTOFTenderSupply.h +++ b/ANALYSIS/TenderSupplies/AliTOFTenderSupply.h @@ -1,51 +1,61 @@ -#ifndef ALITOFTENDERSUPPLY_H -#define ALITOFTENDERSUPPLY_H - -/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * - * See cxx source for full Copyright notice */ - -//////////////////////////////////////////////////////////////////////// -// // -// TPC tender, reapply pid on the fly // -// // -//////////////////////////////////////////////////////////////////////// - -#include - -class AliESDpid; -class AliTOFcalib; -class AliTOFT0maker; - -class AliTOFTenderSupply: public AliTenderSupply { - -public: - AliTOFTenderSupply(); - AliTOFTenderSupply(const char *name, const AliTender *tender=NULL); - - virtual ~AliTOFTenderSupply(){;} - - virtual void Init(); - virtual void ProcessEvent(); - - // TOF method - void SetTOFres(Float_t res){fTOFres=res;} - -private: - AliESDpid *fESDpid; //! ESD pid object - - Bool_t fIsMC; - - // variables for TOF calibrations - AliTOFcalib *fTOFCalib; //! recalibrate TOF signal with OCDB - AliTOFT0maker *fTOFT0maker; //! TOF maker objects (apply all the correction for T0) - - Float_t fTOFres; // TOF resolution - - AliTOFTenderSupply(const AliTOFTenderSupply&c); - AliTOFTenderSupply& operator= (const AliTOFTenderSupply&c); - - ClassDef(AliTOFTenderSupply, 1); -}; - - -#endif +#ifndef ALITOFTENDERSUPPLY_H +#define ALITOFTENDERSUPPLY_H + +/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * + * See cxx source for full Copyright notice */ + +//////////////////////////////////////////////////////////////////////// +// // +// TPC tender, reapply pid on the fly // +// // +//////////////////////////////////////////////////////////////////////// + +#include +#include "AliESDpid.h" + +class AliESDpid; +class AliTOFcalib; +class AliTOFT0maker; + +class AliTOFTenderSupply: public AliTenderSupply { + +public: + AliTOFTenderSupply(); + AliTOFTenderSupply(const char *name, const AliTender *tender=NULL); + + virtual ~AliTOFTenderSupply(){;} + + virtual void Init(); + virtual void ProcessEvent(); + + // TOF method + void SetTOFres(Float_t res){fTOFres=res;} + void SetApplyT0(Bool_t flag=kTRUE){fApplyT0=flag;}; + void SetCorrectExpTimes(Bool_t flag=kTRUE){fCorrectExpTimes=flag;}; + + virtual void SetTimeZeroType(AliESDpid::EStartTimeType_t tofTimeZeroType) {fTimeZeroType = tofTimeZeroType;} + +private: + AliESDpid *fESDpid; //! ESD pid object + + Bool_t fIsMC; // flag for MC data + Bool_t fApplyT0; // flag to subtract the T0-TOF (deprecated) + Int_t fTimeZeroType; // flag to discriminate the time zero type + Bool_t fCorrectExpTimes; // flag to apply Expected Time correction + + // variables for TOF calibrations + AliTOFcalib *fTOFCalib; //! recalibrate TOF signal with OCDB + AliTOFT0maker *fTOFT0maker; //! TOF maker objects (apply all the correction for T0) + + Float_t fTOFres; // TOF resolution + Float_t fT0shift[4]; // T0 detector correction from OCDB + + AliTOFTenderSupply(const AliTOFTenderSupply&c); + AliTOFTenderSupply& operator= (const AliTOFTenderSupply&c); + + ClassDef(AliTOFTenderSupply, 2); +}; + + +#endif + diff --git a/ANALYSIS/TenderSupplies/AliTPCTenderSupply.cxx b/ANALYSIS/TenderSupplies/AliTPCTenderSupply.cxx index cd38f0c128c..c838be2af53 100644 --- a/ANALYSIS/TenderSupplies/AliTPCTenderSupply.cxx +++ b/ANALYSIS/TenderSupplies/AliTPCTenderSupply.cxx @@ -21,8 +21,12 @@ /////////////////////////////////////////////////////////////////////////////// #include +#include #include #include +#include +#include +#include #include #include @@ -38,20 +42,23 @@ #include #include #include +#include +#include #include "AliTPCTenderSupply.h" AliTPCTenderSupply::AliTPCTenderSupply() : - AliTenderSupply(), - fESDpid(0x0), - fGainNew(0x0), - fGainOld(0x0), - fGainCorrection(kTRUE), - fPcorrection(kFALSE), - fDebugLevel(0), - fMip(50), - fGRP(0x0) +AliTenderSupply(), +fESDpid(0x0), +fGainNew(0x0), +fGainOld(0x0), +fGainCorrection(kTRUE), +fPcorrection(kFALSE), +fArrPidResponseMaster(0x0), +fDebugLevel(0), +fMip(50), +fGRP(0x0) { // // default ctor @@ -60,15 +67,16 @@ AliTPCTenderSupply::AliTPCTenderSupply() : //_____________________________________________________ AliTPCTenderSupply::AliTPCTenderSupply(const char *name, const AliTender *tender) : - AliTenderSupply(name,tender), - fESDpid(0x0), - fGainNew(0x0), - fGainOld(0x0), - fGainCorrection(kTRUE), - fPcorrection(kFALSE), - fDebugLevel(0), - fMip(50), - fGRP(0x0) +AliTenderSupply(name,tender), +fESDpid(0x0), +fGainNew(0x0), +fGainOld(0x0), +fGainCorrection(kTRUE), +fPcorrection(kFALSE), +fArrPidResponseMaster(0x0), +fDebugLevel(0), +fMip(50), +fGRP(0x0) { // // named ctor @@ -82,6 +90,7 @@ void AliTPCTenderSupply::Init() // Initialise TPC tender // + AliLog::SetClassDebugLevel("AliTPCTenderSupply",10); AliAnalysisManager *mgr=AliAnalysisManager::GetAnalysisManager(); // // Setup PID object @@ -118,20 +127,20 @@ void AliTPCTenderSupply::Init() alephParameters[3] = 2.12543e+00; alephParameters[4] = 4.88663e+00; //temporary solution - fESDpid->GetTPCResponse().SetMip(fMip); - if (fDebugLevel>0) printf("AliTPCTenderSupply::Init - Use Data parametrisation, Mip set to: %.3f\n",fMip); + //fESDpid->GetTPCResponse().SetMip(fMip); + if (fDebugLevel>0) AliInfo(Form("Use Data parametrisation, Mip set to: %.3f\n",fMip)); //fESDpid->GetTPCResponse().SetMip(49.2); } else { //force no gain and P correction in MC fGainCorrection=kFALSE; fPcorrection=kFALSE; - if (fDebugLevel>0) printf("AliTPCTenderSupply::Init - Use MC parametrisation\n"); + if (fDebugLevel>0) AliInfo("Use MC parametrisation\n"); } fESDpid->GetTPCResponse().SetBetheBlochParameters( alephParameters[0],alephParameters[1],alephParameters[2], alephParameters[3],alephParameters[4]); - + //set detector resolution parametrisation fESDpid->GetTPCResponse().SetSigma(3.79301e-03, 2.21280e+04); } @@ -142,20 +151,22 @@ void AliTPCTenderSupply::ProcessEvent() // // Reapply pid information // - + AliESDEvent *event=fTender->GetEvent(); if (!event) return; //load gain correction if run has changed if (fTender->RunChanged()){ - if (fDebugLevel>0) printf("AliTPCTenderSupply::ProcessEvent - Run Changed (%d)\n",fTender->GetRun()); + if (fDebugLevel>0) AliInfo(Form("Run Changed (%d)\n",fTender->GetRun())); + SetParametrisation(); if (fGainCorrection) SetSplines(); } // // get gain correction factor // - Double_t corrFactor = GetGainCorrection(); + Double_t corrFactor = 1; + if (fGainCorrection) corrFactor=GetGainCorrection(); // // - correct TPC signals @@ -177,9 +188,9 @@ void AliTPCTenderSupply::SetSplines() // // Get Gain splines from OCDB // - + AliInfo("Update Gain splines"); - + // // Get GPR info for pressure correction // @@ -191,7 +202,7 @@ void AliTPCTenderSupply::SetSplines() } else { fGRP = (AliGRPObject*)entryGRP->GetObject(); } - if (fDebugLevel>1) printf("AliTPCTenderSupply::SetSplines - Used GRP entry: %s\n",entryGRP->GetId().ToString().Data()); + if (fDebugLevel>1) AliInfo(Form("GRP entry used: %s\n",entryGRP->GetId().ToString().Data())); fGainNew=0x0; fGainOld=0x0; @@ -209,14 +220,14 @@ void AliTPCTenderSupply::SetSplines() AliError("No UserInfo found in tree"); return; } - + TList *cdbList=(TList*)userInfo->FindObject("cdbList"); if (!cdbList) { AliError("No cdbList found in UserInfo"); if (AliLog::GetGlobalLogLevel()>=AliLog::kError) userInfo->Print(); return; } - + TIter nextCDB(cdbList); TObjString *os=0x0; while ( (os=(TObjString*)nextCDB()) ){ @@ -229,7 +240,7 @@ void AliTPCTenderSupply::SetSplines() return; } - if (fDebugLevel>1) printf("AliTPCTenderSupply::SetSplines - Used old Gain entry: %s\n",entry->GetId().ToString().Data()); + if (fDebugLevel>1) AliInfo(Form("Used old Gain entry: %s\n",entry->GetId().ToString().Data())); TObjArray *arr=(TObjArray *)entry->GetObject(); if (!arr) { @@ -247,7 +258,7 @@ void AliTPCTenderSupply::SetSplines() delete id; break; } - + // //new gain correction // @@ -256,10 +267,10 @@ void AliTPCTenderSupply::SetSplines() AliError("No new gain calibration entry found"); return; } - if (fDebugLevel>1) printf("AliTPCTenderSupply::SetSplines - Used new Gain entry: %s\n",entryNew->GetId().ToString().Data()); + if (fDebugLevel>1) AliInfo(Form("Used new Gain entry: %s\n",entryNew->GetId().ToString().Data())); if (entryNew->GetId().GetLastRun()==AliCDBRunRange::Infinity()){ - if (fDebugLevel>0) printf("AliTPCTenderSupply::SetSplines - Use P correction\n"); + if (fDebugLevel>0) AliInfo("Use P correction\n"); fPcorrection=kTRUE; } @@ -282,19 +293,209 @@ Double_t AliTPCTenderSupply::GetGainCorrection() // AliESDEvent *event=fTender->GetEvent(); UInt_t time=event->GetTimeStamp(); + + Double_t gain=1; - Double_t gain = 1.; - if (!fGainOld) return gain; - if (fGainNew) gain = fGainOld->Eval(time)/fGainNew->Eval(time); + + if (fGainOld){ + //TODO TODO TODO + //first correction for the eval + // needs to be removed when the fix is in AliROOT and + // the production was done with EvalGraphConst + //TODO TODO TODO + if (fTender->GetRun()<=138154||fTender->GetRun()==138197){ + Double_t valDefault = fGainOld->Eval(time); + Double_t valConst = AliTPCcalibDButil::EvalGraphConst(fGainOld, time); + gain = valDefault/valConst; + } + if (fGainNew){ + gain *= AliTPCcalibDButil::EvalGraphConst(fGainOld,time)/AliTPCcalibDButil::EvalGraphConst(fGainNew,time); + } + } //If there is only the default calibration, at least apply correction for pressure if (fPcorrection){ if (fGRP) { Double_t pressure=fGRP->GetCavernAtmosPressure()->GetValue(time); - gain=fGainOld->Eval(time)/(7.03814-0.00459798*pressure)/49.53*fMip; +// gain=fGainOld->Eval(time)/(7.03814-0.00459798*pressure)/49.53*fMip; +// gain=fGainOld->Eval(time)/(7.03814-0.00459798*pressure)/51.51*fMip; + gain=AliTPCcalibDButil::EvalGraphConst(fGainOld,time)/(7.03814-0.00459798*pressure)/51.51*fMip; } } return gain; } +//_____________________________________________________ +void AliTPCTenderSupply::SetParametrisation() +{ + // + // Change BB parametrisation for current run + // + + //Get CDB Entry with pid response parametrisations + AliCDBEntry *pidCDB=fTender->GetCDBManager()->Get("TPC/Calib/PidResponse",fTender->GetRun()); + if (pidCDB){ + fArrPidResponseMaster=(TObjArray*)pidCDB->GetObject(); + } + + //Get the current file to check the reconstruction pass (UGLY, but not stored in ESD... ) + TFile *file=((TChain*)fTender->GetInputData(0))->GetCurrentFile(); + if (!file) { + AliError("File not found, not changing parametrisation"); + return; + } + + Int_t run=fTender->GetRun(); + AliAnalysisManager *mgr=AliAnalysisManager::GetAnalysisManager(); + Double_t alephParameters[5]={0,0,0,0,0}; + + //find the period by run number (UGLY, but not stored in ESD... ) + TString period; + if (run>=114737&&run<=117223) period="LHC10B"; + else if (run>=118503&&run<=121040) period="LHC10C"; + else if (run>=122195&&run<=126437) period="LHC10D"; + else if (run>=127719&&run<=130850) period="LHC10E"; + else if (run>=133004&&run<=135029) period="LHC10F"; + else if (run>=135654&&run<=136377) period="LHC10G"; + else if (run>=136851&&run<=139517) period="LHC10H"; + else if (run>=139699) period="LHC11A"; + + //find pass from file name (UGLY, but not stored in ESD... ) + TString fileName(file->GetName()); + Int_t pass=0; + if (fileName.Contains("/pass1")) { + pass=1; + } else if (fileName.Contains("/pass2")) { + pass=2; + } + + //beam type + TString beamtype=fTender->GetEvent()->GetBeamType(); + if (beamtype.IsNull()||beamtype.Contains("No Beam")) beamtype="p-p"; + beamtype.ToUpper(); + beamtype.ReplaceAll("-",""); + + // + // Set default parametrisations for data and MC + // + Bool_t isMC=mgr->GetMCtruthEventHandler(); + if (isMC){ + //MC data + alephParameters[0] = 2.15898e+00/50.; + alephParameters[1] = 1.75295e+01; + alephParameters[2] = 3.40030e-09; + alephParameters[3] = 1.96178e+00; + alephParameters[4] = 3.91720e+00; + + } else { + //data parametrisation + + + //use defaut data parametrisation in case no other will be selected + alephParameters[0] = 0.0283086/0.97; + alephParameters[1] = 2.63394e+01; + alephParameters[2] = 5.04114e-11; + alephParameters[3] = 2.12543e+00; + alephParameters[4] = 4.88663e+00; + + fESDpid->GetTPCResponse().SetSigma(3.79301e-03, 2.21280e+04); + + if (pass==1){ + + } else if (pass==2){ + //find period + if (run>=114737&&run<=117223){ + //LHC10b + } else if (run>=118503&&run<=121040) { + //LHC10c + } else if (run>=122195){ + //LHC10d + + // last run in LHC10d: &&run<126437 + alephParameters[0] = 1.63246/50.; + alephParameters[1] = 2.20028e+01; + alephParameters[2] = TMath::Exp(-2.48879e+01); + alephParameters[3] = 2.39804e+00; + alephParameters[4] = 5.12090e+00; + + // + fESDpid->GetTPCResponse().SetSigma(2.30176e-02, 5.60422e+02); + } + } + + if ( beamtype == "PBPB" ){ + AliInfo("BETHE-BLOCH parametrization for PbPb !!!!!!!!!!!!!!!!!!!!!!\n"); + + alephParameters[0] = 1.25202/50.; //was 1.79571/55.; + alephParameters[1] = 2.74992e+01; //was 22.0028; + alephParameters[2] = TMath::Exp(-3.31517e+01); //was1.55354e-11; + alephParameters[3] = 2.46246; //was 2.39804; + alephParameters[4] = 6.78938; //was 5.1209; + } + } + + fESDpid->GetTPCResponse().SetBetheBlochParameters( + alephParameters[0],alephParameters[1],alephParameters[2], + alephParameters[3],alephParameters[4]); + + //data type + TString datatype="DATA"; + //in case of mc pass is per default 1 + if (isMC) { + datatype="MC"; + pass=1; + } + + // + //set the new parametrisation + // + + if (fArrPidResponseMaster){ + TObject *grAll=0x0; + //for MC don't use period information + if (isMC) period="[A-Z0-9]*"; + //pattern for the default entry (valid for all particles) + TPRegexp reg(Form("TSPLINE3_%s_([A-Z]*)_%s_PASS%d_%s_MEAN",datatype.Data(),period.Data(),pass,beamtype.Data())); + + //loop over entries and filter them + for (Int_t iresp=0; irespGetEntriesFast();++iresp){ + TObject *responseFunction=fArrPidResponseMaster->At(iresp); + TString responseName=responseFunction->GetName(); + + if (!reg.MatchB(responseName)) continue; + + TObjArray *arr=reg.MatchS(responseName); + TString particleName=arr->At(1)->GetName(); + delete arr; + if (particleName.IsNull()) continue; + if (particleName=="ALL") grAll=responseFunction; + else { + //find particle id + for (Int_t ispec=0; ispec(fESDpid->GetTPCResponse().GetResponseFunction((AliPID::EParticleType)ispec)); + if (old) delete old; + fESDpid->GetTPCResponse().SetResponseFunction((AliPID::EParticleType)ispec,responseFunction); + fESDpid->GetTPCResponse().SetUseDatabase(kTRUE); + AliInfo(Form("Adding graph: %d - %s\n",ispec,responseFunction->GetName())); + break; + } + } + } + } + + //set default response function to all particles which don't have a specific one + if (grAll){ + for (Int_t ispec=0; ispecGetTPCResponse().GetResponseFunction((AliPID::EParticleType)ispec)){ + fESDpid->GetTPCResponse().SetResponseFunction((AliPID::EParticleType)ispec,grAll); + AliInfo(Form("Adding graph: %d - %s\n",ispec,grAll->GetName())); + } + } + } + } +} + diff --git a/ANALYSIS/TenderSupplies/AliTPCTenderSupply.h b/ANALYSIS/TenderSupplies/AliTPCTenderSupply.h index 7d602923a52..5f4f99c111d 100644 --- a/ANALYSIS/TenderSupplies/AliTPCTenderSupply.h +++ b/ANALYSIS/TenderSupplies/AliTPCTenderSupply.h @@ -14,6 +14,7 @@ #include +class TObjArray; class AliESDpid; class AliSplineFit; class AliGRPObject; @@ -29,6 +30,7 @@ public: void SetGainCorrection(Bool_t gainCorr) {fGainCorrection=gainCorr;} void SetDebugLevel(Int_t level) {fDebugLevel=level;} void SetMip(Double_t mip) {fMip=mip;} + void SetResponseFunctions(TObjArray *arr) {fArrPidResponseMaster=arr;} virtual void Init(); virtual void ProcessEvent(); @@ -40,6 +42,7 @@ private: Bool_t fGainCorrection; //Perform gain correction Bool_t fPcorrection; //!Perform pressure correction + TObjArray *fArrPidResponseMaster; //array with gain curves Int_t fDebugLevel; //debug level Double_t fMip; //mip position @@ -49,6 +52,8 @@ private: void SetSplines(); Double_t GetGainCorrection(); + void SetParametrisation(); + AliTPCTenderSupply(const AliTPCTenderSupply&c); AliTPCTenderSupply& operator= (const AliTPCTenderSupply&c); -- 2.43.0