]>
Commit | Line | Data |
---|---|---|
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 | // // | |
20 | /////////////////////////////////////////////////////////////////////////// | |
21 | ||
22 | #include <TChain.h> | |
61d106d3 | 23 | #include <TH1D.h> |
b2a297fa | 24 | |
25 | #include <AliCFContainer.h> | |
572b0139 | 26 | #include <AliInputEventHandler.h> |
27 | #include <AliESDInputHandler.h> | |
ffbede40 | 28 | #include <AliAODInputHandler.h> |
572b0139 | 29 | #include <AliAnalysisManager.h> |
b2a297fa | 30 | #include <AliVEvent.h> |
2a14a7b1 | 31 | #include <AliTriggerAnalysis.h> |
b2a297fa | 32 | |
33 | #include "AliDielectron.h" | |
34 | #include "AliDielectronHistos.h" | |
35 | #include "AliDielectronCF.h" | |
572b0139 | 36 | #include "AliDielectronMC.h" |
b2a297fa | 37 | #include "AliAnalysisTaskMultiDielectron.h" |
38 | ||
39 | ClassImp(AliAnalysisTaskMultiDielectron) | |
40 | ||
41 | //_________________________________________________________________________________ | |
42 | AliAnalysisTaskMultiDielectron::AliAnalysisTaskMultiDielectron() : | |
43 | AliAnalysisTaskSE(), | |
44 | fListDielectron(), | |
45 | fListHistos(), | |
572b0139 | 46 | fListCF(), |
61d106d3 | 47 | fSelectPhysics(kFALSE), |
48 | fTriggerMask(AliVEvent::kMB), | |
2a14a7b1 | 49 | fTriggerOnV0AND(kFALSE), |
50 | fRejectPileup(kFALSE), | |
51 | fTriggerAnalysis(0x0), | |
52 | fEventFilter(0x0), | |
61d106d3 | 53 | fEventStat(0x0) |
b2a297fa | 54 | { |
55 | // | |
56 | // Constructor | |
57 | // | |
58 | } | |
59 | ||
60 | //_________________________________________________________________________________ | |
61 | AliAnalysisTaskMultiDielectron::AliAnalysisTaskMultiDielectron(const char *name) : | |
62 | AliAnalysisTaskSE(name), | |
63 | fListDielectron(), | |
64 | fListHistos(), | |
572b0139 | 65 | fListCF(), |
61d106d3 | 66 | fSelectPhysics(kFALSE), |
67 | fTriggerMask(AliVEvent::kMB), | |
2a14a7b1 | 68 | fTriggerOnV0AND(kFALSE), |
69 | fRejectPileup(kFALSE), | |
70 | fTriggerAnalysis(0x0), | |
71 | fEventFilter(0x0), | |
61d106d3 | 72 | fEventStat(0x0) |
b2a297fa | 73 | { |
74 | // | |
75 | // Constructor | |
76 | // | |
77 | DefineInput(0,TChain::Class()); | |
78 | DefineOutput(1, TList::Class()); | |
79 | DefineOutput(2, TList::Class()); | |
61d106d3 | 80 | DefineOutput(3, TH1D::Class()); |
b2a297fa | 81 | fListHistos.SetName("Dielectron_Histos_Multi"); |
82 | fListCF.SetName("Dielectron_CF_Multi"); | |
2a14a7b1 | 83 | fListDielectron.SetOwner(); |
84 | fListHistos.SetOwner(); | |
85 | fListCF.SetOwner(); | |
b2a297fa | 86 | } |
87 | ||
88 | ||
89 | //_________________________________________________________________________________ | |
90 | void AliAnalysisTaskMultiDielectron::UserCreateOutputObjects() | |
91 | { | |
92 | // | |
93 | // Add all histogram manager histogram lists to the output TList | |
94 | // | |
95 | ||
572b0139 | 96 | if (!fListHistos.IsEmpty()||!fListCF.IsEmpty()) return; //already initialised |
b2a297fa | 97 | |
2a14a7b1 | 98 | AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager(); |
99 | Bool_t isESD=man->GetInputEventHandler()->IsA()==AliESDInputHandler::Class(); | |
ffbede40 | 100 | // Bool_t isAOD=man->GetInputEventHandler()->IsA()==AliAODInputHandler::Class(); |
2a14a7b1 | 101 | |
b2a297fa | 102 | TIter nextDie(&fListDielectron); |
103 | AliDielectron *die=0; | |
104 | while ( (die=static_cast<AliDielectron*>(nextDie())) ){ | |
105 | die->Init(); | |
106 | if (die->GetHistogramList()) fListHistos.Add(const_cast<THashList*>(die->GetHistogramList())); | |
107 | if (die->GetCFManagerPair()) fListCF.Add(const_cast<AliCFContainer*>(die->GetCFManagerPair()->GetContainer())); | |
108 | } | |
61d106d3 | 109 | |
48609e3d | 110 | Int_t cuts=fListDielectron.GetEntries(); |
2a14a7b1 | 111 | Int_t nbins=kNbinsEvent+2*cuts; |
61d106d3 | 112 | if (!fEventStat){ |
48609e3d | 113 | fEventStat=new TH1D("hEventStat","Event statistics",nbins,0,nbins); |
61d106d3 | 114 | fEventStat->GetXaxis()->SetBinLabel(1,"Before Phys. Sel."); |
115 | fEventStat->GetXaxis()->SetBinLabel(2,"After Phys. Sel."); | |
2a14a7b1 | 116 | if (fTriggerOnV0AND&&isESD) fEventStat->GetXaxis()->SetBinLabel(3,"V0and triggers"); |
117 | if (fEventFilter) fEventStat->GetXaxis()->SetBinLabel(4,"After Event Filter"); | |
118 | if (fRejectPileup) fEventStat->GetXaxis()->SetBinLabel(5,"After Pileup rejection"); | |
119 | ||
48609e3d | 120 | for (Int_t i=0; i<cuts; ++i){ |
2a14a7b1 | 121 | fEventStat->GetXaxis()->SetBinLabel((kNbinsEvent+1)+2*i,Form("#splitline{1 candidate}{%s}",fListDielectron.At(i)->GetName())); |
122 | fEventStat->GetXaxis()->SetBinLabel((kNbinsEvent+2)+2*i,Form("#splitline{With >1 candidate}{%s}",fListDielectron.At(i)->GetName())); | |
48609e3d | 123 | } |
61d106d3 | 124 | } |
2a14a7b1 | 125 | |
126 | if (!fTriggerAnalysis) fTriggerAnalysis=new AliTriggerAnalysis; | |
127 | fTriggerAnalysis->EnableHistograms(); | |
128 | fTriggerAnalysis->SetAnalyzeMC(AliDielectronMC::Instance()->HasMC()); | |
61d106d3 | 129 | |
130 | PostData(1, &fListHistos); | |
131 | PostData(2, &fListCF); | |
132 | PostData(3, fEventStat); | |
b2a297fa | 133 | } |
134 | ||
135 | //_________________________________________________________________________________ | |
136 | void AliAnalysisTaskMultiDielectron::UserExec(Option_t *) | |
137 | { | |
138 | // | |
139 | // Main loop. Called for every event | |
140 | // | |
141 | ||
572b0139 | 142 | if (fListHistos.IsEmpty()&&fListCF.IsEmpty()) return; |
143 | ||
144 | AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager(); | |
145 | AliESDInputHandler *esdHandler=0x0; | |
2a14a7b1 | 146 | Bool_t isESD=man->GetInputEventHandler()->IsA()==AliESDInputHandler::Class(); |
ffbede40 | 147 | Bool_t isAOD=man->GetInputEventHandler()->IsA()==AliAODInputHandler::Class(); |
572b0139 | 148 | if ( (esdHandler=dynamic_cast<AliESDInputHandler*>(man->GetInputEventHandler())) && esdHandler->GetESDpid() ){ |
149 | AliDielectronVarManager::SetESDpid(esdHandler->GetESDpid()); | |
150 | } else { | |
151 | //load esd pid bethe bloch parameters depending on the existance of the MC handler | |
152 | // yes: MC parameters | |
153 | // no: data parameters | |
2a14a7b1 | 154 | |
155 | //ESD case | |
156 | if (isESD){ | |
157 | if (!AliDielectronVarManager::GetESDpid()){ | |
158 | ||
159 | if (AliDielectronMC::Instance()->HasMC()) { | |
160 | AliDielectronVarManager::InitESDpid(); | |
161 | } else { | |
162 | AliDielectronVarManager::InitESDpid(1); | |
163 | } | |
164 | } | |
165 | } | |
166 | //AOD case | |
167 | if (isAOD){ | |
168 | if (!AliDielectronVarManager::GetAODpidUtil()){ | |
169 | if (AliDielectronMC::Instance()->HasMC()) { | |
170 | AliDielectronVarManager::InitAODpidUtil(); | |
171 | } else { | |
172 | AliDielectronVarManager::InitAODpidUtil(1); | |
173 | } | |
572b0139 | 174 | } |
175 | } | |
176 | } | |
177 | // Was event selected ? | |
178 | AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler()); | |
61d106d3 | 179 | UInt_t isSelected = AliVEvent::kAny; |
572b0139 | 180 | if( fSelectPhysics && inputHandler && inputHandler->GetEventSelection() ) { |
181 | isSelected = inputHandler->IsEventSelected(); | |
61d106d3 | 182 | isSelected&=fTriggerMask; |
572b0139 | 183 | } |
184 | ||
61d106d3 | 185 | //Before physics selection |
2a14a7b1 | 186 | fEventStat->Fill(kAllEvents); |
61d106d3 | 187 | if (isSelected==0) { |
188 | PostData(3,fEventStat); | |
189 | return; | |
190 | } | |
191 | //after physics selection | |
2a14a7b1 | 192 | fEventStat->Fill(kSelectedEvents); |
193 | ||
194 | //V0and | |
195 | if (fTriggerOnV0AND&&isESD){ | |
196 | if (!fTriggerAnalysis->IsOfflineTriggerFired(static_cast<AliESDEvent*>(InputEvent()), AliTriggerAnalysis::kV0AND)) return; | |
197 | } | |
198 | fEventStat->Fill(kV0andEvents); | |
199 | ||
200 | //event filter | |
201 | if (fEventFilter) { | |
202 | if (!fEventFilter->IsSelected(InputEvent())) return; | |
203 | } | |
204 | fEventStat->Fill(kFilteredEvents); | |
205 | ||
206 | //pileup | |
207 | if (fRejectPileup){ | |
208 | if (InputEvent()->IsPileupFromSPD(3,0.8,3.,2.,5.)) return; | |
209 | } | |
210 | fEventStat->Fill(kPileupEvents); | |
b2a297fa | 211 | |
212 | //bz for AliKF | |
213 | Double_t bz = InputEvent()->GetMagneticField(); | |
214 | AliKFParticle::SetField( bz ); | |
215 | ||
2a14a7b1 | 216 | AliDielectronPID::SetCorrVal((Double_t)InputEvent()->GetRunNumber()); |
217 | ||
b2a297fa | 218 | //Process event in all AliDielectron instances |
219 | TIter nextDie(&fListDielectron); | |
220 | AliDielectron *die=0; | |
48609e3d | 221 | Int_t idie=0; |
b2a297fa | 222 | while ( (die=static_cast<AliDielectron*>(nextDie())) ){ |
b2a297fa | 223 | die->Process(InputEvent()); |
48609e3d | 224 | if (die->HasCandidates()){ |
225 | Int_t ncandidates=die->GetPairArray(1)->GetEntriesFast(); | |
ffbede40 | 226 | if (ncandidates==1) fEventStat->Fill((kNbinsEvent)+2*idie); |
227 | else if (ncandidates>1) fEventStat->Fill((kNbinsEvent+1)+2*idie); | |
48609e3d | 228 | } |
229 | ++idie; | |
b2a297fa | 230 | } |
231 | ||
232 | PostData(1, &fListHistos); | |
233 | PostData(2, &fListCF); | |
61d106d3 | 234 | PostData(3,fEventStat); |
b2a297fa | 235 | } |
236 | ||
572b0139 | 237 | //_________________________________________________________________________________ |
238 | void AliAnalysisTaskMultiDielectron::FinishTaskOutput() | |
239 | { | |
240 | // | |
241 | // Write debug tree | |
242 | // | |
243 | TIter nextDie(&fListDielectron); | |
244 | AliDielectron *die=0; | |
245 | while ( (die=static_cast<AliDielectron*>(nextDie())) ){ | |
246 | die->SaveDebugTree(); | |
247 | } | |
248 | } | |
249 |