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 "AliAnalysisTaskMultiDielectron.h"
37 ClassImp(AliAnalysisTaskMultiDielectron)
39 //_________________________________________________________________________________
40 AliAnalysisTaskMultiDielectron::AliAnalysisTaskMultiDielectron() :
45 fSelectPhysics(kFALSE),
46 fTriggerMask(AliVEvent::kMB),
54 //_________________________________________________________________________________
55 AliAnalysisTaskMultiDielectron::AliAnalysisTaskMultiDielectron(const char *name) :
56 AliAnalysisTaskSE(name),
60 fSelectPhysics(kFALSE),
61 fTriggerMask(AliVEvent::kMB),
67 DefineInput(0,TChain::Class());
68 DefineOutput(1, TList::Class());
69 DefineOutput(2, TList::Class());
70 DefineOutput(3, TH1D::Class());
71 fListHistos.SetName("Dielectron_Histos_Multi");
72 fListCF.SetName("Dielectron_CF_Multi");
76 //_________________________________________________________________________________
77 void AliAnalysisTaskMultiDielectron::UserCreateOutputObjects()
80 // Add all histogram manager histogram lists to the output TList
83 if (!fListHistos.IsEmpty()||!fListCF.IsEmpty()) return; //already initialised
85 TIter nextDie(&fListDielectron);
87 while ( (die=static_cast<AliDielectron*>(nextDie())) ){
89 if (die->GetHistogramList()) fListHistos.Add(const_cast<THashList*>(die->GetHistogramList()));
90 if (die->GetCFManagerPair()) fListCF.Add(const_cast<AliCFContainer*>(die->GetCFManagerPair()->GetContainer()));
93 Int_t cuts=fListDielectron.GetEntries();
96 fEventStat=new TH1D("hEventStat","Event statistics",nbins,0,nbins);
97 fEventStat->GetXaxis()->SetBinLabel(1,"Before Phys. Sel.");
98 fEventStat->GetXaxis()->SetBinLabel(2,"After Phys. Sel.");
99 for (Int_t i=0; i<cuts; ++i){
100 fEventStat->GetXaxis()->SetBinLabel(3+2*i,Form("#splitline{1 candidate}{%s}",fListDielectron.At(i)->GetName()));
101 fEventStat->GetXaxis()->SetBinLabel(4+2*i,Form("#splitline{With >1 candidate}{%s}",fListDielectron.At(i)->GetName()));
105 PostData(1, &fListHistos);
106 PostData(2, &fListCF);
107 PostData(3, fEventStat);
110 //_________________________________________________________________________________
111 void AliAnalysisTaskMultiDielectron::UserExec(Option_t *)
114 // Main loop. Called for every event
117 if (fListHistos.IsEmpty()&&fListCF.IsEmpty()) return;
119 AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
120 AliESDInputHandler *esdHandler=0x0;
121 if ( (esdHandler=dynamic_cast<AliESDInputHandler*>(man->GetInputEventHandler())) && esdHandler->GetESDpid() ){
122 AliDielectronVarManager::SetESDpid(esdHandler->GetESDpid());
124 //load esd pid bethe bloch parameters depending on the existance of the MC handler
125 // yes: MC parameters
126 // no: data parameters
127 if (!AliDielectronVarManager::GetESDpid()){
128 if (AliDielectronMC::Instance()->HasMC()) {
129 AliDielectronVarManager::InitESDpid();
131 AliDielectronVarManager::InitESDpid(1);
135 // Was event selected ?
136 AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
137 UInt_t isSelected = AliVEvent::kAny;
138 if( fSelectPhysics && inputHandler && inputHandler->GetEventSelection() ) {
139 isSelected = inputHandler->IsEventSelected();
140 isSelected&=fTriggerMask;
143 //Before physics selection
144 fEventStat->Fill(0.);
146 PostData(3,fEventStat);
149 //after physics selection
150 fEventStat->Fill(1.);
153 Double_t bz = InputEvent()->GetMagneticField();
154 AliKFParticle::SetField( bz );
156 //Process event in all AliDielectron instances
157 TIter nextDie(&fListDielectron);
158 AliDielectron *die=0;
160 while ( (die=static_cast<AliDielectron*>(nextDie())) ){
161 die->Process(InputEvent());
162 if (die->HasCandidates()){
163 Int_t ncandidates=die->GetPairArray(1)->GetEntriesFast();
164 if (ncandidates==1) fEventStat->Fill(3+2*idie);
165 else if (ncandidates>1) fEventStat->Fill(4+2*idie);
170 PostData(1, &fListHistos);
171 PostData(2, &fListCF);
172 PostData(3,fEventStat);
175 //_________________________________________________________________________________
176 void AliAnalysisTaskMultiDielectron::FinishTaskOutput()
181 TIter nextDie(&fListDielectron);
182 AliDielectron *die=0;
183 while ( (die=static_cast<AliDielectron*>(nextDie())) ){
184 die->SaveDebugTree();