#include "AliTRDPIDmatching.h"
#include "AliTRDPIDTree.h"
#include "TChain.h"
#include "AliAnalysisManager.h"
#include "AliESDEvent.h"
#include "AliESDtrackCuts.h"
#include "AliMCEvent.h"
#include "AliPID.h"
#include "AliESDtrack.h"
#include "AliPIDResponse.h"
#include "AliInputEventHandler.h"
#include "AliMCEventHandler.h"
#include "AliESDInputHandler.h"
#include "AliESDv0KineCuts.h"
#include "THnSparse.h"
using namespace std;
ClassImp(AliTRDPIDmatching)
AliTRDPIDmatching::AliTRDPIDmatching(const char *name): AliTRDPIDTree(name),
fESD(0), fMC(0), fTHntrdmatch(0), fOutputContainer(0), fesdTrackCuts(0), fHasMC(0)
{
DefineInput(0, TChain::Class());
DefineOutput(1, TList::Class());
}
AliTRDPIDmatching::~AliTRDPIDmatching()
{
delete fOutputContainer;
fOutputContainer = 0;
}
void AliTRDPIDmatching::UserCreateOutputObjects()
{
fV0cuts = new AliESDv0KineCuts();
fV0electrons = new TObjArray;
fV0pions = new TObjArray;
fV0protons = new TObjArray;
fesdTrackCuts = new AliESDtrackCuts("AliESDtrackCuts", "cuts");
fesdTrackCuts->SetEtaRange(-0.9,+0.9);
fesdTrackCuts->SetMinNClustersTPC(80);
fesdTrackCuts->SetRequireTPCRefit(kTRUE);
fesdTrackCuts->SetMaxDCAToVertexXY(3);
fesdTrackCuts->SetMaxDCAToVertexZ(3.0);
fesdTrackCuts->SetAcceptKinkDaughters(kFALSE);
fesdTrackCuts->SetMaxChi2PerClusterTPC(4);
fesdTrackCuts->SetRequireITSRefit(kTRUE);
fesdTrackCuts->SetClusterRequirementITS(AliESDtrackCuts::kSPD, AliESDtrackCuts::kAny);
const Int_t kNdim = 5;
Int_t bins[kNdim] = { 7, 180, 280, 500, 7};
Double_t xmin[kNdim] = { 0, -0.9, 0., -10., 0};
Double_t xmax[kNdim] = { 7, 0.9, 7., 10., 7};
fTHntrdmatch= new THnSparseF("trdmatching", "TRD matching; pid;eta;phi;p;ntrdtracklets", kNdim, bins, xmin, xmax);
fOutputContainer = new TObjArray(1);
fOutputContainer->SetName(GetName());
fOutputContainer->SetOwner(kTRUE);
fOutputContainer->Add(fTHntrdmatch);
PostData(1, fOutputContainer);
}
void AliTRDPIDmatching::UserExec(Option_t *)
{
AliESDInputHandler *esdH = dynamic_cast<AliESDInputHandler*> (AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
if (!esdH)
{
Printf("ERROR: Could not get ESDInputHandler \n");
}
else fESD = esdH->GetEvent();
AliMCEventHandler *mcH = dynamic_cast<AliMCEventHandler*>((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
if(!mcH){
fHasMC = kFALSE;
} else {
fMC=mcH->MCEvent();
fHasMC = kTRUE;
}
FillV0PIDlist();
ProcessData(fESD);
PostData(1, fOutputContainer);
ClearV0PIDlist();
}
void AliTRDPIDmatching::ProcessData(AliESDEvent *const esdEvent)
{
AliMCParticle *mctrack = NULL;
TParticle* mcparticle = NULL;
if (!esdEvent) {
Printf("ERROR: esdEvent not available");
return;
}
if(!((AliESDInputHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))) Printf("ESD inputhandler not available \n");
AliESDpid* fESDpid = ((AliESDInputHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->GetESDpid();
if (!fESDpid) {
Printf("ERROR: fESDpid not available");
return;
}
for (Int_t iTracks = 0; iTracks < esdEvent->GetNumberOfTracks(); iTracks++)
{
AliESDtrack *trackESD = esdEvent->GetTrack(iTracks);
if(!trackESD) continue;
if(!fesdTrackCuts->AcceptTrack(trackESD)){continue;}
const AliExternalTrackParam *paramIn = trackESD->GetInnerParam();
Float_t precin=-1;
if(paramIn) precin=paramIn->Pt();
else continue;
if(precin<0.3) continue;
Double_t eta=trackESD->Eta();
Double_t phi=trackESD->Phi();
Int_t ntrdtracklets=trackESD->GetTRDntracklets();
Int_t charge =trackESD->Charge();
Int_t v0id=0;
if(fHasMC==kFALSE)
{
Int_t v0tagAllCharges = TMath::Abs(GetV0tag(iTracks));
if (v0tagAllCharges == -99) {
AliError(Form("Problem with V0 tag list (requested V0 track for track %d from %d (list status %d))!", iTracks, esdEvent->GetNumberOfTracks(),
fV0tags != 0x0));
v0id=0;
}
Bool_t isV0el=0;
Bool_t isV0pi=0;
Bool_t isV0pr=0;
if(v0tagAllCharges == 11) isV0el=1;
if(v0tagAllCharges == 211) isV0pi=1;
if(v0tagAllCharges == 2212) isV0pr=1;
if(isV0el) {
v0id=1;
}
if(isV0pi) {
v0id=3;
}
if(isV0pr) {
v0id=5;
}
}
Int_t mcpid=0;
if(fHasMC==kTRUE)
{
if(!(mctrack = dynamic_cast<AliMCParticle *>(fMC->GetTrack(TMath::Abs(trackESD->GetLabel()))))) continue;
mcparticle = mctrack->Particle();
if(mcparticle)
{
mcpid = mcparticle->GetPdgCode();
if(TMath::Abs(mcpid)==11) v0id=1;
if(TMath::Abs(mcpid)==13) v0id=2;
if(TMath::Abs(mcpid)==211) v0id=3;
if(TMath::Abs(mcpid)==321) v0id=4;
if(TMath::Abs(mcpid)==2212) v0id=5;
}
}
Double_t contentSignal[5];
contentSignal[0]=v0id;
contentSignal[1]=eta;
contentSignal[2]=phi;
contentSignal[3]=precin*charge;
contentSignal[4]=ntrdtracklets;
fTHntrdmatch->Fill(contentSignal);
}
PostData(1, fOutputContainer);
}
Int_t AliTRDPIDmatching::CompareFloat(Float_t f1, Float_t f2) const
{
Float_t precision = 0.00001;
if (((f1 - precision) < f2) &&
((f1 + precision) > f2))
{
return 1;
}
else
{
return 0;
}
}
void AliTRDPIDmatching::Terminate(const Option_t *)
{
}
AliTRDPIDmatching.cxx:100 AliTRDPIDmatching.cxx:101 AliTRDPIDmatching.cxx:102 AliTRDPIDmatching.cxx:103 AliTRDPIDmatching.cxx:104 AliTRDPIDmatching.cxx:105 AliTRDPIDmatching.cxx:106 AliTRDPIDmatching.cxx:107 AliTRDPIDmatching.cxx:108 AliTRDPIDmatching.cxx:109 AliTRDPIDmatching.cxx:110 AliTRDPIDmatching.cxx:111 AliTRDPIDmatching.cxx:112 AliTRDPIDmatching.cxx:113 AliTRDPIDmatching.cxx:114 AliTRDPIDmatching.cxx:115 AliTRDPIDmatching.cxx:116 AliTRDPIDmatching.cxx:117 AliTRDPIDmatching.cxx:118 AliTRDPIDmatching.cxx:119 AliTRDPIDmatching.cxx:120 AliTRDPIDmatching.cxx:121 AliTRDPIDmatching.cxx:122 AliTRDPIDmatching.cxx:123 AliTRDPIDmatching.cxx:124 AliTRDPIDmatching.cxx:125 AliTRDPIDmatching.cxx:126 AliTRDPIDmatching.cxx:127 AliTRDPIDmatching.cxx:128 AliTRDPIDmatching.cxx:129 AliTRDPIDmatching.cxx:130 AliTRDPIDmatching.cxx:131 AliTRDPIDmatching.cxx:132 AliTRDPIDmatching.cxx:133 AliTRDPIDmatching.cxx:134 AliTRDPIDmatching.cxx:135 AliTRDPIDmatching.cxx:136 AliTRDPIDmatching.cxx:137 AliTRDPIDmatching.cxx:138 AliTRDPIDmatching.cxx:139 AliTRDPIDmatching.cxx:140 AliTRDPIDmatching.cxx:141 AliTRDPIDmatching.cxx:142 AliTRDPIDmatching.cxx:143 AliTRDPIDmatching.cxx:144 AliTRDPIDmatching.cxx:145 AliTRDPIDmatching.cxx:146 AliTRDPIDmatching.cxx:147 AliTRDPIDmatching.cxx:148 AliTRDPIDmatching.cxx:149 AliTRDPIDmatching.cxx:150 AliTRDPIDmatching.cxx:151 AliTRDPIDmatching.cxx:152 AliTRDPIDmatching.cxx:153 AliTRDPIDmatching.cxx:154 AliTRDPIDmatching.cxx:155 AliTRDPIDmatching.cxx:156 AliTRDPIDmatching.cxx:157 AliTRDPIDmatching.cxx:158 AliTRDPIDmatching.cxx:159 AliTRDPIDmatching.cxx:160 AliTRDPIDmatching.cxx:161 AliTRDPIDmatching.cxx:162 AliTRDPIDmatching.cxx:163 AliTRDPIDmatching.cxx:164 AliTRDPIDmatching.cxx:165 AliTRDPIDmatching.cxx:166 AliTRDPIDmatching.cxx:167 AliTRDPIDmatching.cxx:168 AliTRDPIDmatching.cxx:169 AliTRDPIDmatching.cxx:170 AliTRDPIDmatching.cxx:171 AliTRDPIDmatching.cxx:172 AliTRDPIDmatching.cxx:173 AliTRDPIDmatching.cxx:174 AliTRDPIDmatching.cxx:175 AliTRDPIDmatching.cxx:176 AliTRDPIDmatching.cxx:177 AliTRDPIDmatching.cxx:178 AliTRDPIDmatching.cxx:179 AliTRDPIDmatching.cxx:180 AliTRDPIDmatching.cxx:181 AliTRDPIDmatching.cxx:182 AliTRDPIDmatching.cxx:183 AliTRDPIDmatching.cxx:184 AliTRDPIDmatching.cxx:185 AliTRDPIDmatching.cxx:186 AliTRDPIDmatching.cxx:187 AliTRDPIDmatching.cxx:188 AliTRDPIDmatching.cxx:189 AliTRDPIDmatching.cxx:190 AliTRDPIDmatching.cxx:191 AliTRDPIDmatching.cxx:192 AliTRDPIDmatching.cxx:193 AliTRDPIDmatching.cxx:194 AliTRDPIDmatching.cxx:195 AliTRDPIDmatching.cxx:196 AliTRDPIDmatching.cxx:197 AliTRDPIDmatching.cxx:198 AliTRDPIDmatching.cxx:199 AliTRDPIDmatching.cxx:200 AliTRDPIDmatching.cxx:201 AliTRDPIDmatching.cxx:202 AliTRDPIDmatching.cxx:203 AliTRDPIDmatching.cxx:204 AliTRDPIDmatching.cxx:205 AliTRDPIDmatching.cxx:206 AliTRDPIDmatching.cxx:207 AliTRDPIDmatching.cxx:208 AliTRDPIDmatching.cxx:209 AliTRDPIDmatching.cxx:210 AliTRDPIDmatching.cxx:211 AliTRDPIDmatching.cxx:212 AliTRDPIDmatching.cxx:213 AliTRDPIDmatching.cxx:214 AliTRDPIDmatching.cxx:215 AliTRDPIDmatching.cxx:216 AliTRDPIDmatching.cxx:217 AliTRDPIDmatching.cxx:218 AliTRDPIDmatching.cxx:219 AliTRDPIDmatching.cxx:220 AliTRDPIDmatching.cxx:221 AliTRDPIDmatching.cxx:222 AliTRDPIDmatching.cxx:223 AliTRDPIDmatching.cxx:224 AliTRDPIDmatching.cxx:225 AliTRDPIDmatching.cxx:226 AliTRDPIDmatching.cxx:227 AliTRDPIDmatching.cxx:228 AliTRDPIDmatching.cxx:229 AliTRDPIDmatching.cxx:230 AliTRDPIDmatching.cxx:231 AliTRDPIDmatching.cxx:232 AliTRDPIDmatching.cxx:233 AliTRDPIDmatching.cxx:234 AliTRDPIDmatching.cxx:235 AliTRDPIDmatching.cxx:236 AliTRDPIDmatching.cxx:237 AliTRDPIDmatching.cxx:238 AliTRDPIDmatching.cxx:239 AliTRDPIDmatching.cxx:240 AliTRDPIDmatching.cxx:241 AliTRDPIDmatching.cxx:242 AliTRDPIDmatching.cxx:243 AliTRDPIDmatching.cxx:244 AliTRDPIDmatching.cxx:245 AliTRDPIDmatching.cxx:246 AliTRDPIDmatching.cxx:247 AliTRDPIDmatching.cxx:248 AliTRDPIDmatching.cxx:249 AliTRDPIDmatching.cxx:250 AliTRDPIDmatching.cxx:251 AliTRDPIDmatching.cxx:252 AliTRDPIDmatching.cxx:253 AliTRDPIDmatching.cxx:254 AliTRDPIDmatching.cxx:255 AliTRDPIDmatching.cxx:256 AliTRDPIDmatching.cxx:257 AliTRDPIDmatching.cxx:258 AliTRDPIDmatching.cxx:259 AliTRDPIDmatching.cxx:260 AliTRDPIDmatching.cxx:261 AliTRDPIDmatching.cxx:262 AliTRDPIDmatching.cxx:263 AliTRDPIDmatching.cxx:264 AliTRDPIDmatching.cxx:265 AliTRDPIDmatching.cxx:266 AliTRDPIDmatching.cxx:267 AliTRDPIDmatching.cxx:268 AliTRDPIDmatching.cxx:269 AliTRDPIDmatching.cxx:270 AliTRDPIDmatching.cxx:271 AliTRDPIDmatching.cxx:272 AliTRDPIDmatching.cxx:273 AliTRDPIDmatching.cxx:274 AliTRDPIDmatching.cxx:275 AliTRDPIDmatching.cxx:276 AliTRDPIDmatching.cxx:277 AliTRDPIDmatching.cxx:278