1 /*************************************************************************
2 * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 ///////////////////////////////////////////////////////////////////////////
17 // Class AliTrackletTaskMulti //
18 // Analysis task to produce data and MC histos needed for tracklets //
19 // dNdEta extraction in multiple bins in one go //
20 // Author: ruben.shahoyan@cern.ch //
21 ///////////////////////////////////////////////////////////////////////////
23 Important parameters to set:
24 1) make sure to initialize correct geometry in UserCreateOutputObjects
25 2) The cut on signal selection variable (delta, dphi ...) should be decided beforehand
36 #include "THnSparse.h"
39 #include "TObjArray.h"
40 #include "TGeoGlobalMagField.h"
42 #include "AliAnalysisManager.h"
44 #include "AliMultiplicity.h"
45 #include "AliESDEvent.h"
46 #include "AliESDInputHandler.h"
47 #include "AliESDInputHandlerRP.h"
48 #include "../ANALYSIS/EventMixing/AliMixEventInputHandler.h"
49 #include "AliCDBPath.h"
50 #include "AliCDBManager.h"
51 #include "AliCDBEntry.h"
52 #include "AliCDBStorage.h"
53 #include "AliGeomManager.h"
55 #include "AliESDVZERO.h"
56 #include "AliESDZDC.h"
57 #include "AliRunLoader.h"
58 #include "AliMCEventHandler.h"
59 #include "AliMCEvent.h"
60 #include "AliMCParticle.h"
62 #include "AliGenEventHeader.h"
63 #include "AliCentrality.h"
64 #include "../ITS/AliITSRecPoint.h"
65 #include "../ITS/AliITSgeomTGeo.h"
66 #include "../ITS/AliITSMultReconstructor.h"
70 #include "AliPhysicsSelection.h"
71 #include "AliTrackletTaskMulti.h"
72 #include "AliITSMultRecBg.h"
73 #include "AliGenEventHeader.h"
74 #include "AliGenHijingEventHeader.h"
75 #include "AliGenDPMjetEventHeader.h"
76 #include "AliESDtrackCuts.h"
78 ClassImp(AliTrackletTaskMulti)
80 // centrality percentile (inverted: 100% - most central)
81 //const Float_t AliTrackletTaskMulti::fgkCentPerc[] = {0,100};//{0,5,10,20,30};
82 const Float_t AliTrackletTaskMulti::fgkCentPerc[] = {0,5,10,20,30,40,50,60,70,80,90};
83 //{0,10,20,30,40,50,60,70,80,90,95,101};
85 const char* AliTrackletTaskMulti::fgCentSelName[] = {"V0M","FMD","TRK","TKL","CL0","CL1","V0MvsFMD","TKLvsV0M","ZEMvsZDC"};
87 const char* AliTrackletTaskMulti::fgkPDGNames[] = {
138 const int AliTrackletTaskMulti::fgkPDGCodes[] = {
189 const double kEtaBinWidth=0.25;
191 //________________________________________________________________________
192 /*//Default constructor
193 AliTrackletTaskMulti::AliTrackletTaskMulti(const char *name)
194 : AliAnalysisTaskSE(name),
196 //________________________________________________________________________
197 AliTrackletTaskMulti::AliTrackletTaskMulti(const char *name)
198 : AliAnalysisTaskSE(name),
202 fDoNormalReco(kFALSE),
203 fDoInjection(kFALSE),
208 fCheckReconstructables(kFALSE),
220 fHistosTrRcblPrim(0),
229 fScaleDTBySin2T(kFALSE),
230 fCutOnDThetaX(kFALSE),
233 fDThetaWindow(0.025),
235 fPhiOverlapCut(0.005),
239 fRemoveOverlaps(kFALSE),
255 fUseCentralityVar(kCentV0M)
259 DefineOutput(1, TList::Class());
261 SetScaleDThetaBySin2T();
273 //________________________________________________________________________
274 AliTrackletTaskMulti::~AliTrackletTaskMulti()
277 // histograms are in the output list and deleted when the output
278 // list is deleted by the TSelector dtor
279 if (fOutput && !AliAnalysisManager::GetAnalysisManager()->IsProofMode()) { //RRR
280 printf("Deleteing output\n");
287 delete fHistosTrData;
288 delete fHistosTrPrim;
290 delete fHistosTrComb;
291 delete fHistosTrCombU;
295 delete fHistosTrRcblPrim;
296 delete fHistosTrRcblSec;
297 delete fHistosCustom;
301 //________________________________________________________________________
302 void AliTrackletTaskMulti::UserCreateOutputObjects()
306 fOutput = new TList();
310 Bool_t needGeom = GetDoNormalReco() || GetDoInjection() || GetDoRotation() || GetDoMixing();
312 AliCDBManager *man = AliCDBManager::Instance();
314 Bool_t newGeom = kTRUE;
315 man->SetDefaultStorage("alien://Folder=/alice/simulation/2008/v4-15-Release/Residual");
318 AliCDBEntry* obj = man->Get("GRP/Geometry/Data",130844,8);
319 AliGeomManager::SetGeometry((TGeoManager*) obj->GetObject());
320 if (!AliGeomManager::ApplyAlignObjsToGeom("ITS",130844,6,-1)) AliFatal("Failed to misalign geometry");
324 AliCDBEntry* obj = man->Get("GRP/Geometry/Data",130845,7);
325 AliGeomManager::SetGeometry((TGeoManager*) obj->GetObject());
326 if (!AliGeomManager::ApplyAlignObjsToGeom("ITS",130845,5,-1)) AliFatal("Failed to misalign geometry");
330 man->SetDefaultStorage("alien://Folder=/alice/data/2010/OCDB"); //man->SetRun(137366);
331 AliCDBEntry* obj = man->Get("GRP/Geometry/Data",137366);
332 AliGeomManager::SetGeometry((TGeoManager*) obj->GetObject());
333 if (!AliGeomManager::ApplyAlignObjsToGeom("ITS",137366,-1,-1)) AliFatal("Failed to misalign geometry");
338 fNCentBins = sizeof(fgkCentPerc)/sizeof(Float_t)-1;
339 //---------------------------------------------Standard histos per tracklet type--->>
340 UInt_t hPattern = 0xffffffff;
341 fHistosTrData = BookHistosSet("TrData",hPattern);
342 hPattern &= ~(BIT(kHEtaZvSPD1)); // fill single clusters for "data" only
343 if (GetDoInjection()) fHistosTrInj = BookHistosSet("TrInj",hPattern);
344 if (GetDoRotation()) fHistosTrRot = BookHistosSet("TrRot",hPattern);
345 if (GetDoMixing()) fHistosTrMix = BookHistosSet("TrMix",hPattern);
347 fHistosTrPrim = BookHistosSet("TrPrim",hPattern);
348 fHistosTrSec = BookHistosSet("TrSec",hPattern);
349 fHistosTrComb = BookHistosSet("TrComb",hPattern);
350 fHistosTrCombU = BookHistosSet("TrCombU",hPattern);
351 if (fCheckReconstructables) {
352 fHistosTrRcblPrim = BookHistosSet("TrRcblPrim",hPattern);
353 fHistosTrRcblSec = BookHistosSet("TrRcblSec",hPattern);
356 //---------------------------------------------Standard histos per tracklet type---<<
358 //---------------------------------------------Custom Histos----------------------->>
359 // put here any non standard histos
360 fHistosCustom = BookCustomHistos();
362 //---------------------------------------------Custom Histos-----------------------<<
363 int nhist = fOutput->GetEntries();
364 for (int i=0;i<nhist;i++) {
365 TObject* hst = fOutput->At(i);
366 if (!hst || !(hst->InheritsFrom(TH1::Class()))) continue;
367 ((TH1*)hst)->Sumw2();
370 if (fUseCentralityVar<0||fUseCentralityVar>kNCentTypes) {
371 printf("Wrong centrality type %d\n",fUseCentralityVar);
374 AliInfo(Form("Centrality type selected: %s\n",fgCentSelName[fUseCentralityVar]));
375 PostData(1, fOutput);
379 //________________________________________________________________________
380 void AliTrackletTaskMulti::UserExec(Option_t *)
384 static Bool_t statOK = kFALSE;
390 Bool_t needRecPoints = GetDoNormalReco() || GetDoInjection() || GetDoRotation() || GetDoMixing();
392 AliAnalysisManager* anMan = AliAnalysisManager::GetAnalysisManager();
393 fRPTree = fRPTreeMix = 0;
394 AliESDInputHandler *handler = (AliESDInputHandler*)anMan->GetInputEventHandler();
395 AliESDInputHandlerRP *handRP = 0;
397 handRP = (AliESDInputHandlerRP*)handler;
398 if (!handRP) { printf("No RP handler\n"); return; }
400 AliESDEvent *esd = handler->GetEvent();
401 if (!esd) { printf("No AliESDEvent\n"); return; }
403 // do we need to initialize the field?
404 AliMagF* field = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
405 if (!field && !esd->InitMagneticField()) {printf("Failed to initialize the B field\n");return;}
408 TH1* hstat = (TH1*)fHistosCustom->UncheckedAt(kHStat);
409 hstat->Fill(kEvTot0); // RS
410 const AliESDVertex* vtxESD = esd->GetPrimaryVertexSPD();
411 const AliMultiplicity* multESD = esd->GetMultiplicity();
413 if (vtxESD->GetNContributors()<1) return;
414 TString vtxTyp = vtxESD->GetTitle();
415 if (vtxTyp.Contains("vertexer: Z")) {
416 if (vtxESD->GetDispersion()>0.04) return;
417 if (vtxESD->GetZRes()>0.25) return;
420 AliCentrality *centrality = esd->GetCentrality();
422 hstat->Fill(kEvTot); // RS
425 vtxESD->GetXYZ(esdvtx);
426 for (int i=3;i--;) fESDVtx[i] = esdvtx[i];
428 float vtxf[3] = {vtxESD->GetX(),vtxESD->GetY(),vtxESD->GetZ()};
430 // registed Ntracklets and ZVertex of the event
431 ((TH1*)fHistosCustom->UncheckedAt(kHZVtxNoSel))->Fill(esdvtx[2]);
433 if(vtxf[2] < fZVertexMin || vtxf[2] > fZVertexMax) return;
435 // centrality->Dump();
437 AliESDVZERO* esdV0 = esd->GetVZEROData();
439 multV0 = esdV0->GetMTotV0A()+esdV0->GetMTotV0C();
440 if (fUseMC) multV0 *= fMCV0Scale;
442 ((TH1*)fHistosCustom->UncheckedAt(kHV0NoSel))->Fill(multV0);
444 float nSPD2 = multESD->GetNumberOfITSClusters(1);
445 ((TH1*)fHistosCustom->UncheckedAt(kHNClSPD2NoSel))->Fill(nSPD2);
447 //------------------------------------------------------
448 AliESDZDC *esdZDC = esd->GetESDZDC();
449 float zdcEnergy=0,zemEnergy=0;
451 zdcEnergy = (esdZDC->GetZDCN1Energy() + esdZDC->GetZDCP1Energy() + esdZDC->GetZDCN2Energy()+ esdZDC->GetZDCP2Energy());
452 zemEnergy = (esdZDC->GetZDCEMEnergy(0)+esdZDC->GetZDCEMEnergy(1))/8.;
454 ((TH2*)fHistosCustom->UncheckedAt(kHZDCZEMNoSel))->Fill(zemEnergy,zdcEnergy);
456 Float_t centPercentile = centrality->GetCentralityPercentileUnchecked(fgCentSelName[fUseCentralityVar]);
458 // temporary >>>>>>>>>>>>>>>>>>>>>>>>
460 if (fUseCentralityVar==kCentZEMvsZDC) {
461 float zdcEn = zdcEnergy;
462 float zemEn = zemEnergy;
464 Float_t zdcPercentile;
466 slope = (zdcEn + 15000.)/(zemEn - 295.);
467 slope += 2.23660e+02;
468 zdcPercentile = (TMath::ATan(slope) - 1.56664)/8.99571e-05;
469 if (zdcPercentile<0) zdcPercentile = 0;
471 else zdcPercentile = 100;
472 centPercentile = zdcPercentile;
474 else if (fUseMC && fUseCentralityVar==kCentV0M) {
475 static TH1* fHtempV0M = 0;
477 TString flcp = Form("%s/COMMON/CENTRALITY/data/pass%d/AliCentralityBy1D_%d.root", AliAnalysisManager::GetOADBPath(), 2, 139172);
478 gSystem->ExpandPathName(flcp);
479 TFile* flc = TFile::Open(flcp);
480 fHtempV0M = (TH1*) (flc->Get("hmultV0_percentile"));
481 fHtempV0M->SetDirectory(0);
484 printf("Getting V0 centrality histo from %s -> %p\n",flcp.Data(),fHtempV0M);
486 if (!fHtempV0M) AliFatal("No V0 centrality histo");
487 centPercentile = fHtempV0M->GetBinContent(fHtempV0M->FindBin((multV0)));
490 // temporary >>>>>>>>>>>>>>>>>>>>>>>>
492 fCurrCentBin = GetCentralityBin(centPercentile);
494 printf("CentPerc: %f : Bin %d ZDC: %f ZEM: %f\n",centPercentile, fCurrCentBin, zdcEnergy,zemEnergy);
495 if (fCurrCentBin<0) {
496 //printf("Reject: %.1f : V0:%.1f V0Cor:%.1f V0CR:%.1f SPD2c:%.1f\n",mltTst, multV0,multV0Corr,multV0CorrResc,nSPD2Corr);
500 ((TH1*)fHistosCustom->UncheckedAt(kHStatCentBin))->Fill(fCurrCentBin);
501 ((TH1*)fHistosCustom->UncheckedAt(kHStatCent))->Fill(centPercentile);
503 AliMCEventHandler* eventHandler = 0;
508 eventHandler = (AliMCEventHandler*)anMan->GetMCtruthEventHandler();
509 if (!eventHandler) { printf("ERROR: Could not retrieve MC event handler\n"); return; }
510 fMCEvent = eventHandler->MCEvent();
511 if (!fMCEvent) { printf("ERROR: Could not retrieve MC event\n"); return; }
512 fStack = fMCEvent->Stack();
513 if (!fStack) { printf("Stack not available\n"); return; }
517 fRPTree = handRP->GetTreeR("ITS");
518 if (!fRPTree) { AliError(" Invalid ITS cluster tree !\n"); return; }
521 // =============================================================================>>>
523 AliGenEventHeader* mcGenH = 0;
527 mcGenH = fMCEvent->GenEventHeader();
528 if (mcGenH->InheritsFrom(AliGenHijingEventHeader::Class())) {
529 AliGenHijingEventHeader* hHijing = (AliGenHijingEventHeader*)mcGenH;
530 fNPart = (hHijing->ProjectileParticipants()+hHijing->TargetParticipants())/2.;
531 fNBColl = hHijing->NN()+hHijing->NNw()+hHijing->NwN()+hHijing->NwNw();
533 else if (mcGenH->InheritsFrom(AliGenDPMjetEventHeader::Class())) {
534 AliGenDPMjetEventHeader* hDpmJet = (AliGenDPMjetEventHeader*)mcGenH;
535 fNPart = (hDpmJet->ProjectileParticipants()+hDpmJet->TargetParticipants())/2.;
536 fNBColl = hDpmJet->NN()+hDpmJet->NNw()+hDpmJet->NwN()+hDpmJet->NwNw();
538 else {} // unknown generator
541 // register Ntracklets and ZVertex of the event
542 ((TH2*)fHistosCustom->UncheckedAt(kHZVtx))->Fill(esdvtx[2],fCurrCentBin);
543 ((TH2*)fHistosCustom->UncheckedAt(kHV0))->Fill(multV0,fCurrCentBin);
544 ((TH2*)fHistosCustom->UncheckedAt(kHNClSPD2))->Fill(nSPD2,fCurrCentBin);
545 ((TH3*)fHistosCustom->UncheckedAt(kHZDCZEM))->Fill(zemEnergy,zdcEnergy,fCurrCentBin);
547 if (fUseMC) FillMCPrimaries();
549 // normal reconstruction
550 hstat->Fill(kBinEntries+kEvProcData + kEntriesPerBin*fCurrCentBin);
552 if (GetDoNormalReco() || GetDoInjection()) { // for the injection the normal reco should be done
554 fMultReco->Run(fRPTree, vtxf);
555 printf("Multiplicity Reconstructed:\n");
556 AliMultiplicity* mlt = fMultReco->GetMultiplicity();
557 if (mlt) mlt->Print();
558 if (GetDoNormalReco()) FillHistos(kData,mlt);
562 if (!GetDoNormalReco()) {
563 FillHistos(kData,multESD); // fill data histos from ESD
564 FillClusterInfoFromMult(multESD, vtxf[2] );
567 // Injection: it must come right after the normal reco since needs its results
568 if (GetDoInjection()) {
569 if (!fMultReco) InitMultReco(); // in principle, not needed, the reco is created above
570 fMultReco->SetRecType(AliITSMultRecBg::kBgInj);
571 fMultReco->Run(fRPTree, vtxf);
572 printf("Multiplicity from Injection:\n");
573 AliMultiplicity* mlt = fMultReco->GetMultiplicity();
574 if (mlt) mlt->Print();
575 hstat->Fill(kBinEntries + kEvProcInj + kEntriesPerBin*fCurrCentBin);
576 FillHistos(kBgInj,mlt);
580 if (GetDoRotation()) {
582 fMultReco->SetRecType(AliITSMultRecBg::kBgRot);
583 fMultReco->SetPhiRotationAngle(fPhiRot);
584 fMultReco->Run(fRPTree, vtxf);
585 printf("Multiplicity from Rotation:\n");
586 AliMultiplicity* mlt = fMultReco->GetMultiplicity();
587 if (mlt) mlt->Print();
588 hstat->Fill(kBinEntries + kEvProcRot + kEntriesPerBin*fCurrCentBin);
589 FillHistos(kBgRot,mlt);
594 AliMixEventInputHandler* handToMix = (AliMixEventInputHandler*)handRP->MixingHandler();
595 if (!handToMix) { printf("No Mixing handler\n"); return; }
596 handToMix->GetEntry();
597 if(handToMix->MixedEventNumber()<1) {printf("Mixing: No enough events in pool\n"); return;}
598 AliESDInputHandlerRP* handRPMix = (AliESDInputHandlerRP*) handToMix->InputEventHandler(0);
600 if (!handRPMix) { printf("No Mixing RP handler\n"); return; }
601 fRPTreeMix = handRPMix->GetTreeR("ITS");
602 if (!fRPTreeMix) { AliError(" Invalid ITS cluster tree of the 2nd event!\n"); return; }
604 AliESDEvent *esdMix = handRPMix->GetEvent();
605 const AliESDVertex* vtxESDmix = esdMix->GetVertex();
606 ((TH2*)fHistosCustom->UncheckedAt(kHZVtxMixDiff))->Fill(vtxESDmix->GetZ()-esdvtx[2],fCurrCentBin);
607 ((TH2*)fHistosCustom->UncheckedAt(kHNTrMixDiff) )->
608 Fill(esdMix->GetMultiplicity()->GetNumberOfTracklets() - multESD->GetNumberOfTracklets(),fCurrCentBin);
611 fMultReco->SetRecType(AliITSMultRecBg::kBgMix);
612 fMultReco->Run(fRPTree, vtxf,fRPTreeMix);
613 printf("Multiplicity from Mixing:\n");
614 AliMultiplicity* mlt = fMultReco->GetMultiplicity();
615 if (mlt) mlt->Print();
616 hstat->Fill(kBinEntries + kEvProcMix + kEntriesPerBin*fCurrCentBin);
617 FillHistos(kBgMix,mlt);
621 // =============================================================================<<<
623 if (fMultReco) delete fMultReco;
629 //________________________________________________________________________
630 void AliTrackletTaskMulti::RegisterStat()
633 TList *lst = dynamic_cast<TList*>(GetOutputData(1));
634 if (lst && (hstat=(TH1*)lst->FindObject("hStat"))) {
635 Info("Terminate","Registering used settings");
636 // fill used settings
637 hstat->Fill(kOneUnit,1.);
638 hstat->Fill(kCentVar,fUseCentralityVar);
639 hstat->Fill(kDPhi,fDPhiWindow);
640 hstat->Fill(kDTht,fDThetaWindow);
641 hstat->Fill(kNStd,fNStdDev);
642 hstat->Fill(kPhiShift,fDPhiShift);
643 hstat->Fill(kThtS2,fScaleDTBySin2T);
644 hstat->Fill(kThtCW,fCutOnDThetaX);
645 hstat->Fill(kPhiOvl,fPhiOverlapCut);
646 hstat->Fill(kZEtaOvl,fZetaOverlap);
647 hstat->Fill(kNoOvl,fRemoveOverlaps);
649 hstat->Fill(kPhiRot,fPhiRot);
650 hstat->Fill(kInjScl,fInjScale);
651 hstat->Fill(kEtaMin,fEtaMin);
652 hstat->Fill(kEtaMax,fEtaMax);
653 hstat->Fill(kZVMin,fZVertexMin);
654 hstat->Fill(kZVMax,fZVertexMax);
656 hstat->Fill(kDPiSCut,fDPhiSCut);
657 hstat->Fill(kNStdCut,fNStdCut);
658 hstat->Fill(kMCV0Scale, fMCV0Scale);
665 //________________________________________________________________________
666 void AliTrackletTaskMulti::Terminate(Option_t *)
668 Printf("Terminating...");
673 //_________________________________________________________________________
674 void AliTrackletTaskMulti::InitMultReco()
676 // create mult reconstructor
677 if (fMultReco) delete fMultReco;
678 fMultReco = new AliITSMultRecBg();
679 fMultReco->SetCreateClustersCopy(kTRUE);
680 fMultReco->SetScaleDThetaBySin2T(fScaleDTBySin2T);
681 fMultReco->SetNStdDev(fNStdDev);
682 fMultReco->SetPhiWindow( fDPhiWindow );
683 fMultReco->SetThetaWindow( fDThetaWindow );
684 fMultReco->SetPhiShift( fDPhiShift );
685 fMultReco->SetRemoveClustersFromOverlaps(fRemoveOverlaps);
686 fMultReco->SetPhiOverlapCut(fPhiOverlapCut);
687 fMultReco->SetZetaOverlapCut(fZetaOverlap);
688 fMultReco->SetHistOn(kFALSE);
689 fMultReco->SetRecType( AliITSMultRecBg::kData );
692 //_________________________________________________________________________
693 TObjArray* AliTrackletTaskMulti::BookCustomHistos()
695 // book custom histos, not related to specific tracklet type
696 TObjArray* histos = new TObjArray();
699 // ------------ job parameters, statistics ------------------------------>>>
700 int nbs = kBinEntries + fNCentBins*kEntriesPerBin;
701 hstat = new TH1F("hStat","Run statistics",nbs,0.5,nbs+0.5);
703 hstat->GetXaxis()->SetBinLabel(kEvTot0, "Ev.Tot0");
704 hstat->GetXaxis()->SetBinLabel(kEvTot, "Ev.Tot");
705 hstat->GetXaxis()->SetBinLabel(kOneUnit,"ScaleMerge");
706 hstat->GetXaxis()->SetBinLabel(kNWorkers,"Workers");
708 hstat->GetXaxis()->SetBinLabel(kCentVar, fgCentSelName[fUseCentralityVar]);
709 hstat->GetXaxis()->SetBinLabel(kDPhi, "#Delta#varphi");
710 hstat->GetXaxis()->SetBinLabel(kDTht, "#Delta#theta");
711 hstat->GetXaxis()->SetBinLabel(kNStd, "N.std");
712 hstat->GetXaxis()->SetBinLabel(kPhiShift,"#delta#varphi");
713 hstat->GetXaxis()->SetBinLabel(kThtS2,"scale #Delta#theta");
714 hstat->GetXaxis()->SetBinLabel(kPhiOvl,"#varpho_{Ovl}");
715 hstat->GetXaxis()->SetBinLabel(kZEtaOvl,"#z_{Ovl}");
716 hstat->GetXaxis()->SetBinLabel(kNoOvl, "rem.ovl");
718 hstat->GetXaxis()->SetBinLabel(kPhiRot,"#varphi_{rot}");
719 hstat->GetXaxis()->SetBinLabel(kInjScl,"inj");
720 hstat->GetXaxis()->SetBinLabel(kEtaMin,"#eta_{min}");
721 hstat->GetXaxis()->SetBinLabel(kEtaMax,"#eta_{max}");
722 hstat->GetXaxis()->SetBinLabel(kZVMin,"ZV_{min} cut");
723 hstat->GetXaxis()->SetBinLabel(kZVMax,"ZV_{max} cut");
725 hstat->GetXaxis()->SetBinLabel(kDPiSCut,"#Delta#varphi-#delta_{#phi} cut");
726 hstat->GetXaxis()->SetBinLabel(kNStdCut,"#Delta cut");
728 hstat->GetXaxis()->SetBinLabel(kMCV0Scale,"MC V0 scale");
730 for (int i=0;i<fNCentBins;i++) {
731 TString bnt = "b"; bnt+= i;
732 int offs = kBinEntries + i*kEntriesPerBin;
733 hstat->GetXaxis()->SetBinLabel(offs + kEvProcData, bnt+" Ev.ProcData");
734 hstat->GetXaxis()->SetBinLabel(offs + kEvProcInj, bnt+" Ev.ProcInj");
735 hstat->GetXaxis()->SetBinLabel(offs + kEvProcRot, bnt+" Ev.ProcRot");
736 hstat->GetXaxis()->SetBinLabel(offs + kEvProcMix, bnt+" Ev.ProcMix");
740 hstat->Fill(kNWorkers);
742 AddHisto(histos,hstat,kHStat);
744 // ------------------------ events per centrality bin ----------------------
745 TH1D* hCentAx = new TH1D("EvCentr","Events per centrality",fNCentBins,fgkCentPerc);
746 hCentAx->GetXaxis()->SetTitle("Centrality parameter");
747 AddHisto(histos,hCentAx,kHStatCent);
749 TH1D* hCentBin = new TH1D("EvCentrBin","Events per centrality bin",fNCentBins,-0.5,fNCentBins-0.5);
750 hCentBin->GetXaxis()->SetTitle("Centrality Bin");
751 AddHisto(histos,hCentBin,kHStatCentBin);
753 // ------------ job parameters, statistics ------------------------------<<<
755 // double etaMn=-3,etaMx=3;
756 double zMn=-30, zMx=30;
757 // int nEtaBins = int((etaMx-etaMn)/kEtaBinWidth);
758 // if (nEtaBins<1) nEtaBins = 1;
760 int nZVBins = int(zMx-zMn);
761 if (nZVBins<1) nZVBins = 1;
763 // Z vertex distribution for events before selection
764 TH1F* hzvns = new TH1F("zvNoSel","Z vertex before selection",nZVBins,zMn,zMx);
765 hzvns->GetXaxis()->SetTitle("Zvertex");
766 AddHisto(histos,hzvns,kHZVtxNoSel);
768 // V0 for events before selection
770 double maxmltV0 = 25000;
772 TH1F* hnV0ns = new TH1F("V0NoSel","V0 signal Before Cent. Selection",nbmltV0,0,maxmltV0);
773 hnV0ns->GetXaxis()->SetTitle("V0 signal");
774 AddHisto(histos,hnV0ns,kHV0NoSel);
778 double maxmltSPD2 = 7000;
779 TH1F* hncl2ns = new TH1F("NClustersSPD2NoSel","N Clusters on SPD2 Before Cent Selection",nbmltSPD2,0,maxmltSPD2);
780 hncl2ns->GetXaxis()->SetTitle("N Clus SPD2");
781 AddHisto(histos,hncl2ns,kHNClSPD2NoSel);
784 double maxZDC=6000., maxZEM=2500.;
785 TH2F* hzdczemns = new TH2F("ZDCZEMNoSel","ZDC vs ZEM Before Cent Selection",
786 nbzdc,0,maxZEM,nbzdc,0,maxZDC);
787 hzdczemns->GetXaxis()->SetTitle("ZEM");
788 hzdczemns->GetXaxis()->SetTitle("ZDC");
789 AddHisto(histos,hzdczemns,kHZDCZEMNoSel);
791 TH2F* hzv = new TH2F("zv","Z vertex after Selection per Cent.Bin",nZVBins,zMn,zMx, fNCentBins, -0.5,fNCentBins-0.5);
792 hzv->GetXaxis()->SetTitle("Zvertex");
793 hzv->GetYaxis()->SetTitle("Cent.Bin ID");
794 AddHisto(histos,hzv,kHZVtx);
797 TH2F* hnV0 = new TH2F("V0","V0 signal per Cent.Bin ",nbmltV0,0,maxmltV0, fNCentBins, -0.5,fNCentBins-0.5);
798 hnV0->GetXaxis()->SetTitle("V0 signal");
799 hnV0->GetYaxis()->SetTitle("Cent.Bin ID");
800 AddHisto(histos,hnV0,kHV0);
803 TH2F* hncl2 = new TH2F("NClustersSPD2","N Clusters on SPD2 per Cent.Bin",nbmltSPD2,0,maxmltSPD2, fNCentBins, -0.5,fNCentBins-0.5);
804 hncl2->GetXaxis()->SetTitle("N Clus SPD2");
805 hncl2->GetYaxis()->SetTitle("Cent.Bin ID");
806 AddHisto(histos,hncl2,kHNClSPD2);
809 TH3F* hzdczem = new TH3F("ZDCZEM","ZDC vs ZEM per Cent.Bin",nbzdc,0,maxZEM,nbzdc,0,maxZDC, fNCentBins, -0.5,fNCentBins-0.5);
810 hzdczem->GetXaxis()->SetTitle("ZEM");
811 hzdczem->GetYaxis()->SetTitle("ZDC");
812 AddHisto(histos,hzdczem,kHZDCZEM);
814 //----------------------------------------------------------------------
815 int nEtaBinsS = int((fEtaMax-fEtaMin)/kEtaBinWidth);
816 if (nEtaBinsS<1) nEtaBinsS = 1;
818 int nZVBinsS = int(fZVertexMax-fZVertexMin);
819 if (nZVBinsS<1) nZVBinsS = 1;
822 // Z vertex vs Eta distribution for primaries
823 char buffn[100],bufft[500];
824 for (int ib=0;ib<fNCentBins;ib++) {
825 sprintf(buffn,"b%d_zvEtaPrimMC",ib);
826 sprintf(bufft,"bin%d Zvertex vs #eta PrimMC",ib);
827 TH2F* hzvetap = new TH2F(buffn,bufft, nEtaBinsS,fEtaMin,fEtaMax,nZVBinsS,fZVertexMin,fZVertexMax);
828 hzvetap->GetXaxis()->SetTitle("#eta");
829 hzvetap->GetYaxis()->SetTitle("Zvertex");
830 AddHisto(histos,hzvetap,kHZVEtaPrimMC+ib);
833 // <n> primaries according to MC generator
834 TH1F* hnprimM = new TH1F("nPrimMean","<N> primaries",fNCentBins, -0.5,fNCentBins-0.5);
835 hnprimM->GetXaxis()->SetTitle("Cent.Bin ID");
836 AddHisto(histos,hnprimM,kHNPrimMeanMC);
838 // <n> primaries per part.pair according to MC generator
839 TH1F* hnprim2partM = new TH1F("nPrim2Part","<N> primaries per part.pair",fNCentBins, -0.5,fNCentBins-0.5);
840 hnprim2partM->GetXaxis()->SetTitle("Cent.Bin ID");
841 AddHisto(histos,hnprim2partM,kHNPrim2PartMC);
843 // <n> primaries per part.pair vs npart.pair according to MC generator
844 TH2F* hnprim2partNp = new TH2F("nPrim2Part_vs_NPart","<N> primaries per part.pair vs N part.pairs",105,0,210,200,0,40);
845 hnprim2partNp->GetXaxis()->SetTitle("N.part.pairs");
846 hnprim2partNp->GetYaxis()->SetTitle("N.prim/N.part.pairs");
847 AddHisto(histos,hnprim2partNp,kHNPrim2PartNpMC);
849 // <n> primaries per b.coll vs npart.pair according to MC generator
850 TH2F* hnprim2BCollNp = new TH2F("nPrim2BColl_vs_NPart","<N> primaries per bin.coll vs N part.pairs",105,0,210,200,0,40);
851 hnprim2BCollNp->GetXaxis()->SetTitle("N.part.pairs");
852 hnprim2BCollNp->GetYaxis()->SetTitle("N.prim/N.bin.coll.");
853 AddHisto(histos,hnprim2BCollNp,kHNPrim2BCollNpMC);
855 // <n> primaries per bin.coll. according to MC generator
856 TH1F* hnprim2BCollM = new TH1F("nPrim2BColl","<N> primaries per bin.coll",fNCentBins, -0.5,fNCentBins-0.5);
857 hnprim2BCollM->GetXaxis()->SetTitle("Cent.Bin ID");
858 AddHisto(histos,hnprim2BCollM,kHNPrim2BCollMC);
860 // n participants according to MC generator
861 TH2F* hnpart = new TH2F("nPart","N participant pairs",210,0,210,fNCentBins, -0.5,fNCentBins-0.5);
862 hnpart->GetXaxis()->SetTitle("N part. pairs");
863 hnpart->GetYaxis()->SetTitle("Cent.Bin ID");
864 AddHisto(histos,hnpart,kHNPartMC);
866 // <n> participants according to MC generator
867 TH1F* hnpartM = new TH1F("nPartMean","<N> participant pairs",fNCentBins, -0.5,fNCentBins-0.5);
868 hnpartM->GetXaxis()->SetTitle("Cent.Bin ID");
869 AddHisto(histos,hnpartM,kHNPartMeanMC);
871 // n bin coll. according to MC generator
872 TH2F* hnbcoll = new TH2F("nBColl","N bin. coll",2000,0,2000,fNCentBins, -0.5,fNCentBins-0.5);
873 hnbcoll->GetXaxis()->SetTitle("N bin. coll");
874 hnbcoll->GetYaxis()->SetTitle("Cent.Bin ID");
875 AddHisto(histos,hnbcoll,kHNBCollMC);
877 // <n> bin col according to MC generator
878 TH1F* hnbcollM = new TH1F("nBCollMean","<N> bin.colls",fNCentBins, -0.5,fNCentBins-0.5);
879 hnbcollM->GetXaxis()->SetTitle("Cent.Bin ID");
880 AddHisto(histos,hnbcollM,kHNBCollMeanMC);
886 // Difference in Z vertex for mixed events
887 TH2F* hzdiff = new TH2F("MixSPDVertexDiff","SPD #Delta Z Vertex distribution per mult bin ",100,-5,5, fNCentBins, -0.5,fNCentBins-0.5);
888 hzdiff->GetXaxis()->SetTitle("#Delta Z Vertex [cm]");
889 hzdiff->GetYaxis()->SetTitle(Form("Entries / %1.2f [cm] per mult bin",10./100.));
890 AddHisto(histos,hzdiff,kHZVtxMixDiff);
892 // Difference in N tracklets for mixed events
893 TH2F* hntdiff = new TH2F("MixNTrackletsDiff"," SPD tracklets Diff ",200,-1000,1000, fNCentBins, -0.5,fNCentBins-0.5);
894 hntdiff->GetXaxis()->SetTitle("# tracklet diff");
895 AddHisto(histos,hntdiff,kHNTrMixDiff);
898 // --------------------------------------------------
900 int npdg = sizeof(fgkPDGNames)/sizeof(char*);
901 TH2F* hpdgP = new TH2F("pdgPrim","primary PDG",npdg,0,npdg,fNCentBins, -0.5,fNCentBins-0.5);
902 AddHisto(histos,hpdgP,kHPrimPDG);
903 TH2F* hpdgS = new TH2F("pdgSec","secondary PDG",npdg,0,npdg,fNCentBins, -0.5,fNCentBins-0.5);
904 AddHisto(histos,hpdgS,kHSecPDG);
905 TH2F* hpdgPP = new TH2F("pdgPrimPar","primary parent PDG ",npdg,0,npdg,fNCentBins, -0.5,fNCentBins-0.5);
906 AddHisto(histos,hpdgPP,kHPrimParPDG);
907 TH2F* hpdgSP = new TH2F("pdgSecPar","secondary parent PDG",npdg,0,npdg,fNCentBins, -0.5,fNCentBins-0.5);
908 AddHisto(histos,hpdgSP,kHSecParPDG);
909 for (int i=0;i<npdg;i++) {
910 hpdgP->GetXaxis()->SetBinLabel(i+1,fgkPDGNames[i]);
911 hpdgS->GetXaxis()->SetBinLabel(i+1,fgkPDGNames[i]);
912 hpdgPP->GetXaxis()->SetBinLabel(i+1,fgkPDGNames[i]);
913 hpdgSP->GetXaxis()->SetBinLabel(i+1,fgkPDGNames[i]);
917 // -------------------------------------------------
919 hclinf = new TH2F("cl0InfoUsed","#phi vs Z of used clusters, Lr0",64,-16,16, 80,0,2*TMath::Pi());
920 AddHisto(histos,hclinf,kHClUsedInfoL0);
921 hclinf = new TH2F("cl1InfoUsed","#phi vs Z of used clusters, Lr1",64,-16,16, 2*80,0,2*TMath::Pi());
922 AddHisto(histos,hclinf,kHClUsedInfoL1);
923 hclinf = new TH2F("cl0InfoAll","#phi vs Z of all clusters, Lr0",64,-16,16, 80,0,2*TMath::Pi());
924 AddHisto(histos,hclinf,kHClAllInfoL0);
925 hclinf = new TH2F("cl1InfoAll","#phi vs Z of all clusters, Lr1",64,-16,16, 2*80,0,2*TMath::Pi());
926 AddHisto(histos,hclinf,kHClAllInfoL1);
928 // -------------------------------------------------
929 histos->SetOwner(kFALSE);
934 //_________________________________________________________________________
935 TObjArray* AliTrackletTaskMulti::BookHistosSet(const char* pref, UInt_t selHistos)
937 // book standard set of histos attaching the pref in front of the name/title
939 const int kNDPhiBins = 100;
940 const int kNDThtBins = 100;
941 int nDistBins = int(fNStdDev)*5;
943 int nEtaBins = int((fEtaMax-fEtaMin)/kEtaBinWidth);
944 if (nEtaBins<1) nEtaBins = 1;
946 int nZVBins = int(fZVertexMax-fZVertexMin);
947 if (nZVBins<1) nZVBins = 1;
948 float dphir = fDPhiWindow*TMath::Sqrt(fNStdDev);
949 float dthtr = fDThetaWindow*TMath::Sqrt(fNStdDev);
951 TObjArray* histos = new TObjArray();
954 char buffn[100],bufft[500];
956 for (int ib=0;ib<fNCentBins;ib++) {
958 int offs = ib*kNStandardH;
959 if (selHistos & (0x1<<kHEtaZvCut) ) {
960 sprintf(buffn,"b%d_%s_ZvEtaCutT",ib,pref);
961 sprintf(bufft,"bin%d (%s) Zv vs Eta with tracklet cut",ib,pref);
962 h2 = new TH2F(buffn,bufft,nEtaBins,fEtaMin,fEtaMax, nZVBins, fZVertexMin,fZVertexMax);
963 h2->GetXaxis()->SetTitle("#eta");
964 h2->GetYaxis()->SetTitle("Zv");
965 AddHisto(histos,h2,offs+kHEtaZvCut);
968 if (selHistos & (0x1<<kHDPhiDTheta) ) {
969 sprintf(buffn,"b%d_%s_dPhidTheta",ib,pref);
970 sprintf(bufft,"bin%d (%s) #Delta#theta vs #Delta#varphi",ib,pref);
971 h2 = new TH2F(buffn,bufft,kNDPhiBins,-dphir,dphir,kNDThtBins,-dthtr,dthtr);
972 h2->GetXaxis()->SetTitle("#Delta#varphi [rad]");
973 h2->GetYaxis()->SetTitle("#Delta#theta [rad]");
974 AddHisto(histos,h2,offs+kHDPhiDTheta);
977 if (selHistos & (0x1<<kHDPhiSDThetaX) ) {
978 sprintf(buffn,"b%d_%s_dPhiSdThetaX",ib,pref);
979 sprintf(bufft,"bin%d (%s) #Delta#theta%s vs #Delta#varphi-#delta_{#varphi}",ib,pref,fScaleDTBySin2T ? "/sin^{2}(#theta)":"");
980 h2 = new TH2F(buffn,bufft,kNDPhiBins,-dphir,dphir,kNDThtBins,-dthtr,dthtr);
981 h2->GetXaxis()->SetTitle("#Delta#varphi-#delta_{#varphi} [rad]");
982 sprintf(bufft,"#Delta#theta%s",fScaleDTBySin2T ? "/sin^{2}(#theta)":"");
983 h2->GetYaxis()->SetTitle(bufft);
984 AddHisto(histos,h2,offs+kHDPhiSDThetaX);
987 if (selHistos & (0x1<<kHWDist) ) {
988 sprintf(buffn,"b%d_%s_WDist",ib,pref);
989 sprintf(bufft,"bin%d #Delta=[(#Delta#varphi-#delta_{#varphi})/#sigma#varphi]^{2}+"
990 "[#Delta#theta%s/#sigma#theta]^{2}",ib,fScaleDTBySin2T ? "*sin^{-2}(#theta)":"");
991 h1 = new TH1F(buffn,bufft,nDistBins,0,fNStdDev);
992 sprintf(bufft,"#Delta=[(#Delta#varphi-#delta_{#varphi})/#sigma#varphi]^{2}+"
993 "[#Delta#theta%s/#sigma#theta]^{2}",fScaleDTBySin2T ? "*sin^{-2}(#theta)":"");
994 h1->GetXaxis()->SetTitle(bufft);
995 AddHisto(histos,h1,offs+kHWDist);
998 if (selHistos & (0x1<<kHEtaZvSPD1) ) {
999 sprintf(buffn,"b%d_%s_ZvEtaSPD1",ib,pref);
1000 sprintf(bufft,"bin%d (%s) Zv vs Eta SPD1 clusters",ib,pref);
1001 h2 = new TH2F(buffn,bufft,nEtaBins,fEtaMin,fEtaMax, nZVBins, fZVertexMin,fZVertexMax);
1002 h2->GetXaxis()->SetTitle("#eta");
1003 h2->GetYaxis()->SetTitle("Zv");
1004 AddHisto(histos,h2,offs+kHEtaZvSPD1);
1009 histos->SetOwner(kFALSE);
1013 //_________________________________________________________________________
1014 void AliTrackletTaskMulti::AddHisto(TObjArray* histos, TObject* h, Int_t at)
1016 // add single histo to the set
1017 if (at>=0) histos->AddAtAndExpand(h,at);
1018 else histos->Add(h);
1022 //_________________________________________________________________________
1023 void AliTrackletTaskMulti::FillHistos(Int_t type, const AliMultiplicity* mlt)
1025 // fill histos of given type
1028 TObjArray* histos = 0;
1029 if (type == kData) histos = fHistosTrData;
1030 else if (type == kBgInj) histos = fHistosTrInj;
1031 else if (type == kBgRot) histos = fHistosTrRot;
1032 else if (type == kBgMix) histos = fHistosTrMix;
1034 Bool_t fillMC = (type==kData) && fUseMC && fStack;
1037 //---------------------------------------- CHECK ------------------------------>>>
1039 AliGenHijingEventHeader* pyHeader = 0;
1042 pyHeader = (AliGenHijingEventHeader*) fMCEvent->GenEventHeader();//header->GenEventHeader();
1043 pyHeader->PrimaryVertex(vtxMC);
1045 //---------------------------------------- CHECK ------------------------------<<<
1047 if (!histos) return;
1048 int ntr = mlt->GetNumberOfTracklets();
1049 for (int itr=ntr;itr--;) {
1051 //---------------------------------------- CHECK ------------------------------>>>
1054 Bool_t reject = kFALSE;
1056 int lab0 = mlt->GetLabel(itr,0);
1057 int lab1 = mlt->GetLabel(itr,1);
1058 if (lab0!=lab1) break;
1059 if (!fStack->IsPhysicalPrimary(lab0)) break;
1061 TParticle* part = fStack->Particle(lab0);
1062 Float_t dz = part->Vz() - vtxMC[2];
1063 if (TMath::Abs(dz)<1e-6) break;
1067 if (reject) continue;
1070 //---------------------------------------- CHECK ------------------------------<<<
1072 double theta = mlt->GetTheta(itr);
1073 double eta = -TMath::Log(TMath::Tan(theta/2));
1074 if (eta<fEtaMin || eta>fEtaMax) continue;
1076 double dtheta = mlt->GetDeltaTheta(itr);
1077 double dThetaX = dtheta;
1078 if (fScaleDTBySin2T) {
1079 double sint = TMath::Sin(theta);
1080 dThetaX /= (sint*sint);
1082 if (fCutOnDThetaX && TMath::Abs(dThetaX)>fDThetaWindow) continue;
1083 // double phi = mlt->GetPhi(itr);
1084 double dphi = mlt->GetDeltaPhi(itr);
1085 double dist = mlt->CalcDist(itr);
1087 FillHistosSet(histos,eta,/*phi,theta,*/dphi,dtheta,dThetaX,dist);
1088 // special handling for mc info
1089 if (fillMC && fStack) {
1090 int lab0 = mlt->GetLabel(itr,0);
1091 int lab1 = mlt->GetLabel(itr,1);
1092 int typeMC = 2; // comb.bg.
1093 if (lab0 == lab1) typeMC = fStack->IsPhysicalPrimary(lab0) ? 0:1; // prim or sec
1094 if (typeMC==0) FillHistosSet(fHistosTrPrim,eta,/*phi,theta,*/dphi,dtheta,dThetaX,dist); // primary
1095 else if (typeMC==1) FillHistosSet(fHistosTrSec, eta,/*phi,theta,*/dphi,dtheta,dThetaX,dist); // secondary
1097 FillHistosSet(fHistosTrComb,eta,/*phi,theta,*/dphi,dtheta,dThetaX,dist); // comb
1098 // for combinatorals fill also the uncorrelated part
1100 float *trl = fMultReco->GetTracklet(itr);
1101 int clId0 = (int)trl[AliITSMultReconstructor::kClID1];
1102 int clId1 = (int)trl[AliITSMultReconstructor::kClID2];
1103 float *clLabs0 = fMultReco->GetClusterOfLayer(0,clId0) + AliITSMultReconstructor::kClMC0;
1104 float *clLabs1 = fMultReco->GetClusterOfLayer(1,clId1) + AliITSMultReconstructor::kClMC0;
1105 if (!HaveCommonParent(clLabs0,clLabs1))
1106 FillHistosSet(fHistosTrCombU,eta,/*phi,theta,*/dphi,dtheta,dThetaX,dist);
1110 if (dist<fNStdCut) {
1111 double dphiS = TMath::Abs(dphi) - fDPhiShift; if (dphi<0) dphiS = -dphiS;
1112 if (dphiS<fDPhiSCut) FillSpecies(typeMC, lab0);
1114 if (fCheckReconstructables) CheckReconstructables();
1118 //-------------------------------------------------------------TMP RS - singles ------->>>
1119 int offsH = fCurrCentBin*kNStandardH;
1120 TH2* hSingles = (TH2*)histos->UncheckedAt(offsH+kHEtaZvSPD1);
1122 int nclS = mlt->GetNumberOfSingleClusters();
1123 double *thtS = mlt->GetThetaSingle();
1124 for (int ics=nclS;ics--;) {
1125 double etaS = -TMath::Log(TMath::Tan(thtS[ics]/2));
1126 if (etaS<fEtaMin || etaS>fEtaMax) continue;
1127 hSingles->Fill(etaS,fESDVtx[2]);
1130 //-------------------------------------------------------------TMP RS - singles -------<<<
1134 //_________________________________________________________________________
1135 void AliTrackletTaskMulti::FillMCPrimaries()
1137 // fill all MC primaries Zv vs Eta
1138 if (!fStack || !fMCEvent) return;
1140 //---------------------------------------- CHECK ------------------------------>>>
1142 AliGenHijingEventHeader* pyHeader = 0;
1145 pyHeader = (AliGenHijingEventHeader*) fMCEvent->GenEventHeader();//header->GenEventHeader();
1146 pyHeader->PrimaryVertex(vtxMC);
1148 //---------------------------------------- CHECK ------------------------------<<<
1150 int ntr = fStack->GetNtrack();
1151 TH2* hprimEtaZ = (TH2F*)fHistosCustom->UncheckedAt(kHZVEtaPrimMC+fCurrCentBin);
1153 for (int itr=ntr;itr--;) {
1154 if (!fStack->IsPhysicalPrimary(itr)) continue;
1155 AliMCParticle *part = (AliMCParticle*)fMCEvent->GetTrack(itr);
1156 if (!part->Charge()) continue;
1158 //---------------------------------------- CHECK ------------------------------>>>
1160 Float_t dz = part->Zv() - vtxMC[2];
1161 if (TMath::Abs(dz)>1e-6) continue; // reject
1163 //---------------------------------------- CHECK ------------------------------<<<
1165 Float_t theta = part->Theta();
1166 if (theta<1e-6 || theta>TMath::Pi()-1e-6) continue;
1167 Float_t eta = part->Eta();
1168 if (eta<fEtaMin || eta>fEtaMax) continue;
1169 hprimEtaZ->Fill(eta, fESDVtx[2]);
1173 ((TH1*)fHistosCustom->UncheckedAt(kHNPrimMeanMC))->Fill(fCurrCentBin,nprim);
1175 ((TH1*)fHistosCustom->UncheckedAt(kHNPrim2PartMC))->Fill(fCurrCentBin,nprim/fNPart);
1176 ((TH2*)fHistosCustom->UncheckedAt(kHNPrim2PartNpMC))->Fill(fNPart,nprim/fNPart);
1177 ((TH2*)fHistosCustom->UncheckedAt(kHNPartMC))->Fill(fNPart,fCurrCentBin);
1178 ((TH1*)fHistosCustom->UncheckedAt(kHNPartMeanMC))->Fill(fCurrCentBin,fNPart);
1181 ((TH1*)fHistosCustom->UncheckedAt(kHNPrim2BCollMC))->Fill(fCurrCentBin,nprim/fNBColl);
1182 ((TH2*)fHistosCustom->UncheckedAt(kHNPrim2BCollNpMC))->Fill(fNPart,nprim/fNBColl);
1183 ((TH2*)fHistosCustom->UncheckedAt(kHNBCollMC))->Fill(fNBColl,fCurrCentBin);
1184 ((TH1*)fHistosCustom->UncheckedAt(kHNBCollMeanMC))->Fill(fCurrCentBin,fNBColl);
1189 //_________________________________________________________________________
1190 void AliTrackletTaskMulti::FillHistosSet(TObjArray* histos, double eta,
1191 //double /*phi*/,double /*theta*/,
1192 double dphi,double dtheta,double dThetaX,
1195 // fill standard set of histos
1196 if (dist>fNStdDev) return;
1198 double dphiS = TMath::Abs(dphi) - fDPhiShift;
1199 if (dphi<0) dphiS = -dphiS;
1201 int offs = fCurrCentBin*kNStandardH;
1203 if (histos->UncheckedAt(offs+kHDPhiSDThetaX))
1204 ((TH2*)histos->UncheckedAt(offs+kHDPhiSDThetaX))->Fill(dphiS,dThetaX);
1206 if (histos->UncheckedAt(offs+kHDPhiDTheta))
1207 ((TH2*)histos->UncheckedAt(offs+kHDPhiDTheta))->Fill(dphi,dtheta);
1209 if (histos->UncheckedAt(kHWDist))
1210 ((TH2*)histos->UncheckedAt(offs+kHWDist))->Fill(dist);
1212 if (dist<fNStdCut && dphiS<fDPhiSCut && histos->UncheckedAt(offs+kHEtaZvCut))
1213 ((TH2*)histos->UncheckedAt(offs+kHEtaZvCut))->Fill(eta,fESDVtx[2]);
1217 //__________________________________________________________________
1218 void AliTrackletTaskMulti::FillSpecies(Int_t primsec, Int_t id)
1221 TH1 *hPart=0,*hParent=0;
1223 hPart = (TH1*)fHistosCustom->UncheckedAt(kHPrimPDG);
1224 hParent = (TH1*)fHistosCustom->UncheckedAt(kHPrimParPDG);
1226 else if (primsec==1) {
1227 hPart = (TH1*)fHistosCustom->UncheckedAt(kHSecPDG);
1228 hParent = (TH1*)fHistosCustom->UncheckedAt(kHSecParPDG);
1231 int ntr = fStack->GetNtrack();
1232 TParticle* part = fStack->Particle(id);
1233 int pdgCode = TMath::Abs(part->GetPdgCode());
1234 int pdgBin = GetPdgBin(pdgCode);
1235 int parID = part->GetFirstMother();
1236 int pdgCodePar = -1;
1238 while (parID>=0 && parID<ntr) {
1239 part = fStack->Particle(parID);
1240 pdgCodePar = TMath::Abs(part->GetPdgCode());
1241 parID = part->GetFirstMother();
1243 if (pdgCodePar>0) pdgBinPar = GetPdgBin(pdgCodePar);
1245 hPart->Fill(pdgBin,fCurrCentBin);
1246 hParent->Fill(pdgBinPar,fCurrCentBin);
1250 //_________________________________________________________________________
1251 Int_t AliTrackletTaskMulti::GetCentralityBin(Float_t perc) const
1253 // calculate centrality bin
1254 for (int i=0;i<fNCentBins;i++) if (perc>=fgkCentPerc[i] && perc<=fgkCentPerc[i+1]) return i;
1258 //_________________________________________________________________________
1259 Int_t AliTrackletTaskMulti::GetPdgBin(Int_t pdgCode)
1261 // return my pdg bin
1262 int ncodes = sizeof(fgkPDGCodes)/sizeof(int);
1264 for (pdgBin=0;pdgBin<ncodes;pdgBin++) if (pdgCode==fgkPDGCodes[pdgBin]) break;
1265 if (pdgBin>=ncodes) {
1266 if (float(pdgCode)>1e9) pdgBin = ncodes; // nuclei
1267 else pdgBin = ncodes+1; // unknown
1272 //_________________________________________________________________________
1273 Bool_t AliTrackletTaskMulti::HaveCommonParent(const float* clLabs0,const float* clLabs1)
1275 // do 2 clusters have common parrent
1276 const int kMaxPar = 50;
1277 static int pars[2][50];
1279 const float *labs[2] = {clLabs0,clLabs1};
1280 int ntr = fStack->GetNtrack();
1281 for (int il=0;il<2;il++) {
1282 for (int ilb=0;ilb<3;ilb++) {
1283 int lbl = (int)labs[il][ilb];
1284 if (lbl<0 || lbl>=ntr) continue;
1286 while (npars[il]<kMaxPar-1) {
1287 pars[il][ npars[il]++ ] = lbl;
1288 TParticle* part = fStack->Particle(lbl);
1290 lbl = part->GetFirstMother();
1291 if (lbl<1 || lbl>=ntr) break;
1295 // compare array of parents
1296 for (int i0=npars[0];i0--;) for (int i1=npars[1];i1--;) if (pars[0][i0]==pars[1][i1]) return kTRUE;
1301 //_________________________________________________________________________
1302 void AliTrackletTaskMulti::CheckReconstructables()
1304 // fill reconstructable tracklets hitsos
1305 static TArrayI trInd;
1306 static TBits isPrimArr;
1308 if (!fMultReco || !fMultReco->IsRecoDone()) {AliInfo("To check reconstructables the reco had to be requested"); return;}
1309 if (!fStack) {AliInfo("MC Stack is not availalble"); return;}
1310 const double kPtMin = 0.05;
1312 TClonesArray *clArr[2];
1313 for (int ilr=0;ilr<2;ilr++) {
1314 clArr[ilr] = fMultReco->GetClustersOfLayer(ilr);
1315 if (!clArr[ilr]) {AliInfo("Clusters are not available"); return;}
1318 int ntr = fStack->GetNtrack();
1321 if (trInd.GetSize()<ntr) trInd.Set(ntr);
1322 isPrimArr.ResetAllBits();
1323 // count track wich may be reconstructable
1325 int ntrStore=0,ntrStorePrim=0;
1326 Int_t *trIndArr = trInd.GetArray();
1327 for (Int_t it=0; it<ntr; it++) {
1328 TParticle* part = fStack->Particle(it);
1329 if (TMath::Abs(part->Eta())>2.2) continue;
1330 if (TMath::Abs(part->Pt())<kPtMin) continue;
1331 if (fStack->IsPhysicalPrimary(it)) {
1332 isPrimArr.SetBitNumber(it);
1335 else { // check if secondary is worth cheking
1336 TParticlePDG* pdgPart = part->GetPDG();
1337 if (TMath::Abs(pdgPart->Charge())!=3) continue;
1338 if (part->R()>5.) continue;
1340 trIndArr[it] = ++ntrStore;
1343 AliInfo(Form("Selected %d MC particles (%d prim) out of %d in the stack\n",ntrStore,ntrStorePrim,ntr));
1346 AliITSRecPoint **clIndL[2];
1347 clIndL[0] = new AliITSRecPoint*[kMaxCl*ntrStore]; // max 2 clusters per layer
1348 clIndL[1] = new AliITSRecPoint*[kMaxCl*ntrStore]; // max 2 clusters per layer
1349 memset(clIndL[0],0,kMaxCl*ntrStore*sizeof(AliITSRecPoint*));
1350 memset(clIndL[1],0,kMaxCl*ntrStore*sizeof(AliITSRecPoint*));
1352 for (int ilr=0;ilr<2;ilr++) {
1353 TClonesArray *clusters = clArr[ilr];
1354 int ncl = clusters->GetEntriesFast();
1355 for (int icl=ncl;icl--;) {
1356 AliITSRecPoint *cl = (AliITSRecPoint*)clusters->UncheckedAt(icl);
1357 for (int ilb=3;ilb--;) {
1358 int lbl = cl->GetLabel(ilb); if (lbl<0 || lbl>=ntr) continue;
1359 int lblI = trIndArr[lbl];
1360 if (--lblI<0) continue; // not kept
1361 for (int icc=0;icc<kMaxCl;icc++) if (!clIndL[ilr][lblI+icc*ntrStore]) {clIndL[ilr][lblI+ntrStore*icc] = cl; break;} // first empty one
1366 Float_t clusterLay[2][AliITSMultReconstructor::kClNPar];
1367 double trComp[6][kMaxCl*kMaxCl];
1368 int indQual[kMaxCl*kMaxCl];
1370 for (int itr=ntr;itr--;) {
1371 int lblI = trIndArr[itr];
1372 if (--lblI<0) continue; // discarded
1373 int ntrCand = 0; // number of tracklet candidates (including overlaps)
1374 for (int icl0=0;icl0<kMaxCl;icl0++) {
1375 AliITSRecPoint *cl0 = clIndL[0][lblI+icl0*ntrStore];
1376 if (!cl0 || !clIndL[1][lblI]) break;
1377 cl0->GetGlobalXYZ( clusterLay[0] );
1378 fMultReco->ClusterPos2Angles(clusterLay[0], fESDVtx);
1379 for (int icl1=0;icl1<kMaxCl;icl1++) {
1380 AliITSRecPoint *cl1 = clIndL[1][lblI+icl1*ntrStore];
1382 cl1->GetGlobalXYZ( clusterLay[1] );
1383 fMultReco->ClusterPos2Angles(clusterLay[1], fESDVtx);
1384 trComp[AliITSMultReconstructor::kTrPhi][ntrCand] = clusterLay[0][AliITSMultReconstructor::kClPh];
1385 trComp[AliITSMultReconstructor::kTrTheta][ntrCand] = clusterLay[0][AliITSMultReconstructor::kClTh];
1386 trComp[AliITSMultReconstructor::kTrDTheta][ntrCand] = clusterLay[0][AliITSMultReconstructor::kClTh] - clusterLay[1][AliITSMultReconstructor::kClTh];
1387 trComp[AliITSMultReconstructor::kTrDPhi][ntrCand] = clusterLay[0][AliITSMultReconstructor::kClPh] - clusterLay[1][AliITSMultReconstructor::kClPh];
1388 trComp[AliITSMultReconstructor::kTrLab1][ntrCand] = icl1*10 + icl0;
1389 double &dphi = trComp[ntrCand][3];
1390 if (dphi>TMath::Pi()) dphi=2.*TMath::Pi()-dphi; // take into account boundary condition
1391 trComp[5][ntrCand] = fMultReco->CalcDist(trComp[AliITSMultReconstructor::kTrDPhi][ntrCand],
1392 trComp[AliITSMultReconstructor::kTrDTheta][ntrCand],
1393 trComp[AliITSMultReconstructor::kTrTheta][ntrCand]);
1397 if (!ntrCand) continue; // no tracklets
1398 if (ntrCand>1) TMath::Sort(ntrCand,trComp[5],indQual,kFALSE); else indQual[0] = 0; // sort in weighted distance
1399 if (fRemoveOverlaps) ntrCand = 1; // select the best
1401 // disable worst tracklet with shared cluster
1402 for (int itc=0;itc<ntrCand;itc++) {
1403 int ind = indQual[itc];
1404 if (trComp[AliITSMultReconstructor::kTrLab1][ind]<0) continue; // already disabled
1405 for (int jtc=itc+1;jtc<ntrCand;jtc++) {
1406 int jnd = indQual[jtc];
1407 if (trComp[AliITSMultReconstructor::kTrLab1][jnd]<0) continue; // already disabled
1408 if ( int(trComp[AliITSMultReconstructor::kTrLab1][ind])/10 == int(trComp[AliITSMultReconstructor::kTrLab1][jnd])/10 ||
1409 int(trComp[AliITSMultReconstructor::kTrLab1][ind])%10 == int(trComp[AliITSMultReconstructor::kTrLab1][jnd])%10) trComp[AliITSMultReconstructor::kTrLab1][jnd] = -1;
1413 // store, but forbid cluster reusing
1414 TObjArray* histos = isPrimArr.TestBitNumber(itr) ? fHistosTrRcblPrim : fHistosTrRcblSec;
1415 for (int itc=0;itc<ntrCand;itc++) {
1416 int ind = indQual[itc];
1417 if (trComp[4][ind]<0) continue; // discarded
1418 double eta = -TMath::Log(TMath::Tan(trComp[AliITSMultReconstructor::kTrTheta][ind]/2));
1419 if (eta<fEtaMin || eta>fEtaMax) continue;
1420 double dThetaX = trComp[AliITSMultReconstructor::kTrTheta][ind];
1421 if (fScaleDTBySin2T) {
1422 double sint = TMath::Sin(trComp[AliITSMultReconstructor::kTrTheta][ind]);
1423 dThetaX /= (sint*sint);
1425 FillHistosSet(histos,eta,
1426 //trComp[AliITSMultReconstructor::kTrPhi][ind],trComp[AliITSMultReconstructor::kTrTheta][ind],
1427 trComp[AliITSMultReconstructor::kTrDPhi][ind],trComp[AliITSMultReconstructor::kTrDTheta][ind],
1428 dThetaX,trComp[5][ind]);
1436 //_________________________________________________________________________
1437 void AliTrackletTaskMulti::FillClusterInfo()
1439 // fill info on clusters associated to good tracklets
1440 if (!fMultReco) return;
1441 int ntr = fMultReco->GetNTracklets();
1443 TH2F *hclU[2] = {(TH2F*)fHistosCustom->UncheckedAt(kHClUsedInfoL0),(TH2F*)fHistosCustom->UncheckedAt(kHClUsedInfoL1)};
1444 TH2F *hclA[2] = {(TH2F*)fHistosCustom->UncheckedAt(kHClAllInfoL0),(TH2F*)fHistosCustom->UncheckedAt(kHClAllInfoL1)};
1445 for (int itr=ntr;itr--;) {
1446 Float_t *trc = fMultReco->GetTracklet(itr);
1447 if (TMath::Abs(TMath::Abs(trc[AliITSMultReconstructor::kTrDPhi])-fDPhiShift)>fDPhiSCut) continue;
1448 if (fMultReco->CalcDist(trc[AliITSMultReconstructor::kTrDPhi],
1449 trc[AliITSMultReconstructor::kTrDTheta],
1450 trc[AliITSMultReconstructor::kTrTheta]) > fNStdCut) continue;
1451 clID[0] = (int)trc[AliITSMultReconstructor::kClID1];
1452 clID[1] = (int)trc[AliITSMultReconstructor::kClID2];
1453 for (int il=0;il<2;il++) {
1454 Float_t *clinf = fMultReco->GetClusterOfLayer(il,clID[il]);
1455 hclU[il]->Fill( clinf[AliITSMultReconstructor::kClZ], clinf[AliITSMultReconstructor::kClPh]);
1459 for (int il=0;il<2;il++) for (int ic=fMultReco->GetNClustersLayer(il);ic--;) {
1460 Float_t *clinf = fMultReco->GetClusterOfLayer(il,ic);
1461 hclA[il]->Fill( clinf[AliITSMultReconstructor::kClZ], clinf[AliITSMultReconstructor::kClPh]);
1466 //_________________________________________________________________________
1467 void AliTrackletTaskMulti::FillClusterInfoFromMult(const AliMultiplicity* mlt, double zVertex)
1469 // fill info on clusters taking them from Multiplicity object
1470 const double kRSPD2 = 3.9;
1471 TH2F *hclU = (TH2F*)fHistosCustom->UncheckedAt(kHClUsedInfoL0);
1472 TH2F *hclA = (TH2F*)fHistosCustom->UncheckedAt(kHClAllInfoL0);
1473 int ntr = mlt->GetNumberOfTracklets();
1474 for (int itr=ntr;itr--;) {
1475 Bool_t goodTracklet = kTRUE;
1476 if (TMath::Abs( mlt->GetDeltaPhi(itr)-fDPhiShift)>fDPhiSCut) goodTracklet = kFALSE;
1477 if (mlt->CalcDist(itr) > fNStdCut) goodTracklet = kFALSE;
1478 double phi = mlt->GetPhi(itr);
1479 double z = kRSPD2/TMath::Tan(mlt->GetTheta(itr)) + zVertex;
1480 if (goodTracklet) hclU->Fill(z,phi);
1484 int ncl = mlt->GetNumberOfSingleClusters();
1485 for (int icl=ncl;icl--;) {
1486 double phi = mlt->GetPhiSingle(icl);
1487 double z = kRSPD2/TMath::Tan(mlt->GetThetaSingle(icl)) + zVertex;