Renames and new scripts
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / scripts / ExtractELoss.C
CommitLineData
ab0f914c 1/**
2 * Script to draw the energy loss fits
3 *
4 * @ingroup pwg2_forward_analysis_scripts
5 */
6#ifndef __CINT__
7#include <TFile.h>
8#include <TList.h>
9#include <TError.h>
10#include "AliFMDCorrELossFit.h"
11#include "AliForwardCorrectionManager.h"
12#endif
13
14//____________________________________________________________________
1c762251 15/**
16 * Extract the energy loss correction object from file and rename it
17 * according to the settings
18 *
19 * @param fname File to extract from
20 * @param sys Collision system (pp, PbPb)
21 * @param sNN Center of mass energy (in GeV) per nucleon
22 * @param field L3 magnetic field (-5,0,5) in kGaus
23 * @param mc Whether this is from MC data or not
24 *
25 * @ingroup pwg2_forward_analysis_scripts
26 */
ab0f914c 27void
0f84fefb 28ExtractELoss(const char* fname="forward_eloss.root",
ab0f914c 29 UShort_t sys=1, UShort_t sNN=900, Short_t field=5, Bool_t mc=false)
30{
31#ifdef __CINT__
32 gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadLibs.C");
33#endif
34
35 TFile* file = TFile::Open(fname, "READ");
36 if (!file) {
37 Error("ExtractELoss", "Couldn't open %s", fname);
38 return;
39 }
40
41 TList* forward = static_cast<TList*>(file->Get("Forward"));
42 // static_cast<TList*>(file->Get("PWG2forwardDnDeta/Forward"));
43 if (!forward) {
44 Error("ExtractELoss", "Couldn't get forward list from %s", fname);
45 return;
46 }
47
48 TList* fitter = static_cast<TList*>(forward->FindObject("fmdEnergyFitter"));
49 if (!fitter) {
50 Error("ExtractELoss", "Couldn't get fitter folder");
51 return;
52 }
53
54 TString cName(AliFMDCorrELossFit::Class()->GetName());
55
56 AliFMDCorrELossFit* obj =
57 static_cast<AliFMDCorrELossFit*>(fitter->FindObject(cName));
58 if (!obj) {
59 Error("ExtractELoss", "Couldn't get %s correction object", cName.Data());
60 return;
61 }
62
63 AliForwardCorrectionManager& mgr = AliForwardCorrectionManager::Instance();
64
65 TString ofName(mgr.GetFileName(AliForwardCorrectionManager::kELossFits,
66 sys, sNN, field, mc));
67 TFile* output = TFile::Open(ofName.Data(), "RECREATE");
68 if (!output) {
69 Error("ExtractELoss", "Failed to open file %s", ofName.Data());
70 return;
71 }
72
73 TString oName(mgr.GetObjectName(AliForwardCorrectionManager::kELossFits));
74 obj->Write(oName);
75
76 output->Write();
77 output->ls();
78 output->Close();
79
80 TString dName(mgr.GetFileDir(AliForwardCorrectionManager::kELossFits));
81 Info("ExtractELoss", "Wrote %s object %s to %s",cName.Data(),oName.Data(),
82 ofName.Data());
83 Info("ExtractELoss", "%s should be copied to %s",ofName.Data(),dName.Data());
84 Info("ExtractELoss", "Do for example\n\t"
85 "aliroot $ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/MoveCorrections.C\(0,0,0,0,1\)\n\t"
86 "cp %s %s/", ofName.Data(), gSystem->ExpandPathName(dName.Data()));
87}
88
89
90
91//____________________________________________________________________
1c762251 92/**
93 * Extract the energy loss correction object from file and rename it
94 * according to the settings
95 *
96 * @param fname File to extract from
97 * @param sys Collision system (pp, PbPb)
98 * @param sNN Center of mass energy (in GeV) per nucleon
99 * @param field L3 magnetic field (-5,0,5) in kGaus
100 * @param mc Whether this is from MC data or not
101 *
102 * @ingroup pwg2_forward_analysis_scripts
103 */
ab0f914c 104void
105ExtractELoss(const char* fname="energyFits.root",
106 const char* sys="p-p",
107 Float_t sNN=900,
1c762251 108 Float_t field=5,
109 Bool_t mc=false)
ab0f914c 110{
111 UShort_t uSys = AliForwardUtil::ParseCollisionSystem(sys);
112 UShort_t usNN = AliForwardUtil::ParseCenterOfMassEnergy(uSys,sNN);
113 Short_t sField = AliForwardUtil::ParseMagneticField(field);
114
1c762251 115 ExtractELoss(fname, uSys, usNN, sField, mc);
ab0f914c 116}
117
118//____________________________________________________________________
119//
120// EOF
121//