- if(track->Pt() >= fPtMin && track->Pt() < fPtMax &&
- track->Eta() >= fEtaMin && track->Eta() < fEtaMax &&
- track->Phi() >= fPhiMin && track->Phi() < fPhiMax)
- return kTRUE;
- else
- return kFALSE;
+ Bool_t result = (track->Pt() >= fPtMin && track->Pt() < fPtMax &&
+ track->Eta() >= fEtaMin && track->Eta() < fEtaMax &&
+ track->Phi() >= fPhiMin && track->Phi() < fPhiMax);
+
+ //getting the charge from a tparticle is expensive
+ //only do it if neccesary
+ if (fCharge!=fgkIgnoreCharge)
+ {
+ TParticlePDG* ppdg = track->GetPDG();
+ Int_t charge = TMath::Nint(ppdg->Charge()/3.0);
+ result = (charge==fCharge) && result;
+ }
+ return result;