2 * @file MakeELossFits.C
3 * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
4 * @date Wed Mar 23 14:08:14 2011
9 * @ingroup pwg2_forward_eloss
12 * Run a pass on ESD data to produce the energ loss fits
15 * @ingroup pwg2_forward_eloss
17 void MakeELossFits(const char* esddir,
23 // --- Libraries to load -------------------------------------------
24 gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadLibs.C");
26 // --- Check for proof mode, and possibly upload pars --------------
28 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadPars.C");
32 // --- Our data chain ----------------------------------------------
33 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/MakeChain.C");
34 TChain* chain = MakeChain("ESD",esddir, true);
35 // If 0 or less events is select, choose all
36 if (nEvents <= 0) nEvents = chain->GetEntries();
37 Info("MakeELossFits", "Will analyse %d events", nEvents);
39 // --- Set the macro path ------------------------------------------
40 gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWG2/FORWARD/analysis2:"
41 "$ALICE_ROOT/ANALYSIS/macros",
42 gROOT->GetMacroPath()));
44 // --- Creating the manager and handlers ---------------------------
45 AliAnalysisManager *mgr = new AliAnalysisManager("Forward ELoss Train",
46 "Forward energy loss");
47 AliAnalysisManager::SetCommonFileName("forward_eloss.root");
49 AliESDInputHandler *esdHandler = new AliESDInputHandler();
50 esdHandler->SetInactiveBranches("AliESDACORDE "
51 "AliRawDataErrorLogs "
62 mgr->SetInputEventHandler(esdHandler);
65 AliAODHandler* aodHandler = new AliAODHandler();
66 mgr->SetOutputEventHandler(aodHandler);
67 aodHandler->SetOutputFileName("AliAODs.root");
69 // --- Add tasks ---------------------------------------------------
70 gROOT->LoadMacro("AddTaskPhysicsSelection.C");
71 AddTaskPhysicsSelection(mc, kTRUE, kFALSE);
73 gROOT->LoadMacro("AddTaskCentrality.C");
76 AliFMDEnergyFitterTask* task = new AliFMDEnergyFitterTask("fmdEnergyFitter");
79 // --- Make the output container and connect it --------------------
80 TString outputfile = AliAnalysisManager::GetCommonFileName();
81 AliAnalysisDataContainer* histOut =
82 mgr->CreateContainer("Forward", TList::Class(),
83 AliAnalysisManager::kOutputContainer,outputfile);
84 mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
85 mgr->ConnectOutput(task, 1, histOut);
87 // --- Set parameters on the algorithms ----------------------------
88 // Set the number of SPD tracklets for which we consider the event a
90 task->GetEventInspector().SetLowFluxCut(1000);
91 // Set the maximum error on v_z [cm]
92 task->GetEventInspector().SetMaxVzErr(0.2);
93 // Set the eta axis to use - note, this overrides whatever is used
94 // by the rest of the algorithms - but only for the energy fitter
96 task->GetEnergyFitter().SetEtaAxis(200, -4, 6);
97 // Set maximum energy loss to consider
98 task->GetEnergyFitter().SetMaxE(15);
99 // Set number of energy loss bins
100 task->GetEnergyFitter().SetNEbins(100);
101 // Set whether to use increasing bin sizes
102 task->GetEnergyFitter().SetUseIncreasingBins(true);
103 // Set whether to do fit the energy distributions
104 task->GetEnergyFitter().SetDoFits(kTRUE);
105 // Set whether to make the correction object
106 task->GetEnergyFitter().SetDoMakeObject(kTRUE);
107 // Set the low cut used for energy
108 task->GetEnergyFitter().SetLowCut(0.4);
109 // Set the number of bins to subtract from maximum of distributions
110 // to get the lower bound of the fit range
111 task->GetEnergyFitter().SetFitRangeBinWidth(4);
112 // Set the maximum number of landaus to try to fit (max 5)
113 task->GetEnergyFitter().SetNParticles(5);
114 // Set the minimum number of entries in the distribution before
115 // trying to fit to the data
116 task->GetEnergyFitter().SetMinEntries(1000);
117 // --- Set limits on fits the energy -------------------------------
118 // Maximum relative error on parameters
119 AliFMDCorrELossFit::ELossFit::fgMaxRelError = .12;
120 // Least weight to use
121 AliFMDCorrELossFit::ELossFit::fgLeastWeight = 1e-5;
122 // Maximum value of reduced chi^2
123 AliFMDCorrELossFit::ELossFit::fgMaxChi2nu = 10;
125 // --- Run the analysis --------------------------------------------
127 if (!mgr->InitAnalysis()) {
128 Error("RunManager", "Failed to initialize analysis train!");
131 // Some informative output
133 // mgr->SetDebugLevel(3);
134 if (mgr->GetDebugLevel() < 1 && proof <= 0) mgr->SetUseProgressBar(kTRUE);
138 Printf("=== RUNNING ANALYSIS ==================================");
139 mgr->StartAnalysis(proof > 0 ? "proof" : "local", chain, nEvents);