ROOT logo
/*

 // example usage:
 TH2D h2("h2",";p (GeV/#it{c});d#it{E}/d#it{x} (arb. units)",100,0,20,100,0,200);
 h2.Draw();
 .L $ALICE_ROOT/ANALYSIS/macros/DrawSplines.C
 DrawTPCPIDSplines(122374,2);



*/

void DrawTPCPIDSplines(Int_t run, Int_t pass, Float_t dEdxMin=0., Float_t dEdxMax=200, Float_t pMin=0.1, Float_t pMax=20.)
{
  //
  // simple macro to draw splines using the AliPIDResponse class
  // only splines for electrons, pions, kaons and protons 
  // NOTE: This is only for simple overlaying purposes not for QA.
  //       The TPC pid depends on eta, the splines are eta averaged
  //         so an overlay could look wrong, depending on the eta
  //         of the track selection.
  //       For QA purposes the nSigma values with full eta correction
  //         should be used as done e.g. in AliAnalysisTaskPIDqa
  //
  AliPIDResponse *pidres = new AliPIDResponse(kFALSE);
  //
  pidres->SetOADBPath("$ALICE_ROOT/OADB");
  pidres->SetCachePID(kFALSE);
  pidres->SetUseTPCEtaCorrection(kFALSE);
  pidres->SetUseTPCMultiplicityCorrection(kFALSE);
  pidres->SetTunedOnData(kFALSE,2);
  pidres->SetCurrentAliRootRev(62720);

  AliESDEvent *ev=new AliESDEvent;
  pidres->InitialiseEvent(ev,pass,run);

  const  Double_t first=pMin;
  const  Double_t last=pMax;
  const  Double_t expMax=TMath::Log(last/first);
  const  Int_t nbinsX=100;

  AliTPCPIDResponse &tpcpid=pidres->GetTPCResponse();

  for (Int_t i=0; i<AliPID::kSPECIES; ++i){
    if (i==AliPID::kMuon) continue;
    TGraph *gr=new TGraph;
    gr->SetNameTitle(Form("Spline_Graph_%s",AliPID::ParticleName(i)),Form("%s splines;p (GeV/#it{c});d#it{E}/d#it{x} (arb. units)",AliPID::ParticleName(i)));
    for (Int_t ip=0; ip<nbinsX; ++ip) {
      Double_t p=first*TMath::Exp(expMax/nbinsX*(Double_t)ip);
      Double_t dEdx=tpcpid.GetExpectedSignal(p,i);
      if (p<pMin || p>pMax || dEdx<dEdxMin || dEdx>dEdxMax ) continue;
      gr->SetPoint(gr->GetN(),p,dEdx);
    }
    gr->Draw("c");
    gr->SetLineWidth(2);
  }
}


 DrawTPCPIDSplines.C:1
 DrawTPCPIDSplines.C:2
 DrawTPCPIDSplines.C:3
 DrawTPCPIDSplines.C:4
 DrawTPCPIDSplines.C:5
 DrawTPCPIDSplines.C:6
 DrawTPCPIDSplines.C:7
 DrawTPCPIDSplines.C:8
 DrawTPCPIDSplines.C:9
 DrawTPCPIDSplines.C:10
 DrawTPCPIDSplines.C:11
 DrawTPCPIDSplines.C:12
 DrawTPCPIDSplines.C:13
 DrawTPCPIDSplines.C:14
 DrawTPCPIDSplines.C:15
 DrawTPCPIDSplines.C:16
 DrawTPCPIDSplines.C:17
 DrawTPCPIDSplines.C:18
 DrawTPCPIDSplines.C:19
 DrawTPCPIDSplines.C:20
 DrawTPCPIDSplines.C:21
 DrawTPCPIDSplines.C:22
 DrawTPCPIDSplines.C:23
 DrawTPCPIDSplines.C:24
 DrawTPCPIDSplines.C:25
 DrawTPCPIDSplines.C:26
 DrawTPCPIDSplines.C:27
 DrawTPCPIDSplines.C:28
 DrawTPCPIDSplines.C:29
 DrawTPCPIDSplines.C:30
 DrawTPCPIDSplines.C:31
 DrawTPCPIDSplines.C:32
 DrawTPCPIDSplines.C:33
 DrawTPCPIDSplines.C:34
 DrawTPCPIDSplines.C:35
 DrawTPCPIDSplines.C:36
 DrawTPCPIDSplines.C:37
 DrawTPCPIDSplines.C:38
 DrawTPCPIDSplines.C:39
 DrawTPCPIDSplines.C:40
 DrawTPCPIDSplines.C:41
 DrawTPCPIDSplines.C:42
 DrawTPCPIDSplines.C:43
 DrawTPCPIDSplines.C:44
 DrawTPCPIDSplines.C:45
 DrawTPCPIDSplines.C:46
 DrawTPCPIDSplines.C:47
 DrawTPCPIDSplines.C:48
 DrawTPCPIDSplines.C:49
 DrawTPCPIDSplines.C:50
 DrawTPCPIDSplines.C:51
 DrawTPCPIDSplines.C:52
 DrawTPCPIDSplines.C:53
 DrawTPCPIDSplines.C:54
 DrawTPCPIDSplines.C:55
 DrawTPCPIDSplines.C:56
 DrawTPCPIDSplines.C:57
 DrawTPCPIDSplines.C:58
 DrawTPCPIDSplines.C:59
 DrawTPCPIDSplines.C:60