]>
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> |
5720c765 | 32 | #include <AliPIDResponse.h> |
33 | #include <AliTPCPIDResponse.h> | |
b2a297fa | 34 | |
35 | #include "AliDielectron.h" | |
36 | #include "AliDielectronHistos.h" | |
37 | #include "AliDielectronCF.h" | |
572b0139 | 38 | #include "AliDielectronMC.h" |
5720c765 | 39 | #include "AliDielectronMixingHandler.h" |
b2a297fa | 40 | #include "AliAnalysisTaskMultiDielectron.h" |
41 | ||
42 | ClassImp(AliAnalysisTaskMultiDielectron) | |
43 | ||
44 | //_________________________________________________________________________________ | |
45 | AliAnalysisTaskMultiDielectron::AliAnalysisTaskMultiDielectron() : | |
46 | AliAnalysisTaskSE(), | |
42c76bea | 47 | fPairArray(0x0), |
b2a297fa | 48 | fListDielectron(), |
49 | fListHistos(), | |
572b0139 | 50 | fListCF(), |
61d106d3 | 51 | fSelectPhysics(kFALSE), |
52 | fTriggerMask(AliVEvent::kMB), | |
5720c765 | 53 | fExcludeTriggerMask(0), |
2a14a7b1 | 54 | fTriggerOnV0AND(kFALSE), |
6675aa47 | 55 | fFiredTrigger(""), |
56 | fFiredExclude(kFALSE), | |
2a14a7b1 | 57 | fRejectPileup(kFALSE), |
1750c463 | 58 | fBeamEnergy(-1.), |
5720c765 | 59 | fTriggerLogic(kAny), |
2a14a7b1 | 60 | fTriggerAnalysis(0x0), |
61 | fEventFilter(0x0), | |
61d106d3 | 62 | fEventStat(0x0) |
b2a297fa | 63 | { |
64 | // | |
65 | // Constructor | |
66 | // | |
67 | } | |
68 | ||
69 | //_________________________________________________________________________________ | |
70 | AliAnalysisTaskMultiDielectron::AliAnalysisTaskMultiDielectron(const char *name) : | |
71 | AliAnalysisTaskSE(name), | |
42c76bea | 72 | fPairArray(0x0), |
b2a297fa | 73 | fListDielectron(), |
74 | fListHistos(), | |
572b0139 | 75 | fListCF(), |
61d106d3 | 76 | fSelectPhysics(kFALSE), |
77 | fTriggerMask(AliVEvent::kMB), | |
5720c765 | 78 | fExcludeTriggerMask(0), |
2a14a7b1 | 79 | fTriggerOnV0AND(kFALSE), |
6675aa47 | 80 | fFiredTrigger(""), |
81 | fFiredExclude(kFALSE), | |
2a14a7b1 | 82 | fRejectPileup(kFALSE), |
1750c463 | 83 | fBeamEnergy(-1.), |
5720c765 | 84 | fTriggerLogic(kAny), |
2a14a7b1 | 85 | fTriggerAnalysis(0x0), |
86 | fEventFilter(0x0), | |
61d106d3 | 87 | fEventStat(0x0) |
b2a297fa | 88 | { |
89 | // | |
90 | // Constructor | |
91 | // | |
92 | DefineInput(0,TChain::Class()); | |
93 | DefineOutput(1, TList::Class()); | |
94 | DefineOutput(2, TList::Class()); | |
61d106d3 | 95 | DefineOutput(3, TH1D::Class()); |
b2a297fa | 96 | fListHistos.SetName("Dielectron_Histos_Multi"); |
97 | fListCF.SetName("Dielectron_CF_Multi"); | |
2a14a7b1 | 98 | fListDielectron.SetOwner(); |
99 | fListHistos.SetOwner(); | |
100 | fListCF.SetOwner(); | |
b2a297fa | 101 | } |
102 | ||
5720c765 | 103 | //_________________________________________________________________________________ |
104 | AliAnalysisTaskMultiDielectron::~AliAnalysisTaskMultiDielectron() | |
105 | { | |
106 | // | |
107 | // Destructor | |
108 | // | |
b2a297fa | 109 | |
5720c765 | 110 | //histograms and CF are owned by the dielectron framework. |
111 | //however they are streamed to file, so in the first place the | |
112 | //lists need to be owner... | |
113 | fListHistos.SetOwner(kFALSE); | |
114 | fListCF.SetOwner(kFALSE); | |
42c76bea | 115 | |
116 | // if(fPairArray) { delete fPairArray; fPairArray=0; } | |
d8bb1abe | 117 | // try to reduce memory issues |
118 | if(fEventStat) { delete fEventStat; fEventStat=0; } | |
119 | if(fTriggerAnalysis) { delete fTriggerAnalysis; fTriggerAnalysis=0; } | |
5720c765 | 120 | } |
b2a297fa | 121 | //_________________________________________________________________________________ |
122 | void AliAnalysisTaskMultiDielectron::UserCreateOutputObjects() | |
123 | { | |
124 | // | |
125 | // Add all histogram manager histogram lists to the output TList | |
126 | // | |
127 | ||
572b0139 | 128 | if (!fListHistos.IsEmpty()||!fListCF.IsEmpty()) return; //already initialised |
b2a297fa | 129 | |
5720c765 | 130 | // AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager(); |
131 | // Bool_t isESD=man->GetInputEventHandler()->IsA()==AliESDInputHandler::Class(); | |
ffbede40 | 132 | // Bool_t isAOD=man->GetInputEventHandler()->IsA()==AliAODInputHandler::Class(); |
2a14a7b1 | 133 | |
b2a297fa | 134 | TIter nextDie(&fListDielectron); |
135 | AliDielectron *die=0; | |
136 | while ( (die=static_cast<AliDielectron*>(nextDie())) ){ | |
137 | die->Init(); | |
d8bb1abe | 138 | if (die->GetHistogramList()) fListHistos.Add(const_cast<THashList*>(die->GetHistogramList())); |
139 | if (die->GetHistogramArray()) fListHistos.Add(const_cast<TObjArray*>(die->GetHistogramArray())); | |
140 | if (die->GetQAHistArray()) fListHistos.Add(const_cast<TObjArray*>(die->GetQAHistArray())); | |
141 | if (die->GetCFManagerPair()) fListCF.Add(const_cast<AliCFContainer*>(die->GetCFManagerPair()->GetContainer())); | |
b2a297fa | 142 | } |
61d106d3 | 143 | |
48609e3d | 144 | Int_t cuts=fListDielectron.GetEntries(); |
2a14a7b1 | 145 | Int_t nbins=kNbinsEvent+2*cuts; |
61d106d3 | 146 | if (!fEventStat){ |
48609e3d | 147 | fEventStat=new TH1D("hEventStat","Event statistics",nbins,0,nbins); |
61d106d3 | 148 | fEventStat->GetXaxis()->SetBinLabel(1,"Before Phys. Sel."); |
149 | fEventStat->GetXaxis()->SetBinLabel(2,"After Phys. Sel."); | |
ba15fdfb | 150 | |
151 | //default names | |
152 | fEventStat->GetXaxis()->SetBinLabel(3,"Bin3 not used"); | |
153 | fEventStat->GetXaxis()->SetBinLabel(4,"Bin4 not used"); | |
154 | fEventStat->GetXaxis()->SetBinLabel(5,"Bin5 not used"); | |
155 | ||
5720c765 | 156 | if(fTriggerOnV0AND) fEventStat->GetXaxis()->SetBinLabel(3,"V0and triggers"); |
2a14a7b1 | 157 | if (fEventFilter) fEventStat->GetXaxis()->SetBinLabel(4,"After Event Filter"); |
158 | if (fRejectPileup) fEventStat->GetXaxis()->SetBinLabel(5,"After Pileup rejection"); | |
159 | ||
48609e3d | 160 | for (Int_t i=0; i<cuts; ++i){ |
2a14a7b1 | 161 | fEventStat->GetXaxis()->SetBinLabel((kNbinsEvent+1)+2*i,Form("#splitline{1 candidate}{%s}",fListDielectron.At(i)->GetName())); |
162 | fEventStat->GetXaxis()->SetBinLabel((kNbinsEvent+2)+2*i,Form("#splitline{With >1 candidate}{%s}",fListDielectron.At(i)->GetName())); | |
48609e3d | 163 | } |
61d106d3 | 164 | } |
2a14a7b1 | 165 | |
166 | if (!fTriggerAnalysis) fTriggerAnalysis=new AliTriggerAnalysis; | |
167 | fTriggerAnalysis->EnableHistograms(); | |
168 | fTriggerAnalysis->SetAnalyzeMC(AliDielectronMC::Instance()->HasMC()); | |
61d106d3 | 169 | |
170 | PostData(1, &fListHistos); | |
171 | PostData(2, &fListCF); | |
172 | PostData(3, fEventStat); | |
b2a297fa | 173 | } |
174 | ||
175 | //_________________________________________________________________________________ | |
176 | void AliAnalysisTaskMultiDielectron::UserExec(Option_t *) | |
177 | { | |
178 | // | |
179 | // Main loop. Called for every event | |
180 | // | |
181 | ||
572b0139 | 182 | if (fListHistos.IsEmpty()&&fListCF.IsEmpty()) return; |
183 | ||
184 | AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager(); | |
2a14a7b1 | 185 | Bool_t isESD=man->GetInputEventHandler()->IsA()==AliESDInputHandler::Class(); |
ffbede40 | 186 | Bool_t isAOD=man->GetInputEventHandler()->IsA()==AliAODInputHandler::Class(); |
ba15fdfb | 187 | |
188 | AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler()); | |
c8f0f810 | 189 | if (!inputHandler) return; |
ba15fdfb | 190 | |
5720c765 | 191 | // AliPIDResponse *pidRes=inputHandler->GetPIDResponse(); |
ba15fdfb | 192 | if ( inputHandler->GetPIDResponse() ){ |
5720c765 | 193 | // for the 2.76 pass2 MC private train. Together with a sigma shift of -0.169 |
194 | // pidRes->GetTPCResponse().SetSigma(4.637e-3,2.41332105409873257e+04); | |
ba15fdfb | 195 | AliDielectronVarManager::SetPIDResponse( inputHandler->GetPIDResponse() ); |
572b0139 | 196 | } else { |
5720c765 | 197 | AliFatal("This task needs the PID response attached to the input event handler!"); |
572b0139 | 198 | } |
199 | ||
5720c765 | 200 | // Was event selected ? |
201 | ULong64_t isSelected = AliVEvent::kAny; | |
202 | Bool_t isRejected = kFALSE; | |
203 | if( fSelectPhysics && inputHandler){ | |
204 | if((isESD && inputHandler->GetEventSelection()) || isAOD){ | |
205 | isSelected = inputHandler->IsEventSelected(); | |
206 | if (fExcludeTriggerMask && (isSelected&fExcludeTriggerMask)) isRejected=kTRUE; | |
207 | if (fTriggerLogic==kAny) isSelected&=fTriggerMask; | |
208 | else if (fTriggerLogic==kExact) isSelected=((isSelected&fTriggerMask)==fTriggerMask); | |
6675aa47 | 209 | |
210 | TString firedTriggerClasses=InputEvent()->GetFiredTriggerClasses(); | |
211 | if(!fFiredTrigger.IsNull()) isSelected=(firedTriggerClasses.Contains(fFiredTrigger))^fFiredExclude; | |
5720c765 | 212 | } |
213 | } | |
214 | ||
215 | ||
61d106d3 | 216 | //Before physics selection |
2a14a7b1 | 217 | fEventStat->Fill(kAllEvents); |
5720c765 | 218 | if (isSelected==0||isRejected) { |
61d106d3 | 219 | PostData(3,fEventStat); |
220 | return; | |
221 | } | |
222 | //after physics selection | |
2a14a7b1 | 223 | fEventStat->Fill(kSelectedEvents); |
224 | ||
225 | //V0and | |
5720c765 | 226 | if(fTriggerOnV0AND){ |
227 | if(isESD){if (!fTriggerAnalysis->IsOfflineTriggerFired(static_cast<AliESDEvent*>(InputEvent()), AliTriggerAnalysis::kV0AND)) | |
228 | return;} | |
229 | if(isAOD){if(!((static_cast<AliAODEvent*>(InputEvent()))->GetVZEROData()->GetV0ADecision() == AliVVZERO::kV0BB && | |
230 | (static_cast<AliAODEvent*>(InputEvent()))->GetVZEROData()->GetV0CDecision() == AliVVZERO::kV0BB) ) | |
231 | return;} | |
232 | } | |
233 | ||
234 | ||
2a14a7b1 | 235 | fEventStat->Fill(kV0andEvents); |
5720c765 | 236 | |
237 | //Fill Event histograms before the event filter | |
238 | TIter nextDie(&fListDielectron); | |
239 | AliDielectron *die=0; | |
5720c765 | 240 | Bool_t hasMC=AliDielectronMC::Instance()->HasMC(); |
5720c765 | 241 | while ( (die=static_cast<AliDielectron*>(nextDie())) ){ |
242 | AliDielectronHistos *h=die->GetHistoManager(); | |
243 | if (h){ | |
a49789c7 | 244 | AliDielectronVarManager::SetFillMap(h->GetUsedVars()); |
0caf5fbb | 245 | if (hasMC && AliDielectronMC::Instance()->ConnectMCEvent() && h->GetHistogramList()->FindObject("MCEvent_noCuts")) { |
246 | AliDielectronVarManager::SetEvent(AliDielectronMC::Instance()->GetMCEvent()); | |
520085dd | 247 | h->FillClass("MCEvent_noCuts",AliDielectronVarManager::kNMaxValues,AliDielectronVarManager::GetData()); |
0caf5fbb | 248 | } |
249 | if (h->GetHistogramList()->FindObject("Event_noCuts")) { | |
250 | AliDielectronVarManager::SetEvent(InputEvent()); | |
251 | h->FillClass("Event_noCuts",AliDielectronVarManager::kNMaxValues,AliDielectronVarManager::GetData()); | |
252 | } | |
5720c765 | 253 | } |
254 | } | |
255 | nextDie.Reset(); | |
2a14a7b1 | 256 | |
257 | //event filter | |
258 | if (fEventFilter) { | |
259 | if (!fEventFilter->IsSelected(InputEvent())) return; | |
260 | } | |
261 | fEventStat->Fill(kFilteredEvents); | |
262 | ||
263 | //pileup | |
264 | if (fRejectPileup){ | |
265 | if (InputEvent()->IsPileupFromSPD(3,0.8,3.,2.,5.)) return; | |
266 | } | |
267 | fEventStat->Fill(kPileupEvents); | |
b2a297fa | 268 | |
269 | //bz for AliKF | |
270 | Double_t bz = InputEvent()->GetMagneticField(); | |
271 | AliKFParticle::SetField( bz ); | |
272 | ||
2a14a7b1 | 273 | AliDielectronPID::SetCorrVal((Double_t)InputEvent()->GetRunNumber()); |
049fcec8 | 274 | AliDielectronPair::SetBeamEnergy(InputEvent(), fBeamEnergy); |
2a14a7b1 | 275 | |
b2a297fa | 276 | //Process event in all AliDielectron instances |
5720c765 | 277 | // TIter nextDie(&fListDielectron); |
278 | // AliDielectron *die=0; | |
42c76bea | 279 | Bool_t sel=kFALSE; |
48609e3d | 280 | Int_t idie=0; |
b2a297fa | 281 | while ( (die=static_cast<AliDielectron*>(nextDie())) ){ |
42c76bea | 282 | if(die->DoEventProcess()) { |
283 | sel= die->Process(InputEvent()); | |
284 | // input for internal train | |
285 | if(die->DontClearArrays()) { | |
286 | fPairArray = (*(die->GetPairArraysPointer())); | |
287 | ||
288 | } | |
289 | } | |
290 | else { | |
291 | // internal train | |
292 | if(sel) die->Process(fPairArray); | |
293 | } | |
294 | ||
48609e3d | 295 | if (die->HasCandidates()){ |
296 | Int_t ncandidates=die->GetPairArray(1)->GetEntriesFast(); | |
ffbede40 | 297 | if (ncandidates==1) fEventStat->Fill((kNbinsEvent)+2*idie); |
298 | else if (ncandidates>1) fEventStat->Fill((kNbinsEvent+1)+2*idie); | |
48609e3d | 299 | } |
300 | ++idie; | |
b2a297fa | 301 | } |
42c76bea | 302 | |
b2a297fa | 303 | PostData(1, &fListHistos); |
304 | PostData(2, &fListCF); | |
61d106d3 | 305 | PostData(3,fEventStat); |
b2a297fa | 306 | } |
307 | ||
572b0139 | 308 | //_________________________________________________________________________________ |
309 | void AliAnalysisTaskMultiDielectron::FinishTaskOutput() | |
310 | { | |
311 | // | |
312 | // Write debug tree | |
313 | // | |
314 | TIter nextDie(&fListDielectron); | |
42c76bea | 315 | Int_t ic=0; |
572b0139 | 316 | AliDielectron *die=0; |
42c76bea | 317 | AliDielectron *die2=0; |
318 | ||
319 | // main loop | |
572b0139 | 320 | while ( (die=static_cast<AliDielectron*>(nextDie())) ){ |
42c76bea | 321 | ic++; |
322 | ||
323 | // debug tree | |
572b0139 | 324 | die->SaveDebugTree(); |
42c76bea | 325 | |
326 | // skip internal train tasks in main loop | |
327 | if(!die->DoEventProcess()) continue; | |
328 | ||
329 | // mix remaining | |
5720c765 | 330 | AliDielectronMixingHandler *mix=die->GetMixingHandler(); |
42c76bea | 331 | if (!mix || !mix->GetMixUncomplete()) continue; |
332 | ||
333 | // loop over all pools | |
334 | for (Int_t ipool=0; ipool<mix->GetNumberOfBins(); ++ipool){ | |
335 | // printf("mix remaining %04d/%04d \n",ipool,mix->GetNumberOfBins()); | |
f6b5f163 | 336 | if(! mix->MixRemaining(die, ipool) ) { fPairArray=0x0; continue; } |
337 | ||
42c76bea | 338 | fPairArray = (*(die->GetPairArraysPointer())); |
339 | if(!fPairArray) continue; | |
340 | ||
341 | // loop over internal train task candidates | |
342 | for(Int_t i=ic; i<fListDielectron.GetEntries(); i++) { | |
343 | die2 = static_cast<AliDielectron*>(fListDielectron.At(i)); | |
35e527fa | 344 | // abort if tasks following are not internal wagons |
345 | if(die2->DoEventProcess()) break; | |
42c76bea | 346 | // fill internal train output |
347 | die2->SetPairArraysPointer(fPairArray); | |
348 | // printf(" --> fill internal train output %s \n",die2->GetName()); | |
349 | die2->FillHistogramsFromPairArray(kTRUE); | |
350 | } | |
351 | // printf("\n\n\n===============\ncall mix in Terminate: %p (%p)\n=================\n\n",mix,die); | |
352 | ||
353 | } | |
354 | ||
572b0139 | 355 | } |
42c76bea | 356 | |
5720c765 | 357 | PostData(1, &fListHistos); |
358 | PostData(2, &fListCF); | |
572b0139 | 359 | } |
360 |