]>
Commit | Line | Data |
---|---|---|
8973b4ed | 1 | //_____________________________________________________________________ |
970b1a8a | 2 | /** |
3 | * | |
4 | * | |
5 | * @param d | |
6 | * @param r | |
7 | * @param vz | |
8 | * @param nDead | |
9 | * | |
10 | * @return | |
11 | * | |
bd6f5206 | 12 | * @ingroup pwglf_forward_scripts_corr |
970b1a8a | 13 | */ |
72cc12cd | 14 | TH2D* MakeOneRing(UShort_t d, Char_t r, Double_t vz, Int_t& nDead) |
8973b4ed | 15 | { |
16 | AliFMDGeometry* geom = AliFMDGeometry::Instance(); | |
17 | AliFMDParameters* pars = AliFMDParameters::Instance(); | |
18 | ||
19 | UShort_t nS = (r == 'I' || r == 'i' ? 20 : 40); | |
20 | UShort_t nT = (r == 'I' || r == 'i' ? 512 : 256); | |
21 | ||
22 | // Make our two histograms | |
72cc12cd | 23 | TH2D* hAll = new TH2D("all","All",200,-4,6,nS,0,2*TMath::Pi()); |
8973b4ed | 24 | hAll->SetXTitle("#eta"); |
25 | hAll->SetYTitle("#phi"); | |
26 | hAll->Sumw2(); | |
27 | hAll->SetDirectory(0); | |
72cc12cd | 28 | TH2D* hOK = static_cast<TH2D*>(hAll->Clone()); |
8973b4ed | 29 | hOK->SetDirectory(0); |
30 | ||
31 | // Loop over all sectors and strips in this ring | |
72cc12cd | 32 | Int_t nOK = 0; |
33 | Int_t nAll = 0; | |
c47f3ae9 | 34 | Int_t nPhi = hAll->GetNbinsY(); |
8973b4ed | 35 | for (UShort_t s = 0; s < nS; s++) { |
36 | for (UShort_t t = 0; t < nT; t++) { | |
37 | // Get eta,phi by quering the geometry (first for (x,y,z), then | |
38 | // correcting for the vertex position, and then calculating | |
39 | // (eta, phi)) | |
40 | Double_t x, y, z; | |
41 | geom->Detector2XYZ(d, r, s, t, x, y, z); | |
42 | z -= vz; | |
43 | Double_t q, eta, phi, theta; | |
44 | AliFMDGeometry::XYZ2REtaPhiTheta(x, y, z, q, eta, phi, theta); | |
72cc12cd | 45 | if (phi < 0) phi += 2*TMath::Pi(); |
8973b4ed | 46 | |
47 | // Check if this is a dead channel or not | |
48 | Bool_t isDead = pars->IsDead(d, r, s, t); | |
c47f3ae9 | 49 | |
50 | // Special check for FMD2i | |
51 | Int_t VA = t/128; | |
52 | if(d==2 && r=='I' && VA>1 && (s==16 || s==17)) isDead =true; | |
53 | ||
54 | // Find the eta bin number and corresponding overflow bin | |
55 | Int_t etaBin = hAll->GetXaxis()->FindBin(eta); | |
56 | Int_t ovrBin = hAll->GetBin(etaBin, nPhi+1); | |
57 | ||
58 | // Increment all histogram | |
8973b4ed | 59 | hAll->Fill(eta, phi); |
c47f3ae9 | 60 | hAll->AddBinContent(ovrBin); |
72cc12cd | 61 | nAll++; |
c47f3ae9 | 62 | |
63 | // If not dead, increment OK histogram | |
72cc12cd | 64 | if (!isDead) { |
65 | hOK->Fill(eta, phi); | |
c47f3ae9 | 66 | hOK->AddBinContent(ovrBin); |
72cc12cd | 67 | nOK++; |
68 | } | |
8973b4ed | 69 | else nDead++; |
70 | } | |
71 | } | |
72 | // Divide out the efficiency. | |
c47f3ae9 | 73 | // Note, that the overflow bins along eta now contains the ratio |
74 | // nOK/nAll Strips for a given eta bin. | |
8973b4ed | 75 | hOK->Divide(hOK,hAll,1,1,"B"); |
76 | ||
77 | // Clean up | |
78 | delete hAll; | |
79 | ||
c47f3ae9 | 80 | Info("ExtractAcceptances","Made correction for FMD%d%c at vz=%f - " |
72cc12cd | 81 | "%d strips out of %d OK", d, r, vz, nOK, nAll); |
82 | ||
8973b4ed | 83 | // Return result |
84 | return hOK; | |
85 | } | |
86 | ||
87 | //_____________________________________________________________________ | |
970b1a8a | 88 | /** |
89 | * | |
90 | * | |
91 | * @param runNo | |
92 | * @param system | |
93 | * @param energy | |
94 | * @param field | |
95 | * @param nVtxBins | |
96 | * @param vtxLow | |
97 | * @param vtxHigh | |
98 | * | |
bd6f5206 | 99 | * @ingroup pwglf_forward_scripts_corr |
970b1a8a | 100 | */ |
c47f3ae9 | 101 | void ExtractAcceptance(Int_t runNo=121526, |
102 | Int_t system = 1, | |
103 | Float_t energy = 900, | |
104 | Float_t field = 5, | |
105 | Int_t nVtxBins=10, | |
106 | Float_t vtxLow=-10, | |
107 | Float_t vtxHigh=10) | |
108 | { | |
8973b4ed | 109 | gSystem->Load("libANALYSIS"); |
110 | gSystem->Load("libANALYSISalice"); | |
bd6f5206 | 111 | gSystem->Load("libPWGLFforward2"); |
8973b4ed | 112 | |
113 | // Float_t delta = (vtxHigh - vtxLow) / (Float_t)nVtxBins; | |
114 | ||
3c5497d0 | 115 | Bool_t kGridOnline = kTRUE; |
116 | if(!(TGrid::Connect("alien://",0,0,"t"))) | |
117 | kGridOnline = kFALSE; | |
118 | ||
8973b4ed | 119 | // --- Initialisations ------------------------------------------ |
120 | //Set up CDB manager | |
c47f3ae9 | 121 | Info("ExtractAcceptances","Setting up OCDB"); |
3c5497d0 | 122 | |
8973b4ed | 123 | AliCDBManager* cdb = AliCDBManager::Instance(); |
3c5497d0 | 124 | if(kGridOnline) |
c47f3ae9 | 125 | cdb->SetDefaultStorage("alien://Folder=/alice/data/2012/OCDB"); |
3c5497d0 | 126 | else |
127 | cdb->SetDefaultStorage("local://$(ALICE_ROOT)/OCDB"); | |
8973b4ed | 128 | cdb->SetRun(runNo); |
129 | ||
72cc12cd | 130 | // Get the geometry |
c47f3ae9 | 131 | Info("ExtractAcceptances","Loading geometry"); |
72cc12cd | 132 | AliGeomManager::LoadGeometry(); |
133 | ||
8973b4ed | 134 | // Get an initialize parameters |
c47f3ae9 | 135 | Info("ExtractAcceptances","Intialising parameters"); |
8973b4ed | 136 | AliFMDParameters* pars = AliFMDParameters::Instance(); |
137 | pars->Init(); | |
138 | ||
139 | // Get an initialise geometry | |
c47f3ae9 | 140 | Info("ExtractAcceptances","Initialising geomtry"); |
8973b4ed | 141 | AliFMDGeometry* geom = AliFMDGeometry::Instance(); |
142 | geom->Init(); | |
72cc12cd | 143 | geom->InitTransformations(); |
8973b4ed | 144 | |
145 | // --- Output object ----------------------------------------------- | |
146 | // Make our correction object | |
147 | AliFMDCorrAcceptance* corr = new AliFMDCorrAcceptance(); | |
148 | corr->SetVertexAxis(nVtxBins, vtxLow, vtxHigh); | |
149 | ||
150 | // --- Loop over verticies and rings ------------------------------- | |
151 | Int_t nDead = 0; | |
152 | Float_t dV = (vtxHigh - vtxLow) / nVtxBins; | |
72cc12cd | 153 | for (Double_t v = vtxLow+dV/2; v < vtxHigh; v += dV) { |
8973b4ed | 154 | for(UShort_t d = 1; d <= 3;d++) { |
155 | UShort_t nR = (d == 1 ? 1 : 2); | |
156 | for (UShort_t q = 0; q < nR; q++) { | |
157 | Char_t r = (q == 0 ? 'I' : 'O'); | |
158 | ||
159 | // Delegate to other function | |
72cc12cd | 160 | TH2D* ratio = MakeOneRing(d, r, v, nDead); |
8973b4ed | 161 | if (!ratio) continue; |
162 | ||
163 | // Set the correction | |
164 | corr->SetCorrection(d, r, v, ratio); | |
165 | } | |
166 | } | |
167 | } | |
168 | ||
169 | // Write to a file | |
c47f3ae9 | 170 | Info("ExtractAcceptances","Writing to disk"); |
72cc12cd | 171 | AliForwardCorrectionManager& cm = AliForwardCorrectionManager::Instance(); |
172 | TString fname = cm.GetFileName(AliForwardCorrectionManager::kAcceptance, | |
3c5497d0 | 173 | system, energy, field, false); |
72cc12cd | 174 | TFile* out = TFile::Open(fname.Data(), "RECREATE"); |
c47f3ae9 | 175 | corr->SetHasOverflow(); |
72cc12cd | 176 | corr->Write(cm.GetObjectName(AliForwardCorrectionManager::kAcceptance)); |
177 | out->Write(); | |
178 | out->Close(); | |
c47f3ae9 | 179 | |
180 | std::ofstream f("Upload.C"); | |
181 | if (!f) { | |
182 | Error("ExtractELoss", "Failed to open Upload.C"); | |
183 | return; | |
184 | } | |
185 | f << "// Generated by ExtractAcceptance.C\n" | |
186 | << "void Upload(const TUrl& url)\n" | |
187 | << "{\n" | |
188 | << " if (TString(\"alien\").EqualTo(url.GetProtocol())) {\n" | |
189 | << " if (!TGrid::Connect(\"alien://\")) {\n" | |
190 | << " Error(\"Upload\", \"Failed to connect to AliEn\");\n" | |
191 | << " return;\n" | |
192 | << " }\n" | |
193 | << " }\n\n"; | |
194 | ||
195 | mgr.SetPrefix(""); | |
196 | TString fef(mgr.GetFileName(AliForwardCorrectionManager::kAcceptance, | |
197 | sys, sNN, field, false)); | |
198 | TString fep(mgr.GetFilePath(AliForwardCorrectionManager::kAcceptance, | |
199 | sys, sNN, field, false)); | |
200 | f << " TString src = \"" << fef << "\";\n" | |
201 | << " TString dest = \"" << fep << "\";\n" | |
202 | << " TString out; out.Form(\"%s%s\",url.GetUrl(),dest.Data());\n\n" | |
203 | << " TString dir(gSystem->DirName(out));\n" | |
204 | << " if (gSystem->AccessPathName(dir)) {\n" | |
205 | << " if (gSystem->mkdir(dir, true) < 0) {\n" | |
206 | << " Warning(\"Upload\",\"Failed to make directory %s\"," | |
207 | << " dir.Data());\n" | |
208 | << " return;\n" | |
209 | << " }\n" | |
210 | << " }\n" | |
211 | << " if (!TFile::Cp(src,out)) \n" | |
212 | << " Warning(\"Upload\",\"Failed to upload %s -> %s\",\n" | |
213 | << " src.Data(), out.Data());\n" | |
214 | << "}\n" | |
215 | << "// EOF" | |
216 | << std::endl; | |
217 | f.close(); | |
72cc12cd | 218 | |
c47f3ae9 | 219 | Info("ExtracAcceptance", |
220 | "Run generated Upload.C(DEST) script to copy files in place"); | |
8973b4ed | 221 | } |
222 | ||
223 | // | |
224 | // EOF | |
225 | // | |
226 |