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