|
| 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 | +} |
0 commit comments