LCOV - code coverage report
Current view: top level - ANALYSIS/ANALYSISalice - AliAnalysisTaskPIDqa.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 1195 0.1 %
Date: 2016-06-14 17:26:59 Functions: 1 40 2.5 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : 
      16             : /* $Id: AliAnalysisTaskPIDqa.cxx 43811 2010-09-23 14:13:31Z wiechula $ */
      17             : #include <TList.h>
      18             : #include <TVectorD.h>
      19             : #include <TObjArray.h>
      20             : #include <TH2.h>
      21             : #include <TFile.h>
      22             : #include <TPRegexp.h>
      23             : #include <TChain.h>
      24             : #include <TF1.h>
      25             : #include <TSpline.h>
      26             : 
      27             : #include <AliAnalysisManager.h>
      28             : #include <AliInputEventHandler.h>
      29             : #include <AliVEventHandler.h>
      30             : #include <AliVEvent.h>
      31             : #include <AliVParticle.h>
      32             : #include <AliVTrack.h>
      33             : #include <AliLog.h>
      34             : #include <AliPID.h>
      35             : #include <AliPIDResponse.h>
      36             : #include <AliITSPIDResponse.h>
      37             : #include <AliTPCPIDResponse.h>
      38             : #include <AliTRDPIDResponse.h>
      39             : #include <AliTOFPIDResponse.h>
      40             : #include <AliTPCdEdxInfo.h>
      41             : 
      42             : #include <AliESDEvent.h>
      43             : #include <AliAODEvent.h>
      44             : #include <AliESDv0.h>
      45             : #include <AliAODv0.h>
      46             : #include <AliESDv0KineCuts.h>
      47             : #include <AliESDtrackCuts.h>
      48             : 
      49             : #include <AliMCEvent.h>
      50             : 
      51             : #include "AliAnalysisTaskPIDqa.h"
      52             : 
      53             : 
      54         170 : ClassImp(AliAnalysisTaskPIDqa)
      55             : 
      56             : //______________________________________________________________________________
      57             : AliAnalysisTaskPIDqa::AliAnalysisTaskPIDqa():
      58           0 : AliAnalysisTaskSE(),
      59           0 : fPIDResponse(0x0),
      60           0 : fV0cuts(0x0),
      61           0 : fV0electrons(0x0),
      62           0 : fV0pions(0x0),
      63           0 : fV0kaons(0x0),
      64           0 : fV0protons(0x0),
      65           0 : fListQA(0x0),
      66           0 : fListQAits(0x0),
      67           0 : fListQAitsSA(0x0),
      68           0 : fListQAitsPureSA(0x0),
      69           0 : fListQAtpc(0x0),
      70           0 : fListQAtpcBasic(0x0),
      71           0 : fListQAtpcMCtruth(0x0),
      72             : //fListQAtpcHybrid(0x0), // -> not used and commented for now
      73             : //fListQAtpcOROChigh(0x0), // -> not used and commented for now
      74           0 : fListQAtpcV0(0x0),
      75           0 : fListQAtrd(0x0),
      76           0 : fListQAtrdNsig(0x0),
      77           0 : fListQAtrdNsigTPCTOF(0x0),
      78           0 : fListQAtof(0x0),
      79           0 : fListQAt0(0x0),
      80           0 : fListQAemcal(0x0),
      81           0 : fListQAhmpid(0x0),
      82           0 : fListQAtofhmpid(0x0),
      83           0 : fListQAtpctof(0x0),
      84           0 : fListQAV0(0x0),
      85           0 : fListQAinfo(0x0)
      86           0 : {
      87             :   //
      88             :   // Dummy constructor
      89             :   //
      90           0 : }
      91             : 
      92             : //______________________________________________________________________________
      93             : AliAnalysisTaskPIDqa::AliAnalysisTaskPIDqa(const char* name):
      94           0 : AliAnalysisTaskSE(name),
      95           0 : fPIDResponse(0x0),
      96           0 : fV0cuts(0x0),
      97           0 : fV0electrons(0x0),
      98           0 : fV0pions(0x0),
      99           0 : fV0kaons(0x0),
     100           0 : fV0protons(0x0),
     101           0 : fListQA(0x0),
     102           0 : fListQAits(0x0),
     103           0 : fListQAitsSA(0x0),
     104           0 : fListQAitsPureSA(0x0),
     105           0 : fListQAtpc(0x0),
     106           0 : fListQAtpcBasic(0x0),
     107           0 : fListQAtpcMCtruth(0x0),
     108             : //fListQAtpcHybrid(0x0), // -> not used and commented for now
     109             : //fListQAtpcOROChigh(0x0), // -> not used and commented for now
     110           0 : fListQAtpcV0(0x0),
     111           0 : fListQAtrd(0x0),
     112           0 : fListQAtrdNsig(0x0),
     113           0 : fListQAtrdNsigTPCTOF(0x0),
     114           0 : fListQAtof(0x0),
     115           0 : fListQAt0(0x0),
     116           0 : fListQAemcal(0x0),
     117           0 : fListQAhmpid(0x0),
     118           0 : fListQAtofhmpid(0x0),
     119           0 : fListQAtpctof(0x0),
     120           0 : fListQAV0(0x0),
     121           0 : fListQAinfo(0x0)
     122           0 : {
     123             :   //
     124             :   // Default constructor
     125             :   //
     126           0 :   DefineInput(0,TChain::Class());
     127           0 :   DefineOutput(1,TList::Class());
     128           0 : }
     129             : 
     130             : //______________________________________________________________________________
     131             : AliAnalysisTaskPIDqa::~AliAnalysisTaskPIDqa()
     132           0 : {
     133             :   //
     134             :   // Destructor
     135             :   //
     136             : 
     137           0 :   delete fV0cuts;
     138           0 :   delete fV0electrons;
     139           0 :   delete fV0pions;
     140           0 :   delete fV0kaons;
     141           0 :   delete fV0protons;
     142             : 
     143           0 :   if (!AliAnalysisManager::GetAnalysisManager()->IsProofMode()) delete fListQA;
     144           0 : }
     145             : 
     146             : //______________________________________________________________________________
     147             : void AliAnalysisTaskPIDqa::UserCreateOutputObjects()
     148             : {
     149             :   //
     150             :   // Create the output QA objects
     151             :   //
     152             : 
     153           0 :   AliLog::SetClassDebugLevel("AliAnalysisTaskPIDqa",10);
     154             : 
     155             :   //input hander
     156           0 :   AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
     157           0 :   AliInputEventHandler *inputHandler=dynamic_cast<AliInputEventHandler*>(man->GetInputEventHandler());
     158           0 :   if (!inputHandler) AliFatal("Input handler needed");
     159             : 
     160             :   //pid response object
     161           0 :   fPIDResponse=inputHandler->GetPIDResponse();
     162           0 :   if (!fPIDResponse) AliError("PIDResponse object was not created");
     163             :   
     164             :   // V0 Kine cuts 
     165           0 :   fV0cuts = new AliESDv0KineCuts;
     166             :  
     167             :   // V0 PID Obj arrays
     168           0 :   fV0electrons = new TObjArray;
     169           0 :   fV0pions     = new TObjArray;
     170           0 :   fV0kaons     = new TObjArray;
     171           0 :   fV0protons   = new TObjArray;
     172             : 
     173             :   //
     174           0 :   fListQA=new TList;
     175           0 :   fListQA->SetOwner();
     176             :   
     177           0 :   fListQAits=new TList;
     178           0 :   fListQAits->SetOwner();
     179           0 :   fListQAits->SetName("ITS");
     180             : 
     181           0 :   fListQAitsSA=new TList;
     182           0 :   fListQAitsSA->SetOwner();
     183           0 :   fListQAitsSA->SetName("ITS_SA");
     184             : 
     185           0 :   fListQAitsPureSA=new TList;
     186           0 :   fListQAitsPureSA->SetOwner();
     187           0 :   fListQAitsPureSA->SetName("ITS_PureSA");
     188             : 
     189           0 :   fListQAtpc=new TList;
     190           0 :   fListQAtpc->SetOwner();
     191           0 :   fListQAtpc->SetName("TPC");
     192             : 
     193           0 :   fListQAtrd=new TList;
     194           0 :   fListQAtrd->SetOwner();
     195           0 :   fListQAtrd->SetName("TRD");
     196             : 
     197           0 :   fListQAtrdNsig=new TList;
     198           0 :   fListQAtrdNsig->SetOwner();
     199           0 :   fListQAtrdNsig->SetName("TRDnSigma");
     200             :   
     201           0 :   fListQAtrdNsigTPCTOF=new TList;
     202           0 :   fListQAtrdNsigTPCTOF->SetOwner();
     203           0 :   fListQAtrdNsigTPCTOF->SetName("TRDnSigma_TPCTOF");
     204             :   
     205           0 :   fListQAtof=new TList;
     206           0 :   fListQAtof->SetOwner();
     207           0 :   fListQAtof->SetName("TOF");
     208             : 
     209           0 :   fListQAt0=new TList;
     210           0 :   fListQAt0->SetOwner();
     211           0 :   fListQAt0->SetName("T0");
     212             :   
     213           0 :   fListQAemcal=new TList;
     214           0 :   fListQAemcal->SetOwner();
     215           0 :   fListQAemcal->SetName("EMCAL");
     216             :   
     217           0 :   fListQAhmpid=new TList;
     218           0 :   fListQAhmpid->SetOwner();
     219           0 :   fListQAhmpid->SetName("HMPID");
     220             :   
     221           0 :   fListQAtpctof=new TList;
     222           0 :   fListQAtpctof->SetOwner();
     223           0 :   fListQAtpctof->SetName("TPC_TOF");
     224             : 
     225           0 :   fListQAtofhmpid=new TList;
     226           0 :   fListQAtofhmpid->SetOwner();
     227           0 :   fListQAtofhmpid->SetName("TOF_HMPID");
     228             :   
     229           0 :   fListQAV0=new TList;
     230           0 :   fListQAV0->SetOwner();
     231           0 :   fListQAV0->SetName("V0decay");
     232             : 
     233           0 :   fListQAinfo=new TList;
     234           0 :   fListQAinfo->SetOwner();
     235           0 :   fListQAinfo->SetName("QAinfo");
     236             :   
     237           0 :   fListQA->Add(fListQAits);
     238           0 :   fListQA->Add(fListQAitsSA);
     239           0 :   fListQA->Add(fListQAitsPureSA);
     240           0 :   fListQA->Add(fListQAtpc);
     241           0 :   fListQA->Add(fListQAtrd);
     242           0 :   fListQA->Add(fListQAtof);
     243           0 :   fListQA->Add(fListQAt0);
     244           0 :   fListQA->Add(fListQAemcal);
     245           0 :   fListQA->Add(fListQAhmpid);
     246           0 :   fListQA->Add(fListQAtpctof);
     247           0 :   fListQA->Add(fListQAtofhmpid);
     248           0 :   fListQA->Add(fListQAV0);
     249           0 :   fListQA->Add(fListQAinfo);
     250             : 
     251           0 :   SetupITSqa();
     252             : //  SetupTPCqa(kFALSE, kTRUE, kFALSE); // is called in first call of FillTPCqa
     253           0 :   SetupTRDqa();
     254           0 :   SetupTOFqa();
     255           0 :   SetupT0qa();
     256           0 :   SetupEMCALqa();
     257           0 :   SetupHMPIDqa();
     258           0 :   SetupTPCTOFqa();
     259           0 :   SetupTOFHMPIDqa();
     260           0 :   SetupV0qa();
     261           0 :   SetupQAinfo();
     262             :   
     263           0 :   PostData(1,fListQA);
     264           0 : }
     265             : 
     266             : 
     267             : //______________________________________________________________________________
     268             : void AliAnalysisTaskPIDqa::UserExec(Option_t */*option*/)
     269             : {
     270             :   //
     271             :   // Setup the PID response functions and fill the QA histograms
     272             :   //
     273             : 
     274           0 :   AliVEvent *event=InputEvent();
     275           0 :   if (!event||!fPIDResponse) return;
     276             : 
     277             :   // Start with the V0 task (only possible for ESDs?)
     278           0 :   FillV0PIDlist();
     279             :   
     280           0 :   FillITSqa();
     281           0 :   FillTPCqa();
     282           0 :   FillTRDqa();
     283           0 :   FillTOFqa();
     284           0 :   FillEMCALqa();
     285           0 :   FillHMPIDqa();
     286           0 :   FillT0qa();
     287             :   
     288             :   //combined detector QA
     289           0 :   FillTPCTOFqa();
     290           0 :   FillTOFHMPIDqa();
     291             :   
     292             :   // Clear the V0 PID arrays
     293           0 :   ClearV0PIDlist();
     294             : 
     295             :   //QA info
     296           0 :   FillQAinfo();
     297             :   
     298           0 :   PostData(1,fListQA);
     299           0 : }
     300             : 
     301             : //______________________________________________________________________________
     302             : void  AliAnalysisTaskPIDqa::FillV0PIDlist(){
     303             : 
     304             :   //
     305             :   // Fill the PID object arrays holding the pointers to identified particle tracks
     306             :   //
     307             : 
     308             :   // Dynamic cast to ESD events (DO NOTHING for AOD events)
     309           0 :   AliESDEvent *event = dynamic_cast<AliESDEvent *>(InputEvent());
     310           0 :   if ( !event )  return;
     311             :   
     312           0 :   if(TString(event->GetBeamType())=="Pb-Pb" || TString(event->GetBeamType())=="A-A"){
     313           0 :     fV0cuts->SetMode(AliESDv0KineCuts::kPurity,AliESDv0KineCuts::kPbPb); 
     314           0 :   }
     315             :   else{
     316           0 :     fV0cuts->SetMode(AliESDv0KineCuts::kPurity,AliESDv0KineCuts::kPP); 
     317             :   }
     318             : 
     319             :   // V0 selection
     320             :   // set event
     321           0 :   fV0cuts->SetEvent(event);
     322             : 
     323             :   // loop over V0 particles
     324           0 :   for(Int_t iv0=0; iv0<event->GetNumberOfV0s();iv0++){
     325             : 
     326           0 :     AliESDv0 *v0 = (AliESDv0 *) event->GetV0(iv0);
     327             :  
     328           0 :     if(!v0) continue;
     329           0 :     if(v0->GetOnFlyStatus()) continue; 
     330             :   
     331             :     // Get the particle selection 
     332             :     Bool_t foundV0 = kFALSE;
     333           0 :     Int_t pdgV0, pdgP, pdgN;
     334             : 
     335           0 :     foundV0 = fV0cuts->ProcessV0(v0, pdgV0, pdgP, pdgN);
     336           0 :     if(!foundV0) continue;
     337             :     
     338           0 :     Int_t iTrackP = v0->GetPindex();  // positive track
     339           0 :     Int_t iTrackN = v0->GetNindex();  // negative track
     340             : 
     341             :     // v0 Armenteros plot (QA)
     342           0 :     Float_t armVar[2] = {0.0,0.0};
     343           0 :     fV0cuts->Armenteros(v0, armVar);
     344             : 
     345           0 :     TH2 *h=(TH2*)fListQAV0->At(0);
     346           0 :     if (!h) continue;
     347           0 :     h->Fill(armVar[0],armVar[1]);
     348             : 
     349             :     // fill the Object arrays
     350             :     // positive particles
     351           0 :     if( pdgP == -11){
     352           0 :       fV0electrons->Add((AliVTrack*)event->GetTrack(iTrackP));
     353           0 :     }
     354           0 :     else if( pdgP == 211){
     355           0 :       fV0pions->Add((AliVTrack*)event->GetTrack(iTrackP));
     356           0 :     }
     357           0 :     else if( pdgP == 321){
     358           0 :       fV0kaons->Add((AliVTrack*)event->GetTrack(iTrackP));
     359           0 :     }
     360           0 :     else if( pdgP == 2212){
     361           0 :       fV0protons->Add((AliVTrack*)event->GetTrack(iTrackP));
     362           0 :     }
     363             : 
     364             :     // negative particles
     365           0 :     if( pdgN == 11){
     366           0 :       fV0electrons->Add((AliVTrack*)event->GetTrack(iTrackN));
     367           0 :     }
     368           0 :     else if( pdgN == -211){
     369           0 :       fV0pions->Add((AliVTrack*)event->GetTrack(iTrackN));
     370           0 :     }
     371           0 :     else if( pdgN == -321){
     372           0 :       fV0kaons->Add((AliVTrack*)event->GetTrack(iTrackN));
     373           0 :     }
     374           0 :     else if( pdgN == -2212){
     375           0 :       fV0protons->Add((AliVTrack*)event->GetTrack(iTrackN));
     376           0 :     }
     377             :   
     378             : 
     379           0 :   }
     380           0 : }
     381             : //______________________________________________________________________________
     382             : void  AliAnalysisTaskPIDqa::ClearV0PIDlist(){
     383             : 
     384             :   //
     385             :   // Clear the PID object arrays
     386             :   //
     387             : 
     388           0 :   fV0electrons->Clear();
     389           0 :   fV0pions->Clear();
     390           0 :   fV0kaons->Clear();
     391           0 :   fV0protons->Clear();
     392             : 
     393           0 : }
     394             : //______________________________________________________________________________
     395             : void AliAnalysisTaskPIDqa::FillITSqa()
     396             : {
     397             :   //
     398             :   // Fill PID qa histograms for the ITS
     399             :   //
     400             : 
     401           0 :   AliVEvent *event=InputEvent();
     402             :   
     403           0 :   Int_t ntracks=event->GetNumberOfTracks();
     404           0 :   for(Int_t itrack = 0; itrack < ntracks; itrack++){
     405           0 :     AliVTrack *track=(AliVTrack*)event->GetTrack(itrack);
     406           0 :     ULong_t status=track->GetStatus();
     407             :     // not that nice. status bits not in virtual interface
     408             :     // ITS refit + ITS pid selection
     409           0 :     if (!( ( (status & AliVTrack::kITSrefit)==AliVTrack::kITSrefit ) ||
     410           0 :            ! ( (status & AliVTrack::kITSpid  )==AliVTrack::kITSpid   ) )) continue;
     411           0 :     Double_t mom=track->P();
     412             :     
     413             :     TList *theList = 0x0;
     414           0 :     if(( (status & AliVTrack::kTPCin)==AliVTrack::kTPCin )){
     415             :       //ITS+TPC tracks
     416           0 :       theList=fListQAits;
     417           0 :     }else{
     418           0 :       if(!( (status & AliVTrack::kITSpureSA)==AliVTrack::kITSpureSA )){ 
     419             :         //ITS Standalone tracks
     420           0 :         theList=fListQAitsSA;
     421           0 :       }else{
     422             :         //ITS Pure Standalone tracks
     423           0 :         theList=fListQAitsPureSA;
     424             :       }
     425             :     }
     426             :     
     427             :     
     428           0 :     for (Int_t ispecie=0; ispecie<AliPID::kSPECIESC; ++ispecie){
     429           0 :       TH2 *h=(TH2*)theList->At(ispecie);
     430           0 :       if (!h) continue;
     431           0 :       Double_t nSigma=fPIDResponse->NumberOfSigmasITS(track, (AliPID::EParticleType)ispecie);
     432           0 :       h->Fill(mom,nSigma);
     433           0 :     }
     434           0 :     TH2 *h=(TH2*)theList->At(AliPID::kSPECIESC);
     435           0 :     if (h) {
     436           0 :       Double_t sig=track->GetITSsignal();
     437           0 :       h->Fill(mom,sig);
     438           0 :     }
     439           0 :   }
     440           0 : }
     441             : 
     442             : 
     443             : //______________________________________________________________________________
     444             : void AliAnalysisTaskPIDqa::FillTPCHistogramsSignal(TList *sublist, Int_t scenario, AliVTrack *track, Int_t mult)
     445             : {
     446             :   //
     447             :   // Fill PID qa histograms for the TPC: Fill the histograms for the TPC signal for different settings
     448             :   //
     449             : 
     450             :   // List of possible scenarios with the numbering scheme (for information only):
     451             :   // scenario ==  0 : Basic
     452             :   // scenario ==  1 : MCtruth
     453             :   // scenario ==  2 : Hybrid (only for LHC11h) -> not used and commented now
     454             :   // scenario ==  3 : OROChigh (only for LHC11h) -> not used and commented now
     455             :   // scenario == 40 : V0 - Electrons
     456             :   // scenario == 41 : V0 - Muons (not implemented)
     457             :   // scenario == 42 : V0 - Pions
     458             :   // scenario == 43 : V0 - Kaons (not filled)
     459             :   // scenario == 44 : V0 - Protons
     460             : 
     461           0 :   AliMCEvent *eventMC=MCEvent();  // MC event for MC truth PID
     462             : 
     463             :   Double_t mom=0.;      // track momentum
     464             :   Double_t eta=0.;      // track eta
     465             :   Double_t phi=0.;      // track phi
     466             :   Double_t sig=0.;      // TPC dE/dx signal
     467             :   Double_t sigStd=0.;         // TPC dE/dx signal (standard = all ROCs)
     468             :   Double_t sigIROC=0.;        // TPC dE/dx signal (IROC) 
     469             :   Double_t sigOROCmedium=0.;  // TPC dE/dx signal (OROCmedium) 
     470             :   Double_t sigOROClong=0.;    // TPC dE/dx signal (OROClong) 
     471             :   Double_t eleLineDist=0.;    // difference between TPC signal and electron expectation
     472             :   Int_t trackLabel=0;   // label of the AliVTrack to identify the corresponding MCtrack
     473             :   Int_t pdgCode=0;      // pdgcode of MC track for MC truth scenario
     474             :   Int_t pdgCodeAbs=0;   // absolute value of pdgcode to get both particles and antiparticles
     475             :   Int_t iSigMax=1;      // number of TPC signals (std = 1, set automatically higher if available)
     476             :   Int_t nSpecies=0;     // number of particle species under study (can be changed, e.g. in case of V0s)
     477             :   Int_t count=0;        // counter for the number of plot sets for all species (i.e. nsigma vs. p, eta and mult)
     478             :   Int_t count2=0;       // counter of extra nsigma plots (only for some scenarios)
     479             :   Int_t count3=0;       // counter of extra nsigma vs. p plots (only V0 scenario)
     480             :   Int_t count4=0;       // yet another counter for the V0 scenario
     481             : 
     482           0 :   mom=track->GetTPCmomentum();
     483           0 :   eta=track->Eta();
     484           0 :   phi=track->Phi();
     485             : //   sigStd=track->GetTPCsignal();
     486           0 :   sigStd=fPIDResponse->GetTPCResponse().GetTrackdEdx(track);
     487             : 
     488           0 :   eleLineDist=sigStd-fPIDResponse->GetTPCResponse().GetExpectedSignal(track,AliPID::kElectron);
     489             : 
     490             :   // Get number of particle species (less for V0 candidates = scenarios 40-44)
     491           0 :   if (scenario > 39) nSpecies=(Int_t)AliPID::kSPECIES;
     492             :   else nSpecies=(Int_t)AliPID::kSPECIESC;
     493             : 
     494             :   // nSpecies is changed in case of V0, due to Muons and Kaons not being filled
     495           0 :   if (scenario>39) nSpecies=nSpecies-2;
     496             : 
     497             :   // Set number of plot sets for all species
     498             :   // (i.e. only nsigma vs. p => count=1; also vs. eta and mult => count=3)
     499           0 :   if ( scenario == 1 || scenario > 39 ) count=3; // MCtruth (scenario==1) and V0 (scenario>39)
     500             :   else count=1;
     501             : 
     502             :   // Set number of extra nsigma plots (only for some scenarios)
     503             :   // (i.e. nsigma vs. eta and mult separately for MIPpions and for electrons)
     504             : //  if ( scenario == 0 || scenario == 2 || scenario == 3 ) count2=4; // Basic, Hybrid, OROClong
     505           0 :   if ( scenario == 0 ) count2=4; // Basic
     506             :   else count2=0;
     507             : 
     508             :   // Get MC track ( --> can be deleted if TPC signal is NOT filled for scenario=1 (MC truth)
     509           0 :   if (eventMC) {
     510           0 :     trackLabel=TMath::Abs(track->GetLabel());
     511           0 :     AliVTrack *mcTrack=(AliVTrack*)eventMC->GetTrack(trackLabel);
     512           0 :     pdgCode=mcTrack->PdgCode();
     513           0 :     pdgCodeAbs=TMath::Abs(pdgCode);
     514           0 :   }
     515             : 
     516             :   // Get TPC dE/dx info and different TPC signals (IROC, OROCmedium, OROClong)
     517             :   AliTPCdEdxInfo* fTPCdEdxInfo = 0x0;
     518           0 :   fTPCdEdxInfo = track->GetTPCdEdxInfo();
     519             : 
     520           0 :   if (fTPCdEdxInfo) {
     521           0 :     sigIROC=fTPCdEdxInfo->GetTPCsignalShortPad();
     522           0 :     sigOROCmedium=fTPCdEdxInfo->GetTPCsignalMediumPad();
     523           0 :     sigOROClong=fTPCdEdxInfo->GetTPCsignalLongPad();
     524             :     iSigMax=4;
     525             : 
     526             :     //printf("mom = %.3f  sigStd = %.3f  sigIROC = %.3f  sigOROCmedium = %.3f  sigOROClong = %.3f \n",mom,sigStd,sigIROC,sigOROCmedium,sigOROClong);
     527           0 :   }
     528             : 
     529             : 
     530             :   // TPC signal vs. momentum (for different particle species (V0s) or all particles (other scenarios))
     531           0 :   if (scenario > 39) {
     532             :     // TPC signal for different particle species vs. momentum (standard, IROC, OROCmedium, OROClong)
     533             :     count3=8;
     534           0 :     if (scenario == 40) count4=0;
     535           0 :     else if (scenario == 42) count4=4;
     536           0 :     else if (scenario == 44) count4=8;
     537           0 :     TH2 *h1std=(TH2*)sublist->At(count*nSpecies+count2+count4); 
     538           0 :     if (h1std) {
     539           0 :       h1std->Fill(mom,sigStd);
     540           0 :     }
     541             : 
     542           0 :     TH2 *h1iroc=(TH2*)sublist->At(count*nSpecies+count2+count4+1);
     543           0 :     if ( h1iroc && sigIROC ) {
     544           0 :       h1iroc->Fill(mom,sigIROC);
     545           0 :     }
     546             : 
     547           0 :     TH2 *h1orocm=(TH2*)sublist->At(count*nSpecies+count2+count4+2);
     548           0 :     if  (h1orocm && sigOROCmedium ) {
     549           0 :       h1orocm->Fill(mom,sigOROCmedium);
     550           0 :     }
     551             : 
     552           0 :     TH2 *h1orocl=(TH2*)sublist->At(count*nSpecies+count2+count4+3);
     553           0 :     if ( h1orocl && sigOROClong ) {
     554           0 :       h1orocl->Fill(mom,sigOROClong);
     555           0 :     }
     556           0 :   }
     557             :   else {
     558             :     // TPC signal for all particles vs. momentum (standard, IROC, OROCmedium, OROClong)
     559           0 :     TH2 *h1std=(TH2*)sublist->At(count*nSpecies+count2); 
     560           0 :     if (h1std) {
     561           0 :       h1std->Fill(mom,sigStd);
     562           0 :     }
     563             : 
     564           0 :     TH2 *h1iroc=(TH2*)sublist->At(count*nSpecies+count2+1);
     565           0 :     if ( h1iroc && sigIROC ) {
     566           0 :       h1iroc->Fill(mom,sigIROC);
     567           0 :     }
     568             : 
     569           0 :     TH2 *h1orocm=(TH2*)sublist->At(count*nSpecies+count2+2);
     570           0 :     if  (h1orocm && sigOROCmedium ) {
     571           0 :       h1orocm->Fill(mom,sigOROCmedium);
     572           0 :     }
     573             : 
     574           0 :     TH2 *h1orocl=(TH2*)sublist->At(count*nSpecies+count2+3);
     575           0 :     if ( h1orocl && sigOROClong ) {
     576           0 :       h1orocl->Fill(mom,sigOROClong);
     577           0 :     }
     578             :   }
     579             : 
     580             : 
     581             :   // - Beginn: MIP pions: TPC signal vs. eta, phi and  mult -
     582           0 :   if (mom>0.45 && mom<0.5 && sigStd>40 && sigStd<60) {
     583           0 :    if (scenario < 40 || scenario == 42) { // if scenario is "V0" then only take pions
     584             : 
     585             :     Bool_t isPionMC=kTRUE;
     586             : 
     587           0 :     if (scenario == 1) {
     588           0 :       if ( pdgCodeAbs != 211 && pdgCodeAbs != 111 ) isPionMC=kFALSE;
     589             :     }
     590             : 
     591             :     // MIP pions: TPC signal vs. eta (standard, IROC, OROCmedium, OROClong)
     592           0 :     for (Int_t iSig=0; iSig<iSigMax; iSig++) {
     593           0 :       if (iSig==0) sig=sigStd;
     594           0 :       else if (iSig==1) sig=sigIROC;
     595           0 :       else if (iSig==2) sig=sigOROCmedium;
     596           0 :       else if (iSig==3) sig=sigOROClong;
     597             : 
     598           0 :       TH2 *h2=(TH2*)sublist->At(count*nSpecies+count2+count3+4+iSig);
     599           0 :       if ( h2 && isPionMC ) {
     600           0 :         h2->Fill(eta,sig);
     601           0 :       }
     602             :     }
     603             : 
     604             :     // MIP pions: TPC signal vs. phi (standard, IROC, OROCmedium, OROClong)
     605           0 :     for (Int_t iSig=0; iSig<iSigMax; iSig++) {
     606           0 :       if (iSig==0) sig=sigStd;
     607           0 :       else if (iSig==1) sig=sigIROC;
     608           0 :       else if (iSig==2) sig=sigOROCmedium;
     609           0 :       else if (iSig==3) sig=sigOROClong;
     610             : 
     611           0 :       TH2 *h2=(TH2*)sublist->At(count*nSpecies+count2+count3+8+iSig);
     612           0 :       if ( h2 && isPionMC ) {
     613           0 :         h2->Fill(phi,sig);
     614           0 :       }
     615             :     }
     616             : 
     617             :     // MIP pions: TPC signal vs. mult (standard, IROC, OROCmedium, OROClong)
     618           0 :     for (Int_t iSig=0; iSig<iSigMax; iSig++) {
     619           0 :       if (iSig==0) sig=sigStd;
     620           0 :       else if (iSig==1) sig=sigIROC;
     621           0 :       else if (iSig==2) sig=sigOROCmedium;
     622           0 :       else if (iSig==3) sig=sigOROClong;
     623             : 
     624           0 :       TH2 *h3=(TH2*)sublist->At(count*nSpecies+count2+count3+12+iSig);
     625           0 :       if ( h3 && isPionMC && mult > 0 ) {
     626           0 :         h3->Fill(mult,sig);
     627           0 :       }
     628             :     }
     629           0 :    }
     630             :   } // - End: MIP pions -
     631             : 
     632             :   // - Beginn: Electrons: TPC signal vs. eta, phi and mult -
     633           0 :   if (mom>0.32 && mom<0.38 && eleLineDist>-10. && eleLineDist<15.) {
     634           0 :    if (scenario < 40 || scenario == 40) { // if scenario is "V0" then only take electrons
     635             : 
     636             :     Bool_t isElectronMC=kTRUE;
     637             : 
     638           0 :     if (scenario == 1) {
     639           0 :       if ( pdgCodeAbs != 11 ) isElectronMC=kFALSE;
     640             :     }
     641             : 
     642             :     // Electrons: TPC signal vs. eta (standard, IROC, OROCmedium, OROClong)
     643           0 :     for (Int_t iSig=0; iSig<iSigMax; iSig++) {
     644           0 :       if (iSig==0) sig=sigStd;
     645           0 :       else if (iSig==1) sig=sigIROC;
     646           0 :       else if (iSig==2) sig=sigOROCmedium;
     647           0 :       else if (iSig==3) sig=sigOROClong;
     648             : 
     649           0 :       TH2 *h4=(TH2*)sublist->At(count*nSpecies+count2+count3+16+iSig);
     650           0 :       if ( h4 && isElectronMC ) {
     651           0 :         h4->Fill(eta,sig);
     652           0 :       }
     653             :     }
     654             : 
     655             :     // Electrons: TPC signal vs. phi (standard, IROC, OROCmedium, OROClong)
     656           0 :     for (Int_t iSig=0; iSig<iSigMax; iSig++) {
     657           0 :       if (iSig==0) sig=sigStd;
     658           0 :       else if (iSig==1) sig=sigIROC;
     659           0 :       else if (iSig==2) sig=sigOROCmedium;
     660           0 :       else if (iSig==3) sig=sigOROClong;
     661             : 
     662           0 :       TH2 *h4=(TH2*)sublist->At(count*nSpecies+count2+count3+20+iSig);
     663           0 :       if ( h4 && isElectronMC ) {
     664           0 :         h4->Fill(phi,sig);
     665           0 :       }
     666             :     }
     667             : 
     668             :     // Electrons: TPC signal vs. mult (standard, IROC, OROCmedium, OROClong)
     669           0 :     for (Int_t iSig=0; iSig<iSigMax; iSig++) {
     670           0 :       if (iSig==0) sig=sigStd;
     671           0 :       else if (iSig==1) sig=sigIROC;
     672           0 :       else if (iSig==2) sig=sigOROCmedium;
     673           0 :       else if (iSig==3) sig=sigOROClong;
     674             : 
     675           0 :       TH2 *h5=(TH2*)sublist->At(count*nSpecies+count2+count3+24+iSig);
     676           0 :       if ( h5 && isElectronMC && mult > 0 ) {
     677           0 :         h5->Fill(mult,sig);
     678           0 :       }
     679             :     }
     680           0 :    }
     681             :   } // - End: Electrons -
     682             : 
     683           0 : }
     684             : 
     685             : //______________________________________________________________________________
     686             : void AliAnalysisTaskPIDqa::FillTPCHistogramsNsigma(TList *sublist, Int_t scenario, AliVTrack *track, Int_t mult)
     687             : {
     688             :   //
     689             :   // Fill PID qa histograms for the TPC: Fill the histograms for TPC Nsigma for different settings
     690             :   //
     691             : 
     692             :   // List of possible scenarios with the numbering scheme (for information only):
     693             :   // scenario ==  0 : Basic
     694             :   // scenario ==  1 : MCtruth
     695             :   // scenario ==  2 : Hybrid (only for LHC11h) -> not used and commented now
     696             :   // scenario ==  3 : OROChigh (only for LHC11h) -> not used and commented now
     697             :   // scenario == 40 : V0 - Electrons
     698             :   // scenario == 41 : V0 - Muons (not implemented)
     699             :   // scenario == 42 : V0 - Pions
     700             :   // scenario == 43 : V0 - Kaons (not filled)
     701             :   // scenario == 44 : V0 - Protons
     702             : 
     703           0 :   AliMCEvent *eventMC=MCEvent();  // MC event for MC truth PID
     704             : 
     705             :   Double_t mom=0.;      // track momentum
     706             :   Double_t eta=0.;      // track eta
     707             :   Double_t nSigma=0.;   // number of sigmas wrt. expected signal
     708             :   Double_t sig=0.;      // TPC dE/dx signal
     709             :   Double_t eleLineDist=0.;  // difference between TPC signal and electron expectation
     710             :   Int_t trackLabel=0;   // label of the AliVTrack to identify the corresponding MCtrack
     711             :   Int_t pdgCode=0;      // pdgcode of MC track for MC truth scenario
     712             :   Int_t pdgCodeAbs=0;   // absolute value of pdgcode to get both particles and antiparticles
     713             :   Int_t nSpecies=0;     // number of particle species under study (can be changed, e.g. in case of V0s)
     714             :   Int_t numberSpecies=0;   // number of particle species under study (stays constant for one scenario)
     715             :   Int_t mvSpecie=0;     // "move Specie", needed for V0s, as Muons and Kaons are not filled
     716             :   Int_t count=0;        // counter for the number of plot sets for all species (i.e. vs. p, eta and mult)
     717             : 
     718           0 :   mom=track->GetTPCmomentum();
     719           0 :   eta=track->Eta();
     720             : //   sig=track->GetTPCsignal();
     721           0 :   sig=fPIDResponse->GetTPCResponse().GetTrackdEdx(track);
     722             : 
     723           0 :   eleLineDist=sig-fPIDResponse->GetTPCResponse().GetExpectedSignal(track,AliPID::kElectron);
     724             : 
     725             :   // Get number of particle species (less for V0 candidates = scenarios 40-44)
     726           0 :   if (scenario > 39) nSpecies=(Int_t)AliPID::kSPECIES;
     727             :   else nSpecies=(Int_t)AliPID::kSPECIESC;
     728             : 
     729             :   // numberSpecies always keeps the value obtained by AliPID::kSPECIES(C)
     730             :   numberSpecies=nSpecies;
     731             : 
     732             :   // nSpecies is changed in case of V0, due to Muons and Kaons not being filled
     733           0 :   if (scenario>39) nSpecies=nSpecies-2;
     734             : 
     735             :   // Set number of plot sets for all species
     736             :   // (i.e. only vs. p => count=1; also vs. eta and mult => count=3)
     737           0 :   if ( scenario == 1 || scenario > 39 ) count=3; // MCtruth (scenario==1) and V0 (scenario>39)
     738             :   else count=1;
     739             : 
     740             :   // Get MC track
     741           0 :   if (eventMC) {
     742           0 :     trackLabel=TMath::Abs(track->GetLabel());
     743           0 :     AliVTrack *mcTrack=(AliVTrack*)eventMC->GetTrack(trackLabel);
     744           0 :     pdgCode=mcTrack->PdgCode();
     745           0 :     pdgCodeAbs=TMath::Abs(pdgCode);
     746           0 :   }
     747             : 
     748             :   // - Beginn: Nsigma vs. p, vs. eta and vs. multiplicity for different particle species -
     749           0 :   for (Int_t ispecie=0; ispecie<numberSpecies; ++ispecie){
     750             : 
     751           0 :     if (scenario == 1) {
     752           0 :       if ( ispecie == 0 && pdgCodeAbs != 11 ) continue;  // Electron
     753           0 :       if ( ispecie == 1 && pdgCodeAbs != 13 ) continue;  // Muon
     754           0 :       if ( ispecie == 2 && pdgCodeAbs != 211 && pdgCodeAbs!=111 ) continue;  // Pion
     755           0 :       if ( ispecie == 3 && pdgCodeAbs != 321 && pdgCodeAbs!=311 ) continue;  // Kaon
     756           0 :       if ( ispecie == 4 && pdgCodeAbs != 2212 ) continue;  // Proton
     757           0 :       if ( ispecie == 5 && pdgCodeAbs != 1000010020 ) continue;  // Deuteron
     758           0 :       if ( ispecie == 6 && pdgCodeAbs != 1000010030 ) continue;  // Triton
     759           0 :       if ( ispecie == 7 && pdgCodeAbs != 1000020030 ) continue;  // Helium-3
     760           0 :       if ( ispecie == 8 && pdgCodeAbs != 1000020040 ) continue;  // Alpha
     761             :     }
     762           0 :     else if (scenario == 40) {
     763           0 :       if ( ispecie != 0 ) continue;    // Electron
     764             :     }
     765           0 :     else if (scenario == 41) continue; // Muon (not filled)
     766           0 :     else if (scenario == 42) {
     767           0 :       if ( ispecie != 2 ) continue;    // Pion
     768             :     }
     769           0 :     else if (scenario == 43) continue; // Kaon (not filled)
     770           0 :     else if (scenario == 44) {
     771           0 :       if ( ispecie != 4 ) continue;    // Proton
     772             :     }
     773             : 
     774             : /* // special LHC11h setting not used and commented now
     775             :     if (scenario == 2) {
     776             :       nSigma=fPIDResponse->NumberOfSigmasTPC(track, (AliPID::EParticleType)ispecie, AliTPCPIDResponse::kdEdxHybrid);
     777             :     }
     778             :     else if (scenario == 3) {
     779             :       nSigma=fPIDResponse->NumberOfSigmasTPC(track, (AliPID::EParticleType)ispecie, AliTPCPIDResponse::kdEdxOROC);
     780             :     }
     781             : */
     782             : //    else {
     783           0 :       nSigma=fPIDResponse->NumberOfSigmasTPC(track, (AliPID::EParticleType)ispecie);
     784             : //    }
     785             : 
     786             :     mvSpecie=0;  // Reset, in case it has been changed before
     787             : 
     788             :     // For the V0 scenario, it is necessary to close the gaps due to Muons and Kaons not being filled.
     789             :     // Electrons stay at position "0".
     790           0 :     if (scenario>39) {
     791           0 :       if (ispecie == 2) mvSpecie=1;       // Pions are moved from position "2" -> "1".
     792           0 :       else if (ispecie == 4) mvSpecie=2;  // Protons are moved from  position "4" -> "2".
     793             :     }
     794             : 
     795           0 :     TH2 *h=(TH2*)sublist->At(ispecie-mvSpecie);
     796           0 :     if ( h ) h->Fill(mom,nSigma);
     797             : 
     798           0 :     if (count == 3) {
     799           0 :       TH2 *hEta=(TH2*)sublist->At(ispecie-mvSpecie+nSpecies);
     800           0 :       TH2 *hMult=(TH2*)sublist->At(ispecie-mvSpecie+2*nSpecies);
     801             :  
     802           0 :       if ( hEta ) hEta->Fill(eta,nSigma);
     803           0 :       if ( hMult && mult > 0 ) hMult->Fill(mult,nSigma);
     804           0 :     }
     805           0 :   } // - End: different particle species -
     806             : 
     807             : 
     808             :   // -- Beginn: Fill histograms for MIP pions and electrons (only for some scenarios) --
     809           0 :   if ( scenario == 0 || scenario == 2 || scenario == 3 ) {
     810             : 
     811             :     // - Beginn: MIP pions: Nsigma vs. eta, Nsigma vs. mult -
     812           0 :     if (mom>0.45 && mom<0.5 && sig>40 && sig<60) {
     813             : 
     814             :       Bool_t isPionMC=kTRUE;
     815             : 
     816           0 :       TH2 *h1=(TH2*)sublist->At(count*nSpecies);
     817           0 :       if (h1) {
     818           0 :         if (scenario == 1) {
     819           0 :           if ( pdgCodeAbs != 211 && pdgCodeAbs != 111 ) isPionMC=kFALSE;
     820           0 :           if (isPionMC) {
     821           0 :             nSigma=fPIDResponse->NumberOfSigmasTPC(track, AliPID::kPion);
     822           0 :           }
     823             :         }
     824             : /* // special LHC11h setting not used and commented now
     825             :         else if (scenario == 2) {
     826             :           nSigma=fPIDResponse->NumberOfSigmasTPC(track, AliPID::kPion, AliTPCPIDResponse::kdEdxHybrid);
     827             :         }
     828             :         else if (scenario == 3) {
     829             :           nSigma=fPIDResponse->NumberOfSigmasTPC(track, AliPID::kPion, AliTPCPIDResponse::kdEdxOROC);
     830             :         }
     831             : */
     832           0 :         else nSigma=fPIDResponse->NumberOfSigmasTPC(track, AliPID::kPion);
     833             : 
     834           0 :         if (isPionMC) h1->Fill(eta,nSigma);
     835             :       }
     836             : 
     837           0 :       TH2 *h2m=(TH2*)sublist->At(count*nSpecies+1);
     838           0 :       if ( h2m && isPionMC && mult > 0 ) {
     839           0 :         h2m->Fill(mult,nSigma);
     840           0 :       }
     841             :    
     842           0 :     } // - End: MIP pions -
     843             : 
     844             :     // - Beginn: Electrons: Nsigma vs. eta, Nsigma vs. mult -
     845           0 :     if (mom>0.32 && mom<0.38 && eleLineDist>-10. && eleLineDist<15.) {
     846             : 
     847             :       Bool_t isElectronMC=kTRUE;
     848             : 
     849           0 :       TH2 *h3=(TH2*)sublist->At(count*nSpecies+2);
     850           0 :       if (h3) {
     851           0 :         if (scenario == 1) {
     852           0 :           if ( pdgCodeAbs != 11 ) isElectronMC=kFALSE;
     853           0 :           if (isElectronMC) {
     854           0 :             nSigma=fPIDResponse->NumberOfSigmasTPC(track, AliPID::kElectron);
     855           0 :           }
     856             :         }
     857             : /* // special LHC11h setting not used and commented now
     858             :         if (scenario == 2) {
     859             :           nSigma=fPIDResponse->NumberOfSigmasTPC(track, AliPID::kElectron, AliTPCPIDResponse::kdEdxHybrid);
     860             :         }
     861             :         else if (scenario == 3) {
     862             :           nSigma=fPIDResponse->NumberOfSigmasTPC(track, AliPID::kElectron, AliTPCPIDResponse::kdEdxOROC);
     863             :         }
     864             : */
     865           0 :         else nSigma=fPIDResponse->NumberOfSigmasTPC(track, AliPID::kElectron);
     866             : 
     867           0 :         if (isElectronMC) h3->Fill(eta,nSigma);
     868             :       }
     869             : 
     870           0 :       TH2 *h4m=(TH2*)sublist->At(count*nSpecies+3);
     871           0 :       if ( h4m && isElectronMC && mult > 0 ) {
     872           0 :         h4m->Fill(mult,nSigma);
     873           0 :       }
     874             : 
     875           0 :     } // - End: Electrons -
     876             :   } // -- End: Fill histograms for MIP pions and electrons --
     877             : 
     878           0 : }
     879             : 
     880             : //______________________________________________________________________________
     881             : void AliAnalysisTaskPIDqa::FillTPCqa()
     882             : {
     883             :   //
     884             :   // Fill PID qa histograms for the TPC
     885             :   //
     886             : 
     887             :   // switches for the different scenarios
     888             :   Bool_t scBasic=1;     // default/basic
     889             :   Bool_t scMCtruth=1;   // for MC truth tracks
     890             :   Bool_t scHybrid=0;    // for hybrid PID (only LHC11h) -> not used and commented now
     891             :   Bool_t scOROChigh=0;  // only OROC signal (only LHC11h) -> not used and commented now
     892             :   Bool_t scV0=1;        // for V0 candidates (only for ESDs available)
     893             :   Int_t scCounter=0;    // counter of scenarios, used for the histograms at the end of FillTPCqa
     894             : 
     895             :   // input handler
     896           0 :   AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
     897           0 :   AliInputEventHandler *inputHandler=dynamic_cast<AliInputEventHandler*>(man->GetInputEventHandler());
     898           0 :   if (!inputHandler) AliFatal("Input handler needed");
     899             : 
     900           0 :   AliVEvent *event=InputEvent();
     901             : 
     902             :   // ESD or AOD event needed to get reference multiplicity (not in AliVEvent)
     903             :   AliAODEvent *fAODevent = 0x0;   // AOD event
     904             :   AliESDEvent *fESDevent = 0x0;   // ESD event
     905             :   AliESDtrackCuts *esdTrackCuts = 0x0;  // ESD track Cuts (ref mult is in AliESDtrackCuts)
     906             : 
     907             :   Double_t eta=0.;    // track eta
     908             :   Int_t mult=0;       // event multiplicity (TPConlyRefMult)
     909             :   //Int_t nacc=0;       // counter for accepted multiplicity
     910             : 
     911             :   // Check for MC
     912           0 :   scMCtruth=(MCEvent()!=0x0);
     913             : 
     914             : /* // special LHC11h setting not used and commented now
     915             :   // Check if period is data LHC11h by checking if
     916             :   // the splines for ALLhigh have been set by AliPIDResponse
     917             :   AliTPCPIDResponse &tpcResp=fPIDResponse->GetTPCResponse();
     918             :   if (tpcResp.GetResponseFunction(AliPID::kPion, AliTPCPIDResponse::kALLhigh)==0x0) {
     919             :     scHybrid   = kFALSE;
     920             :     scOROChigh = kFALSE;
     921             :   }
     922             : */
     923             : 
     924             :   // Check if "ESD" or "AOD" and get the corresponding event and the beam type (or centrality)
     925           0 :   TString analysisType = inputHandler->GetDataType(); // can be "ESD" or "AOD"
     926           0 :   if (analysisType == "ESD") {
     927           0 :     fESDevent = dynamic_cast<AliESDEvent*>( InputEvent() );
     928           0 :     esdTrackCuts = new AliESDtrackCuts("esdTrackCuts");
     929             :     //printf("\n--- New event - event type = ESD \n");
     930           0 :   }
     931           0 :   else if (analysisType == "AOD") {
     932           0 :     fAODevent = dynamic_cast<AliAODEvent*>( InputEvent() );
     933             :     //printf("\n--- New event - event type = AOD \n");
     934             : 
     935             :     // disable V0 scenario, because V0s are not available for AODs in this current implementation
     936             :     scV0=0;
     937           0 :   }
     938             : 
     939             :   // Check if Basic list is already created
     940             :   // If not: Go to SetupTPCqa and creat lists and histograms
     941           0 :   if(!fListQAtpcBasic) {
     942             :     //printf("\n--- No list QA TPC Basic found -> go to SetupTPCqa! ---\n");
     943           0 :     SetupTPCqa(scMCtruth, scHybrid, scV0);
     944             :   }
     945             : 
     946             :   // Get the number of scenarios by counting those, which are switched on
     947           0 :   if (scBasic) scCounter++;
     948           0 :   if (scMCtruth) scCounter++;
     949             : //  if (scHybrid) scCounter++;
     950             : //  if (scOROChigh) scCounter++;
     951           0 :   if (scV0) scCounter++;
     952             : 
     953             :   // Get reference multiplicity for ESDs
     954           0 :   if ( analysisType == "ESD" && esdTrackCuts ) {
     955           0 :     mult=esdTrackCuts->GetReferenceMultiplicity(fESDevent,kTRUE);
     956           0 :   }
     957             : 
     958             :   // Get reference multiplicity for AODs
     959           0 :   if ( analysisType == "AOD" && fAODevent ) {
     960           0 :     AliAODHeader * header=dynamic_cast<AliAODHeader*>(fAODevent->GetHeader());
     961           0 :     if(!header) AliFatal("Not a standard AOD");
     962           0 :     mult=header->GetTPConlyRefMultiplicity();
     963           0 :   }
     964             : 
     965             :   /*if (mult < 0) {
     966             :     printf("Reference multiplicity not available \n");
     967             :     //return;
     968             :   }*/
     969             : 
     970             :   //printf("The multiplicity is = %i ",mult);
     971             : 
     972             : 
     973             :   // -- Begin: track loop --
     974           0 :   Int_t ntracks=event->GetNumberOfTracks();
     975           0 :   for(Int_t itrack = 0; itrack < ntracks; itrack++){
     976           0 :     AliVTrack *track=(AliVTrack*)event->GetTrack(itrack);
     977             : 
     978             :     //
     979             :     //basic track cuts
     980             :     //
     981           0 :     ULong_t status=track->GetStatus();
     982             :     // not that nice. status bits not in virtual interface
     983             :     // TPC refit + ITS refit + TPC pid
     984           0 :     if (!( (status & AliVTrack::kTPCrefit) == AliVTrack::kTPCrefit) ||
     985           0 :         !( (status & AliVTrack::kITSrefit) == AliVTrack::kITSrefit) ) continue;
     986             : 
     987             :     // The TPC pid cut removes the light nuclei (>5 sigma from proton line)
     988             :     //||        !( (status & AliVTrack::kTPCpid  ) == AliVTrack::kTPCpid  )
     989           0 :     Float_t nCrossedRowsTPC = track->GetTPCClusterInfo(2,1);
     990             :     Float_t  ratioCrossedRowsOverFindableClustersTPC = 1.0;
     991           0 :     if (track->GetTPCNclsF()>0) {
     992           0 :       ratioCrossedRowsOverFindableClustersTPC = nCrossedRowsTPC/track->GetTPCNclsF();
     993           0 :     }
     994             : 
     995           0 :     if ( nCrossedRowsTPC<70 || ratioCrossedRowsOverFindableClustersTPC<.8 ) continue;
     996             : 
     997           0 :     eta=track->Eta();
     998           0 :     if ( TMath::Abs(eta)>0.9 ) continue;
     999             : 
    1000             :     //nacc++; // counter for accepted multiplicity
    1001             : 
    1002             :     // the default ("basic") scenario
    1003           0 :     if (scBasic == 1) {
    1004           0 :       FillTPCHistogramsNsigma(fListQAtpcBasic,0,track,mult);
    1005           0 :       FillTPCHistogramsSignal(fListQAtpcBasic,0,track,mult);
    1006             :     }
    1007             : 
    1008             :     // only MC truth identified particles
    1009           0 :     if (scMCtruth == 1) {
    1010           0 :       FillTPCHistogramsNsigma(fListQAtpcMCtruth,1,track,mult);
    1011             :     }
    1012             : 
    1013             : /* // special LHC11h setting not used and commented now
    1014             :     // the "hybrid" scenario (only for LHC11h)
    1015             :     if (scHybrid == 1) {
    1016             :       FillTPCHistogramsNsigma(fListQAtpcHybrid,2,track,mult);
    1017             :     }
    1018             : 
    1019             :     // the "OROC high" scenario (only for LHC11h)
    1020             :     if (scOROChigh == 1) {
    1021             :       FillTPCHistogramsNsigma(fListQAtpcOROChigh,3,track,mult);
    1022             :     }
    1023             : */
    1024             : 
    1025           0 :   } // -- End: track loop --
    1026             : 
    1027             : 
    1028             :   // -- Begin: track loops for V0 candidates --
    1029           0 :   if (scV0 == 1) {
    1030             : 
    1031             :     // - Begin: track loop for electrons from V0 -
    1032           0 :     for(Int_t itrack = 0; itrack < fV0electrons->GetEntries(); itrack++){
    1033           0 :       AliVTrack *track=(AliVTrack*)fV0electrons->At(itrack);
    1034             : 
    1035             :       //
    1036             :       //basic track cuts
    1037             :       //
    1038           0 :       ULong_t status=track->GetStatus();
    1039             :       // not that nice. status bits not in virtual interface
    1040             :       // TPC refit + ITS refit + TPC pid
    1041           0 :       if (!( (status & AliVTrack::kTPCrefit) == AliVTrack::kTPCrefit) ||
    1042           0 :           !( (status & AliVTrack::kITSrefit) == AliVTrack::kITSrefit) ) continue;
    1043             : 
    1044             :       // The TPC pid cut removes the light nuclei (>5 sigma from proton line)
    1045             :       //||        !( (status & AliVTrack::kTPCpid  ) == AliVTrack::kTPCpid  )
    1046           0 :       Float_t nCrossedRowsTPC = track->GetTPCClusterInfo(2,1);
    1047             :       Float_t  ratioCrossedRowsOverFindableClustersTPC = 1.0;
    1048           0 :       if (track->GetTPCNclsF()>0) {
    1049           0 :         ratioCrossedRowsOverFindableClustersTPC = nCrossedRowsTPC/track->GetTPCNclsF();
    1050           0 :       }
    1051             : 
    1052           0 :       if ( nCrossedRowsTPC<70 || ratioCrossedRowsOverFindableClustersTPC<.8 ) continue;
    1053             : 
    1054           0 :       eta=track->Eta();
    1055           0 :       if ( TMath::Abs(eta)>0.9 ) continue;
    1056             : 
    1057             :       // fill histograms for V0 candidates
    1058           0 :       FillTPCHistogramsNsigma(fListQAtpcV0,40,track,mult);
    1059           0 :       FillTPCHistogramsSignal(fListQAtpcV0,40,track,mult);
    1060             : 
    1061           0 :     } // - End: track loop for electrons from V0 -
    1062             : 
    1063             : 
    1064             :     // - Begin: track loop for pions from V0 -
    1065           0 :     for(Int_t itrack = 0; itrack < fV0pions->GetEntries(); itrack++){
    1066           0 :       AliVTrack *track=(AliVTrack*)fV0pions->At(itrack);
    1067             : 
    1068             :       //
    1069             :       //basic track cuts
    1070             :       //
    1071           0 :       ULong_t status=track->GetStatus();
    1072             :       // not that nice. status bits not in virtual interface
    1073             :       // TPC refit + ITS refit + TPC pid
    1074           0 :       if (!( (status & AliVTrack::kTPCrefit) == AliVTrack::kTPCrefit) ||
    1075           0 :           !( (status & AliVTrack::kITSrefit) == AliVTrack::kITSrefit) ) continue;
    1076             : 
    1077             :       // The TPC pid cut removes the light nuclei (>5 sigma from proton line)
    1078             :       //||        !( (status & AliVTrack::kTPCpid  ) == AliVTrack::kTPCpid  )
    1079           0 :       Float_t nCrossedRowsTPC = track->GetTPCClusterInfo(2,1);
    1080             :       Float_t  ratioCrossedRowsOverFindableClustersTPC = 1.0;
    1081           0 :       if (track->GetTPCNclsF()>0) {
    1082           0 :         ratioCrossedRowsOverFindableClustersTPC = nCrossedRowsTPC/track->GetTPCNclsF();
    1083           0 :       }
    1084             : 
    1085           0 :       if ( nCrossedRowsTPC<70 || ratioCrossedRowsOverFindableClustersTPC<.8 ) continue;
    1086             : 
    1087           0 :       eta=track->Eta();
    1088           0 :       if ( TMath::Abs(eta)>0.9 ) continue;
    1089             : 
    1090             :       // fill histograms for V0 candidates
    1091           0 :       FillTPCHistogramsNsigma(fListQAtpcV0,42,track,mult);
    1092           0 :       FillTPCHistogramsSignal(fListQAtpcV0,42,track,mult);
    1093             : 
    1094           0 :     } // - End: track loop for pions from V0 -
    1095             : 
    1096             : 
    1097             : /*  // Take out the kaons - are not filled (at least at the moment)
    1098             :     // - Begin: track loop for kaons from V0 -
    1099             :     for(Int_t itrack = 0; itrack < fV0kaons->GetEntries(); itrack++){
    1100             :       AliVTrack *track=(AliVTrack*)fV0kaons->At(itrack);
    1101             : 
    1102             :       //
    1103             :       //basic track cuts
    1104             :       //
    1105             :       ULong_t status=track->GetStatus();
    1106             :       // not that nice. status bits not in virtual interface
    1107             :       // TPC refit + ITS refit + TPC pid
    1108             :       if (!( (status & AliVTrack::kTPCrefit) == AliVTrack::kTPCrefit) ||
    1109             :           !( (status & AliVTrack::kITSrefit) == AliVTrack::kITSrefit) ) continue;
    1110             : 
    1111             :       // The TPC pid cut removes the light nuclei (>5 sigma from proton line)
    1112             :       //||        !( (status & AliVTrack::kTPCpid  ) == AliVTrack::kTPCpid  )
    1113             :       Float_t nCrossedRowsTPC = track->GetTPCClusterInfo(2,1);
    1114             :       Float_t  ratioCrossedRowsOverFindableClustersTPC = 1.0;
    1115             :       if (track->GetTPCNclsF()>0) {
    1116             :         ratioCrossedRowsOverFindableClustersTPC = nCrossedRowsTPC/track->GetTPCNclsF();
    1117             :       }
    1118             : 
    1119             :       if ( nCrossedRowsTPC<70 || ratioCrossedRowsOverFindableClustersTPC<.8 ) continue;
    1120             : 
    1121             :       eta=track->Eta();
    1122             :       if ( TMath::Abs(eta)>0.9 ) continue;
    1123             : 
    1124             :       // fill histograms for V0 candidates
    1125             :       FillTPCHistogramsNsigma(fListQAtpcV0,43,track,mult);
    1126             :       FillTPCHistogramsSignal(fListQAtpcV0,43,track,mult);
    1127             : 
    1128             :     } // - End: track loop for kaons from V0 -
    1129             : */
    1130             : 
    1131             :     // - Begin: track loop for protons from V0 -
    1132           0 :     for(Int_t itrack = 0; itrack < fV0protons->GetEntries(); itrack++){
    1133           0 :       AliVTrack *track=(AliVTrack*)fV0protons->At(itrack);
    1134             : 
    1135             :       //
    1136             :       //basic track cuts
    1137             :       //
    1138           0 :       ULong_t status=track->GetStatus();
    1139             :       // not that nice. status bits not in virtual interface
    1140             :       // TPC refit + ITS refit + TPC pid
    1141           0 :       if (!( (status & AliVTrack::kTPCrefit) == AliVTrack::kTPCrefit) ||
    1142           0 :           !( (status & AliVTrack::kITSrefit) == AliVTrack::kITSrefit) ) continue;
    1143             : 
    1144             :       // The TPC pid cut removes the light nuclei (>5 sigma from proton line)
    1145             :       //||        !( (status & AliVTrack::kTPCpid  ) == AliVTrack::kTPCpid  )
    1146           0 :       Float_t nCrossedRowsTPC = track->GetTPCClusterInfo(2,1);
    1147             :       Float_t  ratioCrossedRowsOverFindableClustersTPC = 1.0;
    1148           0 :       if (track->GetTPCNclsF()>0) {
    1149           0 :         ratioCrossedRowsOverFindableClustersTPC = nCrossedRowsTPC/track->GetTPCNclsF();
    1150           0 :       }
    1151             : 
    1152           0 :       if ( nCrossedRowsTPC<70 || ratioCrossedRowsOverFindableClustersTPC<.8 ) continue;
    1153             : 
    1154           0 :       eta=track->Eta();
    1155           0 :       if ( TMath::Abs(eta)>0.9 ) continue;
    1156             : 
    1157             :       // fill histograms for V0 candidates
    1158           0 :       FillTPCHistogramsNsigma(fListQAtpcV0,44,track,mult);
    1159           0 :       FillTPCHistogramsSignal(fListQAtpcV0,44,track,mult);
    1160             : 
    1161           0 :     } // - End: track loop for protons from V0 -
    1162             : 
    1163           0 :   } // -- End: track loops for V0 candidates --
    1164             : 
    1165             : 
    1166             :   // Multiplicity distribution
    1167           0 :   TH1 *hm=(TH1*)fListQAtpc->At(scCounter);
    1168           0 :   if (hm) {
    1169           0 :     hm->Fill(mult);
    1170             :   }
    1171             : 
    1172             :   //printf("\nAccepted multiplicity = %i \n --- END of event --- \n",nacc);
    1173             : 
    1174           0 : }
    1175             : 
    1176             : //______________________________________________________________________________
    1177             : void AliAnalysisTaskPIDqa::FillTRDqa()
    1178             : {
    1179             :   //
    1180             :   // Fill PID qa histograms for the TRD
    1181             :   //
    1182           0 :   AliVEvent *event=InputEvent();
    1183           0 :   Int_t ntracks = event->GetNumberOfTracks();
    1184           0 :   for(Int_t itrack = 0; itrack <  ntracks; itrack++){
    1185           0 :     AliVTrack *track = (AliVTrack *)event->GetTrack(itrack);
    1186             : 
    1187             :     //
    1188             :     //basic track cuts
    1189             :     //
    1190           0 :     ULong_t status=track->GetStatus();
    1191             :     // not that nice. status bits not in virtual interface
    1192             :     // TPC refit + ITS refit + TPC pid + TRD out
    1193           0 :     if (!( (status & AliVTrack::kTPCrefit) == AliVTrack::kTPCrefit) ||
    1194           0 :         !( (status & AliVTrack::kITSrefit) == AliVTrack::kITSrefit) ||
    1195             : //         !( (status & AliVTrack::kTPCpid  ) == AliVTrack::kTPCpid  ) || //removes light nuclei. So it is out for the moment
    1196           0 :         !( (status & AliVTrack::kTRDout  ) == AliVTrack::kTRDout  )) continue;
    1197             :     
    1198           0 :     Float_t nCrossedRowsTPC = track->GetTPCClusterInfo(2,1);
    1199             :     Float_t  ratioCrossedRowsOverFindableClustersTPC = 1.0;
    1200           0 :     if (track->GetTPCNclsF()>0) {
    1201           0 :       ratioCrossedRowsOverFindableClustersTPC = nCrossedRowsTPC/track->GetTPCNclsF();
    1202           0 :     }
    1203             :     
    1204           0 :     if ( nCrossedRowsTPC<70 || ratioCrossedRowsOverFindableClustersTPC<.8 ) continue;
    1205             : 
    1206           0 :     Double_t likelihoods[AliPID::kSPECIES];
    1207           0 :     if(fPIDResponse->ComputeTRDProbability(track, AliPID::kSPECIES, likelihoods) != AliPIDResponse::kDetPidOk) continue;
    1208             :     Int_t ntracklets = 0;
    1209             :     Double_t momentum = -1.;
    1210           0 :     for(Int_t itl = 0; itl < 6; itl++) {
    1211           0 :       if(track->GetTRDmomentum(itl) > 0.) {
    1212           0 :         ntracklets++;
    1213           0 :         if(momentum < 0) momentum = track->GetTRDmomentum(itl);
    1214             :       }
    1215             :     }
    1216             :     
    1217           0 :     for(Int_t ispecie = 0; ispecie < AliPID::kSPECIES; ispecie++){
    1218           0 :       TH2F *hLike = (TH2F *)fListQAtrd->At(ntracklets*AliPID::kSPECIES+ispecie);
    1219           0 :       if (hLike) hLike->Fill(momentum,likelihoods[ispecie]);
    1220             :     }
    1221             : 
    1222             :     //=== nSigma and signal ===
    1223           0 :     for (Int_t ispecie=0; ispecie<AliPID::kSPECIESC; ++ispecie){
    1224           0 :       TH2 *h=(TH2*)fListQAtrdNsig->At(ispecie);
    1225           0 :       TH2 *hTPCTOF=(TH2*)fListQAtrdNsigTPCTOF->At(ispecie);
    1226           0 :       if (!h || !hTPCTOF) continue;
    1227           0 :       Float_t nSigmaTPC=fPIDResponse->NumberOfSigmas(AliPIDResponse::kTPC, track, (AliPID::EParticleType)ispecie);
    1228           0 :       Float_t nSigmaTRD=fPIDResponse->NumberOfSigmas(AliPIDResponse::kTRD, track, (AliPID::EParticleType)ispecie);
    1229           0 :       Float_t nSigmaTOF=fPIDResponse->NumberOfSigmas(AliPIDResponse::kTOF, track, (AliPID::EParticleType)ispecie);
    1230           0 :       h->Fill(momentum,nSigmaTRD);
    1231             : 
    1232           0 :       if (TMath::Abs(nSigmaTPC)<3 && TMath::Abs(nSigmaTOF)<3) {
    1233           0 :         hTPCTOF->Fill(momentum,nSigmaTRD);
    1234           0 :       }
    1235           0 :     }
    1236             : 
    1237           0 :     TH2 *h=(TH2*)fListQAtrdNsig->Last();
    1238             :     
    1239           0 :     if (h) {
    1240           0 :       Double_t sig=track->GetTRDsignal();
    1241           0 :       h->Fill(momentum,sig);
    1242           0 :     }
    1243             :     
    1244           0 :   }
    1245           0 : }
    1246             : 
    1247             : //______________________________________________________________________________
    1248             : void AliAnalysisTaskPIDqa::FillTOFqa()
    1249             : {
    1250             :   //
    1251             :   // Fill TOF information
    1252             :   //
    1253           0 :   AliVEvent *event=InputEvent();
    1254             : 
    1255           0 :   Int_t ntracks=event->GetNumberOfTracks();
    1256             :   Int_t tracksAtTof = 0;
    1257           0 :   for(Int_t itrack = 0; itrack < ntracks; itrack++){
    1258           0 :     AliVTrack *track=(AliVTrack*)event->GetTrack(itrack);
    1259             : 
    1260             :     //
    1261             :     //basic track cuts
    1262             :     //
    1263           0 :     ULong_t status=track->GetStatus();
    1264             :     // TPC refit + ITS refit +
    1265             :     // TOF out + kTIME
    1266             :     // kTIME
    1267             :     // (we don't use kTOFmismatch because it depends on TPC and kTOFpid because it prevents light nuclei
    1268           0 :     if (!((status & AliVTrack::kTPCrefit) == AliVTrack::kTPCrefit) ||
    1269           0 :         !((status & AliVTrack::kITSrefit) == AliVTrack::kITSrefit) ||
    1270           0 :         !((status & AliVTrack::kTOFout  ) == AliVTrack::kTOFout  ) ||
    1271             :         //        !((status & AliVTrack::kTOFpid  ) == AliVTrack::kTOFpid  ) ||
    1272           0 :         !((status & AliVTrack::kTIME    ) == AliVTrack::kTIME    ) ) continue;
    1273             : 
    1274           0 :     Float_t nCrossedRowsTPC = track->GetTPCClusterInfo(2,1);
    1275             :     Float_t  ratioCrossedRowsOverFindableClustersTPC = 1.0;
    1276           0 :     if (track->GetTPCNclsF()>0) {
    1277           0 :       ratioCrossedRowsOverFindableClustersTPC = nCrossedRowsTPC/track->GetTPCNclsF();
    1278           0 :     }
    1279             : 
    1280           0 :     if ( nCrossedRowsTPC<70 || ratioCrossedRowsOverFindableClustersTPC<.8 ) continue;
    1281             : 
    1282           0 :     tracksAtTof++;
    1283             : 
    1284           0 :     Double_t mom=track->P();
    1285             : 
    1286           0 :     for (Int_t ispecie=0; ispecie<AliPID::kSPECIESC; ++ispecie){
    1287           0 :       TH2 *h=(TH2*)fListQAtof->At(ispecie);
    1288           0 :       if (!h) continue;
    1289           0 :       Double_t nSigma=fPIDResponse->NumberOfSigmasTOF(track, (AliPID::EParticleType)ispecie);
    1290           0 :       h->Fill(mom,nSigma);
    1291           0 :     }
    1292             : 
    1293           0 :     TH2 *h=(TH2*)fListQAtof->FindObject("hSigP_TOF");
    1294           0 :     if (h) {
    1295           0 :       Double_t sig=track->GetTOFsignal()/1000.;
    1296           0 :       h->Fill(mom,sig);
    1297           0 :     }
    1298             : 
    1299           0 :     Int_t mask = fPIDResponse->GetTOFResponse().GetStartTimeMask(mom);
    1300           0 :     ((TH1F*)fListQAtof->FindObject("hStartTimeMask_TOF"))->Fill((Double_t)(mask+0.5));
    1301             : 
    1302           0 :     if (mom >= 0.75 && mom <= 1.25 ) {
    1303           0 :       Double_t nsigma= fPIDResponse->NumberOfSigmasTOF(track, (AliPID::EParticleType)AliPID::kPion);
    1304           0 :       if (mask == 0) {
    1305           0 :         ((TH1F*)fListQAtof->FindObject("hNsigma_TOF_Pion_T0-Fill"))->Fill(nsigma);
    1306           0 :       } else if (mask == 1) {
    1307           0 :         ((TH1F*)fListQAtof->FindObject("hNsigma_TOF_Pion_T0-TOF"))->Fill(nsigma);
    1308           0 :       } else if ( (mask == 2) || (mask == 4) || (mask == 6) ) {
    1309           0 :         ((TH1F*)fListQAtof->FindObject("hNsigma_TOF_Pion_T0-T0"))->Fill(nsigma);
    1310           0 :       } else {
    1311           0 :         ((TH1F*)fListQAtof->FindObject("hNsigma_TOF_Pion_T0-Best"))->Fill(nsigma);
    1312             :       }
    1313           0 :       if (mask & 0x1) { //at least TOF-T0 present
    1314           0 :         Double_t delta=0;
    1315           0 :         (void)fPIDResponse->GetSignalDelta((AliPIDResponse::EDetector)AliPIDResponse::kTOF,track,(AliPID::EParticleType)AliPID::kPion,delta);
    1316           0 :         ((TH1F*)fListQAtof->FindObject("hDelta_TOF_Pion"))->Fill(delta);
    1317           0 :       }
    1318           0 :     }
    1319             : 
    1320           0 :     Double_t res = (Double_t)fPIDResponse->GetTOFResponse().GetStartTimeRes(mom);
    1321           0 :     ((TH1F*)fListQAtof->FindObject("hStartTimeRes_TOF"))->Fill(res);
    1322             : 
    1323           0 :     Double_t startTimeT0 = event->GetT0TOF(0);
    1324           0 :     if (startTimeT0 < 90000) ((TH1F*)fListQAtof->FindObject("hStartTimeAC_T0"))->Fill(startTimeT0);
    1325             :     else {
    1326           0 :       startTimeT0 = event->GetT0TOF(1);
    1327           0 :       if (startTimeT0 < 90000) ((TH1F*)fListQAtof->FindObject("hStartTimeA_T0"))->Fill(startTimeT0);
    1328           0 :       startTimeT0 = event->GetT0TOF(2);
    1329           0 :       if (startTimeT0 < 90000) ((TH1F*)fListQAtof->FindObject("hStartTimeC_T0"))->Fill(startTimeT0);
    1330             :     }
    1331           0 :   }
    1332           0 :   if (tracksAtTof > 0) {
    1333           0 :     ((TH1F* )fListQAtof->FindObject("hnTracksAt_TOF"))->Fill(tracksAtTof);
    1334           0 :     Int_t mask = fPIDResponse->GetTOFResponse().GetStartTimeMask(5.);
    1335           0 :     if (mask & 0x1) ((TH1F*)fListQAtof->FindObject("hT0MakerEff"))->Fill(tracksAtTof);
    1336           0 :   }
    1337           0 : }
    1338             : 
    1339             : //______________________________________________________________________________
    1340             : void AliAnalysisTaskPIDqa::FillT0qa()
    1341             : {
    1342             :   //
    1343             :   // Fill TOF information
    1344             :   //
    1345           0 :   AliVEvent *event=InputEvent();
    1346             : 
    1347           0 :   Int_t ntracks=event->GetNumberOfTracks();
    1348             : 
    1349             :   Int_t tracksAtT0 = 0;
    1350             : 
    1351           0 :   for(Int_t itrack = 0; itrack < ntracks; itrack++){
    1352           0 :     AliVTrack *track=(AliVTrack*)event->GetTrack(itrack);
    1353             : 
    1354             :     //
    1355             :     //basic track cuts
    1356             :     //
    1357           0 :     ULong_t status=track->GetStatus();
    1358             :     // TPC refit + ITS refit +
    1359           0 :     if (!((status & AliVTrack::kTPCrefit) == AliVTrack::kTPCrefit) ||
    1360           0 :         !((status & AliVTrack::kITSrefit) == AliVTrack::kITSrefit) ) continue;
    1361           0 :     Float_t nCrossedRowsTPC = track->GetTPCClusterInfo(2,1);
    1362             :     Float_t  ratioCrossedRowsOverFindableClustersTPC = 1.0;
    1363           0 :     if (track->GetTPCNclsF()>0) {
    1364           0 :       ratioCrossedRowsOverFindableClustersTPC = nCrossedRowsTPC/track->GetTPCNclsF();
    1365           0 :     }
    1366           0 :     if ( nCrossedRowsTPC<70 || ratioCrossedRowsOverFindableClustersTPC<.8 ) continue;
    1367             : 
    1368           0 :     tracksAtT0++;
    1369           0 :   }
    1370             : 
    1371             :   Bool_t t0A = kFALSE;
    1372             :   Bool_t t0C = kFALSE;
    1373             :   Bool_t t0And = kFALSE;
    1374           0 :   Double_t startTimeT0 = event->GetT0TOF(0);     // AND
    1375           0 :   if (startTimeT0 < 90000) {
    1376             :     t0And = kTRUE;
    1377           0 :     ((TH1F*)fListQAt0->FindObject("hStartTimeAC_T0"))->Fill(startTimeT0);
    1378           0 :     }
    1379           0 :   startTimeT0 = event->GetT0TOF(1);             // T0A 
    1380           0 :   if (startTimeT0 < 90000) {
    1381             :     t0A = kTRUE;
    1382           0 :     ((TH1F*)fListQAt0->FindObject("hStartTimeA_T0"))->Fill(startTimeT0);
    1383             :     
    1384           0 :   }
    1385           0 :   startTimeT0 = event->GetT0TOF(2);             // T0C 
    1386           0 :   if (startTimeT0 < 90000) {
    1387             :     t0C = kTRUE;
    1388           0 :     ((TH1F*)fListQAt0->FindObject("hStartTimeC_T0"))->Fill(startTimeT0);
    1389           0 :   }
    1390             :   
    1391           0 :   ((TH1F* )fListQAt0->FindObject("hnTracksAt_T0"))->Fill(tracksAtT0);
    1392           0 :   if (t0A) ((TH1F*)fListQAt0->FindObject("hT0AEff"))->Fill(tracksAtT0);
    1393           0 :   if (t0C) ((TH1F*)fListQAt0->FindObject("hT0CEff"))->Fill(tracksAtT0);
    1394           0 :   if (t0And) ((TH1F*)fListQAt0->FindObject("hT0AndEff"))->Fill(tracksAtT0);
    1395           0 :   if (t0A || t0C) ((TH1F*)fListQAt0->FindObject("hT0OrEff"))->Fill(tracksAtT0);
    1396           0 : }
    1397             : 
    1398             : 
    1399             : //______________________________________________________________________________
    1400             : void AliAnalysisTaskPIDqa::FillEMCALqa()
    1401             : {
    1402             :   //
    1403             :   // Fill PID qa histograms for the EMCAL
    1404             :   //
    1405             : 
    1406           0 :   AliVEvent *event=InputEvent();
    1407             :   
    1408           0 :   Int_t ntracks=event->GetNumberOfTracks();
    1409           0 :   for(Int_t itrack = 0; itrack < ntracks; itrack++){
    1410           0 :     AliVTrack *track=(AliVTrack*)event->GetTrack(itrack);
    1411             :     
    1412             :     //
    1413             :     //basic track cuts
    1414             :     //
    1415           0 :     ULong_t status=track->GetStatus();
    1416             :     // not that nice. status bits not in virtual interface
    1417           0 :     if (!( (status & AliVTrack::kEMCALmatch) == AliVTrack::kEMCALmatch) ) continue;
    1418             : 
    1419           0 :     Double_t pt=track->Pt();
    1420             :    
    1421             :     //EMCAL nSigma (only for electrons at the moment)
    1422           0 :     TH2 *h=(TH2*)fListQAemcal->At(0);
    1423           0 :     if (!h) continue;
    1424           0 :     Double_t nSigma=fPIDResponse->NumberOfSigmasEMCAL(track, (AliPID::EParticleType)0);
    1425           0 :     h->Fill(pt,nSigma);
    1426             :     
    1427           0 :   }
    1428             : 
    1429             :    //EMCAL signal (E/p vs. pT) for electrons from V0
    1430           0 :   for(Int_t itrack = 0; itrack < fV0electrons->GetEntries(); itrack++){
    1431           0 :     AliVTrack *track=(AliVTrack*)fV0electrons->At(itrack);
    1432             : 
    1433             :     //
    1434             :     //basic track cuts
    1435             :     //
    1436           0 :     ULong_t status=track->GetStatus();
    1437             :     // not that nice. status bits not in virtual interface
    1438           0 :     if (!( (status & AliVTrack::kEMCALmatch) == AliVTrack::kEMCALmatch) ) continue;
    1439             : 
    1440           0 :     Double_t pt=track->Pt();
    1441             : 
    1442           0 :     TH2 *h=(TH2*)fListQAemcal->At(1);
    1443           0 :     if (h) {
    1444             : 
    1445           0 :       Int_t nMatchClus = track->GetEMCALcluster();
    1446           0 :       Double_t mom     = track->P();
    1447             :       Double_t eop     = -1.;
    1448             : 
    1449           0 :       if(nMatchClus > -1){
    1450             :     
    1451           0 :         AliVCluster *matchedClus = (AliVCluster*)event->GetCaloCluster(nMatchClus);
    1452             : 
    1453           0 :         if(matchedClus){
    1454             : 
    1455             :           // matched cluster is EMCAL
    1456           0 :           if(matchedClus->IsEMCAL()){
    1457             : 
    1458           0 :             Double_t fClsE       = matchedClus->E();
    1459           0 :             eop                  = fClsE/mom;
    1460             : 
    1461           0 :             h->Fill(pt,eop);
    1462             : 
    1463           0 :           }
    1464             :         }
    1465           0 :       }
    1466           0 :     }
    1467           0 :   }
    1468             : 
    1469             :    //EMCAL signal (E/p vs. pT) for pions from V0
    1470           0 :   for(Int_t itrack = 0; itrack < fV0pions->GetEntries(); itrack++){
    1471           0 :     AliVTrack *track=(AliVTrack*)fV0pions->At(itrack);
    1472             : 
    1473             :     //
    1474             :     //basic track cuts
    1475             :     //
    1476           0 :     ULong_t status=track->GetStatus();
    1477             :     // not that nice. status bits not in virtual interface
    1478           0 :     if (!( (status & AliVTrack::kEMCALmatch) == AliVTrack::kEMCALmatch) ) continue;
    1479             : 
    1480           0 :     Double_t pt=track->Pt();
    1481             : 
    1482           0 :     TH2 *h=(TH2*)fListQAemcal->At(2);
    1483           0 :     if (h) {
    1484             : 
    1485           0 :       Int_t nMatchClus = track->GetEMCALcluster();
    1486           0 :       Double_t mom     = track->P();
    1487             :       Double_t eop     = -1.;
    1488             : 
    1489           0 :       if(nMatchClus > -1){
    1490             :     
    1491           0 :         AliVCluster *matchedClus = (AliVCluster*)event->GetCaloCluster(nMatchClus);
    1492             : 
    1493           0 :         if(matchedClus){
    1494             : 
    1495             :           // matched cluster is EMCAL
    1496           0 :           if(matchedClus->IsEMCAL()){
    1497             : 
    1498           0 :             Double_t fClsE       = matchedClus->E();
    1499           0 :             eop                  = fClsE/mom;
    1500             : 
    1501           0 :             h->Fill(pt,eop);
    1502             : 
    1503           0 :           }
    1504             :         }
    1505           0 :       }
    1506           0 :     }
    1507           0 :   }
    1508             : 
    1509             :    //EMCAL signal (E/p vs. pT) for protons from V0
    1510           0 :   for(Int_t itrack = 0; itrack < fV0protons->GetEntries(); itrack++){
    1511           0 :     AliVTrack *track=(AliVTrack*)fV0protons->At(itrack);
    1512             : 
    1513             :     //
    1514             :     //basic track cuts
    1515             :     //
    1516           0 :     ULong_t status=track->GetStatus();
    1517             :     // not that nice. status bits not in virtual interface
    1518           0 :     if (!( (status & AliVTrack::kEMCALmatch) == AliVTrack::kEMCALmatch) ) continue;
    1519             : 
    1520           0 :     Double_t pt=track->Pt();
    1521             : 
    1522           0 :     TH2 *hP=(TH2*)fListQAemcal->At(3);
    1523           0 :     TH2 *hAP=(TH2*)fListQAemcal->At(4);
    1524           0 :     if (hP && hAP) {
    1525             : 
    1526           0 :       Int_t nMatchClus = track->GetEMCALcluster();
    1527           0 :       Double_t mom     = track->P();
    1528           0 :       Int_t charge     = track->Charge();          
    1529             :       Double_t eop     = -1.;
    1530             : 
    1531           0 :       if(nMatchClus > -1){
    1532             :     
    1533           0 :         AliVCluster *matchedClus = (AliVCluster*)event->GetCaloCluster(nMatchClus);
    1534             : 
    1535           0 :         if(matchedClus){
    1536             : 
    1537             :           // matched cluster is EMCAL
    1538           0 :           if(matchedClus->IsEMCAL()){
    1539             : 
    1540           0 :             Double_t fClsE       = matchedClus->E();
    1541           0 :             eop                  = fClsE/mom;
    1542             : 
    1543           0 :             if(charge > 0)      hP->Fill(pt,eop);
    1544           0 :             else if(charge < 0) hAP->Fill(pt,eop);
    1545             : 
    1546           0 :           }
    1547             :         }
    1548           0 :       }
    1549           0 :     }
    1550           0 :   }
    1551             : 
    1552           0 : }
    1553             : 
    1554             : 
    1555             : //______________________________________________________________________________
    1556             : void AliAnalysisTaskPIDqa::FillHMPIDqa()
    1557             : {
    1558             :   //
    1559             :   // Fill PID qa histograms for the HMPID
    1560             :   //
    1561             :   
    1562           0 :   AliVEvent *event=InputEvent();
    1563             :   
    1564           0 :   Int_t ntracks=event->GetNumberOfTracks();
    1565           0 :   for(Int_t itrack = 0; itrack < ntracks; itrack++){
    1566           0 :     AliVTrack *track=(AliVTrack*)event->GetTrack(itrack);
    1567             :     
    1568             :     //
    1569             :     //basic track cuts
    1570             :     //
    1571           0 :     const ULong_t status=track->GetStatus();
    1572             :     // not that nice. status bits not in virtual interface
    1573             :     // TPC refit + ITS refit +
    1574             :     // TOF out + TOFpid +
    1575             :     // kTIME
    1576           0 :     if (!((status & AliVTrack::kTPCrefit) == AliVTrack::kTPCrefit) ||
    1577           0 :         !((status & AliVTrack::kITSrefit) == AliVTrack::kITSrefit) ) continue;
    1578             : 
    1579           0 :     const Float_t nCrossedRowsTPC = track->GetTPCClusterInfo(2,1);
    1580             :     Float_t  ratioCrossedRowsOverFindableClustersTPC = 1.0;
    1581           0 :     if (track->GetTPCNclsF()>0) {
    1582           0 :       ratioCrossedRowsOverFindableClustersTPC = nCrossedRowsTPC/track->GetTPCNclsF();
    1583           0 :     }
    1584             : 
    1585           0 :     if ( nCrossedRowsTPC<70 || ratioCrossedRowsOverFindableClustersTPC<.8 ) continue;
    1586             :     
    1587           0 :     const Double_t mom = track->P();
    1588           0 :     const Double_t ckovAngle = track->GetHMPIDsignal();
    1589             : 
    1590             :     Int_t nhists=0;
    1591           0 :     for (Int_t ispecie=0; ispecie<AliPID::kSPECIESC; ++ispecie){
    1592           0 :       if (ispecie==AliPID::kElectron || ispecie==AliPID::kMuon) continue;
    1593           0 :       TH2 *h=(TH2*)fListQAhmpid->At(nhists);
    1594           0 :       if (!h) {++nhists; continue;}
    1595           0 :       const Double_t nSigma=fPIDResponse->NumberOfSigmasHMPID(track, (AliPID::EParticleType)ispecie);
    1596           0 :       h->Fill(mom,nSigma);
    1597           0 :       ++nhists;
    1598           0 :     }
    1599             :     
    1600           0 :     TH1F *hThetavsMom = (TH1F*)fListQAhmpid->At(AliPID::kSPECIESC);
    1601             :     
    1602           0 :     if (hThetavsMom) hThetavsMom->Fill(mom,ckovAngle);
    1603             :   
    1604           0 :   }
    1605           0 : }
    1606             : //______________________________________________________________________________
    1607             : void AliAnalysisTaskPIDqa::FillTOFHMPIDqa()
    1608             : {
    1609             :   //
    1610             :   // Fill PID qa histograms for the HMPID
    1611             :   //
    1612             :   
    1613           0 :   AliVEvent *event=InputEvent();
    1614             :   
    1615           0 :   Int_t ntracks=event->GetNumberOfTracks();
    1616           0 :   for(Int_t itrack = 0; itrack < ntracks; itrack++){
    1617           0 :     AliVTrack *track=(AliVTrack*)event->GetTrack(itrack);
    1618             :     
    1619             :     //
    1620             :     //basic track cuts
    1621             :     //
    1622           0 :     ULong_t status=track->GetStatus();
    1623             :     // not that nice. status bits not in virtual interface
    1624             :     // TPC refit + ITS refit +
    1625             :     // TOF out + TOFpid +
    1626             :     // kTIME
    1627           0 :     if (!((status & AliVTrack::kTPCrefit) == AliVTrack::kTPCrefit) ||
    1628           0 :         !((status & AliVTrack::kITSrefit) == AliVTrack::kITSrefit) ||
    1629           0 :         !((status & AliVTrack::kTOFout  ) == AliVTrack::kTOFout  ) ||
    1630           0 :         !((status & AliVTrack::kTOFpid  ) == AliVTrack::kTOFpid  ) ||
    1631           0 :         !((status & AliVTrack::kTIME    ) == AliVTrack::kTIME    ) ) continue;
    1632             : 
    1633           0 :     Float_t nCrossedRowsTPC = track->GetTPCClusterInfo(2,1);
    1634             :     Float_t  ratioCrossedRowsOverFindableClustersTPC = 1.0;
    1635           0 :     if (track->GetTPCNclsF()>0) {
    1636           0 :       ratioCrossedRowsOverFindableClustersTPC = nCrossedRowsTPC/track->GetTPCNclsF();
    1637           0 :     }
    1638             : 
    1639           0 :     if ( nCrossedRowsTPC<70 || ratioCrossedRowsOverFindableClustersTPC<.8 ) continue;
    1640             :     
    1641           0 :     Double_t mom = track->P();
    1642           0 :     Double_t ckovAngle = track->GetHMPIDsignal();
    1643             :     
    1644           0 :     Double_t nSigmaTOF[3]; 
    1645           0 :     TH1F *h[3];
    1646             :     
    1647           0 :     for (Int_t ispecie=2; ispecie<5; ++ispecie){
    1648             :       //TOF nSigma
    1649           0 :       nSigmaTOF[ispecie-2]=fPIDResponse->NumberOfSigmasTOF(track, (AliPID::EParticleType)ispecie);
    1650           0 :       h[ispecie-2] = (TH1F*)fListQAtofhmpid->At(ispecie-2);}
    1651             :       
    1652           0 :     if(TMath::Abs(nSigmaTOF[0])<2)                                                              h[0]->Fill(mom,ckovAngle);
    1653             :     
    1654           0 :     if(TMath::Abs(nSigmaTOF[1])<2 && TMath::Abs(nSigmaTOF[0])>3)                                h[1]->Fill(mom,ckovAngle);
    1655             : 
    1656           0 :     if(TMath::Abs(nSigmaTOF[2])<2 && TMath::Abs(nSigmaTOF[1])>3 && TMath::Abs(nSigmaTOF[0])>3)  h[2]->Fill(mom,ckovAngle);
    1657             :       
    1658           0 :   }
    1659             :   
    1660           0 : }
    1661             : 
    1662             : //______________________________________________________________________________
    1663             : void AliAnalysisTaskPIDqa::FillTPCTOFqa()
    1664             : {
    1665             :   //
    1666             :   // Fill PID qa histograms for the TOF
    1667             :   //   Here also the TPC histograms after TOF selection are filled
    1668             :   //
    1669             : 
    1670           0 :   AliVEvent *event=InputEvent();
    1671             : 
    1672           0 :   Int_t ntracks=event->GetNumberOfTracks();
    1673           0 :   for(Int_t itrack = 0; itrack < ntracks; itrack++){
    1674           0 :     AliVTrack *track=(AliVTrack*)event->GetTrack(itrack);
    1675             : 
    1676             :     //
    1677             :     //basic track cuts
    1678             :     //
    1679           0 :     ULong_t status=track->GetStatus();
    1680             :     // not that nice. status bits not in virtual interface
    1681             :     // TPC refit + ITS refit +
    1682             :     // TOF out + TOFpid +
    1683             :     // kTIME
    1684           0 :     if (!((status & AliVTrack::kTPCrefit) == AliVTrack::kTPCrefit) ||
    1685           0 :         !((status & AliVTrack::kITSrefit) == AliVTrack::kITSrefit) ||
    1686             : //         !( (status & AliVTrack::kTPCpid  ) == AliVTrack::kTPCpid ) || //removes light nuclei, so it is out for the moment
    1687           0 :         !((status & AliVTrack::kTOFout  ) == AliVTrack::kTOFout  ) ||
    1688             :         //!((status & AliVTrack::kTOFpid  ) == AliVTrack::kTOFpid  ) || // not valid any longer with new TOF structure
    1689           0 :         !((status & AliVTrack::kTIME    ) == AliVTrack::kTIME    ) ) continue;
    1690             : 
    1691           0 :     Float_t nCrossedRowsTPC = track->GetTPCClusterInfo(2,1);
    1692             :     Float_t  ratioCrossedRowsOverFindableClustersTPC = 1.0;
    1693           0 :     if (track->GetTPCNclsF()>0) {
    1694           0 :       ratioCrossedRowsOverFindableClustersTPC = nCrossedRowsTPC/track->GetTPCNclsF();
    1695           0 :     }
    1696             : 
    1697           0 :     if ( nCrossedRowsTPC<70 || ratioCrossedRowsOverFindableClustersTPC<.8 ) continue;
    1698             : 
    1699             : 
    1700           0 :     Double_t mom=track->P();
    1701           0 :     Double_t momTPC=track->GetTPCmomentum();
    1702             : 
    1703           0 :     for (Int_t ispecie=0; ispecie<AliPID::kSPECIESC; ++ispecie){
    1704             :       //TOF nSigma
    1705           0 :       Double_t nSigmaTOF=fPIDResponse->NumberOfSigmasTOF(track, (AliPID::EParticleType)ispecie);
    1706           0 :       Double_t nSigmaTPC=fPIDResponse->NumberOfSigmasTPC(track, (AliPID::EParticleType)ispecie);
    1707             : 
    1708             :       //TPC after TOF cut
    1709           0 :       TH2 *h=(TH2*)fListQAtpctof->At(ispecie);
    1710           0 :       if (h && TMath::Abs(nSigmaTOF)<3.) h->Fill(momTPC,nSigmaTPC);
    1711             : 
    1712             :       //TOF after TPC cut
    1713           0 :       h=(TH2*)fListQAtpctof->At(ispecie+AliPID::kSPECIESC);
    1714           0 :       if (h && TMath::Abs(nSigmaTPC)<3.) h->Fill(mom,nSigmaTOF);
    1715             : 
    1716             :       //EMCAL after TOF and TPC cut
    1717           0 :       h=(TH2*)fListQAtpctof->At(ispecie+2*AliPID::kSPECIESC);
    1718           0 :       if (h && TMath::Abs(nSigmaTOF)<3. && TMath::Abs(nSigmaTPC)<3. ){
    1719             : 
    1720           0 :         Int_t nMatchClus = track->GetEMCALcluster();
    1721           0 :         Double_t pt      = track->Pt();
    1722             :         Double_t eop     = -1.;
    1723             :         
    1724           0 :         if(nMatchClus > -1){
    1725             :           
    1726           0 :           AliVCluster *matchedClus = (AliVCluster*)event->GetCaloCluster(nMatchClus);
    1727             :           
    1728           0 :           if(matchedClus){
    1729             :             
    1730             :             // matched cluster is EMCAL
    1731           0 :             if(matchedClus->IsEMCAL()){
    1732             :               
    1733           0 :               Double_t fClsE       = matchedClus->E();
    1734           0 :               eop                  = fClsE/mom;
    1735             : 
    1736           0 :               h->Fill(pt,eop);
    1737             :  
    1738             :               
    1739           0 :             }
    1740             :           }
    1741           0 :         }
    1742           0 :       }
    1743             :     }
    1744           0 :   }
    1745           0 : }
    1746             : 
    1747             : //_____________________________________________________________________________
    1748             : void AliAnalysisTaskPIDqa::FillQAinfo()
    1749             : {
    1750             :   //
    1751             :   // Fill the QA information
    1752             :   //
    1753             : 
    1754             : 
    1755             :   //TPC QA info
    1756           0 :   TObjArray *arrTPC=static_cast<TObjArray*>(fListQAinfo->At(0));
    1757             : 
    1758           0 :   if (fPIDResponse && arrTPC){
    1759           0 :     AliTPCPIDResponse &tpcResp=fPIDResponse->GetTPCResponse();
    1760             : 
    1761             :     // ===| spline names |======================================================
    1762           0 :     if (!arrTPC->UncheckedAt(0)){
    1763           0 :       TH1F *hTPCsplineNames = new TH1F("TPCsplineNames","TPCsplineNames",Int_t(AliPID::kSPECIESC),0.,Double_t(AliPID::kSPECIESC));
    1764           0 :       arrTPC->AddAt(hTPCsplineNames,0);
    1765             :       
    1766           0 :       for (Int_t iresp=0; iresp<AliPID::kSPECIESC; ++iresp){
    1767           0 :         const TObject *o=tpcResp.GetResponseFunction((AliPID::EParticleType)iresp);
    1768           0 :         if (!o) continue;
    1769           0 :         hTPCsplineNames->GetXaxis()->SetBinLabel(iresp+1, Form("%02d: %s",iresp, o->GetName()));
    1770           0 :       }
    1771           0 :     }
    1772             : 
    1773             :     // ===| tpc response config |===============================================
    1774           0 :     if (!arrTPC->UncheckedAt(1)){
    1775           0 :       TH1F *hTPCconfigInfo = new TH1F("TPCconfigInfo","TPCconfigInfo", 4,0., 4.);
    1776           0 :       arrTPC->AddAt(hTPCconfigInfo,1);
    1777             : 
    1778             :       Int_t ibin=1;
    1779           0 :       hTPCconfigInfo->GetXaxis()->SetBinLabel(ibin++,Form("Eta Corr map: %s", tpcResp.GetEtaCorrMap()?tpcResp.GetEtaCorrMap()->GetName():"none"));
    1780           0 :       hTPCconfigInfo->GetXaxis()->SetBinLabel(ibin++,Form("Sigma Par map: %s", tpcResp.GetSigmaPar1Map()?tpcResp.GetSigmaPar1Map()->GetName():"none"));
    1781           0 :       hTPCconfigInfo->GetXaxis()->SetBinLabel(ibin++,Form("MIP: %.2f", tpcResp.GetMIP()));
    1782           0 :       hTPCconfigInfo->GetXaxis()->SetBinLabel(ibin++,Form("Res: Def %.3g (%.3g) : AllHigh %.3g (%.3g) : OROC high %.3g (%.3g)",
    1783           0 :                           tpcResp.GetRes0(AliTPCPIDResponse::kDefault), tpcResp.GetResN2(AliTPCPIDResponse::kDefault),
    1784           0 :                           tpcResp.GetRes0(AliTPCPIDResponse::kALLhigh), tpcResp.GetResN2(AliTPCPIDResponse::kALLhigh),
    1785           0 :                           tpcResp.GetRes0(AliTPCPIDResponse::kOROChigh), tpcResp.GetResN2(AliTPCPIDResponse::kOROChigh)
    1786             :                          ));
    1787           0 :     }
    1788           0 :   }
    1789           0 : }
    1790             : 
    1791             : //______________________________________________________________________________
    1792             : void AliAnalysisTaskPIDqa::SetupITSqa()
    1793             : {
    1794             :   //
    1795             :   // Create the ITS qa objects
    1796             :   //
    1797             :   
    1798           0 :   TVectorD *vX=MakeLogBinning(200,.1,30);
    1799             :   
    1800             :   //ITS+TPC tracks
    1801           0 :   for (Int_t ispecie=0; ispecie<AliPID::kSPECIESC; ++ispecie){
    1802           0 :     TH2F *hNsigmaP = new TH2F(Form("hNsigmaP_ITS_%s",AliPID::ParticleName(ispecie)),
    1803           0 :                               Form("ITS n#sigma %s vs. p;p [GeV]; n#sigma",AliPID::ParticleName(ispecie)),
    1804           0 :                               vX->GetNrows()-1,vX->GetMatrixArray(),
    1805             :                               200,-10,10);
    1806           0 :     fListQAits->Add(hNsigmaP);
    1807             :   }
    1808           0 :   TH2F *hSig = new TH2F("hSigP_ITS",
    1809             :                         "ITS signal vs. p;p [GeV]; ITS signal [arb. units]",
    1810           0 :                         vX->GetNrows()-1,vX->GetMatrixArray(),
    1811             :                         300,0,300);
    1812           0 :   fListQAits->Add(hSig);
    1813             : 
    1814             :   //ITS Standalone tracks
    1815           0 :   for (Int_t ispecie=0; ispecie<AliPID::kSPECIESC; ++ispecie){
    1816           0 :     TH2F *hNsigmaPSA = new TH2F(Form("hNsigmaP_ITSSA_%s",AliPID::ParticleName(ispecie)),
    1817           0 :                                 Form("ITS n#sigma %s vs. p;p [GeV]; n#sigma",AliPID::ParticleName(ispecie)),
    1818           0 :                                 vX->GetNrows()-1,vX->GetMatrixArray(),
    1819             :                                 200,-10,10);
    1820           0 :     fListQAitsSA->Add(hNsigmaPSA);
    1821             :   }
    1822           0 :   TH2F *hSigSA = new TH2F("hSigP_ITSSA",
    1823             :                           "ITS signal vs. p;p [GeV]; ITS signal [arb. units]",
    1824           0 :                           vX->GetNrows()-1,vX->GetMatrixArray(),
    1825             :                           300,0,300);
    1826           0 :   fListQAitsSA->Add(hSigSA);
    1827             :   
    1828             :   //ITS Pure Standalone tracks
    1829           0 :   for (Int_t ispecie=0; ispecie<AliPID::kSPECIESC; ++ispecie){
    1830           0 :     TH2F *hNsigmaPPureSA = new TH2F(Form("hNsigmaP_ITSPureSA_%s",AliPID::ParticleName(ispecie)),
    1831           0 :                                     Form("ITS n#sigma %s vs. p;p [GeV]; n#sigma",AliPID::ParticleName(ispecie)),
    1832           0 :                                     vX->GetNrows()-1,vX->GetMatrixArray(),
    1833             :                                     200,-10,10);
    1834           0 :     fListQAitsPureSA->Add(hNsigmaPPureSA);
    1835             :   }
    1836           0 :   TH2F *hSigPureSA = new TH2F("hSigP_ITSPureSA",
    1837             :                               "ITS signal vs. p;p [GeV]; ITS signal [arb. units]",
    1838           0 :                               vX->GetNrows()-1,vX->GetMatrixArray(),
    1839             :                               300,0,300);
    1840           0 :   fListQAitsPureSA->Add(hSigPureSA);
    1841             :   
    1842           0 :   delete vX;  
    1843           0 : }
    1844             : 
    1845             : //_____________________________________________________________________________
    1846             : void AliAnalysisTaskPIDqa::AddTPCHistogramsSignal(TList *sublist, const char *scenario, Int_t scnumber)
    1847             : {
    1848             :   //
    1849             :   // Create the TPC qa objects: create histograms for the TPC signal for different settings
    1850             :   //
    1851             : 
    1852           0 :   TVectorD *vX=MakeLogBinning(200,.1,30);
    1853             :   Int_t nBinsMult = 38;
    1854           0 :   Double_t xBinsMult[39] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 
    1855             :                            120, 140, 160, 180, 200, 
    1856             :                            300, 400, 500, 600, 700, 800, 900, 1000, 
    1857             :                            1200, 1400, 1600, 1800, 2000, 
    1858             :                            2200, 2400, 2600, 2800, 3000, 
    1859             :                            3200, 3400, 3600, 3800, 4000
    1860             :                            };
    1861             :   const Int_t binsEta=110;
    1862             :   Float_t etaMin=-1.1;
    1863             :   Float_t etaMax=1.1;
    1864             : 
    1865             :   const Int_t binsPhi=90;
    1866             :   Float_t phiMin=0.;
    1867             :   Float_t phiMax=6.283;
    1868             : 
    1869           0 :   char signal[4][12]={"std","IROC","OROCmedium","OROClong"};
    1870             : 
    1871             :   Int_t nSpecies=0;
    1872             :   
    1873             :   // TPC signal vs. p for different particle species (standard, IROC, OROCmedium, OROClong) (V0)
    1874             :   // TPC signal vs. p for all particles (standard, IROC, OROCmedium, OROClong) (other scenarios)
    1875           0 :   if (scnumber == 4) {
    1876             :     nSpecies=(Int_t)AliPID::kSPECIES;
    1877           0 :     for (Int_t ispecie=0; ispecie<nSpecies; ++ispecie){
    1878           0 :       if ( ispecie == 1 || ispecie == 3 ) continue;  // Muons and Kaons are not filled for V0s
    1879             :       else {
    1880           0 :         for (Int_t iSig=0; iSig<4; iSig++) {
    1881           0 :           TH2F *hSigP = new TH2F(Form("hSigP_TPC_%s_%s_%s",signal[iSig],scenario,AliPID::ParticleName(ispecie)),
    1882           0 :                               Form("TPC_%s n#sigma (%s) %s vs. p;p (GeV/c); TPC signal (arb. units)",scenario,signal[iSig],AliPID::ParticleName(ispecie)),
    1883           0 :                               vX->GetNrows()-1,vX->GetMatrixArray(),
    1884             :                               300,0,300);
    1885           0 :           sublist->Add(hSigP);
    1886             :         }
    1887             :       }
    1888           0 :     }
    1889           0 :   }
    1890             :   else {
    1891           0 :     for (Int_t iSig=0; iSig<4; iSig++) {
    1892           0 :       TH2F *hSigP = new TH2F(Form("hSigP_TPC_%s_%s",signal[iSig],scenario),
    1893           0 :                              Form("TPC_%s signal (%s) vs. p;p (GeV/c); TPC signal (arb. units)",scenario,signal[iSig]),
    1894           0 :                              vX->GetNrows()-1,vX->GetMatrixArray(),
    1895             :                              300,0,300);
    1896           0 :       sublist->Add(hSigP);
    1897             :     }
    1898             :   }
    1899             : 
    1900             :   // MIP pions: TPC signal vs. eta
    1901           0 :   for (Int_t iSig=0; iSig<4; iSig++) {
    1902           0 :     TH2F *hSigEtaMIPpi = new TH2F(Form("hSigEta_TPC_%s_%s_MIPpi",signal[iSig],scenario),
    1903           0 :                                   Form("TPC_%s signal (%s) MIPpi vs. eta;#eta;TPC signal (arb. units)",scenario,signal[iSig]),
    1904             :                                   binsEta,etaMin,etaMax,
    1905             :                                   300,0,300);
    1906           0 :     sublist->Add(hSigEtaMIPpi);
    1907             :   }
    1908             : 
    1909             :   // MIP pions: TPC signal vs. phi
    1910           0 :   for (Int_t iSig=0; iSig<4; iSig++) {
    1911           0 :     TH2F *hSigPhiMIPpi = new TH2F(Form("hSigPhi_TPC_%s_%s_MIPpi",signal[iSig],scenario),
    1912           0 :                                   Form("TPC_%s signal (%s) MIPpi vs. phi;#phi;TPC signal (arb. units)",scenario,signal[iSig]),
    1913             :                                   binsPhi,phiMin,phiMax,
    1914             :                                   300,0,300);
    1915           0 :     sublist->Add(hSigPhiMIPpi);
    1916             :   }
    1917             : 
    1918             :   // MIP pions: TPC signal vs. multiplicity
    1919           0 :   for (Int_t iSig=0; iSig<4; iSig++) {
    1920           0 :     TH2F *hSigMultMPIpi = new TH2F(Form("hSigMult_TPC_%s_%s_MIPpi",signal[iSig],scenario),
    1921           0 :                                    Form("TPC_%s signal (%s) MIPpi vs. mult;multiplicity;TPC signal (arb. units)",scenario,signal[iSig]),
    1922           0 :                                    nBinsMult,xBinsMult,
    1923             :                                    300,0,300);
    1924           0 :     sublist->Add(hSigMultMPIpi);
    1925             :   }
    1926             :  
    1927             :   // Electrons: TPC signal vs. eta
    1928           0 :   for (Int_t iSig=0; iSig<4; iSig++) {
    1929           0 :     TH2F *hSigEtaEle = new TH2F(Form("hSigEta_TPC_%s_%s_Ele",signal[iSig],scenario),
    1930           0 :                                 Form("TPC_%s signal (%s) electrons vs. eta;#eta;TPC signal (arb. units)",scenario,signal[iSig]),
    1931             :                                 binsEta,etaMin,etaMax,
    1932             :                                 300,0,300);
    1933           0 :     sublist->Add(hSigEtaEle);
    1934             :   }
    1935             : 
    1936             :   // Electrons: TPC signal vs. phi
    1937           0 :   for (Int_t iSig=0; iSig<4; iSig++) {
    1938           0 :     TH2F *hSigPhiEle = new TH2F(Form("hSigPhi_TPC_%s_%s_Ele",signal[iSig],scenario),
    1939           0 :                                   Form("TPC_%s signal (%s) electrons vs. phi;#phi;TPC signal (arb. units)",scenario,signal[iSig]),
    1940             :                                   binsPhi,phiMin,phiMax,
    1941             :                                   300,0,300);
    1942           0 :     sublist->Add(hSigPhiEle);
    1943             :   }
    1944             : 
    1945             :   // Electrons: TPC signal vs. multiplicity
    1946           0 :   for (Int_t iSig=0; iSig<4; iSig++) {
    1947           0 :     TH2F *hSigMultEle = new TH2F(Form("hSigMult_TPC_%s_%s_Ele",signal[iSig],scenario),
    1948           0 :                                  Form("TPC_%s signal (%s) electrons vs. mult;multiplicity;TPC signal (arb. units)",scenario,signal[iSig]),
    1949           0 :                                  nBinsMult,xBinsMult,
    1950             :                                  300,0,300);
    1951           0 :     sublist->Add(hSigMultEle);
    1952             :   }
    1953             : 
    1954           0 :   delete vX;
    1955             : 
    1956           0 : }
    1957             : 
    1958             : //_____________________________________________________________________________
    1959             : void AliAnalysisTaskPIDqa::AddTPCHistogramsNsigma(TList *sublist, const char *scenario, Int_t scnumber)
    1960             : {
    1961             :   //
    1962             :   // Create the TPC qa objects: create histograms for TPC Nsigma for different settings
    1963             :   //
    1964             : 
    1965           0 :   TVectorD *vX=MakeLogBinning(200,.1,30.);
    1966             :   Int_t nBinsMult = 38;
    1967           0 :   Double_t xBinsMult[39] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 
    1968             :                            120, 140, 160, 180, 200, 
    1969             :                            300, 400, 500, 600, 700, 800, 900, 1000, 
    1970             :                            1200, 1400, 1600, 1800, 2000, 
    1971             :                            2200, 2400, 2600, 2800, 3000, 
    1972             :                            3200, 3400, 3600, 3800, 4000
    1973             :                            };
    1974             :   const Int_t binsEta=110;
    1975             :   Float_t etaMin=-1.1;
    1976             :   Float_t etaMax=1.1;
    1977             : 
    1978             :   Int_t nSpecies=0;
    1979             :   
    1980           0 :   if (scnumber == 4) nSpecies=(Int_t)AliPID::kSPECIES;
    1981             :   else nSpecies=(Int_t)AliPID::kSPECIESC; 
    1982             : 
    1983             :   // Nsigma vs. p for different particle species
    1984           0 :   for (Int_t ispecie=0; ispecie<nSpecies; ++ispecie){
    1985           0 :     if ( scnumber == 4 && ispecie == 1 ) continue;  // Muons are not filled for V0s (scnumber==4)
    1986           0 :     else if ( scnumber == 4 && ispecie == 3 ) continue;  // Kaons are not filled for V0s (scnumber==4)
    1987             :     else {
    1988           0 :       TH2F *hNsigmaP = new TH2F(Form("hNsigmaP_TPC_%s_%s",scenario,AliPID::ParticleName(ispecie)),
    1989           0 :                               Form("TPC_%s n#sigma %s vs. p;p (GeV/c); n#sigma",scenario,AliPID::ParticleName(ispecie)),
    1990           0 :                               vX->GetNrows()-1,vX->GetMatrixArray(),
    1991             :                               200,-10,10);
    1992           0 :       sublist->Add(hNsigmaP);
    1993             :     }
    1994           0 :   }
    1995             : 
    1996             :   // Nsigma vs. eta for different particle species (only for some scenarios)
    1997           0 :   if ( scnumber == 1 || scnumber == 4 ) {
    1998           0 :     for (Int_t ispecie=0; ispecie<nSpecies; ++ispecie){
    1999           0 :       if ( scnumber == 4 && ispecie == 1 ) continue;  // Muons are not filled for V0s (scnumber==4)
    2000           0 :       else if ( scnumber == 4 && ispecie == 3 ) continue;  // Kaons are not filled for V0s (scnumber==4)
    2001             :       else {
    2002           0 :         TH2F *hNsigmaEta = new TH2F(Form("hNsigmaEta_TPC_%s_%s",scenario,AliPID::ParticleName(ispecie)),
    2003           0 :                               Form("TPC_%s n#sigma %s vs. eta;#eta; n#sigma",scenario,AliPID::ParticleName(ispecie)),
    2004             :                               binsEta,etaMin,etaMax,
    2005             :                               200,-10,10);
    2006           0 :         sublist->Add(hNsigmaEta);
    2007             :       }
    2008           0 :     }
    2009           0 :   }
    2010             : 
    2011             :   // Nsigma vs. multiplicity for different particle species (only for some scenarios)
    2012           0 :   if ( scnumber == 1 || scnumber == 4 ) {
    2013           0 :     for (Int_t ispecie=0; ispecie<nSpecies; ++ispecie){
    2014           0 :       if ( scnumber == 4 && ispecie == 1 ) continue;  // Muons are not filled for V0s (scnumber==4)
    2015           0 :       else if ( scnumber == 4 && ispecie == 3 ) continue;  // Kaons are not filled for V0s (scnumber==4)
    2016             :       else {
    2017           0 :         TH2F *hNsigmaMult = new TH2F(Form("hNsigmaMult_TPC_%s_%s",scenario,AliPID::ParticleName(ispecie)),
    2018           0 :                               Form("TPC_%s n#sigma %s vs. mult;multiplicity; n#sigma",scenario,AliPID::ParticleName(ispecie)),
    2019           0 :                               nBinsMult,xBinsMult,
    2020             :                               200,-10,10);
    2021           0 :         sublist->Add(hNsigmaMult);
    2022             :       }
    2023           0 :     }
    2024           0 :   }
    2025             : 
    2026             :   // - Beginn: Adding histograms for MIP pions and electrons (only for some scenarios) -
    2027           0 :   if ( scnumber == 0 || scnumber == 2 || scnumber == 3 ) {
    2028             : 
    2029             :     // MIP pions: Nsigma vs. eta 
    2030           0 :     TH2F *hNsigmaEtaMIPpi = new TH2F(Form("hNsigmaEta_TPC_%s_MIPpi",scenario),
    2031           0 :                               Form("TPC_%s n#sigma MIPpi vs. eta;#eta; n#sigma",scenario),
    2032             :                               binsEta,etaMin,etaMax,
    2033             :                               200,-10,10);
    2034           0 :     sublist->Add(hNsigmaEtaMIPpi);
    2035             : 
    2036             :     // MIP pions: Nsigma vs. multiplicity
    2037           0 :     TH2F *hNsigmaMultMIPpi = new TH2F(Form("hNsigmaMult_TPC_%s_MIPpi",scenario),
    2038           0 :                                Form("TPC_%s n#sigma MIPpi vs. mult;multiplicity; n#sigma",scenario),
    2039           0 :                                nBinsMult,xBinsMult,
    2040             :                                200,-10,10);
    2041           0 :     sublist->Add(hNsigmaMultMIPpi);
    2042             : 
    2043             :     // Electrons: Nsigma vs. eta
    2044           0 :     TH2F *hNsigmaEtaEle = new TH2F(Form("hNsigmaEta_TPC_%s_Ele",scenario),
    2045           0 :                               Form("TPC_%s n#sigma electrons vs. eta;#eta; n#sigma",scenario),
    2046             :                               binsEta,etaMin,etaMax,
    2047             :                               200,-10,10);
    2048           0 :     sublist->Add(hNsigmaEtaEle);
    2049             : 
    2050             :     // Electrons: Nsigma vs. multiplicity
    2051           0 :     TH2F *hNsigmaMultEle = new TH2F(Form("hNsigmaMult_TPC_%s_Ele",scenario),
    2052           0 :                                Form("TPC_%s n#sigma electrons vs. mult;multiplicity; n#sigma",scenario),
    2053             :                                nBinsMult,xBinsMult,
    2054             :                                200,-10,10);
    2055           0 :     sublist->Add(hNsigmaMultEle);
    2056           0 :   } // - End: Adding histograms for MIP pions and electrons
    2057             : 
    2058           0 :   delete vX;
    2059             : 
    2060           0 : }
    2061             : 
    2062             : //______________________________________________________________________________
    2063             : void AliAnalysisTaskPIDqa::SetupTPCqa(Bool_t fillMC, Bool_t fill11h, Bool_t fillV0)
    2064             : {
    2065             :   //
    2066             :   // Create the TPC qa objects
    2067             :   //
    2068             :   
    2069             :   // Set up the multiplicity binning
    2070             :   Int_t nBinsMult = 38;
    2071           0 :   Double_t xBinsMult[39] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 
    2072             :                            120, 140, 160, 180, 200, 
    2073             :                            300, 400, 500, 600, 700, 800, 900, 1000, 
    2074             :                            1200, 1400, 1600, 1800, 2000, 
    2075             :                            2200, 2400, 2600, 2800, 3000, 
    2076             :                            3200, 3400, 3600, 3800, 4000
    2077             :                            };
    2078             : 
    2079             : 
    2080             :   // Create TPC sublists for different scenarios 
    2081             :   // corresponding to available information, 
    2082             :   // e.g. MC or not, special settings for LHC11h
    2083             : 
    2084             :   // basic/default scenario, used always
    2085           0 :   fListQAtpcBasic=new TList;
    2086           0 :   fListQAtpcBasic->SetOwner();
    2087           0 :   fListQAtpcBasic->SetName("TPCBasic");
    2088           0 :   fListQAtpc->Add(fListQAtpcBasic);
    2089             :  
    2090             :   // MC truth scenario: use only MC truth identified particles
    2091             :   // only available for MC
    2092           0 :   if (fillMC == kTRUE) {
    2093           0 :     fListQAtpcMCtruth=new TList;
    2094           0 :     fListQAtpcMCtruth->SetOwner();
    2095           0 :     fListQAtpcMCtruth->SetName("TPCMCtruth");
    2096           0 :     fListQAtpc->Add(fListQAtpcMCtruth);
    2097           0 :   }
    2098             :   
    2099             : /* // special LHC11h setting not used and commented now
    2100             :   // Hybrid and OROChigh scenarios, 
    2101             :   // special settings only available for PbPb LHC11h data
    2102             :   if (fill11h == kTRUE) {
    2103             :     fListQAtpcHybrid=new TList;
    2104             :     fListQAtpcHybrid->SetOwner();
    2105             :     fListQAtpcHybrid->SetName("TPCHybrid");
    2106             :     fListQAtpc->Add(fListQAtpcHybrid);
    2107             :   
    2108             :     fListQAtpcOROChigh=new TList;
    2109             :     fListQAtpcOROChigh->SetOwner();
    2110             :     fListQAtpcOROChigh->SetName("TPCOROChigh");
    2111             :     fListQAtpc->Add(fListQAtpcOROChigh);
    2112             :   }
    2113             : */
    2114             : 
    2115             :   // scenario only for V0s, 
    2116             :   // only available for ESDs
    2117           0 :   if (fillV0 == kTRUE) {
    2118           0 :     fListQAtpcV0=new TList;
    2119           0 :     fListQAtpcV0->SetOwner();
    2120           0 :     fListQAtpcV0->SetName("TPCV0");
    2121           0 :     fListQAtpc->Add(fListQAtpcV0);
    2122           0 :   }
    2123             : 
    2124             : 
    2125             :   // the default ("basic") scenario
    2126           0 :   AddTPCHistogramsNsigma(fListQAtpcBasic,"Basic",0);
    2127           0 :   AddTPCHistogramsSignal(fListQAtpcBasic,"Basic",0);
    2128             : 
    2129             :   // only MC truth identified particles
    2130           0 :   if (fillMC) {
    2131           0 :     AddTPCHistogramsNsigma(fListQAtpcMCtruth,"MCtruth",1);
    2132           0 :   }
    2133             : 
    2134             : /* // special LHC11h setting not used and commented now
    2135             :   // the "hybrid" scenario (only for period LHC11h)
    2136             :   if (fill11h) {
    2137             :     AddTPCHistogramsNsigma(fListQAtpcHybrid,"Hybrid",2);
    2138             :   }
    2139             : 
    2140             :   // the "OROC high" scenario (only for period LHC11h)
    2141             :   if (fill11h) {
    2142             :     AddTPCHistogramsNsigma(fListQAtpcOROChigh,"OROChigh",3);
    2143             :   }
    2144             : */
    2145             :   
    2146             :   // only for V0s
    2147           0 :   if (fillV0) {
    2148           0 :     AddTPCHistogramsNsigma(fListQAtpcV0,"V0",4);
    2149           0 :     AddTPCHistogramsSignal(fListQAtpcV0,"V0",4);
    2150           0 :   }
    2151             :  
    2152             : 
    2153             :   // Multiplicity distribution --- as check
    2154           0 :   TH1F *hMult = new TH1F("hMult_TPC",
    2155             :                          "Multiplicity distribution;multiplicity;counts",
    2156           0 :                          nBinsMult,xBinsMult);
    2157           0 :   fListQAtpc->Add(hMult);
    2158             : 
    2159           0 : }
    2160             : 
    2161             : //______________________________________________________________________________
    2162             : void AliAnalysisTaskPIDqa::SetupTRDqa()
    2163             : {
    2164             :   //
    2165             :   // Create the TRD qa objects
    2166             :   //
    2167           0 :   TVectorD *vX=MakeLogBinning(200,.1,30);
    2168           0 :   for(Int_t itl = 0; itl < 6; ++itl){
    2169           0 :     for(Int_t ispecie = 0; ispecie < AliPID::kSPECIES; ispecie++){
    2170           0 :       TH2F *hLikeP = new TH2F(Form("hLikeP_TRD_%dtls_%s", itl, AliPID::ParticleName(ispecie)),
    2171           0 :                               Form("TRD Likelihood to be %s %s for tracks having %d %s; p (GeV/c); TRD %s Likelihood", ispecie == 0 ? "an" : "a", AliPID::ParticleName(ispecie), itl+1, itl == 0 ? "tracklet" : "tracklets", AliPID::ParticleName(ispecie)),
    2172           0 :                               vX->GetNrows()-1, vX->GetMatrixArray(),
    2173             :                               100, 0., 1.);
    2174           0 :       fListQAtrd->Add(hLikeP);
    2175             :     }
    2176             :   }
    2177             : 
    2178             :   // === nSigma Values and signal ===
    2179           0 :   for (Int_t ispecie=0; ispecie<AliPID::kSPECIESC; ++ispecie){
    2180           0 :     TH2F *hNsigmaP = new TH2F(Form("hNsigmaP_TRD_%s",AliPID::ParticleName(ispecie)),
    2181           0 :                               Form("TRD n#sigma %s vs. p;p [GeV]; n#sigma",AliPID::ParticleName(ispecie)),
    2182           0 :                               vX->GetNrows()-1,vX->GetMatrixArray(),
    2183             :                               100,-10,10);
    2184           0 :     fListQAtrdNsig->Add(hNsigmaP);
    2185             :   }
    2186             : 
    2187           0 :   TH2F *hSig = new TH2F("hSigP_TRD",
    2188             :                         "TRD signal vs. p;p [GeV]; TRD signal [arb. units]",
    2189           0 :                         vX->GetNrows()-1,vX->GetMatrixArray(),
    2190             :                         100,0,100);
    2191           0 :   fListQAtrdNsig->Add(hSig);
    2192             : 
    2193           0 :   fListQAtrd->Add(fListQAtrdNsig);
    2194             : 
    2195             :   // === Same after 3 sigma in TPC and TOF
    2196           0 :   for (Int_t ispecie=0; ispecie<AliPID::kSPECIESC; ++ispecie){
    2197           0 :     TH2F *hNsigmaP = new TH2F(Form("hNsigmaP_TRD_TPCTOF_%s",AliPID::ParticleName(ispecie)),
    2198           0 :                               Form("TRD n#sigma %s vs. p after 3#sigma cut in TPC&TOF;p [GeV]; n#sigma",AliPID::ParticleName(ispecie)),
    2199           0 :                               vX->GetNrows()-1,vX->GetMatrixArray(),
    2200             :                               100,-10,10);
    2201           0 :     fListQAtrdNsigTPCTOF->Add(hNsigmaP);
    2202             :   }
    2203             :   
    2204           0 :   fListQAtrd->Add(fListQAtrdNsigTPCTOF);
    2205             :   
    2206           0 :   delete vX;
    2207           0 : }
    2208             : 
    2209             : //______________________________________________________________________________
    2210             : void AliAnalysisTaskPIDqa::SetupTOFqa()
    2211             : {
    2212             :   //
    2213             :   // Create the TOF qa objects
    2214             :   //
    2215             :   
    2216           0 :   TVectorD *vX=MakeLogBinning(200,.1,30);
    2217             : 
    2218           0 :   for (Int_t ispecie=0; ispecie<AliPID::kSPECIESC; ++ispecie){
    2219           0 :     TH2F *hNsigmaP = new TH2F(Form("hNsigmaP_TOF_%s",AliPID::ParticleName(ispecie)),
    2220           0 :                               Form("TOF n#sigma %s vs. p;p [GeV]; n#sigma",AliPID::ParticleName(ispecie)),
    2221           0 :                               vX->GetNrows()-1,vX->GetMatrixArray(),
    2222             :                               200,-10,10);
    2223           0 :     fListQAtof->Add(hNsigmaP);
    2224             :   }
    2225             : 
    2226           0 :   TH1F *hnSigT0Fill = new TH1F("hNsigma_TOF_Pion_T0-Fill","TOF n#sigma (Pion) T0-FILL [0.75-1.25. GeV/c]",200,-10,10);
    2227           0 :   fListQAtof->Add(hnSigT0Fill);
    2228           0 :   TH1F *hnSigT0T0 = new TH1F("hNsigma_TOF_Pion_T0-T0","TOF n#sigma (Pion) T0-T0 [0.75-1.25 GeV/c]",200,-10,10);
    2229           0 :   fListQAtof->Add(hnSigT0T0);
    2230           0 :   TH1F *hnSigT0TOF = new TH1F("hNsigma_TOF_Pion_T0-TOF","TOF n#sigma (Pion) T0-TOF [0.75-1.25 GeV/c]",200,-10,10);
    2231           0 :   fListQAtof->Add(hnSigT0TOF);
    2232           0 :   TH1F *hnSigT0Best = new TH1F("hNsigma_TOF_Pion_T0-Best","TOF n#sigma (Pion) T0-Best [0.75-1.25 GeV/c]",200,-10,10);
    2233           0 :   fListQAtof->Add(hnSigT0Best);
    2234           0 :   TH1F *hnDeltaPi = new TH1F("hDelta_TOF_Pion","DeltaT (Pion) [0.75-1.25 GeV/c]",50,-500,500);
    2235           0 :   fListQAtof->Add(hnDeltaPi);
    2236             :   
    2237           0 :   TH2F *hSig = new TH2F("hSigP_TOF",
    2238             :                         "TOF signal vs. p;p [GeV]; TOF signal [ns]",
    2239           0 :                         vX->GetNrows()-1,vX->GetMatrixArray(),
    2240             :                         300,0,30);
    2241             : 
    2242           0 :   delete vX;
    2243             :   
    2244           0 :   fListQAtof->Add(hSig);
    2245             : 
    2246           0 :   TH1F *hStartTimeMaskTOF = new TH1F("hStartTimeMask_TOF","StartTime mask",8,0,8);
    2247           0 :   fListQAtof->Add(hStartTimeMaskTOF);
    2248           0 :   TH1F *hStartTimeResTOF = new TH1F("hStartTimeRes_TOF","StartTime resolution [ps]",100,0,500);
    2249           0 :   fListQAtof->Add(hStartTimeResTOF);
    2250             : 
    2251           0 :   TH1F *hnTracksAtTOF = new TH1F("hnTracksAt_TOF","Matched tracks at TOF",100,0,100);
    2252           0 :   fListQAtof->Add(hnTracksAtTOF);
    2253           0 :   TH1F *hT0MakerEff = new TH1F("hT0MakerEff","Events with T0-TOF vs nTracks",100,0,100);
    2254           0 :   fListQAtof->Add(hT0MakerEff);
    2255             : 
    2256             :   // this in principle should stay on a T0 PID QA, but are just the data prepared for TOF use
    2257           0 :   TH1F *hStartTimeAT0 = new TH1F("hStartTimeA_T0","StartTime from T0A [ps]",1000,-1000,1000);
    2258           0 :   fListQAtof->Add(hStartTimeAT0);
    2259           0 :   TH1F *hStartTimeCT0 = new TH1F("hStartTimeC_T0","StartTime from T0C [ps]",1000,-1000,1000);
    2260           0 :   fListQAtof->Add(hStartTimeCT0);
    2261           0 :   TH1F *hStartTimeACT0 = new TH1F("hStartTimeAC_T0","StartTime from T0AC [ps]",1000,-1000,1000);;
    2262           0 :   fListQAtof->Add(hStartTimeACT0);
    2263           0 : }
    2264             : 
    2265             : 
    2266             : //______________________________________________________________________________
    2267             : void AliAnalysisTaskPIDqa::SetupT0qa()
    2268             : {
    2269             :   //
    2270             :   // Create the T0 qa objects
    2271             :   //
    2272             :   
    2273             :   // these are similar to plots inside TOFqa, but these are for all events
    2274           0 :   TH1F *hStartTimeAT0 = new TH1F("hStartTimeA_T0","StartTime from T0A [ps]",1000,-1000,1000);
    2275           0 :   fListQAt0->Add(hStartTimeAT0);
    2276           0 :   TH1F *hStartTimeCT0 = new TH1F("hStartTimeC_T0","StartTime from T0C [ps]",1000,-1000,1000);
    2277           0 :   fListQAt0->Add(hStartTimeCT0);
    2278           0 :   TH1F *hStartTimeACT0 = new TH1F("hStartTimeAC_T0","StartTime from T0AC [ps]",1000,-1000,1000);;
    2279           0 :   fListQAt0->Add(hStartTimeACT0);
    2280             : 
    2281           0 :   TH1F *hnTracksAtT0 = new TH1F("hnTracksAt_T0","Tracks for events selected for T0",100,0,100);
    2282           0 :   fListQAt0->Add(hnTracksAtT0);
    2283           0 :   TH1F *hT0AEff = new TH1F("hT0AEff","Events with T0A vs nTracks",100,0,100);
    2284           0 :   fListQAt0->Add(hT0AEff);
    2285           0 :   TH1F *hT0CEff = new TH1F("hT0CEff","Events with T0C vs nTracks",100,0,100);
    2286           0 :   fListQAt0->Add(hT0CEff);
    2287           0 :   TH1F *hT0AndEff = new TH1F("hT0AndEff","Events with T0AC (AND) vs nTracks",100,0,100);
    2288           0 :   fListQAt0->Add(hT0AndEff);
    2289           0 :   TH1F *hT0OrEff = new TH1F("hT0OrEff","Events with T0AC (OR) vs nTracks",100,0,100);
    2290           0 :   fListQAt0->Add(hT0OrEff);
    2291             : 
    2292             : 
    2293           0 : }
    2294             : 
    2295             : //______________________________________________________________________________
    2296             : void AliAnalysisTaskPIDqa::SetupEMCALqa()
    2297             : {
    2298             :   //
    2299             :   // Create the EMCAL qa objects
    2300             :   //
    2301             : 
    2302           0 :   TVectorD *vX=MakeLogBinning(200,.1,30);
    2303             :   
    2304           0 :   TH2F *hNsigmaPt = new TH2F(Form("hNsigmaPt_EMCAL_%s",AliPID::ParticleName(0)),
    2305           0 :                              Form("EMCAL n#sigma %s vs. p_{T};p_{T} [GeV]; n#sigma",AliPID::ParticleName(0)),
    2306           0 :                              vX->GetNrows()-1,vX->GetMatrixArray(),
    2307             :                              200,-10,10);
    2308           0 :   fListQAemcal->Add(hNsigmaPt);  
    2309             :   
    2310             : 
    2311           0 :   TH2F *hSigPtEle = new TH2F("hSigPt_EMCAL_Ele",
    2312             :                         "EMCAL signal (E/p) vs. p_{T} for electrons;p_{T} [GeV]; EMCAL signal (E/p) [arb. units]",
    2313           0 :                         vX->GetNrows()-1,vX->GetMatrixArray(),
    2314             :                         200,0,2);
    2315           0 :   fListQAemcal->Add(hSigPtEle);
    2316             : 
    2317           0 :   TH2F *hSigPtPions = new TH2F("hSigPt_EMCAL_Pions",
    2318             :                         "EMCAL signal (E/p) vs. p_{T} for pions;p_{T} [GeV]; EMCAL signal (E/p) [arb. units]",
    2319           0 :                         vX->GetNrows()-1,vX->GetMatrixArray(),
    2320             :                         200,0,2);
    2321           0 :   fListQAemcal->Add(hSigPtPions);
    2322             : 
    2323           0 :   TH2F *hSigPtProtons = new TH2F("hSigPt_EMCAL_Protons",
    2324             :                         "EMCAL signal (E/p) vs. p_{T} for protons;p_{T} [GeV]; EMCAL signal (E/p) [arb. units]",
    2325           0 :                         vX->GetNrows()-1,vX->GetMatrixArray(),
    2326             :                         200,0,2);
    2327           0 :   fListQAemcal->Add(hSigPtProtons);
    2328             : 
    2329           0 :   TH2F *hSigPtAntiProtons = new TH2F("hSigPt_EMCAL_Antiprotons",
    2330             :                         "EMCAL signal (E/p) vs. p_{T} for antiprotons;p_{T} [GeV]; EMCAL signal (E/p) [arb. units]",
    2331           0 :                         vX->GetNrows()-1,vX->GetMatrixArray(),
    2332             :                         200,0,2);
    2333           0 :   fListQAemcal->Add(hSigPtAntiProtons);
    2334             : 
    2335           0 :   delete vX;  
    2336           0 : }
    2337             : 
    2338             : //______________________________________________________________________________
    2339             : void AliAnalysisTaskPIDqa::SetupHMPIDqa()
    2340             : {
    2341             :   //
    2342             :   // Create the HMPID qa objects
    2343             :   //
    2344             : 
    2345           0 :   TVectorD *vX=MakeLogBinning(200,.1,30);
    2346             : 
    2347             :   // nSigmas
    2348             :   Int_t nhists=0;
    2349           0 :   for (Int_t ispecie=0; ispecie<AliPID::kSPECIES; ++ispecie){
    2350           0 :     if (ispecie==AliPID::kElectron || ispecie==AliPID::kMuon) continue;
    2351           0 :     TH2F *hNsigmaP = new TH2F(Form("hNsigmaP_HMPID_%s",AliPID::ParticleName(ispecie)),
    2352           0 :                               Form("HMPID n#sigma %s vs. p;p [GeV]; n#sigma",AliPID::ParticleName(ispecie)),
    2353           0 :                               vX->GetNrows()-1,vX->GetMatrixArray(),
    2354             :                               200,-10,10);
    2355           0 :     fListQAhmpid->AddAt(hNsigmaP, nhists);
    2356           0 :     ++nhists;
    2357           0 :   }
    2358             :   
    2359             :   // cherenkov angle
    2360           0 :   TH2F *hCkovAnglevsMom   = new TH2F("hCkovAnglevsMom",  "Cherenkov angle vs momentum",
    2361           0 :                                      vX->GetNrows()-1,vX->GetMatrixArray(),
    2362             :                                      500,0,1);
    2363           0 :   fListQAhmpid->AddAt(hCkovAnglevsMom,nhists);
    2364             :   
    2365           0 :   delete vX;
    2366           0 : }
    2367             : 
    2368             : //______________________________________________________________________________
    2369             : void AliAnalysisTaskPIDqa::SetupTOFHMPIDqa()
    2370             : {
    2371             :   //
    2372             :   // Create the HMPID qa objects
    2373             :   //
    2374             :   
    2375           0 :   TH2F *hCkovAnglevsMomPion   = new TH2F("hCkovAnglevsMom_pion",  "Cherenkov angle vs momentum for pions",500,0,5.,500,0,1);
    2376           0 :   fListQAtofhmpid->Add(hCkovAnglevsMomPion);
    2377             :   
    2378           0 :   TH2F *hCkovAnglevsMomKaon   = new TH2F("hCkovAnglevsMom_kaon",  "Cherenkov angle vs momentum for kaons",500,0,5.,500,0,1);
    2379           0 :   fListQAtofhmpid->Add(hCkovAnglevsMomKaon);
    2380             :   
    2381           0 :   TH2F *hCkovAnglevsMomProton = new TH2F("hCkovAnglevsMom_proton","Cherenkov angle vs momentum for protons",500,0,5.,500,0,1);
    2382           0 :   fListQAtofhmpid->Add(hCkovAnglevsMomProton);
    2383             :   
    2384             :   
    2385           0 : }  
    2386             : 
    2387             : //______________________________________________________________________________
    2388             : void AliAnalysisTaskPIDqa::SetupTPCTOFqa()
    2389             : {
    2390             :   //
    2391             :   // Create the qa objects for TPC + TOF combination
    2392             :   //
    2393             :   
    2394           0 :   TVectorD *vX=MakeLogBinning(200,.1,30);
    2395             : 
    2396             :   //TPC signals after TOF cut
    2397           0 :   for (Int_t ispecie=0; ispecie<AliPID::kSPECIESC; ++ispecie){
    2398           0 :     TH2F *hNsigmaP = new TH2F(Form("hNsigmaP_TPC_TOF_%s",AliPID::ParticleName(ispecie)),
    2399           0 :                               Form("TPC n#sigma %s vs. p (after TOF 3#sigma cut);p_{TPC} [GeV]; n#sigma",AliPID::ParticleName(ispecie)),
    2400           0 :                               vX->GetNrows()-1,vX->GetMatrixArray(),
    2401             :                               200,-10,10);
    2402           0 :     fListQAtpctof->Add(hNsigmaP);
    2403             :   }
    2404             : 
    2405             :   //TOF signals after TPC cut
    2406           0 :   for (Int_t ispecie=0; ispecie<AliPID::kSPECIESC; ++ispecie){
    2407           0 :     TH2F *hNsigmaP = new TH2F(Form("hNsigmaP_TOF_TPC_%s",AliPID::ParticleName(ispecie)),
    2408           0 :                               Form("TOF n#sigma %s vs. p (after TPC n#sigma cut);p [GeV]; n#sigma",AliPID::ParticleName(ispecie)),
    2409           0 :                               vX->GetNrows()-1,vX->GetMatrixArray(),
    2410             :                               200,-10,10);
    2411           0 :     fListQAtpctof->Add(hNsigmaP);
    2412             :   }
    2413             : 
    2414             :   //EMCAL signal after TOF and TPC cut
    2415           0 :   for (Int_t ispecie=0; ispecie<AliPID::kSPECIES; ++ispecie){
    2416           0 :     TH2F *heopPt = new TH2F(Form("heopPt_TOF_TPC_%s",AliPID::ParticleName(ispecie)),
    2417           0 :                             Form("EMCAL signal (E/p) %s vs. p_{T};p_{T} [GeV]; EMCAL signal (E/p) [arb. units]",AliPID::ParticleName(ispecie)),
    2418           0 :                             vX->GetNrows()-1,vX->GetMatrixArray(),
    2419             :                             200,0,2);
    2420           0 :     fListQAtpctof->Add(heopPt);
    2421             :   }
    2422             : 
    2423           0 :   delete vX;
    2424           0 : }
    2425             : //______________________________________________________________________________
    2426             : void AliAnalysisTaskPIDqa::SetupV0qa()
    2427             : {
    2428             :   //
    2429             :   // Create the qa objects for V0 Kine cuts
    2430             :   //
    2431             :   
    2432           0 :   TH2F *hArmenteros  = new TH2F("hArmenteros",  "Armenteros plot",200,-1.,1.,200,0.,0.4);
    2433           0 :   fListQAV0->Add(hArmenteros);
    2434             :  
    2435           0 : }
    2436             : 
    2437             : //_____________________________________________________________________________
    2438             : void AliAnalysisTaskPIDqa::SetupQAinfo(){
    2439             :   //
    2440             :   // Setup the info of QA objects
    2441             :   //
    2442             : 
    2443           0 :   TObjArray *arr=new TObjArray;
    2444           0 :   arr->SetName("TPC_info");
    2445           0 :   arr->SetOwner();
    2446           0 :   fListQAinfo->Add(arr);
    2447           0 : }
    2448             : 
    2449             : //______________________________________________________________________________
    2450             : TVectorD* AliAnalysisTaskPIDqa::MakeLogBinning(Int_t nbinsX, Double_t xmin, Double_t xmax)
    2451             : {
    2452             :   //
    2453             :   // Make logarithmic binning
    2454             :   // the user has to delete the array afterwards!!!
    2455             :   //
    2456             :   
    2457             :   //check limits
    2458           0 :   if (xmin<1e-20 || xmax<1e-20){
    2459           0 :     AliError("For Log binning xmin and xmax must be > 1e-20. Using linear binning instead!");
    2460           0 :     return MakeLinBinning(nbinsX, xmin, xmax);
    2461             :   }
    2462           0 :   if (xmax<xmin){
    2463             :     Double_t tmp=xmin;
    2464             :     xmin=xmax;
    2465             :     xmax=tmp;
    2466           0 :   }
    2467           0 :   TVectorD *binLim=new TVectorD(nbinsX+1);
    2468             :   Double_t first=xmin;
    2469             :   Double_t last=xmax;
    2470           0 :   Double_t expMax=TMath::Log(last/first);
    2471           0 :   for (Int_t i=0; i<nbinsX+1; ++i){
    2472           0 :     (*binLim)[i]=first*TMath::Exp(expMax/nbinsX*(Double_t)i);
    2473             :   }
    2474             :   return binLim;
    2475           0 : }
    2476             : 
    2477             : //______________________________________________________________________________
    2478             : TVectorD* AliAnalysisTaskPIDqa::MakeLinBinning(Int_t nbinsX, Double_t xmin, Double_t xmax)
    2479             : {
    2480             :   //
    2481             :   // Make linear binning
    2482             :   // the user has to delete the array afterwards!!!
    2483             :   //
    2484           0 :   if (xmax<xmin){
    2485             :     Double_t tmp=xmin;
    2486             :     xmin=xmax;
    2487             :     xmax=tmp;
    2488           0 :   }
    2489           0 :   TVectorD *binLim=new TVectorD(nbinsX+1);
    2490             :   Double_t first=xmin;
    2491             :   Double_t last=xmax;
    2492           0 :   Double_t binWidth=(last-first)/nbinsX;
    2493           0 :   for (Int_t i=0; i<nbinsX+1; ++i){
    2494           0 :     (*binLim)[i]=first+binWidth*(Double_t)i;
    2495             :   }
    2496           0 :   return binLim;
    2497           0 : }
    2498             : 
    2499             : //_____________________________________________________________________________
    2500             : TVectorD* AliAnalysisTaskPIDqa::MakeArbitraryBinning(const char* bins)
    2501             : {
    2502             :   //
    2503             :   // Make arbitrary binning, bins separated by a ','
    2504             :   //
    2505           0 :   TString limits(bins);
    2506           0 :   if (limits.IsNull()){
    2507           0 :     AliError("Bin Limit string is empty, cannot add the variable");
    2508           0 :     return 0x0;
    2509             :   }
    2510             :   
    2511           0 :   TObjArray *arr=limits.Tokenize(",");
    2512           0 :   Int_t nLimits=arr->GetEntries();
    2513           0 :   if (nLimits<2){
    2514           0 :     AliError("Need at leas 2 bin limits, cannot add the variable");
    2515           0 :     delete arr;
    2516           0 :     return 0x0;
    2517             :   }
    2518             :   
    2519           0 :   TVectorD *binLimits=new TVectorD(nLimits);
    2520           0 :   for (Int_t iLim=0; iLim<nLimits; ++iLim){
    2521           0 :     (*binLimits)[iLim]=(static_cast<TObjString*>(arr->At(iLim)))->GetString().Atof();
    2522             :   }
    2523             :   
    2524           0 :   delete arr;
    2525             :   return binLimits;
    2526           0 : }
    2527             : 

Generated by: LCOV version 1.11