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