Skip to content

Commit fe6c5a3

Browse files
committed
Streamline LF injector/GT, add eta window trigger
1 parent 1a1cf15 commit fe6c5a3

2 files changed

Lines changed: 70 additions & 53 deletions

File tree

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# PDG N ptMin ptMax genDecayed
2-
3334 1 0.2 10
3-
-3334 1 0.2 10
4-
3312 1 0.2 10
5-
-3312 1 0.2 10
1+
# PDG N ptMin ptMax etaMin etaMax genDecayed
2+
3334 1 0.2 10 -1.2 1.2
3+
-3334 1 0.2 10 -1.2 1.2
4+
3312 1 0.2 10 -1.2 1.2
5+
-3312 1 0.2 10 -1.2 1.2

MC/config/PWGLF/pythia8/generator_pythia8_LF.C

Lines changed: 65 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ class GeneratorPythia8LF : public o2::eventgen::GeneratorPythia8
183183
const int& pypid = pythiaObjectSignal.event[j].id();
184184
const float& pyeta = pythiaObjectSignal.event[j].eta();
185185
const float& pypt = pythiaObjectSignal.event[j].pT();
186-
if (pypid == cfg.pdg && cfg.etaMin < pyeta && pyeta < cfg.etaMax && pypt > cfg.ptMin && pypt < cfg.ptMax) {
186+
if (pypid == cfg.mPdg && cfg.mEtaMin < pyeta && pyeta < cfg.mEtaMax && pypt > cfg.mPtMin && pypt < cfg.mPtMax) {
187187
LOG(info) << "Found particle " << j << " " << pypid << " with eta " << pyeta << " and pT " << pypt << " in event " << mEventCounter << " after " << nTries << " tries";
188188
satisfiesTrigger = true;
189189
break;
@@ -204,27 +204,27 @@ class GeneratorPythia8LF : public o2::eventgen::GeneratorPythia8
204204
continue;
205205
}
206206
// Do the injection
207-
for (int i{0}; i < cfg.nInject; ++i) {
208-
const double pt = gRandom->Uniform(cfg.ptMin, cfg.ptMax);
209-
const double eta = gRandom->Uniform(cfg.etaMin, cfg.etaMax);
207+
for (int i{0}; i < cfg.mNInject; ++i) {
208+
const double pt = gRandom->Uniform(cfg.mPtMin, cfg.mPtMax);
209+
const double eta = gRandom->Uniform(cfg.mEtaMin, cfg.mEtaMax);
210210
const double phi = gRandom->Uniform(0, TMath::TwoPi());
211211
const double px{pt * std::cos(phi)};
212212
const double py{pt * std::sin(phi)};
213213
const double pz{pt * std::sinh(eta)};
214-
const double et{std::hypot(std::hypot(pt, pz), cfg.mass)};
214+
const double et{std::hypot(std::hypot(pt, pz), cfg.mMass)};
215215

216216
Particle particle;
217-
particle.id(cfg.pdg);
217+
particle.id(cfg.mPdg);
218218
particle.status(11);
219-
particle.m(cfg.mass);
219+
particle.m(cfg.mMass);
220220
particle.px(px);
221221
particle.py(py);
222222
particle.pz(pz);
223223
particle.e(et);
224224
particle.xProd(0.f);
225225
particle.yProd(0.f);
226226
particle.zProd(0.f);
227-
mPythia.particleData.mayDecay(cfg.pdg, true); // force decay
227+
mPythia.particleData.mayDecay(cfg.mPdg, true); // force decay
228228
mPythia.event.append(particle);
229229
}
230230
injectedForThisEvent = true;
@@ -270,16 +270,16 @@ class GeneratorPythia8LF : public o2::eventgen::GeneratorPythia8
270270
if (mConfigToUse >= 0 && (nConfig - 1) != mConfigToUse) {
271271
continue;
272272
}
273-
LOGF(info, "Injecting %i particles with PDG %i, pT in [%f, %f]", cfg.nInject, cfg.pdg, cfg.ptMin, cfg.ptMax);
273+
LOGF(info, "Injecting %i particles with PDG %i, pT in [%f, %f]", cfg.mNInject, cfg.mPdg, cfg.mPtMin, cfg.mPtMax);
274274

275-
for (int i{0}; i < cfg.nInject; ++i) {
276-
const double pt = gRandom->Uniform(cfg.ptMin, cfg.ptMax);
277-
const double eta = gRandom->Uniform(cfg.etaMin, cfg.etaMax);
275+
for (int i{0}; i < cfg.mNInject; ++i) {
276+
const double pt = gRandom->Uniform(cfg.mPtMin, cfg.mPtMax);
277+
const double eta = gRandom->Uniform(cfg.mEtaMin, cfg.mEtaMax);
278278
const double phi = gRandom->Uniform(0, TMath::TwoPi());
279279
const double px{pt * std::cos(phi)};
280280
const double py{pt * std::sin(phi)};
281281
const double pz{pt * std::sinh(eta)};
282-
const double et{std::hypot(std::hypot(pt, pz), cfg.mass)};
282+
const double et{std::hypot(std::hypot(pt, pz), cfg.mMass)};
283283

284284
// TParticle::TParticle(Int_t pdg,
285285
// Int_t status,
@@ -288,7 +288,7 @@ class GeneratorPythia8LF : public o2::eventgen::GeneratorPythia8
288288
// Double_t px, Double_t py, Double_t pz, Double_t etot,
289289
// Double_t vx, Double_t vy, Double_t vz, Double_t time)
290290

291-
mParticles.push_back(TParticle(cfg.pdg,
291+
mParticles.push_back(TParticle(cfg.mPdg,
292292
MCGenStatusEncoding(1, 1).fullEncoding,
293293
-1, -1,
294294
-1, -1,
@@ -311,65 +311,82 @@ class GeneratorPythia8LF : public o2::eventgen::GeneratorPythia8
311311
}
312312

313313
struct ConfigContainer {
314-
ConfigContainer(int input_pdg = 0, int n = 1, float p = 1, float P = 10) : pdg{input_pdg},
315-
nInject{n},
316-
ptMin{p},
317-
ptMax{P}
314+
ConfigContainer(int input_pdg = 0, int n = 1,
315+
float ptMin = 1, float ptMax = 10,
316+
float etaMin = -1, float etaMax = 1) : mPdg{input_pdg},
317+
mNInject{n},
318+
mPtMin{ptMin},
319+
mPtMax{ptMax},
320+
mEtaMin{etaMin},
321+
mEtaMax{etaMax}
318322
{
319-
mass = GeneratorPythia8LongLivedGun::getMass(pdg);
320-
if (mass <= 0) {
321-
LOG(fatal) << "Could not find mass for pdg " << pdg;
323+
mMass = GeneratorPythia8LongLivedGun::getMass(mPdg);
324+
if (mMass <= 0) {
325+
LOG(fatal) << "Could not find mass for mPdg " << mPdg;
322326
}
323-
LOGF(info, "ConfigContainer: pdg = %i, nInject = %i, ptMin = %f, ptMax = %f, mass = %f", pdg, nInject, ptMin, ptMax, mass);
327+
LOGF(info, "ConfigContainer: mPdg = %i, mNInject = %i, mPtMin = %f, mPtMax = %f, mEtaMin = %f, mEtaMax = %f, mMass = %f",
328+
mPdg, mNInject, mPtMin, mPtMax, mEtaMin, mEtaMax, mMass);
324329
};
325-
ConfigContainer(TObjArray* arr) : ConfigContainer(atoi(arr->At(0)->GetName()),
326-
atoi(arr->At(1)->GetName()),
327-
atof(arr->At(2)->GetName()),
328-
atof(arr->At(3)->GetName())){};
329-
330-
int pdg = 0;
331-
int nInject = 1;
332-
float ptMin = 1;
333-
float ptMax = 10;
334-
float etaMin = -1.f;
335-
float etaMax = 1.f;
336-
double mass = 0.f;
330+
331+
// ConfigContainer(const ConfigContainer cfg) : ConfigContainer(cfg.mPdg,
332+
// cfg.mNInject,
333+
// cfg.mPtMin,
334+
// cfg.mPtMax,
335+
// cfg.mEtaMin,
336+
// cfg.mEtaMax){};
337+
// ConfigContainer(TObjArray* arr) : ConfigContainer(atoi(arr->At(0)->GetName()),
338+
// atoi(arr->At(1)->GetName()),
339+
// atof(arr->At(2)->GetName()),
340+
// atof(arr->At(3)->GetName()),
341+
// atof(arr->At(4)->GetName()),
342+
// atof(arr->At(5)->GetName())){};
343+
// ConfigContainer(TString line) : ConfigContainer(line.Tokenize(" ")){};
344+
345+
// Data Members
346+
int mPdg = 0;
347+
int mNInject = 1;
348+
float mPtMin = 1;
349+
float mPtMax = 10;
350+
float mEtaMin = -1.f;
351+
float mEtaMax = 1.f;
352+
double mMass = 0.f;
353+
337354
void print() const
338355
{
339-
LOGF(info, "int pdg = %i", pdg);
340-
LOGF(info, "int nInject = %i", nInject);
341-
LOGF(info, "float ptMin = %f", ptMin);
342-
LOGF(info, "float ptMax = %f", ptMax);
343-
LOGF(info, "float etaMin = %f", etaMin);
344-
LOGF(info, "float etaMax = %f", etaMax);
345-
LOGF(info, "double mass = %f", mass);
356+
LOGF(info, "int mPdg = %i", mPdg);
357+
LOGF(info, "int mNInject = %i", mNInject);
358+
LOGF(info, "float mPtMin = %f", mPtMin);
359+
LOGF(info, "float mPtMax = %f", mPtMax);
360+
LOGF(info, "float mEtaMin = %f", mEtaMin);
361+
LOGF(info, "float mEtaMax = %f", mEtaMax);
362+
LOGF(info, "double mMass = %f", mMass);
346363
}
347364
};
348365

349366
//__________________________________________________________________
350-
ConfigContainer addGun(int input_pdg, int nInject = 1, float ptMin = 1, float ptMax = 10)
367+
ConfigContainer addGun(int input_pdg, int nInject = 1, float ptMin = 1, float ptMax = 10, float etaMin = 1, float etaMax = 10)
351368
{
352369
if (mUseTriggering) { // If in trigger mode, every particle needs to be generated from pythia
353-
return addGunGenDecayed(input_pdg, nInject, ptMin, ptMax);
370+
return addGunGenDecayed(input_pdg, nInject, ptMin, ptMax, etaMin, etaMax);
354371
}
355-
ConfigContainer cfg{input_pdg, nInject, ptMin, ptMax};
372+
ConfigContainer cfg{input_pdg, nInject, ptMin, ptMax, etaMin, etaMax};
356373
mGunConfigs.push_back(cfg);
357374
return cfg;
358375
}
359376

360377
//__________________________________________________________________
361-
ConfigContainer addGun(ConfigContainer cfg) { return addGun(cfg.pdg, cfg.nInject, cfg.ptMin, cfg.ptMax); }
378+
ConfigContainer addGun(ConfigContainer cfg) { return addGun(cfg.mPdg, cfg.mNInject, cfg.mPtMin, cfg.mPtMax, cfg.mEtaMin, cfg.mEtaMax); }
362379

363380
//__________________________________________________________________
364-
ConfigContainer addGunGenDecayed(int input_pdg, int nInject = 1, float ptMin = 1, float ptMax = 10)
381+
ConfigContainer addGunGenDecayed(int input_pdg, int nInject = 1, float ptMin = 1, float ptMax = 10, float etaMin = 1, float etaMax = 10)
365382
{
366-
ConfigContainer cfg{input_pdg, nInject, ptMin, ptMax};
383+
ConfigContainer cfg{input_pdg, nInject, ptMin, ptMax, etaMin, etaMax};
367384
mGunConfigsGenDecayed.push_back(cfg);
368385
return cfg;
369386
}
370387

371388
//__________________________________________________________________
372-
ConfigContainer addGunGenDecayed(ConfigContainer cfg) { return addGunGenDecayed(cfg.pdg, cfg.nInject, cfg.ptMin, cfg.ptMax); }
389+
ConfigContainer addGunGenDecayed(ConfigContainer cfg) { return addGunGenDecayed(cfg.mPdg, cfg.mNInject, cfg.mPtMin, cfg.mPtMax, cfg.mEtaMin, cfg.mEtaMax); }
373390

374391
//__________________________________________________________________
375392
long int getNGuns() const { return mGunConfigs.size() + mGunConfigsGenDecayed.size(); }

0 commit comments

Comments
 (0)