ROOT logo
/**************************************************************************
 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
 *                                                                        *
 * Author: The ALICE Off-line Project.                                    *
 * Contributors are mentioned in the code where appropriate.              *
 *                                                                        *
 * Permission to use, copy, modify and distribute this software and its   *
 * documentation strictly for non-commercial purposes is hereby granted   *
 * without fee, provided that the above copyright notice appears in all   *
 * copies and that both the copyright notice and this permission notice   *
 * appear in the supporting documentation. The authors make no claims     *
 * about the suitability of this software for any purpose. It is          *
 * provided "as is" without express or implied warranty.                  *
 **************************************************************************/

/* $Id$ */ 

// AliFlowTrackSimpleCuts:
// A simple track cut class to the the AliFlowTrackSimple 
// for basic kinematic cuts
//
// author: N. van der Kolk (kolk@nikhef.nl)
// mods: Mikolaj Krzewicki (mikolaj.krzewicki@cern.ch), Redmer Bertens (rbertens@cern.ch)

#include <limits.h>
#include <float.h>
#include "TNamed.h"
#include "TParticle.h"
#include "TParticlePDG.h"
#include "AliFlowTrackSimpleCuts.h"
#include "AliFlowTrackSimple.h"

ClassImp(AliFlowTrackSimpleCuts)

//-----------------------------------------------------------------------
AliFlowTrackSimpleCuts::AliFlowTrackSimpleCuts(const char* name):
  TNamed(name,name),
  fCutPt(kFALSE),
  fPtMax(FLT_MAX),
  fPtMin(-FLT_MAX),
  fCutEta(kFALSE),
  fEtaMax(FLT_MAX),
  fEtaMin(-FLT_MAX),
  fCutEtaGap(kFALSE),
  fEtaGapMax(0.),
  fEtaGapMin(0.),
  fCutPhi(kFALSE),
  fPhiMax(FLT_MAX),
  fPhiMin(-FLT_MAX),
  fCutPID(kFALSE),
  fPID(0),
  fCutCharge(kFALSE),
  fCharge(0),
  fCutMass(kFALSE),
  fMassMax(FLT_MAX),
  fMassMin(-FLT_MAX),
  fPOItype(1)
{
  //constructor 
}

////-----------------------------------------------------------------------
//AliFlowTrackSimpleCuts::AliFlowTrackSimpleCuts(const AliFlowTrackSimpleCuts& someCuts):
//  TNamed(),
//  fCutPt(someCuts.fCutPt),
//  fPtMax(someCuts.fPtMax),
//  fPtMin(someCuts.fPtMin),
//  fCutEta(someCuts.fCutEta),
//  fEtaMax(someCuts.fEtaMax),
//  fEtaMin(someCuts.fEtaMin),
//  fCutPhi(someCuts.fCutPhi),
//  fPhiMax(someCuts.fPhiMax),
//  fPhiMin(someCuts.fPhiMin),
//  fCutPID(someCuts.fCutPID),
//  fPID(someCuts.fPID),
//  fCutCharge(someCuts.fCutCharge),
//  fCharge(someCuts.fCharge)
//{
//  //copy constructor 
//}
//
////-----------------------------------------------------------------------
//AliFlowTrackSimpleCuts& AliFlowTrackSimpleCuts::operator=(const AliFlowTrackSimpleCuts& someCuts)
//{
//  TNamed::operator=(someCuts);
//  fCutPt  = someCuts.fCutPt;
//  fPtMax  = someCuts.fPtMax;
//  fPtMin  = someCuts.fPtMin;
//  fCutEta = someCuts.fCutEta;
//  fEtaMax = someCuts.fEtaMax;
//  fEtaMin = someCuts.fEtaMin;
//  fCutPhi = someCuts.fCutPhi;
//  fPhiMax = someCuts.fPhiMax;
//  fPhiMin = someCuts.fPhiMin;
//  fCutPID = someCuts.fCutPID;
//  fPID    = someCuts.fPID;
//  fCutCharge = someCuts.fCutCharge;
//  fCharge = someCuts.fCharge;
//
//  return *this;
//}

