]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis2/scripts/ExtractSecMap.C
cf764e90e6fe1b5468239c683f42f0d17b646704
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / scripts / ExtractSecMap.C
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 "AliFMDCorrSecondaryMap.h"
11 #include "AliCentralCorrSecondaryMap.h"
12 #include "AliForwardCorrectionManager.h"
13 #endif 
14
15 //____________________________________________________________________
16 /** 
17  * Extract the energy loss correction object from file and rename it 
18  * according to the settings 
19  * 
20  * @param fname  File to extract from 
21  * @param sys    Collision system (pp, PbPb)
22  * @param sNN    Center of mass energy (in GeV) per nucleon
23  * @param field  L3 magnetic field (-5,0,5) in kGaus
24  * 
25  * @ingroup pwg2_forward_analysis_scripts
26  */
27 void
28 ExtractSecMap(const char* fname,
29              UShort_t sys=1, UShort_t sNN=900, Short_t field=5)
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("ExtractSecMap", "Couldn't open %s", fname);
38     return;
39   }
40
41   ExtractFMDSecMap(file, sys, sNN, field);
42   ExtractSPDSecMap(file, sys, sNN, field);
43 }
44
45 //____________________________________________________________________
46 /** 
47  * Extract and copy FMD secondary map to file 
48  * 
49  * @param file  Input file
50  * @param sys   Collision system (1:pp, 2:PbPb)
51  * @param sNN   Center of mass energy (GeV) per nucleon
52  * @param field L3 magnetic field
53  *
54  * @ingroup pwg2_forward_analysis_scripts
55  */
56 void     
57 ExtractFMDSecMap(TFile* file, UShort_t sys, UShort_t sNN, Short_t field)
58 {
59   TList* forward = static_cast<TList*>(file->Get("ForwardResults"));
60   // static_cast<TList*>(file->Get("PWG2forwardDnDeta/Forward"));
61   if (!forward) { 
62     Error("ExtractSecMap", "Couldn't get forward list from %s", fname);
63     return;
64   }
65   
66   TString n(AliFMDCorrSecondaryMap::Class()->GetName());
67   TObject* fmdCorr = forward->FindObject(n);
68   if (!fmdCorr) { 
69     Error("ExtractSecMap", "Couldn't get forward correction object %s", 
70           n.Data());
71     return;
72   }
73
74   AliForwardCorrectionManager& mgr = AliForwardCorrectionManager::Instance();
75   mgr.WriteFile(AliForwardCorrectionManager::kSecondaryMap, 
76                 sys, sNN, field, false, fmdCorr, false);
77 }
78
79 //____________________________________________________________________
80 /** 
81  * Extract and copy SPD secondary map to file 
82  * 
83  * @param file  Input file
84  * @param sys   Collision system (1:pp, 2:PbPb)
85  * @param sNN   Center of mass energy (GeV) per nucleon
86  * @param field L3 magnetic field
87  *
88  * @ingroup pwg2_forward_analysis_scripts
89  */
90 void     
91 ExtractSPDSecMap(TFile* file, UShort_t sys, UShort_t sNN, Short_t field)
92 {
93   TList* central = static_cast<TList*>(file->Get("CentralResults"));
94   // static_cast<TList*>(file->Get("PWG2centralDnDeta/Central"));
95   if (!central) { 
96     Error("ExtractSecMap", "Couldn't get central list from %s", fname);
97     return;
98   }
99   
100   TString n(AliCentralCorrSecondaryMap::Class()->GetName());
101   TObject* spdCorr  = central->FindObject(n);
102   if (!spdCorr) { 
103     Error("ExtractSecMap", "Couldn't get central correction object %s", 
104           n.Data());
105     return;
106   }
107
108
109   AliCentralMultiplicityTask::Manager* mgr = new 
110     AliCentralMultiplicityTask::Manager;
111   // mgr->Dump();
112   mgr->Print();
113   mgr->WriteFile(0, sys, sNN, field, spdCorr, false);
114 }
115     
116   
117 //____________________________________________________________________
118 /** 
119  * Extract the energy loss correction object from file and rename it 
120  * according to the settings 
121  * 
122  * @param fname  File to extract from 
123  * @param sys    Collision system (pp, PbPb)
124  * @param sNN    Center of mass energy (in GeV) per nucleon
125  * @param field  L3 magnetic field (-5,0,5) in kGaus
126  * @param mc     Whether this is from MC data or not 
127  * 
128  * @ingroup pwg2_forward_analysis_scripts
129  */
130 void
131 ExtractSecMap(const char* fname="forward_mccorr.root", 
132               const char* sys="p-p", 
133               Float_t     sNN=900, 
134               Float_t     field=5)
135 {
136   gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadLibs.C");
137
138   UShort_t uSys   = AliForwardUtil::ParseCollisionSystem(sys);
139   UShort_t usNN   = AliForwardUtil::ParseCenterOfMassEnergy(uSys,sNN);
140   Short_t  sField = AliForwardUtil::ParseMagneticField(field);
141
142   ExtractSecMap(fname, uSys, usNN, sField);
143 }
144
145 //____________________________________________________________________
146 //
147 // EOF
148 //