ROOT logo
/**************************************************************************
 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 *                                                                        *
 * Author: Satyajit Jena.                                                 *
 * Contributors are mentioned in the code where appropriate.              *
 *                                                                        *
 * Permission to use, copy, modify and distribute this software and its   *
 * documentation strictly for non-commercial purposes is hereby granted   *
 * without fee, provided that the above copyright notice appears in all   *
 * copies and that both the copyright notice and this permission notice   *
 * appear in the supporting documentation. The authors make no claims     *
 * about the suitability of this software for any purpose. It is          *
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/


//=========================================================================//
//                 AliEbyE Fluctuaion Analysis for PID                     //
//                   Deepika Jena | drathee@cern.ch                        //
//                   Satyajit Jena | sjena@cern.ch                         //
//=========================================================================//

#include "TChain.h"
#include "TList.h"
#include "TFile.h"
#include "TTree.h"
#include "TH1D.h"
#include "TH2F.h"
#include "TH3F.h"

#include "THnSparse.h"

#include "AliAnalysisTask.h"
#include "AliAnalysisManager.h"

#include "AliVEvent.h"
#include "AliESDEvent.h"
#include "AliMCEvent.h"
#include "AliAODEvent.h"

#include "AliStack.h"
#include "AliGenEventHeader.h"
#include "AliGenPythiaEventHeader.h"
#include "AliGenHijingEventHeader.h"
#include "AliGenDPMjetEventHeader.h"
#include "TDatabasePDG.h"

#include "AliEbyEPidTaskFastGen.h"

ClassImp(AliEbyEPidTaskFastGen)

//-----------------------------------------------------------------------
AliEbyEPidTaskFastGen::AliEbyEPidTaskFastGen( const char *name )
: AliAnalysisTaskSE( name ),
  fThnList(0),
  fVxMax(3.),
  fVyMax(3.),
  fVzMax(15.),
  fPtLowerLimit(0.2),
  fPtHigherLimit(5.),
  fEtaLowerLimit(-1.),
  fEtaHigherLimit(1.),
  fHistoCorrelationMC(NULL)
{ 
 
  DefineOutput(1, TList::Class()); 
}

AliEbyEPidTaskFastGen::~AliEbyEPidTaskFastGen()
{
  if (fThnList) delete fThnList;
}


//---------------------------------------------------------------------------------
void AliEbyEPidTaskFastGen::UserCreateOutputObjects() {
  fThnList = new TList();
  fThnList->SetOwner(kTRUE);
  Int_t fgSparseDataBins[kNSparseData]   = {50000,   500,     440,  30000,   15000,  15000,   10000,  5000,   5000,  5000,  2500,  2500,  2500,  1250, 1250};
  Double_t fgSparseDataMin[kNSparseData] = {0.,       0.,      0.,     0.,      0.,     0.,      0.,    0.,     0.,    0.,    0.,    0.,    0.,   0.,    0.};
  Double_t fgSparseDataMax[kNSparseData] = {50000.,  100.,    440., 30000.,  15000., 15000.,  10000., 5000.,  5000., 5000., 2500., 2500., 2500., 1250., 1250.};
  
  const Char_t *fgkSparseDataTitle[] = {
    "Nnumber of Partiles",
    "Impact Parameters",
    "N_{p}",
    "N_{ch}",
    "N_{+}",
    "N_{-}",
    "N_{#pi}",
    "N_{#pi^{+}}",
    "N_{#pi^{-}}",
    "N_{K}",
    "N_{K^{+}}",
    "N_{K^{-}}",
    "N_{pr}",
    "N_{p}",
    "N_{#bar{p}}"
  };
  
  fHistoCorrelationMC = new THnSparseI("hHistoPR", "", kNSparseData, fgSparseDataBins, fgSparseDataMin, fgSparseDataMax);
  for (Int_t iaxis = 0; iaxis < kNSparseData; iaxis++)
    fHistoCorrelationMC->GetAxis(iaxis)->SetTitle(fgkSparseDataTitle[iaxis]);
  fThnList->Add(fHistoCorrelationMC);
  
  PostData(1, fThnList);
}


//----------------------------------------------------------------------------------
void AliEbyEPidTaskFastGen::UserExec( Option_t * ){
  AliMCEvent* mcEvent = MCEvent();
  if (!mcEvent) {
    Printf("ERROR: Could not retrieve MC event");
    return;
  }
  
  AliStack *stack = mcEvent->Stack();
 
  AliGenEventHeader* genHeader = mcEvent->GenEventHeader();
  if(!genHeader){
    printf("  Event generator header not available!!!\n");
    return;
  }
  
  Double_t imp = -1;
  Double_t np = -1;
  Double_t nt = -1;
  
  if(genHeader->InheritsFrom(AliGenHijingEventHeader::Class())){
    imp = ((AliGenHijingEventHeader*) genHeader)->ImpactParameter();
    nt  = ((AliGenHijingEventHeader*) genHeader)->TargetParticipants();
    np  = ((AliGenHijingEventHeader*) genHeader)->ProjectileParticipants();
  }  
  

  Int_t count[4][2];
  for (Int_t i = 0; i < 4; i++) {
    for (Int_t j = 0; j < 2; j++) count[i][j] = 0; 
  }
  
  Int_t nParticles = stack->GetNtrack();
  for (Int_t iParticle = 0; iParticle < nParticles; iParticle++) {
    TParticle* part = stack->Particle(iParticle);
    if (!part) {
      Printf(" No Particle Available ");
      continue;
    }
    
    //  TDatabasePDG* pdgDB   = TDatabasePDG::Instance();
    //  TParticlePDG* pdgPart = pdgDB->GetParticle(part->GetPdgCode());
    
    Float_t pt = part->Pt();
    if(pt < fPtLowerLimit || pt > fPtHigherLimit ) continue;
    Float_t gEta = part->Eta();
    if(gEta < fEtaLowerLimit || gEta > fEtaHigherLimit ) continue;
    
    
    //  Float_t gCharge = (pdgPart ? pdgPart->Charge() : 0);
    
    Int_t pid = part->GetPdgCode();
    if(pid == 211)         { count[1][0]++;  count[0][0]++; } 
    else if(pid ==  -211)  { count[1][1]++;  count[0][1]++; } 
    else if(pid ==   321)  { count[2][0]++;  count[0][0]++; } 
    else if(pid ==  -321)  { count[2][1]++;  count[0][1]++; } 
    else if(pid ==  2212)  { count[3][0]++;  count[0][0]++; } 
    else if(pid == -2212)  { count[3][1]++;  count[0][1]++; } 
  }
  
  Double_t vsparseMC[kNSparseData];
  vsparseMC[0]  = nParticles;
  vsparseMC[1]  = imp;
  vsparseMC[2]  = np + nt;
  vsparseMC[3]  = count[0][0] + count[0][1];
  vsparseMC[4]  = count[0][0];
  vsparseMC[5]  = count[0][1];

  vsparseMC[6]  = count[1][0] + count[1][1];
  vsparseMC[7]  = count[1][0];
  vsparseMC[8]  = count[1][1];

  vsparseMC[9]  = count[2][0] + count[2][1];
  vsparseMC[10]  = count[2][0];
  vsparseMC[11]  = count[2][1];

  vsparseMC[12] = count[3][0] + count[3][1];
  vsparseMC[13] = count[3][0];
  vsparseMC[14] = count[3][1];
  

   /* Printf(" %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f %10.2f",
  	 vsparseMC[0], vsparseMC[1], vsparseMC[2], 
	 vsparseMC[3], vsparseMC[4], vsparseMC[5], 
	 vsparseMC[6], vsparseMC[7], vsparseMC[8], 
	 vsparseMC[9], vsparseMC[10], vsparseMC[11],
	 vsparseMC[12], vsparseMC[13], vsparseMC[13]);
   */
  fHistoCorrelationMC->Fill(vsparseMC);
  PostData(1, fThnList);
  
}

