1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 // Analysis task for Kinematic filtering
18 // Fill AODtrackMC tracks from Kinematic stack
23 #include "TParticle.h"
26 #include "AliAnalysisTaskMCParticleFilter.h"
27 #include "AliAnalysisManager.h"
28 #include "AliAnalysisFilter.h"
29 #include "AliHeader.h"
31 #include "AliMCEvent.h"
32 #include "AliMCEventHandler.h"
33 #include "AliAODEvent.h"
34 #include "AliAODHeader.h"
35 #include "AliAODMCHeader.h"
36 #include "AliAODHandler.h"
37 #include "AliAODVertex.h"
38 #include "AliAODMCParticle.h"
43 ClassImp(AliAnalysisTaskMCParticleFilter)
45 ////////////////////////////////////////////////////////////////////////
47 //____________________________________________________________________
48 AliAnalysisTaskMCParticleFilter::AliAnalysisTaskMCParticleFilter():
50 fTrackFilterMother(0x0)
52 // Default constructor
55 //____________________________________________________________________
56 AliAnalysisTaskMCParticleFilter::AliAnalysisTaskMCParticleFilter(const char* name):
57 AliAnalysisTaskSE(name),
58 fTrackFilterMother(0x0)
60 // Default constructor
64 //____________________________________________________________________
65 AliAnalysisTaskMCParticleFilter::AliAnalysisTaskMCParticleFilter(const AliAnalysisTaskMCParticleFilter& obj):
66 AliAnalysisTaskSE(obj),
67 fTrackFilterMother(obj.fTrackFilterMother)
72 //____________________________________________________________________
73 AliAnalysisTaskMCParticleFilter::~AliAnalysisTaskMCParticleFilter()
75 // if( fTrackFilterMother ) delete fTrackFilterMother;
79 //____________________________________________________________________
80 AliAnalysisTaskMCParticleFilter& AliAnalysisTaskMCParticleFilter::operator=(const AliAnalysisTaskMCParticleFilter& other)
84 AliAnalysisTaskSE::operator=(other);
85 fTrackFilterMother = other.fTrackFilterMother;
90 //____________________________________________________________________
91 void AliAnalysisTaskMCParticleFilter::UserCreateOutputObjects()
93 // Create the output container
94 if (OutputTree()&&fTrackFilterMother)
95 OutputTree()->GetUserInfo()->Add(fTrackFilterMother);
97 // this part is mainly needed to set the MCEventHandler
98 // to the AODHandler, this will not be needed when
99 // AODHandler goes to ANALYSISalice
100 // setting in the steering macro will not work on proof :(
101 // so we have to do it in a task
103 // the branch booking can also go into the AODHandler then
107 TClonesArray *tca = new TClonesArray("AliAODMCParticle", 0);
108 tca->SetName(AliAODMCParticle::StdBranchName());
109 AddAODBranch("TClonesArray",&tca);
112 AliAODMCHeader *mcHeader = new AliAODMCHeader();
113 Printf("AODMCHeader %p",mcHeader);
114 Printf("AODMCHeader ** %p",&mcHeader);
115 mcHeader->SetName(AliAODMCHeader::StdBranchName());
116 AddAODBranch("AliAODMCHeader",&mcHeader);
120 AliMCEventHandler *mcH = (AliMCEventHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
121 AliAODHandler *aodH = dynamic_cast<AliAODHandler*> ((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
123 Printf("%s:&d Could not get AODHandler",(char*)__FILE__,__LINE__);
126 aodH->SetMCEventHandler(mcH);
131 //____________________________________________________________________
132 void AliAnalysisTaskMCParticleFilter::UserExec(Option_t */*option*/)
134 // Execute analysis for current event
137 // Fill AOD tracks from Kinematic stack
140 AliAODEvent* aod = AODEvent();
142 AliWarning("No Output Handler connected, doing nothing !") ;
146 AliMCEventHandler *mcH = (AliMCEventHandler*) ((AliAnalysisManager::GetAnalysisManager())->GetMCtruthEventHandler());
148 AliWarning("No MC handler Found");
154 // Fill control histos
156 // tmp array for holding the mctracks
157 // need to set mother and duagther __before__
158 // filling in the tree
160 AliMCEvent *mcE = MCEvent();
163 AliWarning("No MC event Found");
167 AliStack* stack = mcE->Stack();
168 Int_t np = mcE->GetNumberOfTracks();
169 Int_t nprim = stack->GetNprimary();
170 // TODO ADD MC VERTEX
172 // We take all real primaries
177 for (Int_t ip = 0; ip < np; ip++){
178 AliMCParticle* mcpart = mcE->GetTrack(ip);
179 TParticle* part = mcpart->Particle();
181 Float_t xv = part->Vx();
182 Float_t yv = part->Vy();
183 Float_t zv = part->Vz();
184 Float_t rv = TMath::Sqrt(xv * xv + yv * yv);
186 Bool_t write = kFALSE;
189 // Select the primary event
191 } else if (part->GetUniqueID() == 4) {
192 // Particles from decay
193 // Check that the decay chain ends at a primary particle
194 TParticle* mother = part;
195 Int_t imo = part->GetFirstMother();
196 while((imo >= nprim) && (mother->GetUniqueID() == 4)) {
197 mother = mcE->Stack()->Particle(imo);
198 imo = mother->GetFirstMother();
200 // Select according to pseudorapidity and production point
201 if (imo < nprim && Select(mother, rv, zv))
203 } else if (part->GetUniqueID() == 5) {
204 // Now look for pair production
206 Int_t imo = part->GetFirstMother();
208 // Select, if the gamma is a primary
211 // Check if the gamma comes from the decay chain of a primary particle
212 TParticle* mother = mcE->Stack()->Particle(imo);
213 imo = mother->GetFirstMother();
214 while((imo >= nprim) && (mother->GetUniqueID() == 4)) {
215 mother = mcE->Stack()->Particle(imo);
216 imo = mother->GetFirstMother();
218 // Select according to pseudorapidity and production point
219 if (imo < nprim && Select(mother, rv, zv))
224 else if (part->GetUniqueID() == 13){
226 // Check that we end at a primary particle
227 TParticle* mother = part;
228 Int_t imo = part->GetFirstMother();
229 while((imo >= nprim) && ((mother->GetUniqueID() == 4 ) || ( mother->GetUniqueID() == 13))) {
230 mother = mcE->Stack()->Particle(imo);
231 imo = mother->GetFirstMother();
233 // Select according to pseudorapidity and production point
234 if (imo < nprim && Select(mother, rv, zv))
239 if(mcH)mcH->SelectParticle(ip);
247 Bool_t AliAnalysisTaskMCParticleFilter::Select(TParticle* part, Float_t rv, Float_t zv)
249 // Selection accoring to eta of the mother and production point
250 // This has to be refined !!!!!!
252 // Esp if we don't have collisison in the central barrel but e.g. beam gas
255 Float_t eta = part->Eta();
257 // central barrel consider everything in the ITS...
258 // large eta window for smeared vertex and SPD acceptance (2 at z = 0)
259 // larger for V0s in the TPC
260 // if (TMath::Abs(eta) < 2.5 && rv < 250. && TMath::Abs(zv)<255)return kTRUE;
263 if (TMath::Abs(eta) < 1. && rv < 170)return kTRUE;
266 if(eta > -4.2 && eta < -2.3 && zv > -500.)return kTRUE; // Muon arms
268 // PMD acceptance 2.3 <= eta < = 3.5
269 // if(eta>2.0&&eta<3.7)return kTRUE;