//----------------------------------------------------------------------- 
Bool_t AliFlowTrackSimpleCuts::IsSelected(TObject* obj, Int_t)
{
  //check cuts
  TParticle* p = dynamic_cast<TParticle*>(obj);
  if (p) return PassesCuts(p);
  AliFlowTrackSimple* ts = dynamic_cast<AliFlowTrackSimple*>(obj);
  if (ts) return PassesCuts(ts);
  return kFALSE; //default when passed a wrong type of object
}

//----------------------------------------------------------------------- 
Bool_t AliFlowTrackSimpleCuts::PassesCuts(const AliFlowTrackSimple *track) const
{
  //simple method to check if the simple track passes the simple cuts
  if(fCutPt) {if (track->Pt() < fPtMin || track->Pt() >= fPtMax ) return kFALSE;}
  if(fCutEta) {if (track->Eta() < fEtaMin || track->Eta() >= fEtaMax ) return kFALSE;}
  if(fCutPhi) {if (track->Phi() < fPhiMin || track->Phi() >= fPhiMax ) return kFALSE;}
  if(fCutCharge) {if (track->Charge() != fCharge) return kFALSE;}
  if(fCutMass) {if (track->Mass() < fMassMin || track->Mass() >= fMassMax ) return kFALSE;}
  if(fCutEtaGap) {if (track->Eta() > fEtaGapMin && track->Eta() < fEtaGapMax) return kFALSE;}
  //if(fCutPID) {if (track->PID() != fPID) return kFALSE;}
  return kTRUE;
}

