ATLAS Offline Software
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 
17 namespace Pythia8 {
18 
19 // Class to compute the DJRs
20 class mergingDJRs : public UserHooks {
21 
22 private:
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 
43 public:
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)
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
121 inline 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
Pythia8::mergingDJRs::m_useStandardRin
bool m_useStandardRin
Definition: mergingDJRs.cxx:31
Pythia8::mergingDJRs::m_HistDjr2
std::unique_ptr< TH1F > m_HistDjr2
Definition: mergingDJRs.cxx:37
Pythia8::mergingDJRs::doVetoPartonLevel
virtual bool doVetoPartonLevel(const Event &event) override
Definition: mergingDJRs.cxx:90
make_unique
std::unique_ptr< T > make_unique(Args &&... args)
Definition: SkimmingToolEXOT5.cxx:23
Event
Definition: trigbs_orderedMerge.cxx:42
Pythia8::mergingDJRs::m_DJR
vector< double > m_DJR
Definition: mergingDJRs.cxx:40
Pythia8::mergingDJRs::m_nSel
int m_nSel
Definition: mergingDJRs.cxx:32
Pythia8::mergingDJRs::m_etaMax
double m_etaMax
Definition: mergingDJRs.cxx:25
Pythia8::mergingDJRs::m_sjHookPtrIn
Pythia8::SlowJetHook * m_sjHookPtrIn
Definition: mergingDJRs.cxx:28
Pythia8::mergingDJRs::m_slowJet
std::unique_ptr< Pythia8::SlowJet > m_slowJet
Definition: mergingDJRs.cxx:34
Pythia8::mergingDJRs::m_radius
double m_radius
Definition: mergingDJRs.cxx:26
Pythia8::mergingDJRs::m_massSetIn
int m_massSetIn
Definition: mergingDJRs.cxx:33
Pythia8_UserHooks::UserHooksFactory::Creator
Definition: UserHooksFactory.h:54
UserHooksFactory.h
Pythia8
Author: James Monk (jmonk@cern.ch)
Definition: IPythia8Custom.h:13
Pythia8::mergingDJRs::m_HistDjr
std::unique_ptr< TH1F > m_HistDjr
Definition: mergingDJRs.cxx:37
Pythia8::mergingDJRs::m_outFile
std::unique_ptr< TFile > m_outFile
Definition: mergingDJRs.cxx:38
event
POOL::TEvent event(POOL::TEvent::kClassAccess)
lumiFormat.i
int i
Definition: lumiFormat.py:85
Pythia8::mergingDJRs::m_pTjetMin
double m_pTjetMin
Definition: mergingDJRs.cxx:27
Pythia8::mergingDJRs
Definition: mergingDJRs.cxx:20
Pythia8::mergingDJRs::m_workEventJet
Event m_workEventJet
Definition: mergingDJRs.cxx:41
Pythia8::mergingDJRs::getDJR
virtual void getDJR(const Event &event)
Definition: mergingDJRs.cxx:121
UserSetting.h
Pythia8::mergingDJRs::m_useFJcoreIn
bool m_useFJcoreIn
Definition: mergingDJRs.cxx:29
Pythia8::mergingDJRs::m_power
int m_power
Definition: mergingDJRs.cxx:24
Pythia8::mergingDJRs::m_result
vector< double > m_result
Definition: mergingDJRs.cxx:40
Pythia8::Ckkwl
Pythia8_UserHooks::UserHooksFactory::Creator< Pythia8::mergingDJRs > Ckkwl("mergingDJRs")
UserHooksUtils.h
Pythia8::mergingDJRs::canVetoPartonLevel
virtual bool canVetoPartonLevel() override
Definition: mergingDJRs.cxx:74
isLepton
bool isLepton(const T &p)
APID: the fourth generation leptons are leptons.
Definition: AtlasPID.h:155
Pythia8::mergingDJRs::initAfterBeams
virtual bool initAfterBeams() override
Definition: mergingDJRs.cxx:81
Pythia8::mergingDJRs::mergingDJRs
mergingDJRs()
Definition: mergingDJRs.cxx:44
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
Pythia8::mergingDJRs::~mergingDJRs
~mergingDJRs()
Definition: mergingDJRs.cxx:68