]>
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 <AliLog.h> | |
26 | #include <AliAODHandler.h> | |
27 | #include <AliAnalysisManager.h> | |
28 | #include <AliVEvent.h> | |
8df8e382 | 29 | #include <AliInputEventHandler.h> |
30 | #include <AliESDInputHandler.h> | |
b2a297fa | 31 | |
32 | #include "AliDielectron.h" | |
8df8e382 | 33 | #include "AliDielectronMC.h" |
b2a297fa | 34 | #include "AliDielectronHistos.h" |
8df8e382 | 35 | #include "AliDielectronVarManager.h" |
b2a297fa | 36 | #include "AliAnalysisTaskDielectronFilter.h" |
37 | ||
38 | ClassImp(AliAnalysisTaskDielectronFilter) | |
39 | ||
40 | //_________________________________________________________________________________ | |
41 | AliAnalysisTaskDielectronFilter::AliAnalysisTaskDielectronFilter() : | |
61d106d3 | 42 | AliAnalysisTaskSE(), |
43 | fDielectron(0), | |
44 | fSelectPhysics(kTRUE), | |
45 | fTriggerMask(AliVEvent::kMB), | |
46 | fEventStat(0x0) | |
b2a297fa | 47 | { |
48 | // | |
49 | // Constructor | |
50 | // | |
51 | } | |
52 | ||
53 | //_________________________________________________________________________________ | |
54 | AliAnalysisTaskDielectronFilter::AliAnalysisTaskDielectronFilter(const char *name) : | |
61d106d3 | 55 | AliAnalysisTaskSE(name), |
56 | fDielectron(0), | |
57 | fSelectPhysics(kTRUE), | |
58 | fTriggerMask(AliVEvent::kMB), | |
59 | fEventStat(0x0) | |
b2a297fa | 60 | { |
61 | // | |
62 | // Constructor | |
63 | // | |
64 | DefineInput(0,TChain::Class()); | |
65 | DefineOutput(1, THashList::Class()); | |
61d106d3 | 66 | DefineOutput(2, TH1D::Class()); |
b2a297fa | 67 | } |
68 | ||
69 | //_________________________________________________________________________________ | |
70 | void AliAnalysisTaskDielectronFilter::Init() | |
71 | { | |
72 | // Initialization | |
73 | if (fDebug > 1) AliInfo("Init() \n"); | |
74 | ||
75 | // require AOD handler | |
76 | AliAODHandler *aodH = (AliAODHandler*)((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler()); | |
77 | if (!aodH) Fatal("Init", "No AOD handler. Halting."); | |
78 | ||
79 | //require dielectron framework | |
80 | if (!fDielectron) { | |
81 | Error("Init","Dielectron framework class required. Please create and instance with proper cuts and set it via 'SetDielectron' before executing this task!!!"); | |
82 | return; | |
83 | } | |
8df8e382 | 84 | fDielectron->Init(); |
b2a297fa | 85 | |
86 | aodH->AddFilteredAOD("AliAOD.Dielectron.root", "DielectronEvents"); | |
87 | // AddAODBranch("AliDielectronCandidates",fDielectron->GetPairArraysPointer(),"deltaAOD.Dielectron.root"); | |
88 | } | |
89 | ||
61d106d3 | 90 | //_________________________________________________________________________________ |
91 | void AliAnalysisTaskDielectronFilter::UserCreateOutputObjects() | |
92 | { | |
93 | // | |
94 | // Initilise histograms | |
95 | // | |
96 | if (!fEventStat){ | |
97 | fEventStat=new TH1D("hEventStat","Event statistics",5,0,5); | |
98 | fEventStat->GetXaxis()->SetBinLabel(1,"Before Phys. Sel."); | |
99 | fEventStat->GetXaxis()->SetBinLabel(2,"After Phys. Sel."); | |
100 | fEventStat->GetXaxis()->SetBinLabel(3,"After Cand. Sel."); | |
101 | } | |
102 | ||
103 | PostData(2,fEventStat); | |
104 | } | |
105 | ||
b2a297fa | 106 | //_________________________________________________________________________________ |
107 | void AliAnalysisTaskDielectronFilter::UserExec(Option_t *) | |
108 | { | |
109 | // | |
110 | // Main loop. Called for every event | |
111 | // | |
8df8e382 | 112 | |
b2a297fa | 113 | if (!fDielectron) return; |
114 | ||
8df8e382 | 115 | AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager(); |
116 | AliESDInputHandler *esdHandler=0x0; | |
117 | if ( (esdHandler=dynamic_cast<AliESDInputHandler*>(man->GetInputEventHandler())) && esdHandler->GetESDpid() ){ | |
118 | AliDielectronVarManager::SetESDpid(esdHandler->GetESDpid()); | |
119 | } else { | |
120 | //load esd pid bethe bloch parameters depending on the existance of the MC handler | |
121 | // yes: MC parameters | |
122 | // no: data parameters | |
123 | if (!AliDielectronVarManager::GetESDpid()){ | |
124 | if (AliDielectronMC::Instance()->HasMC()) { | |
125 | AliDielectronVarManager::InitESDpid(); | |
126 | } else { | |
127 | AliDielectronVarManager::InitESDpid(1); | |
128 | } | |
129 | } | |
130 | } | |
131 | // Was event selected ? | |
132 | AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler()); | |
61d106d3 | 133 | UInt_t isSelected = AliVEvent::kAny; |
8df8e382 | 134 | if( fSelectPhysics && inputHandler && inputHandler->GetEventSelection() ) { |
135 | isSelected = inputHandler->IsEventSelected(); | |
61d106d3 | 136 | isSelected&=fTriggerMask; |
8df8e382 | 137 | } |
61d106d3 | 138 | |
139 | //Before physics selection | |
140 | fEventStat->Fill(0.); | |
141 | if (isSelected==0) { | |
142 | PostData(2,fEventStat); | |
143 | return; | |
144 | } | |
145 | //after physics selection | |
146 | fEventStat->Fill(1.); | |
8df8e382 | 147 | |
b2a297fa | 148 | //bz for AliKF |
149 | Double_t bz = InputEvent()->GetMagneticField(); | |
150 | AliKFParticle::SetField( bz ); | |
151 | ||
152 | fDielectron->Process(InputEvent()); | |
8df8e382 | 153 | |
b2a297fa | 154 | if(fDielectron->HasCandidates()){ |
8df8e382 | 155 | //If input event is an AliESDevent |
156 | // replace the references of the legs with the AOD references | |
157 | if(man->GetInputEventHandler()->IsA()==AliESDInputHandler::Class()){ | |
158 | AliAODEvent *aod = ((AliAODHandler*)((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler()))->GetAOD(); | |
159 | TObjArray *obj = 0x0; | |
160 | AliAODTrack *leg1 = 0x0; | |
161 | AliAODTrack *leg2 = 0x0; | |
162 | for(Int_t i=0; i < 10; i++ ){ | |
163 | obj = (TObjArray*)(*(fDielectron->GetPairArraysPointer()))->UncheckedAt(i); | |
164 | if(!obj) continue; | |
165 | for(int j=0;j<obj->GetEntriesFast();j++) | |
166 | { | |
167 | AliDielectronPair *pairObj = (AliDielectronPair*)obj->UncheckedAt(j); | |
168 | Int_t id1 = ((AliESDtrack*)pairObj->GetFirstDaughter())->GetID(); | |
169 | Int_t id2 = ((AliESDtrack*)pairObj->GetSecondDaughter())->GetID(); | |
170 | for(Int_t it=0;it<aod->GetNumberOfTracks();it++){ | |
171 | if(aod->GetTrack(it)->GetID() == id1) leg1 = aod->GetTrack(it); | |
172 | if(aod->GetTrack(it)->GetID() == id2) leg2 = aod->GetTrack(it); | |
173 | } | |
174 | if(!leg1 || !leg2) continue; | |
175 | pairObj->SetRefFirstDaughter(leg1); | |
176 | pairObj->SetRefSecondDaughter(leg2); | |
177 | } | |
178 | } | |
179 | } | |
180 | ||
b2a297fa | 181 | AliAODExtension *extDielectron = dynamic_cast<AliAODHandler*> |
8df8e382 | 182 | ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler())->GetFilteredAOD("AliAOD.Dielectron.root"); |
b2a297fa | 183 | extDielectron->SelectEvent(); |
61d106d3 | 184 | //after candidate selection |
185 | fEventStat->Fill(2.); | |
186 | ||
b2a297fa | 187 | //see if dielectron candidate branch exists, if not create is |
188 | TTree *t=extDielectron->GetTree(); | |
189 | if (!t->GetBranch("dielectrons")){ | |
190 | t->Bronch("dielectrons","TObjArray",fDielectron->GetPairArraysPointer()); | |
191 | } | |
192 | } | |
193 | ||
194 | PostData(1, const_cast<THashList*>(fDielectron->GetHistogramList())); | |
61d106d3 | 195 | PostData(2,fEventStat); |
b2a297fa | 196 | } |
197 |