void AliEbyEPidTaskFastGen::Terminate( Option_t * ){

  Info("AliEbyEPiDTask"," Task Successfully finished");
  
}


 AliEbyEPidTaskFastGen.cxx:1
 AliEbyEPidTaskFastGen.cxx:2
 AliEbyEPidTaskFastGen.cxx:3
 AliEbyEPidTaskFastGen.cxx:4
 AliEbyEPidTaskFastGen.cxx:5
 AliEbyEPidTaskFastGen.cxx:6
 AliEbyEPidTaskFastGen.cxx:7
 AliEbyEPidTaskFastGen.cxx:8
 AliEbyEPidTaskFastGen.cxx:9
 AliEbyEPidTaskFastGen.cxx:10
 AliEbyEPidTaskFastGen.cxx:11
 AliEbyEPidTaskFastGen.cxx:12
 AliEbyEPidTaskFastGen.cxx:13
 AliEbyEPidTaskFastGen.cxx:14
 AliEbyEPidTaskFastGen.cxx:15
 AliEbyEPidTaskFastGen.cxx:16
 AliEbyEPidTaskFastGen.cxx:17
 AliEbyEPidTaskFastGen.cxx:18
 AliEbyEPidTaskFastGen.cxx:19
 AliEbyEPidTaskFastGen.cxx:20
 AliEbyEPidTaskFastGen.cxx:21
 AliEbyEPidTaskFastGen.cxx:22
 AliEbyEPidTaskFastGen.cxx:23
 AliEbyEPidTaskFastGen.cxx:24
 AliEbyEPidTaskFastGen.cxx:25
 AliEbyEPidTaskFastGen.cxx:26
 AliEbyEPidTaskFastGen.cxx:27
 AliEbyEPidTaskFastGen.cxx:28
 AliEbyEPidTaskFastGen.cxx:29
 AliEbyEPidTaskFastGen.cxx:30
 AliEbyEPidTaskFastGen.cxx:31
 AliEbyEPidTaskFastGen.cxx:32
 AliEbyEPidTaskFastGen.cxx:33
 AliEbyEPidTaskFastGen.cxx:34
 AliEbyEPidTaskFastGen.cxx:35
 AliEbyEPidTaskFastGen.cxx:36
 AliEbyEPidTaskFastGen.cxx:37
 AliEbyEPidTaskFastGen.cxx:38
 AliEbyEPidTaskFastGen.cxx:39
 AliEbyEPidTaskFastGen.cxx:40
 AliEbyEPidTaskFastGen.cxx:41
 AliEbyEPidTaskFastGen.cxx:42
 AliEbyEPidTaskFastGen.cxx:43
 AliEbyEPidTaskFastGen.cxx:44
 AliEbyEPidTaskFastGen.cxx:45
 AliEbyEPidTaskFastGen.cxx:46
 AliEbyEPidTaskFastGen.cxx:47
 AliEbyEPidTaskFastGen.cxx:48
 AliEbyEPidTaskFastGen.cxx:49
 AliEbyEPidTaskFastGen.cxx:50
 AliEbyEPidTaskFastGen.cxx:51
 AliEbyEPidTaskFastGen.cxx:52
 AliEbyEPidTaskFastGen.cxx:53
 AliEbyEPidTaskFastGen.cxx:54
 AliEbyEPidTaskFastGen.cxx:55
 AliEbyEPidTaskFastGen.cxx:56
 AliEbyEPidTaskFastGen.cxx:57
 AliEbyEPidTaskFastGen.cxx:58
 AliEbyEPidTaskFastGen.cxx:59
 AliEbyEPidTaskFastGen.cxx:60
 AliEbyEPidTaskFastGen.cxx:61
 AliEbyEPidTaskFastGen.cxx:62
 AliEbyEPidTaskFastGen.cxx:63
 AliEbyEPidTaskFastGen.cxx:64
 AliEbyEPidTaskFastGen.cxx:65
 AliEbyEPidTaskFastGen.cxx:66
 AliEbyEPidTaskFastGen.cxx:67
 AliEbyEPidTaskFastGen.cxx:68
 AliEbyEPidTaskFastGen.cxx:69
 AliEbyEPidTaskFastGen.cxx:70
 AliEbyEPidTaskFastGen.cxx:71
 AliEbyEPidTaskFastGen.cxx:72
 AliEbyEPidTaskFastGen.cxx:73
 AliEbyEPidTaskFastGen.cxx:74
 AliEbyEPidTaskFastGen.cxx:75
 AliEbyEPidTaskFastGen.cxx:76
 AliEbyEPidTaskFastGen.cxx:77
 AliEbyEPidTaskFastGen.cxx:78
 AliEbyEPidTaskFastGen.cxx:79
 AliEbyEPidTaskFastGen.cxx:80
 AliEbyEPidTaskFastGen.cxx:81
 AliEbyEPidTaskFastGen.cxx:82
 AliEbyEPidTaskFastGen.cxx:83
 AliEbyEPidTaskFastGen.cxx:84
 AliEbyEPidTaskFastGen.cxx:85
 AliEbyEPidTaskFastGen.cxx:86
 AliEbyEPidTaskFastGen.cxx:87
 AliEbyEPidTaskFastGen.cxx:88
 AliEbyEPidTaskFastGen.cxx:89
 AliEbyEPidTaskFastGen.cxx:90
 AliEbyEPidTaskFastGen.cxx:91
 AliEbyEPidTaskFastGen.cxx:92
 AliEbyEPidTaskFastGen.cxx:93
 AliEbyEPidTaskFastGen.cxx:94
 AliEbyEPidTaskFastGen.cxx:95
 AliEbyEPidTaskFastGen.cxx:96
 AliEbyEPidTaskFastGen.cxx:97
 AliEbyEPidTaskFastGen.cxx:98
 AliEbyEPidTaskFastGen.cxx:99
 AliEbyEPidTaskFastGen.cxx:100
 AliEbyEPidTaskFastGen.cxx:101
 AliEbyEPidTaskFastGen.cxx:102
 AliEbyEPidTaskFastGen.cxx:103
 AliEbyEPidTaskFastGen.cxx:104
 AliEbyEPidTaskFastGen.cxx:105
 AliEbyEPidTaskFastGen.cxx:106
 AliEbyEPidTaskFastGen.cxx:107
 AliEbyEPidTaskFastGen.cxx:108
 AliEbyEPidTaskFastGen.cxx:109
 AliEbyEPidTaskFastGen.cxx:110
 AliEbyEPidTaskFastGen.cxx:111
 AliEbyEPidTaskFastGen.cxx:112
 AliEbyEPidTaskFastGen.cxx:113
 AliEbyEPidTaskFastGen.cxx:114
 AliEbyEPidTaskFastGen.cxx:115
 AliEbyEPidTaskFastGen.cxx:116
 AliEbyEPidTaskFastGen.cxx:117
 AliEbyEPidTaskFastGen.cxx:118
 AliEbyEPidTaskFastGen.cxx:119
 AliEbyEPidTaskFastGen.cxx:120
 AliEbyEPidTaskFastGen.cxx:121
 AliEbyEPidTaskFastGen.cxx:122
 AliEbyEPidTaskFastGen.cxx:123
 AliEbyEPidTaskFastGen.cxx:124
 AliEbyEPidTaskFastGen.cxx:125
 AliEbyEPidTaskFastGen.cxx:126
 AliEbyEPidTaskFastGen.cxx:127
 AliEbyEPidTaskFastGen.cxx:128
 AliEbyEPidTaskFastGen.cxx:129
 AliEbyEPidTaskFastGen.cxx:130
 AliEbyEPidTaskFastGen.cxx:131
 AliEbyEPidTaskFastGen.cxx:132
 AliEbyEPidTaskFastGen.cxx:133
 AliEbyEPidTaskFastGen.cxx:134
 AliEbyEPidTaskFastGen.cxx:135
 AliEbyEPidTaskFastGen.cxx:136
 AliEbyEPidTaskFastGen.cxx:137
 AliEbyEPidTaskFastGen.cxx:138
 AliEbyEPidTaskFastGen.cxx:139
 AliEbyEPidTaskFastGen.cxx:140
 AliEbyEPidTaskFastGen.cxx:141
 AliEbyEPidTaskFastGen.cxx:142
 AliEbyEPidTaskFastGen.cxx:143
 AliEbyEPidTaskFastGen.cxx:144
 AliEbyEPidTaskFastGen.cxx:145
 AliEbyEPidTaskFastGen.cxx:146
 AliEbyEPidTaskFastGen.cxx:147
 AliEbyEPidTaskFastGen.cxx:148
 AliEbyEPidTaskFastGen.cxx:149
 AliEbyEPidTaskFastGen.cxx:150
 AliEbyEPidTaskFastGen.cxx:151
 AliEbyEPidTaskFastGen.cxx:152
 AliEbyEPidTaskFastGen.cxx:153
 AliEbyEPidTaskFastGen.cxx:154
 AliEbyEPidTaskFastGen.cxx:155
 AliEbyEPidTaskFastGen.cxx:156
 AliEbyEPidTaskFastGen.cxx:157
 AliEbyEPidTaskFastGen.cxx:158
 AliEbyEPidTaskFastGen.cxx:159
 AliEbyEPidTaskFastGen.cxx:160
 AliEbyEPidTaskFastGen.cxx:161
 AliEbyEPidTaskFastGen.cxx:162
 AliEbyEPidTaskFastGen.cxx:163
 AliEbyEPidTaskFastGen.cxx:164
 AliEbyEPidTaskFastGen.cxx:165
 AliEbyEPidTaskFastGen.cxx:166
 AliEbyEPidTaskFastGen.cxx:167
 AliEbyEPidTaskFastGen.cxx:168
 AliEbyEPidTaskFastGen.cxx:169
 AliEbyEPidTaskFastGen.cxx:170
 AliEbyEPidTaskFastGen.cxx:171
 AliEbyEPidTaskFastGen.cxx:172
 AliEbyEPidTaskFastGen.cxx:173
 AliEbyEPidTaskFastGen.cxx:174
 AliEbyEPidTaskFastGen.cxx:175
 AliEbyEPidTaskFastGen.cxx:176
 AliEbyEPidTaskFastGen.cxx:177
 AliEbyEPidTaskFastGen.cxx:178
 AliEbyEPidTaskFastGen.cxx:179
 AliEbyEPidTaskFastGen.cxx:180
 AliEbyEPidTaskFastGen.cxx:181
 AliEbyEPidTaskFastGen.cxx:182
 AliEbyEPidTaskFastGen.cxx:183
 AliEbyEPidTaskFastGen.cxx:184
 AliEbyEPidTaskFastGen.cxx:185
 AliEbyEPidTaskFastGen.cxx:186
 AliEbyEPidTaskFastGen.cxx:187
 AliEbyEPidTaskFastGen.cxx:188
 AliEbyEPidTaskFastGen.cxx:189
 AliEbyEPidTaskFastGen.cxx:190
 AliEbyEPidTaskFastGen.cxx:191
 AliEbyEPidTaskFastGen.cxx:192
 AliEbyEPidTaskFastGen.cxx:193
 AliEbyEPidTaskFastGen.cxx:194
 AliEbyEPidTaskFastGen.cxx:195
 AliEbyEPidTaskFastGen.cxx:196
 AliEbyEPidTaskFastGen.cxx:197
 AliEbyEPidTaskFastGen.cxx:198
 AliEbyEPidTaskFastGen.cxx:199
 AliEbyEPidTaskFastGen.cxx:200
 AliEbyEPidTaskFastGen.cxx:201
 AliEbyEPidTaskFastGen.cxx:202
 AliEbyEPidTaskFastGen.cxx:203
 AliEbyEPidTaskFastGen.cxx:204
 AliEbyEPidTaskFastGen.cxx:205
 AliEbyEPidTaskFastGen.cxx:206
 AliEbyEPidTaskFastGen.cxx:207
 AliEbyEPidTaskFastGen.cxx:208
 AliEbyEPidTaskFastGen.cxx:209