ATLAS Offline Software
Loading...
Searching...
No Matches
FillerAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
5// $Id$
12
13
14#include "FillerAlg.h"
15#include "D3PDMakerTest/Obj1.h"
16#include "D3PDMakerTest/Obj3.h"
17#include "D3PDMakerTest/Obj4.h"
18#include "D3PDMakerTest/Obj5.h"
24#include <sstream>
25#include <stdint.h>
26
27
28using CLHEP::GeV;
29using std::make_unique;
30
31
32namespace D3PDTest {
33
34
35// Dufus-quality RNG, using LCG. Constants from numerical recipies.
36// I don't particularly care about RNG quality here, just about
37// getting something that's reproducible.
38std::atomic<uint32_t> seed = 1;
39const uint32_t rngmax = static_cast<uint32_t> (-1);
40uint32_t rng()
41{
42 seed = (1664525*seed + 1013904223);
43 return seed;
44}
45
46double randf (double rmax, double rmin = 0)
47{
48 return static_cast<double>(rng()) / rngmax * (rmax-rmin) + rmin;
49}
50
51
52
53
59FillerAlg::FillerAlg (const std::string& name,
60 ISvcLocator* svcloc)
61 : AthAlgorithm (name, svcloc),
62 m_count (0)
63{
64 declareProperty ("SGKeyObj1Cont", m_sgkeyObj1cont = "obj1container");
65 declareProperty ("SGKeyObj1Sel", m_sgkeyObj1sel = "obj1sel");
66 declareProperty ("SGKeyObj1", m_sgkeyObj1 = "obj1");
67 declareProperty ("SGKeyObj3Cont", m_sgkeyObj3cont = "obj3container");
68 declareProperty ("SGKeyObj4Cont", m_sgkeyObj4cont = "obj4container");
69 declareProperty ("SGKeyObj5Cont", m_sgkeyObj5cont = "obj5container");
70}
71
72
77{
78 Obj1Container::dvlinfo(); // TEMP
79 m_count = 0;
80 return AthAlgorithm::initialize();
81}
82
83
88{
89 return AthAlgorithm::finalize();
90}
91
92
97{
100 for (unsigned i = 0; i < 10; i++) {
101 Obj1* o1 = new Obj1 (10*m_count + i);
102 for (unsigned int j=0; j < i; j++)
103 o1->m_vo2.push_back (Obj2 (10*m_count + i + 100*j));
104 c->push_back (o1);
105
106 if (i % (m_count+1) == 0)
107 s->SetBit (i);
108 }
109 CHECK( this->evtStore()->record (c, m_sgkeyObj1cont) );
110 CHECK( this->evtStore()->record (s, m_sgkeyObj1sel) );
111
112 Obj1* o1 = new Obj1;
113 for (int i = 0; i < m_count; i++)
114 o1->m_vo2.push_back (Obj2 (i + 23*m_count));
115 for (int i = 0; i < 2*m_count; i++)
116 o1->m_vo3.push_back (Obj2 (i + 27*m_count));
117 c = new Obj1Container;
118 c->push_back (o1);
119 CHECK( this->evtStore()->record (c, m_sgkeyObj1) );
120
121 return StatusCode::SUCCESS;
122}
123
124
129{
131 for (unsigned i = 0; i < 10; i++) {
132 double pt = randf(100*GeV);
133 double eta = randf(5, -5);
134 double phi = randf(-M_PI, M_PI);
135 double m = randf(10*GeV);
136 Obj3* o3 = new Obj3 (pt, eta, phi, m);
137 c->push_back (o3);
138 }
139 CHECK( this->evtStore()->record (c, m_sgkeyObj3cont) );
140 return StatusCode::SUCCESS;
141}
142
143
148{
150 for (unsigned i = 0; i < 10; i++) {
151 Obj4* o4 = new Obj4 (30*m_count + i);
152 c->push_back (o4);
153 }
154 CHECK( this->evtStore()->record (c, m_sgkeyObj4cont) );
155
156 return StatusCode::SUCCESS;
157}
158
159
164{
165 auto c = make_unique<Obj5Container>();
166 auto store = make_unique<SG::AuxStoreInternal>();
167 c->setStore (store.get());
168
169 static const Obj5::Accessor<int> anInt ("anInt");
170 static const Obj5::Accessor<float> aFloat ("aFloat");
171 static const Obj5::Accessor<std::string> aString ("aString");
172 static const Obj5::Accessor<D3PDTest::MyVec2> aFourvec ("aFourvec");
173
174 for (unsigned i = 0; i < 10; i++) {
175 c->push_back (make_unique<Obj5> (300*m_count + i));
176 anInt(*c->back()) = 400*m_count + i;
177 aFloat(*c->back()) = 500*m_count + i + 0.5;
178
179 std::ostringstream os;
180 os << "aux " << 600*m_count + i;
181 aString(*c->back()) = os.str();
182
183 double pt = randf(100*GeV);
184 double eta = randf(-5, 5);
185 double phi = randf(-M_PI, M_PI);
186 double m = randf(10*GeV);
187 aFourvec(*c->back()).SetPtEtaPhiM (pt, eta, phi, m);
188 }
189 CHECK( this->evtStore()->record (std::move(c), m_sgkeyObj5cont) );
190 CHECK( this->evtStore()->record (std::move(store), m_sgkeyObj5cont + "Aux.") );
191
192 return StatusCode::SUCCESS;
193}
194
195
200{
205
206 ++m_count;
207 return StatusCode::SUCCESS;
208}
209
210
211} // namespace D3PDTest
#define M_PI
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
An auxiliary data store that holds data internally.
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
Put objects into StoreGate to test D3PD maker.
DataVector< INavigable4Momentum > INavigable4MomentumCollection
Test class for D3PD maker.
Test class for D3PD maker.
Test class for D3PD maker.
Test class for D3PD maker.
Test class for D3PD maker (aux data).
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
FillerAlg(const std::string &name, ISvcLocator *svcloc)
Standard Gaudi algorithm constructor.
Definition FillerAlg.cxx:59
std::string m_sgkeyObj5cont
Definition FillerAlg.h:75
virtual StatusCode finalize()
Standard Gaudi finalize method.
Definition FillerAlg.cxx:87
std::string m_sgkeyObj1cont
Definition FillerAlg.h:70
StatusCode fillObj3Collections()
Fill collections involving Obj3.
std::string m_sgkeyObj3cont
Definition FillerAlg.h:73
std::string m_sgkeyObj1
Definition FillerAlg.h:72
std::string m_sgkeyObj1sel
Definition FillerAlg.h:71
virtual StatusCode execute()
Standard Gaudi execute method.
std::string m_sgkeyObj4cont
Definition FillerAlg.h:74
StatusCode fillObj4Collections()
Fill collections involving Obj4.
virtual StatusCode initialize()
Standard Gaudi initialize method.
Definition FillerAlg.cxx:76
StatusCode fillObj1Collections()
Fill collections involving Obj1/2.
Definition FillerAlg.cxx:96
StatusCode fillObj5Collections()
Fill collections involving Obj5.
Test class for D3PD maker.
Definition Obj1.h:38
Test class for D3PD maker.
Definition Obj2.h:28
Test class for D3PD maker.
Definition Obj3.h:33
Test class for D3PD maker.
Definition Obj4.h:34
static const DataModel_detail::DVLInfoBase & dvlinfo()
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
uint32_t rng()
Definition FillerAlg.cxx:40
std::atomic< uint32_t > seed
Definition FillerAlg.cxx:38
double randf(double rmax, double rmin=0)
Definition FillerAlg.cxx:46
const uint32_t rngmax
Definition FillerAlg.cxx:39