]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/FORWARD/analysis2/MakeMCCorr.C
Fixed references from PWG2 -> PWGLF - very efficiently done using ETags.
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / MakeMCCorr.C
CommitLineData
269cc80d 1/**
56236b95 2 * @file MakeMCCorr.C
269cc80d 3 * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
56236b95 4 * @date Tue Jul 12 10:06:07 2011
269cc80d 5 *
56236b95 6 * @brief Generate MC corrections
269cc80d 7 *
bd6f5206 8 * @ingroup pwglf_forward_scripts_makers
269cc80d 9 */
56236b95 10//====================================================================
269cc80d 11/**
56236b95 12 * Generatew MC corrections
269cc80d 13 *
14 * If the ROOT AliEn interface library (libRAliEn) can be loaded,
15 * and the parameter @a name is not empty, then use the plugin to do
16 * the analysis. Note that in this case, the output is placed
17 * in a sub-directory named by @a name after escaping spaces and special
18 * characters
19 *
c6115ede 20 * @param esddir AOD input directory. Any file matching the pattern
269cc80d 21 * *AliAODs*.root are added to the chain
22 * @param nEvents Number of events to process. If 0 or less, then
23 * all events are analysed
269cc80d 24 * @param vzMin Least @f$ v_z@f$ (centimeter)
25 * @param vzMax Largest @f$ v_z@f$ (centimeter)
26 * @param proof If larger then 1, run in PROOF-Lite mode with this
27 * many number of workers.
28 * @param name Name of train - free form. This will be the name
29 * of the output directory if the plug-in is used
30 *
bd6f5206 31 * @ingroup pwglf_forward_corr
32 * @ingroup pwglf_forward_scripts_makers
269cc80d 33 */
34void MakeMCCorr(const char* esddir = ".",
35 Int_t nEvents = -1,
36 Double_t vzMin = -10,
37 Double_t vzMax = +10,
38 Int_t proof = 0,
39 const char* name = 0)
40{
41 if ((name && name[0] != '\0') && gSystem->Load("libRAliEn") >= 0) {
269cc80d 42
bd6f5206 43 gROOT->LoadMacro("$ALICE_ROOT/PWGLF/FORWARD/analysis2/trains/TrainSetup.C+");
44 gROOT->LoadMacro("$ALICE_ROOT/PWGLF/FORWARD/analysis2/trains/MakeMCCorrTrain.C+");
56236b95 45
bcd522ff 46 MakeMCCorrTrain t(name);
269cc80d 47 t.SetDataDir(esddir);
48 t.SetDataSet("");
49 t.SetAllowOverwrite(true);
50 t.SetProofServer(Form("workers=%d",proof));
51 t.Run(proof > 0 ? "PROOF" : "LOCAL", "FULL", nEvents, proof > 0);
52 return;
53 }
54 // --- Libraries to load -------------------------------------------
bd6f5206 55 gROOT->Macro("$ALICE_ROOT/PWGLF/FORWARD/analysis2/scripts/LoadLibs.C");
269cc80d 56
57 // --- Check for proof mode, and possibly upload pars --------------
58 if (proof> 0) {
bd6f5206 59 gROOT->LoadMacro("$ALICE_ROOT/PWGLF/FORWARD/analysis2/scripts/LoadPars.C");
269cc80d 60 LoadPars(proof);
61 }
62
63 // --- Our data chain ----------------------------------------------
bd6f5206 64 gROOT->LoadMacro("$ALICE_ROOT/PWGLF/FORWARD/analysis2/scripts/MakeChain.C");
269cc80d 65 TChain* chain = MakeChain("ESD", esddir,true);
66 // If 0 or less events is select, choose all
67 if (nEvents <= 0) nEvents = chain->GetEntries();
68
69 // --- Set the macro path ------------------------------------------
bd6f5206 70 gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWGLF/FORWARD/analysis2:"
269cc80d 71 "$ALICE_ROOT/ANALYSIS/macros",
72 gROOT->GetMacroPath()));
73
74 // --- Creating the manager and handlers ---------------------------
75 AliAnalysisManager *mgr = new AliAnalysisManager(name, "Forward MC corr");
76 AliAnalysisManager::SetCommonFileName("forward_mccorr.root");
77
78 // --- ESD input handler -------------------------------------------
79 AliESDInputHandler *esdHandler = new AliESDInputHandler();
80 mgr->SetInputEventHandler(esdHandler);
81
82 // --- Monte Carlo handler -----------------------------------------
83 AliMCEventHandler* mcHandler = new AliMCEventHandler();
84 mgr->SetMCtruthEventHandler(mcHandler);
85 mcHandler->SetReadTR(true);
86
87 // --- Add Physics Selection ---------------------------------------
88 // Physics selection
89 gROOT->LoadMacro("AddTaskPhysicsSelection.C");
90 AddTaskPhysicsSelection(kTRUE, kTRUE, kFALSE);
91 // --- Fix up physics selection to give proper A,C, and E triggers -
92 AliInputEventHandler* ih =
93 static_cast<AliInputEventHandler*>(mgr->GetInputEventHandler());
94 AliPhysicsSelection* ps =
95 static_cast<AliPhysicsSelection*>(ih->GetEventSelection());
96 // Ignore trigger class when selecting events. This mean that we
97 // get offline+(A,C,E) events too
98 // ps->SetSkipTriggerClassSelection(true);
99
100 // --- Add our task ------------------------------------------------
101 gROOT->LoadMacro("AddTaskForwardMCCorr.C");
102 AddTaskForwardMCCorr();
103
104 gROOT->LoadMacro("AddTaskCentralMCCorr.C");
105 AddTaskCentralMCCorr();
106
107 // --- Run the analysis --------------------------------------------
108 TStopwatch t;
109 if (!mgr->InitAnalysis()) {
110 Error("MakedNdeta", "Failed to initialize analysis train!");
111 return;
112 }
113 // Skip terminate if we're so requested and not in Proof or full mode
114 mgr->SetSkipTerminate(false);
115 // Some informative output
116 mgr->PrintStatus();
117 // mgr->SetDebugLevel(3);
118 if (mgr->GetDebugLevel() < 1 && !proof)
119 mgr->SetUseProgressBar(kTRUE,100);
120
121 // Run the train
122 t.Start();
123 Printf("=== RUNNING ANALYSIS ==================================");
124 mgr->StartAnalysis(proof ? "proof" : "local", chain, nEvents);
125 t.Stop();
126 t.Print();
127}
128//
129// EOF
130//