]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis2/MakeELossFits.C
removing the setting of AOD track references for TPC only tracks
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / MakeELossFits.C
1 /**
2  * @file 
3  * 
4  * @ingroup pwg2_forward_scripts
5  */
6 /** 
7  * Run a pass on ESD data to produce the energ loss fits 
8  * 
9  *
10  * @ingroup pwg2_forward_scripts
11  */
12 void MakeELossFits(const char* esddir, 
13                    Int_t       nEvents=1000, 
14                    Int_t       proof=0,
15                    Bool_t      mc=false)
16 {
17   // --- Libraries to load -------------------------------------------
18   gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadLibs.C");
19
20   // --- Check for proof mode, and possibly upload pars --------------
21   if (proof > 0) {
22     gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadPars.C");
23     LoadPars(proof);
24   }
25   
26   // --- Our data chain ----------------------------------------------
27   gROOT->LoadMacro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/MakeESDChain.C");
28   TChain* chain = MakeESDChain(esddir, true);
29   // If 0 or less events is select, choose all 
30   if (nEvents <= 0) nEvents = chain->GetEntries();
31   Info("MakeELossFits", "Will analyse %d events", nEvents);
32
33   // --- Creating the manager and handlers ---------------------------
34   AliAnalysisManager *mgr  = new AliAnalysisManager("Analysis Train", 
35                                                     "FMD analysis train");
36
37   AliESDInputHandler *esdHandler = new AliESDInputHandler();
38   esdHandler->SetInactiveBranches("AliESDACORDE "
39                                   "AliRawDataErrorLogs "
40                                   "CaloClusters "
41                                   "Cascades "
42                                   "EMCALCells "
43                                   "EMCALTrigger "
44                                   "Kinks "
45                                   "Cascades "
46                                   "MuonTracks "
47                                   "TrdTracks "
48                                   "CaloClusters "
49                                   "HLTGlobalTrigger");
50   mgr->SetInputEventHandler(esdHandler);      
51   
52   // AOD output handler
53   AliAODHandler* aodHandler   = new AliAODHandler();
54   mgr->SetOutputEventHandler(aodHandler);
55   aodHandler->SetOutputFileName("AliAODs.root");
56
57   // --- Add tasks ---------------------------------------------------
58   gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
59   AddTaskPhysicsSelection(mc, kTRUE, kTRUE);
60   AliFMDEnergyFitterTask* task = new AliFMDEnergyFitterTask("fmdEnergyFitter");
61   mgr->AddTask(task);
62
63   // --- Make the output container and connect it --------------------
64   TString outputfile = "energyFits.root";
65   AliAnalysisDataContainer* histOut = 
66     mgr->CreateContainer("Forward", TList::Class(), 
67                          AliAnalysisManager::kOutputContainer,outputfile);
68   mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
69   mgr->ConnectOutput(task, 1, histOut);
70
71   // --- Set parameters on the algorithms ----------------------------
72   // Set the number of SPD tracklets for which we consider the event a
73   // low flux event
74   task->GetEventInspector().SetLowFluxCut(1000); 
75   // Set the maximum error on v_z [cm]
76   task->GetEventInspector().SetMaxVzErr(0.2);
77   // Set the eta axis to use - note, this overrides whatever is used
78   // by the rest of the algorithms - but only for the energy fitter
79   // algorithm. 
80   task->GetEnergyFitter().SetEtaAxis(200, -4, 6);
81   // Set maximum energy loss to consider 
82   task->GetEnergyFitter().SetMaxE(15); 
83   // Set number of energy loss bins 
84   task->GetEnergyFitter().SetNEbins(100);
85   // Set whether to use increasing bin sizes 
86   task->GetEnergyFitter().SetUseIncreasingBins(true);
87   // Set whether to do fit the energy distributions 
88   task->GetEnergyFitter().SetDoFits(kTRUE);
89   // Set whether to make the correction object 
90   task->GetEnergyFitter().SetDoMakeObject(kTRUE);
91   // Set the low cut used for energy
92   task->GetEnergyFitter().SetLowCut(0.4);
93   // Set the number of bins to subtract from maximum of distributions
94   // to get the lower bound of the fit range
95   task->GetEnergyFitter().SetFitRangeBinWidth(4);
96   // Set the maximum number of landaus to try to fit (max 5)
97   task->GetEnergyFitter().SetNParticles(5);
98   // Set the minimum number of entries in the distribution before
99   // trying to fit to the data
100   task->GetEnergyFitter().SetMinEntries(1000);
101   // --- Set limits on fits the energy -------------------------------
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   = 5;
108   
109   // --- Run the analysis --------------------------------------------
110   TStopwatch t;
111   if (!mgr->InitAnalysis()) {
112     Error("RunManager", "Failed to initialize analysis train!");
113     return;
114   }
115   // Some informative output 
116   mgr->PrintStatus();
117   // mgr->SetDebugLevel(3);
118   if (mgr->GetDebugLevel() < 1 && proof <= 0) mgr->SetUseProgressBar(kTRUE);
119
120   // Run the train 
121   t.Start();
122   Printf("=== RUNNING ANALYSIS ==================================");
123   mgr->StartAnalysis(proof > 0 ? "proof" : "local", chain, nEvents);
124   t.Stop();
125   t.Print();
126 }
127 //
128 // EOF
129 //