ATLAS Offline Software
Namespaces | Functions
CreateDummyEl.cxx File Reference
#include "CreateDummyEl.h"
#include "xAODEgamma/Egamma.h"
#include "xAODEgamma/ElectronContainer.h"
#include "xAODEventInfo/EventInfo.h"
#include <xAODCaloEvent/CaloCluster.h>
#include <xAODCaloEvent/CaloClusterAuxContainer.h>
#include <xAODCaloEvent/CaloClusterContainer.h>
#include <xAODEgamma/ElectronAuxContainer.h>
#include "AsgMessaging/MessageCheck.h"
#include "AsgMessaging/MsgStream.h"

Go to the source code of this file.

Namespaces

 asg
 

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

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