]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/analysis2/corrs/RunCopySecMap.C
Re-organised scripts
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / corrs / RunCopySecMap.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 RunCopySecMap(UShort_t sys, UShort_t cms, Short_t field, const Char_t* path=0)
9 {
10   RunCopySecMap(sys == 1 ? "pp" : "PbPb", 
11                 cms, 
12                 field, 
13                 path);
14 }
15 /** 
16  * 
17  * @param sys       Collision system 
18  * @param cms       Center of mass energy per nucleon in GeV
19  * @param field     Magnetic field 
20  * 
21  * @ingroup pwg2_forward_analysis_scripts
22  */
23 void
24 RunCopySecMap(const char* sys, UShort_t cms, Short_t field,
25               const Char_t* path=0)
26 {
27   gROOT->Macro("$ALICE_ROOT/PWG2/FORWARD/analysis2/scripts/LoadLibs.C");
28   gSystem->Load("libPWG2forward.so");
29
30   AliFMDAnaParameters* p = AliFMDAnaParameters::Instance();
31   p->SetEnergy(Float_t(cms));
32   p->SetMagField(Float_t(field));
33   p->SetCollisionSystem(sys);
34   if (path) {
35     std::cout<<"Setting path to "<<path<<std::endl;
36     p->SetBackgroundPath(path);
37     p->SetEnergyPath(path);
38     p->SetEventSelectionPath(path);
39     p->SetSharingEfficiencyPath(path);
40   }
41   p->Init(true, AliFMDAnaParameters::kBackgroundCorrection);
42  
43   Int_t    nVtx   = p->GetNvtxBins();
44   Double_t minVtx = -p->GetVtxCutZ();
45   Double_t maxVtx = p->GetVtxCutZ();
46   Int_t    nEta   = p->GetNetaBins();
47   Double_t minEta = p->GetEtaMin();
48   Double_t maxEta = p->GetEtaMax();
49
50   TAxis vtxAxis(nVtx, minVtx, maxVtx);
51   AliFMDCorrSecondaryMap* m = new AliFMDCorrSecondaryMap;
52   m->SetVertexAxis(nVtx, minVtx, maxVtx);
53   m->SetEtaAxis(nEta,minEta,maxEta);
54   AliFMDCorrDoubleHit* dh = new AliFMDCorrDoubleHit;
55
56   for (UShort_t d = 1; d <= 3; d++) { 
57     UShort_t nQ = (d == 1 ? 1 : 2);
58     for (UShort_t q = 0; q < nQ; q++) { 
59       Char_t r = (q == 0 ? 'I' : 'O');
60      
61       TH1F* old2hit = p->GetDoubleHitCorrection(d, r);
62       if (!old2hit) 
63         Warning("RunCopySecMap",
64                 "Didn't find double hit correction for FMD%d%c", d, r);
65       else { 
66         TH1D* new2hit = new TH1D(Form("FMD%d%c", d, r), 
67                                  Form("Double hit correction for FMD%d%c",d,r), 
68                                  nEta, minEta, maxEta);
69         new2hit->SetXTitle("#eta");
70         new2hit->SetYTitle("#sum_{i} N_{i,strips hit}(#eta)/"
71                            "#sum_{i} N_{i,total hits}(#eta)");
72         new2hit->SetFillColor(Color(d,r));
73         new2hit->SetFillStyle(3001);
74         new2hit->SetDirectory(0);
75         new2hit->SetStats(0);
76         new2hit->Sumw2();
77         new2hit->Add(old2hit);
78
79         Info("RunCopySecMap", 
80              "Copying %s to %s", old2hit->GetName(), new2hit->GetName());
81
82         dh->SetCorrection(d, r, new2hit);
83       }
84
85       for (UShort_t b = 1; b <= nVtx; b++) { 
86         TH2F* oldmap = p->GetBackgroundCorrection(d, r, b-1);
87         if (!oldmap) {
88           Warning("RunCopySecMap",
89                   "Didn't find secondary map correction "
90                   "for FMD%d%c, vertex bin %3d", d, r, b);
91           continue;
92         }
93        
94         TH2D* newmap = new TH2D(Form("FMD%d%c_vtxbin%03d", d, r, b), 
95                                 Form("Secondary map correction for FMD%d%c "
96                                      "in vertex bin %d [%+8.4f,%+8.4f]", 
97                                      d, r, b, vtxAxis.GetBinLowEdge(b), 
98                                      vtxAxis.GetBinUpEdge(b)), 
99                                 nEta, minEta, maxEta, 
100                                 oldmap->GetYaxis()->GetNbins(), 
101                                 oldmap->GetYaxis()->GetXmin(), 
102                                 oldmap->GetYaxis()->GetXmax());
103         newmap->SetXTitle("#eta");
104         newmap->SetYTitle("#phi [radians]");
105         newmap->SetZTitle("#sum_{i} N_{ch,i,primary} / #sum_{i} N_{ch,i,FMD}");
106         newmap->SetDirectory(0);
107         newmap->SetStats(0);
108         newmap->Sumw2();
109         newmap->Add(oldmap);
110
111         Info("RunCopySecMap",
112              "Copying %s to %s", oldmap->GetName(), newmap->GetName());
113
114         m->SetCorrection(d, r, b, newmap);
115       }
116     }
117   }
118   UShort_t isys = AliForwardUtil::ParseCollisionSystem(sys);
119   AliForwardCorrectionManager& mgr = AliForwardCorrectionManager::Instance();
120   TString fname(mgr.GetFileName(AliForwardCorrectionManager::kSecondaryMap,
121                                 isys, cms, field, false));
122   TFile* output = TFile::Open(fname.Data(), "RECREATE");
123   if (!output) { 
124     Warning("Run", "Failed to open output file %s", fname.Data());
125     return kFALSE;
126   }
127   m->Write(mgr.GetObjectName(AliForwardCorrectionManager::kSecondaryMap));
128   output->Write();
129   output->Close();
130   Info("Run", "File %s created.  It should be copied to %s and stored in SVN",
131        fname.Data(),mgr.GetFileDir(AliForwardCorrectionManager::kSecondaryMap));
132
133   fname = mgr.GetFileName(AliForwardCorrectionManager::kDoubleHit,
134                           isys, cms, field, false);
135   output = TFile::Open(fname.Data(), "RECREATE");
136   if (!output) { 
137     Warning("Run", "Failed to open output file %s", fname.Data());
138     return kFALSE;
139   }
140   dh->Write(mgr.GetObjectName(AliForwardCorrectionManager::kDoubleHit));
141   output->Write();
142   output->Close();
143   Info("Run", "File %s created.  It should be copied to %s and stored in SVN",
144        fname.Data(),mgr.GetFileDir(AliForwardCorrectionManager::kDoubleHit));
145 }
146 //
147 // EOF
148 //