#include <TAxis.h>
#include <TFile.h>
#include <TH1.h>
+#include <TKey.h>
#include <TObjArray.h>
#include <TString.h>
+#include <TROOT.h>
#include <TSystem.h>
#include "AliLog.h"
AliTRDPIDResponse::AliTRDPIDResponse(const Char_t * filename):
TObject()
,fReferences(NULL)
+ ,fGainNormalisationFactor(1.)
,fPIDmethod(2)
{
//
// Default constructor
//
- Int_t size = (AliPID::kSPECIES+1)*(kNPBins+1);
- memset(fMapRefHists, 0, sizeof(Int_t) * size);
- Load(filename);
+ Int_t size = (AliPID::kSPECIES)*(kNPBins);
+ //memset(fMapRefHists, 0, sizeof(Int_t) * size);
+ for(Int_t ispec = 0; ispec < AliPID::kSPECIES; ispec++)
+ for(Int_t ipbin = 0; ipbin < kNPBins; ipbin++)
+ fMapRefHists[ispec][ipbin] = -1;
+ Load(filename);
}
//____________________________________________________________
AliTRDPIDResponse::AliTRDPIDResponse(const AliTRDPIDResponse &ref):
TObject(ref)
,fReferences(ref.fReferences)
+ ,fGainNormalisationFactor(ref.fGainNormalisationFactor)
,fPIDmethod(ref.fPIDmethod)
{
//
// Flat copy of the reference histos
// For creating a deep copy call SetOwner
//
- Int_t size = (AliPID::kSPECIES+1)*(kNPBins+1);
+ Int_t size = (AliPID::kSPECIES)*(kNPBins);
memcpy(fMapRefHists, ref.fMapRefHists, sizeof(Double_t) * size);
}
SetBit(kIsOwner, kFALSE);
} else if(fReferences) delete fReferences;
fReferences = ref.fReferences;
- Int_t size = (AliPID::kSPECIES+1)*(kNPBins+1);
+ Int_t size = (AliPID::kSPECIES)*(kNPBins);
memcpy(fMapRefHists, ref.fMapRefHists, sizeof(Double_t) * size);
fPIDmethod = ref.fPIDmethod;
return kFALSE;
}
+ gROOT->cd();
fReferences = new TObjArray();
fReferences->SetOwner();
TIter iter(in->GetListOfKeys());
+ TKey *histkey = NULL;
TObject *tmp = NULL;
Int_t arrayPos = 0, pbin = 0;
AliPID::EParticleType species;
TString histname;
- while((tmp = iter())){
+ while((histkey = dynamic_cast<TKey *>(iter()))){
+ tmp = histkey->ReadObj();
histname = tmp->GetName();
if(histname.BeginsWith("fHQel")){ // Electron histogram
histname.ReplaceAll("fHQel_p","");
histname.ReplaceAll("fHQpi_p","");
species = AliPID::kPion;
}
- pbin = histname.Atoi();
+ pbin = histname.Atoi() - 1;
fMapRefHists[species][pbin] = arrayPos;
- fReferences->AddAt(tmp->Clone(), arrayPos);
+ fReferences->AddAt(new TH1F(*dynamic_cast<TH1F *>(tmp)), arrayPos);
arrayPos++;
}
in->Close();
s=0.;
for(Int_t is(AliPID::kSPECIES); is--;){
prLayer[is] = GetProbabilitySingleLayer(is, p[il], DE[0]);
+ AliDebug(3, Form("Probability for Species %d in Layer %d: %f", is, il, prLayer[is]));
s+=prLayer[is];
}
if(s<1.e-30){
// from the reference histogram
// Interpolation between momentum bins
//
+ AliDebug(1, Form("Make Probability for Species %d with Momentum %f", species, plocal));
Int_t pbin = GetLowerMomentumBin(plocal);
Double_t pLayer = 0.;
// Do Interpolation exept for underflow and overflow
if(pbin >= 0 && pbin < kNPBins-1){
TH1 *refHistUpper = NULL, *refHistLower = NULL;
- refHistLower = dynamic_cast<TH1 *>(fReferences->UncheckedAt(fMapRefHists[species][pbin]));
- refHistUpper = dynamic_cast<TH1 *>(fReferences->UncheckedAt(fMapRefHists[species][pbin+1]));
+ if(fMapRefHists[species][pbin] > 0)
+ refHistLower = dynamic_cast<TH1 *>(fReferences->UncheckedAt(fMapRefHists[species][pbin]));
+ if(fMapRefHists[species][pbin+1] > 0)
+ refHistUpper = dynamic_cast<TH1 *>(fReferences->UncheckedAt(fMapRefHists[species][pbin+1]));
if (refHistLower && refHistUpper ) {
Double_t pLower = refHistLower->GetBinContent(refHistLower->GetXaxis()->FindBin(dEdx));
TH1 *refHist = NULL;
if(pbin < 0){
// underflow
- refHist = dynamic_cast<TH1 *>(fReferences->UncheckedAt(fMapRefHists[0][0]));
+ if(fMapRefHists[species][0] >= 0){
+ refHist = dynamic_cast<TH1 *>(fReferences->UncheckedAt(fMapRefHists[species][0]));
+ }
} else {
// overflow
- refHist = dynamic_cast<TH1 *>(fReferences->UncheckedAt(fMapRefHists[species][kNPBins]));
+ if(fMapRefHists[species][kNPBins-1] > 0)
+ refHist = dynamic_cast<TH1 *>(fReferences->UncheckedAt(fMapRefHists[species][kNPBins-1]));
}
if (refHist)
pLayer = refHist->GetBinContent(refHist->GetXaxis()->FindBin(dEdx));
}
+ AliDebug(1, Form("Probability %f", pLayer));
return pLayer;
}
break;
case 2: // 1D LQ
out[0]= 0.;
- for(Int_t islice = 0; islice < 8; islice++) out[0] += in[islice];
+ for(Int_t islice = 0; islice < 8; islice++) out[0] += in[islice] * fGainNormalisationFactor;
if(out[0] < 1e-6) return kFALSE;
break;
default: