]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis2/corrs/RunCopyVtxBias.C
388f0eef332823bbb91a995bde518b7775192c8e
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / corrs / RunCopyVtxBias.C
1 /** 
2  * 
3  * 
4  * @param d 
5  * @param r 
6  * 
7  * @return 
8  * 
9  * @ingroup pwg2_forward_analysis_scripts_corr
10  */
11 Color_t Color(UShort_t d, Char_t r ) const 
12
13   return ((d == 1 ? kRed : (d == 2 ? kGreen : kBlue))
14           + ((r == 'I' || r == 'i') ? 2 : -2));
15 }
16 /** 
17  * 
18  * 
19  * @param sys 
20  * @param cms 
21  * @param field 
22  * @param path 
23  * 
24  * @ingroup pwg2_forward_analysis_scripts_corr
25  */
26 void
27 RunCopyVtxBias(UShort_t sys, UShort_t cms, Short_t field, const char* path=0)
28 {
29   RunCopyVtxBias(sys == 1 ? "pp" : "PbPb", cms, field, path);
30 }
31
32 /** 
33  * 
34  * @param sys       Collision system 
35  * @param cms       Center of mass energy per nucleon in GeV
36  * @param field     Magnetic field 
37  * @param path      File path
38  * 
39  * 
40  * @ingroup pwg2_forward_analysis_scripts_corr
41  */
42 void
43 RunCopyVtxBias(const char* sys, UShort_t cms, Short_t field, const char* path=0)
44 {
45   gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadLibs.C");
46   gSystem->Load("libPWG2forward.so");
47
48   AliFMDAnaParameters* p = AliFMDAnaParameters::Instance();
49   p->SetEnergy(Float_t(cms));
50   p->SetMagField(Float_t(field));
51   p->SetCollisionSystem(sys);
52   if (path) {
53     p->SetBackgroundPath(path);
54     p->SetEnergyPath(path);
55     p->SetEventSelectionPath(path);
56     p->SetSharingEfficiencyPath(path);
57   }
58   p->Init(true, AliFMDAnaParameters::kBackgroundCorrection|
59           AliFMDAnaParameters::kEventSelectionEfficiency);
60  
61   Int_t    nVtx   = p->GetNvtxBins();
62   Double_t minVtx = -p->GetVtxCutZ();
63   Double_t maxVtx = -p->GetVtxCutZ();
64   Int_t    nEta   = p->GetNetaBins();
65   Double_t minEta = p->GetEtaMin();
66   Double_t maxEta = p->GetEtaMax();
67
68   TAxis vtxAxis(nVtx, minVtx, maxVtx);
69   AliFMDCorrVertexBias* obj = new AliFMDCorrVertexBias;
70   obj->SetVertexAxis(vtxAxis);
71
72   for (UShort_t b = 1; b <= nVtx; b++) { 
73     for (UShort_t q = 0; q < 2; q++) { 
74       Char_t r = q == 0 ? 'I' : 'O';
75
76       TH2F* oldcorr = p->GetEventSelectionEfficiency("INEL",b-1,r);
77       if (!oldcorr) {
78         Warning("RunCopyVtxBias",
79                 "Didn't find secondary map correction "
80                 "for ring type %c, vertex bin %3d", r, b);
81         continue;
82       }
83    
84       TH2D* newcorr = new TH2D(Form("FMDX%c", r), 
85                                Form("Vertex bias correction for %c rings "
86                                     "in vertex bin %d [%+8.4f,%+8.4f]", 
87                                     r, b, vtxAxis.GetBinLowEdge(b), 
88                                     vtxAxis.GetBinUpEdge(b)), 
89                                nEta, minEta, maxEta, 
90                                oldcorr->GetYaxis()->GetNbins(), 
91                                oldcorr->GetYaxis()->GetXmin(), 
92                                oldcorr->GetYaxis()->GetXmax());
93       newcorr->SetXTitle("#eta");
94       newcorr->SetYTitle("#phi [radians]");
95       newcorr->SetZTitle("1/N_{t}#sum_{i}^{N_{tv}} N_{ch,i,primary} / "
96                          "1/N_{v}#sum_{i}^{N_{v}} N_{ch,i,primary}");
97       newcorr->SetDirectory(0);
98       newcorr->SetStats(0);
99       newcorr->Sumw2();
100       newcorr->Add(oldcorr);
101
102       Info("RunCopyVtxBias",
103            "Copying %s to %s", oldcorr->GetName(), newcorr->GetName());
104
105       obj->SetCorrection(r, b, newcorr);
106     }
107   }
108   UShort_t isys = AliForwardUtil::ParseCollisionSystem(sys);
109   AliForwardCorrectionManager& mgr = AliForwardCorrectionManager::Instance();
110   TString fname(mgr.GetFileName(AliForwardCorrectionManager::kVertexBias,
111                                 isys, cms, field, false));
112   TFile* output = TFile::Open(fname.Data(), "RECREATE");
113   if (!output) { 
114     Warning("Run", "Failed to open output file %s", fname.Data());
115     return kFALSE;
116   }
117   obj->Write(mgr.GetObjectName(AliForwardCorrectionManager::kVertexBias));
118   output->Write();
119   output->Close();
120   Info("Run", "File %s created.  It should be copied to %s and stored in SVN",
121        fname.Data(),mgr.GetFileDir(AliForwardCorrectionManager::kVertexBias));
122
123 }
124 //
125 // EOF
126 //