27const std::set<CaloSampling::CaloSample> samplings{
28 CaloSampling::PreSamplerB, CaloSampling::EMB1, CaloSampling::EMB2,
29 CaloSampling::EMB3, CaloSampling::PreSamplerE, CaloSampling::EME1,
30 CaloSampling::EME2, CaloSampling::EME3
36 unsigned sampling_pattern = 0;
37 for (
auto sample : samplings) {
38 sampling_pattern |= 0x1U <<
sample;
42 for (
auto sample : samplings) {
47 if (std::abs(
eta) < 1.45) {
48 cluster->
setEnergy(CaloSampling::PreSamplerB, e / 4);
49 cluster->
setEnergy(CaloSampling::EMB1, e / 4);
50 cluster->
setEnergy(CaloSampling::EMB2, e / 4);
51 cluster->
setEnergy(CaloSampling::EMB3, e / 4);
53 cluster->
setEnergy(CaloSampling::PreSamplerE, e / 4);
54 cluster->
setEnergy(CaloSampling::EME1, e / 4);
55 cluster->
setEnergy(CaloSampling::EME2, e / 4);
56 cluster->
setEnergy(CaloSampling::EME3, e / 4);
63 etaCaloDecor(*cluster) =
eta;
64 phiCaloDecor(*cluster) =
phi;
78 using namespace asg::CreateDummyEl;
80 setMsgLevel(MSG::INFO);
84 std::unique_ptr<xAOD::EventInfo> eventInfo =
85 std::make_unique<xAOD::EventInfo>();
86 eventInfo->makePrivateStore();
87 eventInfo->setEventNumber(363636);
88 eventInfo->setRunNumber(runNumber);
91 randomrunnumber(*eventInfo) = runNumber;
92 if (!store.
record(std::move(eventInfo),
"EventInfo").isSuccess()) {
94 return StatusCode::FAILURE;
97 size_t numel = pt_eta.size();
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) };
110 clusters->push_back(cluster);
111 fill_cluster(cluster,
eta, 0.0, e);
114 if (!store.
record(std::move(clusters),
"MyClusters").isSuccess() ||
115 !store.
record(std::move(clAux),
"MyClustersAux.").isSuccess()) {
117 return StatusCode::FAILURE;
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);
133 links.emplace_back(
"MyClusters", el->index());
134 el->setCaloClusterLinks(links);
139 if (!store.
record(std::move(electrons),
"MyElectrons").isSuccess() ||
140 !store.
record(std::move(electronsAux),
"MyElectronAux.").isSuccess()) {
142 return StatusCode::FAILURE;
145 return StatusCode::SUCCESS;
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
StatusCode getElectrons(const std::vector< std::pair< double, double > > &pt_eta, int runNumber, xAOD::TStore &store)
A number of constexpr particle constants to avoid hardcoding them directly in various places.
void record(const T *p, const std::string &key)
SG::Decorator< T, ALLOC > Decorator
Helper class to provide type-safe access to aux data.
bool setPhi(const CaloSample sampling, const float phi)
Set in a given sampling. Returns false if the sample isn't part of the cluster.
void insertMoment(MomentType type, double value)
bool setEta(const CaloSample sampling, const float eta)
Set in a given sampling. Returns false if the sample isn't part of the cluster.
bool setEnergy(const CaloSample sampling, const float e)
Set energy for a given sampling. Returns false if the sample isn't part of the cluster.
void setSamplingPattern(const unsigned sp, const bool clearSamplingVars=false)
Set sampling pattern (one bit per sampling.
@ ETACALOFRAME
Eta in the calo frame (for egamma)
@ PHICALOFRAME
Phi in the calo frame (for egamma)
A relatively simple transient store for objects created in analysis.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Electron_v1 Electron
Definition of the current "egamma version".