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