1 /*************************************************************************
2 * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 ///////////////////////////////////////////////////////////////////////////
18 // Basic Analysis Task //
20 ///////////////////////////////////////////////////////////////////////////
25 #include <AliCFContainer.h>
26 #include <AliInputEventHandler.h>
27 #include <AliESDInputHandler.h>
28 #include <AliAnalysisManager.h>
29 #include <AliVEvent.h>
31 #include "AliDielectron.h"
32 #include "AliDielectronHistos.h"
33 #include "AliDielectronCF.h"
34 #include "AliDielectronMC.h"
35 #include "AliAnalysisTaskDielectronME.h"
37 ClassImp(AliAnalysisTaskDielectronME)
39 //_________________________________________________________________________________
40 AliAnalysisTaskDielectronME::AliAnalysisTaskDielectronME() :
46 fSelectPhysics(kFALSE),
47 fTriggerMask(AliVEvent::kMB),
55 //_________________________________________________________________________________
56 AliAnalysisTaskDielectronME::AliAnalysisTaskDielectronME(const char *name) :
57 AliAnalysisTaskME(name),
62 fSelectPhysics(kFALSE),
63 fTriggerMask(AliVEvent::kMB),
69 DefineInput(0,TChain::Class());
70 DefineOutput(1, TList::Class());
71 DefineOutput(2, TList::Class());
72 DefineOutput(3, TH1D::Class());
73 fListHistos.SetName("Dielectron_Histos_Multi");
74 fListCF.SetName("Dielectron_CF_Multi");
78 //_________________________________________________________________________________
79 void AliAnalysisTaskDielectronME::UserCreateOutputObjects()
82 // Add all histogram manager histogram lists to the output TList
85 if (!fListHistos.IsEmpty()||!fListCF.IsEmpty()) return; //already initialised
87 TIter nextDie(&fListDielectron);
89 while ( (die=static_cast<AliDielectron*>(nextDie())) ){
91 if (die->GetHistogramList()) fListHistos.Add(const_cast<THashList*>(die->GetHistogramList()));
92 if (die->GetCFManagerPair()) fListCF.Add(const_cast<AliCFContainer*>(die->GetCFManagerPair()->GetContainer()));
95 Int_t cuts=fListDielectron.GetEntries();
98 fEventStat=new TH1D("hEventStat","Event statistics",nbins,0,nbins);
99 fEventStat->GetXaxis()->SetBinLabel(1,"Before Phys. Sel.");
100 fEventStat->GetXaxis()->SetBinLabel(2,"After Phys. Sel.");
101 for (Int_t i=0; i<cuts; ++i){
102 fEventStat->GetXaxis()->SetBinLabel(3+2*i,Form("#splitline{1 candidate}{%s}",fListDielectron.At(i)->GetName()));
103 fEventStat->GetXaxis()->SetBinLabel(4+2*i,Form("#splitline{With >1 candidate}{%s}",fListDielectron.At(i)->GetName()));
107 PostData(1, &fListHistos);
108 PostData(2, &fListCF);
109 PostData(3, fEventStat);
112 //_________________________________________________________________________________
113 void AliAnalysisTaskDielectronME::UserExec(Option_t *)
116 // Main loop. Called for every event
119 if (fListHistos.IsEmpty()&&fListCF.IsEmpty()) return;
121 AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
122 AliESDInputHandler *esdHandler=0x0;
123 if ( (esdHandler=dynamic_cast<AliESDInputHandler*>(man->GetInputEventHandler())) && esdHandler->GetESDpid() ){
124 AliDielectronVarManager::SetESDpid(esdHandler->GetESDpid());
126 //load esd pid bethe bloch parameters depending on the existance of the MC handler
127 // yes: MC parameters
128 // no: data parameters
129 if (!AliDielectronVarManager::GetESDpid()){
130 if (AliDielectronMC::Instance()->HasMC()) {
131 AliDielectronVarManager::InitESDpid();
133 AliDielectronVarManager::InitESDpid(1);
137 // Was event selected ?
138 AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
139 UInt_t isSelected = AliVEvent::kAny;
140 if( fSelectPhysics && inputHandler && inputHandler->GetEventSelection() ) {
141 isSelected = inputHandler->IsEventSelected();
142 isSelected&=fTriggerMask;
145 //Before physics selection
146 fEventStat->Fill(0.);
148 PostData(3,fEventStat);
151 //after physics selection
152 fEventStat->Fill(1.);
155 Double_t bz = GetEvent(0)->GetMagneticField();
156 AliKFParticle::SetField( bz );
158 //Process event in all AliDielectron instances
159 TIter nextDie(&fListDielectron);
160 AliDielectron *die=0;
162 while ( (die=static_cast<AliDielectron*>(nextDie())) ){
163 for (Int_t evt1=0; evt1<fPoolDepth-1; evt1++){
164 for (Int_t evt2=evt1+1; evt2<fPoolDepth; evt2++){
165 die->Process((AliESDEvent*)GetEvent(evt1),(AliESDEvent*)GetEvent(evt2));
166 if (die->HasCandidates()){
167 Int_t ncandidates=die->GetPairArray(1)->GetEntriesFast();
168 if (ncandidates==1) fEventStat->Fill(3+2*idie);
169 else if (ncandidates>1) fEventStat->Fill(4+2*idie);
176 PostData(1, &fListHistos);
177 PostData(2, &fListCF);
178 PostData(3,fEventStat);
181 //_________________________________________________________________________________
182 void AliAnalysisTaskDielectronME::FinishTaskOutput()
187 TIter nextDie(&fListDielectron);
188 AliDielectron *die=0;
189 while ( (die=static_cast<AliDielectron*>(nextDie())) ){
190 die->SaveDebugTree();