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