TENDER becomes Tender
[u/mrichter/AliRoot.git] / PWGPP / macros / RecoQAtrain.C
1 // RS: This is macro to build an analysis train which will run from the reco loop
2 //     Uses special AliRecoInputHandler 
3 // Should be attached in rec.C as
4 // AliReconstruction rec; rec.SetAnalysisMacro(thisMacroPath);
5
6 void LoadLibraries();
7 void AddAnalysisTasks(Bool_t writeITSTP=kFALSE, Bool_t useTPCcrv=kFALSE); 
8
9
10 void RecoQAtrain(Bool_t writeITSTP=kFALSE, Bool_t useTPCcrv=kFALSE)
11 {
12   //
13   TGrid::Connect("alien://");
14   if (!gGrid || !gGrid->IsConnected()) {
15     ::Error("QAtrain", "No grid connection");
16     return;
17   }   
18   // Set temporary merging directory to current one
19   gSystem->Setenv("TMPDIR", gSystem->pwd());
20   // Set temporary compilation directory to current one
21   gSystem->SetBuildDir(gSystem->pwd(), kTRUE);
22   // Load libraries
23   LoadLibraries();
24   printf("Include path: %s\n", gSystem->GetIncludePath());
25   // Create manager
26   AliAnalysisManager *mgr  = new AliAnalysisManager("Analysis", "Reco QA train");
27   // Input handler
28   AliRecoInputHandler *esdHandler = new AliRecoInputHandler();
29   esdHandler->SetReadFriends(kTRUE);
30   esdHandler->SetActiveBranches("ESDfriend");
31   mgr->SetInputEventHandler(esdHandler);
32   //  
33   // AnalysisTasks
34   AddAnalysisTasks(writeITSTP,useTPCcrv);
35   //
36   if (!mgr->InitAnalysis()) printf("Failed to initialize Reco Analysis");
37 }
38
39 void LoadLibraries()
40 {
41   gSystem->SetIncludePath("-I. -I$ROOTSYS/include -I$ALICE_ROOT/include -I$ALICE_ROOT -I$ALICE_ROOT/ITS -I$ALICE_ROOT/TRD -I$ALICE_ROOT/PWGPP -I$ALICE_ROOT/PWGPP/TRD");
42   gSystem->Load("libANALYSIS");
43   gSystem->Load("libANALYSISalice");
44   gSystem->Load("libCORRFW");
45   gSystem->Load("libTender");
46   //  gSystem->Load("libPWG0base.so");
47   //  gSystem->Load("libPWG0dep.so");
48   //  gSystem->Load("libPWG0selectors.so");
49   gSystem->Load("libPWGPP.so");
50 }
51
52 void AddAnalysisTasks(Bool_t writeITSTP, Bool_t useTPCcrv)
53 {
54   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
55   mgr->SetCommonFileName("RecoQAresults.root");
56   //
57   // Event Statistics (Jan Fiete)
58   gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
59   AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(kFALSE /*MC*/);
60   //
61   // add standard ITSAlignQA task with only SDD calibration histos activated
62   gROOT->LoadMacro("$ALICE_ROOT/PWGPP/macros/AddTaskITSAlign.C");
63   AliAnalysisTaskITSAlignQA *itsAlign = AddTaskITSAlign(0,2011,kTRUE);
64   itsAlign->SetLoadGeometryFromOCDB(kFALSE);
65   itsAlign->SetDoSPDResiduals(kFALSE);
66   itsAlign->SetDoSDDResiduals(kFALSE);
67   itsAlign->SetDoSSDResiduals(kFALSE);
68   itsAlign->SetDoSDDDriftTime(kFALSE);
69   itsAlign->SetMinMaxMult(20.,1070.);
70   itsAlign->SetUseTPCMomentum(useTPCcrv);
71   itsAlign->SetDoFillTPTree(writeITSTP);
72   //
73   if (writeITSTP) {
74     AliAnalysisDataContainer *coutputTP = mgr->CreateContainer("ITSSumTP",
75                                                                TTree::Class(),
76                                                                AliAnalysisManager::kOutputContainer,
77                                                                "AODtpITS.root" );
78     mgr->ConnectOutput(itsAlign, 2, coutputTP);
79   }
80   //
81 }