@@ -34,7 +34,6 @@ public:
3434 mRapidityMin = -1. ;
3535 mRapidityMax = 1. ;
3636 mVerbose = false;
37- mUseExternalGenerator = false;
3837 }
3938
4039 /// Destructor
@@ -71,20 +70,14 @@ public:
7170 };
7271
7372 void setTriggerGap (int triggerGap ) {mInverseTriggerRatio = triggerGap ;}
74-
7573 void setConfigMBdecays (TString val ){mConfigMBdecays = val ;}
76-
7774 void setVerbose (bool val ) { mVerbose = val ; };
7875
7976 int getNGeneratedEvents () { return mGeneratedEvents ; }
80-
8177 int getTriggerGap () { return mInverseTriggerRatio ; }
82-
83- void setExternalGenerator (GeneratorPythia8 * gen , float prob ) {
84- mExternalGenerator = gen ;
85- mUseExternalGen = true;
86- mProbExternalGen = prob ;
87- }
78+ int getHadronPDG (int i ) { return mHadronsPDGs [i ]; }
79+ float getRejFactorPrompt (int i ) { return mRejFactorPrompt [i ]; }
80+ float getRejFactorNonPrompt (int i ) { return mRejFactorNonPrompt [i ]; }
8881
8982protected :
9083
@@ -119,34 +112,54 @@ bool generateEvent() override {
119112
120113bool importParticles () override
121114 {
122- // Possibility to make more actions after particles are imported, such as injected additional particles on top
123- // or modifying some PDG values
115+ // Possibility to make more actions after particles are imported, such as modifying some PDG values (for chi_c1)
124116 if (!GeneratorPythia8 ::importParticles ()) {
125117 return false;
126118 }
127- bool genOk = false;
128- // we use the external generator to simulate independent particles to be added on top
129- if (mUseExternalGenerator && mGeneratedEvents % mInverseTriggerRatio == 0 ){
130- bool genOk = false;
131- while (!genOk ){
132- genOk = (mExternalGenerator -> generateEvent () && mExternalGenerator -> importParticles ()) ? true : false ;
119+
120+ if (!(mInverseTriggerRatio == 1 || mGeneratedEvents % mInverseTriggerRatio == 1 ) || !mHasChic1 ){
121+ return true; // This is a min bias event or event without prompt chi_c1
122+ }
123+
124+ // Since chi_c1(3872) is not produced in PYTHIA we replace prompt chi_c1(1P) with prompt chi_c1(3872) with a given probabiliyt (from the rejFactor)
125+ int iChic3872 = -1 ;
126+ for (int ihad = 0 ; ihad < mHadronsPDGs .size (); ihad ++ ) {
127+ if (mHadronsPDGs [ihad ] == 9920443 && mRejFactorPrompt [ihad ] > 1e-8 ) {
128+ iChic3872 = ihad ;
133129 }
134- int originalSize = mParticles .size ();
135- for (int ipart = 0 ; ipart < mExternalGenerator -> getParticles ().size (); ipart ++ ){
136- TParticle part = TParticle (mExternalGenerator -> getParticles ().at (ipart ));
137- if (part .GetFirstMother () >= 0 ) part .SetFirstMother (part .GetFirstMother () + originalSize );
138- if (part .GetFirstDaughter () >= 0 ) part .SetFirstDaughter (part .GetFirstDaughter () + originalSize );
139- if (part .GetLastDaughter () >= 0 ) part .SetLastDaughter (part .GetLastDaughter () + originalSize );
140- mParticles .push_back (part );
141- }
142- mExternalGenerator -> clearParticles ();
130+ }
131+ if (iChic3872 == -1 ) {
132+ return true; // In this case we don't request any chi_c1(3872)
133+ }
134+ if (gRandom -> Rndm () > mRejFactorPrompt [iChic3872 ]) {
135+ return true;
143136 }
144137
145- mGeneratedEvents ++ ;
138+ for (int idx = 0 ; idx < mParticles .size (); idx ++ ) {
139+ if (mParticles [idx ].GetPdgCode () != 20443 ) {
140+ continue ;
141+ }
146142
147- if (!makeEvtGenDecays ()) {
148- return false;
143+ LOGF (info , "replacing one chi_c1(1P) with pt=%.3f and y=%.3f by a chi_c1(3872)" , mParticles [idx ].Pt (), mParticles [idx ].Y ());
144+ if (mParticles [idx ].GetFirstDaughter () >= 0 ) {
145+ LOGF (info , "particle has already been decayed, we do not replace it" );
146+ return true;
147+ }
148+
149+ // modify e and pz to conserve rapidity and modify the mass
150+ float pz_new = 0. ;
151+ float e_new = sqrt (3.87164 * 3.87164 - 3.51067 * 3.51067 + mParticles [idx ].Energy ()* mParticles [idx ].Energy ());
152+ if (std ::fabs (mParticles [idx ].Pz ()) > 1e-8 ) {
153+ pz_new = sqrt (3.87164 * 3.87164 - 3.51067 * 3.51067 + mParticles [idx ].Energy ()* mParticles [idx ].Energy () - mParticles [idx ].Pz ()* mParticles [idx ].Pz ()) / sqrt (mParticles [idx ].Energy ()* mParticles [idx ].Energy ()/mParticles [idx ].Pz ()/mParticles [idx ].Pz () - 1. );
154+ e_new = mParticles [idx ].Energy () / mParticles [idx ].Pz () * pz_new ;
155+ }
156+ mParticles [idx ].SetMomentum (mParticles [idx ].Px (), mParticles [idx ].Py (), pz_new , e_new );
157+
158+ mParticles [idx ].SetPdgCode (9920443 );
159+
160+ break ;
149161 }
162+
150163 return true;
151164 }
152165
@@ -185,6 +198,7 @@ bool isCharmonium(int pdg) {
185198
186199// search for the presence of at least one of the required hadrons in a selected rapidity window
187200bool findHadrons (Pythia8 ::Event & event ) {
201+ mHasChic1 = false;
188202 int ihad = 0 ;
189203 for (int ida = 0 ; ida < event .size (); ++ ida ) {
190204 //auto daughterList = event[ipa].daughterList();
@@ -245,6 +259,8 @@ bool findHadrons(Pythia8::Event& event) {
245259 }
246260 cout << endl ;
247261 }
262+
263+ if (event [ida ].id () == 20443 && !isNonPrompt ) mHasChic1 = true;
248264
249265 // rejection factor given in the ini file
250266 float randomNumber = gRandom -> Rndm ();
@@ -260,7 +276,6 @@ bool findHadrons(Pythia8::Event& event) {
260276 }
261277 //}
262278 }
263-
264279 return false;
265280};
266281
@@ -279,15 +294,10 @@ private:
279294 mRejFactorPrompt ; // rejection factors for possibility to trigger a given
280295 // particle only a fraction of the time, 1 by default
281296 std ::vector < float > mRejFactorNonPrompt ;
282- double mRapidityMin ;
297+ double mRapidityMin ;
283298 double mRapidityMax ;
284299 bool mVerbose ;
285- // external generator to inject particles which are not generated by Pythia (e.g. chi_c1(3872))
286- bool mUseExternalGen ;
287- GeneratorPythia8 * mExternalGenerator ;
288- float mProbExternalGen ; // we call this generator only for a fraction of events
289- bool mEventFlagExternalGen ; // the decision on whether to use the generator is done in the event findHadrons loop,
290- // so we use this flag to keep track of it at the time we can inject new particles
300+ bool mHasChic1 ; // in case we want to replace chi_c1(1P) by chi_c1(3872), avoid to recheck the full stack of particles if unnecessary
291301};
292302
293303}
@@ -435,6 +445,8 @@ FairGenerator *GeneratorInclusiveAllQuarkonia_EvtGenMidY(int triggerGap, double
435445 // The keywords "prompt" and "non-prompt" can be used to modify all prompt and all non-prompt (e.g. "prompt:rejFactor1,non-prompt:rejFactor2")
436446 // The keyword can be used for only one particle (e.g. "pdg1:rejFactor1:prompt,pdg1:rejFactor2:non-prompt")
437447 // Example if you want only to trigger on a given particle p: "prompt:0,non-prompt:0,p:1"
448+
449+ // For particle which are not produced by default in Pythia (chi_c1(3872)), the rejFactors string should be understood as a probabiliy to inject it (default being 0.)
438450
439451 int particleList [17 ] = {
440452 443 , // Jpsi
@@ -472,6 +484,10 @@ FairGenerator *GeneratorInclusiveAllQuarkonia_EvtGenMidY(int triggerGap, double
472484 // specify particles to be triggered
473485 for (int i = 0 ; i < 17 ; i ++ ) {
474486 gen -> addHadronPDGs (particleList [i ]);
487+ if (particleList [i ] == 9920443 ) {
488+ // chi_c1(3872) is by default not produced
489+ gen -> setRejFactorPrompt (particleList [i ], 0. );
490+ }
475491 }
476492 gen -> setVerbose (verbose );
477493
0 commit comments