]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/FORWARD/analysis2/AddTaskFMDELoss.C
Merge branch 'master' into TPCdev
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / AddTaskFMDELoss.C
1 /**
2  * @file   AddTaskFMDELoss.C
3  * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
4  * @date   Wed Mar 23 12:14:03 2011
5  * 
6  * @brief  
7  * 
8  * 
9  * @ingroup pwglf_forward_scripts_tasks
10  */
11 /**
12  * @defgroup pwglf_forward_eloss Energy Loss Fits
13  *
14  * Fitting the energy loss @f$\Delta/\Delta_{mip}@f$ spectra 
15  *
16  * @ingroup pwglf_forward_topical
17  */
18
19 /**
20  * This is the macro to include the FMD energy fitter in a train.  
21  * 
22  * @param mc        Assume MC input 
23  * @param useCent   Use centrality information 
24  * @param onlyMB    Only collect statistics for MB (INEL) events
25  * @param debug     Debug level
26  * @param residuals If set, also do residuals 
27  *
28  * @return Newly created task 
29  *
30  * @ingroup pwglf_forward_eloss
31  */
32 AliAnalysisTask*
33 AddTaskFMDELoss(Bool_t        mc, 
34                 Bool_t        useCent,
35                 Bool_t        onlyMB=false, 
36                 Int_t         debug=0,
37                 const Char_t* residuals="")
38 {
39   // --- Load libraries ----------------------------------------------
40   gROOT->LoadClass("AliAODForwardMult", "libPWGLFforward2");
41
42   // --- Get analysis manager ----------------------------------------
43   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
44   if (!mgr) {
45     Error("AddTaskFMDELoss", "No analysis manager to connect to.");
46     return NULL;
47   }   
48   
49   // --- Make the task and add it to the manager ---------------------
50   AliFMDEnergyFitterTask* task = new AliFMDEnergyFitterTask("ForwardELoss");
51   // --- Set parameters on the algorithms ----------------------------
52   // Set the number of SPD tracklets for which we consider the event a
53   // low flux event
54   task->GetEventInspector().SetLowFluxCut(1000); 
55   // Set the maximum error on v_z [cm]
56   task->GetEventInspector().SetMaxVzErr(0.2);
57   // Set the eta axis to use - note, this overrides whatever is used
58   // by the rest of the algorithms - but only for the energy fitter
59   // algorithm. 
60   task->GetEnergyFitter().SetEtaAxis(200, -4, 6);
61   // Set maximum energy loss to consider 
62   task->GetEnergyFitter().SetMaxE(15); 
63   // Set number of energy loss bins 
64   task->GetEnergyFitter().SetNEbins(500);
65   // Set whether to use increasing bin sizes 
66   task->GetEnergyFitter().SetUseIncreasingBins(true);
67   // Set whether to do fit the energy distributions 
68   task->GetEnergyFitter().SetDoFits(kTRUE);
69   // Set whether to make the correction object 
70   task->GetEnergyFitter().SetDoMakeObject(kTRUE);
71   // Set the low cut used for energy
72   task->GetEnergyFitter().SetLowCut(0.4);
73   // Set the number of bins to subtract from maximum of distributions
74   // to get the lower bound of the fit range
75   task->GetEnergyFitter().SetFitRangeBinWidth(4);
76   // Set the maximum number of landaus to try to fit (max 5)
77   task->GetEnergyFitter().SetNParticles(5);
78   // Set the minimum number of entries in the distribution before
79   // trying to fit to the data - 10K seems the absolute minimum
80   task->GetEnergyFitter().SetMinEntries(10000);
81   // If set, only collect statistics for MB.  This is to prevent a
82   // bias when looping over data where the MB trigger is downscaled.
83   task->SetOnlyMB(onlyMB);
84   // Debug
85   task->SetDebug(debug);
86
87   TString resi(residuals);
88   resi.ToUpper();
89   AliFMDEnergyFitter::EResidualMethod rm = AliFMDEnergyFitter::kNoResiduals;
90   if (!resi.IsNull() && !resi.BeginsWith("no")) {
91     if (resi.BeginsWith("square")) 
92       rm = AliFMDEnergyFitter::kResidualSquareDifference;
93     else if (resi.BeginsWith("scale")) 
94       rm = AliFMDEnergyFitter::kResidualScaledDifference;
95     else // Anything else gives plain difference and errors in errors
96       rm = AliFMDEnergyFitter::kResidualDifference;
97   }
98   task->GetEnergyFitter().SetStoreResiduals(rm);
99
100   // --- Set limits on fits the energy -------------------------------
101   // DO NOT CHANGE THESE UNLESS YOU KNOW WHAT YOU ARE DOING
102   // Maximum relative error on parameters 
103   // AliFMDCorrELossFit::ELossFit::fgMaxRelError = .12;
104   // Least weight to use 
105   // AliFMDCorrELossFit::ELossFit::fgLeastWeight = 1e-5;
106   // Maximum value of reduced chi^2 
107   // AliFMDCorrELossFit::ELossFit::fgMaxChi2nu   = 20;
108   
109   // --- Make the output container and connect it --------------------
110   task->Connect(0,0);
111
112   Printf("Returning task %p", task);
113   return task;
114 }
115 //
116 // EOF
117 //