]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGDQ/dielectron/AliAnalysisTaskDielectronSE.cxx
including switch to set on/off iso-track core removal, cleaning and bug fix
[u/mrichter/AliRoot.git] / PWGDQ / dielectron / AliAnalysisTaskDielectronSE.cxx
CommitLineData
b2a297fa 1/*************************************************************************
2* Copyright(c) 1998-2009, 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///////////////////////////////////////////////////////////////////////////
17// //
18// Basic Analysis Task //
19// for Dielectron Analysis //
20// //
21///////////////////////////////////////////////////////////////////////////
22
23#include <TChain.h>
61d106d3 24#include <TH1D.h>
b2a297fa 25
26#include <AliCFContainer.h>
27#include <AliVEvent.h>
61d106d3 28#include <AliInputEventHandler.h>
29#include <AliESDInputHandler.h>
30#include <AliAnalysisManager.h>
ffbede40 31#include <AliAODInputHandler.h>
5720c765 32#include <AliTriggerAnalysis.h>
b2a297fa 33
34#include "AliDielectron.h"
35#include "AliDielectronHistos.h"
36#include "AliDielectronCF.h"
37#include "AliAnalysisTaskDielectronSE.h"
38
39ClassImp(AliAnalysisTaskDielectronSE)
40
41//_________________________________________________________________________________
42AliAnalysisTaskDielectronSE::AliAnalysisTaskDielectronSE() :
43 AliAnalysisTaskSE(),
61d106d3 44 fDielectron(0),
45 fSelectPhysics(kFALSE),
46 fTriggerMask(AliVEvent::kMB),
5720c765 47 fTriggerOnV0AND(kFALSE),
48 fRejectPileup(kFALSE),
49 fTriggerAnalysis(0x0),
50 fEventFilter(0x0),
61d106d3 51 fEventStat(0x0)
b2a297fa 52{
53 //
54 // Constructor
55 //
56}
57
58//_________________________________________________________________________________
59AliAnalysisTaskDielectronSE::AliAnalysisTaskDielectronSE(const char *name) :
60 AliAnalysisTaskSE(name),
61d106d3 61 fDielectron(0),
62 fSelectPhysics(kFALSE),
63 fTriggerMask(AliVEvent::kMB),
5720c765 64 fTriggerOnV0AND(kFALSE),
65 fRejectPileup(kFALSE),
66 fTriggerAnalysis(0x0),
67 fEventFilter(0x0),
61d106d3 68 fEventStat(0x0)
b2a297fa 69{
70 //
71 // Constructor
72 //
73 DefineInput(0,TChain::Class());
74 DefineOutput(1, THashList::Class());
75 DefineOutput(2, AliCFContainer::Class());
61d106d3 76 DefineOutput(3, TH1D::Class());
b2a297fa 77}
78
79//_________________________________________________________________________________
80void AliAnalysisTaskDielectronSE::UserCreateOutputObjects()
81{
82 //
83 // Initialise the framework objects
84 //
85 if (!fDielectron){
86 AliError("No Dielectron framework object set !!!");
87 return;
88 }
89 fDielectron->Init();
61d106d3 90 if (fDielectron->GetHistogramList()){
91 PostData(1, const_cast<THashList*>(fDielectron->GetHistogramList()));
92 }
93 if (fDielectron->GetCFManagerPair()){
94 PostData(2, const_cast<AliCFContainer*>(fDielectron->GetCFManagerPair()->GetContainer()));
95 }
96
97 if (!fEventStat){
98 fEventStat=new TH1D("hEventStat","Event statistics",5,0,5);
99 fEventStat->GetXaxis()->SetBinLabel(1,"Before Phys. Sel.");
100 fEventStat->GetXaxis()->SetBinLabel(2,"After Phys. Sel.");
101 }
5720c765 102 Int_t nbins=kNbinsEvent+2;
103 if (!fEventStat){
104 fEventStat=new TH1D("hEventStat","Event statistics",nbins,0,nbins);
105 fEventStat->GetXaxis()->SetBinLabel(1,"Before Phys. Sel.");
106 fEventStat->GetXaxis()->SetBinLabel(2,"After Phys. Sel.");
107
108 //default names
109 fEventStat->GetXaxis()->SetBinLabel(3,"Bin3 not used");
110 fEventStat->GetXaxis()->SetBinLabel(4,"Bin4 not used");
111 fEventStat->GetXaxis()->SetBinLabel(5,"Bin5 not used");
112
113 if(fTriggerOnV0AND) fEventStat->GetXaxis()->SetBinLabel(3,"V0and triggers");
114 if (fEventFilter) fEventStat->GetXaxis()->SetBinLabel(4,"After Event Filter");
115 if (fRejectPileup) fEventStat->GetXaxis()->SetBinLabel(5,"After Pileup rejection");
116
117 fEventStat->GetXaxis()->SetBinLabel((kNbinsEvent+1),Form("#splitline{1 candidate}{%s}",fDielectron->GetName()));
118 fEventStat->GetXaxis()->SetBinLabel((kNbinsEvent+2),Form("#splitline{With >1 candidate}{%s}",fDielectron->GetName()));
119
120 }
121
122 if (!fTriggerAnalysis) fTriggerAnalysis=new AliTriggerAnalysis;
123 fTriggerAnalysis->EnableHistograms();
124 fTriggerAnalysis->SetAnalyzeMC(AliDielectronMC::Instance()->HasMC());
61d106d3 125
126 PostData(3,fEventStat);
127
b2a297fa 128}
129
130//_________________________________________________________________________________
131void AliAnalysisTaskDielectronSE::UserExec(Option_t *)
132{
133 //
134 // Main loop. Called for every event
135 //
136
137 if (!fDielectron) return;
138
61d106d3 139 AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
5720c765 140 Bool_t isESD=man->GetInputEventHandler()->IsA()==AliESDInputHandler::Class();
141 Bool_t isAOD=man->GetInputEventHandler()->IsA()==AliAODInputHandler::Class();
142
143 AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
144 if (!inputHandler) return;
145
146 if ( inputHandler->GetPIDResponse() ){
147 AliDielectronVarManager::SetPIDResponse( inputHandler->GetPIDResponse() );
61d106d3 148 } else {
5720c765 149 AliFatal("This task needs the PID response attached to the input event handler!");
61d106d3 150 }
5720c765 151
61d106d3 152 // Was event selected ?
61d106d3 153 UInt_t isSelected = AliVEvent::kAny;
5720c765 154 if( fSelectPhysics && inputHandler){
155 if((isESD && inputHandler->GetEventSelection()) || isAOD){
156 isSelected = inputHandler->IsEventSelected();
157 isSelected&=fTriggerMask;
158 }
159 }
160
161
61d106d3 162 //Before physics selection
5720c765 163 fEventStat->Fill(kAllEvents);
61d106d3 164 if (isSelected==0) {
165 PostData(3,fEventStat);
166 return;
167 }
168 //after physics selection
5720c765 169 fEventStat->Fill(kSelectedEvents);
170
171 //V0and
172 if(fTriggerOnV0AND){
173 if(isESD){if (!fTriggerAnalysis->IsOfflineTriggerFired(static_cast<AliESDEvent*>(InputEvent()), AliTriggerAnalysis::kV0AND))
174 return;}
175 if(isAOD){if(!((static_cast<AliAODEvent*>(InputEvent()))->GetVZEROData()->GetV0ADecision() == AliVVZERO::kV0BB &&
176 (static_cast<AliAODEvent*>(InputEvent()))->GetVZEROData()->GetV0CDecision() == AliVVZERO::kV0BB) )
177 return;}
178 }
179
180
181 fEventStat->Fill(kV0andEvents);
182
183 //Fill Event histograms before the event filter
184 Double_t values[AliDielectronVarManager::kNMaxValues]={0};
185 Double_t valuesMC[AliDielectronVarManager::kNMaxValues]={0};
186 AliDielectronVarManager::Fill(InputEvent(),values);
187 Bool_t hasMC=AliDielectronMC::Instance()->HasMC();
188 if (hasMC) {
189 if (AliDielectronMC::Instance()->ConnectMCEvent())
190 AliDielectronVarManager::Fill(AliDielectronMC::Instance()->GetMCEvent(),valuesMC);
191 }
192
193 AliDielectronHistos *h=fDielectron->GetHistoManager();
194 if (h){
195 if (h->GetHistogramList()->FindObject("Event_noCuts"))
196 h->FillClass("Event_noCuts",AliDielectronVarManager::kNMaxValues,values);
197 if (hasMC && h->GetHistogramList()->FindObject("MCEvent_noCuts"))
198 h->FillClass("Event_noCuts",AliDielectronVarManager::kNMaxValues,valuesMC);
199 }
200
201 //event filter
202 if (fEventFilter) {
203 if (!fEventFilter->IsSelected(InputEvent())) return;
204 }
205 fEventStat->Fill(kFilteredEvents);
206
207 //pileup
208 if (fRejectPileup){
209 if (InputEvent()->IsPileupFromSPD(3,0.8,3.,2.,5.)) return;
210 }
211 fEventStat->Fill(kPileupEvents);
61d106d3 212
b2a297fa 213 //bz for AliKF
214 Double_t bz = InputEvent()->GetMagneticField();
215 AliKFParticle::SetField( bz );
5720c765 216
217 // make an artificial shift in the electron nsigma. Configured in the Config file
218 AliDielectronPID::SetCorrVal((Double_t)InputEvent()->GetRunNumber());
219
220 //
221 // Actual data processing
222 //
b2a297fa 223 fDielectron->Process(InputEvent());
b2a297fa 224
5720c765 225 //statistics for number of selected candidates
226 Int_t ncandidates=fDielectron->GetPairArray(1)->GetEntriesFast();
227 if (ncandidates==1) fEventStat->Fill((kNbinsEvent));
228 else if (ncandidates>1) fEventStat->Fill((kNbinsEvent+1));
229
230 //Publish the data
b2a297fa 231 if (fDielectron->GetHistogramList()){
232 PostData(1, const_cast<THashList*>(fDielectron->GetHistogramList()));
233 }
234 if (fDielectron->GetCFManagerPair()){
235 PostData(2, const_cast<AliCFContainer*>(fDielectron->GetCFManagerPair()->GetContainer()));
236 }
61d106d3 237 PostData(3,fEventStat);
b2a297fa 238}
239