Merge remote-tracking branch 'origin/master' into TPCdev
[u/mrichter/AliRoot.git] / PWGPP / macros / runFilteringTask.C
1 void runFilteringTask( const char* esdList,   
2         Float_t scalingTracks,
3         Float_t scalingV0,
4         const char* ocdb = "local:///cvmfs/alice.gsi.de/alice/data/2010/OCDB/" ,
5         Int_t nFiles = 1000000,  
6         Int_t firstFile=0, 
7         Int_t nEvents=30000000, 
8         Int_t firstEvent =0,
9         const char* esdFileName="AliESDs.root",
10         Bool_t mc=kFALSE)
11 {
12     TStopwatch timer;
13     timer.Start();
14
15     printf("\n\n\n");
16     printf("scalingTracks=%d\n",scalingTracks);
17     printf("scalingV0=%d\n",scalingV0);
18     printf("nFiles=%d\n",nFiles);
19
20     gSystem->SetIncludePath("-I$ROOTSYS/include -I$ALICE_ROOT/include -I$ALICE_ROOT/ITS -I$ALICE_ROOT -I$ALICE_ROOT/TRD");
21
22     gSystem->Load("libANALYSIS");
23     gSystem->Load("libANALYSISalice");
24     gSystem->Load("libTENDER");
25     gSystem->Load("libCORRFW");
26     gSystem->Load("libPWGUDbase");
27     gSystem->Load("libTPCcalib");
28     gSystem->Load("libPWGPP");
29     gSystem->Load("libPWGLFspectra");
30
31     //____________________________________________//
32     // Make the analysis manager
33     AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
34     mgr->SetDebugLevel(0);
35
36     AliESDInputHandler* esdH = new AliESDInputHandler();
37     //esdH->SetReadFriends(1);
38     //esdH->SetReadFriends(1);
39     mgr->SetInputEventHandler(esdH);  
40
41     // Enable MC event handler
42     AliMCEventHandler* handlerMC = new AliMCEventHandler;
43     //handler->SetReadTR(kFALSE);
44     if (mc) mgr->SetMCtruthEventHandler(handlerMC);
45
46     gROOT->LoadMacro("$ALICE_ROOT/PWGPP/PilotTrain/AddTaskCDBconnect.C");
47     AddTaskCDBconnect(ocdb);
48
49     if (gSystem->AccessPathName("localOCDBaccessConfig.C", kFileExists)==0) {
50       gROOT->LoadMacro("localOCDBaccessConfig.C");
51       localOCDBaccessConfig();
52     }
53
54     // Create input chain
55     //gROOT->LoadMacro("$ALICE_ROOT/PWGUD/macros/CreateESDChain.C");
56     //TChain* chain = CreateESDChain(esdList, nFiles,firstFile);
57     AliXRDPROOFtoolkit toolkit;
58     AliXRDPROOFtoolkit::FilterList(esdList,Form("%s esdTree",esdFileName),0);
59     TChain * chain = toolkit.MakeChain(Form("%s.Good",esdList),"esdTree","asd",nFiles,firstFile);
60
61
62
63     if(!chain) {
64         printf("ERROR: chain cannot be created\n");
65         return;
66     }
67     chain->Lookup();
68
69     //
70     // Wagons to run 
71     //
72
73
74     gROOT->LoadMacro("$ALICE_ROOT/PWGPP/macros/AddTaskFilteredTree.C");
75     AliAnalysisTaskFilteredTree* task = (AliAnalysisTaskFilteredTree*)AddTaskFilteredTree("FilterEvents_Trees.root");
76     task->SetLowPtTrackDownscaligF(scalingTracks);
77     task->SetLowPtV0DownscaligF(scalingV0);
78
79     // Init
80     if (!mgr->InitAnalysis()) 
81         mgr->PrintStatus();
82
83     //
84     // Run on dataset
85     mgr->StartAnalysis("local",chain,nEvents, firstEvent);
86
87     timer.Stop();
88     timer.Print();
89
90     delete mgr;
91 }