]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG/muondep/AccEffTemplates/GenMuBox.C
Adding MuBox generator (Laurent)
[u/mrichter/AliRoot.git] / PWG / muondep / AccEffTemplates / GenMuBox.C
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2 #include <Riostream.h>
3 #include "TRandom.h"
4 #include "AliGenerator.h"
5 #include "AliGenBox.h"
6 #endif
7
8 /// Simple 3D-BOX generator for single muons
9 /// with a fixed fraction of + and - (50% per default)
10
11 class AliGenMuBox : public AliGenBox
12 {
13 public:
14   
15   AliGenMuBox(Float_t plusShare=0.50);
16
17   virtual ~AliGenMuBox() {}
18   
19   void GenerateN(Int_t ntimes);
20
21   void Generate() { GenerateN(1); }
22
23 private:
24   Float_t fPlusShare; // Fraction of plus muons
25   
26   ClassDef(AliGenMuBox,1) // Square box random generator for muons (+ and -)
27 };
28
29 ClassImp(AliGenMuBox)
30
31 AliGenMuBox::AliGenMuBox(Float_t plusShare) : AliGenBox(), fPlusShare(plusShare)
32 {
33   if ( fPlusShare <= 0.0 )
34   {
35     fPlusShare = 0.0;
36   }
37   if ( fPlusShare > 1.0 )
38   {
39     fPlusShare = 1.0;
40   }
41 }
42
43 void AliGenMuBox::GenerateN(Int_t ntimes)
44 {
45   Int_t ipart = 13;
46   
47   if ( fPlusShare == 1.0 )
48   {
49     ipart = -13;
50   }
51   else
52   {
53     Float_t x = Rndm();
54   
55     if ( x < fPlusShare )
56     {
57       ipart = -13;
58     }
59   }
60
61   SetPart(ipart);
62   
63   AliGenBox::GenerateN(ntimes);
64 }
65
66 AliGenerator* GenMuBox()
67 {
68   AliGenBox* generator = new AliGenMuBox;
69   
70   generator->SetNumberParticles(1);
71   
72   generator->SetPtRange(VAR_GENMUBOX_PTMIN,VAR_GENMUBOX_PTMAX);
73   generator->SetYRange(VAR_GENMUBOX_YMIN,VAR_GENMUBOX_YMAX);
74   
75   generator->SetPhiRange(0., 360.);
76   generator->SetTrackingFlag(1);
77   
78   return generator;
79 }