allow defining a fraction of particles as neutral
authormverweij <marta.verweij@cern.ch>
Tue, 2 Sep 2014 12:19:41 +0000 (14:19 +0200)
committermverweij <marta.verweij@cern.ch>
Tue, 2 Sep 2014 13:25:27 +0000 (15:25 +0200)
PWGJE/EMCALJetTasks/AliJetEmbeddingTask.cxx
PWGJE/EMCALJetTasks/AliJetEmbeddingTask.h

index 1995810..90be965 100644 (file)
@@ -4,6 +4,8 @@
 //
 // Author: S.Aiola, C.Loizides
 
+#include <TRandom3.h>
+
 #include "AliJetEmbeddingTask.h"
 
 ClassImp(AliJetEmbeddingTask)
@@ -11,7 +13,8 @@ ClassImp(AliJetEmbeddingTask)
 //________________________________________________________________________
 AliJetEmbeddingTask::AliJetEmbeddingTask() : 
   AliJetModelBaseTask("AliJetEmbeddingTask"),
-  fMassless(kFALSE)
+  fMassless(kFALSE),
+  fNeutralFraction(0)
 {
   // Default constructor.
   SetSuffix("Embedded");
@@ -20,7 +23,8 @@ AliJetEmbeddingTask::AliJetEmbeddingTask() :
 //________________________________________________________________________
 AliJetEmbeddingTask::AliJetEmbeddingTask(const char *name) : 
   AliJetModelBaseTask(name),
-  fMassless(kFALSE)
+  fMassless(kFALSE),
+  fNeutralFraction(0)
 {
   // Standard constructor.
   SetSuffix("Embedded");
@@ -51,7 +55,12 @@ void AliJetEmbeddingTask::Run()
     for (Int_t i = 0; i < fNTracks; ++i) {
       Double_t mass = 0.1396;
       if(fMassless) mass = 0.;
-      AddTrack(-1,-999,-1,0,0,0,0,kFALSE,0,1,mass);
+      Short_t charge = 1;
+      if(fNeutralFraction>0.) {
+       Double_t rnd = gRandom->Rndm();
+       if(rnd<fNeutralFraction) charge = 0;
+      }
+      AddTrack(-1,-999,-1,0,0,0,0,kFALSE,0,charge,mass);
     }
   }
 }
index ae4ed37..9a61fd0 100644 (file)
@@ -11,17 +11,19 @@ class AliJetEmbeddingTask : public AliJetModelBaseTask {
   AliJetEmbeddingTask(const char *name); 
   virtual ~AliJetEmbeddingTask();
 
-  void           SetMasslessParticles(Bool_t b) { fMassless = b ; }
+  void           SetMasslessParticles(Bool_t b) { fMassless        = b ; }
+  void           SetNeutralFraction(Double_t f) { fNeutralFraction = f ; }
 
  protected:
   void           Run();
 
+ private:
   Bool_t         fMassless;               //make particles massless
+  Double_t       fNeutralFraction;        //assign charge==0 to fraction of particles
 
- private:
   AliJetEmbeddingTask(const AliJetEmbeddingTask&);            // not implemented
   AliJetEmbeddingTask &operator=(const AliJetEmbeddingTask&); // not implemented
 
-  ClassDef(AliJetEmbeddingTask, 2) // Jet embedding task
+  ClassDef(AliJetEmbeddingTask, 3) // Jet embedding task
 };
 #endif