added AliNormalizationCounter (Francesco)
[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//____________________________________________________________________
15void
16ExtractELoss(const char* fname="energyFits.root",
17 UShort_t sys=1, UShort_t sNN=900, Short_t field=5, Bool_t mc=false)
18{
19#ifdef __CINT__
20 gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadLibs.C");
21#endif
22
23 TFile* file = TFile::Open(fname, "READ");
24 if (!file) {
25 Error("ExtractELoss", "Couldn't open %s", fname);
26 return;
27 }
28
29 TList* forward = static_cast<TList*>(file->Get("Forward"));
30 // static_cast<TList*>(file->Get("PWG2forwardDnDeta/Forward"));
31 if (!forward) {
32 Error("ExtractELoss", "Couldn't get forward list from %s", fname);
33 return;
34 }
35
36 TList* fitter = static_cast<TList*>(forward->FindObject("fmdEnergyFitter"));
37 if (!fitter) {
38 Error("ExtractELoss", "Couldn't get fitter folder");
39 return;
40 }
41
42 TString cName(AliFMDCorrELossFit::Class()->GetName());
43
44 AliFMDCorrELossFit* obj =
45 static_cast<AliFMDCorrELossFit*>(fitter->FindObject(cName));
46 if (!obj) {
47 Error("ExtractELoss", "Couldn't get %s correction object", cName.Data());
48 return;
49 }
50
51 AliForwardCorrectionManager& mgr = AliForwardCorrectionManager::Instance();
52
53 TString ofName(mgr.GetFileName(AliForwardCorrectionManager::kELossFits,
54 sys, sNN, field, mc));
55 TFile* output = TFile::Open(ofName.Data(), "RECREATE");
56 if (!output) {
57 Error("ExtractELoss", "Failed to open file %s", ofName.Data());
58 return;
59 }
60
61 TString oName(mgr.GetObjectName(AliForwardCorrectionManager::kELossFits));
62 obj->Write(oName);
63
64 output->Write();
65 output->ls();
66 output->Close();
67
68 TString dName(mgr.GetFileDir(AliForwardCorrectionManager::kELossFits));
69 Info("ExtractELoss", "Wrote %s object %s to %s",cName.Data(),oName.Data(),
70 ofName.Data());
71 Info("ExtractELoss", "%s should be copied to %s",ofName.Data(),dName.Data());
72 Info("ExtractELoss", "Do for example\n\t"
73 "aliroot $ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/MoveCorrections.C\(0,0,0,0,1\)\n\t"
74 "cp %s %s/", ofName.Data(), gSystem->ExpandPathName(dName.Data()));
75}
76
77
78
79//____________________________________________________________________
80void
81ExtractELoss(const char* fname="energyFits.root",
82 const char* sys="p-p",
83 Float_t sNN=900,
84 Float_t field=5)
85{
86 UShort_t uSys = AliForwardUtil::ParseCollisionSystem(sys);
87 UShort_t usNN = AliForwardUtil::ParseCenterOfMassEnergy(uSys,sNN);
88 Short_t sField = AliForwardUtil::ParseMagneticField(field);
89
90 ExtractELoss(fname, uSys, usNN, sField);
91}
92
93//____________________________________________________________________
94//
95// EOF
96//