end-of-line normalization
[u/mrichter/AliRoot.git] / PWGHF / vertexingHF / AliAnalysisTaskSEVertexingHFTest.C
CommitLineData
7fac8669 1void AliAnalysisTaskSEVertexingHFTest()
2{
3 //
4 // Test macro for the AliAnalysisTaskSE for heavy-flavour vertexing
5 // A.Dainese, andrea.dainese@lnl.infn.it
6 //
7
8 Bool_t inputAOD=kFALSE; // otherwise, ESD
9 Bool_t createAOD=kTRUE; // kTRUE: create AOD and use it as input to vertexing
10 // kFALSE: use ESD as input to vertexing
11 Bool_t writeKineToAOD = kFALSE;
12 TString mode="local"; // otherwise, "grid"
13 Bool_t useParFiles=kFALSE;
14 Bool_t doCentrality=kTRUE;
15
16 gROOT->LoadMacro("$ALICE_ROOT/PWGHF/vertexingHF/macros/LoadLibraries.C");
17 LoadLibraries(useParFiles);
18 gSystem->Load("libPWGmuon");
19 TChain *chain = 0;
20
21 if(mode=="local") {
22 // Local files
23 TString treeName,fileName;
24 if(inputAOD) {
25 treeName="aodTree";
26 fileName="AliAOD.root";
27 } else {
28 treeName="esdTree";
29 fileName="AliESDs.root";
30 }
31 chain = new TChain(treeName.Data());
32 chain->Add(fileName.Data());
33
34 } else if (mode=="grid") {
35 //Fetch files with AliEn :
36 const char *collectionfile = "Collection.xml";
37 TGrid::Connect("alien://") ;
38 TAlienCollection *coll = TAlienCollection::Open(collectionfile);
39 if(inputAOD) { // input AOD
40 chain = new TChain("aodTree");
41 while(coll->Next()) chain->Add(coll->GetTURL(""));
42 } else { // input ESD
43 //Create an AliRunTagCuts and an AliEventTagCuts Object and impose some selection criteria
44 AliRunTagCuts *runCuts = new AliRunTagCuts();
45 AliEventTagCuts *eventCuts = new AliEventTagCuts();
46 AliLHCTagCuts *lhcCuts = new AliLHCTagCuts();
47 AliDetectorTagCuts *detCuts = new AliDetectorTagCuts();
48 eventCuts->SetMultiplicityRange(0,20000);
49 //Create an AliTagAnalysis Object and chain the tags
50 AliTagAnalysis *tagAna = new AliTagAnalysis();
51 tagAna->SetType("ESD");
52 TGridResult *tagResult = coll->GetGridResult("",0,0);
53 tagResult->Print();
54 tagAna->ChainGridTags(tagResult);
55 //Create a new esd chain and assign the chain that is returned by querying the tags
56 chain = tagAna->QueryTags(runCuts,lhcCuts,detCuts,eventCuts);
57 }
58 } else {
59 printf("ERROR: mode has to be \"local\" or \"grid\" \n");
60 return;
61 }
62
63
64 // Create the analysis manager
65 AliAnalysisManager *mgr = new AliAnalysisManager("My Manager","My Manager");
66 mgr->SetDebugLevel(10);
67
68 // Input Handler
69 AliInputEventHandler *inputHandler = 0;
70 if(inputAOD) {
71 inputHandler = new AliAODInputHandler();
72 } else {
73 inputHandler = new AliESDInputHandler();
74 }
75 mgr->SetInputEventHandler(inputHandler);
76
77 // Output
78 AliAODHandler *aodHandler = new AliAODHandler();
79 const char* deltaAODfname="AliAOD.VertexingHF.root";
80 if(createAOD) {
81 aodHandler->SetOutputFileName("AliAOD.root");
82 } else {
83 aodHandler->SetOutputFileName(deltaAODfname);
84 aodHandler->SetAODExtensionMode();
85 }
86 mgr->SetOutputEventHandler(aodHandler);
87 mgr->RegisterExtraFile(deltaAODfname);
88
89 if(!inputAOD && createAOD) {
90 // MC Truth
91 AliMCEventHandler* mcHandler = new AliMCEventHandler();
92 if(writeKineToAOD) mgr->SetMCtruthEventHandler(mcHandler);
93 AliAnalysisTaskMCParticleFilter *kinefilter = new AliAnalysisTaskMCParticleFilter("Particle Filter");
94 if(writeKineToAOD) mgr->AddTask(kinefilter);
95 // Centrality
96 if(doCentrality){
97 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
98 AliCentralitySelectionTask *taskCentrality = AddTaskCentrality();
99 }
100
101 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskESDFilter.C");
102 AliAnalysisTaskESDfilter *filter = AddTaskESDFilter(writeKineToAOD);
103
104 }
105
106 // Vertexing analysis task
107 gROOT->LoadMacro("$ALICE_ROOT/PWGHF/vertexingHF/macros/AddTaskVertexingHF.C");
108 AliAnalysisTaskSEVertexingHF *hfTask = AddTaskVertexingHF(deltaAODfname);
109
110
111 //
112 // Run the analysis
113 //
114 printf("CHAIN HAS %d ENTRIES\n",(Int_t)chain->GetEntries());
115 if(!mgr->InitAnalysis()) return;
116
117 mgr->PrintStatus();
118
119 TStopwatch watch;
120 watch.Start();
121 mgr->StartAnalysis(mode.Data(),chain);
122 watch.Stop();
123 watch.Print();
124
125 return;
126}