1+ // Parameterized generator for muons
2+ // Port of the Run 2 generator by P. Pillot:
3+ // https://github.com/alisw/AliDPG/blob/master/MC/CustomGenerators/PWGDQ/Muon_GenParamSingle_PbPb5TeV_1.C
4+
5+ // clang-format off
6+ R__ADD_INCLUDE_PATH ($O2DPG_MC_CONFIG_ROOT /MC /config /PWGDQ /EvtGen )
7+ // clang-format on
8+ R__LOAD_LIBRARY (libpythia6 )
9+
10+ #include "GeneratorEvtGen.C"
11+
12+ namespace o2
13+ {
14+ namespace eventgen
15+ {
16+
17+ class O2_GeneratorParamMuon : public GeneratorTGenerator
18+ {
19+ public :
20+ // parameters tuned to Pb-Pb @ 5.02 TeV
21+ inline static Double_t fPtP0 {797.446 };
22+ inline static Double_t fPtP1 {0.830278 };
23+ inline static Double_t fPtP2 {0.632177 };
24+ inline static Double_t fPtP3 {10.2202 };
25+ inline static Double_t fPtP4 {-0.000614809 };
26+ inline static Double_t fPtP5 {-1.70993 };
27+
28+ inline static Double_t fYP0 {1.87732 };
29+ inline static Double_t fYP1 {0.00658212 };
30+ inline static Double_t fYP2 {-0.0988071 };
31+ inline static Double_t fYP3 {-0.000452746 };
32+ inline static Double_t fYP4 {0.00269782 };
33+
34+ O2_GeneratorParamMuon () : GeneratorTGenerator ("ParamMuon" )
35+ {
36+ fParamMuon = new GeneratorParam (2 , -1 , PtMuon , YMuon , V2Muon , IpMuon );
37+ fParamMuon -> SetPtRange (0.1 , 999. );
38+ fParamMuon -> SetYRange (-4.3 , -2.3 );
39+ fParamMuon -> SetPhiRange (0. , 360. );
40+ fParamMuon -> SetDecayer (new TPythia6Decayer ()); // "no decayer" error otherwise
41+ fParamMuon -> SetForceDecay (kNoDecay );
42+ setTGenerator (fParamMuon );
43+ }
44+
45+ ~O2_GeneratorParamMuon () { delete fParamMuon ; };
46+
47+ Bool_t Init () override
48+ {
49+ GeneratorTGenerator ::Init ();
50+ fParamMuon -> Init ();
51+ return true;
52+ }
53+
54+ // for tuning steps
55+ static void SetPtPars (Double_t p0 , Double_t p1 , Double_t p2 , Double_t p3 ,
56+ Double_t p4 , Double_t p5 )
57+ {
58+ fPtP0 = p0 ;
59+ fPtP1 = p1 ;
60+ fPtP2 = p2 ;
61+ fPtP3 = p3 ;
62+ fPtP4 = p4 ;
63+ fPtP5 = p5 ;
64+ }
65+
66+ // for tuning steps
67+ static void SetYPars (Double_t p0 , Double_t p1 , Double_t p2 , Double_t p3 ,
68+ Double_t p4 )
69+ {
70+ fYP0 = p0 ;
71+ fYP1 = p1 ;
72+ fYP2 = p2 ;
73+ fYP3 = p3 ;
74+ fYP4 = p4 ;
75+ }
76+
77+ void SetNSignalPerEvent (Int_t nsig ) { fParamMuon -> SetNumberParticles (nsig ); }
78+
79+ // muon composition
80+ static Int_t IpMuon (TRandom * ran )
81+ {
82+ if (ran -> Rndm () < 0.5 ) {
83+ return 13 ;
84+ } else {
85+ return -13 ;
86+ }
87+ }
88+
89+ // muon pT
90+ static Double_t PtMuon (const Double_t * px , const Double_t * )
91+ {
92+ Double_t x = px [0 ];
93+ return fPtP0 * (1. / TMath ::Power (fPtP1 + TMath ::Power (x , fPtP2 ), fPtP3 ) +
94+ fPtP4 * TMath ::Exp (fPtP5 * x ));
95+ }
96+
97+ // muon y
98+ static Double_t YMuon (const Double_t * py , const Double_t * )
99+ {
100+ Double_t y = py [0 ];
101+ return fYP0 * (1. + fYP1 * y + fYP2 * y * y + fYP3 * y * y * y +
102+ fYP4 * y * y * y * y );
103+ }
104+
105+ static Double_t V2Muon (const Double_t * , const Double_t * )
106+ {
107+ // muon v2
108+ return 0. ;
109+ }
110+
111+ private :
112+ GeneratorParam * fParamMuon {nullptr};
113+ };
114+
115+ } // namespace eventgen
116+ } // namespace o2
117+
118+ FairGenerator * paramMuGen (Double_t ptP0 = 797.446 , Double_t ptP1 = 0.830278 ,
119+ Double_t ptP2 = 0.632177 , Double_t ptP3 = 10.2202 ,
120+ Double_t ptP4 = -0.000614809 , Double_t ptP5 = -1.70993 ,
121+ Double_t yP0 = 1.87732 , Double_t yP1 = 0.00658212 ,
122+ Double_t yP2 = -0.0988071 , Double_t yP3 = -0.000452746 ,
123+ Double_t yP4 = 0.00269782 , Int_t nMuons = 2 )
124+ {
125+ auto gen = new o2 ::eventgen ::GeneratorEvtGen < o2 ::eventgen ::O2_GeneratorParamMuon > ();
126+ o2 ::eventgen ::O2_GeneratorParamMuon ::SetPtPars (ptP0 , ptP1 , ptP2 , ptP3 , ptP4 , ptP5 );
127+ o2 ::eventgen ::O2_GeneratorParamMuon ::SetYPars (yP0 , yP1 , yP2 , yP3 , yP4 );
128+ gen -> SetNSignalPerEvent (nMuons ); // number of muons per event
129+
130+ TString pdgs = "13" ;
131+ std ::string spdg ;
132+ TObjArray * obj = pdgs .Tokenize (";" );
133+ gen -> SetSizePdg (obj -> GetEntriesFast ());
134+ for (int i = 0 ; i < obj -> GetEntriesFast (); i ++ ) {
135+ spdg = obj -> At (i )-> GetName ();
136+ gen -> AddPdg (std ::stoi (spdg ), i );
137+ printf ("PDG %d \n" , std ::stoi (spdg ));
138+ }
139+
140+ gen -> PrintDebug ();
141+ return gen ;
142+ }
0 commit comments