]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis2/MakeELossFits.C
f721a4c50adfeee0b9bcfb2eb3449cefd927d89e
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / MakeELossFits.C
1 /**
2  * @file   MakeELossFits.C
3  * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk>
4  * @date   Wed Mar 23 14:08:14 2011
5  * 
6  * @brief  
7  * 
8  * 
9  * @ingroup pwg2_forward_eloss
10  */
11 /** 
12  * Run a pass on ESD data to produce the energ loss fits 
13  * 
14  *
15  * @ingroup pwg2_forward_eloss
16  */
17 void MakeELossFits(const char* esddir, 
18                    Int_t       nEvents=1000, 
19                    Int_t       proof=0,
20                    Bool_t      mc=false,
21                    Bool_t      cent=false)
22 {
23   // --- Libraries to load -------------------------------------------
24   gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadLibs.C");
25
26   // --- Check for proof mode, and possibly upload pars --------------
27   if (proof > 0) {
28     gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadPars.C");
29     LoadPars(proof);
30   }
31   
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);
38
39   // --- Set the macro path ------------------------------------------
40   gROOT->SetMacroPath(Form("%s:$(ALICE_ROOT)/PWG2/FORWARD/analysis2:"
41                            "$ALICE_ROOT/ANALYSIS/macros",
42                            gROOT->GetMacroPath()));
43
44   // --- Creating the manager and handlers ---------------------------
45   AliAnalysisManager *mgr  = new AliAnalysisManager("Forward ELoss Train", 
46                                                     "Forward energy loss");
47   AliAnalysisManager::SetCommonFileName("forward_eloss.root");
48
49   AliESDInputHandler *esdHandler = new AliESDInputHandler();
50   esdHandler->SetInactiveBranches("AliESDACORDE "
51                                   "AliRawDataErrorLogs "
52                                   "CaloClusters "
53                                   "Cascades "
54                                   "EMCALCells "
55                                   "EMCALTrigger "
56                                   "Kinks "
57                                   "Cascades "
58                                   "MuonTracks "
59                                   "TrdTracks "
60                                   "CaloClusters "
61                                   "HLTGlobalTrigger");
62   mgr->SetInputEventHandler(esdHandler);      
63   
64   // AOD output handler
65   AliAODHandler* aodHandler   = new AliAODHandler();
66   mgr->SetOutputEventHandler(aodHandler);
67   aodHandler->SetOutputFileName("AliAODs.root");
68
69   // --- Add tasks ---------------------------------------------------
70   gROOT->LoadMacro("AddTaskPhysicsSelection.C");
71   AddTaskPhysicsSelection(mc, kTRUE, kFALSE);
72   
73   gROOT->LoadMacro("AddTaskCentrality.C");
74   AddTaskCentrality();
75   
76   AliFMDEnergyFitterTask* task = new AliFMDEnergyFitterTask("fmdEnergyFitter");
77   mgr->AddTask(task);
78   
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);
86
87   // --- Set parameters on the algorithms ----------------------------
88   // Set the number of SPD tracklets for which we consider the event a
89   // low flux event
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
95   // algorithm. 
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;
124   
125   // --- Run the analysis --------------------------------------------
126   TStopwatch t;
127   if (!mgr->InitAnalysis()) {
128     Error("RunManager", "Failed to initialize analysis train!");
129     return;
130   }
131   // Some informative output 
132   mgr->PrintStatus();
133   // mgr->SetDebugLevel(3);
134   if (mgr->GetDebugLevel() < 1 && proof <= 0) mgr->SetUseProgressBar(kTRUE);
135
136   // Run the train 
137   t.Start();
138   Printf("=== RUNNING ANALYSIS ==================================");
139   mgr->StartAnalysis(proof > 0 ? "proof" : "local", chain, nEvents);
140   t.Stop();
141   t.Print();
142 }
143 //
144 // EOF
145 //