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