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 73 of file CreateDummyEl.cxx.

76 {
77  using namespace asg::CreateDummyEl;
78  ANA_CHECK_SET_TYPE(int);
79  setMsgLevel(MSG::INFO);
80  // This is what we will return back
81 
82  // create the EventInfo
83  std::unique_ptr<xAOD::EventInfo> eventInfo =
84  std::make_unique<xAOD::EventInfo>();
85  eventInfo->makePrivateStore();
86  eventInfo->setEventNumber(363636);
87  eventInfo->setRunNumber(runNumber);
88  static SG::AuxElement::Decorator<unsigned int> randomrunnumber(
89  "RandomRunNumber");
90  randomrunnumber(*eventInfo) = runNumber;
91  if (!store.record(std::move(eventInfo), "EventInfo").isSuccess()) {
92  ANA_MSG_ERROR("Could not record EventInfo");
93  return StatusCode::FAILURE;
94  }
95 
96  size_t numel = pt_eta.size();
97  // Create all clusters
98  std::unique_ptr<xAOD::CaloClusterContainer> clusters =
99  std::make_unique<xAOD::CaloClusterContainer>();
100  std::unique_ptr<xAOD::CaloClusterAuxContainer> clAux =
101  std::make_unique<xAOD::CaloClusterAuxContainer>();
102  clusters->setStore(clAux.get());
103  clusters->reserve(numel);
104  for (const auto& i : pt_eta) {
105  const double pt{ i.first };
106  const double eta{ i.second };
107  const double e{ pt * cosh(eta) };
108  xAOD::CaloCluster* cluster = new xAOD::CaloCluster();
109  clusters->push_back(cluster);
110  fill_cluster(cluster, eta, 0.0, e);
111  }
112 
113  if (!store.record(std::move(clusters), "MyClusters").isSuccess() ||
114  !store.record(std::move(clAux), "MyClustersAux.").isSuccess()) {
115  ANA_MSG_ERROR("Could not record clusters");
116  return StatusCode::FAILURE;
117  }
118  // Create all electrons one per cluster
119  std::vector<ElementLink<xAOD::CaloClusterContainer>> links{};
120  std::unique_ptr<xAOD::ElectronContainer> electrons =
121  std::make_unique<xAOD::ElectronContainer>();
122  std::unique_ptr<xAOD::ElectronAuxContainer> electronsAux =
123  std::make_unique<xAOD::ElectronAuxContainer>();
124  electrons->setStore(electronsAux.get());
125  electrons->reserve(numel);
126  for (const auto& i : pt_eta) {
127  const double pt{ i.first };
128  const double eta{ i.second };
130  electrons->push_back(el);
131  links.clear();
132  links.emplace_back("MyClusters", el->index());
133  el->setCaloClusterLinks(links);
134  el->setEta(eta);
135  el->setPhi(0.0);
136  el->setM(0.511);
137  el->setPt(pt);
138  }
139  if (!store.record(std::move(electrons), "MyElectrons").isSuccess() ||
140  !store.record(std::move(electronsAux), "MyElectronAux.").isSuccess()) {
141  ANA_MSG_ERROR("Could not record Electrons");
142  return StatusCode::FAILURE;
143  }
144 
145  return StatusCode::SUCCESS;
146 }
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:59
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
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