1 #include "AliFMDAnalysisTaskGenerateCorrection.h"
2 #include "AliESDEvent.h"
6 #include "AliTrackReference.h"
8 #include "AliFMDAnaParameters.h"
9 #include "AliFMDStripIndex.h"
11 #include "AliMCParticle.h"
12 #include "AliMCEvent.h"
13 //#include "AliFMDGeometry.h"
15 #include "AliGenEventHeader.h"
16 #include "AliMultiplicity.h"
17 #include "AliHeader.h"
18 #include "AliFMDAnaCalibBackgroundCorrection.h"
19 #include "AliFMDAnaCalibEventSelectionEfficiency.h"
20 #include "AliGenPythiaEventHeader.h"
21 //#include "AliCDBManager.h"
22 //#include "AliCDBId.h"
23 //#include "AliCDBMetaData.h"
27 #include "AliGenDPMjetEventHeader.h"
29 ClassImp(AliFMDAnalysisTaskGenerateCorrection)
31 //_____________________________________________________________________
32 AliFMDAnalysisTaskGenerateCorrection::AliFMDAnalysisTaskGenerateCorrection():
46 // Default constructor
48 //_____________________________________________________________________
49 AliFMDAnalysisTaskGenerateCorrection::AliFMDAnalysisTaskGenerateCorrection(const char* name):
50 AliAnalysisTaskSE(name),
64 DefineOutput(1, TList::Class());
65 DefineOutput(2, TList::Class());
66 DefineOutput(3, TH1F::Class());
67 DefineOutput(4, TList::Class());
69 //_____________________________________________________________________
70 void AliFMDAnalysisTaskGenerateCorrection::UserCreateOutputObjects()
72 // Create the output containers
75 std::cout<<"Creating output objects"<<std::endl;
77 SelectCollisionCandidates(AliVEvent::kAny);
79 for(Int_t v=0; v<fNvtxBins;v++) {
81 TH2F* hSPDhits = new TH2F(Form("hSPDhits_vtx%d",v),
82 Form("hSPDhits_vtx%d",v),
83 fNbinsEta, -4,6, 20, 0,2*TMath::Pi());
85 fListOfHits.Add(hSPDhits);
87 for(Int_t iring = 0; iring<2;iring++) {
88 Char_t ringChar = (iring == 0 ? 'I' : 'O');
89 Int_t nSec = (iring == 1 ? 40 : 20);
91 TH2F* hPrimary = new TH2F(Form("hPrimary_FMD_%c_vtx%d",ringChar,v),
92 Form("hPrimary_FMD_%c_vtx%d",ringChar,v),
93 fNbinsEta, -4,6, nSec, 0,2*TMath::Pi());
95 fListOfPrimaries.Add(hPrimary);
96 TH2F* hPrimaryNSD = new TH2F(Form("hPrimaryNSD_FMD_%c_vtx%d",ringChar,v),
97 Form("hPrimaryNSD_FMD_%c_vtx%d",ringChar,v),
98 fNbinsEta, -4,6, nSec, 0,2*TMath::Pi());
100 fListOfPrimaries.Add(hPrimaryNSD);
110 for(Int_t det =1; det<=3;det++) {
111 Int_t nRings = (det==1 ? 1 : 2);
112 for(Int_t ring = 0;ring<nRings;ring++) {
113 Int_t nSec = (ring == 1 ? 40 : 20);
114 Char_t ringChar = (ring == 0 ? 'I' : 'O');
115 TH1F* doubleHits = new TH1F(Form("DoubleHits_FMD%d%c",det,ringChar),
116 Form("DoubleHits_FMD%d%c",det,ringChar),fNbinsEta, -4,6);
117 TH1F* allHits = new TH1F(Form("allHits_FMD%d%c",det,ringChar),
118 Form("allHits_FMD%d%c",det,ringChar), fNbinsEta, -4,6);
122 fListOfHits.Add(allHits);
123 fListOfHits.Add(doubleHits);
125 for(Int_t v=0; v<fNvtxBins;v++) {
126 TH2F* hHits = new TH2F(Form("hHits_FMD%d%c_vtx%d", det,ringChar,v),
127 Form("hHits_FMD%d%c_vtx%d", det,ringChar,v),
128 fNbinsEta, -4,6, nSec, 0, 2*TMath::Pi());
130 fListOfHits.Add(hHits);
131 TH2F* hHitsNSD = new TH2F(Form("hHitsNSD_FMD%d%c_vtx%d", det,ringChar,v),
132 Form("hHitsNSD_FMD%d%c_vtx%d", det,ringChar,v),
133 fNbinsEta, -4,6, nSec, 0, 2*TMath::Pi());
135 fListOfHits.Add(hHitsNSD);
142 TH1F* hEventsSelected = new TH1F("EventsSelected","EventsSelected",fNvtxBins,0,fNvtxBins);
143 TH1F* hEventsAll = new TH1F("EventsAll","EventsAll",fNvtxBins,0,fNvtxBins);
144 TH1F* hEventsAllNSD = new TH1F("EventsAllNSD","EventsAllNSD",fNvtxBins,0,fNvtxBins);
145 TH1F* hEventsSelectedVtx = new TH1F("EventsSelectedVtx","EventsSelectedVtx",fNvtxBins,0,fNvtxBins);
146 TH1F* hEventsSelectedTrigger = new TH1F("EventsSelectedTrigger","EventsSelectedTrigger",fNvtxBins,0,fNvtxBins);
148 TH1F* hEventsSelectedNSDVtx = new TH1F("EventsSelectedNSDVtx","EventsSelectedNSDVtx",fNvtxBins,0,fNvtxBins);
149 TH1F* hEventsSelectedNSD = new TH1F("EventsSelectedNSD","EventsSelectedNSD",fNvtxBins,0,fNvtxBins);
151 TH1F* hXvtx = new TH1F("hXvtx","x vertex distribution",100,-2,2);
152 TH1F* hYvtx = new TH1F("hYvtx","y vertex distribution",100,-2,2);
153 TH1F* hZvtx = new TH1F("hZvtx","z vertex distribution",4*fNvtxBins,-4*fZvtxCut,4*fZvtxCut);
155 fListOfPrimaries.Add(hXvtx);
156 fListOfPrimaries.Add(hYvtx);
157 fListOfPrimaries.Add(hZvtx);
159 hEventsSelected->Sumw2();
161 hEventsAllNSD->Sumw2();
163 fListOfHits.Add(hEventsSelected);
164 fListOfHits.Add(hEventsSelectedVtx);
165 fListOfHits.Add(hEventsSelectedTrigger);
166 fListOfHits.Add(hEventsSelectedNSDVtx);
167 fListOfHits.Add(hEventsSelectedNSD);
170 fListOfPrimaries.Add(hEventsAll);
171 fListOfPrimaries.Add(hEventsAllNSD);
173 for(Int_t v=0; v<fNvtxBins;v++) {
175 for(Int_t iring = 0; iring<2;iring++) {
176 Char_t ringChar = (iring == 0 ? 'I' : 'O');
177 Int_t nSec = (iring == 1 ? 40 : 20);
178 TH2F* hAnalysed = new TH2F(Form("Analysed_FMD%c_vtx%d",ringChar,v),
179 Form("Analysed_FMD%c_vtx%d",ringChar,v),
180 fNbinsEta, -4,6, nSec, 0,2*TMath::Pi());
183 fListOfPrimaries.Add(hAnalysed);
185 TH2F* hAnalysedNSD = new TH2F(Form("AnalysedNSD_FMD%c_vtx%d",ringChar,v),
186 Form("AnalysedNSD_FMD%c_vtx%d",ringChar,v),
187 fNbinsEta, -4,6, nSec, 0,2*TMath::Pi());
189 hAnalysedNSD->Sumw2();
190 fListOfPrimaries.Add(hAnalysedNSD);
192 TH2F* hInel = new TH2F(Form("Inel_FMD%c_vtx%d",ringChar,v),
193 Form("Inel_FMD%c_vtx%d",ringChar,v),
194 fNbinsEta, -4,6, nSec, 0,2*TMath::Pi());
197 fListOfPrimaries.Add(hInel);
199 TH2F* hNSD = new TH2F(Form("NSD_FMD%c_vtx%d",ringChar,v),
200 Form("NSD_FMD%c_vtx%d",ringChar,v),
201 fNbinsEta, -4,6, nSec, 0,2*TMath::Pi());
204 fListOfPrimaries.Add(hNSD);
209 fVertexBins.SetName("VertexBins");
210 fVertexBins.GetXaxis()->Set(fNvtxBins,-1*fZvtxCut,fZvtxCut);
215 //_____________________________________________________________________
216 void AliFMDAnalysisTaskGenerateCorrection::Init()
218 fLastTrackByStrip.Reset(-1);
222 //_____________________________________________________________________
223 void AliFMDAnalysisTaskGenerateCorrection::UserExec(Option_t */*option*/)
226 fLastTrackByStrip.Reset(-1);
227 fHitsByStrip.Reset(0);
228 AliMCEvent* mcevent = MCEvent();
230 AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
233 AliESDEvent* esdevent = (AliESDEvent*)InputEvent();
235 pars->SetTriggerStatus(esdevent);
237 Double_t esdvertex[3];
238 Bool_t vtxStatus = pars->GetVertex(esdevent,esdvertex);
240 AliMCParticle* particle = 0;
241 AliStack* stack = mcevent->Stack();
243 UShort_t det,sec,strip;
246 Int_t nTracks = mcevent->GetNumberOfTracks();
247 AliHeader* header = mcevent->Header();
248 AliGenEventHeader* genHeader = header->GenEventHeader();
250 AliGenPythiaEventHeader* pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(genHeader);
251 AliGenDPMjetEventHeader* dpmHeader = dynamic_cast<AliGenDPMjetEventHeader*>(header->GenEventHeader());
253 if (!pythiaGenHeader && !dpmHeader) {
254 std::cout<<" no pythia or dpm header! - NSD selection unusable"<<std::endl;
258 if(pythiaGenHeader) {
259 Int_t pythiaType = pythiaGenHeader->ProcessType();
261 if(pythiaType==92 || pythiaType==93)
265 Int_t processType = dpmHeader->ProcessType();
266 if(processType == 5 || processType == 6)
273 genHeader->PrimaryVertex(vertex);
275 TH1F* hXvtx = (TH1F*)fListOfPrimaries.FindObject("hXvtx");
276 hXvtx->Fill(vertex.At(0));
277 TH1F* hYvtx = (TH1F*)fListOfPrimaries.FindObject("hYvtx");
278 hYvtx->Fill(vertex.At(1));
279 TH1F* hZvtx = (TH1F*)fListOfPrimaries.FindObject("hZvtx");
280 hZvtx->Fill(vertex.At(2));
285 Double_t delta = 2*fZvtxCut/fNvtxBins;
286 Double_t vertexBinDouble = (vertex.At(2) + fZvtxCut) / delta;
287 Int_t vertexBin = (Int_t)vertexBinDouble;
289 // Vertex determination correction
290 TH1F* hEventsSelected = (TH1F*)fListOfHits.FindObject("EventsSelected");
291 TH1F* hEventsSelectedVtx = (TH1F*)fListOfHits.FindObject("EventsSelectedVtx");
292 TH1F* hEventsSelectedTrigger = (TH1F*)fListOfHits.FindObject("EventsSelectedTrigger");
293 TH1F* hEventsSelectedNSDVtx = (TH1F*)fListOfHits.FindObject("EventsSelectedNSDVtx");
294 TH1F* hEventsSelectedNSD = (TH1F*)fListOfHits.FindObject("EventsSelectedNSD");
295 TH1F* hEventsAll = (TH1F*)fListOfPrimaries.FindObject("EventsAll");
296 TH1F* hEventsAllNSD = (TH1F*)fListOfPrimaries.FindObject("EventsAllNSD");
298 // TH1F* hTriggered = (TH1F*)fListOfHits.FindObject("Triggered");
299 // TH1F* hTriggeredAll = (TH1F*)fListOfPrimaries.FindObject("TriggeredAll");
301 Bool_t vtxFound = kTRUE;
305 //if(TMath::Abs(vertex.At(2)) > fZvtxCut) {
306 // vtxFound = kFALSE;
309 Bool_t isTriggered = pars->IsEventTriggered(AliFMDAnaParameters::kMB1);
310 Bool_t isTriggeredNSD = pars->IsEventTriggered(AliFMDAnaParameters::kNSD);
311 if(vtxFound && isTriggered) hEventsSelected->Fill(vertexBin);
313 if(vtxFound) hEventsSelectedVtx->Fill(vertexBin);
314 if(isTriggered) hEventsSelectedTrigger->Fill(vertexBin);
316 if(vtxFound && isTriggeredNSD) hEventsSelectedNSDVtx->Fill(vertexBin);
317 if(isTriggeredNSD) hEventsSelectedNSD->Fill(vertexBin);
320 hEventsAll->Fill(vertexBin);
321 if(nsd) hEventsAllNSD->Fill(vertexBin);
323 if(!vtxFound || !isTriggered) return; //Not important for FMD but crucial for SPD since maps are done from ESD
325 if(TMath::Abs(vertex.At(2)) > fZvtxCut) {
329 for(Int_t i = 0 ;i<nTracks;i++) {
330 particle = (AliMCParticle*) mcevent->GetTrack(i);
335 if(stack->IsPhysicalPrimary(i) && particle->Charge() != 0) {
338 TH2F* hPrimaryInner = (TH2F*)fListOfPrimaries.FindObject( Form("hPrimary_FMD_%c_vtx%d",'I',vertexBin));
339 TH2F* hPrimaryOuter = (TH2F*)fListOfPrimaries.FindObject( Form("hPrimary_FMD_%c_vtx%d",'O',vertexBin));
340 hPrimaryInner->Fill(particle->Eta(),particle->Phi());
341 hPrimaryOuter->Fill(particle->Eta(),particle->Phi());
342 if( isTriggeredNSD) {
343 TH2F* hPrimaryInnerNSD = (TH2F*)fListOfPrimaries.FindObject( Form("hPrimaryNSD_FMD_%c_vtx%d",'I',vertexBin));
344 TH2F* hPrimaryOuterNSD = (TH2F*)fListOfPrimaries.FindObject( Form("hPrimaryNSD_FMD_%c_vtx%d",'O',vertexBin));
345 hPrimaryInnerNSD->Fill(particle->Eta(),particle->Phi());
346 hPrimaryOuterNSD->Fill(particle->Eta(),particle->Phi());
348 TH2F* hAnalysedInner = (TH2F*)fListOfPrimaries.FindObject( Form("Analysed_FMD%c_vtx%d",'I',vertexBin));
349 TH2F* hAnalysedOuter = (TH2F*)fListOfPrimaries.FindObject( Form("Analysed_FMD%c_vtx%d",'O',vertexBin));
350 TH2F* hAnalysedNSDInner = (TH2F*)fListOfPrimaries.FindObject( Form("AnalysedNSD_FMD%c_vtx%d",'I',vertexBin));
351 TH2F* hAnalysedNSDOuter = (TH2F*)fListOfPrimaries.FindObject( Form("AnalysedNSD_FMD%c_vtx%d",'O',vertexBin));
352 TH2F* hInelInner = (TH2F*)fListOfPrimaries.FindObject( Form("Inel_FMD%c_vtx%d",'I',vertexBin));
353 TH2F* hInelOuter = (TH2F*)fListOfPrimaries.FindObject( Form("Inel_FMD%c_vtx%d",'O',vertexBin));
354 TH2F* hNSDInner = (TH2F*)fListOfPrimaries.FindObject( Form("NSD_FMD%c_vtx%d",'I',vertexBin));
355 TH2F* hNSDOuter = (TH2F*)fListOfPrimaries.FindObject( Form("NSD_FMD%c_vtx%d",'O',vertexBin));
357 //if(vtxFound && isTriggered) {
359 hAnalysedNSDInner->Fill(particle->Eta(),particle->Phi());
360 hAnalysedNSDOuter->Fill(particle->Eta(),particle->Phi());
363 hAnalysedInner->Fill(particle->Eta(),particle->Phi());
364 hAnalysedOuter->Fill(particle->Eta(),particle->Phi());
366 hInelInner->Fill(particle->Eta(),particle->Phi());
367 hInelOuter->Fill(particle->Eta(),particle->Phi());
370 hNSDInner->Fill(particle->Eta(),particle->Phi());
371 hNSDOuter->Fill(particle->Eta(),particle->Phi());
375 for(Int_t j=0; j<particle->GetNumberOfTrackReferences();j++) {
377 AliTrackReference* ref = particle->GetTrackReference(j);
379 if(ref->DetectorId() != AliTrackReference::kFMD)
382 AliFMDStripIndex::Unpack(ref->UserId(),det,ring,sec,strip);
383 Float_t thisStripTrack = fLastTrackByStrip(det,ring,sec,strip);
384 if(particle->Charge() != 0 && i != thisStripTrack ) {
386 Float_t phi = pars->GetPhiFromSector(det,ring,sec);
387 Float_t eta = pars->GetEtaFromStrip(det,ring,sec,strip,vertex.At(2));
389 TH2F* hHits = (TH2F*)fListOfHits.FindObject(Form("hHits_FMD%d%c_vtx%d", det,ring,vertexBin));
390 hHits->Fill(eta,phi);
391 if( isTriggeredNSD) {
392 TH2F* hHitsNSD = (TH2F*)fListOfHits.FindObject(Form("hHitsNSD_FMD%d%c_vtx%d", det,ring,vertexBin));
393 hHitsNSD->Fill(eta,phi);
396 Float_t nstrips = (ring =='O' ? 256 : 512);
397 fHitsByStrip(det,ring,sec,strip) +=1;
398 TH1F* allHits = (TH1F*)fListOfHits.FindObject(Form("allHits_FMD%d%c",det,ring));
399 TH1F* doubleHits = (TH1F*)fListOfHits.FindObject(Form("DoubleHits_FMD%d%c",det,ring));
401 if(fHitsByStrip(det,ring,sec,strip) == 1)
404 doubleHits->Fill(eta);
406 fLastTrackByStrip(det,ring,sec,strip) = (Float_t)i;
408 fLastTrackByStrip(det,ring,sec,strip-1) = (Float_t)i;
409 if(strip < (nstrips - 1))
410 fLastTrackByStrip(det,ring,sec,strip+1) = (Float_t)i;
417 TH2F* hSPDMult = (TH2F*)fListOfHits.FindObject(Form("hSPDhits_vtx%d", vertexBin));
419 const AliMultiplicity* spdmult = esdevent->GetMultiplicity();
420 for(Int_t j = 0; j< spdmult->GetNumberOfTracklets();j++)
421 hSPDMult->Fill(spdmult->GetEta(j),spdmult->GetPhi(j));
423 for(Int_t j = 0; j< spdmult->GetNumberOfSingleClusters();j++)
424 hSPDMult->Fill(-TMath::Log(TMath::Tan(spdmult->GetThetaSingle(j)/2.)),spdmult->GetPhiSingle(j));
427 PostData(1, &fListOfHits);
428 PostData(2, &fListOfPrimaries);
429 PostData(3, &fVertexBins);
431 //_____________________________________________________________________
432 void AliFMDAnalysisTaskGenerateCorrection::Terminate(Option_t */*option*/)
434 /* TH1F* allHits = (TH1F*)fListOfHits.FindObject("allHits");
435 TH1F* doubleHits = (TH1F*)fListOfHits.FindObject("DoubleHits");
437 doubleHits->Divide(allHits);
438 GenerateCorrection();
439 PostData(1, &fListOfHits);
440 PostData(4, &fListOfCorrection);*/
443 //_____________________________________________________________________
444 void AliFMDAnalysisTaskGenerateCorrection::GenerateCorrection() {
446 fBackground = new AliFMDAnaCalibBackgroundCorrection();
447 fEventSelectionEff = new AliFMDAnaCalibEventSelectionEfficiency();
450 TH1F* hEventsSelected = (TH1F*)fListOfHits.FindObject("EventsSelected");
451 TH1F* hEventsSelectedVtx = (TH1F*)fListOfHits.FindObject("EventsSelectedVtx");
452 TH1F* hEventsSelectedTrigger = (TH1F*)fListOfHits.FindObject("EventsSelectedTrigger");
453 TH1F* hEventsSelectedNSDVtx = (TH1F*)fListOfHits.FindObject("EventsSelectedNSDVtx");
454 TH1F* hEventsSelectedNSD = (TH1F*)fListOfHits.FindObject("EventsSelectedNSD");
456 TH1F* hEventsAll = (TH1F*)fListOfPrimaries.FindObject("EventsAll");
457 TH1F* hEventsAllNSD = (TH1F*)fListOfPrimaries.FindObject("EventsAllNSD");
458 TH1F* hEventsSelectedVtxDivByTr = (TH1F*)hEventsSelectedVtx->Clone("hEventsSelectedVtxDivByTr");
459 TH1F* hEventsSelectedNSDVtxDivByNSD = (TH1F*)hEventsSelectedNSDVtx->Clone("hEventsSelectedNSDVtxDivByNSD");
461 fListOfHits.Add(hEventsSelectedVtxDivByTr);
462 fListOfHits.Add(hEventsSelectedNSDVtxDivByNSD);
463 hEventsSelectedNSDVtxDivByNSD->Divide(hEventsSelectedNSD);
464 hEventsSelectedVtxDivByTr->Divide(hEventsSelectedTrigger);
466 for(Int_t v=0;v<fNvtxBins ; v++) {
467 TH2F* hAnalysedInner = (TH2F*)fListOfPrimaries.FindObject(Form("Analysed_FMD%c_vtx%d",'I',v));
468 TH2F* hAnalysedOuter = (TH2F*)fListOfPrimaries.FindObject(Form("Analysed_FMD%c_vtx%d",'O',v));
469 TH2F* hAnalysedNSDInner = (TH2F*)fListOfPrimaries.FindObject( Form("AnalysedNSD_FMD%c_vtx%d",'I',v));
470 TH2F* hAnalysedNSDOuter = (TH2F*)fListOfPrimaries.FindObject( Form("AnalysedNSD_FMD%c_vtx%d",'O',v));
472 TH2F* hInelInner = (TH2F*)fListOfPrimaries.FindObject(Form("Inel_FMD%c_vtx%d",'I',v));
473 TH2F* hInelOuter = (TH2F*)fListOfPrimaries.FindObject(Form("Inel_FMD%c_vtx%d",'O',v));
474 TH2F* hNSDInner = (TH2F*)fListOfPrimaries.FindObject( Form("NSD_FMD%c_vtx%d",'I',v));
475 TH2F* hNSDOuter = (TH2F*)fListOfPrimaries.FindObject( Form("NSD_FMD%c_vtx%d",'O',v));
476 // hAnalysedInner->Scale((hEventsSelected->GetBinContent(v+1) == 0 ? 0 : 1/hEventsSelected->GetBinContent(v+1)));
477 //hAnalysedOuter->Scale((hEventsSelected->GetBinContent(v+1) == 0 ? 0 : 1/hEventsSelected->GetBinContent(v+1)));
479 hAnalysedInner->Scale((hEventsSelectedTrigger->GetBinContent(v+1) == 0 ? 0 : 1/hEventsSelectedTrigger->GetBinContent(v+1)));
481 hAnalysedOuter->Scale((hEventsSelectedTrigger->GetBinContent(v+1) == 0 ? 0 : 1/hEventsSelectedTrigger->GetBinContent(v+1)));
482 hAnalysedNSDInner->Scale((hEventsSelectedNSD->GetBinContent(v+1) == 0 ? 0 : 1/hEventsSelectedNSD->GetBinContent(v+1)));
484 hAnalysedNSDOuter->Scale((hEventsSelectedNSD->GetBinContent(v+1) == 0 ? 0 : 1/hEventsSelectedNSD->GetBinContent(v+1)));
488 hInelInner->Scale((hEventsAll->GetBinContent(v+1) == 0 ? 0 : 1/hEventsAll->GetBinContent(v+1)));
489 hInelOuter->Scale((hEventsAll->GetBinContent(v+1) == 0 ? 0 : 1/hEventsAll->GetBinContent(v+1)));
491 hNSDInner->Scale((hEventsAllNSD->GetBinContent(v+1) == 0 ? 0 : 1/hEventsAllNSD->GetBinContent(v+1)));
492 hNSDOuter->Scale((hEventsAllNSD->GetBinContent(v+1) == 0 ? 0 : 1/hEventsAllNSD->GetBinContent(v+1)));
495 hAnalysedInner->Divide(hInelInner);
496 hAnalysedOuter->Divide(hInelOuter);
498 hAnalysedNSDInner->Divide(hNSDInner);
499 hAnalysedNSDOuter->Divide(hNSDOuter);
501 fEventSelectionEff->SetCorrection("INEL",v,'I',hAnalysedInner);
502 fEventSelectionEff->SetCorrection("INEL",v,'O',hAnalysedOuter);
504 fEventSelectionEff->SetCorrection("NSD",v,'I',hAnalysedNSDInner);
505 fEventSelectionEff->SetCorrection("NSD",v,'O',hAnalysedNSDOuter);
511 if(hEventsSelectedTrigger->GetEntries())
512 vtxEff = hEventsSelectedVtx->GetEntries() / hEventsSelectedTrigger->GetEntries();
513 fEventSelectionEff->SetVtxToTriggerRatio(vtxEff);
515 // hEventsAll->Divide(hEventsAll,hEventsSelected,1,1,"B");
516 hEventsSelectedVtx->Divide(hEventsAll);
517 hEventsSelectedTrigger->Divide(hEventsAll);
519 hEventsSelectedNSDVtx->Divide(hEventsAllNSD);
520 hEventsSelectedNSD->Divide(hEventsAllNSD);
522 for(Int_t i = 1; i<=hEventsSelected->GetNbinsX(); i++) {
523 if(hEventsSelected->GetBinContent(i) == 0 )
525 Float_t b = hEventsSelected->GetBinContent(i);
526 // Float_t b = hEventsSelected->GetBinContent(i)*hEventsSelectedTrigger->GetBinContent(i);
527 Float_t db = hEventsSelected->GetBinError(i);
528 Float_t sum = hEventsAll->GetBinContent(i);
529 Float_t dsum = hEventsAll->GetBinError(i);
531 Float_t da = TMath::Sqrt(TMath::Power(db,2) + TMath::Power(dsum,2));
533 Float_t cor = sum / b;
534 Float_t ecor = TMath::Sqrt(TMath::Power(da,2) + TMath::Power(a/(b*db),2)) / b;
536 hEventsAll->SetBinContent(i,cor);
537 hEventsAll->SetBinError(i,ecor);
541 //TH1F* hEventTest = (TH1F*)hEventsAll->Clone("hEventTest");
545 fEventSelectionEff->SetCorrection(hEventsAll);
547 for(Int_t det= 1; det <=3; det++) {
548 Int_t nRings = (det==1 ? 1 : 2);
550 for(Int_t iring = 0; iring<nRings; iring++) {
551 Char_t ring = (iring == 0 ? 'I' : 'O');
552 TH1F* allHits = (TH1F*)fListOfHits.FindObject(Form("allHits_FMD%d%c",det,ring));
553 TH1F* doubleHits = (TH1F*)fListOfHits.FindObject(Form("DoubleHits_FMD%d%c",det,ring));
554 allHits->Divide(doubleHits);
556 fBackground->SetDoubleHitCorrection(det,ring,allHits);
558 for(Int_t vertexBin=0;vertexBin<fNvtxBins ;vertexBin++) {
559 TH2F* hHits = (TH2F*)fListOfHits.FindObject(Form("hHits_FMD%d%c_vtx%d", det,ring,vertexBin));
560 TH2F* hPrimary = (TH2F*)fListOfPrimaries.FindObject( Form("hPrimary_FMD_%c_vtx%d",ring,vertexBin));
561 TH2F* hCorrection = (TH2F*)hHits->Clone(Form("FMD%d%c_vtxbin_%d_correction",det,ring,vertexBin));
562 hCorrection->Divide(hPrimary);
564 TH2F* hHitsNSD = (TH2F*)fListOfHits.FindObject(Form("hHitsNSD_FMD%d%c_vtx%d", det,ring,vertexBin));
565 TH2F* hPrimaryNSD = (TH2F*)fListOfPrimaries.FindObject( Form("hPrimaryNSD_FMD_%c_vtx%d",ring,vertexBin));
566 TH2F* hCorrectionNSD = (TH2F*)hHitsNSD->Clone(Form("FMDNSD%d%c_vtxbin_%d_correction",det,ring,vertexBin));
567 hCorrectionNSD->Divide(hPrimaryNSD);
570 hCorrection->SetTitle(hCorrection->GetName());
571 hCorrectionNSD->SetTitle(hCorrectionNSD->GetName());
573 fListOfCorrection.Add(hCorrection);
574 fListOfCorrection.Add(hCorrectionNSD);
575 fBackground->SetBgCorrection(det,ring,vertexBin,hCorrection);
576 fBackground->SetNSDBgCorrection(det,ring,vertexBin,hCorrectionNSD);
582 for(Int_t vertexBin=0;vertexBin<fNvtxBins ;vertexBin++) {
583 TH2F* hPrimary = (TH2F*)fListOfPrimaries.FindObject( Form("hPrimary_FMD_%c_vtx%d",'I',vertexBin));
584 TH2F* hSPDMult = (TH2F*)fListOfHits.FindObject(Form("hSPDhits_vtx%d", vertexBin));
585 if(!hSPDMult) continue;
587 TH2F* hCorrection = (TH2F*)hSPDMult->Clone(Form("SPD_vtxbin_%d_correction",vertexBin));
588 hCorrection->SetTitle(hCorrection->GetName());
589 fListOfCorrection.Add(hCorrection);
590 hCorrection->Divide(hPrimary);
591 fBackground->SetBgCorrection(0,'Q',vertexBin,hCorrection);
593 TH1F* hAlive = new TH1F(Form("hAliveSPD_vtxbin%d",vertexBin),Form("hAliveSPD_vtxbin%d",vertexBin),hSPDMult->GetNbinsX(),hSPDMult->GetXaxis()->GetXmin(), hSPDMult->GetXaxis()->GetXmax());
594 TH1F* hPresent = new TH1F(Form("hPresentSPD_vtxbin%d",vertexBin),Form("hPresentSPD_vtxbin%d",vertexBin),hSPDMult->GetNbinsX(),hSPDMult->GetXaxis()->GetXmin(), hSPDMult->GetXaxis()->GetXmax());
595 for(Int_t xx = 1; xx <=hSPDMult->GetNbinsX(); xx++) {
597 if(TMath::Abs(hCorrection->GetXaxis()->GetBinCenter(xx)) > 2)
599 for(Int_t yy = 1; yy <=hSPDMult->GetNbinsY(); yy++) {
600 if(hCorrection->GetBinContent(xx,yy) > 0.1)
601 hAlive->Fill(hCorrection->GetXaxis()->GetBinCenter(xx));
602 hPresent->Fill(hCorrection->GetXaxis()->GetBinCenter(xx));
606 TH1F* hDeadCorrection = (TH1F*)hAlive->Clone(Form("hSPDDeadCorrection_vtxbin%d",vertexBin));
607 hDeadCorrection->Divide(hPresent);
608 fBackground->SetSPDDeadCorrection(vertexBin,hDeadCorrection);
609 fListOfCorrection.Add(hDeadCorrection);
617 TAxis refAxis(fNvtxBins,-1*fZvtxCut,fZvtxCut);
618 fBackground->SetRefAxis(&refAxis);
621 //_____________________________________________________________________
622 void AliFMDAnalysisTaskGenerateCorrection::ReadFromFile(const Char_t* filename, Bool_t storeInOCDB, Int_t /*runNo*/) {
624 TFile infile(filename);
625 TH1F* hVertex = (TH1F*)infile.Get("VertexBins");
626 fZvtxCut = hVertex->GetXaxis()->GetXmax();
627 fNvtxBins = hVertex->GetXaxis()->GetNbins();
628 fVertexBins.SetName("VertexBins");
629 fVertexBins.GetXaxis()->Set(fNvtxBins,-1*fZvtxCut,fZvtxCut);
631 TList* listOfHits = (TList*)infile.Get("Hits");
632 TList* listOfPrim = (TList*)infile.Get("Primaries");
634 TH1F* hEventsSelected = (TH1F*)listOfHits->FindObject("EventsSelected");
635 TH1F* hEventsSelectedVtx = (TH1F*)listOfHits->FindObject("EventsSelectedVtx");
636 TH1F* hEventsSelectedTrigger = (TH1F*)listOfHits->FindObject("EventsSelectedTrigger");
637 TH1F* hEventsSelectedNSDVtx = (TH1F*)listOfHits->FindObject("EventsSelectedNSDVtx");
638 TH1F* hEventsSelectedNSD = (TH1F*)listOfHits->FindObject("EventsSelectedNSD");
639 TH1F* hEventsAll = (TH1F*)listOfPrim->FindObject("EventsAll");
640 TH1F* hEventsAllNSD = (TH1F*)listOfPrim->FindObject("EventsAllNSD");
642 fListOfHits.Add(hEventsSelected);
643 fListOfHits.Add(hEventsSelectedVtx);
644 fListOfHits.Add(hEventsSelectedNSD);
645 fListOfHits.Add(hEventsSelectedNSDVtx);
646 fListOfHits.Add(hEventsSelectedTrigger);
647 fListOfPrimaries.Add(hEventsAll);
648 fListOfPrimaries.Add(hEventsAllNSD);
650 TH1F* hXvtx = (TH1F*)listOfPrim->FindObject("hXvtx");
651 TH1F* hYvtx = (TH1F*)listOfPrim->FindObject("hYvtx");
652 TH1F* hZvtx = (TH1F*)listOfPrim->FindObject("hZvtx");
653 fListOfPrimaries.Add(hXvtx);
654 fListOfPrimaries.Add(hYvtx);
655 fListOfPrimaries.Add(hZvtx);
657 for(Int_t det =1; det<=3;det++)
659 Int_t nRings = (det==1 ? 1 : 2);
660 for(Int_t ring = 0;ring<nRings;ring++)
662 Char_t ringChar = (ring == 0 ? 'I' : 'O');
663 TH1F* allHits = (TH1F*)listOfHits->FindObject(Form("allHits_FMD%d%c",det,ringChar));
664 TH1F* doubleHits = (TH1F*)listOfHits->FindObject(Form("DoubleHits_FMD%d%c",det,ringChar));
665 fListOfHits.Add(allHits);
666 fListOfHits.Add(doubleHits);
667 for(Int_t v=0; v<fNvtxBins;v++)
670 TH2F* hHits = (TH2F*)listOfHits->FindObject(Form("hHits_FMD%d%c_vtx%d", det,ringChar,v));
671 fListOfHits.Add(hHits);
672 TH2F* hHitsNSD = (TH2F*)listOfHits->FindObject(Form("hHitsNSD_FMD%d%c_vtx%d", det,ringChar,v));
673 fListOfHits.Add(hHitsNSD);
677 for(Int_t v=0; v<fNvtxBins;v++) {
678 TH2F* hSPDHits = (TH2F*)listOfHits->FindObject(Form("hSPDhits_vtx%d", v));
679 fListOfHits.Add(hSPDHits);
681 for(Int_t iring = 0; iring<2;iring++) {
682 Char_t ringChar = (iring == 0 ? 'I' : 'O');
685 TH2F* hPrimary = (TH2F*)listOfPrim->FindObject( Form("hPrimary_FMD_%c_vtx%d",ringChar,v));
686 TH2F* hPrimaryNSD = (TH2F*)listOfPrim->FindObject( Form("hPrimaryNSD_FMD_%c_vtx%d",ringChar,v));
688 TH2F* hAnalysed = (TH2F*)listOfPrim->FindObject(Form("Analysed_FMD%c_vtx%d",ringChar,v));
689 TH2F* hAnalysedNSD = (TH2F*)listOfPrim->FindObject(Form("AnalysedNSD_FMD%c_vtx%d",ringChar,v));
690 TH2F* hInel = (TH2F*)listOfPrim->FindObject(Form("Inel_FMD%c_vtx%d",ringChar,v));
691 TH2F* hNSD = (TH2F*)listOfPrim->FindObject(Form("NSD_FMD%c_vtx%d",ringChar,v));
693 fListOfPrimaries.Add(hPrimary);
694 fListOfPrimaries.Add(hPrimaryNSD);
695 fListOfPrimaries.Add(hAnalysed);
696 fListOfPrimaries.Add(hInel);
697 fListOfPrimaries.Add(hAnalysedNSD);
698 fListOfPrimaries.Add(hNSD);
701 GenerateCorrection();
703 TFile fout("backgroundFromFile.root","recreate");
705 fListOfPrimaries.Write();
706 fListOfCorrection.Write();
710 AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
712 TFile fbg(pars->GetPath(pars->GetBackgroundID()),"RECREATE");
713 fBackground->Write(AliFMDAnaParameters::GetBackgroundID());
715 TFile feselect(pars->GetPath(pars->GetEventSelectionEffID()),"RECREATE");
716 fEventSelectionEff->Write(AliFMDAnaParameters::GetEventSelectionEffID());
725 //_____________________________________________________________________