ATLAS Offline Software
Loading...
Searching...
No Matches
RandomSignalEventGenerator.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
10
11#include <vector>
12#include <sstream>
13
15
17 const std::string& name,
18 const IInterface* parent) :
19 base_class(type, name, parent){
20
21}
22
23
24StatusCode
26 if(m_n_sig_lo >= m_n_sig_hi ||
28 ){
29 ATH_MSG_ERROR("Config error: lower signal limit exceeds uper limit");
30 return StatusCode::FAILURE;
31 }
32
34 m_flip = RandUint(0, 1);
35
38
41
42 return StatusCode::SUCCESS;
43}
44
46 std::stringstream ss;
47 ss << name() <<":: "
48 << m_n_sig_lo << " "
49 << m_n_sig_hi << " "
50 << m_e_sig_lo << " "
51 << m_e_sig_hi << " "
52 << m_eta_sig_hi << " ";
53
54 ss << m_nbkgd << " "
55 << m_bkgd_etmax << " "
56 << m_bkgd_etamax << '\n';
57
58 return ss.str();
59}
60
61
64
65 auto factory = std::unique_ptr<ITLorentzVectorFactory>(nullptr);
67 factory.reset(new TLorentzVectorFactory());
68 } else {
69 factory.reset(new TLorentzVectorFactoryEtaE());
70 }
71
73
74 auto nj = m_randNSig();
75 for(std::size_t ij = 0; ij < nj; ++ij){
76 const auto& eta = m_randEtaSig();
77 const auto& en = m_randEnSig();
78 // depending on the factory, en is e or et
79 auto tlv = factory->make(eta, en);
80 if(m_flip()){
81 tlv.SetZ(-tlv.Z()); // randomly flip the sign of the +vly generated tlv.
82 }
83 result.push_back(std::shared_ptr<const HypoJet::IJet>(new TLorentzVectorAsIJet(tlv)));
84 }
85
86 if(m_nbkgd){
87 for(int i = 0; i < m_nbkgd; ++i){
88 const auto& eta = m_randEtaBkd();
89 const auto& en = m_randEnBkd();
90 // depending on the factory, en is e or et
91 auto tlv = factory->make(eta, en);
92 if(m_flip()){
93 tlv.SetZ(-tlv.Z()); // randomly flip the sign of the +vly generated tlv.
94 }
95 result.push_back(std::shared_ptr<const HypoJet::IJet>(new TLorentzVectorAsIJet(tlv)));
96 }
97 }
98
99 std::shuffle(result.begin(), result.end(), m_shuffle_re);
100 return result;
101}
Scalar eta() const
pseudorapidity method
#define ATH_MSG_ERROR(x)
std::vector< pHypoJet > HypoJetVector
Definition HypoJetDefs.h:27
static Double_t ss
virtual std::string toString() const override
RandomSignalHypoJetVectorGenerator(const std::string &type, const std::string &name, const IInterface *parent)
void shuffle(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end, UniformRandom &g)
Specialization of shuffle for DataVector/List.