Skip to content

Commit 86354ce

Browse files
authored
add external trigger for prompt gamma selection (#10)
* add external trigger for prompt gamma selection * add hook based prompt gamma trigger * fix doxygen comment and add another detector combination * add configuration to trigger on parton/jets minimal eta acceptance with hooks * add configuration to trigger on high pT decay photons within detector acceptance with external trigger
1 parent a217a74 commit 86354ce

File tree

13 files changed

+878
-7
lines changed

13 files changed

+878
-7
lines changed
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
R__ADD_INCLUDE_PATH($O2DPG_ROOT)
2+
#include "MC/run/common/detector_acceptance.C"
3+
#include "Pythia8/Pythia.h"
4+
5+
/// =================================================
6+
/// \file jets_hook.C
7+
8+
/// \brief Select jet events within acceptance or associated parton flavor using Pythia Hooks.
9+
///
10+
/// Select outoging jets on the 2->2 process, at least one in a selected acceptance and
11+
/// with a given PDG value.
12+
/// Only valid for PYTHIA8 and using Hooks
13+
///
14+
/// \author Gustavo Conesa Balbastre (LPSC-IN2P3-CNRS)
15+
/// =================================================
16+
17+
class UserHooks_jets : public Pythia8::UserHooks
18+
{
19+
20+
public:
21+
UserHooks_jets() = default;
22+
~UserHooks_jets() = default;
23+
bool canVetoPartonLevel() override { return true; };
24+
bool doVetoPartonLevel(const Pythia8::Event& event) override {
25+
26+
// Get the outgoing 2->2 partons.
27+
// The jets are in position 5 or 6.
28+
// Note that in PYTHIA6 they are at positions 7 or 8.
29+
int id1 = 5;
30+
int id2 = 6;
31+
32+
// Check the first jet
33+
//
34+
bool acc1 = detector_acceptance(mAcceptance, event[id1].phi(), event[id1].eta()) ;
35+
bool okpdg1 = true;
36+
37+
if ( mOutPartonPDG > 0 && TMath::Abs(event[id1].id()) != mOutPartonPDG )
38+
okpdg1 = false;
39+
40+
if ( acc1 && okpdg1 )
41+
{
42+
printf("--- Accepted event, jet 1 ---\n");
43+
printf("PDG %d, status %d, mother %d, E %2.2f, pT %2.2f, eta %2.2f, phi %2.2f\n",
44+
event[id1].id() , event[id1].status(), event[id1].mother1(),
45+
event[id1].e() , event[id1].pT(),
46+
event[id1].eta(), event[id1].phi()*TMath::RadToDeg());
47+
48+
return false;
49+
}
50+
51+
// Check the second jet
52+
//
53+
bool acc2 = detector_acceptance(mAcceptance, event[id2].phi(), event[id2].eta()) ;
54+
bool okpdg2 = true;
55+
56+
if ( mOutPartonPDG > 0 && TMath::Abs(event[id2].id()) != mOutPartonPDG )
57+
okpdg2 = false;
58+
59+
if ( acc2 && okpdg2 )
60+
{
61+
printf("--- Accepted event, jet 2 ---\n");
62+
printf("PDG %d, status %d, mother %d, E %2.2f, pT %2.2f, eta %2.2f, phi %2.2f\n",
63+
event[id2].id() , event[id2].status(), event[id2].mother1(),
64+
event[id2].e() , event[id2].pT(),
65+
event[id2].eta(), event[id2].phi()*TMath::RadToDeg());
66+
67+
return false;
68+
}
69+
70+
// Jets not found
71+
//
72+
printf("--- Rejected event ---\n");
73+
74+
return true;
75+
76+
};
77+
78+
void setAcceptance (int val) { mAcceptance = val; };
79+
void setOutPartonPDG(int val) { mOutPartonPDG = val; };
80+
81+
private:
82+
83+
int mAcceptance = 0;
84+
int mOutPartonPDG = 0;
85+
};
86+
87+
Pythia8::UserHooks*
88+
pythia8_userhooks_jets(int acc = 0, int pdgPar = 0)
89+
{
90+
auto hooks = new UserHooks_jets();
91+
92+
// If default settings, check if not set via environmental variables
93+
//
94+
if ( !pdgPar && gSystem->Getenv("CONFIG_OUTPARTON_PDG") )
95+
{
96+
pdgPar = atoi(gSystem->Getenv("CONFIG_OUTPARTON_PDG"));
97+
printf("Select outgoing partons with pdg = %d\n",pdgPar);
98+
}
99+
100+
if ( !acc && gSystem->Getenv("CONFIG_DETECTOR_ACCEPTANCE") )
101+
{
102+
acc = atoi(gSystem->Getenv("CONFIG_DETECTOR_ACCEPTANCE"));
103+
printf("Requested acceptance %d\n",acc);
104+
}
105+
106+
hooks->setAcceptance(acc);
107+
hooks->setOutPartonPDG(pdgPar);
108+
109+
return hooks;
110+
}
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
R__ADD_INCLUDE_PATH($O2DPG_ROOT)
2+
#include "MC/run/common/detector_acceptance.C"
3+
#include "Pythia8/Pythia.h"
4+
5+
/// =================================================
6+
/// \file prompt_gamma_hook.C
7+
8+
/// \brief Select prompt photon events within acceptance or associated parton flavor using Pythia Hooks.
9+
///
10+
/// Select prompt photons checking the first generated outoging photon on the 2->2 process
11+
/// Then select if requested that the associated parton has a given PDG value.
12+
/// Finally check if the photon is in the detector acceptances defined in detector_acceptance.C
13+
/// Only valid for PYTHIA8 and using Hooks
14+
///
15+
/// \author Gustavo Conesa Balbastre (LPSC-IN2P3-CNRS)
16+
/// =================================================
17+
18+
class UserHooks_promptgamma : public Pythia8::UserHooks
19+
{
20+
21+
public:
22+
UserHooks_promptgamma() = default;
23+
~UserHooks_promptgamma() = default;
24+
bool canVetoPartonLevel() override { return true; };
25+
bool doVetoPartonLevel(const Pythia8::Event& event) override {
26+
27+
// printf("Event, size %d\n", event.size());
28+
//
29+
// for (Int_t ida = 0; ida < 10; ida++) {
30+
// printf("parton %d, PDG %d, status %d, mother %d, E %2.2f, pT %2.2f, eta %2.2f, phi %2.2f\n", ida,
31+
// event[ida].id(),
32+
// event[ida].status(),
33+
// event[ida].mother1(),
34+
// event[ida].e(),
35+
// event[ida].pT(),
36+
// event[ida].eta(),
37+
// event[ida].phi()*TMath::RadToDeg());
38+
// }
39+
40+
// Get the outgoing 2->2 partons.
41+
// The photon and the associated outgoing parton are in position 5 or 6.
42+
// Note that in PYTHIA6 they are at positions 7 or 8.
43+
Int_t idGam = 5;
44+
Int_t idPar = 6;
45+
if ( event[idGam].id() != 22 )
46+
{
47+
idGam = 6;
48+
idPar = 5;
49+
}
50+
51+
if ( event[idGam].id() != 22 )
52+
{
53+
printf("No direct photon found in the parton list!\n");
54+
return true;
55+
}
56+
57+
if ( mOutPartonPDG > 0 && mOutPartonPDG <= 22 )
58+
{
59+
// d 1, u 2, s 3, c 4, b 5, t 6
60+
61+
if ( TMath::Abs(event[idPar].id()) != mOutPartonPDG )
62+
{
63+
//printf("--- Rejected event, parton pdg ---\n");
64+
return true;
65+
}
66+
}
67+
68+
// Select photons within acceptance
69+
//
70+
if ( detector_acceptance(mAcceptance, event[idGam].phi(), event[idGam].eta()) )
71+
{
72+
printf("+++ Accepted event +++ \n");
73+
printf("gamma, PDG %d, status %d, mother %d, E %2.2f, pT %2.2f, eta %2.2f, phi %2.2f\n",
74+
event[idGam].id() , event[idGam].status(), event[idGam].mother1(),
75+
event[idGam].e() , event[idGam].pT(),
76+
event[idGam].eta(), event[idGam].phi()*TMath::RadToDeg());
77+
78+
// printf("parton, PDG %d, status %d, mother %d, E %2.2f, pT %2.2f, eta %2.2f, phi %2.2f\n",
79+
// event[idPar].id() , event[idPar].status(), event[idPar].mother1(),
80+
// event[idPar].e() , event[idPar].pT(),
81+
// event[idPar].eta(), event[idPar].phi()*TMath::RadToDeg());
82+
83+
// Check difference in pT and azimuthal angle, it should be 0 and +-180 degrees, respectively.
84+
// printf("parton-photon, Delta E %2.2f, Delta pT %2.2f, Delta eta %2.2f, Delta phi %2.2f\n",
85+
// event[idPar].e() - event[idGam].e(),
86+
// event[idPar].pT() - event[idGam].pT(),
87+
// event[idPar].eta()- event[idGam].eta(),
88+
// event[idPar].phi()*TMath::RadToDeg()-event[idGam].phi()*TMath::RadToDeg());
89+
90+
return false;
91+
}
92+
else
93+
{
94+
//printf("--- Rejected event ---\n");
95+
return true;
96+
}
97+
98+
return false;
99+
100+
};
101+
102+
void setAcceptance (int val) { mAcceptance = val; };
103+
void setOutPartonPDG(int val) { mOutPartonPDG = val; };
104+
105+
private:
106+
107+
int mAcceptance = 0;
108+
int mOutPartonPDG = 0;
109+
};
110+
111+
Pythia8::UserHooks*
112+
pythia8_userhooks_promptgamma(int acc = 0, int pdgPar = 0)
113+
{
114+
auto hooks = new UserHooks_promptgamma();
115+
116+
// If default settings, check if not set via environmental variables
117+
//
118+
if ( !pdgPar && gSystem->Getenv("CONFIG_OUTPARTON_PDG") )
119+
{
120+
pdgPar = atoi(gSystem->Getenv("CONFIG_OUTPARTON_PDG"));
121+
printf("Select outgoing partons with pdg = %d\n",pdgPar);
122+
}
123+
124+
if ( !acc && gSystem->Getenv("CONFIG_DETECTOR_ACCEPTANCE") )
125+
{
126+
acc = atoi(gSystem->Getenv("CONFIG_DETECTOR_ACCEPTANCE"));
127+
printf("Requested acceptance %d\n",acc);
128+
}
129+
130+
hooks->setAcceptance(acc);
131+
hooks->setOutPartonPDG(pdgPar);
132+
133+
return hooks;
134+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[GeneratorPythia8]
2+
config=pythia8_jets.cfg
3+
hooksFileName=${O2DPG_ROOT}/MC/config/PWGGAJE/hooks/jets_hook.C
4+
hooksFuncName=pythia8_userhooks_jets()
5+
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[GeneratorPythia8]
2+
config=pythia8_dirgamma.cfg
3+
hooksFileName=${O2DPG_ROOT}/MC/config/PWGGAJE/hooks/prompt_gamma_hook.C
4+
hooksFuncName=pythia8_userhooks_promptgamma()
5+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[GeneratorPythia8]
2+
config=pythia8_jets.cfg
3+
4+
[TriggerExternal]
5+
fileName=${O2DPG_ROOT}/MC/config/PWGGAJE/trigger/decay_gamma_jets.C
6+
funcName=decay_gamma_jets()
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[GeneratorPythia8]
2+
config=pythia8_dirgamma.cfg
3+
4+
[TriggerExternal]
5+
fileName=${O2DPG_ROOT}/MC/config/PWGGAJE/trigger/prompt_gamma.C
6+
funcName=prompt_gamma()
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
R__ADD_INCLUDE_PATH($O2DPG_ROOT)
2+
#include "MC/run/common/detector_acceptance.C"
3+
#include <TParticle.h>
4+
#include "Generators/Trigger.h"
5+
6+
/// =================================================
7+
/// \file decay_gamma_jets.C
8+
9+
/// \brief Select jet events with high pT decay photons within acceptance or associated parton flavor
10+
///
11+
/// Select 2->2 jet events with high pT decay photons on a given acceptance, defined in detector_acceptance.C
12+
/// Only valid for PYTHIA8.
13+
///
14+
/// \author Gustavo Conesa Balbastre (LPSC-IN2P3-CNRS)
15+
/// =================================================
16+
17+
o2::eventgen::Trigger decay_gamma_jets( )
18+
{
19+
return [](const std::vector<TParticle>& particles) -> bool {
20+
21+
// Select decay photon with min pT
22+
Float_t ptmin = 0;
23+
if ( !ptmin && gSystem->Getenv("CONFIG_DECAYGAMMA_PTMIN") )
24+
ptmin = atof(gSystem->Getenv("CONFIG_DECAYGAMMA_PTMIN"));
25+
//printf("Requested minimum pT %2.2f\n",ptmin);
26+
27+
// Select photons within acceptance
28+
//
29+
Int_t acceptance = 0;
30+
if ( gSystem->Getenv("CONFIG_DETECTOR_ACCEPTANCE") )
31+
acceptance = atoi(gSystem->Getenv("CONFIG_DETECTOR_ACCEPTANCE"));
32+
//printf("Requested acceptance %d\n",acceptance);
33+
34+
// Particle loop
35+
//
36+
//printf("N particles %lu\n",particles.size());
37+
Int_t ipart = 0;
38+
for(const TParticle part : particles)
39+
{
40+
ipart++;
41+
42+
if ( part.Pt() < ptmin )
43+
continue;
44+
45+
if ( part.GetPdgCode() != 22 )
46+
continue;
47+
48+
TParticle mother;
49+
if ( part.GetFirstMother() > 5 ) // below 5 (7 in pythia6) 2->2 partons and colliding nucleons
50+
mother = particles.at(part.GetFirstMother());
51+
else
52+
continue;
53+
54+
if ( TMath::Abs(mother.GetPdgCode()) <= 100 )
55+
continue;
56+
57+
//if ( mother.GetStatusCode() != 0 )
58+
// continue;
59+
60+
if ( !detector_acceptance(acceptance, part.Phi(), part.Eta()) )
61+
continue;
62+
63+
printf("index %d, PDG %d, status %d, mother %d, E %2.2f, pT %2.2f, eta %2.2f, phi %2.2f\n",
64+
ipart-1, part.GetPdgCode(),
65+
part.GetStatusCode(),
66+
part.GetFirstMother(),
67+
part.Energy(), part.Pt(),
68+
part.Eta(), part.Phi()*TMath::RadToDeg());
69+
70+
printf("mother %d, PDG %d, status %d, 1st daugh %d, last daugh %d, E %2.2f, pT %2.2f, eta %2.2f, phi %2.2f\n",
71+
part.GetFirstMother(), mother.GetPdgCode(),
72+
mother.GetStatusCode(),
73+
mother.GetFirstDaughter(), mother.GetLastDaughter(),
74+
mother.Energy(), mother.Pt(),
75+
mother.Eta(), mother.Phi()*TMath::RadToDeg());
76+
77+
printf("+++ Accepted event +++ \n");
78+
79+
return true;
80+
81+
} // loop
82+
83+
//printf("+++ Rejected event +++ \n");
84+
85+
return false;
86+
87+
};
88+
}

0 commit comments

Comments
 (0)