LCOV - code coverage report
Current view: top level - ANALYSIS/ANALYSISalice - AliESDv0Cuts.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 128 485 26.4 %
Date: 2016-06-14 17:26:59 Functions: 6 23 26.1 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
       3             :  *                                                                        *
       4             :  * Author: The ALICE Off-line Project.                                    *
       5             :  * Contributors are mentioned in the code where appropriate.              *
       6             :  *                                                                        *
       7             :  * Permission to use, copy, modify and distribute this software and its   *
       8             :  * documentation strictly for non-commercial purposes is hereby granted   *
       9             :  * without fee, provided that the above copyright notice appears in all   *
      10             :  * copies and that both the copyright notice and this permission notice   *
      11             :  * appear in the supporting documentation. The authors make no claims     *
      12             :  * about the suitability of this software for any purpose. It is          *
      13             :  * provided "as is" without express or implied warranty.                  *
      14             :  **************************************************************************/
      15             : 
      16             : /* $Id: AliESDv0Cuts.cxx 24534 2008-03-16 22:22:11Z fca $ */
      17             : 
      18             : #include "AliESDv0Cuts.h"
      19             : 
      20             : #include <AliESDVertex.h>
      21             : #include <AliESDtrack.h>
      22             : #include <AliESDv0.h>
      23             : #include <AliESD.h>
      24             : #include <AliESDEvent.h>
      25             : #include <AliLog.h>
      26             : 
      27             : #include <TTree.h>
      28             : #include <TCanvas.h>
      29             : #include <TDirectory.h>
      30             : 
      31             : //____________________________________________________________________
      32         170 : ClassImp(AliESDv0Cuts)
      33             : 
      34             : // Cut names
      35             : const Char_t* AliESDv0Cuts::fgkCutNames[kNCuts] = {
      36             :  "dca positive to pvtx",
      37             :  "dca negative to pvtx",
      38             :  "#Chi^{2}",
      39             :  "dca v0 daughters",
      40             :  "min decay radius",
      41             :  "max decay radius",
      42             :  "cosine pointing angle",
      43             :  "on-the-fly status",
      44             :  "dca v0 to pvtx",
      45             :  "p",
      46             :  "p_{T}",
      47             :  "p_{x}",
      48             :  "p_{y}",
      49             :  "p_{z}"
      50             : };
      51             : 
      52             : //____________________________________________________________________
      53           2 : AliESDv0Cuts::AliESDv0Cuts(const Char_t* name, const Char_t* title) : AliAnalysisCuts(name,title),
      54           2 :   fCutMinDcaPosToVertex(0),
      55           2 :   fCutMinDcaNegToVertex(0),
      56           2 :   fCutMaxChi2(40),
      57           2 :   fCutMaxDcaV0Daughters(0),
      58           2 :   fCutMinRadius(0),
      59           2 :   fCutMaxRadius(0),
      60           2 :   fCutMinCosinePointingAngle(0),
      61           2 :   fCutRequireOnFlyStatus(0),
      62           2 :   fCutMaxDcaV0ToVertex(0),
      63           2 :   fPMin(0),
      64           2 :   fPMax(0),
      65           2 :   fPtMin(0),
      66           2 :   fPtMax(0),
      67           2 :   fPxMin(0),
      68           2 :   fPxMax(0),
      69           2 :   fPyMin(0),
      70           2 :   fPyMax(0),
      71           2 :   fPzMin(0),
      72           2 :   fPzMax(0),
      73           2 :   fHistogramsOn(0),
      74           2 :   fhCutStatistics(0),         
      75           2 :   fhCutCorrelation(0)
      76          10 : {
      77             :   //
      78             :   // constructor
      79             :   //
      80             : 
      81           2 :   Init();
      82             : 
      83             :   //##############################################################################
      84             :   // setting default cuts
      85           2 :   SetMinDcaPosToVertex();
      86           2 :   SetMinDcaNegToVertex();
      87           2 :   SetMaxChi2();
      88           2 :   SetMaxDcaV0Daughters();
      89           2 :   SetMinRadius();
      90           2 :   SetMaxRadius();
      91           2 :   SetMinCosinePointingAngle();
      92           2 :   SetRequireOnFlyStatus();
      93           2 :   SetMaxDcaV0ToVertex();
      94           2 :   SetPRange();
      95           2 :   SetPtRange();
      96           2 :   SetPxRange();
      97           2 :   SetPyRange();
      98           2 :   SetPzRange();
      99             : 
     100           2 :   SetHistogramsOn();
     101           4 : }
     102             : 
     103             : //_____________________________________________________________________________
     104           0 : AliESDv0Cuts::AliESDv0Cuts(const AliESDv0Cuts &c) : AliAnalysisCuts(c),
     105           0 :   fCutMinDcaPosToVertex(0),
     106           0 :   fCutMinDcaNegToVertex(0),
     107           0 :   fCutMaxChi2(0),
     108           0 :   fCutMaxDcaV0Daughters(0),
     109           0 :   fCutMinRadius(0),
     110           0 :   fCutMaxRadius(0),
     111           0 :   fCutMinCosinePointingAngle(0),
     112           0 :   fCutRequireOnFlyStatus(0),
     113           0 :   fCutMaxDcaV0ToVertex(0),
     114           0 :   fPMin(0),
     115           0 :   fPMax(0),
     116           0 :   fPtMin(0),
     117           0 :   fPtMax(0),
     118           0 :   fPxMin(0),
     119           0 :   fPxMax(0),
     120           0 :   fPyMin(0),
     121           0 :   fPyMax(0),
     122           0 :   fPzMin(0),
     123           0 :   fPzMax(0),
     124           0 :   fHistogramsOn(0),
     125           0 :   fhCutStatistics(0),         
     126           0 :   fhCutCorrelation(0)
     127           0 : {
     128             :   //
     129             :   // copy constructor
     130             :   //
     131             : 
     132           0 :   ((AliESDv0Cuts &) c).Copy(*this);
     133           0 : }
     134             : 
     135             : AliESDv0Cuts::~AliESDv0Cuts()
     136           0 : {
     137             :   //
     138             :   // destructor
     139             :   //
     140             : 
     141           0 :   for (Int_t i=0; i<2; i++) {
     142             :     
     143           0 :     if (fhDcaPosToVertex[i])
     144           0 :       delete fhDcaPosToVertex[i];
     145           0 :     if (fhDcaNegToVertex[i])
     146           0 :       delete fhDcaNegToVertex[i];
     147           0 :     if (fhChi2[i])
     148           0 :       delete fhChi2[i];
     149           0 :     if (fhDcaV0Daughters[i])
     150           0 :       delete fhDcaV0Daughters[i];
     151           0 :     if (fhRadius[i])
     152           0 :       delete fhRadius[i];             
     153           0 :     if (fhCosinePointingAngle[i])
     154           0 :       delete fhCosinePointingAngle[i];
     155           0 :     if (fhOnFlyStatus[i])
     156           0 :     delete fhOnFlyStatus[i];
     157           0 :     if (fhDcaV0ToVertex[i])
     158           0 :       delete fhDcaV0ToVertex[i];
     159           0 :     if (fhPt[i])
     160           0 :       delete fhPt[i];
     161             :   }
     162             : 
     163           0 :   if (fhCutStatistics)
     164           0 :     delete fhCutStatistics;             
     165           0 :   if (fhCutCorrelation)
     166           0 :     delete fhCutCorrelation;            
     167           0 : }
     168             : 
     169             : void AliESDv0Cuts::Init()
     170             : {
     171             :   //
     172             :   // sets everything to zero
     173             :   //
     174           4 :   fCutMinDcaPosToVertex      = 0;
     175           2 :   fCutMinDcaNegToVertex      = 0;
     176           2 :   fCutMaxChi2                = 0;
     177           2 :   fCutMaxDcaV0Daughters      = 0;
     178           2 :   fCutMinRadius              = 0;
     179           2 :   fCutMaxRadius              = 0;
     180           2 :   fCutMinCosinePointingAngle = 0;
     181           2 :   fCutRequireOnFlyStatus     = 0;
     182           2 :   fCutMaxDcaV0ToVertex       = 0;
     183             : 
     184           2 :   fPMin  = 0;
     185           2 :   fPMax  = 0;
     186           2 :   fPtMin = 0;
     187           2 :   fPtMax = 0;
     188           2 :   fPxMin = 0;
     189           2 :   fPxMax = 0;
     190           2 :   fPyMin = 0;
     191           2 :   fPyMax = 0;
     192           2 :   fPzMin = 0;
     193           2 :   fPzMax = 0;
     194             : 
     195           2 :   fHistogramsOn = kFALSE;
     196             : 
     197          12 :   for (Int_t i=0; i<2; ++i)
     198             :   {
     199           4 :     fhDcaPosToVertex[i]      = 0;
     200           4 :     fhDcaNegToVertex[i]      = 0;
     201           4 :     fhChi2[i]                = 0;
     202           4 :     fhDcaV0Daughters[i]      = 0;
     203           4 :     fhRadius[i]              = 0;
     204           4 :     fhCosinePointingAngle[i] = 0;
     205           4 :     fhOnFlyStatus[i]         = 0;
     206           4 :     fhDcaV0ToVertex[i]       = 0;
     207             :     
     208           4 :     fhPt[i]                  = 0;
     209             :   }
     210           2 :   fhCutStatistics = 0;
     211           2 :   fhCutCorrelation = 0;
     212           2 : }
     213             : 
     214             : //_____________________________________________________________________________
     215             : AliESDv0Cuts &AliESDv0Cuts::operator=(const AliESDv0Cuts &c)
     216             : {
     217             :   //
     218             :   // Assignment operator
     219             :   //
     220             : 
     221           0 :   if (this != &c) ((AliESDv0Cuts &) c).Copy(*this);
     222           0 :   return *this;
     223             : }
     224             : 
     225             : //_____________________________________________________________________________
     226             : void AliESDv0Cuts::Copy(TObject &c) const
     227             : {
     228             :   //
     229             :   // Copy function
     230             :   //
     231             : 
     232           0 :   AliESDv0Cuts& target = (AliESDv0Cuts &) c;
     233             : 
     234           0 :   target.Init();
     235             : 
     236           0 :   target.fCutMinDcaPosToVertex      = fCutMinDcaPosToVertex;
     237           0 :   target.fCutMinDcaNegToVertex      = fCutMinDcaNegToVertex;
     238           0 :   target.fCutMaxChi2                = fCutMaxChi2;
     239           0 :   target.fCutMaxDcaV0Daughters      = fCutMaxDcaV0Daughters;
     240           0 :   target.fCutMinRadius              = fCutMinRadius;
     241           0 :   target.fCutMaxRadius              = fCutMaxRadius;
     242           0 :   target.fCutMinCosinePointingAngle = fCutMinCosinePointingAngle;
     243           0 :   target.fCutRequireOnFlyStatus     = fCutRequireOnFlyStatus;
     244           0 :   target.fCutMaxDcaV0ToVertex       = fCutMaxDcaV0ToVertex;
     245             : 
     246           0 :   target.fPMin  = fPMin;
     247           0 :   target.fPMax  = fPMax;
     248           0 :   target.fPtMin = fPtMin;
     249           0 :   target.fPtMax = fPtMax;
     250           0 :   target.fPxMin = fPxMin;
     251           0 :   target.fPxMax = fPxMax;
     252           0 :   target.fPyMin = fPyMin;
     253           0 :   target.fPyMax = fPyMax;
     254           0 :   target.fPzMin = fPzMin;
     255           0 :   target.fPzMax = fPzMax;
     256             : 
     257           0 :   target.fHistogramsOn = fHistogramsOn;
     258             : 
     259           0 :   for (Int_t i=0; i<2; ++i)
     260             :   {
     261           0 :     if (fhDcaPosToVertex[i]) target.fhDcaPosToVertex[i] = (TH1F*) fhDcaPosToVertex[i]->Clone();
     262           0 :     if (fhDcaNegToVertex[i]) target.fhDcaNegToVertex[i] = (TH1F*) fhDcaNegToVertex[i]->Clone();
     263           0 :     if (fhChi2[i]) target.fhChi2[i] = (TH1F*) fhChi2[i]->Clone();
     264           0 :     if (fhDcaV0Daughters[i]) target.fhDcaV0Daughters[i] = (TH1F*) fhDcaV0Daughters[i]->Clone();
     265           0 :     if (fhRadius[i]) target.fhRadius[i] = (TH1F*) fhRadius[i]->Clone();
     266           0 :     if (fhCosinePointingAngle[i]) target.fhCosinePointingAngle[i] = (TH1F*) fhCosinePointingAngle[i]->Clone();
     267           0 :     if (fhOnFlyStatus[i]) target.fhOnFlyStatus[i] = (TH1F*) fhOnFlyStatus[i]->Clone();
     268           0 :     if (fhDcaV0ToVertex[i]) target.fhDcaV0ToVertex[i] = (TH1F*) fhDcaV0ToVertex[i]->Clone();
     269             :     
     270           0 :     if (fhPt[i]) target.fhPt[i] = (TH1F*) fhPt[i]->Clone();
     271             :   }
     272           0 :   if (fhCutStatistics) target.fhCutStatistics = (TH1F*) fhCutStatistics->Clone();
     273           0 :   if (fhCutCorrelation) target.fhCutCorrelation = (TH2F*) fhCutCorrelation->Clone();
     274             : 
     275           0 :   TNamed::Copy(c);
     276           0 : }
     277             : 
     278             : //_____________________________________________________________________________
     279             : Long64_t AliESDv0Cuts::Merge(TCollection* list) {
     280             :   // Merge a list of AliESDv0Cuts objects with this (needed for PROOF)
     281             :   // Returns the number of merged objects (including this)
     282             : 
     283           0 :   if (!list)
     284           0 :     return 0;
     285             :   
     286           0 :   if (list->IsEmpty())
     287           0 :     return 1;
     288             : 
     289           0 :   if (!fHistogramsOn)
     290           0 :     return 0;
     291             : 
     292           0 :   TIterator* iter = list->MakeIterator();
     293             :   TObject* obj;
     294             : 
     295             : 
     296             :   // collection of measured and generated histograms
     297             :   Int_t count = 0;
     298           0 :   while ((obj = iter->Next())) {
     299             : 
     300           0 :     AliESDv0Cuts* entry = dynamic_cast<AliESDv0Cuts*>(obj);
     301           0 :     if (entry == 0)
     302           0 :       continue;
     303             : 
     304           0 :     if (!entry->fHistogramsOn)
     305           0 :       continue;
     306             :     
     307           0 :     for (Int_t i=0; i<2; i++) {
     308             :       
     309           0 :       fhDcaPosToVertex[i]     ->Add(entry->fhDcaPosToVertex[i]     );
     310           0 :       fhDcaNegToVertex[i]     ->Add(entry->fhDcaNegToVertex[i]     );
     311           0 :       fhChi2[i]               ->Add(entry->fhChi2[i]               );
     312           0 :       fhDcaV0Daughters[i]     ->Add(entry->fhDcaV0Daughters[i]     );
     313           0 :       fhRadius[i]             ->Add(entry->fhRadius[i]             );
     314           0 :       fhCosinePointingAngle[i]->Add(entry->fhCosinePointingAngle[i]);
     315           0 :       fhOnFlyStatus[i]        ->Add(entry->fhOnFlyStatus[i]        );
     316           0 :       fhDcaV0ToVertex[i]      ->Add(entry->fhDcaV0ToVertex[i]      );
     317             : 
     318           0 :       fhPt[i]                ->Add(entry->fhPt[i]);
     319             :     }      
     320           0 :     fhCutStatistics  ->Add(entry->fhCutStatistics);        
     321           0 :     fhCutCorrelation ->Add(entry->fhCutCorrelation);      
     322             : 
     323           0 :     count++;
     324           0 :   }
     325             : 
     326           0 :   return count+1;
     327           0 : }
     328             : 
     329             : void AliESDv0Cuts::EnableNeededBranches(TTree* tree)
     330             : {
     331             :   // enables the branches needed by AcceptV0, for a list see comment of AcceptV0
     332             : 
     333           0 :   tree->SetBranchStatus("fV0s.fDcaV0Daughters", 1);
     334           0 :   tree->SetBranchStatus("fV0s.fChi2V0", 1);
     335           0 :   tree->SetBranchStatus("fV0s.fPos*", 1);
     336           0 :   tree->SetBranchStatus("fV0s.fNmom*", 1);
     337           0 :   tree->SetBranchStatus("fV0s.fPmom*", 1);
     338           0 :   tree->SetBranchStatus("fV0s.fRr", 1);
     339           0 :   tree->SetBranchStatus("fV0s.fPointAngle*", 1);
     340           0 :   tree->SetBranchStatus("fV0s.fOnFlyStatus", 1);
     341           0 : }
     342             : 
     343             : //____________________________________________________________________
     344             : Bool_t
     345             : AliESDv0Cuts::IsSelected(TList* listObj) {
     346             : // Selection cuts
     347          52 :   if(listObj->GetSize()!=4) return kFALSE;
     348          26 :   AliESDv0           *esdV0     = (AliESDv0*)listObj->At(0);
     349          26 :   AliESDtrack        *trackPos  = (AliESDtrack*)listObj->At(1);
     350          26 :   AliESDtrack        *trackNeg  = (AliESDtrack*)listObj->At(2);
     351          26 :   const AliESDVertex *esdVertex = (AliESDVertex*)listObj->At(3);
     352          26 :   return AcceptV0(esdV0,trackPos,trackNeg,esdVertex);
     353          26 : }
     354             : 
     355             : //____________________________________________________________________
     356             : Bool_t
     357             : AliESDv0Cuts::AcceptV0(AliESDv0* const esdV0, AliESDtrack* const trackPos, AliESDtrack* const trackNeg, const AliESDVertex* esdVertex) {
     358             :   // 
     359             :   // figure out if the v0s survives all the v0 cuts defined
     360             :   //
     361             :   // the different quality parameter and kinematic values are first
     362             :   // retrieved from the v0. then it is found out what cuts the
     363             :   // v0 did not survive and finally the cuts are imposed.
     364             : 
     365             :   // this function needs the following branches... but this is not enough
     366             :   // fV0s.fDcaV0Daughters
     367             :   // fV0s.fChi2V0
     368             :   // fV0s.fPos*
     369             :   // fV0s.fNmom*
     370             :   // fV0s.fPmom*
     371             :   // fV0s.fRr
     372             :   // fV0s.fPointAngle
     373             :   // fV0s.fOnFlyStatus
     374             : 
     375             :   Float_t  dcaPosToVertex = 0, dcaNegToVertex = 0;
     376          52 :   Float_t  tdcaPosToVertex[2]={999,999};
     377          26 :   Float_t  tdcaNegToVertex[2]={999,999};
     378             : 
     379          52 :   if (trackPos) trackPos->GetImpactParameters(tdcaPosToVertex[0],tdcaPosToVertex[1]);
     380          52 :   if (trackNeg) trackNeg->GetImpactParameters(tdcaNegToVertex[0],tdcaNegToVertex[1]);
     381             : 
     382          26 :   dcaPosToVertex = TMath::Sqrt(tdcaPosToVertex[0]*tdcaPosToVertex[0]+tdcaPosToVertex[1]*tdcaPosToVertex[1]);
     383          26 :   dcaNegToVertex = TMath::Sqrt(tdcaNegToVertex[0]*tdcaNegToVertex[0]+tdcaNegToVertex[1]*tdcaNegToVertex[1]);
     384             : 
     385          26 :   UInt_t  status = esdV0->GetOnFlyStatus();
     386          26 :   Float_t chi2  = esdV0->GetChi2V0();
     387             : 
     388          26 :   Double_t dcaV0Daughters = esdV0->GetDcaV0Daughters();
     389             : 
     390          26 :   Double_t vtxPosition[3]; esdVertex->GetXYZ(vtxPosition);
     391          26 :   Double_t dcaV0ToVertex  = esdV0->GetD(vtxPosition[0],vtxPosition[1],vtxPosition[2]);
     392             : 
     393          26 :   Double_t v0Position[3];
     394          26 :   esdV0->GetXYZ(v0Position[0],v0Position[1],v0Position[2]);
     395          26 :   Double_t radius = TMath::Sqrt(TMath::Power(v0Position[0],2) + TMath::Power(v0Position[1],2));
     396          26 :   Double_t v0CosinePointingAngle = esdV0->GetV0CosineOfPointingAngle();
     397             : 
     398             :   // getting the kinematic variables of the v0
     399          26 :   Double_t p[3];
     400          26 :   esdV0->GetPxPyPz(p[0],p[1],p[2]);
     401          26 :   Float_t momentum = TMath::Sqrt(TMath::Power(p[0],2) + TMath::Power(p[1],2) + TMath::Power(p[2],2));
     402          26 :   Float_t pt       = TMath::Sqrt(TMath::Power(p[0],2) + TMath::Power(p[1],2));
     403             : 
     404             :   //########################################################################
     405             :   // cut the v0?
     406             :   
     407          26 :   Bool_t cuts[kNCuts];
     408         780 :   for (Int_t i=0; i<kNCuts; i++) cuts[i]=kFALSE;
     409             :   
     410             :   // v0 quality cuts
     411          26 :   if (dcaPosToVertex < fCutMinDcaPosToVertex)
     412           2 :     cuts[0]=kTRUE;
     413          26 :   if (dcaNegToVertex < fCutMinDcaNegToVertex) 
     414           6 :     cuts[1]=kTRUE;
     415          26 :   if (chi2 > fCutMaxChi2) 
     416           0 :     cuts[2]=kTRUE; 
     417          26 :   if (dcaV0Daughters > fCutMaxDcaV0Daughters) 
     418           2 :     cuts[3]=kTRUE;  
     419          26 :   if (radius  < fCutMinRadius) 
     420           0 :     cuts[4]=kTRUE;  
     421          26 :   if (radius  > fCutMaxRadius) 
     422           0 :     cuts[5]=kTRUE;  
     423          26 :   if (v0CosinePointingAngle < fCutMinCosinePointingAngle)
     424           4 :     cuts[6]=kTRUE;  
     425          26 :   if (fCutRequireOnFlyStatus && !status)
     426           0 :     cuts[7]=kTRUE;  
     427          26 :   if (dcaV0ToVertex > fCutMaxDcaV0ToVertex)
     428           0 :     cuts[8] = kTRUE;
     429             : 
     430             :   // v0 kinematics cut
     431          52 :   if((momentum < fPMin) || (momentum > fPMax)) 
     432           0 :     cuts[9]=kTRUE;
     433          52 :   if((pt < fPtMin) || (pt > fPtMax)) 
     434           0 :     cuts[10] = kTRUE;
     435          52 :   if((p[0] < fPxMin) || (p[0] > fPxMax)) 
     436           0 :     cuts[11] = kTRUE;
     437          52 :   if((p[1] < fPyMin) || (p[1] > fPyMax)) 
     438           0 :     cuts[12] = kTRUE;
     439          52 :   if((p[2] < fPzMin) || (p[2] > fPzMax))
     440           0 :     cuts[13] = kTRUE;
     441             : 
     442             :   Bool_t cut=kFALSE;
     443         780 :   for (Int_t i=0; i<kNCuts; i++) 
     444         378 :     if (cuts[i]) cut = kTRUE;
     445             :   
     446             :   //########################################################################
     447             :   // filling histograms
     448          26 :   if (fHistogramsOn) {
     449           0 :     fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin("n v0s")));
     450             :     
     451           0 :     if (cut)
     452           0 :       fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin("n cut v0s")));
     453             :     
     454           0 :     for (Int_t i=0; i<kNCuts; i++) {
     455           0 :       if (cuts[i])
     456           0 :         fhCutStatistics->Fill(fhCutStatistics->GetBinCenter(fhCutStatistics->GetXaxis()->FindBin(fgkCutNames[i])));
     457             :       
     458           0 :       for (Int_t j=i; j<kNCuts; j++) {
     459           0 :         if (cuts[i] && cuts[j]) {
     460           0 :           Float_t x = fhCutCorrelation->GetXaxis()->GetBinCenter(fhCutCorrelation->GetXaxis()->FindBin(fgkCutNames[i]));
     461           0 :           Float_t y = fhCutCorrelation->GetYaxis()->GetBinCenter(fhCutCorrelation->GetYaxis()->FindBin(fgkCutNames[j]));
     462           0 :           fhCutCorrelation->Fill(x,y);
     463           0 :         }
     464             :       }
     465             :     }
     466             :     
     467           0 :     fhDcaPosToVertex[0]->Fill(dcaPosToVertex);
     468           0 :     fhDcaNegToVertex[0]->Fill(dcaNegToVertex);
     469           0 :     fhChi2[0]->Fill(chi2);
     470           0 :     fhDcaV0Daughters[0]->Fill(dcaV0Daughters);
     471           0 :     fhRadius[0]->Fill(radius);
     472           0 :     fhCosinePointingAngle[0]->Fill(v0CosinePointingAngle);
     473           0 :     fhOnFlyStatus[0]->Fill(status);
     474           0 :     fhDcaV0ToVertex[0]->Fill(dcaV0ToVertex);
     475             :     
     476           0 :     fhPt[0]->Fill(pt);
     477           0 :   }
     478             : 
     479             :   //########################################################################
     480             :   // cut the v0!
     481          36 :   if (cut) return kFALSE;
     482             : 
     483             :   //########################################################################
     484             :   // filling histograms after cut
     485          16 :   if (fHistogramsOn) {
     486           0 :     fhDcaPosToVertex[1]->Fill(dcaPosToVertex);
     487           0 :     fhDcaNegToVertex[1]->Fill(dcaNegToVertex);
     488           0 :     fhChi2[1]->Fill(chi2);
     489           0 :     fhDcaV0Daughters[1]->Fill(dcaV0Daughters);
     490           0 :     fhRadius[1]->Fill(radius);
     491           0 :     fhCosinePointingAngle[1]->Fill(v0CosinePointingAngle);
     492           0 :     fhOnFlyStatus[1]->Fill(status);
     493           0 :     fhDcaV0ToVertex[1]->Fill(dcaV0ToVertex);
     494             :     
     495           0 :     fhPt[1]->Fill(pt);
     496           0 :   }
     497             : 
     498          16 :   return kTRUE;
     499          26 : }
     500             : 
     501             : //____________________________________________________________________
     502             : TObjArray* AliESDv0Cuts::GetAcceptedV0s(const AliESD* esd)
     503             : {
     504             :   //
     505             :   // returns an array of all v0s that pass the cuts
     506             :   //
     507             : 
     508           0 :   TObjArray* acceptedV0s = new TObjArray();
     509             :   //  const AliESDVertex *spdVertex = esd->GetVertex();
     510           0 :   const AliESDVertex *primaryVertex = esd->GetPrimaryVertex();
     511             :   Int_t    lIndexTrackPos       = 0, lIndexTrackNeg       = 0;
     512             : 
     513             :   // loop over esd v0s
     514           0 :   for (Int_t iV0 = 0; iV0 < esd->GetNumberOfV0s(); iV0++) {
     515           0 :     AliESDv0* v0 = esd->GetV0(iV0);
     516             : 
     517           0 :     lIndexTrackPos = TMath::Abs(v0->GetPindex());
     518           0 :     lIndexTrackNeg = TMath::Abs(v0->GetNindex());
     519           0 :     AliESDtrack *trackPos = esd->GetTrack(lIndexTrackPos);
     520           0 :     AliESDtrack *trackNeg = esd->GetTrack(lIndexTrackNeg);
     521             : 
     522           0 :     if (AcceptV0(v0,trackPos,trackNeg,primaryVertex))
     523           0 :       acceptedV0s->Add(v0);
     524             :   }
     525             : 
     526           0 :   return acceptedV0s;
     527           0 : }
     528             : 
     529             : //____________________________________________________________________
     530             : Int_t AliESDv0Cuts::CountAcceptedV0s(const AliESD* esd)
     531             : {
     532             :   //
     533             :   // returns an the number of v0s that pass the cuts
     534             :   //
     535             : 
     536             :   Int_t count = 0;
     537             :   //  const AliESDVertex *spdVertex = esd->GetVertex();
     538           0 :   const AliESDVertex *primaryVertex = esd->GetPrimaryVertex();
     539             :   Int_t    lIndexTrackPos       = 0, lIndexTrackNeg       = 0;
     540             : 
     541             :   // loop over esd v0s
     542           0 :   for (Int_t iV0 = 0; iV0 < esd->GetNumberOfV0s(); iV0++) {
     543           0 :     AliESDv0* v0 = esd->GetV0(iV0);
     544             : 
     545           0 :     lIndexTrackPos = TMath::Abs(v0->GetPindex());
     546           0 :     lIndexTrackNeg = TMath::Abs(v0->GetNindex());
     547           0 :     AliESDtrack *trackPos = esd->GetTrack(lIndexTrackPos);
     548           0 :     AliESDtrack *trackNeg = esd->GetTrack(lIndexTrackNeg);
     549             : 
     550           0 :     if (AcceptV0(v0,trackPos,trackNeg,primaryVertex))
     551           0 :       count++;
     552             :   }
     553             : 
     554           0 :   return count;
     555             : }
     556             : 
     557             : //____________________________________________________________________
     558             : TObjArray* AliESDv0Cuts::GetAcceptedV0s(const AliESDEvent* esd)
     559             : {
     560             :   //
     561             :   // returns an array of all v0s that pass the cuts
     562             :   //
     563             : 
     564           0 :   TObjArray* acceptedV0s = new TObjArray();
     565             :   //  const AliESDVertex *spdVertex = esd->GetVertex();
     566           0 :   const AliESDVertex *primaryVertex = esd->GetPrimaryVertex();
     567             :   Int_t    lIndexTrackPos       = 0, lIndexTrackNeg       = 0;
     568             : 
     569             :   // loop over esd v0s
     570           0 :   for (Int_t iV0 = 0; iV0 < esd->GetNumberOfV0s(); iV0++) {
     571           0 :     AliESDv0* v0 = esd->GetV0(iV0);
     572             : 
     573           0 :     lIndexTrackPos = TMath::Abs(v0->GetPindex());
     574           0 :     lIndexTrackNeg = TMath::Abs(v0->GetNindex());
     575           0 :     AliESDtrack *trackPos = esd->GetTrack(lIndexTrackPos);
     576           0 :     AliESDtrack *trackNeg = esd->GetTrack(lIndexTrackNeg);
     577             : 
     578           0 :     if (AcceptV0(v0,trackPos,trackNeg,primaryVertex))
     579           0 :       acceptedV0s->Add(v0);
     580             :   }
     581             : 
     582           0 :   return acceptedV0s;
     583           0 : }
     584             : 
     585             : //____________________________________________________________________
     586             : Int_t AliESDv0Cuts::CountAcceptedV0s(const AliESDEvent* esd)
     587             : {
     588             :   //
     589             :   // returns an the number of v0s that pass the cuts
     590             :   //
     591             : 
     592             :   Int_t count = 0;
     593             :   //  const AliESDVertex *spdVertex = esd->GetVertex();
     594           0 :   const AliESDVertex *primaryVertex = esd->GetPrimaryVertex();
     595             :   Int_t    lIndexTrackPos       = 0, lIndexTrackNeg       = 0;
     596             : 
     597             :   // loop over esd v0s
     598           0 :   for (Int_t iV0 = 0; iV0 < esd->GetNumberOfV0s(); iV0++) {
     599           0 :     AliESDv0* v0 = esd->GetV0(iV0);
     600             : 
     601           0 :     lIndexTrackPos = TMath::Abs(v0->GetPindex());
     602           0 :     lIndexTrackNeg = TMath::Abs(v0->GetNindex());
     603           0 :     AliESDtrack *trackPos = esd->GetTrack(lIndexTrackPos);
     604           0 :     AliESDtrack *trackNeg = esd->GetTrack(lIndexTrackNeg);
     605             : 
     606           0 :     if (AcceptV0(v0,trackPos,trackNeg,primaryVertex))
     607           0 :       count++;
     608             :   }
     609             : 
     610           0 :   return count;
     611             : }
     612             : 
     613             : //____________________________________________________________________
     614             :  void AliESDv0Cuts::DefineHistograms(Int_t color) {
     615             :    // 
     616             :    // diagnostics histograms are defined
     617             :    // 
     618             : 
     619           0 :    fHistogramsOn=kTRUE;
     620             :    
     621           0 :    Bool_t oldStatus = TH1::AddDirectoryStatus();
     622           0 :    TH1::AddDirectory(kFALSE);
     623             :    
     624             :    //###################################################################################
     625             :    // defining histograms
     626             : 
     627           0 :    fhCutStatistics = new TH1F("cut_statistics","cut statistics",kNCuts+4,-0.5,kNCuts+3.5);
     628             : 
     629           0 :    fhCutStatistics->GetXaxis()->SetBinLabel(1,"n v0s");
     630           0 :    fhCutStatistics->GetXaxis()->SetBinLabel(2,"n cut v0s");
     631             : 
     632           0 :    fhCutCorrelation = new TH2F("cut_correlation","cut correlation",kNCuts,-0.5,kNCuts-0.5,kNCuts,-0.5,kNCuts-0.5);;
     633             :   
     634           0 :    for (Int_t i=0; i<kNCuts; i++) {
     635           0 :      fhCutStatistics->GetXaxis()->SetBinLabel(i+4,fgkCutNames[i]);
     636           0 :      fhCutCorrelation->GetXaxis()->SetBinLabel(i+1,fgkCutNames[i]);
     637           0 :      fhCutCorrelation->GetYaxis()->SetBinLabel(i+1,fgkCutNames[i]);
     638             :    } 
     639             : 
     640           0 :   fhCutStatistics  ->SetLineColor(color);
     641           0 :   fhCutCorrelation ->SetLineColor(color);
     642           0 :   fhCutStatistics  ->SetLineWidth(2);
     643           0 :   fhCutCorrelation ->SetLineWidth(2);
     644             : 
     645           0 :   Char_t str[256];
     646           0 :   for (Int_t i=0; i<2; i++) {
     647           0 :     if (i==0) snprintf(str,256, " ");
     648           0 :     else snprintf(str,256, "_cut");
     649             : 
     650           0 :     fhDcaPosToVertex[i]      = new TH1F(Form("dcaPosToVertex%s",str),"",120,0,3);
     651           0 :     fhDcaNegToVertex[i]      = new TH1F(Form("dcaNegToVertex%s",str),"",120,0,3);
     652           0 :     fhChi2[i]                = new TH1F(Form("chi2%s",str),"",50,0,50);
     653           0 :     fhDcaV0Daughters[i]      = new  TH1F(Form("dcaV0Daughters%s",str),"",200,0,5);
     654           0 :     fhRadius[i]              = new  TH1F(Form("decayRadius%s",str),"",300,0,150);
     655           0 :     fhCosinePointingAngle[i] = new  TH1F(Form("cosinePointingAngle%s",str),"",100,-1,1);
     656           0 :     fhOnFlyStatus[i]         = new  TH1F(Form("onflystatus%s",str),"",5,0,5);
     657           0 :     fhDcaV0ToVertex[i]       = new  TH1F(Form("dcaV0ToVertex%s",str),"",100,0,5);
     658             : 
     659           0 :     fhPt[i]                  = new TH1F(Form("pt%s",str)     ,"p_{T} distribution;p_{T} (GeV/c)",500,0.0,100.0);
     660             :     
     661           0 :     fhDcaPosToVertex[i]->SetTitle("Dca of positive daughter to parent vertex");
     662           0 :     fhDcaNegToVertex[i]->SetTitle("Dca of negative daughter to parent vertex");
     663           0 :     fhChi2[i]->SetTitle("#Chi^{2} for v0");
     664           0 :     fhDcaV0Daughters[i]->SetTitle("Dca between daughter tracks");
     665           0 :     fhRadius[i]->SetTitle("Decay radius of the v0");
     666           0 :     fhCosinePointingAngle[i]->SetTitle("Cosine of the Pointing Angle");
     667           0 :     fhOnFlyStatus[i]->SetTitle("On-the-Fly Status");
     668           0 :     fhDcaV0ToVertex[i]->SetTitle("Dca of v0 to parent vertex");
     669             : 
     670           0 :     fhDcaPosToVertex[i]->SetLineColor(color);      fhDcaPosToVertex[i]->SetLineWidth(2);
     671           0 :     fhDcaNegToVertex[i]->SetLineColor(color);      fhDcaNegToVertex[i]->SetLineWidth(2);
     672           0 :     fhChi2[i]->SetLineColor(color);                fhChi2[i]->SetLineWidth(2);
     673           0 :     fhDcaV0Daughters[i]->SetLineColor(color);      fhDcaV0Daughters[i]->SetLineWidth(2);
     674           0 :     fhRadius[i]->SetLineColor(color);              fhRadius[i]->SetLineWidth(2);
     675           0 :     fhCosinePointingAngle[i]->SetLineColor(color); fhCosinePointingAngle[i]->SetLineWidth(2);
     676           0 :     fhOnFlyStatus[i]->SetLineColor(color);         fhOnFlyStatus[i]->SetLineWidth(2);
     677           0 :     fhDcaV0ToVertex[i]->SetLineColor(color);       fhDcaV0ToVertex[i]->SetLineWidth(2); 
     678             :   }
     679             : 
     680           0 :   TH1::AddDirectory(oldStatus);
     681           0 : }
     682             : 
     683             : //____________________________________________________________________
     684             : Bool_t AliESDv0Cuts::LoadHistograms(const Char_t* dir)
     685             : {
     686             :   //
     687             :   // loads the histograms from a file
     688             :   // if dir is empty a directory with the name of this object is taken (like in SaveHistogram)
     689             :   //
     690             : 
     691           0 :   if (!dir)
     692           0 :     dir = GetName();
     693             : 
     694           0 :   if (!gDirectory->cd(dir))
     695           0 :     return kFALSE;
     696             : 
     697           0 :   fhCutStatistics = dynamic_cast<TH1F*> (gDirectory->Get("cut_statistics"));
     698           0 :   fhCutCorrelation = dynamic_cast<TH2F*> (gDirectory->Get("cut_correlation"));
     699             : 
     700           0 :   Char_t str[5];
     701           0 :   for (Int_t i=0; i<2; i++) {
     702           0 :     if (i==0)
     703             :     {
     704           0 :       gDirectory->cd("before_cuts");
     705           0 :       str[0] = 0;
     706           0 :     }
     707             :     else
     708             :     {
     709           0 :       gDirectory->cd("after_cuts");
     710           0 :       snprintf(str,5, "_cut");
     711             :     }
     712             : 
     713           0 :     fhDcaPosToVertex[i]      = dynamic_cast<TH1F*> (gDirectory->Get(Form("dcaPosToVertex%s",str)     ));
     714           0 :     fhDcaNegToVertex[i]      = dynamic_cast<TH1F*> (gDirectory->Get(Form("dcaNegToVertex%s",str)     ));
     715           0 :     fhChi2[i] = dynamic_cast<TH1F*> (gDirectory->Get(Form("chi2%s",str)));
     716           0 :     fhDcaV0Daughters[i] = dynamic_cast<TH1F*> (gDirectory->Get(Form("dcaV0Daughters%s",str)));
     717           0 :     fhRadius[i] = dynamic_cast<TH1F*> (gDirectory->Get(Form("decayRadius%s",str)));
     718           0 :     fhCosinePointingAngle[i] = dynamic_cast<TH1F*> (gDirectory->Get(Form("cosinepointingangle%s",str)));
     719           0 :     fhOnFlyStatus[i] = dynamic_cast<TH1F*> (gDirectory->Get(Form("onflystatus%s",str)));
     720           0 :     fhDcaV0ToVertex[i] = dynamic_cast<TH1F*> (gDirectory->Get(Form("dcaV0ToVertex%s",str)));
     721             : 
     722           0 :     fhPt[i] = dynamic_cast<TH1F*> (gDirectory->Get(Form("pt%s",str)));
     723             : 
     724           0 :     gDirectory->cd("../");
     725             :   }
     726             : 
     727           0 :   gDirectory->cd("..");
     728             : 
     729             :   return kTRUE;
     730           0 : }
     731             : 
     732             : //____________________________________________________________________
     733             : void AliESDv0Cuts::SaveHistograms(const Char_t* dir) {
     734             :   //
     735             :   // saves the histograms in a directory (dir)
     736             :   //
     737             : 
     738           0 :   if (!fHistogramsOn) {
     739           0 :     AliDebug(0, "Histograms not on - cannot save histograms!!!");
     740             :     return;
     741             :   }
     742             : 
     743           0 :   if (!dir)
     744           0 :     dir = GetName();
     745             : 
     746           0 :   gDirectory->mkdir(dir);
     747           0 :   gDirectory->cd(dir);
     748             : 
     749           0 :   gDirectory->mkdir("before_cuts");
     750           0 :   gDirectory->mkdir("after_cuts");
     751             :  
     752           0 :   fhCutStatistics->Write();
     753           0 :   fhCutCorrelation->Write();
     754             : 
     755           0 :   for (Int_t i=0; i<2; i++) {
     756           0 :     if (i==0)
     757           0 :       gDirectory->cd("before_cuts");
     758             :     else
     759           0 :       gDirectory->cd("after_cuts");
     760             : 
     761           0 :     fhDcaPosToVertex[i]      ->Write();
     762           0 :     fhDcaNegToVertex[i]      ->Write();
     763           0 :     fhChi2[i]                ->Write();
     764           0 :     fhDcaV0Daughters[i]      ->Write();
     765           0 :     fhRadius[i]              ->Write();
     766           0 :     fhCosinePointingAngle[i] ->Write();
     767           0 :     fhOnFlyStatus[i]         ->Write();
     768           0 :     fhDcaV0ToVertex[i]       ->Write();
     769             : 
     770           0 :     fhPt[i]                  ->Write();
     771             :     
     772           0 :     gDirectory->cd("../");
     773             :   }
     774             : 
     775           0 :   gDirectory->cd("../");
     776           0 : }
     777             : 
     778             : //____________________________________________________________________
     779             : void AliESDv0Cuts::DrawHistograms()
     780             : {
     781             :   // draws some histograms
     782             : 
     783           0 :   TCanvas* canvas1 = new TCanvas(Form("%s_1", GetName()), "V0 Quality Results1", 800, 800);
     784           0 :   canvas1->Divide(2, 2);
     785             : 
     786           0 :   canvas1->cd(1);
     787           0 :   fhDcaPosToVertex[0]->SetStats(kFALSE);
     788           0 :   fhDcaPosToVertex[0]->Draw();
     789             : 
     790           0 :   canvas1->cd(2);
     791           0 :   fhChi2[0]->SetStats(kFALSE);
     792           0 :   fhChi2[0]->Draw();
     793             : 
     794           0 :   canvas1->cd(3);
     795           0 :   fhDcaV0ToVertex[0]->SetStats(kFALSE);
     796           0 :   fhDcaV0ToVertex[0]->Draw();
     797             : 
     798           0 :   canvas1->SaveAs(Form("%s_%s.gif", GetName(), canvas1->GetName()));
     799             : 
     800           0 :   TCanvas* canvas2 = new TCanvas(Form("%s_2", GetName()), "V0 Quality Results2", 1200, 800);
     801           0 :   canvas2->Divide(3, 2);
     802             : 
     803           0 :   canvas2->cd(1);
     804           0 :   fhDcaV0Daughters[0]->SetStats(kFALSE);
     805           0 :   gPad->SetLogy();
     806           0 :   fhDcaV0Daughters[0]->Draw();
     807             : 
     808           0 :   canvas2->cd(2);
     809           0 :   fhRadius[0]->SetStats(kFALSE);
     810           0 :   gPad->SetLogy();
     811           0 :   fhRadius[0]->Draw();
     812             : 
     813             : 
     814           0 :   canvas2->cd(4);
     815           0 :   fhCosinePointingAngle[0]->SetStats(kFALSE);
     816           0 :   gPad->SetLogy();
     817           0 :   fhCosinePointingAngle[0]->Draw();
     818             : 
     819           0 :   canvas2->cd(5);
     820           0 :   fhOnFlyStatus[0]->SetStats(kFALSE);
     821           0 :   gPad->SetLogy();
     822           0 :   fhOnFlyStatus[0]->Draw();
     823             : 
     824           0 :   canvas2->SaveAs(Form("%s_%s.gif", GetName(), canvas2->GetName()));
     825             : 
     826           0 :   TCanvas* canvas3 = new TCanvas(Form("%s_4", GetName()), "V0 Quality Results3", 800, 500);
     827           0 :   canvas3->Divide(2, 1);
     828             : 
     829           0 :   canvas3->cd(1);
     830           0 :   fhCutStatistics->SetStats(kFALSE);
     831           0 :   fhCutStatistics->LabelsOption("v");
     832           0 :   gPad->SetBottomMargin(0.3);
     833           0 :   fhCutStatistics->Draw();
     834             : 
     835           0 :   canvas3->cd(2);
     836           0 :   fhCutCorrelation->SetStats(kFALSE);
     837           0 :   fhCutCorrelation->LabelsOption("v");
     838           0 :   gPad->SetBottomMargin(0.3);
     839           0 :   gPad->SetLeftMargin(0.3);
     840           0 :   fhCutCorrelation->Draw("COLZ");
     841             : 
     842           0 :   canvas3->SaveAs(Form("%s_%s.gif", GetName(), canvas3->GetName()));
     843           0 : }
     844             : 

Generated by: LCOV version 1.11