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 // Create a new AOD starting from the general AOD. This Task can be used also strating
18 //from ESD changing the input handler. (Method to be testeted on the grid)
19 // filtering of the ESD.
21 // Authors: S. Bufalino (stefania.bufalino@cern.ch)
22 // R. Lea (ramona.lea@cern.ch)
23 // Based on AliAnalysisTaskESDMuonFilter.cxx
25 // (see AddFilteredAOD method)
28 #include "AliAnalysisTaskESDNuclExFilterMC.h"
30 #include "AliAODEvent.h"
31 #include "AliAODHandler.h"
32 #include "AliAODExtension.h"
33 #include "AliAODMCParticle.h"
34 #include "AliAODMCNuclExReplicator.h"
35 #include "AliAODVertex.h"
36 #include "AliAnalysisFilter.h"
37 #include "AliAnalysisManager.h"
38 #include "AliCodeTimer.h"
39 #include "AliESDEvent.h"
40 #include "AliESDInputHandler.h"
41 #include "AliESDMuonTrack.h"
42 #include "AliESDVertex.h"
43 #include "AliESDtrack.h"
45 #include "AliMCEvent.h"
46 #include "AliMCEventHandler.h"
47 #include "AliMultiplicity.h"
50 #include <TParticle.h>
51 #include "AliESDtrackCuts.h"
52 #include "AliAODTrack.h"
53 #include "AliAODPid.h"
55 //#include "AliPIDResponse.h"
59 ClassImp(AliAnalysisTaskESDNuclExFilterMC)
61 ////////////////////////////////////////////////////////////////////////
63 AliAnalysisTaskESDNuclExFilterMC::AliAnalysisTaskESDNuclExFilterMC(Bool_t onlyMuon, Bool_t keepAllEvents, Int_t mcMode, Int_t nsigmaTrk1,Int_t nsigmaTrk2, Int_t partType1,Int_t partType2):
66 fEnableMuonAOD(kTRUE),
67 fEnableDimuonAOD(kTRUE),
69 fKeepAllEvents(keepAllEvents),
71 fnSigmaTrk1(nsigmaTrk1),
72 fnSigmaTrk2(nsigmaTrk2),
73 fpartType1(partType1),
74 fpartType2(partType2),
77 // Default constructor
80 AliAnalysisTaskESDNuclExFilterMC::AliAnalysisTaskESDNuclExFilterMC(const char* name, Bool_t onlyMuon, Bool_t keepAllEvents, Int_t mcMode, Int_t nsigmaTrk1,Int_t nsigmaTrk2, Int_t partType1,Int_t partType2):
81 AliAnalysisTaskSE(name),
83 fEnableMuonAOD(kTRUE),
84 fEnableDimuonAOD(kTRUE),
86 fKeepAllEvents(keepAllEvents),
88 fnSigmaTrk1(nsigmaTrk1),
89 fnSigmaTrk2(nsigmaTrk2),
90 fpartType1(partType1),
91 fpartType2(partType2),
98 //______________________________________________________________________________
99 void AliAnalysisTaskESDNuclExFilterMC::UserCreateOutputObjects()
102 // Create the output container
103 if (fTrackFilter) OutputTree()->GetUserInfo()->Add(fTrackFilter);
107 //______________________________________________________________________________
108 void AliAnalysisTaskESDNuclExFilterMC::PrintTask(Option_t *option, Int_t indent) const
110 // Specify how we are configured
112 AliAnalysisTaskSE::PrintTask(option,indent);
114 TString spaces(' ',indent+3);
118 cout << spaces.Data() << "Keep only muon information " << endl;
122 cout << spaces.Data() << "Keep all information from standard AOD" << endl;
125 if ( fKeepAllEvents )
127 cout << spaces.Data() << "Keep all events, regardless of number of muons" << endl;
131 cout << spaces.Data() << "Keep only events with at least one muon" << endl;
136 cout << spaces.Data() << "Assuming work on MC data (i.e. will transmit MC branches)" << endl;
140 //______________________________________________________________________________
141 void AliAnalysisTaskESDNuclExFilterMC::AddFilteredAOD(const char* aodfilename, const char* title, Bool_t toMerge)
144 //cout<<"Entro ne ADDFILTETEDAOD"<<endl;
146 AliAODHandler *aodH = (AliAODHandler*)((AliAnalysisManager::GetAnalysisManager())->GetOutputEventHandler());
147 if (!aodH) Fatal("UserCreateOutputObjects", "No AOD handler");
151 AliAODExtension* ext = aodH->AddFilteredAOD(aodfilename,title,toMerge);
158 if(!murep)delete murep;
160 murep = new AliAODMCNuclExReplicator("NuclExReplicator",
161 "remove non interesting tracks",
162 fMCMode,fnSigmaTrk1,fnSigmaTrk2,fpartType1,fpartType2);
165 ext->DropUnspecifiedBranches(); // all branches not part of a FilterBranch call (below) will be dropped
167 ext->FilterBranch("header",murep);
168 ext->FilterBranch("vertices",murep);
169 ext->FilterBranch("nuclei",murep);
170 ext->FilterBranch("secvertices",murep); //per test
171 ext->FilterBranch("daughtertracks",murep);
173 //cout<<"add filterd aod"<<endl;
177 // MC branches will be copied (if present), as they are, but only
178 // for events with at least one muon.
179 // For events w/o muon, mcparticles array will be empty and mcheader will be dummy
180 // (e.g. strlen(GetGeneratorName())==0)
182 ext->FilterBranch("mcparticles",murep);
183 ext->FilterBranch("mcHeader",murep);
188 //cout<<"fine add filterd"<<endl;
191 //______________________________________________________________________________
192 void AliAnalysisTaskESDNuclExFilterMC::Init()
197 AddFilteredAOD("AliAOD.NuclEx.root", "NuclexFilteredEvents",kTRUE);
201 //______________________________________________________________________________
202 void AliAnalysisTaskESDNuclExFilterMC::UserExec(Option_t */*option*/)
204 // Execute analysis for current event
206 Long64_t ientry = Entry();
207 if(fDebug)printf("Muon Filter: Analysing event # %5d\n", (Int_t) ientry);
209 //***************************************************
213 //*************************************************
218 void AliAnalysisTaskESDNuclExFilterMC::ConvertESDtoAOD()
222 //cout<<"========================> CONVERT ESD TO AOD <============================="<<endl;
225 AliAODEvent *lAODevent=(AliAODEvent*)InputEvent();
227 // Read primary vertex from AOD event
228 // AliAODVertex *primary = *(AODEvent()->GetPrimaryVertex());
230 AliAODVertex *primary = lAODevent->GetPrimaryVertex();
231 if (fDebug && primary) primary->Print();
232 //cout<<"Primary vtx x: "<<primary->GetX()<<" "<<primary->GetY()<<" "<<primary->GetZ()<<endl;
234 AliAODHandler* handler = dynamic_cast<AliAODHandler*>(AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler());
238 AliAODExtension *extNuclEx = handler->GetFilteredAOD("AliAOD.NuclEx.root");
242 extNuclEx->SetEvent(lAODevent);
243 extNuclEx->SelectEvent();
244 extNuclEx->FinishEvent();
250 //------------------------------------------------
251 void AliAnalysisTaskESDNuclExFilterMC::Terminate(Option_t */*option*/)
253 // Terminate analysis
257 if (fDebug > 1) printf("AnalysisESDfilter: Terminate() \n");