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