ATLAS Offline Software
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 
6 #include "../src/ITLorentzVectorFactory.h"
7 #include "../src/TLorentzVectorFactoryEtaE.h"
8 #include "../src/TLorentzVectorFactory.h"
9 #include "../src/TLorentzVectorAsIJet.h"
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 
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);
66  if (m_useEtaEtNotEtaE){
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 }
TLorentzVectorFactory
Definition: TLorentzVectorFactory.h:13
RandomSignalHypoJetVectorGenerator::m_nbkgd
Gaudi::Property< int > m_nbkgd
Definition: RandomSignalHypoJetVectorGenerator.h:53
RandomSignalHypoJetVectorGenerator::toString
virtual std::string toString() const override
Definition: RandomSignalEventGenerator.cxx:45
RandomSignalHypoJetVectorGenerator::m_useEtaEtNotEtaE
Gaudi::Property< bool > m_useEtaEtNotEtaE
Definition: RandomSignalHypoJetVectorGenerator.h:62
get_generator_info.result
result
Definition: get_generator_info.py:21
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
RandomSignalHypoJetVectorGenerator::m_eta_sig_hi
Gaudi::Property< double > m_eta_sig_hi
Definition: RandomSignalHypoJetVectorGenerator.h:49
RandomSignalHypoJetVectorGenerator::m_shuffle_re
std::default_random_engine m_shuffle_re
Definition: RandomSignalHypoJetVectorGenerator.h:65
RandDouble
Definition: RandDouble.h:8
TLorentzVectorAsIJet::TLorentzVectorAsIJet
TLorentzVectorAsIJet(const TLorentzVector &tl)
Definition: TLorentzVectorAsIJet.h:14
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
RandUint
Definition: RandUint.h:8
RandomSignalHypoJetVectorGenerator::m_n_sig_lo
Gaudi::Property< int > m_n_sig_lo
Definition: RandomSignalHypoJetVectorGenerator.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
RandomSignalHypoJetVectorGenerator::m_e_sig_lo
Gaudi::Property< double > m_e_sig_lo
Definition: RandomSignalHypoJetVectorGenerator.h:41
RandomSignalHypoJetVectorGenerator::m_randEnSig
RandDouble m_randEnSig
Definition: RandomSignalHypoJetVectorGenerator.h:68
test_pyathena.parent
parent
Definition: test_pyathena.py:15
HypoJetVector
std::vector< pHypoJet > HypoJetVector
Definition: HypoJetDefs.h:27
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
RandomSignalHypoJetVectorGenerator::m_n_sig_hi
Gaudi::Property< int > m_n_sig_hi
Definition: RandomSignalHypoJetVectorGenerator.h:37
PlotCalibFromCool.en
en
Definition: PlotCalibFromCool.py:399
TLorentzVectorAsIJet
Definition: TLorentzVectorAsIJet.h:12
RandomSignalHypoJetVectorGenerator::RandomSignalHypoJetVectorGenerator
RandomSignalHypoJetVectorGenerator(const std::string &type, const std::string &name, const IInterface *parent)
Definition: RandomSignalEventGenerator.cxx:16
RandomSignalHypoJetVectorGenerator.h
RandomSignalHypoJetVectorGenerator::m_flip
RandUint m_flip
Definition: RandomSignalHypoJetVectorGenerator.h:72
RandomSignalHypoJetVectorGenerator::m_bkgd_etmax
Gaudi::Property< double > m_bkgd_etmax
Definition: RandomSignalHypoJetVectorGenerator.h:56
RandomSignalHypoJetVectorGenerator::m_randEtaBkd
RandDouble m_randEtaBkd
Definition: RandomSignalHypoJetVectorGenerator.h:69
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TLorentzVectorFactoryEtaE
Definition: TLorentzVectorFactoryEtaE.h:13
RandomSignalHypoJetVectorGenerator::m_randEtaSig
RandDouble m_randEtaSig
Definition: RandomSignalHypoJetVectorGenerator.h:67
RandomSignalHypoJetVectorGenerator::m_bkgd_etamax
Gaudi::Property< double > m_bkgd_etamax
Definition: RandomSignalHypoJetVectorGenerator.h:59
RandomSignalHypoJetVectorGenerator::m_randEnBkd
RandDouble m_randEnBkd
Definition: RandomSignalHypoJetVectorGenerator.h:70
RandomSignalHypoJetVectorGenerator::m_randNSig
RandUint m_randNSig
Definition: RandomSignalHypoJetVectorGenerator.h:66
RandomSignalHypoJetVectorGenerator::get
virtual HypoJetVector get() override
Definition: RandomSignalEventGenerator.cxx:63
RandomSignalHypoJetVectorGenerator::initialize
virtual StatusCode initialize() override
Definition: RandomSignalEventGenerator.cxx:25
RandomSignalHypoJetVectorGenerator::m_e_sig_hi
Gaudi::Property< double > m_e_sig_hi
Definition: RandomSignalHypoJetVectorGenerator.h:45