//----------------------------------------------------------------------- 
Bool_t AliFlowTrackSimpleCuts::PassesCuts(TParticle* track) const
{
  //simple method to check if the simple track passes the simple cuts
  if(fCutPt)  {if (track->Pt() < fPtMin || track->Pt() >= fPtMax ) return kFALSE;}
  if(fCutEta) {if (track->Eta() < fEtaMin || track->Eta() >= fEtaMax ) return kFALSE;}
  if(fCutPhi) {if (track->Phi() < fPhiMin || track->Phi() >= fPhiMax ) return kFALSE;}
  if(fCutEtaGap) {if (track->Eta() > fEtaGapMin && track->Eta() < fEtaGapMax) return kFALSE;}

  //if(fCutPID) {if (track->GetPdgCode() != fPID) return kFALSE;}

  //getting the charge from a tparticle is expensive
  //only do it if neccesary
  if (fCutCharge) 
  {
    TParticlePDG* ppdg = track->GetPDG();
    Int_t charge = TMath::Nint(ppdg->Charge()/3.0); //mc particles have charge in units of 1/3e
    return (charge==fCharge);
  }

  if (fCutMass) {
    TParticlePDG* ppdg = track->GetPDG();
    if (ppdg->Mass() < fMassMin || ppdg->Mass() >= fMassMax )
      return kFALSE;
  }

  return kTRUE;
}
 AliFlowTrackSimpleCuts.cxx:1
 AliFlowTrackSimpleCuts.cxx:2
 AliFlowTrackSimpleCuts.cxx:3
 AliFlowTrackSimpleCuts.cxx:4
 AliFlowTrackSimpleCuts.cxx:5
 AliFlowTrackSimpleCuts.cxx:6
 AliFlowTrackSimpleCuts.cxx:7
 AliFlowTrackSimpleCuts.cxx:8
 AliFlowTrackSimpleCuts.cxx:9
 AliFlowTrackSimpleCuts.cxx:10
 AliFlowTrackSimpleCuts.cxx:11
 AliFlowTrackSimpleCuts.cxx:12
 AliFlowTrackSimpleCuts.cxx:13
 AliFlowTrackSimpleCuts.cxx:14
 AliFlowTrackSimpleCuts.cxx:15
 AliFlowTrackSimpleCuts.cxx:16
 AliFlowTrackSimpleCuts.cxx:17
 AliFlowTrackSimpleCuts.cxx:18
 AliFlowTrackSimpleCuts.cxx:19
 AliFlowTrackSimpleCuts.cxx:20
 AliFlowTrackSimpleCuts.cxx:21
 AliFlowTrackSimpleCuts.cxx:22
 AliFlowTrackSimpleCuts.cxx:23
 AliFlowTrackSimpleCuts.cxx:24
 AliFlowTrackSimpleCuts.cxx:25
 AliFlowTrackSimpleCuts.cxx:26
 AliFlowTrackSimpleCuts.cxx:27
 AliFlowTrackSimpleCuts.cxx:28
 AliFlowTrackSimpleCuts.cxx:29
 AliFlowTrackSimpleCuts.cxx:30
 AliFlowTrackSimpleCuts.cxx:31
 AliFlowTrackSimpleCuts.cxx:32
 AliFlowTrackSimpleCuts.cxx:33
 AliFlowTrackSimpleCuts.cxx:34
 AliFlowTrackSimpleCuts.cxx:35
 AliFlowTrackSimpleCuts.cxx:36
 AliFlowTrackSimpleCuts.cxx:37
 AliFlowTrackSimpleCuts.cxx:38
 AliFlowTrackSimpleCuts.cxx:39
 AliFlowTrackSimpleCuts.cxx:40
 AliFlowTrackSimpleCuts.cxx:41
 AliFlowTrackSimpleCuts.cxx:42
 AliFlowTrackSimpleCuts.cxx:43
 AliFlowTrackSimpleCuts.cxx:44
 AliFlowTrackSimpleCuts.cxx:45
 AliFlowTrackSimpleCuts.cxx:46
 AliFlowTrackSimpleCuts.cxx:47
 AliFlowTrackSimpleCuts.cxx:48
 AliFlowTrackSimpleCuts.cxx:49
 AliFlowTrackSimpleCuts.cxx:50
 AliFlowTrackSimpleCuts.cxx:51
 AliFlowTrackSimpleCuts.cxx:52
 AliFlowTrackSimpleCuts.cxx:53
 AliFlowTrackSimpleCuts.cxx:54
 AliFlowTrackSimpleCuts.cxx:55
 AliFlowTrackSimpleCuts.cxx:56
 AliFlowTrackSimpleCuts.cxx:57
 AliFlowTrackSimpleCuts.cxx:58
 AliFlowTrackSimpleCuts.cxx:59
 AliFlowTrackSimpleCuts.cxx:60
 AliFlowTrackSimpleCuts.cxx:61
 AliFlowTrackSimpleCuts.cxx:62
 AliFlowTrackSimpleCuts.cxx:63
 AliFlowTrackSimpleCuts.cxx:64
 AliFlowTrackSimpleCuts.cxx:65
 AliFlowTrackSimpleCuts.cxx:66
 AliFlowTrackSimpleCuts.cxx:67
 AliFlowTrackSimpleCuts.cxx:68
 AliFlowTrackSimpleCuts.cxx:69
 AliFlowTrackSimpleCuts.cxx:70
 AliFlowTrackSimpleCuts.cxx:71
 AliFlowTrackSimpleCuts.cxx:72
 AliFlowTrackSimpleCuts.cxx:73
 AliFlowTrackSimpleCuts.cxx:74
 AliFlowTrackSimpleCuts.cxx:75
 AliFlowTrackSimpleCuts.cxx:76
 AliFlowTrackSimpleCuts.cxx:77
 AliFlowTrackSimpleCuts.cxx:78
 AliFlowTrackSimpleCuts.cxx:79
 AliFlowTrackSimpleCuts.cxx:80
 AliFlowTrackSimpleCuts.cxx:81
 AliFlowTrackSimpleCuts.cxx:82
 AliFlowTrackSimpleCuts.cxx:83
 AliFlowTrackSimpleCuts.cxx:84
 AliFlowTrackSimpleCuts.cxx:85
 AliFlowTrackSimpleCuts.cxx:86
 AliFlowTrackSimpleCuts.cxx:87
 AliFlowTrackSimpleCuts.cxx:88
 AliFlowTrackSimpleCuts.cxx:89
 AliFlowTrackSimpleCuts.cxx:90
 AliFlowTrackSimpleCuts.cxx:91
 AliFlowTrackSimpleCuts.cxx:92
 AliFlowTrackSimpleCuts.cxx:93
 AliFlowTrackSimpleCuts.cxx:94
 AliFlowTrackSimpleCuts.cxx:95
 AliFlowTrackSimpleCuts.cxx:96
 AliFlowTrackSimpleCuts.cxx:97
 AliFlowTrackSimpleCuts.cxx:98
 AliFlowTrackSimpleCuts.cxx:99
 AliFlowTrackSimpleCuts.cxx:100
 AliFlowTrackSimpleCuts.cxx:101
 AliFlowTrackSimpleCuts.cxx:102
 AliFlowTrackSimpleCuts.cxx:103
 AliFlowTrackSimpleCuts.cxx:104
 AliFlowTrackSimpleCuts.cxx:105
 AliFlowTrackSimpleCuts.cxx:106
 AliFlowTrackSimpleCuts.cxx:107
 AliFlowTrackSimpleCuts.cxx:108
 AliFlowTrackSimpleCuts.cxx:109
 AliFlowTrackSimpleCuts.cxx:110
 AliFlowTrackSimpleCuts.cxx:111
 AliFlowTrackSimpleCuts.cxx:112
 AliFlowTrackSimpleCuts.cxx:113
 AliFlowTrackSimpleCuts.cxx:114
 AliFlowTrackSimpleCuts.cxx:115
 AliFlowTrackSimpleCuts.cxx:116
 AliFlowTrackSimpleCuts.cxx:117
 AliFlowTrackSimpleCuts.cxx:118
 AliFlowTrackSimpleCuts.cxx:119
 AliFlowTrackSimpleCuts.cxx:120
 AliFlowTrackSimpleCuts.cxx:121
 AliFlowTrackSimpleCuts.cxx:122
 AliFlowTrackSimpleCuts.cxx:123
 AliFlowTrackSimpleCuts.cxx:124
 AliFlowTrackSimpleCuts.cxx:125
 AliFlowTrackSimpleCuts.cxx:126
 AliFlowTrackSimpleCuts.cxx:127
 AliFlowTrackSimpleCuts.cxx:128
 AliFlowTrackSimpleCuts.cxx:129
 AliFlowTrackSimpleCuts.cxx:130
 AliFlowTrackSimpleCuts.cxx:131
 AliFlowTrackSimpleCuts.cxx:132
 AliFlowTrackSimpleCuts.cxx:133
 AliFlowTrackSimpleCuts.cxx:134
 AliFlowTrackSimpleCuts.cxx:135
 AliFlowTrackSimpleCuts.cxx:136
 AliFlowTrackSimpleCuts.cxx:137
 AliFlowTrackSimpleCuts.cxx:138
 AliFlowTrackSimpleCuts.cxx:139
 AliFlowTrackSimpleCuts.cxx:140
 AliFlowTrackSimpleCuts.cxx:141
 AliFlowTrackSimpleCuts.cxx:142
 AliFlowTrackSimpleCuts.cxx:143
 AliFlowTrackSimpleCuts.cxx:144
 AliFlowTrackSimpleCuts.cxx:145
 AliFlowTrackSimpleCuts.cxx:146
 AliFlowTrackSimpleCuts.cxx:147
 AliFlowTrackSimpleCuts.cxx:148
 AliFlowTrackSimpleCuts.cxx:149
 AliFlowTrackSimpleCuts.cxx:150
 AliFlowTrackSimpleCuts.cxx:151
 AliFlowTrackSimpleCuts.cxx:152
 AliFlowTrackSimpleCuts.cxx:153
 AliFlowTrackSimpleCuts.cxx:154
 AliFlowTrackSimpleCuts.cxx:155