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