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"
30 ClassImp(AliFMDAnalysisTaskGenerateCorrection)
32 ; // This is for emacs - do not delete
35 //_____________________________________________________________________
36 AliFMDAnalysisTaskGenerateCorrection::AliFMDAnalysisTaskGenerateCorrection():
48 fEventSelectionEff(0),
52 // Default constructor
54 //_____________________________________________________________________
55 AliFMDAnalysisTaskGenerateCorrection::AliFMDAnalysisTaskGenerateCorrection(const char* name):
56 AliAnalysisTaskSE(name),
67 fEventSelectionEff(0),
72 DefineOutput(1, TList::Class());
73 DefineOutput(2, TList::Class());
74 DefineOutput(3, TH1F::Class());
75 DefineOutput(4, TList::Class());
77 //_____________________________________________________________________
78 void AliFMDAnalysisTaskGenerateCorrection::UserCreateOutputObjects()
80 // Create the output containers
83 std::cout<<"Creating output objects"<<std::endl;
85 // SelectCollisionCandidates(AliVEvent::kAny);
87 for(Int_t v=0; v<fNvtxBins;v++) {
89 TH2F* hSPDhits = new TH2F(Form("hSPDhits_vtx%d",v),
90 Form("hSPDhits_vtx%d",v),
91 fNbinsEta, fEtaLow,fEtaHigh, 20, 0,2*TMath::Pi());
93 fListOfHits.Add(hSPDhits);
95 TH1F* hReadChannels = new TH1F(Form("hFMDReadChannels_vtx%d",v),
96 Form("hFMDReadChannels_vtx%d",v),
97 fNbinsEta,fEtaLow,fEtaHigh);
98 hReadChannels->Sumw2();
99 fListOfHits.Add(hReadChannels);
100 TH1F* hAllChannels = new TH1F(Form("hFMDAllChannels_vtx%d",v),
101 Form("hFMDAllChannels_vtx%d",v),
102 fNbinsEta,fEtaLow,fEtaHigh);
103 hAllChannels->Sumw2();
104 fListOfHits.Add(hAllChannels);
108 for(Int_t iring = 0; iring<2;iring++) {
109 Char_t ringChar = (iring == 0 ? 'I' : 'O');
110 Int_t nSec = (iring == 1 ? 40 : 20);
112 TH2F* hPrimary = new TH2F(Form("hPrimary_FMD_%c_vtx%d",ringChar,v),
113 Form("hPrimary_FMD_%c_vtx%d",ringChar,v),
114 fNbinsEta, fEtaLow,fEtaHigh, nSec, 0,2*TMath::Pi());
116 fListOfPrimaries.Add(hPrimary);
117 TH2F* hPrimaryNSD = new TH2F(Form("hPrimaryNSD_FMD_%c_vtx%d",ringChar,v),
118 Form("hPrimaryNSD_FMD_%c_vtx%d",ringChar,v),
119 fNbinsEta, fEtaLow,fEtaHigh, nSec, 0,2*TMath::Pi());
120 hPrimaryNSD->Sumw2();
121 fListOfPrimaries.Add(hPrimaryNSD);
131 for(Int_t det =1; det<=3;det++) {
132 Int_t nRings = (det==1 ? 1 : 2);
133 for(Int_t ring = 0;ring<nRings;ring++) {
134 Int_t nSec = (ring == 1 ? 40 : 20);
135 Char_t ringChar = (ring == 0 ? 'I' : 'O');
136 TH1F* doubleHits = new TH1F(Form("DoubleHits_FMD%d%c",det,ringChar),
137 Form("DoubleHits_FMD%d%c",det,ringChar),fNbinsEta, fEtaLow,fEtaHigh);
138 TH1F* allHits = new TH1F(Form("allHits_FMD%d%c",det,ringChar),
139 Form("allHits_FMD%d%c",det,ringChar), fNbinsEta, fEtaLow,fEtaHigh);
143 fListOfHits.Add(allHits);
144 fListOfHits.Add(doubleHits);
146 for(Int_t v=0; v<fNvtxBins;v++) {
147 TH2F* hHits = new TH2F(Form("hHits_FMD%d%c_vtx%d", det,ringChar,v),
148 Form("hHits_FMD%d%c_vtx%d", det,ringChar,v),
149 fNbinsEta, fEtaLow,fEtaHigh, nSec, 0, 2*TMath::Pi());
151 fListOfHits.Add(hHits);
152 TH2F* hHitsNSD = new TH2F(Form("hHitsNSD_FMD%d%c_vtx%d", det,ringChar,v),
153 Form("hHitsNSD_FMD%d%c_vtx%d", det,ringChar,v),
154 fNbinsEta, fEtaLow,fEtaHigh, nSec, 0, 2*TMath::Pi());
156 fListOfHits.Add(hHitsNSD);
163 TH1F* hEventsSelected = new TH1F("EventsSelected","EventsSelected",fNvtxBins,0,fNvtxBins);
164 TH1F* hEventsAll = new TH1F("EventsAll","EventsAll",fNvtxBins,0,fNvtxBins);
165 TH1F* hEventsAllNSD = new TH1F("EventsAllNSD","EventsAllNSD",fNvtxBins,0,fNvtxBins);
166 TH1F* hEventsSelectedVtx = new TH1F("EventsSelectedVtx","EventsSelectedVtx",fNvtxBins,0,fNvtxBins);
167 TH1F* hEventsSelectedTrigger = new TH1F("EventsSelectedTrigger","EventsSelectedTrigger",fNvtxBins,0,fNvtxBins);
169 TH1F* hEventsSelectedNSDVtx = new TH1F("EventsSelectedNSDVtx","EventsSelectedNSDVtx",fNvtxBins,0,fNvtxBins);
170 TH1F* hEventsSelectedNSD = new TH1F("EventsSelectedNSD","EventsSelectedNSD",fNvtxBins,0,fNvtxBins);
172 TH1F* hXvtx = new TH1F("hXvtx","x vertex distribution",100,-2,2);
173 TH1F* hYvtx = new TH1F("hYvtx","y vertex distribution",100,-2,2);
174 TH1F* hZvtx = new TH1F("hZvtx","z vertex distribution",4*fNvtxBins,-4*fZvtxCut,4*fZvtxCut);
176 fListOfPrimaries.Add(hXvtx);
177 fListOfPrimaries.Add(hYvtx);
178 fListOfPrimaries.Add(hZvtx);
180 hEventsSelected->Sumw2();
182 hEventsAllNSD->Sumw2();
184 fListOfHits.Add(hEventsSelected);
185 fListOfHits.Add(hEventsSelectedVtx);
186 fListOfHits.Add(hEventsSelectedTrigger);
187 fListOfHits.Add(hEventsSelectedNSDVtx);
188 fListOfHits.Add(hEventsSelectedNSD);
191 fListOfPrimaries.Add(hEventsAll);
192 fListOfPrimaries.Add(hEventsAllNSD);
194 for(Int_t v=0; v<fNvtxBins;v++) {
196 for(Int_t iring = 0; iring<2;iring++) {
197 Char_t ringChar = (iring == 0 ? 'I' : 'O');
198 Int_t nSec = (iring == 1 ? 40 : 20);
199 TH2F* hAnalysed = new TH2F(Form("Analysed_FMD%c_vtx%d",ringChar,v),
200 Form("Analysed_FMD%c_vtx%d",ringChar,v),
201 fNbinsEta, fEtaLow,fEtaHigh, nSec, 0,2*TMath::Pi());
204 fListOfPrimaries.Add(hAnalysed);
206 TH2F* hAnalysedNSD = new TH2F(Form("AnalysedNSD_FMD%c_vtx%d",ringChar,v),
207 Form("AnalysedNSD_FMD%c_vtx%d",ringChar,v),
208 fNbinsEta, fEtaLow,fEtaHigh, nSec, 0,2*TMath::Pi());
210 hAnalysedNSD->Sumw2();
211 fListOfPrimaries.Add(hAnalysedNSD);
213 TH2F* hInel = new TH2F(Form("Inel_FMD%c_vtx%d",ringChar,v),
214 Form("Inel_FMD%c_vtx%d",ringChar,v),
215 fNbinsEta, fEtaLow,fEtaHigh, nSec, 0,2*TMath::Pi());
218 fListOfPrimaries.Add(hInel);
220 TH2F* hNSD = new TH2F(Form("NSD_FMD%c_vtx%d",ringChar,v),
221 Form("NSD_FMD%c_vtx%d",ringChar,v),
222 fNbinsEta, fEtaLow,fEtaHigh, nSec, 0,2*TMath::Pi());
225 fListOfPrimaries.Add(hNSD);
230 fVertexBins.SetName("VertexBins");
231 fVertexBins.GetXaxis()->Set(fNvtxBins,-1*fZvtxCut,fZvtxCut);
236 //_____________________________________________________________________
237 void AliFMDAnalysisTaskGenerateCorrection::Init()
239 fLastTrackByStrip.Reset(-1);
243 //_____________________________________________________________________
244 void AliFMDAnalysisTaskGenerateCorrection::UserExec(Option_t */*option*/)
247 fLastTrackByStrip.Reset(-1);
248 fHitsByStrip.Reset(0);
249 AliMCEvent* mcevent = MCEvent();
251 AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
254 AliESDEvent* esdevent = (AliESDEvent*)InputEvent();
256 pars->SetTriggerStatus(esdevent);
258 Double_t esdvertex[3];
259 Bool_t vtxStatus = pars->GetVertex(esdevent,esdvertex);
261 /* Double_t deltaEsd = 2*fZvtxCut/fNvtxBins;
262 Double_t vertexBinDoubleEsd = (esdvertex[2] + fZvtxCut) / deltaEsd;
263 Int_t vertexBinEsd = (Int_t)vertexBinDoubleEsd;*/
265 AliMCParticle* particle = 0;
266 AliStack* stack = mcevent->Stack();
268 UShort_t det,sec,strip;
271 Int_t nTracks = mcevent->GetNumberOfTracks();
272 AliHeader* header = mcevent->Header();
273 AliGenEventHeader* genHeader = header->GenEventHeader();
275 AliGenPythiaEventHeader* pythiaGenHeader = dynamic_cast<AliGenPythiaEventHeader*>(genHeader);
276 AliGenDPMjetEventHeader* dpmHeader = dynamic_cast<AliGenDPMjetEventHeader*>(header->GenEventHeader());
278 if (!pythiaGenHeader && !dpmHeader) {
279 std::cout<<" no pythia or dpm header! - NSD selection unusable"<<std::endl;
283 if(pythiaGenHeader) {
284 Int_t pythiaType = pythiaGenHeader->ProcessType();
286 if(pythiaType==92 || pythiaType==93)
290 Int_t processType = dpmHeader->ProcessType();
291 if(processType == 5 || processType == 6)
298 genHeader->PrimaryVertex(vertex);
300 TH1F* hXvtx = (TH1F*)fListOfPrimaries.FindObject("hXvtx");
301 hXvtx->Fill(vertex.At(0));
302 TH1F* hYvtx = (TH1F*)fListOfPrimaries.FindObject("hYvtx");
303 hYvtx->Fill(vertex.At(1));
304 TH1F* hZvtx = (TH1F*)fListOfPrimaries.FindObject("hZvtx");
305 hZvtx->Fill(vertex.At(2));
310 Double_t delta = 2*fZvtxCut/fNvtxBins;
311 Double_t vertexBinDouble = (vertex.At(2) + fZvtxCut) / delta;
312 Int_t vertexBin = (Int_t)vertexBinDouble;
314 // Vertex determination correction
315 TH1F* hEventsSelected = (TH1F*)fListOfHits.FindObject("EventsSelected");
316 TH1F* hEventsSelectedVtx = (TH1F*)fListOfHits.FindObject("EventsSelectedVtx");
317 TH1F* hEventsSelectedTrigger = (TH1F*)fListOfHits.FindObject("EventsSelectedTrigger");
318 TH1F* hEventsSelectedNSDVtx = (TH1F*)fListOfHits.FindObject("EventsSelectedNSDVtx");
319 TH1F* hEventsSelectedNSD = (TH1F*)fListOfHits.FindObject("EventsSelectedNSD");
320 TH1F* hEventsAll = (TH1F*)fListOfPrimaries.FindObject("EventsAll");
321 TH1F* hEventsAllNSD = (TH1F*)fListOfPrimaries.FindObject("EventsAllNSD");
323 // TH1F* hTriggered = (TH1F*)fListOfHits.FindObject("Triggered");
324 // TH1F* hTriggeredAll = (TH1F*)fListOfPrimaries.FindObject("TriggeredAll");
326 Bool_t vtxFound = kTRUE;
330 //if(TMath::Abs(vertex.At(2)) > fZvtxCut) {
331 // vtxFound = kFALSE;
335 if(TMath::Abs(vertex.At(2)) > fZvtxCut) {
340 Bool_t isTriggered = pars->IsEventTriggered(AliFMDAnaParameters::kMB1);
341 Bool_t isTriggeredNSD = pars->IsEventTriggered(AliFMDAnaParameters::kNSD);
342 if(vtxFound && isTriggered) hEventsSelected->Fill(vertexBin);
344 if(vtxFound) hEventsSelectedVtx->Fill(vertexBin);
345 if(isTriggered) hEventsSelectedTrigger->Fill(vertexBin);
347 if(vtxFound && isTriggeredNSD) hEventsSelectedNSDVtx->Fill(vertexBin);
348 if(isTriggeredNSD) hEventsSelectedNSD->Fill(vertexBin);
351 hEventsAll->Fill(vertexBin);
352 if(nsd) hEventsAllNSD->Fill(vertexBin);
356 TH1F* hFMDReadChannels = (TH1F*)fListOfHits.FindObject(Form("hFMDReadChannels_vtx%d",vertexBin));
357 TH1F* hFMDAllChannels = (TH1F*)fListOfHits.FindObject(Form("hFMDAllChannels_vtx%d",vertexBin));
359 AliESDFMD* fmd = esdevent->GetFMDData();
361 for(UShort_t d=1;d<=3;d++) {
362 Int_t nRings = (d==1 ? 1 : 2);
363 for (UShort_t ir = 0; ir < nRings; ir++) {
364 Char_t r = (ir == 0 ? 'I' : 'O');
365 UShort_t nsec = (ir == 0 ? 20 : 40);
366 UShort_t nstr = (ir == 0 ? 512 : 256);
367 for(UShort_t s =0; s < nsec; s++) {
368 for(UShort_t str = 0; str < nstr; str++) {
369 Float_t mult = fmd->Multiplicity(d,r,s,str);
371 hFMDAllChannels->Fill(pars->GetEtaFromStrip(d,r,s,str,esdvertex[2]));
373 if(mult != AliESDFMD::kInvalidMult)
374 hFMDReadChannels->Fill(pars->GetEtaFromStrip(d,r,s,str,esdvertex[2]));
379 // End, FMD dead channels
381 for(Int_t i = 0 ;i<nTracks;i++) {
382 particle = (AliMCParticle*) mcevent->GetTrack(i);
387 if(stack->IsPhysicalPrimary(i) && particle->Charge() != 0) {
389 //if(vtxFound && isTriggered) {
390 TH2F* hPrimaryInner = (TH2F*)fListOfPrimaries.FindObject( Form("hPrimary_FMD_%c_vtx%d",'I',vertexBin));
391 TH2F* hPrimaryOuter = (TH2F*)fListOfPrimaries.FindObject( Form("hPrimary_FMD_%c_vtx%d",'O',vertexBin));
392 hPrimaryInner->Fill(particle->Eta(),particle->Phi());
393 hPrimaryOuter->Fill(particle->Eta(),particle->Phi());
394 if( isTriggeredNSD) {
395 TH2F* hPrimaryInnerNSD = (TH2F*)fListOfPrimaries.FindObject( Form("hPrimaryNSD_FMD_%c_vtx%d",'I',vertexBin));
396 TH2F* hPrimaryOuterNSD = (TH2F*)fListOfPrimaries.FindObject( Form("hPrimaryNSD_FMD_%c_vtx%d",'O',vertexBin));
397 hPrimaryInnerNSD->Fill(particle->Eta(),particle->Phi());
398 hPrimaryOuterNSD->Fill(particle->Eta(),particle->Phi());
401 TH2F* hAnalysedInner = (TH2F*)fListOfPrimaries.FindObject( Form("Analysed_FMD%c_vtx%d",'I',vertexBin));
402 TH2F* hAnalysedOuter = (TH2F*)fListOfPrimaries.FindObject( Form("Analysed_FMD%c_vtx%d",'O',vertexBin));
403 TH2F* hAnalysedNSDInner = (TH2F*)fListOfPrimaries.FindObject( Form("AnalysedNSD_FMD%c_vtx%d",'I',vertexBin));
404 TH2F* hAnalysedNSDOuter = (TH2F*)fListOfPrimaries.FindObject( Form("AnalysedNSD_FMD%c_vtx%d",'O',vertexBin));
405 TH2F* hInelInner = (TH2F*)fListOfPrimaries.FindObject( Form("Inel_FMD%c_vtx%d",'I',vertexBin));
406 TH2F* hInelOuter = (TH2F*)fListOfPrimaries.FindObject( Form("Inel_FMD%c_vtx%d",'O',vertexBin));
407 TH2F* hNSDInner = (TH2F*)fListOfPrimaries.FindObject( Form("NSD_FMD%c_vtx%d",'I',vertexBin));
408 TH2F* hNSDOuter = (TH2F*)fListOfPrimaries.FindObject( Form("NSD_FMD%c_vtx%d",'O',vertexBin));
410 //if(vtxFound && isTriggered) {
412 hAnalysedNSDInner->Fill(particle->Eta(),particle->Phi());
413 hAnalysedNSDOuter->Fill(particle->Eta(),particle->Phi());
415 if(isTriggered && vtxFound) {
416 hAnalysedInner->Fill(particle->Eta(),particle->Phi());
417 hAnalysedOuter->Fill(particle->Eta(),particle->Phi());
419 hInelInner->Fill(particle->Eta(),particle->Phi());
420 hInelOuter->Fill(particle->Eta(),particle->Phi());
423 hNSDInner->Fill(particle->Eta(),particle->Phi());
424 hNSDOuter->Fill(particle->Eta(),particle->Phi());
427 //if(!vtxFound || !isTriggered) continue;
429 for(Int_t j=0; j<particle->GetNumberOfTrackReferences();j++) {
431 AliTrackReference* ref = particle->GetTrackReference(j);
433 if(ref->DetectorId() != AliTrackReference::kFMD)
436 AliFMDStripIndex::Unpack(ref->UserId(),det,ring,sec,strip);
437 Float_t thisStripTrack = fLastTrackByStrip(det,ring,sec,strip);
438 if(particle->Charge() != 0 && i != thisStripTrack ) {
440 Float_t phi = pars->GetPhiFromSector(det,ring,sec);
441 Float_t eta = pars->GetEtaFromStrip(det,ring,sec,strip,vertex.At(2));
443 TH2F* hHits = (TH2F*)fListOfHits.FindObject(Form("hHits_FMD%d%c_vtx%d", det,ring,vertexBin));
444 hHits->Fill(eta,phi);
445 if( isTriggeredNSD) {
446 TH2F* hHitsNSD = (TH2F*)fListOfHits.FindObject(Form("hHitsNSD_FMD%d%c_vtx%d", det,ring,vertexBin));
447 hHitsNSD->Fill(eta,phi);
450 Float_t nstrips = (ring =='O' ? 256 : 512);
451 fHitsByStrip(det,ring,sec,strip) +=1;
452 TH1F* allHits = (TH1F*)fListOfHits.FindObject(Form("allHits_FMD%d%c",det,ring));
453 TH1F* doubleHits = (TH1F*)fListOfHits.FindObject(Form("DoubleHits_FMD%d%c",det,ring));
455 if(fHitsByStrip(det,ring,sec,strip) == 1)
458 doubleHits->Fill(eta);
460 fLastTrackByStrip(det,ring,sec,strip) = (Float_t)i;
462 fLastTrackByStrip(det,ring,sec,strip-1) = (Float_t)i;
463 if(strip < (nstrips - 1))
464 fLastTrackByStrip(det,ring,sec,strip+1) = (Float_t)i;
471 if(vtxFound && isTriggered) {
473 TH2F* hSPDMult = (TH2F*)fListOfHits.FindObject(Form("hSPDhits_vtx%d", vertexBin));
475 const AliMultiplicity* spdmult = esdevent->GetMultiplicity();
476 for(Int_t j = 0; j< spdmult->GetNumberOfTracklets();j++)
477 hSPDMult->Fill(spdmult->GetEta(j),spdmult->GetPhi(j));
479 for(Int_t j = 0; j< spdmult->GetNumberOfSingleClusters();j++)
480 hSPDMult->Fill(-TMath::Log(TMath::Tan(spdmult->GetThetaSingle(j)/2.)),spdmult->GetPhiSingle(j));
484 PostData(1, &fListOfHits);
485 PostData(2, &fListOfPrimaries);
486 PostData(3, &fVertexBins);
488 //_____________________________________________________________________
489 void AliFMDAnalysisTaskGenerateCorrection::Terminate(Option_t */*option*/)
491 /* TH1F* allHits = (TH1F*)fListOfHits.FindObject("allHits");
492 TH1F* doubleHits = (TH1F*)fListOfHits.FindObject("DoubleHits");
494 doubleHits->Divide(allHits);
495 GenerateCorrection();
496 PostData(1, &fListOfHits);
497 PostData(4, &fListOfCorrection);*/
500 //_____________________________________________________________________
501 void AliFMDAnalysisTaskGenerateCorrection::GenerateCorrection() {
503 fBackground = new AliFMDAnaCalibBackgroundCorrection();
504 fEventSelectionEff = new AliFMDAnaCalibEventSelectionEfficiency();
507 TH1F* hEventsSelected = (TH1F*)fListOfHits.FindObject("EventsSelected");
508 TH1F* hEventsSelectedVtx = (TH1F*)fListOfHits.FindObject("EventsSelectedVtx");
509 TH1F* hEventsSelectedTrigger = (TH1F*)fListOfHits.FindObject("EventsSelectedTrigger");
510 TH1F* hEventsSelectedNSDVtx = (TH1F*)fListOfHits.FindObject("EventsSelectedNSDVtx");
511 TH1F* hEventsSelectedNSD = (TH1F*)fListOfHits.FindObject("EventsSelectedNSD");
513 TH1F* hEventsAll = (TH1F*)fListOfPrimaries.FindObject("EventsAll");
514 TH1F* hEventsAllNSD = (TH1F*)fListOfPrimaries.FindObject("EventsAllNSD");
515 TH1F* hEventsSelectedVtxDivByTr = (TH1F*)hEventsSelectedVtx->Clone("hEventsSelectedVtxDivByTr");
516 TH1F* hEventsSelectedNSDVtxDivByNSD = (TH1F*)hEventsSelectedNSDVtx->Clone("hEventsSelectedNSDVtxDivByNSD");
518 fListOfHits.Add(hEventsSelectedVtxDivByTr);
519 fListOfHits.Add(hEventsSelectedNSDVtxDivByNSD);
520 hEventsSelectedNSDVtxDivByNSD->Divide(hEventsSelectedNSD);
521 hEventsSelectedVtxDivByTr->Divide(hEventsSelectedTrigger);
523 for(Int_t v=0;v<fNvtxBins ; v++) {
524 TH2F* hAnalysedInner = (TH2F*)fListOfPrimaries.FindObject(Form("Analysed_FMD%c_vtx%d",'I',v));
525 TH2F* hAnalysedOuter = (TH2F*)fListOfPrimaries.FindObject(Form("Analysed_FMD%c_vtx%d",'O',v));
526 TH2F* hAnalysedNSDInner = (TH2F*)fListOfPrimaries.FindObject( Form("AnalysedNSD_FMD%c_vtx%d",'I',v));
527 TH2F* hAnalysedNSDOuter = (TH2F*)fListOfPrimaries.FindObject( Form("AnalysedNSD_FMD%c_vtx%d",'O',v));
529 TH2F* hInelInner = (TH2F*)fListOfPrimaries.FindObject(Form("Inel_FMD%c_vtx%d",'I',v));
530 TH2F* hInelOuter = (TH2F*)fListOfPrimaries.FindObject(Form("Inel_FMD%c_vtx%d",'O',v));
531 TH2F* hNSDInner = (TH2F*)fListOfPrimaries.FindObject( Form("NSD_FMD%c_vtx%d",'I',v));
532 TH2F* hNSDOuter = (TH2F*)fListOfPrimaries.FindObject( Form("NSD_FMD%c_vtx%d",'O',v));
533 // hAnalysedInner->Scale((hEventsSelected->GetBinContent(v+1) == 0 ? 0 : 1/hEventsSelected->GetBinContent(v+1)));
534 //hAnalysedOuter->Scale((hEventsSelected->GetBinContent(v+1) == 0 ? 0 : 1/hEventsSelected->GetBinContent(v+1)));
536 hAnalysedInner->Scale((hEventsSelectedTrigger->GetBinContent(v+1) == 0 ? 0 : 1/hEventsSelectedTrigger->GetBinContent(v+1)));
538 hAnalysedOuter->Scale((hEventsSelectedTrigger->GetBinContent(v+1) == 0 ? 0 : 1/hEventsSelectedTrigger->GetBinContent(v+1)));
539 hAnalysedNSDInner->Scale((hEventsSelectedNSD->GetBinContent(v+1) == 0 ? 0 : 1/hEventsSelectedNSD->GetBinContent(v+1)));
541 hAnalysedNSDOuter->Scale((hEventsSelectedNSD->GetBinContent(v+1) == 0 ? 0 : 1/hEventsSelectedNSD->GetBinContent(v+1)));
545 hInelInner->Scale((hEventsAll->GetBinContent(v+1) == 0 ? 0 : 1/hEventsAll->GetBinContent(v+1)));
546 hInelOuter->Scale((hEventsAll->GetBinContent(v+1) == 0 ? 0 : 1/hEventsAll->GetBinContent(v+1)));
548 hNSDInner->Scale((hEventsAllNSD->GetBinContent(v+1) == 0 ? 0 : 1/hEventsAllNSD->GetBinContent(v+1)));
549 hNSDOuter->Scale((hEventsAllNSD->GetBinContent(v+1) == 0 ? 0 : 1/hEventsAllNSD->GetBinContent(v+1)));
552 hAnalysedInner->Divide(hInelInner);
553 hAnalysedOuter->Divide(hInelOuter);
555 hAnalysedNSDInner->Divide(hNSDInner);
556 hAnalysedNSDOuter->Divide(hNSDOuter);
558 fEventSelectionEff->SetCorrection("INEL",v,'I',hAnalysedInner);
559 fEventSelectionEff->SetCorrection("INEL",v,'O',hAnalysedOuter);
561 fEventSelectionEff->SetCorrection("NSD",v,'I',hAnalysedNSDInner);
562 fEventSelectionEff->SetCorrection("NSD",v,'O',hAnalysedNSDOuter);
565 TH1F* hFMDReadChannels = (TH1F*)fListOfHits.FindObject(Form("hFMDReadChannels_vtx%d",v));
567 TH1F* hFMDAllChannels = (TH1F*)fListOfHits.FindObject(Form("hFMDAllChannels_vtx%d",v));
568 if(hFMDReadChannels) {
569 TH1F* hFMDDeadCorrection = (TH1F*)hFMDReadChannels->Clone("hFMDDeadCorrection");
570 hFMDDeadCorrection->Divide(hFMDAllChannels);
571 fBackground->SetFMDDeadCorrection(v,hFMDDeadCorrection);
572 fListOfCorrection.Add(hFMDDeadCorrection);
574 else AliWarning("No Dead Channel Correction generated");
579 if(hEventsSelectedTrigger->GetEntries())
580 vtxEff = hEventsSelectedVtx->GetEntries() / hEventsSelectedTrigger->GetEntries();
581 fEventSelectionEff->SetVtxToTriggerRatio(vtxEff);
583 // hEventsAll->Divide(hEventsAll,hEventsSelected,1,1,"B");
584 hEventsSelectedVtx->Divide(hEventsAll);
585 hEventsSelectedTrigger->Divide(hEventsAll);
587 hEventsSelectedNSDVtx->Divide(hEventsAllNSD);
588 hEventsSelectedNSD->Divide(hEventsAllNSD);
590 for(Int_t i = 1; i<=hEventsSelected->GetNbinsX(); i++) {
591 if(hEventsSelected->GetBinContent(i) == 0 )
593 Float_t b = hEventsSelected->GetBinContent(i);
594 // Float_t b = hEventsSelected->GetBinContent(i)*hEventsSelectedTrigger->GetBinContent(i);
595 Float_t db = hEventsSelected->GetBinError(i);
596 Float_t sum = hEventsAll->GetBinContent(i);
597 Float_t dsum = hEventsAll->GetBinError(i);
599 Float_t da = TMath::Sqrt(TMath::Power(db,2) + TMath::Power(dsum,2));
601 Float_t cor = sum / b;
602 Float_t ecor = TMath::Sqrt(TMath::Power(da,2) + TMath::Power(a/(b*db),2)) / b;
604 hEventsAll->SetBinContent(i,cor);
605 hEventsAll->SetBinError(i,ecor);
609 //TH1F* hEventTest = (TH1F*)hEventsAll->Clone("hEventTest");
613 fEventSelectionEff->SetCorrection(hEventsAll);
615 for(Int_t det= 1; det <=3; det++) {
616 Int_t nRings = (det==1 ? 1 : 2);
618 for(Int_t iring = 0; iring<nRings; iring++) {
619 Char_t ring = (iring == 0 ? 'I' : 'O');
620 TH1F* allHits = (TH1F*)fListOfHits.FindObject(Form("allHits_FMD%d%c",det,ring));
621 TH1F* doubleHits = (TH1F*)fListOfHits.FindObject(Form("DoubleHits_FMD%d%c",det,ring));
622 allHits->Divide(doubleHits);
624 fBackground->SetDoubleHitCorrection(det,ring,allHits);
626 for(Int_t vertexBin=0;vertexBin<fNvtxBins ;vertexBin++) {
627 TH2F* hHits = (TH2F*)fListOfHits.FindObject(Form("hHits_FMD%d%c_vtx%d", det,ring,vertexBin));
628 TH2F* hPrimary = (TH2F*)fListOfPrimaries.FindObject( Form("hPrimary_FMD_%c_vtx%d",ring,vertexBin));
629 TH2F* hCorrection = (TH2F*)hHits->Clone(Form("FMD%d%c_vtxbin_%d_correction",det,ring,vertexBin));
630 hCorrection->Divide(hPrimary);
632 TH2F* hHitsNSD = (TH2F*)fListOfHits.FindObject(Form("hHitsNSD_FMD%d%c_vtx%d", det,ring,vertexBin));
633 TH2F* hPrimaryNSD = (TH2F*)fListOfPrimaries.FindObject( Form("hPrimaryNSD_FMD_%c_vtx%d",ring,vertexBin));
634 TH2F* hCorrectionNSD = 0;
635 if(hHitsNSD && hPrimaryNSD) {
636 hCorrectionNSD = (TH2F*)hHitsNSD->Clone(Form("FMDNSD%d%c_vtxbin_%d_correction",det,ring,vertexBin));
637 hCorrectionNSD->Divide(hPrimaryNSD);
640 hCorrection->SetTitle(hCorrection->GetName());
641 fListOfCorrection.Add(hCorrection);
642 fBackground->SetBgCorrection(det,ring,vertexBin,hCorrection);
645 fBackground->SetNSDBgCorrection(det,ring,vertexBin,hCorrectionNSD);
646 hCorrectionNSD->SetTitle(hCorrectionNSD->GetName());
647 fListOfCorrection.Add(hCorrectionNSD);
654 for(Int_t vertexBin=0;vertexBin<fNvtxBins ;vertexBin++) {
655 TH2F* hPrimary = (TH2F*)fListOfPrimaries.FindObject( Form("hPrimary_FMD_%c_vtx%d",'I',vertexBin));
656 TH2F* hSPDMult = (TH2F*)fListOfHits.FindObject(Form("hSPDhits_vtx%d", vertexBin));
657 if(!hSPDMult) continue;
659 TH2F* hCorrection = (TH2F*)hSPDMult->Clone(Form("SPD_vtxbin_%d_correction",vertexBin));
660 hCorrection->SetTitle(hCorrection->GetName());
661 fListOfCorrection.Add(hCorrection);
662 hCorrection->Divide(hPrimary);
665 TH1F* hAlive = new TH1F(Form("hAliveSPD_vtxbin%d",vertexBin),Form("hAliveSPD_vtxbin%d",vertexBin),hSPDMult->GetNbinsX(),hSPDMult->GetXaxis()->GetXmin(), hSPDMult->GetXaxis()->GetXmax());
666 TH1F* hPresent = new TH1F(Form("hPresentSPD_vtxbin%d",vertexBin),Form("hPresentSPD_vtxbin%d",vertexBin),hSPDMult->GetNbinsX(),hSPDMult->GetXaxis()->GetXmin(), hSPDMult->GetXaxis()->GetXmax());
667 for(Int_t xx = 1; xx <=hSPDMult->GetNbinsX(); xx++) {
671 for(Int_t yy = 1; yy <=hSPDMult->GetNbinsY(); yy++) {
672 if(TMath::Abs(hCorrection->GetXaxis()->GetBinCenter(xx)) > 1.9) {
673 hCorrection->SetBinContent(xx,yy,0.);
674 hCorrection->SetBinError(xx,yy,0.);
677 if(hCorrection->GetBinContent(xx,yy) > 0.9) {
678 hAlive->Fill(hCorrection->GetXaxis()->GetBinCenter(xx) );
681 hCorrection->SetBinContent(xx,yy,0.);
682 hCorrection->SetBinError(xx,yy,0.);
685 hPresent->Fill(hCorrection->GetXaxis()->GetBinCenter(xx));
689 TH1F* hDeadCorrection = (TH1F*)hAlive->Clone(Form("hSPDDeadCorrection_vtxbin%d",vertexBin));
690 hDeadCorrection->Divide(hPresent);
691 fBackground->SetSPDDeadCorrection(vertexBin,hDeadCorrection);
692 fListOfCorrection.Add(hDeadCorrection);
694 fBackground->SetBgCorrection(0,'Q',vertexBin,hCorrection);
698 TAxis refAxis(fNvtxBins,-1*fZvtxCut,fZvtxCut);
699 fBackground->SetRefAxis(&refAxis);
702 //_____________________________________________________________________
703 void AliFMDAnalysisTaskGenerateCorrection::ReadFromFile(const Char_t* filename, Bool_t storeInOCDB, Int_t /*runNo*/) {
705 TFile infile(filename);
706 TH1F* hVertex = (TH1F*)infile.Get("VertexBins");
707 fZvtxCut = hVertex->GetXaxis()->GetXmax();
708 fNvtxBins = hVertex->GetXaxis()->GetNbins();
709 fVertexBins.SetName("VertexBins");
710 fVertexBins.GetXaxis()->Set(fNvtxBins,-1*fZvtxCut,fZvtxCut);
712 TList* listOfHits = (TList*)infile.Get("Hits");
713 TList* listOfPrim = (TList*)infile.Get("Primaries");
715 TH1F* hEventsSelected = (TH1F*)listOfHits->FindObject("EventsSelected");
716 TH1F* hEventsSelectedVtx = (TH1F*)listOfHits->FindObject("EventsSelectedVtx");
717 TH1F* hEventsSelectedTrigger = (TH1F*)listOfHits->FindObject("EventsSelectedTrigger");
718 TH1F* hEventsSelectedNSDVtx = (TH1F*)listOfHits->FindObject("EventsSelectedNSDVtx");
719 TH1F* hEventsSelectedNSD = (TH1F*)listOfHits->FindObject("EventsSelectedNSD");
720 TH1F* hEventsAll = (TH1F*)listOfPrim->FindObject("EventsAll");
721 TH1F* hEventsAllNSD = (TH1F*)listOfPrim->FindObject("EventsAllNSD");
723 fListOfHits.Add(hEventsSelected);
724 fListOfHits.Add(hEventsSelectedVtx);
725 fListOfHits.Add(hEventsSelectedNSD);
726 fListOfHits.Add(hEventsSelectedNSDVtx);
727 fListOfHits.Add(hEventsSelectedTrigger);
728 fListOfPrimaries.Add(hEventsAll);
729 fListOfPrimaries.Add(hEventsAllNSD);
731 TH1F* hXvtx = (TH1F*)listOfPrim->FindObject("hXvtx");
732 TH1F* hYvtx = (TH1F*)listOfPrim->FindObject("hYvtx");
733 TH1F* hZvtx = (TH1F*)listOfPrim->FindObject("hZvtx");
734 fListOfPrimaries.Add(hXvtx);
735 fListOfPrimaries.Add(hYvtx);
736 fListOfPrimaries.Add(hZvtx);
738 for(Int_t det =1; det<=3;det++)
740 Int_t nRings = (det==1 ? 1 : 2);
741 for(Int_t ring = 0;ring<nRings;ring++)
743 Char_t ringChar = (ring == 0 ? 'I' : 'O');
744 TH1F* allHits = (TH1F*)listOfHits->FindObject(Form("allHits_FMD%d%c",det,ringChar));
745 TH1F* doubleHits = (TH1F*)listOfHits->FindObject(Form("DoubleHits_FMD%d%c",det,ringChar));
746 fListOfHits.Add(allHits);
747 fListOfHits.Add(doubleHits);
748 for(Int_t v=0; v<fNvtxBins;v++)
751 TH2F* hHits = (TH2F*)listOfHits->FindObject(Form("hHits_FMD%d%c_vtx%d", det,ringChar,v));
752 fListOfHits.Add(hHits);
753 TH2F* hHitsNSD = (TH2F*)listOfHits->FindObject(Form("hHitsNSD_FMD%d%c_vtx%d", det,ringChar,v));
755 fListOfHits.Add(hHitsNSD);
759 for(Int_t v=0; v<fNvtxBins;v++) {
760 TH2F* hSPDHits = (TH2F*)listOfHits->FindObject(Form("hSPDhits_vtx%d", v));
761 fListOfHits.Add(hSPDHits);
762 TH1F* hFMDReadChannels = (TH1F*)listOfHits->FindObject(Form("hFMDReadChannels_vtx%d",v));
763 TH1F* hFMDAllChannels = (TH1F*)listOfHits->FindObject(Form("hFMDAllChannels_vtx%d",v));
765 if(hFMDReadChannels && hFMDAllChannels) {
766 fListOfHits.Add(hFMDReadChannels);
767 fListOfHits.Add(hFMDAllChannels);
769 for(Int_t iring = 0; iring<2;iring++) {
770 Char_t ringChar = (iring == 0 ? 'I' : 'O');
773 TH2F* hPrimary = (TH2F*)listOfPrim->FindObject( Form("hPrimary_FMD_%c_vtx%d",ringChar,v));
774 TH2F* hPrimaryNSD = (TH2F*)listOfPrim->FindObject( Form("hPrimaryNSD_FMD_%c_vtx%d",ringChar,v));
776 TH2F* hAnalysed = (TH2F*)listOfPrim->FindObject(Form("Analysed_FMD%c_vtx%d",ringChar,v));
777 TH2F* hAnalysedNSD = (TH2F*)listOfPrim->FindObject(Form("AnalysedNSD_FMD%c_vtx%d",ringChar,v));
778 TH2F* hInel = (TH2F*)listOfPrim->FindObject(Form("Inel_FMD%c_vtx%d",ringChar,v));
779 TH2F* hNSD = (TH2F*)listOfPrim->FindObject(Form("NSD_FMD%c_vtx%d",ringChar,v));
781 fListOfPrimaries.Add(hPrimary);
783 fListOfPrimaries.Add(hPrimaryNSD);
784 fListOfPrimaries.Add(hAnalysed);
785 fListOfPrimaries.Add(hInel);
786 fListOfPrimaries.Add(hAnalysedNSD);
787 fListOfPrimaries.Add(hNSD);
790 GenerateCorrection();
792 TFile fout("backgroundFromFile.root","recreate");
794 fListOfPrimaries.Write();
795 fListOfCorrection.Write();
799 AliFMDAnaParameters* pars = AliFMDAnaParameters::Instance();
801 pars->SetBackgroundPath(".");
802 pars->SetEnergyPath(".");
803 pars->SetEventSelectionPath(".");
804 pars->SetSharingEfficiencyPath(".");
806 AliInfo(Form("Generating %s", pars->GetPath(pars->GetBackgroundID())));
807 TFile fbg(pars->GetPath(pars->GetBackgroundID()),"RECREATE");
808 fBackground->Write(AliFMDAnaParameters::GetBackgroundID());
811 AliInfo(Form("Generating %s", pars->GetPath(pars->GetEventSelectionEffID())));
812 TFile feselect(pars->GetPath(pars->GetEventSelectionEffID()),"RECREATE");
813 fEventSelectionEff->Write(AliFMDAnaParameters::GetEventSelectionEffID());
816 //_____________________________________________________________________