ATLAS Offline Software
SimpleHypoJetVectorGenerator.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 <random>
13 #include <sstream>
14 
16 
18  const std::string& name,
19  const IInterface* parent) :
20  base_class(type, name, parent){
21 
22 }
23 
24 
27  if(m_es.size() != m_etas.size()){
28  ATH_MSG_ERROR("Config error: no of Et values != no of Eta values"
29  << m_es.size() << " " << m_etas.size());
30  return StatusCode::FAILURE;
31  }
32 
33  return StatusCode::SUCCESS;
34 
35 }
36 
38  std::stringstream ss;
39  ss << name() <<":: e: ";
40  for(const auto& e : m_es){ss << e << ", ";}
41  ss << " eta: ";
42  for(const auto& e : m_etas){ss << e << ", ";}
43  ss<<" bkgd: "<< m_nbkgd << " max E" << m_bkgd_etmax << " max abs eta: "
44  << m_bkgd_etamax << '\n';
45 
46  return ss.str();
47 }
48 
49 
52 
53  auto factory = std::unique_ptr<ITLorentzVectorFactory>(nullptr);
54  if (m_useEtaEtNotEtaE){
55  factory.reset(new TLorentzVectorFactory());
56  } else {
57  factory.reset(new TLorentzVectorFactoryEtaE());
58  }
59 
61 
62  for(std::size_t i = 0; i < m_es.size(); ++i){
63  const auto& eta = m_etas[i];
64  const auto& et = m_es[i];
65  auto tlv = factory->make(eta, et);
66  result.push_back(std::shared_ptr<const HypoJet::IJet>(new TLorentzVectorAsIJet(tlv)));
67  }
68 
69  if(m_nbkgd){
70  std::default_random_engine generator;
71  std::uniform_real_distribution<double> eta_distribution(-m_bkgd_etamax,
73 
74  std::uniform_real_distribution<double> en_distribution(5.,
75  m_bkgd_etmax);
76 
77 
78 
79  for(int i = 0; i < m_nbkgd; ++i){
80  const auto& eta = eta_distribution(generator);
81  const auto& en = en_distribution(generator);
82  // depending on the factory, en is e or et
83  auto tlv = factory->make(eta, en);
84  result.push_back(std::shared_ptr<const HypoJet::IJet>(new TLorentzVectorAsIJet(tlv)));
85  }
86  }
87 
88  std::shuffle(result.begin(), result.end(), m_shuffle_re);
89  return result;
90 }
TLorentzVectorFactory
Definition: TLorentzVectorFactory.h:13
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
SimpleHypoJetVectorGenerator::m_es
Gaudi::Property< std::vector< double > > m_es
Definition: SimpleHypoJetVectorGenerator.h:31
et
Extra patterns decribing particle interation process.
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
SimpleHypoJetVectorGenerator::m_bkgd_etamax
Gaudi::Property< double > m_bkgd_etamax
Definition: SimpleHypoJetVectorGenerator.h:45
SimpleHypoJetVectorGenerator.h
SimpleHypoJetVectorGenerator::SimpleHypoJetVectorGenerator
SimpleHypoJetVectorGenerator(const std::string &type, const std::string &name, const IInterface *parent)
Definition: SimpleHypoJetVectorGenerator.cxx:17
TLorentzVectorAsIJet::TLorentzVectorAsIJet
TLorentzVectorAsIJet(const TLorentzVector &tl)
Definition: TLorentzVectorAsIJet.h:14
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SimpleHypoJetVectorGenerator::m_useEtaEtNotEtaE
Gaudi::Property< bool > m_useEtaEtNotEtaE
Definition: SimpleHypoJetVectorGenerator.h:48
lumiFormat.i
int i
Definition: lumiFormat.py:85
SimpleHypoJetVectorGenerator::m_bkgd_etmax
Gaudi::Property< double > m_bkgd_etmax
Definition: SimpleHypoJetVectorGenerator.h:42
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SimpleHypoJetVectorGenerator::toString
virtual std::string toString() const override
Definition: SimpleHypoJetVectorGenerator.cxx:37
SimpleHypoJetVectorGenerator::m_shuffle_re
std::default_random_engine m_shuffle_re
Definition: SimpleHypoJetVectorGenerator.h:51
test_pyathena.parent
parent
Definition: test_pyathena.py:15
HypoJetVector
std::vector< pHypoJet > HypoJetVector
Definition: HypoJetDefs.h:27
SimpleHypoJetVectorGenerator::m_nbkgd
Gaudi::Property< int > m_nbkgd
Definition: SimpleHypoJetVectorGenerator.h:39
SimpleHypoJetVectorGenerator::get
virtual HypoJetVector get() override
Definition: SimpleHypoJetVectorGenerator.cxx:51
SimpleHypoJetVectorGenerator::m_etas
Gaudi::Property< std::vector< double > > m_etas
Definition: SimpleHypoJetVectorGenerator.h:34
SimpleHypoJetVectorGenerator::initialize
virtual StatusCode initialize() override
Definition: SimpleHypoJetVectorGenerator.cxx:26
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
PlotCalibFromCool.en
en
Definition: PlotCalibFromCool.py:399
TLorentzVectorAsIJet
Definition: TLorentzVectorAsIJet.h:12
mc.generator
generator
Configure Herwig7 These are the commands corresponding to what would go into the regular Herwig infil...
Definition: mc.MGH7_FxFx_H71-DEFAULT_test.py:18
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TLorentzVectorFactoryEtaE
Definition: TLorentzVectorFactoryEtaE.h:13