89e94bddbc51d03a5f018559ddc8e579f004509e
[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   if (writeITSTP) {
58     AliAODHandler* aodHandler = new AliAODHandler();
59     aodHandler->SetOutputFileName( "AODtpITS.root" );
60     aodHandler->SetCreateNonStandardAOD();
61     mgr->SetOutputEventHandler(aodHandler);
62   }
63   //
64   // Event Statistics (Jan Fiete)
65   gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
66   AliPhysicsSelectionTask* physSelTask = AddTaskPhysicsSelection(kFALSE /*MC*/);
67   //
68   // add standard ITSAlignQA task with only SDD calibration histos activated
69   gROOT->LoadMacro("$ALICE_ROOT/PWGPP/macros/AddTaskITSAlign.C");
70   AliAnalysisTaskITSAlignQA *itsAlign = AddTaskITSAlign(0,2011,kTRUE);
71   itsAlign->SetLoadGeometryFromOCDB(kFALSE);
72   itsAlign->SetDoSPDResiduals(kFALSE);
73   itsAlign->SetDoSDDResiduals(kFALSE);
74   itsAlign->SetDoSSDResiduals(kFALSE);
75   itsAlign->SetDoSDDDriftTime(kFALSE);
76   itsAlign->SetMinMaxMult(20.,1070.);
77   itsAlign->SetUseTPCMomentum(useTPCcrv);
78   //
79   itsAlign->SetDoFillTPTree(writeITSTP);
80 }