AliTRDtracker trdTracker(trdcf);
//An instance of the TRD PID maker
- TFile* pidFile = TFile::Open("pid.root");
- if (!pidFile->IsOpen()) {
- cerr << "Can't get pid.root !\n";
- return 7;
- }
- AliTRDPartID* trdPID = (AliTRDPartID*) pidFile->Get("AliTRDPartID");
- if (!trdPID) {
- cerr << "Can't get PID object !\n";
- return 8;
- }
+ AliTRDPartID* trdPID = AliTRDPartID::GetFromFile();
+ if (!trdPID) return 7;
TFile *ef=TFile::Open("AliESDs.root","RECREATE");
if (!ef->IsOpen()) {cerr<<"Can't AliESDs.root !\n"; return 1;}
}
timer.Stop(); timer.Print();
- pidFile->Close();
trdcf->Close();
delete geom;
itscf->Close();
#include "AliTRDPartID.h"
#include "AliESDtrack.h"
-#include "TProfile.h"
-#include "TF1.h"
-
+#include <TProfile.h>
+#include <TF1.h>
+#include <TFile.h>
+#include <TROOT.h>
#include <TMath.h>
+#include <Riostream.h>
ClassImp(AliTRDPartID)
{
// This function calculates the "detector response" PID probabilities
- static const Double_t masses[]={
- 0.000511, 0.105658, 0.139570, 0.493677, 0.938272
- };
+ static const Double_t masses[AliESDtrack::kSPECIES] =
+ {0.000511, 0.105658, 0.139570, 0.493677, 0.938272};
if (((track->GetStatus()&AliESDtrack::kTRDin) == 0) &&
((track->GetStatus()&AliESDtrack::kTRDout) == 0)) return kFALSE;
if (TMath::Abs(measuredSignal - expectedSignal) > fRange * expectedError) {
track->SetTRDpid(iSpecies, 0.);
} else {
- Double_t p = TMath::Gaus(measuredSignal, expectedSignal, expectedError);
+ Double_t delta = (measuredSignal-expectedSignal) / expectedError;
+ const Double_t kInvSqr2Pi = 0.398942280401432703;
+ Double_t p = kInvSqr2Pi / expectedError * TMath::Exp(-delta*delta / 2.);
pSum += p;
track->SetTRDpid(iSpecies, p);
}
// determine the parameters of the bethe bloch function
if (fBetheBloch) delete fBetheBloch;
- fBetheBloch = new TF1("fBetheBlochTRD", fcnBetheBloch,
- 0.001, 100000., 5);
+ fBetheBloch = new TF1("fBetheBlochTRD", fcnBetheBloch, 0.001, 100000., 5);
fBetheBloch->SetParameters(1, 10, 0.00002, 2, 2);
fBetheBloch->SetParLimits(2, 0., 0.01);
fBetheBloch->SetParLimits(3, 0., 10.);
fBetheBloch->SetParLimits(4, 0., 10.);
fBetheBloch->SetFillStyle(0);
fBetheBloch->SetLineColor(kRed);
- dEdxVsBetaGamma->Fit(fBetheBloch, "N");
+ dEdxVsBetaGamma->Fit(fBetheBloch, "NIR", "goff", 0.6, dEdxVsBetaGamma->GetXaxis()->GetXmax());
}
TF1* AliTRDPartID::CreateBetheBloch(Double_t mass)
return result;
}
+AliTRDPartID* AliTRDPartID::GetFromFile(const char* fileName)
+{
+// read an AliTRDPartID object from a file
+
+ TFile* pidFile = (TFile*) gROOT->GetListOfFiles()->FindObject(fileName);
+ Bool_t fileOpened = kFALSE;
+ if (!pidFile) {
+ pidFile = TFile::Open(fileName);
+ fileOpened = kTRUE;
+ }
+ if (!pidFile->IsOpen()) {
+ cerr << "Can't open " << fileName << " !\n";
+ if (fileOpened) delete pidFile;
+ return NULL;
+ }
+ gROOT->cd();
+
+ AliTRDPartID* trdPID = (AliTRDPartID*) pidFile->Get("AliTRDPartID")->Clone();
+ if (!trdPID) {
+ cerr << "Can't get PID object !\n";
+ } else {
+ trdPID->GetBetheBloch()->SetFunction(fcnBetheBloch);
+ }
+
+ if (fileOpened) {
+ pidFile->Close();
+ delete pidFile;
+ }
+
+ return trdPID;
+}
+
Double_t AliTRDPartID::fcnBetheBloch(Double_t* xx, Double_t* par)
{
// parametrized bethe bloch function (xx[0] = beta*gamma = p/m):