]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGLF/FORWARD/analysis2/corrs/ExtractMCCorr.C
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[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 runNo  Run number 
14  * @param sys    Collision system (pp, PbPb)
15  * @param sNN    Center of mass energy (in GeV) per nucleon
16  * @param fld    L3 magnetic field (-5,0,5) in kGaus
17  * @param sat    For satellite interactions 
18  * 
19  * @ingroup pwglf_forward_scripts_corr
20  */
21 void
22 ExtractMCCorr(const char* fname,
23               ULong_t     runNo=0, 
24               UShort_t    sys=0,
25               UShort_t    sNN=0,
26               Short_t     fld=999,
27               Bool_t      sat=false)
28 {
29   const char* fwd = "$ALICE_ROOT/PWGLF/FORWARD/analysis2";
30   gSystem->AddIncludePath(Form("-I%s -I$ALICE_ROOT/include", fwd));
31   gROOT->Macro(Form("%s/scripts/LoadLibs.C", fwd));
32   gROOT->LoadMacro(Form("%s/corrs/CorrExtractor.C++g", fwd));
33   
34   CorrExtractor fmdEx(&AliForwardCorrectionManager::Instance());
35   if (runNo > 0)   fmdEx.fRunNo     = runNo;
36   if (sys   > 0)   fmdEx.fSys       = sys;
37   if (sNN   > 0)   fmdEx.fSNN       = sNN;
38   if (fld   < 999) fmdEx.fField     = fld;
39   if (sat)         fmdEx.fSatellite = sat;
40   if (fmdEx.Init(fname, "ForwardCorrSums", "fmd_corrections.root")) 
41     fmdEx.Extract(AliFMDCorrSecondaryMap::Class(),
42                   "ForwardCorrResults");
43
44   CorrExtractor spdEx(&AliCentralCorrectionManager::Instance());
45   if (runNo > 0)   spdEx.fRunNo     = runNo;
46   if (sys   > 0)   spdEx.fSys       = sys;
47   if (sNN   > 0)   spdEx.fSNN       = sNN;
48   if (fld   < 999) spdEx.fField     = fld;
49   if (sat)         spdEx.fSatellite = sat;
50   if (spdEx.Init(fname, "CentralCorrSums", "spd_corrections.root")) {
51     spdEx.Extract(AliCentralCorrSecondaryMap::Class(), "CentralCorrResults");
52     spdEx.Extract(AliCentralCorrAcceptance::Class(), "CentralCorrResults");
53   }
54
55   std::ofstream f("Upload.C");
56   f << "// Generated by ExtractMCCorr.C\n"
57     << "TString MakeDest(const TString& dest, const TString& fname)\n"
58     << "{\n"
59     << "  TString tmp(dest);\n"
60     << "  if (!tmp.IsNull()) {\n"
61     << "    if (!tmp.EndsWith(\"/\")) tmp.Append(\"/\");\n"
62     << "    tmp.Append(fname);\n"
63     << "  }\n"
64     << "  return tmp;\n"
65     << "}\n\n"
66     << "void Upload(const TString& dest=\"\")\n"
67     << "{\n"
68     << "  gROOT->Macro(\"" << fwd << "/scripts/LoadLibs.C\");\n"
69     << "  \n"
70     << "  const char* fmdFile = \"fmd_corrections.root\";\n"
71     << "  const char* spdFile = \"spd_corrections.root\";\n"
72     << "  TString fdest = MakeDest(dest, fmdFile);\n"
73     << "  TString sdest = MakeDest(dest, spdFile);\n"
74     << "  \n"
75     << "  AliForwardCorrectionManager::Instance().Append(fmdFile, fdest);\n"
76     << "  AliCentralCorrectionManager::Instance().Append(spdFile, sdest);\n"
77     << "}\n"
78     << "// EOF\n"
79     << std::endl;
80   f.close();
81 }
82
83 //____________________________________________________________________
84 //
85 // EOF
86 //