Example macro for filtering MC info to the AOD on proof, added comment
[u/mrichter/AliRoot.git] / ANALYSIS / runAODFilterMC.C
1 void runAODFilterMC()
2 {
3   // PROOF example
4
5       gSystem->Load("libTree.so");
6       gSystem->Load("libPhysics.so");
7       gSystem->Load("libGeom.so");
8       gSystem->Load("libVMC.so");
9
10       bool bKineFilter = true;
11
12       TProof::Open("alicecaf");
13       char *dataset = "/COMMON/COMMON/LHC08c11_10TeV_0.5T";
14       //      char *dataset = "/PWG4/kleinb/LHC08q_jetjet100";
15       // gProof->ClearPackages();
16       gProof->UploadPackage("${ALICE_ROOT}/STEERBase.par");
17       gProof->EnablePackage("STEERBase");
18       gProof->UploadPackage("${ALICE_ROOT}/ESD.par");
19       gProof->EnablePackage("ESD");
20       gProof->UploadPackage("${ALICE_ROOT}/AOD.par");
21       gProof->EnablePackage("AOD");
22       gProof->UploadPackage("${ALICE_ROOT}/ANALYSIS.par");
23       gProof->EnablePackage("ANALYSIS");
24       gProof->UploadPackage("${ALICE_ROOT}/ANALYSISalice.par");
25       gProof->EnablePackage("ANALYSISalice");
26       
27       //
28       if (gApplication) gApplication->InitializeGraphics();
29       // Create the chain
30       //
31
32
33         /////////////////////////////////////////////////////////////////////////////////// 
34         // Create the analysis manager
35         //
36         // Input 
37       AliESDInputHandler* inpHandler = new AliESDInputHandler();
38       // Output
39       AliAODHandler* aodHandler = new AliAODHandler();
40       aodHandler->SetOutputFileName("aod_ckb2.root");
41       // MC Truth
42       AliMCEventHandler* mcHandler = new AliMCEventHandler();
43       AliAnalysisManager *mgr  = new AliAnalysisManager("Filter Manager", "Filter Manager");
44      if(bKineFilter){
45        mgr->SetMCtruthEventHandler(mcHandler);
46      }
47
48       mgr->SetInputEventHandler  (inpHandler);
49       mgr->SetOutputEventHandler (aodHandler);
50       aodHandler->Dump();
51
52       mgr->SetDebugLevel(10);
53
54       // Filtering of MC particles (decays conversions etc)
55       // this task is also needed to set the MCEventHandler
56       // to the AODHandler, this will not be needed when
57       // AODHandler goes to ANALYSISalice
58       AliAnalysisTaskMCParticleFilter *kinefilter = new AliAnalysisTaskMCParticleFilter("Particle Filter");
59       if(bKineFilter)mgr->AddTask(kinefilter);
60       
61       
62       // 
63       AliESDtrackCuts* esdTrackCutsL = new AliESDtrackCuts("AliESDtrackCuts", "Loose");
64       esdTrackCutsL->SetMinNClustersTPC(50);
65       esdTrackCutsL->SetMaxChi2PerClusterTPC(3.5);
66       esdTrackCutsL->SetMaxCovDiagonalElements(2,2,0.5,0.5,2);
67       esdTrackCutsL->SetRequireTPCRefit(kTRUE);
68       esdTrackCutsL->SetDCAToVertexZ(3.0);
69       esdTrackCutsL->SetDCAToVertexXY(3.0);
70       esdTrackCutsL->SetRequireSigmaToVertex(kFALSE);
71       esdTrackCutsL->SetAcceptKingDaughters(kFALSE);
72       
73       AliAnalysisFilter* trackFilter = new AliAnalysisFilter("trackFilter");
74       trackFilter->AddCuts(esdTrackCutsL);
75       
76       AliAnalysisTaskESDfilter *esdfilter = new AliAnalysisTaskESDfilter("ESD Filter");
77       esdfilter->SetTrackFilter(trackFilter);
78       
79       mgr->AddTask(esdfilter);
80     
81     
82       //
83       // Create containers for input/output
84       AliAnalysisDataContainer *cinput1 = mgr->CreateContainer("cchain",TChain::Class(), 
85                                                                AliAnalysisManager::kInputContainer);
86       
87       AliAnalysisDataContainer *coutput1 = mgr->CreateContainer("tree", TTree::Class(),
88                                                               AliAnalysisManager::kOutputContainer, "default");
89       
90       coutput1->SetSpecialOutput();
91
92       if(bKineFilter){
93         mgr->ConnectInput  (kinefilter,     0, cinput1  );
94         mgr->ConnectOutput (kinefilter,     0, coutput1 );
95       }
96
97         mgr->ConnectInput  (esdfilter,     0, cinput1  );
98         mgr->ConnectOutput (esdfilter,     0, coutput1 );
99       
100       //
101       // Run the analysis
102       //    
103       mgr->InitAnalysis();
104       mgr->PrintStatus();
105       mgr->StartAnalysis("proof",dataset,10000);
106
107 }