* provided "as is" without express or implied warranty. *
**************************************************************************/
-/*$Log$
+/*
+$Log$
+Revision 1.10 2006/08/22 13:30:49 arcelli
+removal of effective c++ warnings (C.Zampolli)
+
+Revision 1.9 2006/04/20 22:30:50 hristov
+Coding conventions (Annalisa)
+
+Revision 1.8 2006/04/16 22:29:05 hristov
+Coding conventions (Annalisa)
+
+Revision 1.7 2006/04/16 20:12:46 hristov
+Removing memory leak in case of cached CDB entries
+
+Revision 1.6 2006/04/11 15:28:32 hristov
+Checks on cache status before deleting calibration objects (A.Colla)
+
+Revision 1.5 2006/04/05 08:35:38 hristov
+Coding conventions (S.Arcelli, C.Zampolli)
+
+Revision 1.4 2006/03/31 11:26:46 arcelli
+ changing CDB Ids according to standard convention
+
+Revision 1.3 2006/03/28 14:57:02 arcelli
+updates to handle new V5 geometry & some re-arrangements
+
+Revision 1.2 2006/02/13 17:22:26 arcelli
+just Fixing Log info
+
+Revision 1.1 2006/02/13 16:10:48 arcelli
+Add classes for TOF Calibration (C.Zampolli)
+
author: Chiara Zampolli, zampolli@bo.infn.it
- */
+*/
///////////////////////////////////////////////////////////////////////////////
// //
// //
///////////////////////////////////////////////////////////////////////////////
-#include "AliTOFcalib.h"
-#include "AliRun.h"
-#include <TTask.h>
-#include <TFile.h>
-#include <TROOT.h>
-#include <TSystem.h>
-#include "AliTOF.h"
-#include "AliTOFcalibESD.h"
-#include "AliESD.h"
-#include <TObject.h>
#include "TF1.h"
+#include "TFile.h"
#include "TH1F.h"
#include "TH2F.h"
-#include "AliESDtrack.h"
-#include "AliTOFChannel.h"
-#include "AliTOFChSim.h"
-#include "AliTOFGeometry.h"
-#include "AliTOFdigit.h"
-#include "TClonesArray.h"
-#include "AliTOFCal.h"
-#include "TRandom.h"
-#include "AliTOFcluster.h"
#include "TList.h"
+#include "TROOT.h"
+#include "TStyle.h"
+
+#include "AliCDBEntry.h"
+#include "AliCDBId.h"
#include "AliCDBManager.h"
#include "AliCDBMetaData.h"
-#include "AliCDBStorage.h"
-#include "AliCDBId.h"
-#include "AliCDBEntry.h"
+#include "AliESDtrack.h"
+#include "AliESD.h"
+#include "AliLog.h"
+
+#include "AliTOFCal.h"
+#include "AliTOFcalibESD.h"
+#include "AliTOFcalib.h"
+#include "AliTOFChannel.h"
+#include "AliTOFGeometryV5.h"
+#include "AliTOFGeometry.h"
extern TROOT *gROOT;
extern TStyle *gStyle;
ClassImp(AliTOFcalib)
const Int_t AliTOFcalib::fgkchannel = 5000;
-const Char_t* AliTOFcalib::ffile[6]={"$ALICE_ROOT/TOF/Spectra/spectrum0_1.root","$ALICE_ROOT/TOF/Spectra/spectrum0_2.root","$ALICE_ROOT/TOF/Spectra/spectrum1_1.root","$ALICE_ROOT/TOF/Spectra/spectrum1_2.root","$ALICE_ROOT/TOF/Spectra/spectrum2_1.root","$ALICE_ROOT/TOF/Spectra/spectrum2_2.root"};
//_______________________________________________________________________
-AliTOFcalib::AliTOFcalib():TTask("AliTOFcalib",""){
- fNSector = 0;
- fNPlate = 0;
- fNStripA = 0;
- fNStripB = 0;
- fNStripC = 0;
- fNpadZ = 0;
- fNpadX = 0;
- fsize = 0;
+AliTOFcalib::AliTOFcalib():
+ TTask("AliTOFcalib",""),
+ fNChannels(-1),
+ fNSector(-1),
+ fNPlate(-1),
+ fNStripA(-1),
+ fNStripB(-1),
+ fNStripC(-1),
+ fNpadZ(-1),
+ fNpadX(-1),
+ fNevents(0),
+ fESDsel(0x0),
+ fArrayToT(0x0),
+ fArrayTime(0x0),
+ fTOFCal(0x0),
+ fTOFSimCal(0x0),
+ fTOFSimToT(0x0)
+{
+ //TOF Calibration Class ctor
fArrayToT = 0x0;
fArrayTime = 0x0;
- flistFunc = 0x0;
- fTOFCal = 0x0;
fESDsel = 0x0;
- for (Int_t i = 0;i<6;i++){
- fhToT[i]=0x0;
- }
- fGeom=0x0;
+ AliTOFGeometry *geom=new AliTOFGeometryV5();
+ AliInfo("V5 TOF Geometry is taken as the default");
+ fNSector = geom->NSectors();
+ fNPlate = geom->NPlates();
+ fNStripA = geom->NStripA();
+ fNStripB = geom->NStripB();
+ fNStripC = geom->NStripC();
+ fNpadZ = geom->NpadZ();
+ fNpadX = geom->NpadX();
+ fNChannels = fNSector*(2*(fNStripC+fNStripB)+fNStripA)*fNpadZ*fNpadX; //generalized version
+ fTOFCal = 0x0;
+ fTOFSimCal = 0x0;
+ fTOFSimToT = 0x0;
+ delete geom;
}
-//____________________________________________________________________________
-
-AliTOFcalib::AliTOFcalib(char* headerFile, Int_t nEvents):TTask("AliTOFcalib","")
-{
- AliRunLoader *rl = AliRunLoader::Open("galice.root",AliConfig::GetDefaultEventFolderName(),"read");
- rl->CdGAFile();
- TFile *in=(TFile*)gFile;
- in->cd();
- fGeom = (AliTOFGeometry*)in->Get("TOFgeometry");
- fNSector = fGeom->NSectors();
- fNPlate = fGeom->NPlates();
- fNStripA = fGeom->NStripA();
- fNStripB = fGeom->NStripB();
- fNStripC = fGeom->NStripC();
- fNpadZ = fGeom->NpadZ();
- fNpadX = fGeom->NpadX();
- fsize = 2*(fNStripC+fNStripB) + fNStripA;
- for (Int_t i = 0;i<6;i++){
- fhToT[i]=0x0;
- }
+//_______________________________________________________________________
+AliTOFcalib::AliTOFcalib(AliTOFGeometry *geom):
+ TTask("AliTOFcalib",""),
+ fNChannels(-1),
+ fNSector(-1),
+ fNPlate(-1),
+ fNStripA(-1),
+ fNStripB(-1),
+ fNStripC(-1),
+ fNpadZ(-1),
+ fNpadX(-1),
+ fNevents(0),
+ fESDsel(0x0),
+ fArrayToT(0x0),
+ fArrayTime(0x0),
+ fTOFCal(0x0),
+ fTOFSimCal(0x0),
+ fTOFSimToT(0x0)
+{
+ //TOF Calibration Class ctor, taking the TOF geometry as input
fArrayToT = 0x0;
fArrayTime = 0x0;
- flistFunc = 0x0;
- fNevents=nEvents;
- fHeadersFile=headerFile;
- fTOFCal = 0x0;
fESDsel = 0x0;
- TFile* file = (TFile*) gROOT->GetFile(fHeadersFile.Data()) ;
- if(file == 0){
- if(fHeadersFile.Contains("rfio"))
- file = TFile::Open(fHeadersFile,"update") ;
- else
- file = new TFile(fHeadersFile.Data(),"update") ;
- gAlice = (AliRun*)file->Get("gAlice") ;
- }
-
- TTask * roottasks = (TTask*)gROOT->GetRootFolder()->FindObject("Tasks") ;
- roottasks->Add(this) ;
+ fNSector = geom->NSectors();
+ fNPlate = geom->NPlates();
+ fNStripA = geom->NStripA();
+ fNStripB = geom->NStripB();
+ fNStripC = geom->NStripC();
+ fNpadZ = geom->NpadZ();
+ fNpadX = geom->NpadX();
+ fNChannels = fNSector*(2*(fNStripC+fNStripB)+fNStripA)*fNpadZ*fNpadX; //generalized version
+ fTOFCal = 0x0;
+ fTOFSimCal = 0x0;
+ fTOFSimToT = 0x0;
}
//____________________________________________________________________________
-AliTOFcalib::AliTOFcalib(const AliTOFcalib & calib):TTask("AliTOFcalib","")
+AliTOFcalib::AliTOFcalib(const AliTOFcalib & calib):
+ TTask("AliTOFcalib",""),
+ fNChannels(-1),
+ fNSector(-1),
+ fNPlate(-1),
+ fNStripA(-1),
+ fNStripB(-1),
+ fNStripC(-1),
+ fNpadZ(-1),
+ fNpadX(-1),
+ fNevents(0),
+ fESDsel(0x0),
+ fArrayToT(0x0),
+ fArrayTime(0x0),
+ fTOFCal(0x0),
+ fTOFSimCal(0x0),
+ fTOFSimToT(0x0)
{
+ //TOF Calibration Class copy ctor
fNSector = calib.fNSector;
fNPlate = calib.fNPlate;
fNStripA = calib.fNStripA;
fNStripC = calib.fNStripC;
fNpadZ = calib.fNpadZ;
fNpadX = calib.fNpadX;
- fsize = calib.fsize;
+ fNChannels = calib.fNChannels;
fArrayToT = calib.fArrayToT;
fArrayTime = calib.fArrayTime;
- flistFunc = calib.flistFunc;
- for (Int_t i = 0;i<6;i++){
- fhToT[i]=calib.fhToT[i];
- }
fTOFCal=calib.fTOFCal;
- fESDsel = calib.fESDsel;
- fGeom = calib.fGeom;
+ fTOFSimCal = calib.fTOFSimCal;
+ fTOFSimToT=calib.fTOFSimToT;
}
//____________________________________________________________________________
-AliTOFcalib::~AliTOFcalib()
+AliTOFcalib& AliTOFcalib::operator=(const AliTOFcalib &calib)
{
- delete fArrayToT;
- delete fArrayTime;
- delete flistFunc;
- delete[] fhToT;
- delete fTOFCal;
- delete fESDsel;
+ //TOF Calibration Class assignment operator
+ this->fNSector = calib.fNSector;
+ this->fNPlate = calib.fNPlate;
+ this->fNStripA = calib.fNStripA;
+ this->fNStripB = calib.fNStripB;
+ this->fNStripC = calib.fNStripC;
+ this->fNpadZ = calib.fNpadZ;
+ this->fNpadX = calib.fNpadX;
+ this->fNChannels = calib.fNChannels;
+ this->fArrayToT = calib.fArrayToT;
+ this->fArrayTime = calib.fArrayTime;
+ this->fTOFCal=calib.fTOFCal;
+ this->fTOFSimCal = calib.fTOFSimCal;
+ this->fTOFSimToT=calib.fTOFSimToT;
+ return *this;
}
-//____________________________________________________________________________
-void AliTOFcalib::Init(){
- SetHistos();
- SetFitFunctions();
- fTOFCal = new AliTOFCal();
- fTOFCal->CreateArray();
- fNSector = 18;
- fNPlate = 5;
- fNStripA = 15;
- fNStripB = 19;
- fNStripC = 20;
- fNpadZ = 2;
- fNpadX = 96;
- fsize = 1;
- //fsize = fNSector*(2*(fNStripC+fNStripB)+fNStripA())*fNpadZ*fNpadX; //generalized version
-}
-//____________________________________________________________________________
+//____________________________________________________________________________
-void AliTOFcalib::SetHistos(){
- TFile * spFile;
- TH1F * hToT;
- for (Int_t i =0;i<6;i++){
- //for the time being, only one spectrum is used
- spFile = new TFile("$ALICE_ROOT/TOF/Spectra/spectrumtest0_1.root","read");
- //otherwise
- //spFile = new TFile(ffile[i],"read");
- spFile->GetObject("ToT",hToT);
- fhToT[i]=hToT;
- Int_t nbins = hToT->GetNbinsX();
- Float_t Delta = hToT->GetBinWidth(1);
- Float_t maxch = hToT->GetBinLowEdge(nbins)+Delta;
- Float_t minch = hToT->GetBinLowEdge(1);
- Float_t max=0,min=0; //maximum and minimum value of the distribution
- Int_t maxbin=0,minbin=0; //maximum and minimum bin of the distribution
- for (Int_t ii=nbins; ii>0; ii--){
- if (hToT->GetBinContent(ii)!= 0) {
- max = maxch - (nbins-ii-1)*Delta;
- maxbin = ii;
- break;}
- }
- for (Int_t j=1; j<nbins; j++){
- if (hToT->GetBinContent(j)!= 0) {
- min = minch + (j-1)*Delta;
- minbin = j;
- break;}
- }
- fMaxToT[i]=max;
- fMinToT[i]=min;
- fMaxToTDistr[i]=hToT->GetMaximum();
- }
-}
-//__________________________________________________________________________
+AliTOFcalib::~AliTOFcalib()
+{
+ //TOF Calibration Class dtor
+ delete fArrayToT;
+ delete fArrayTime;
-void AliTOFcalib::SetFitFunctions(){
- TFile * spFile;
- flistFunc = new TList();
- for (Int_t i =0;i<6;i++){
- //only one type of spectrum used for the time being
- spFile = new TFile("$ALICE_ROOT/TOF/Spectra/spectrumtest0_1.root","read");
- //otherwise
- //spFile = new TFile(ffile[i],"read");
- TH1F * h = (TH1F*)spFile->Get("TimeToTFit");
- TList * list = (TList*)h->GetListOfFunctions();
- TF1* f = (TF1*)list->At(0);
- Double_t par[6] = {0,0,0,0,0,0};
- Int_t npar=f->GetNpar();
- for (Int_t ipar=0;ipar<npar;ipar++){
- par[ipar]=f->GetParameter(ipar);
- }
- flistFunc->AddLast(f);
+ if(!(AliCDBManager::Instance()->GetCacheFlag())){ // CDB objects must NOT be deleted if cache is active!
+ delete fTOFCal;
+ delete fTOFSimCal;
}
- return;
+
+ delete fESDsel;
}
//__________________________________________________________________________
-TF1* AliTOFcalib::SetFitFunctions(TH1F *histo){
+TF1* AliTOFcalib::SetFitFunctions(TH1F *histo)
+{
+ //Define Fit Functions for Slewing Correction
TF1 * fpol[3];
- const Int_t nbins = histo->GetNbinsX();
- Float_t Delta = histo->GetBinWidth(1); //all the bins have the same width
- Double_t max = histo->GetBinLowEdge(nbins)+Delta;
+ const Int_t knbins = histo->GetNbinsX();
+ Float_t delta = histo->GetBinWidth(1); //all the bins have the same width
+ Double_t max = histo->GetBinLowEdge(knbins)+delta;
max = 15;
fpol[0]=new TF1("poly3","pol3",5,max);
fpol[1]=new TF1("poly4","pol4",5,max);
char npoly[10];
Double_t chi[3]={1E6,1E6,1E6};
Int_t ndf[3]={-1,-1,-1};
- Double_t Nchi[3]={1E6,1E6,1E6};
+ Double_t nchi[3]={1E6,1E6,1E6};
Double_t bestchi=1E6;
TF1 * fGold=0x0;
Int_t nonzero =0;
Int_t numberOfpar =0;
- for (Int_t j=0; j<nbins; j++){
+ for (Int_t j=0; j<knbins; j++){
if (histo->GetBinContent(j)!=0) {
nonzero++;
}
histo->Fit(npoly, "ERN", " ", 5.,14.);
chi[ifun] = fpol[ifun]->GetChisquare();
ndf[ifun] = fpol[ifun]->GetNDF();
- Nchi[ifun] = (Double_t)chi[ifun]/ndf[ifun];
- if (Nchi[ifun]<bestchi) {
- bestchi=Nchi[ifun];
+ nchi[ifun] = (Double_t)chi[ifun]/ndf[ifun];
+ if (nchi[ifun]<bestchi) {
+ bestchi=nchi[ifun];
fGold = fpol[ifun];
numberOfpar = fGold->GetNpar();
}
}
//____________________________________________________________________________
-TClonesArray* AliTOFcalib::DecalibrateDigits(TClonesArray * digits){
-
- TObjArray ChArray(fsize);
- ChArray.SetOwner();
- for (Int_t kk = 0 ; kk < fsize; kk++){
- AliTOFChSim * channel = new AliTOFChSim();
- ChArray.Add(channel);
- }
- Int_t ndigits = digits->GetEntriesFast();
- for (Int_t i=0;i<ndigits;i++){
- Float_t trix = 0;
- Float_t triy = 0;
- Float_t SimToT = 0;
- AliTOFdigit * element = (AliTOFdigit*)digits->At(i);
- /*
- Int_t *detId[5];
- detId[0] = element->GetSector();
- detId[1] = element->GetPlate();
- detId[2] = element->GetStrip();
- detId[3] = element->GetPadz();
- detId[4] = element->GetPadx();
- Int_t index = GetIndex(detId);
- */
- //select the corresponding channel with its simulated ToT spectrum
- //summing up everything, index = 0 for all channels:
- Int_t index = 0;
- AliTOFChSim *ch = (AliTOFChSim*)ChArray.At(index);
- Int_t itype = -1;
- if (!ch->IsSlewed()){
- Double_t rand = gRandom->Uniform(0,6);
- itype = (Int_t)(6-rand);
- ch->SetSpectrum(itype);
- ch->SetSlewedStatus(kTRUE);
- }
- else itype = ch->GetSpectrum();
- TH1F * hToT = fhToT[itype];
- TF1 * f = (TF1*)flistFunc->At(itype);
- while (SimToT <= triy){
- trix = gRandom->Rndm(i);
- triy = gRandom->Rndm(i);
- trix = (fMaxToT[itype]-fMinToT[itype])*trix + fMinToT[itype];
- triy = fMaxToTDistr[itype]*triy;
- Int_t binx=hToT->FindBin(trix);
- SimToT=hToT->GetBinContent(binx);
- }
-
- Float_t par[6];
- for(Int_t kk=0;kk<6;kk++){
- par[kk]=0;
- }
- element->SetToT(trix);
- Int_t nfpar = f->GetNpar();
- for (Int_t kk = 0; kk< nfpar; kk++){
- par[kk]=f->GetParameter(kk);
- }
- Float_t ToT = element->GetToT();
- element->SetTdcND(element->GetTdc());
- Float_t tdc = ((element->GetTdc())*AliTOFGeometry::TdcBinWidth()+32)*1.E-3; //tof signal in ns
- Float_t timeoffset=par[0] + ToT*par[1] +ToT*ToT*par[2] +ToT*ToT*ToT*par[3] +ToT*ToT*ToT*ToT*par[4] +ToT*ToT*ToT*ToT*ToT*par[5];
- timeoffset=0;
- Float_t timeSlewed = tdc + timeoffset;
- element->SetTdc((timeSlewed*1E3-32)/AliTOFGeometry::TdcBinWidth());
- }
- TFile * file = new TFile("ToT.root", "recreate");
- file->cd();
- ChArray.Write("ToT",TObject::kSingleKey);
- file->Close();
- delete file;
- ChArray.Clear();
- return digits;
-}
-//____________________________________________________________________________
-
-void AliTOFcalib::SelectESD(AliESD *event, AliRunLoader *rl)
+void AliTOFcalib::SelectESD(AliESD *event)
{
- AliLoader *tofl = rl->GetLoader("TOFLoader");
- if (tofl == 0x0) {
- AliError("Can not get the TOF Loader");
- delete rl;
- }
- tofl->LoadRecPoints("read");
- TClonesArray *fClusters =new TClonesArray("AliTOFcluster", 1000);
- TTree *rTree=tofl->TreeR();
- if (rTree == 0) {
- cerr<<"Can't get the Rec Points tree !\n";
- delete rl;
- }
- TBranch *branch=rTree->GetBranch("TOF");
- if (!branch) {
- cerr<<"Cant' get the branch !\n";
- delete rl;
- }
- branch->SetAddress(&fClusters);
- rTree->GetEvent(0);
- Float_t LowerMomBound=0.8; // [GeV/c] default value Pb-Pb
- Float_t UpperMomBound=1.8 ; // [GeV/c] default value Pb-Pb
+ //track selection for Calibration
+ Float_t lowerMomBound=0.8; // [GeV/c] default value Pb-Pb
+ Float_t upperMomBound=1.8 ; // [GeV/c] default value Pb-Pb
Int_t ntrk =0;
Int_t ngoodtrkfinalToT = 0;
ntrk=event->GetNumberOfTracks();
fESDsel = new TObjArray(ntrk);
fESDsel->SetOwner();
- TObjArray UCdatatemp(ntrk);
+ TObjArray uCdatatemp(ntrk);
Int_t ngoodtrk = 0;
Int_t ngoodtrkfinal = 0;
Float_t mintime =1E6;
time*=1.E-3; // tof given in nanoseconds
if(time <= mintime)mintime=time;
Double_t mom=t->GetP();
- if (!(mom<=UpperMomBound && mom>=LowerMomBound))continue;
- UInt_t AssignedTOFcluster=t->GetTOFcluster();//index of the assigned TOF cluster, >0 ?
- if(AssignedTOFcluster==0){ // not matched
+ if (!(mom<=upperMomBound && mom>=lowerMomBound))continue;
+ UInt_t assignedTOFcluster=t->GetTOFcluster();//index of the assigned TOF cluster, >0 ?
+ if(assignedTOFcluster==0){ // not matched
continue;
}
- AliTOFcluster * tofcl = (AliTOFcluster *)fClusters->UncheckedAt(AssignedTOFcluster);
- Int_t isector = tofcl->GetDetInd(0);
- Int_t iplate = tofcl->GetDetInd(1);
- Int_t istrip = tofcl->GetDetInd(2);
- Int_t ipadz = tofcl->GetDetInd(3);
- Int_t ipadx = tofcl->GetDetInd(4);
- Float_t ToT = tofcl->GetToT();
AliTOFcalibESD *unc = new AliTOFcalibESD;
unc->CopyFromAliESD(t);
- unc->SetSector(isector);
- unc->SetPlate(iplate);
- unc->SetStrip(istrip);
- unc->SetPadz(ipadz);
- unc->SetPadx(ipadx);
- unc->SetToT(ToT);
Double_t c1[15];
unc->GetExternalCovariance(c1);
- UCdatatemp.Add(unc);
+ uCdatatemp.Add(unc);
ngoodtrk++;
}
for (Int_t i = 0; i < ngoodtrk ; i ++){
- AliTOFcalibESD *unc = (AliTOFcalibESD*)UCdatatemp.At(i);
+ AliTOFcalibESD *unc = (AliTOFcalibESD*)uCdatatemp.At(i);
if((unc->GetTOFsignal()-mintime*1.E3)<5.E3){
fESDsel->Add(unc);
ngoodtrkfinal++;
}
//_____________________________________________________________________________
-void AliTOFcalib::CombESDId(){
+void AliTOFcalib::CombESDId()
+{
+ //track PID for calibration
Float_t t0offset=0;
Float_t loffset=0;
Int_t ntracksinset=6;
Float_t sqMomError[6]={0.,0.,0.,0.,0.,0.};
Float_t sqTrackError[6]={0.,0.,0.,0.,0.,0.};
Float_t tracktoflen[6]={0.,0.,0.,0.,0.,0.};
- Float_t TimeResolution = 0.90e-10; // 90 ps by default
- Float_t timeresolutioninns=TimeResolution*(1.e+9); // convert in [ns]
+ Float_t timeResolution = 0.90e-10; // 90 ps by default
+ Float_t timeresolutioninns=timeResolution*(1.e+9); // convert in [ns]
Float_t timezero[6]={0.,0.,0.,0.,0.,0.};
Float_t weightedtimezero[6]={0.,0.,0.,0.,0.,0.};
Float_t besttimezero[6]={0.,0.,0.,0.,0.,0.};
momentum[j]=mom;
}
Float_t t0best=999.;
- Float_t Et0best=999.;
+ Float_t et0best=999.;
Float_t chisquarebest=999.;
for (Int_t i1=0; i1<3;i1++) {
beta[0]=momentum[0]/sqrt(massarray[i1]*massarray[i1]+momentum[0]*momentum[0]);
Float_t sumAllweights=0.;
Float_t meantzero=0.;
- Float_t Emeantzero=0.;
+ Float_t emeantzero=0.;
for (Int_t itz=0; itz<ntracksinset;itz++) {
sqMomError[itz]=
} // end loop for (Int_t itz=0; itz<15;itz++)
meantzero=meantzero/sumAllweights; // it is given in [ns]
- Emeantzero=sqrt(1./sumAllweights); // it is given in [ns]
+ emeantzero=sqrt(1./sumAllweights); // it is given in [ns]
// calculate chisquare
chisquarebest=chisquare;
t0best=meantzero;
- Et0best=Emeantzero;
+ et0best=emeantzero;
} // close if(dummychisquare<=chisquare)
} // end loop on i6
} // end loop on i5
//_____________________________________________________________________________
void AliTOFcalib::CalibrateESD(){
+ //Calibrate selected ESD times
Int_t nelements = fESDsel->GetEntries();
- Int_t *number=new Int_t[fsize];
- fArrayToT = new AliTOFArray(fsize);
- fArrayTime = new AliTOFArray(fsize);
- for (Int_t i=0; i<fsize; i++){
+ Int_t *number=new Int_t[fNChannels];
+ fArrayToT = new AliTOFArray(fNChannels);
+ fArrayTime = new AliTOFArray(fNChannels);
+ for (Int_t i=0; i<fNChannels; i++){
number[i]=0;
fArrayToT->AddArray(i, new TArrayF(fgkchannel));
TArrayF * parrToT = fArrayToT->GetArray(i);
else AliError("No pid from combinatorial algo for this track");
Double_t mtime = (Double_t)element->GetTOFsignal()*1E-3; //measured time
Double_t mToT = (Double_t) element->GetToT(); //measured ToT, ns
- /*
- Int_t *detId[5];
- detId[0] = element->GetSector();
- detId[1] = element->GetPlate();
- detId[2] = element->GetStrip();
- detId[3] = element->GetPadz();
- detId[4] = element->GetPadx();
- Int_t index = GetIndex(detId);
- */
//select the correspondent channel with its simulated ToT spectrum
//summing up everything, index = 0 for all channels:
- Int_t index = 0;
+ Int_t index = element->GetTOFCalChannel();
Int_t index2 = number[index];
TArrayF * parrToT = fArrayToT->GetArray(index);
TArrayF & refaToT = * parrToT;
for (Int_t kk = 0; kk< nfpar; kk++){
par[kk]=fGold->GetParameter(kk);
}
- AliTOFChannel * CalChannel = fTOFCal->GetChannel(i);
- CalChannel->SetSlewPar(par);
+ if (!fTOFCal) {
+ AliTOFGeometry *geom=new AliTOFGeometryV5();
+ fTOFCal = new AliTOFCal(geom);
+ fTOFCal->CreateArray();
+ delete geom;
+ }
+ AliTOFChannel * calChannel = fTOFCal->GetChannel(i);
+ calChannel->SetSlewPar(par);
}
delete[] number;
}
//___________________________________________________________________________
-TH1F* AliTOFcalib::Profile(Int_t ich){
- const Int_t nbinToT = 650;
+TH1F* AliTOFcalib::Profile(Int_t ich)
+{
+ //Prepare histograms for Slewing Correction
+ const Int_t knbinToT = 650;
Int_t nbinTime = 400;
Float_t minTime = -10.5; //ns
Float_t maxTime = 10.5; //ns
Float_t minToT = 7.5; //ns
Float_t maxToT = 40.; //ns
- Float_t DeltaToT = (maxToT-minToT)/nbinToT;
- Double_t mTime[nbinToT+1],mToT[nbinToT+1],meanTime[nbinToT+1], meanTime2[nbinToT+1],ToT[nbinToT+1], ToT2[nbinToT+1],meanToT[nbinToT+1],meanToT2[nbinToT+1],Time[nbinToT+1],Time2[nbinToT+1],xlow[nbinToT+1],sigmaTime[nbinToT+1];
- Int_t n[nbinToT+1], nentrx[nbinToT+1];
- Double_t sigmaToT[nbinToT+1];
- for (Int_t i = 0; i < nbinToT+1 ; i++){
+ Float_t deltaToT = (maxToT-minToT)/knbinToT;
+ Double_t mTime[knbinToT+1],mToT[knbinToT+1],meanTime[knbinToT+1], meanTime2[knbinToT+1],vToT[knbinToT+1], vToT2[knbinToT+1],meanToT[knbinToT+1],meanToT2[knbinToT+1],vTime[knbinToT+1],vTime2[knbinToT+1],xlow[knbinToT+1],sigmaTime[knbinToT+1];
+ Int_t n[knbinToT+1], nentrx[knbinToT+1];
+ Double_t sigmaToT[knbinToT+1];
+ for (Int_t i = 0; i < knbinToT+1 ; i++){
mTime[i]=0;
mToT[i]=0;
n[i]=0;
meanTime[i]=0;
meanTime2[i]=0;
- ToT[i]=0;
- ToT2[i]=0;
+ vToT[i]=0;
+ vToT2[i]=0;
meanToT[i]=0;
meanToT2[i]=0;
- Time[i]=0;
- Time2[i]=0;
+ vTime[i]=0;
+ vTime2[i]=0;
xlow[i]=0;
sigmaTime[i]=0;
sigmaToT[i]=0;
n[i]=0;
nentrx[i]=0;
}
- TH2F* hSlewing = new TH2F("hSlewing", "hSlewing", nbinToT, minToT, maxToT, nbinTime, minTime, maxTime);
+ TH2F* hSlewing = new TH2F("hSlewing", "hSlewing", knbinToT, minToT, maxToT, nbinTime, minTime, maxTime);
TArrayF * parrToT = fArrayToT->GetArray(ich);
TArrayF & refaToT = * parrToT;
TArrayF * parrTime = fArrayTime->GetArray(ich);
TArrayF & refaTime = * parrTime;
for (Int_t j = 0; j < AliTOFcalib::fgkchannel; j++){
if (refaToT[j] == 0) continue;
- Int_t nx = (Int_t)((refaToT[j]-minToT)/DeltaToT)+1;
+ Int_t nx = (Int_t)((refaToT[j]-minToT)/deltaToT)+1;
if ((refaToT[j] != 0) && (refaTime[j] != 0)){
- Time[nx]+=refaTime[j];
- Time2[nx]+=(refaTime[j])*(refaTime[j]);
- ToT[nx]+=refaToT[j];
- ToT2[nx]+=refaToT[j]*refaToT[j];
+ vTime[nx]+=refaTime[j];
+ vTime2[nx]+=(refaTime[j])*(refaTime[j]);
+ vToT[nx]+=refaToT[j];
+ vToT2[nx]+=refaToT[j]*refaToT[j];
nentrx[nx]++;
hSlewing->Fill(refaToT[j],refaTime[j]);
}
}
Int_t nbinsToT=hSlewing->GetNbinsX();
- if (nbinsToT != nbinToT) {
+ if (nbinsToT != knbinToT) {
AliError("Profile :: incompatible numbers of bins");
return 0x0;
}
if (n[usefulBins]==0 && i == nbinsToT) {
break;
}
- meanTime[usefulBins]+=Time[i];
- meanTime2[usefulBins]+=Time2[i];
- meanToT[usefulBins]+=ToT[i];
- meanToT2[usefulBins]+=ToT2[i];
+ meanTime[usefulBins]+=vTime[i];
+ meanTime2[usefulBins]+=vTime2[i];
+ meanToT[usefulBins]+=vToT[i];
+ meanToT2[usefulBins]+=vToT2[i];
if (n[usefulBins]<20 && i!=nbinsToT) continue;
mTime[usefulBins]=meanTime[usefulBins]/n[usefulBins];
mToT[usefulBins]=meanToT[usefulBins]/n[usefulBins];
}
}
for (Int_t i=0;i<usefulBins;i++){
- Int_t binN = (Int_t)((mToT[i]-minToT)/DeltaToT)+1;
+ Int_t binN = (Int_t)((mToT[i]-minToT)/deltaToT)+1;
histo->Fill(mToT[i],mTime[i]);
histo->SetBinError(binN,sigmaTime[i]);
}
}
//_____________________________________________________________________________
-void AliTOFcalib::CorrectESDTime(){
+void AliTOFcalib::CorrectESDTime()
+{
+ //Calculate the corrected TOF time
Int_t nelements = fESDsel->GetEntries();
for (Int_t i=0; i< nelements; i++) {
AliTOFcalibESD *element=(AliTOFcalibESD*)fESDsel->At(i);
- /*
- Int_t *detId[5];
- detId[0] = element->GetSector();
- detId[1] = element->GetPlate();
- detId[2] = element->GetStrip();
- detId[3] = element->GetPadz();
- detId[4] = element->GetPadx();
- Int_t index = GetIndex(detId);
- */
+ Int_t index = element->GetTOFCalChannel();
+ Float_t tToT = element->GetToT();
//select the correspondent channel with its simulated ToT spectrum
//summing up everything, index = 0 for all channels:
- Int_t index = 0;
Int_t ipid = element->GetCombID();
Double_t etime = 0; //expected time
Double_t expTime[10];
else if (ipid == 1) etime = expTime[3]*1E-3; //ns
else if (ipid == 2) etime = expTime[4]*1E-3; //ns
Float_t par[6];
- AliTOFChannel * CalChannel = fTOFCal->GetChannel(index);
+ if (!fTOFCal) {
+ AliTOFGeometry *geom=new AliTOFGeometryV5();
+ fTOFCal = new AliTOFCal(geom);
+ fTOFCal->CreateArray();
+ delete geom;
+ }
+ AliTOFChannel * calChannel = fTOFCal->GetChannel(index);
for (Int_t j = 0; j<6; j++){
- par[j]=CalChannel->GetSlewPar(j);
+ par[j]=calChannel->GetSlewPar(j);
}
- //Float_t TimeCorr=par[0]+par[1]*ToT+par[2]*ToT*ToT+par[3]*ToT*ToT*ToT+par[4]*ToT*ToT*ToT*ToT+par[5]*ToT*ToT*ToT*ToT*ToT;
+ Float_t timeCorr=0;
+ timeCorr= par[0]+par[1]*tToT+par[2]*tToT*tToT+par[3]*tToT*tToT*tToT+par[4]*tToT*tToT*tToT*tToT+par[5]*tToT*tToT*tToT*tToT*tToT;
}
}
//_____________________________________________________________________________
-void AliTOFcalib::CorrectESDTime(AliESD *event, AliRunLoader *rl ){
- AliLoader *tofl = rl->GetLoader("TOFLoader");
- if (tofl == 0x0) {
- AliError("Can not get the TOF Loader");
- delete rl;
- }
- tofl->LoadRecPoints("read");
- TClonesArray *fClusters =new TClonesArray("AliTOFcluster", 1000);
- TTree *rTree=tofl->TreeR();
- if (rTree == 0) {
- cerr<<"Can't get the Rec Points tree !\n";
- delete rl;
- }
- TBranch *branch=rTree->GetBranch("TOF");
- if (!branch) {
- cerr<<"Cant' get the branch !\n";
- delete rl;
- }
- branch->SetAddress(&fClusters);
- rTree->GetEvent(0);
+void AliTOFcalib::CorrectESDTime(AliESD *event){
+ //Calculate the corrected TOF time
+
Int_t ntrk =0;
ntrk=event->GetNumberOfTracks();
for (Int_t itrk=0; itrk<ntrk; itrk++) {
if ((t->GetStatus()&AliESDtrack::kTIME)==0) {
continue;
}
- UInt_t AssignedTOFcluster=t->GetTOFcluster();//index of the assigned TOF cluster, >0 ?
- if(AssignedTOFcluster==0){ // not matched
+ UInt_t assignedTOFcluster=t->GetTOFcluster();//index of the assigned TOF cluster, >0 ?
+ if(assignedTOFcluster==0){ // not matched
continue;
}
- AliTOFcluster * tofcl = (AliTOFcluster *)fClusters->UncheckedAt(AssignedTOFcluster);
- /*
- Int_t *detId[5];
- detId[0] = tofcl->GetSector();
- detId[1] = tofcl->GetPlate();
- detId[2] = tofcl->GetStrip();
- detId[3] = tofcl->GetPadz();
- detId[4] = tofcl->GetPadx();
- Int_t index = GetIndex(detId);
- */
- //select the correspondent channel with its simulated ToT spectrum
- //summing up everything, index = 0 for all channels:
- Int_t index = 0;
- AliTOFChannel * CalChannel = fTOFCal->GetChannel(index);
+ Int_t index = t->GetTOFCalChannel();
+ if (!fTOFCal) {
+ AliTOFGeometry *geom=new AliTOFGeometryV5();
+ fTOFCal = new AliTOFCal(geom);
+ fTOFCal->CreateArray();
+ delete geom;
+ }
+ AliTOFChannel * calChannel = fTOFCal->GetChannel(index);
Float_t par[6];
for (Int_t j = 0; j<6; j++){
- par[j]=CalChannel->GetSlewPar(j);
+ par[j]=calChannel->GetSlewPar(j);
}
- Float_t ToT = tofcl->GetToT();
- Float_t TimeCorr =0;
- TimeCorr=par[0]+par[1]*ToT+par[2]*ToT*ToT+par[3]*ToT*ToT*ToT+par[4]*ToT*ToT*ToT*ToT+par[5]*ToT*ToT*ToT*ToT*ToT;
+ Float_t tToT = t->GetTOFsignalToT();
+ Float_t timeCorr =0;
+ timeCorr=par[0]+par[1]*tToT+par[2]*tToT*tToT+par[3]*tToT*tToT*tToT+par[4]*tToT*tToT*tToT*tToT+par[5]*tToT*tToT*tToT*tToT*tToT;
}
}
//_____________________________________________________________________________
-void AliTOFcalib::WriteOnCDB(){
+void AliTOFcalib::WriteParOnCDB(Char_t *sel, Int_t minrun, Int_t maxrun)
+{
+ //Write calibration parameters to the CDB
AliCDBManager *man = AliCDBManager::Instance();
- AliCDBId id("TOF/Calib/Constants",1,100);
+ if(!man->IsDefaultStorageSet())man->SetDefaultStorage("local://$ALICE_ROOT");
+ Char_t *sel1 = "Par" ;
+ Char_t out[100];
+ sprintf(out,"%s/%s",sel,sel1);
+ AliCDBId id(out,minrun,maxrun);
AliCDBMetaData *md = new AliCDBMetaData();
- md->SetResponsible("Shimmize");
+ md->SetResponsible("Chiara Zampolli");
+ if (!fTOFCal) {
+ AliTOFGeometry *geom=new AliTOFGeometryV5();
+ fTOFCal = new AliTOFCal(geom);
+ fTOFCal->CreateArray();
+ delete geom;
+ }
man->Put(fTOFCal,id,md);
+ delete md;
+}
+//_____________________________________________________________________________
+
+void AliTOFcalib::WriteParOnCDB(Char_t *sel, Int_t minrun, Int_t maxrun, AliTOFCal *cal){
+ //Write calibration parameters to the CDB
+ AliCDBManager *man = AliCDBManager::Instance();
+ if(!man->IsDefaultStorageSet())man->SetDefaultStorage("local://$ALICE_ROOT");
+ Char_t *sel1 = "Par" ;
+ Char_t out[100];
+ sprintf(out,"%s/%s",sel,sel1);
+ AliCDBId id(out,minrun,maxrun);
+ AliCDBMetaData *md = new AliCDBMetaData();
+ md->SetResponsible("Chiara Zampolli");
+ man->Put(cal,id,md);
+ delete md;
}
//_____________________________________________________________________________
-void AliTOFcalib::ReadFromCDB(Char_t *sel, Int_t nrun){
+Bool_t AliTOFcalib::ReadParFromCDB(Char_t *sel, Int_t nrun)
+{
+ //Read calibration parameters from the CDB
AliCDBManager *man = AliCDBManager::Instance();
- AliCDBEntry *entry = man->Get(sel,nrun);
- if (!entry){
- AliError("Retrivial failed");
- AliCDBStorage *origSto =man->GetDefaultStorage();
- man->SetDefaultStorage("local://$ALICE_ROOT");
- entry = man->Get("TOF/Calib/Constants",nrun);
- man->SetDefaultStorage(origSto);
+ if(!man->IsDefaultStorageSet())man->SetDefaultStorage("local://$ALICE_ROOT");
+ Char_t *sel1 = "Par" ;
+ Char_t out[100];
+ sprintf(out,"%s/%s",sel,sel1);
+ AliCDBEntry *entry = man->Get(out,nrun);
+ if (!entry) {
+ AliError(Form("Failed to get entry: %s",out));
+ return kFALSE;
}
AliTOFCal *cal =(AliTOFCal*)entry->GetObject();
fTOFCal = cal;
+ return kTRUE;
+
}
//_____________________________________________________________________________
+void AliTOFcalib::WriteSimParOnCDB(Char_t *sel, Int_t minrun, Int_t maxrun)
+{
+ //Write Sim miscalibration parameters to the CDB
+
+
+ //for the time being, only one spectrum is used
+ TFile *spFile = new TFile("$ALICE_ROOT/TOF/data/spectrum.root","read");
+ TH1F * hToT;
+ // Retrieve ToT Spectrum
+ spFile->GetObject("ToT",hToT);
+
+ fTOFSimToT=hToT;
+
+ // Retrieve Time over TOT dependence
+
+ TH1F * h = (TH1F*)spFile->Get("TimeToTFit");
+ TList * list = (TList*)h->GetListOfFunctions();
+ TF1* f = (TF1*)list->At(0);
+ Float_t par[6] = {0,0,0,0,0,0};
+ Int_t npar=f->GetNpar();
+ for (Int_t ipar=0;ipar<npar;ipar++){
+ par[ipar]=f->GetParameter(ipar);
+ }
+ if (!fTOFSimCal) {
+ AliTOFGeometry *geom=new AliTOFGeometryV5();
+ fTOFSimCal = new AliTOFCal(geom);
+ fTOFSimCal->CreateArray();
+ delete geom;
+ }
+ for(Int_t iTOFch=0; iTOFch<fTOFSimCal->NPads();iTOFch++){
+ AliTOFChannel * calChannel = fTOFSimCal->GetChannel(iTOFch);
+ calChannel->SetSlewPar(par);
+ }
+
+ // Store them in the CDB
-Int_t AliTOFcalib::GetIndex(Int_t *detId){
+ AliCDBManager *man = AliCDBManager::Instance();
+ if(!man->IsDefaultStorageSet())man->SetDefaultStorage("local://$ALICE_ROOT");
+ AliCDBMetaData *md = new AliCDBMetaData();
+ md->SetResponsible("Chiara Zampolli");
+ Char_t *sel1 = "SimPar" ;
+ Char_t out[100];
+ sprintf(out,"%s/%s",sel,sel1);
+ AliCDBId id1(out,minrun,maxrun);
+ man->Put(fTOFSimCal,id1,md);
+ Char_t *sel2 = "SimHisto" ;
+ sprintf(out,"%s/%s",sel,sel2);
+ AliCDBId id2(out,minrun,maxrun);
+ man->Put(fTOFSimToT,id2,md);
+ delete md;
+}
+
+//_____________________________________________________________________________
+void AliTOFcalib::WriteSimParOnCDB(Char_t *sel, Int_t minrun, Int_t maxrun, AliTOFCal *cal, TH1F * histo){
+ //Write Sim miscalibration parameters to the CDB
+
+ fTOFSimToT=histo;
+ fTOFSimCal=cal;
+ AliCDBManager *man = AliCDBManager::Instance();
+ if(!man->IsDefaultStorageSet())man->SetDefaultStorage("local://$ALICE_ROOT");
+ AliCDBMetaData *md = new AliCDBMetaData();
+ md->SetResponsible("Chiara Zampolli");
+ Char_t *sel1 = "SimPar" ;
+ Char_t out[100];
+ sprintf(out,"%s/%s",sel,sel1);
+ AliCDBId id1(out,minrun,maxrun);
+ man->Put(fTOFSimCal,id1,md);
+ Char_t *sel2 = "SimHisto" ;
+ sprintf(out,"%s/%s",sel,sel2);
+ AliCDBId id2(out,minrun,maxrun);
+ man->Put(fTOFSimToT,id2,md);
+ delete md;
+}
+//_____________________________________________________________________________
+void AliTOFcalib::ReadSimParFromCDB(Char_t *sel, Int_t nrun)
+{
+ //Read miscalibration parameters from the CDB
+ AliCDBManager *man = AliCDBManager::Instance();
+ if(!man->IsDefaultStorageSet())man->SetDefaultStorage("local://$ALICE_ROOT");
+ Char_t *sel1 = "SimPar" ;
+ Char_t out[100];
+ sprintf(out,"%s/%s",sel,sel1);
+ AliCDBEntry *entry1 = man->Get(out,nrun);
+ AliTOFCal *cal =(AliTOFCal*)entry1->GetObject();
+ fTOFSimCal=cal;
+ Char_t *sel2 = "SimHisto" ;
+ sprintf(out,"%s/%s",sel,sel2);
+ AliCDBEntry *entry2 = man->Get(out,nrun);
+ TH1F *histo =(TH1F*)entry2->GetObject();
+ fTOFSimToT=histo;
+}
+//_____________________________________________________________________________
+
+Int_t AliTOFcalib::GetIndex(Int_t *detId)
+{
+ //Retrieve calibration channel index
Int_t isector = detId[0];
if (isector >= fNSector)
AliError(Form("Wrong sector number in TOF (%d) !",isector));