]>
Commit | Line | Data |
---|---|---|
df0d5480 | 1 | /************************************************************************** |
2 | * Copyright(c) 2004, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | // Thil class computes background corrections for the FMD. The correction is computed | |
17 | // in eta,phi cells and the objects stored can be put into alien to use with analysis. | |
18 | // It is based on the AliFMDInput class that is used to loop over hits and primaries. | |
19 | // | |
20 | // Author: Hans Hjersing Dalsgaard, NBI, hans.dalsgaard@cern.ch | |
21 | // | |
22 | // | |
23 | ||
24 | #include "AliSimulation.h" | |
25 | #include "TStopwatch.h" | |
26 | #include "iostream" | |
27 | #include "TGrid.h" | |
28 | #include "AliRunLoader.h" | |
29 | #include "AliGeomManager.h" | |
30 | #include "AliFMDGeometry.h" | |
31 | #include "AliStack.h" | |
32 | #include "TParticle.h" | |
33 | #include "TDatabasePDG.h" | |
34 | #include "TParticlePDG.h" | |
35 | #include "AliRun.h" | |
36 | #include "AliFMDBackgroundCorrection.h" | |
37 | #include "TSystem.h" | |
38 | #include "AliCDBManager.h" | |
39 | #include "TTree.h" | |
40 | #include "TClonesArray.h" | |
41 | #include "TBranch.h" | |
42 | #include "AliFMDHit.h" | |
43 | #include "AliLoader.h" | |
44 | #include "AliFMD.h" | |
df0d5480 | 45 | #include "AliGenEventHeader.h" |
46 | #include "AliHeader.h" | |
47 | #include "TFile.h" | |
48 | #include "TAxis.h" | |
49 | #include "AliCDBId.h" | |
50 | #include "AliCDBMetaData.h" | |
51 | #include "TROOT.h" | |
52 | #include "AliFMDParameters.h" | |
53 | #include "AliLog.h" | |
26c8b5ff | 54 | #include "TList.h" |
8dc823cc | 55 | #include "AliFMDAnaParameters.h" |
b82e76e0 | 56 | #include "AliFMDAnaCalibBackgroundCorrection.h" |
08d168d9 | 57 | #include "AliTrackReference.h" |
58 | #include "AliFMDStripIndex.h" | |
df0d5480 | 59 | |
60 | ClassImp(AliFMDBackgroundCorrection) | |
61 | //_____________________________________________________________________ | |
62 | AliFMDBackgroundCorrection::AliFMDBackgroundCorrection() : | |
63 | TNamed(), | |
ca3af5d9 | 64 | fCorrectionArray(), |
65 | fPrimaryList() | |
df0d5480 | 66 | {} |
67 | ||
68 | //_____________________________________________________________________ | |
08d168d9 | 69 | AliFMDBackgroundCorrection::AliFMDInputBG::AliFMDInputBG(Bool_t hits_not_trackref) : |
5d5bc6be | 70 | AliFMDInput("galice.root"), |
8dc823cc | 71 | fPrimaryArray(), |
72 | fHitArray(), | |
627ba74b | 73 | fHitMap(), |
6289b3e8 | 74 | fLastTrackByStrip(), |
df0d5480 | 75 | fPrim(0), |
76 | fHits(0), | |
77 | fZvtxCut(0), | |
78 | fNvtxBins(0), | |
79 | fPrevTrack(-1), | |
80 | fPrevDetector(-1), | |
81 | fPrevRing('Q'), | |
5d5bc6be | 82 | fPrevSec(-1), |
df0d5480 | 83 | fNbinsEta(100) |
84 | { | |
6289b3e8 | 85 | |
86 | if(hits_not_trackref) { | |
08d168d9 | 87 | AddLoad(kHits); |
6289b3e8 | 88 | AddLoad(kTracks); |
89 | } | |
08d168d9 | 90 | else |
91 | AddLoad(kTrackRefs); | |
df0d5480 | 92 | AddLoad(kKinematics); |
93 | AddLoad(kHeader); | |
627ba74b | 94 | |
95 | ||
df0d5480 | 96 | } |
97 | ||
98 | //_____________________________________________________________________ | |
99 | ||
08d168d9 | 100 | void AliFMDBackgroundCorrection::GenerateBackgroundCorrection(Bool_t from_hits, |
101 | const Int_t nvtxbins, | |
df0d5480 | 102 | Float_t zvtxcut, |
ca3af5d9 | 103 | const Int_t nBinsEta, |
df0d5480 | 104 | Bool_t storeInAlien, |
105 | Int_t runNo, | |
106 | Int_t endRunNo, | |
107 | const Char_t* filename, | |
108 | Bool_t simulate, | |
109e97cd | 109 | Int_t nEvents, |
110 | Bool_t inFile, | |
111 | const Char_t* infilename) { | |
df0d5480 | 112 | |
ca3af5d9 | 113 | //TGrid::Connect("alien:",0,0,"t"); |
df0d5480 | 114 | if(simulate) |
115 | Simulate(nEvents); | |
116 | else { | |
ca3af5d9 | 117 | //AliCDBManager::Instance()->SetDefaultStorage("alien://Folder=/alice/data/2008/LHC08d/OCDB/"); |
162637e4 | 118 | AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); |
df0d5480 | 119 | AliCDBManager::Instance()->SetRun(runNo); |
120 | ||
121 | #if defined(__CINT__) | |
122 | gSystem->Load("liblhapdf"); | |
123 | gSystem->Load("libEGPythia6"); | |
124 | gSystem->Load("libpythia6"); | |
125 | gSystem->Load("libAliPythia6"); | |
126 | gSystem->Load("libgeant321"); | |
127 | #endif | |
ca3af5d9 | 128 | // |
df0d5480 | 129 | } |
130 | ||
131 | //Setting up the geometry | |
132 | //----------------------------------------------- | |
133 | if (AliGeomManager::GetGeometry() == NULL) | |
134 | AliGeomManager::LoadGeometry(); | |
135 | ||
136 | AliFMDGeometry* geo = AliFMDGeometry::Instance(); | |
137 | geo->Init(); | |
138 | geo->InitTransformations(); | |
ca3af5d9 | 139 | |
df0d5480 | 140 | AliInfo("Processing hits and primaries "); |
141 | ||
08d168d9 | 142 | AliFMDInputBG input(from_hits); |
df0d5480 | 143 | |
109e97cd | 144 | if(!inFile) { |
145 | ||
146 | input.SetVtxCutZ(zvtxcut); | |
147 | input.SetNvtxBins(nvtxbins); | |
148 | input.SetNbinsEta(nBinsEta); | |
149 | input.Run(); | |
150 | } | |
df0d5480 | 151 | |
109e97cd | 152 | AliInfo(Form("Found %d primaries and %d hits.", input.GetNprim(),input.GetNhits())); |
153 | TObjArray* hitArray ; | |
154 | TObjArray* primaryArray; | |
155 | if(inFile) { | |
156 | TFile* infile = TFile::Open(infilename); | |
157 | hitArray = new TObjArray(); | |
158 | primaryArray = new TObjArray(); | |
159 | ||
160 | for(Int_t det =1; det<=3;det++) | |
161 | { | |
162 | TObjArray* detArrayHits = new TObjArray(); | |
163 | detArrayHits->SetName(Form("FMD%d",det)); | |
164 | hitArray->AddAtAndExpand(detArrayHits,det); | |
165 | Int_t nRings = (det==1 ? 1 : 2); | |
166 | for(Int_t ring = 0;ring<nRings;ring++) | |
167 | { | |
168 | ||
169 | Char_t ringChar = (ring == 0 ? 'I' : 'O'); | |
170 | TObjArray* vtxArrayHits = new TObjArray(); | |
171 | vtxArrayHits->SetName(Form("FMD%d%c",det,ringChar)); | |
172 | detArrayHits->AddAtAndExpand(vtxArrayHits,ring); | |
173 | for(Int_t v=0; v<nvtxbins;v++) | |
174 | { | |
175 | ||
176 | TH2F* hHits = (TH2F*)infile->Get(Form("hHits_FMD%d%c_vtx%d",det,ringChar,v)); | |
177 | ||
178 | ||
179 | vtxArrayHits->AddAtAndExpand(hHits,v); | |
180 | ||
181 | } | |
182 | } | |
183 | ||
184 | } | |
185 | ||
186 | for(Int_t iring = 0; iring<2;iring++) { | |
187 | Char_t ringChar = (iring == 0 ? 'I' : 'O'); | |
188 | TObjArray* ringArray = new TObjArray(); | |
189 | ringArray->SetName(Form("FMD_%c",ringChar)); | |
190 | primaryArray->AddAtAndExpand(ringArray,iring); | |
191 | for(Int_t v=0; v<nvtxbins;v++) { | |
192 | ||
193 | TH2F* hPrimary = (TH2F*)infile->Get(Form("hPrimary_FMD_%c_vtx%d",ringChar,v)); | |
194 | ringArray->AddAtAndExpand(hPrimary,v); | |
195 | } | |
196 | } | |
197 | ||
198 | ||
199 | } | |
200 | else { | |
201 | hitArray = input.GetHits(); | |
202 | primaryArray = input.GetPrimaries(); | |
203 | } | |
df0d5480 | 204 | fCorrectionArray.SetName("FMD_bg_correction"); |
205 | fCorrectionArray.SetOwner(); | |
ca3af5d9 | 206 | |
207 | TList* primaryList = new TList(); | |
26c8b5ff | 208 | primaryList->SetName("primaries"); |
ca3af5d9 | 209 | |
26c8b5ff | 210 | TList* hitList = new TList(); |
211 | hitList->SetName("hits"); | |
212 | TList* corrList = new TList(); | |
213 | corrList->SetName("corrections"); | |
109e97cd | 214 | |
b82e76e0 | 215 | AliFMDAnaCalibBackgroundCorrection* background = new AliFMDAnaCalibBackgroundCorrection(); |
216 | ||
df0d5480 | 217 | for(Int_t det= 1; det <=3; det++) { |
218 | Int_t nRings = (det==1 ? 1 : 2); | |
219 | ||
220 | TObjArray* detArrayCorrection = new TObjArray(); | |
221 | detArrayCorrection->SetName(Form("FMD%d",det)); | |
222 | fCorrectionArray.AddAtAndExpand(detArrayCorrection,det); | |
223 | ||
224 | ||
225 | for(Int_t iring = 0; iring<nRings; iring++) { | |
226 | TObjArray* primRingArray = (TObjArray*)primaryArray->At(iring); | |
227 | Char_t ringChar = (iring == 0 ? 'I' : 'O'); | |
228 | TObjArray* vtxArrayCorrection = new TObjArray(); | |
229 | vtxArrayCorrection->SetName(Form("FMD%d%c",det,ringChar)); | |
230 | detArrayCorrection->AddAtAndExpand(vtxArrayCorrection,iring); | |
231 | ||
232 | for(Int_t vertexBin=0;vertexBin<nvtxbins;vertexBin++) { | |
233 | TObjArray* detArray = (TObjArray*)hitArray->At(det); | |
234 | TObjArray* vtxArray = (TObjArray*)detArray->At(iring); | |
235 | TH2F* hHits = (TH2F*)vtxArray->At(vertexBin); | |
26c8b5ff | 236 | hitList->Add(hHits); |
df0d5480 | 237 | TH2F* hPrimary = (TH2F*)primRingArray->At(vertexBin); |
26c8b5ff | 238 | primaryList->Add(hPrimary); |
df0d5480 | 239 | TH2F* hCorrection = (TH2F*)hHits->Clone(Form("FMD%d%c_vtxbin_%d_correction",det,ringChar,vertexBin)); |
ca3af5d9 | 240 | hCorrection->Divide(hPrimary); |
26c8b5ff | 241 | corrList->Add(hCorrection); |
8dc823cc | 242 | hCorrection->SetTitle(hCorrection->GetName()); |
df0d5480 | 243 | vtxArrayCorrection->AddAtAndExpand(hCorrection,vertexBin); |
b82e76e0 | 244 | background->SetBgCorrection(det,ringChar,vertexBin,hCorrection); |
df0d5480 | 245 | } |
246 | ||
247 | } | |
248 | } | |
249 | ||
250 | TAxis refAxis(nvtxbins,-1*zvtxcut,zvtxcut); | |
109e97cd | 251 | if(inFile) { |
252 | TFile* infile = TFile::Open(infilename); | |
253 | TAxis* refaxis = (TAxis*)infile->Get("vertexbins"); | |
254 | background->SetRefAxis(refaxis); | |
255 | ||
256 | } | |
257 | else background->SetRefAxis(&refAxis); | |
df0d5480 | 258 | |
8dc823cc | 259 | TFile* fout = new TFile(filename,"RECREATE"); |
df0d5480 | 260 | refAxis.Write("vertexbins"); |
26c8b5ff | 261 | |
262 | hitList->Write(); | |
263 | primaryList->Write(); | |
264 | corrList->Write(); | |
ca3af5d9 | 265 | |
8dc823cc | 266 | TObjArray* container = new TObjArray(); |
267 | container->SetOwner(); | |
268 | container->AddAtAndExpand(&refAxis,0); | |
269 | container->AddAtAndExpand(&fCorrectionArray,1); | |
270 | container->AddAtAndExpand(hitArray,2); | |
271 | container->AddAtAndExpand(primaryArray,3); | |
b82e76e0 | 272 | |
273 | ||
df0d5480 | 274 | if(storeInAlien) { |
275 | AliCDBManager* cdb = AliCDBManager::Instance(); | |
162637e4 | 276 | cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); |
8dc823cc | 277 | AliCDBId id(AliFMDAnaParameters::GetBackgroundPath(),runNo,endRunNo); |
df0d5480 | 278 | |
279 | AliCDBMetaData* meta = new AliCDBMetaData; | |
280 | meta->SetResponsible(gSystem->GetUserInfo()->fRealName.Data()); | |
281 | meta->SetAliRootVersion(gROOT->GetVersion()); | |
282 | meta->SetBeamPeriod(1); | |
283 | meta->SetComment("Background Correction for FMD"); | |
b82e76e0 | 284 | meta->SetProperty("key1", background ); |
285 | cdb->Put(background, id, meta); | |
df0d5480 | 286 | |
287 | } | |
288 | ||
8dc823cc | 289 | fout->Close(); |
290 | ||
df0d5480 | 291 | |
ca3af5d9 | 292 | } |
293 | ||
df0d5480 | 294 | //_____________________________________________________________________ |
295 | void AliFMDBackgroundCorrection::Simulate(Int_t nEvents) { | |
296 | ||
297 | AliSimulation sim ; | |
298 | sim.SetRunNumber(0); | |
299 | TGrid::Connect("alien:",0,0,"t"); | |
300 | sim.SetDefaultStorage("alien://Folder=/alice/data/2008/LHC08d/OCDB/"); | |
301 | sim.SetConfigFile("Config.C"); | |
302 | sim.SetRunQA("FMD:"); | |
303 | TStopwatch timer; | |
304 | timer.Start(); | |
305 | sim.RunSimulation(nEvents); | |
306 | timer.Stop(); | |
307 | timer.Print(); | |
308 | ||
309 | } | |
310 | ||
311 | //_____________________________________________________________________ | |
faf80567 | 312 | Bool_t |
313 | AliFMDBackgroundCorrection::AliFMDInputBG::ProcessHit(AliFMDHit* h, | |
314 | TParticle* /*p*/) | |
315 | { | |
df0d5480 | 316 | |
08d168d9 | 317 | if(!h) |
318 | return kTRUE; | |
faf80567 | 319 | Bool_t retval = ProcessEvent(h->Detector(), |
320 | h->Ring(), | |
98accb9e | 321 | h->Sector(), |
322 | h->Strip(), | |
faf80567 | 323 | h->Track(), |
324 | h->Q()); | |
08d168d9 | 325 | |
6289b3e8 | 326 | // std::cout<<"Length: "<<h->Length()<<std::endl; |
327 | // std::cout<<"Is stopped "<<h->IsStop()<<" "<<kTRUE<<std::endl; | |
08d168d9 | 328 | return retval; |
329 | } | |
330 | //_____________________________________________________________________ | |
faf80567 | 331 | Bool_t |
6289b3e8 | 332 | AliFMDBackgroundCorrection::AliFMDInputBG::ProcessTrackRef(AliTrackReference* tr, TParticle* p) |
faf80567 | 333 | { |
08d168d9 | 334 | if(!tr) |
335 | return kTRUE; | |
336 | UShort_t det,sec,strip; | |
337 | Char_t ring; | |
338 | AliFMDStripIndex::Unpack(tr->UserId(),det,ring,sec,strip); | |
faf80567 | 339 | Int_t nTrack = tr->GetTrack(); |
340 | TDatabasePDG* pdgDB = TDatabasePDG::Instance(); | |
08d168d9 | 341 | TParticlePDG* pdgPart = pdgDB->GetParticle(p->GetPdgCode()); |
faf80567 | 342 | Float_t charge = (pdgPart ? pdgPart->Charge() : 0); |
343 | Bool_t retval = ProcessEvent(det,ring,sec,strip,nTrack,charge); | |
08d168d9 | 344 | return retval; |
345 | ||
346 | } | |
347 | //_____________________________________________________________________ | |
faf80567 | 348 | Bool_t |
349 | AliFMDBackgroundCorrection::AliFMDInputBG::ProcessEvent(UShort_t det, | |
350 | Char_t ring, | |
351 | UShort_t sec, | |
352 | UShort_t strip, | |
353 | Int_t nTrack, | |
354 | Float_t charge) | |
08d168d9 | 355 | { |
356 | ||
df0d5480 | 357 | |
df0d5480 | 358 | |
6289b3e8 | 359 | /* if(charge != 0 && |
627ba74b | 360 | ((nTrack != fPrevTrack) || |
6289b3e8 | 361 | (det != fPrevDetector))){ || |
362 | (ring != fPrevRing))){ || | |
363 | (sec != fPrevSec))) {*/ | |
364 | /*Float_t nstrips = (ring =='O' ? 256 : 512); | |
365 | ||
366 | ||
367 | Float_t prevStripTrack = -1; | |
368 | if(strip >0) | |
369 | prevStripTrack = fLastTrackByStrip.operator()(det,ring,sec,strip-1); | |
370 | ||
371 | Float_t nextStripTrack = -1; | |
372 | if(strip < (nstrips - 1)) | |
373 | nextStripTrack = fLastTrackByStrip.operator()(det,ring,sec,strip+1); | |
374 | */ | |
375 | ||
376 | Float_t thisStripTrack = fLastTrackByStrip.operator()(det,ring,0,0); | |
377 | // if(nTrack == fLastTrackByStrip.operator()(det,ring,sec,strip)) | |
378 | // std::cout<<"Track # "<<nTrack<<" failed the cut in "<<det<<" "<<ring<<" "<<sec<<" "<<strip<<std::endl; | |
379 | // else | |
380 | // std::cout<<"Track # "<<nTrack<<" passed the cut in "<<det<<" "<<ring<<" "<<sec<<" "<<strip<<std::endl; | |
381 | if(charge != 0 && nTrack != thisStripTrack) { | |
382 | ||
383 | fHitMap.operator()(det,ring,sec,strip) += 1; | |
08d168d9 | 384 | fHits++; |
6289b3e8 | 385 | Float_t nstrips = (ring =='O' ? 256 : 512); |
386 | fLastTrackByStrip.operator()(det,ring,sec,strip) = (Float_t)nTrack; | |
387 | if(strip >0) | |
388 | fLastTrackByStrip.operator()(det,ring,sec,strip-1) = (Float_t)nTrack; | |
389 | if(strip < (nstrips - 1)) | |
390 | fLastTrackByStrip.operator()(det,ring,sec,strip+1) = (Float_t)nTrack; | |
5d5bc6be | 391 | |
6289b3e8 | 392 | fPrevDetector = det; |
393 | fPrevRing = ring; | |
394 | fPrevSec = sec; | |
395 | fPrevTrack = nTrack; | |
08d168d9 | 396 | } |
ca3af5d9 | 397 | |
6289b3e8 | 398 | |
5d5bc6be | 399 | |
df0d5480 | 400 | return kTRUE; |
08d168d9 | 401 | |
df0d5480 | 402 | } |
403 | ||
404 | //_____________________________________________________________________ | |
faf80567 | 405 | Bool_t AliFMDBackgroundCorrection::AliFMDInputBG::Init() |
406 | { | |
6289b3e8 | 407 | fLastTrackByStrip.Reset(-1); |
408 | ||
df0d5480 | 409 | fPrimaryArray.SetOwner(); |
410 | fPrimaryArray.SetName("FMD_primary"); | |
411 | ||
627ba74b | 412 | fPrimaryMapInner.SetBins(fNbinsEta, -6,6, 20, 0, 2*TMath::Pi()); |
413 | fPrimaryMapOuter.SetBins(fNbinsEta, -6,6, 40, 0, 2*TMath::Pi()); | |
414 | fPrimaryMapInner.SetName("fPrimaryMapInner"); | |
415 | fPrimaryMapInner.SetName("fPrimaryMapOuter"); | |
416 | ||
417 | fPrimaryMapInner.Sumw2(); | |
418 | fPrimaryMapOuter.Sumw2(); | |
df0d5480 | 419 | for(Int_t iring = 0; iring<2;iring++) { |
420 | Char_t ringChar = (iring == 0 ? 'I' : 'O'); | |
421 | TObjArray* ringArray = new TObjArray(); | |
422 | ringArray->SetName(Form("FMD_%c",ringChar)); | |
423 | fPrimaryArray.AddAtAndExpand(ringArray,iring); | |
424 | Int_t nSec = (iring == 1 ? 40 : 20); | |
425 | for(Int_t v=0; v<fNvtxBins;v++) { | |
426 | ||
427 | TH2F* hPrimary = new TH2F(Form("hPrimary_FMD_%c_vtx%d",ringChar,v), | |
428 | Form("hPrimary_FMD_%c_vtx%d",ringChar,v), | |
429 | fNbinsEta, -6,6, nSec, 0,2*TMath::Pi()); | |
b82e76e0 | 430 | hPrimary->Sumw2(); |
df0d5480 | 431 | ringArray->AddAtAndExpand(hPrimary,v); |
432 | } | |
433 | } | |
434 | ||
435 | ||
436 | fHitArray.SetOwner(); | |
437 | fHitArray.SetName("FMD_hits"); | |
438 | ||
faf80567 | 439 | for(Int_t det =1; det<=3;det++) { |
440 | TObjArray* detArrayHits = new TObjArray(); | |
441 | detArrayHits->SetName(Form("FMD%d",det)); | |
442 | fHitArray.AddAtAndExpand(detArrayHits,det); | |
443 | Int_t nRings = (det==1 ? 1 : 2); | |
444 | for(Int_t ring = 0;ring<nRings;ring++) { | |
445 | Int_t nSec = (ring == 1 ? 40 : 20); | |
446 | Char_t ringChar = (ring == 0 ? 'I' : 'O'); | |
447 | TObjArray* vtxArrayHits = new TObjArray(); | |
448 | vtxArrayHits->SetName(Form("FMD%d%c",det,ringChar)); | |
449 | detArrayHits->AddAtAndExpand(vtxArrayHits,ring); | |
450 | for(Int_t v=0; v<fNvtxBins;v++) { | |
451 | TH2F* hHits = new TH2F(Form("hHits_FMD%d%c_vtx%d", det,ringChar,v), | |
452 | Form("hHits_FMD%d%c_vtx%d", det,ringChar,v), | |
453 | fNbinsEta, -6,6, nSec, 0, 2*TMath::Pi()); | |
454 | hHits->Sumw2(); | |
455 | vtxArrayHits->AddAtAndExpand(hHits,v); | |
456 | ||
457 | } | |
df0d5480 | 458 | } |
faf80567 | 459 | } |
df0d5480 | 460 | |
df0d5480 | 461 | AliFMDInput::Init(); |
462 | ||
df0d5480 | 463 | return kTRUE; |
464 | } | |
ca3af5d9 | 465 | //_____________________________________________________________________ |
466 | ||
faf80567 | 467 | Bool_t AliFMDBackgroundCorrection::AliFMDInputBG::Begin(Int_t event ) |
468 | { | |
df0d5480 | 469 | |
faf80567 | 470 | Bool_t retVal = AliFMDInput::Begin(event); |
471 | AliStack* partStack = fLoader->Stack(); | |
472 | Int_t nTracks = partStack->GetNtrack(); | |
ca3af5d9 | 473 | |
faf80567 | 474 | |
475 | for(Int_t j=0;j<nTracks;j++) { | |
5d5bc6be | 476 | TParticle* p = partStack->Particle(j); |
477 | TDatabasePDG* pdgDB = TDatabasePDG::Instance(); | |
478 | TParticlePDG* pdgPart = pdgDB->GetParticle(p->GetPdgCode()); | |
479 | Float_t charge = (pdgPart ? pdgPart->Charge() : 0); | |
480 | Float_t phi = TMath::ATan2(p->Py(),p->Px()); | |
faf80567 | 481 | |
482 | if(phi<0) phi = phi+2*TMath::Pi(); | |
627ba74b | 483 | // if(p->Theta() == 0) continue; |
484 | Float_t eta = p->Eta(); | |
485 | ||
486 | // std::cout<<-1*TMath::Log(TMath::Tan(0.5*p->Theta()))<<std::endl; | |
faf80567 | 487 | |
488 | Bool_t primary = partStack->IsPhysicalPrimary(j); | |
489 | //(charge!=0)&&(TMath::Abs(p->Vx() - vertex.At(0))<0.01)&&(TMath::Abs(p->Vy() - vertex.At(1))<0.01)&&(TMath::Abs(p->Vz() - vertex.At(2))<0.01); | |
490 | if(primary && charge !=0) { | |
491 | ||
492 | fPrim++; | |
faf80567 | 493 | |
627ba74b | 494 | fPrimaryMapInner.Fill(eta,phi); |
495 | fPrimaryMapOuter.Fill(eta,phi); | |
faf80567 | 496 | } |
497 | } | |
109e97cd | 498 | |
ca3af5d9 | 499 | return retVal; |
500 | } | |
501 | //_____________________________________________________________________ | |
627ba74b | 502 | Bool_t AliFMDBackgroundCorrection::AliFMDInputBG::End() { |
503 | ||
504 | Bool_t retval = AliFMDInput::End(); | |
505 | ||
506 | AliGenEventHeader* genHeader = fLoader->GetHeader()->GenEventHeader(); | |
507 | TArrayF vertex; | |
508 | genHeader->PrimaryVertex(vertex); | |
509 | ||
510 | if(TMath::Abs(vertex.At(2)) > fZvtxCut) | |
511 | return kTRUE; | |
512 | ||
513 | Double_t delta = 2*fZvtxCut/fNvtxBins; | |
514 | Double_t vertexBinDouble = (vertex.At(2) + fZvtxCut) / delta; | |
515 | Int_t vertexBin = (Int_t)vertexBinDouble; | |
516 | //Primaries | |
517 | TObjArray* innerArray = (TObjArray*)fPrimaryArray.At(0); | |
518 | TObjArray* outerArray = (TObjArray*)fPrimaryArray.At(1); | |
519 | ||
520 | TH2F* hPrimaryInner = (TH2F*)innerArray->At(vertexBin); | |
521 | TH2F* hPrimaryOuter = (TH2F*)outerArray->At(vertexBin); | |
522 | ||
523 | hPrimaryInner->Add(&fPrimaryMapInner); | |
524 | hPrimaryOuter->Add(&fPrimaryMapOuter); | |
525 | ||
526 | //Hits | |
527 | for(UShort_t det=1;det<=3;det++) { | |
528 | Int_t nRings = (det==1 ? 1 : 2); | |
529 | for (UShort_t ir = 0; ir < nRings; ir++) { | |
530 | Char_t ring = (ir == 0 ? 'I' : 'O'); | |
531 | UShort_t nsec = (ir == 0 ? 20 : 40); | |
532 | UShort_t nstr = (ir == 0 ? 512 : 256); | |
533 | ||
534 | for(UShort_t sec =0; sec < nsec; sec++) { | |
535 | ||
536 | for(UShort_t strip = 0; strip < nstr; strip++) { | |
537 | ||
538 | if(fHitMap.operator()(det,ring,sec,strip) > 0) { | |
6289b3e8 | 539 | //std::cout<<fHitMap.operator()(det,ring,sec,strip)<<std::endl; |
627ba74b | 540 | Double_t x,y,z; |
541 | AliFMDGeometry* fmdgeo = AliFMDGeometry::Instance(); | |
542 | fmdgeo->Detector2XYZ(det,ring,sec,strip,x,y,z); | |
543 | ||
544 | Int_t iring = (ring == 'I' ? 0 : 1); | |
545 | ||
546 | TObjArray* detArray = (TObjArray*)fHitArray.At(det); | |
547 | TObjArray* vtxArray = (TObjArray*)detArray->At(iring); | |
548 | TH2F* hHits = (TH2F*)vtxArray->At(vertexBin); | |
549 | ||
550 | Float_t phi = TMath::ATan2(y,x); | |
551 | if(phi<0) phi = phi+2*TMath::Pi(); | |
552 | Float_t r = TMath::Sqrt(TMath::Power(x,2)+TMath::Power(y,2)); | |
553 | Float_t theta = TMath::ATan2(r,z-vertex.At(2)); | |
554 | Float_t eta = -1*TMath::Log(TMath::Tan(0.5*theta)); | |
6289b3e8 | 555 | hHits->Fill(eta,phi,fHitMap.operator()(det,ring,sec,strip)); |
627ba74b | 556 | } |
557 | ||
558 | } | |
559 | } | |
560 | } | |
561 | } | |
562 | ||
563 | fPrimaryMapInner.Reset(); | |
564 | fPrimaryMapOuter.Reset(); | |
565 | fHitMap.Reset(0); | |
6289b3e8 | 566 | fLastTrackByStrip.Reset(-1); |
627ba74b | 567 | |
568 | return retval; | |
569 | } | |
570 | ||
ca3af5d9 | 571 | // |
572 | // EOF | |
573 | // | |
df0d5480 | 574 | |
575 |