ATLAS Offline Software
Loading...
Searching...
No Matches
mergingDJRs.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
5#include "UserHooksUtils.h"
6#include "UserSetting.h"
7
8// ROOT, for saving file.
9#include "TFile.h"
10
11// ROOT, for histogramming.
12#include "TF1.h"
13#include "TH1.h"
14
15#include <iostream>
16
17namespace Pythia8 {
18
19// Class to compute the DJRs
20class mergingDJRs : public UserHooks {
21
22private:
23 // Settings for SlowJet jet finder, with kT clustering
24 int m_power = 1;
25 double m_etaMax = 10.;
26 double m_radius = 1.0;
27 double m_pTjetMin = 10.;
28 Pythia8::SlowJetHook *m_sjHookPtrIn = 0;
29 bool m_useFJcoreIn = false; // SHOULD BE FALSE TO ALLOW THE SUB PROCESS BEFORE
30 // CLUSTERING THE PAARTICLES
31 bool m_useStandardRin = true;
32 int m_nSel = 2; // Exclude neutrinos (and other invisible) from study.
33 int m_massSetIn = 1;
34 std::unique_ptr<Pythia8::SlowJet> m_slowJet;
35
36 // ROOT output files
37 std::unique_ptr<TH1F> m_HistDjr, m_HistDjr2;
38 std::unique_ptr<TFile> m_outFile;
39
40 vector<double> m_result, m_DJR;
42
43public:
45 // ROOT histograms and the output file where to save them
46 m_HistDjr(std::make_unique<TH1F>("HistDjr", "The first DJR", 100, 0.0, 3.0)),
47 m_HistDjr2(std::make_unique<TH1F>("HistDjr2", "The second DJR", 100, 0.0, 3.0)),
48 m_outFile(std::make_unique<TFile>("hist-DJR.root", "RECREATE")) {
49
50 // Slowjet pointer
51 m_slowJet = std::make_unique<Pythia8::SlowJet>(
54
55 std::cout << "**********************************************************"
56 << std::endl;
57 std::cout << "* *"
58 << std::endl;
59 std::cout << "* the jet merging userhook CKKWL DJRS is working *"
60 << std::endl;
61 std::cout << "* *"
62 << std::endl;
63 std::cout << "**********************************************************"
64 << std::endl;
65 }
66
67 // Destructor prints histogram
69 m_HistDjr->Write();
70 m_HistDjr2->Write();
71 }
72
73 // Parton level vetoing
74 virtual bool canVetoPartonLevel() override { return true; }
75 virtual bool doVetoPartonLevel(const Event &event) override;
76
77 // Function to compute the DJRs
78 virtual void getDJR(const Event &event);
79
80 // To initialize the variables
81 virtual bool initAfterBeams() override {
82
83 m_workEventJet.init("(workEventJet)", particleDataPtr);
84
85 return true;
86 }
87};
88
89// parton level veto (before beam remnants and resonance showers)
90inline bool mergingDJRs::doVetoPartonLevel(const Event &event) {
91
92 // subEvent method extract a list of the current partons list and save the
93 // output in workEvent.
94 subEvent(event);
95 m_workEventJet = workEvent;
96
97 // The selected particles to pass to slowjet
98 for (int j = 0; j < m_workEventJet.size(); ++j) {
99 if (!(m_workEventJet[j].isFinal()) || m_workEventJet[j].isLepton() ||
100 m_workEventJet[j].id() == 23 || std::abs(m_workEventJet[j].id()) == 24 ||
101 m_workEventJet[j].id() == 22) {
102 m_workEventJet[j].statusNeg();
103 continue;
104 }
105 }
106
107 // slowjet analyze the events
108 if (not m_slowJet->setup(m_workEventJet)){
109 std::cout<< "setup failed in mergingDJRs::doVetoPartonLevel\n";
110 return false;
111 }
112
113 // Call getDJR and store the DJRs vector
115
116 // if we reached here then no veto
117 return false;
118}
119
120// Compute DJR vector
121inline void mergingDJRs::getDJR(const Event &event) {
122
123 // setup slowjet pointer
124 if (not m_slowJet->setup(event)){
125 std::cout<< "setup failed in mergingDJRs::getDJR\n";
126 return;
127 };
128
129 // Clear members.
130 m_DJR.clear();
131 m_result.clear();
132
133 while (m_slowJet->sizeAll() - m_slowJet->sizeJet() > 0) {
134 // Save the next clustering scale.
135 m_result.push_back(sqrt(m_slowJet->dNext()));
136 // Perform step.
137 m_slowJet->doStep();
138 }
139
140 // Save clustering scales in reverse order
141 for (int i = m_result.size() - 1; i >= 0; --i) {
142 m_DJR.push_back(m_result[i]);
143 }
144
145 // Fill the histogram and Normalize them
146 double eventWeight = infoPtr->mergingWeight() * infoPtr->weight();
147
148 if (m_DJR.size() > 0) {
149 m_HistDjr->Fill(log10(m_DJR[0]), eventWeight);
150 m_HistDjr2->Fill(log10(m_DJR[1]), eventWeight);
151 }
152}
153
155 Ckkwl("mergingDJRs");
156
157} // namespace Pythia8
bool isLepton(const T &p)
APID: the fourth generation leptons are leptons.
Definition AtlasPID.h:189
std::unique_ptr< TH1F > m_HistDjr
virtual void getDJR(const Event &event)
std::unique_ptr< TH1F > m_HistDjr2
virtual bool initAfterBeams() override
vector< double > m_result
virtual bool canVetoPartonLevel() override
virtual bool doVetoPartonLevel(const Event &event) override
vector< double > m_DJR
std::unique_ptr< TFile > m_outFile
Pythia8::SlowJetHook * m_sjHookPtrIn
std::unique_ptr< Pythia8::SlowJet > m_slowJet
Author: James Monk (jmonk@cern.ch)
Pythia8_UserHooks::UserHooksFactory::Creator< Pythia8::mergingDJRs > Ckkwl("mergingDJRs")
STL namespace.