]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/FORWARD/analysis2/corrs/ExtractMCCorr.C
Mega commit of many changes to PWGLFforward
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / corrs / ExtractMCCorr.C
1 /**
2  * Script to draw the energy loss fits 
3  * 
4  * @ingroup pwglf_forward_scripts_corr
5  */
6   
7 //____________________________________________________________________
8 /** 
9  * Extract the energy loss correction object from file and rename it 
10  * according to the settings 
11  * 
12  * @param fname  File to extract from 
13  * @param sys    Collision system (pp, PbPb)
14  * @param sNN    Center of mass energy (in GeV) per nucleon
15  * @param field  L3 magnetic field (-5,0,5) in kGaus
16  * 
17  * @ingroup pwglf_forward_scripts_corr
18  */
19 void
20 ExtractMCCorr(const char* fname)
21 {
22   const char* fwd = "$ALICE_ROOT/../trunk/PWGLF/FORWARD/analysis2";
23   gSystem->AddIncludePath(Form("-I%s", fwd));
24   gROOT->Macro(Form("%s/scripts/LoadLibs.C", fwd));
25   gROOT->LoadMacro(Form("%s/corrs/CorrExtractor.C++g", fwd));
26   
27   CorrExtractor fmdEx(&AliForwardCorrectionManager::Instance());
28   if (fmdEx.Init(fname, "ForwardCorrSums", "fmd_corrections.root")) {
29     fmdEx.Extract(AliFMDCorrSecondaryMap::Class(),
30                   "ForwardCorrResults");
31   }
32
33   CorrExtractor spdEx(&AliCentralCorrectionManager::Instance());
34   if (spdEx.Init(fname, "CentralCorrSums", "spd_corrections.root")) {
35     spdEx.Extract(AliCentralCorrSecondaryMap::Class(), "CentralCorrResults");
36     spdEx.Extract(AliCentralCorrAcceptance::Class(), "CentralCorrResults");
37   }
38
39   std::ofstream f("Upload.C");
40   f << "// Generated by ExtractMCCorr.C\n"
41     << "TString MakeDest(const TString& dest, const TString& fname)\n"
42     << "{\n"
43     << "  TString tmp(dest);\n"
44     << "  if (!tmp.IsNull()) {\n"
45     << "    if (!tmp.EndsWith(\"/\")) tmp.Append(\"/\");\n"
46     << "    tmp.Append(fname);\n"
47     << "  }\n"
48     << "  return tmp;\n"
49     << "}\n\n"
50     << "void Upload(const TString& dest=\"\")\n"
51     << "{\n"
52     << "  gROOT->Macro(\"" << fwd << "/scripts/LoadLibs.C\");\n"
53     << "  \n"
54     << "  const char* fmdFile = \"fmd_corrections.root\";\n"
55     << "  const char* spdFile = \"spd_corrections.root\";\n"
56     << "  TString fdest = MakeDest(dest, fmdFile);\n"
57     << "  TString sdest = MakeDest(dest, spdFile);\n"
58     << "  \n"
59     << "  AliForwardCorrectionManager::Instance().Append(fmdFile, fdest);\n"
60     << "  AliCentralCorrectionManager::Instance().Append(spdFile, sdest);\n"
61     << "}\n"
62     << "// EOF\n"
63     << std::endl;
64   f.close();
65 }
66
67 //____________________________________________________________________
68 //
69 // EOF
70 //