add possibily to select particles based on charge (useful for mc)
authormverweij <marta.verweij@cern.ch>
Tue, 2 Sep 2014 12:16:51 +0000 (14:16 +0200)
committermverweij <marta.verweij@cern.ch>
Tue, 2 Sep 2014 13:25:27 +0000 (15:25 +0200)
PWG/EMCAL/AliParticleContainer.cxx
PWG/EMCAL/AliParticleContainer.h

index 8626d25..b9b0ef0 100644 (file)
@@ -25,7 +25,8 @@ AliParticleContainer::AliParticleContainer():
   fMCTrackBitMap(0),
   fMinMCLabel(0),
   fMCFlag(0),
-  fGeneratorIndex(-1)
+  fGeneratorIndex(-1),
+  fCharge(-1)
 {
   // Default constructor.
 
@@ -44,7 +45,8 @@ AliParticleContainer::AliParticleContainer(const char *name):
   fMCTrackBitMap(0),
   fMinMCLabel(0),
   fMCFlag(0),
-  fGeneratorIndex(-1)
+  fGeneratorIndex(-1),
+  fCharge(-1)
 {
   // Standard constructor.
 
@@ -99,7 +101,7 @@ AliVParticle* AliParticleContainer::GetAcceptParticle(Int_t i) const {
   if(!vp) return 0;
 
   if(AcceptParticle(vp))
-    return vp;
+      return vp;
   else {
     AliDebug(2,"Particle not accepted.");
     return 0;
@@ -201,6 +203,9 @@ Bool_t AliParticleContainer::AcceptParticle(AliVParticle *vp) const
 
   if (fGeneratorIndex >= 0 && fGeneratorIndex != vp->GetGeneratorIndex())
     return kFALSE;
+
+  if (fCharge>=0 && fCharge != vp->Charge() )
+    return kFALSE;
   
   return kTRUE;
 }
index 7cde621..cb2ec28 100644 (file)
@@ -44,6 +44,7 @@ class AliParticleContainer : public AliEmcalContainer {
   void                        SetGeneratorIndex(Short_t i)                      { fGeneratorIndex = i  ; }
   void                        SelectPhysicalPrimaries(Bool_t s)                 { if (s) fMCFlag |=  AliAODMCParticle::kPhysicalPrim ; 
                                                                                   else   fMCFlag &= ~AliAODMCParticle::kPhysicalPrim ; }
+  void                        SetCharge(Short_t c)                              { fCharge = c         ; }
 
  protected:
   Double_t                    fParticlePtCut;                 // cut on particle pt
@@ -56,12 +57,13 @@ class AliParticleContainer : public AliEmcalContainer {
   Int_t                       fMinMCLabel;                    // minimum MC label value for the tracks/clusters being considered MC particles
   UInt_t                      fMCFlag;                        // select MC particles with flags
   Short_t                     fGeneratorIndex;                // select MC particles with generator index (default = -1 = switch off selection)
+  Short_t                     fCharge;                        // select particles with charge=fCharge
 
  private:
   AliParticleContainer(const AliParticleContainer& obj); // copy constructor
   AliParticleContainer& operator=(const AliParticleContainer& other); // assignment
 
-  ClassDef(AliParticleContainer,2);
+  ClassDef(AliParticleContainer,3);
 
 };