ATLAS Offline Software
Functions
CreateDummyEl.h File Reference
#include <vector>
#include <xAODEgamma/ElectronContainer.h>
Include dependency graph for CreateDummyEl.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

StatusCode getElectrons (const std::vector< std::pair< double, double >> &pt_eta, int runNumber, xAOD::TStore &store)
 

Function Documentation

◆ getElectrons()

StatusCode getElectrons ( const std::vector< std::pair< double, double >> &  pt_eta,
int  runNumber,
xAOD::TStore store 
)

Definition at line 74 of file CreateDummyEl.cxx.

77 {
78  using namespace asg::CreateDummyEl;
79  ANA_CHECK_SET_TYPE(int);
80  setMsgLevel(MSG::INFO);
81  // This is what we will return back
82 
83  // create the EventInfo
84  std::unique_ptr<xAOD::EventInfo> eventInfo =
85  std::make_unique<xAOD::EventInfo>();
86  eventInfo->makePrivateStore();
87  eventInfo->setEventNumber(363636);
88  eventInfo->setRunNumber(runNumber);
89  static SG::AuxElement::Decorator<unsigned int> randomrunnumber(
90  "RandomRunNumber");
91  randomrunnumber(*eventInfo) = runNumber;
92  if (!store.record(std::move(eventInfo), "EventInfo").isSuccess()) {
93  ANA_MSG_ERROR("Could not record EventInfo");
94  return StatusCode::FAILURE;
95  }
96 
97  size_t numel = pt_eta.size();
98  // Create all clusters
99  std::unique_ptr<xAOD::CaloClusterContainer> clusters =
100  std::make_unique<xAOD::CaloClusterContainer>();
101  std::unique_ptr<xAOD::CaloClusterAuxContainer> clAux =
102  std::make_unique<xAOD::CaloClusterAuxContainer>();
103  clusters->setStore(clAux.get());
104  clusters->reserve(numel);
105  for (const auto& i : pt_eta) {
106  const double pt{ i.first };
107  const double eta{ i.second };
108  const double e{ pt * cosh(eta) };
109  xAOD::CaloCluster* cluster = new xAOD::CaloCluster();
110  clusters->push_back(cluster);
111  fill_cluster(cluster, eta, 0.0, e);
112  }
113 
114  if (!store.record(std::move(clusters), "MyClusters").isSuccess() ||
115  !store.record(std::move(clAux), "MyClustersAux.").isSuccess()) {
116  ANA_MSG_ERROR("Could not record clusters");
117  return StatusCode::FAILURE;
118  }
119  // Create all electrons one per cluster
120  std::vector<ElementLink<xAOD::CaloClusterContainer>> links{};
121  std::unique_ptr<xAOD::ElectronContainer> electrons =
122  std::make_unique<xAOD::ElectronContainer>();
123  std::unique_ptr<xAOD::ElectronAuxContainer> electronsAux =
124  std::make_unique<xAOD::ElectronAuxContainer>();
125  electrons->setStore(electronsAux.get());
126  electrons->reserve(numel);
127  for (const auto& i : pt_eta) {
128  const double pt{ i.first };
129  const double eta{ i.second };
131  electrons->push_back(el);
132  links.clear();
133  links.emplace_back("MyClusters", el->index());
134  el->setCaloClusterLinks(links);
135  el->setEta(eta);
136  el->setPhi(0.0);
138  el->setPt(pt);
139  }
140  if (!store.record(std::move(electrons), "MyElectrons").isSuccess() ||
141  !store.record(std::move(electronsAux), "MyElectronAux.").isSuccess()) {
142  ANA_MSG_ERROR("Could not record Electrons");
143  return StatusCode::FAILURE;
144  }
145 
146  return StatusCode::SUCCESS;
147 }
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
SGTest::store
TestStore store
Definition: TestStore.cxx:23
test_pyathena.eta
eta
Definition: test_pyathena.py:10
xAOD::Electron
Electron_v1 Electron
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
xAOD::EventInfo_v1::setEventNumber
void setEventNumber(uint64_t value)
Set the current event's event number.
test_pyathena.pt
pt
Definition: test_pyathena.py:11
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:294
xAOD::CaloCluster
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Definition: Event/xAOD/xAODCaloEvent/xAODCaloEvent/CaloCluster.h:19
xAOD::CaloCluster_v1
Description of a calorimeter cluster.
Definition: CaloCluster_v1.h:62
SG::Decorator
Helper class to provide type-safe access to aux data.
Definition: Decorator.h:59
lumiFormat.i
int i
Definition: lumiFormat.py:85
DMTest::links
links
Definition: CLinks_v1.cxx:22
plotIsoValidation.el
el
Definition: plotIsoValidation.py:197
SG::AuxElement::makePrivateStore
void makePrivateStore()
Create a new (empty) private store for this object.
Definition: AuxElement.cxx:192
SGTest::TestStore::record
void record(const T *p, const std::string &key)
Definition: TestStore.h:81
xAOD::Electron_v1
Definition: Electron_v1.h:34
DeMoAtlasDataLoss.runNumber
string runNumber
Definition: DeMoAtlasDataLoss.py:64
python.Constants.INFO
int INFO
Definition: Control/AthenaCommon/python/Constants.py:15
ANA_CHECK_SET_TYPE
#define ANA_CHECK_SET_TYPE(TYPE)
set the type for ANA_CHECK to report failures
Definition: Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:314
xAOD::EventInfo_v1::setRunNumber
void setRunNumber(uint32_t value)
Set the current event's run number.
RunTileMonitoring.clusters
clusters
Definition: RunTileMonitoring.py:133
InDetDD::electrons
@ electrons
Definition: InDetDD_Defs.h:17
ParticleConstants::PDG2011::electronMassInMeV
constexpr double electronMassInMeV
the mass of the electron (in MeV)
Definition: ParticleConstants.h:26