Public Member Functions | Private Member Functions | Private Attributes | List of all members
arttest::AssnsProducer Class Reference
Inheritance diagram for arttest::AssnsProducer:
art::EDProducer art::detail::Producer art::detail::LegacyModule art::Modifier art::ModuleBase art::ProductRegistryHelper

Public Member Functions

 AssnsProducer (fhicl::ParameterSet const &p)
 
- Public Member Functions inherited from art::EDProducer
 EDProducer ()=default
 
 EDProducer (fhicl::ParameterSet const &pset)
 
template<typename Config >
 EDProducer (Table< Config > const &config)
 
std::string workerType () const
 
- Public Member Functions inherited from art::detail::Producer
virtual ~Producer () noexcept
 
 Producer ()
 
 Producer (fhicl::ParameterSet const &)
 
 Producer (Producer const &)=delete
 
 Producer (Producer &&)=delete
 
Produceroperator= (Producer const &)=delete
 
Produceroperator= (Producer &&)=delete
 
void doBeginJob ()
 
void doEndJob ()
 
void doRespondToOpenInputFile (FileBlock const &fb)
 
void doRespondToCloseInputFile (FileBlock const &fb)
 
void doRespondToOpenOutputFiles (FileBlock const &fb)
 
void doRespondToCloseOutputFiles (FileBlock const &fb)
 
bool doBeginRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doEndRun (RunPrincipal &rp, ModuleContext const &mc)
 
bool doBeginSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEndSubRun (SubRunPrincipal &srp, ModuleContext const &mc)
 
bool doEvent (EventPrincipal &ep, ModuleContext const &mc, std::atomic< std::size_t > &counts_run, std::atomic< std::size_t > &counts_passed, std::atomic< std::size_t > &counts_failed)
 
- Public Member Functions inherited from art::Modifier
virtual ~Modifier () noexcept
 
 Modifier ()
 
 Modifier (Modifier const &)=delete
 
 Modifier (Modifier &&)=delete
 
Modifieroperator= (Modifier const &)=delete
 
Modifieroperator= (Modifier &&)=delete
 
- Public Member Functions inherited from art::ModuleBase
virtual ~ModuleBase () noexcept
 
 ModuleBase ()
 
ModuleDescription const & moduleDescription () const
 
void setModuleDescription (ModuleDescription const &)
 
template<typename T , BranchType = InEvent>
ProductToken< T > consumes (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename T , BranchType = InEvent>
ProductToken< T > mayConsume (InputTag const &)
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
std::array< std::vector< ProductInfo >, NumBranchTypes > const & getConsumables () const
 
void sortConsumables (std::string const &current_process_name)
 
template<typename T , BranchType BT>
ViewToken< T > consumesView (InputTag const &tag)
 
template<typename T , BranchType BT>
ViewToken< T > mayConsumeView (InputTag const &tag)
 

Private Member Functions

void produce (art::Event &e) override
 

Private Attributes

std::string const wantVoid_
 
bool const wantMV_
 
bool const wantMany_
 
bool const dinkVoid_
 
bool const wantAmbiguous_
 

Additional Inherited Members

- Public Types inherited from art::EDProducer
using ModuleType = EDProducer
 
using WorkerType = WorkerT< EDProducer >
 
- Public Types inherited from art::detail::Producer
template<typename UserConfig , typename KeysToIgnore = void>
using Table = Modifier::Table< UserConfig, KeysToIgnore >
 
- Public Types inherited from art::Modifier
template<typename UserConfig , typename UserKeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::ModuleConfig, UserKeysToIgnore >
 
- Static Public Member Functions inherited from art::EDProducer
static void commitEvent (EventPrincipal &ep, Event &e)
 

Detailed Description

Definition at line 38 of file AssnsProducer_module.cc.

Constructor & Destructor Documentation

arttest::AssnsProducer::AssnsProducer ( fhicl::ParameterSet const &  p)
explicit

Definition at line 58 of file AssnsProducer_module.cc.

59  : EDProducer{ps}
60  , wantVoid_{ps.get<std::string>("wantVoid", "ALL")}
61  , wantMV_{ps.get<bool>("wantMV", true)}
62  , wantMany_{ps.get<bool>("wantMany", true)}
63  , dinkVoid_{ps.get<bool>("dinkVoid", false)}
64  , wantAmbiguous_{ps.get<bool>("wantAmbiguous", false)}
65 {
66  produces<uintvec>();
67  produces<stringvec>();
68  if (wantMV_) {
69  produces<mapvec>("mv");
70  produces<AssnsABX_t>("mapvec");
71  if (wantMany_) {
72  produces<AssnsABX_t>("manymapvec");
73  }
74  if (wantVoid_ != "NONE") {
75  produces<AssnsVoid_t>("mapvec");
76  if (wantMany_) {
77  produces<AssnsVoid_t>("manymapvec");
78  }
79  }
80  }
81  produces<AssnsABX_t>();
82  if (wantMany_) {
83  produces<AssnsABX_t>("many");
84  }
85  if (wantVoid_ == "ALL") {
86  produces<AssnsVoid_t>();
87  if (wantMany_) {
88  produces<AssnsVoid_t>("many");
89  }
90  }
91  if (wantAmbiguous_) {
92  produces<AssnsABY_t>();
93  }
94 }
static const double ps
Definition: Units.h:103
std::string string
Definition: nybbler.cc:12
EDProducer()=default

Member Function Documentation

void arttest::AssnsProducer::produce ( art::Event e)
overrideprivatevirtual

Implements art::EDProducer.

Definition at line 97 of file AssnsProducer_module.cc.

98 {
99 
100  // Create the data products among which we will make associations.
101  auto vui = make_unique<uintvec>(uintvec{2, 0, 1});
102  auto vs = make_unique<stringvec>(stringvec{"one", "two", "zero"});
103 
104  // Making a map_vector is hard.
105  auto mvs = make_unique<mapvec>();
106  using key_t = mapvec::key_type;
107  mvs->reserve(4);
108  (*mvs)[key_t(0)] = "zero";
109  (*mvs)[key_t(11)] = "one";
110  (*mvs)[key_t(22)] = "two";
111 
112  // Extra members.
113  if (dinkVoid_) {
114  vui->emplace_back(4);
115  vs->emplace_back("four");
116  (*mvs)[key_t(33)] = "four";
117  }
118 
119  // We will need the product IDs of the data products.
120  ProductID const vui_pid{e.getProductID<uintvec>()};
121  ProductID const vs_pid{e.getProductID<stringvec>()};
122 
123  // Create the association objects.
124  // Assns into vectors.
125  auto a = std::make_unique<AssnsABX_t>();
126  auto ay = std::make_unique<AssnsABY_t>();
127  auto av = std::make_unique<AssnsVoid_t>();
128 
129  // Assns into map_vector.
130  auto b = std::make_unique<AssnsABX_t>();
131  auto bv = std::make_unique<AssnsVoid_t>();
132 
133  // addS will add to both x and xv a reference between slot1 of
134  // productID1 and slot2 of productID2. The reference in x will have
135  // associated data td.
136  auto addS = [&e](auto& x,
137  auto& xv,
138  ProductID const id1,
139  size_t const slot1,
140  ProductID const id2,
141  size_t const slot2,
142  auto td) {
143  Ptr<size_t> const p1{id1, slot1, e.productGetter(id1)};
144  Ptr<string> const p2{id2, slot2, e.productGetter(id2)};
145  x->addSingle(p1, p2, td);
146  xv->addSingle(p1, p2);
147  };
148  // AddSV adds only to x, and has no td.
149  auto addSV = [&e](auto& x,
150  ProductID const id1,
151  size_t const slot1,
152  ProductID const id2,
153  size_t const slot2) {
154  Ptr<size_t> const p1{id1, slot1, e.productGetter(id1)};
155  Ptr<string> const p2{id2, slot2, e.productGetter(id2)};
156  x->addSingle(p1, p2);
157  };
158  // AddSS adds only to x (with td).
159  auto addSS = [&e](auto& x,
160  ProductID const id1,
161  size_t const slot1,
162  ProductID const id2,
163  size_t const slot2,
164  auto td) {
165  Ptr<size_t> const p1{id1, slot1, e.productGetter(id1)};
166  Ptr<string> const p2{id2, slot2, e.productGetter(id2)};
167  x->addSingle(p1, p2, td);
168  };
169 
170  // We add associations in an order such that the associated data are
171  // in alphabetical order.
172  addS(a, av, vui_pid, 1, vs_pid, 2, AssnTestData(1, 2, "A"));
173  addSS(ay, vui_pid, 1, vs_pid, 2, "A");
174 
175  addS(a, av, vui_pid, 2, vs_pid, 0, AssnTestData(2, 0, "B"));
176  addSS(ay, vui_pid, 2, vs_pid, 0, "B");
177 
178  addS(a, av, vui_pid, 0, vs_pid, 1, AssnTestData(0, 1, "C"));
179  addSS(ay, vui_pid, 0, vs_pid, 1, "C");
180 
181  if (dinkVoid_) {
182  addSV(av, vui_pid, 3, vs_pid, 3);
183  }
184 
185  auto am = make_unique<AssnsABX_t>(*a);
186  auto avm = make_unique<AssnsVoid_t>(*av);
187 
188  addS(am, avm, vui_pid, 1, vs_pid, 2, AssnTestData(1, 2, "AA"));
189 
190  if (dinkVoid_) {
191  addSV(avm, vui_pid, 3, vs_pid, 3);
192  }
193 
194  std::unique_ptr<AssnsABX_t> bm;
195  std::unique_ptr<AssnsVoid_t> bvm;
196 
197  if (wantMV_) {
198  ProductID const mvs_pid{e.getProductID<mapvec>("mv")};
199  addS(b, bv, vui_pid, 1, mvs_pid, 0, AssnTestData(1, 0, "A"));
200  addS(b, bv, vui_pid, 2, mvs_pid, 11, AssnTestData(2, 11, "B"));
201  addS(b, bv, vui_pid, 0, mvs_pid, 22, AssnTestData(0, 22, "C"));
202  if (dinkVoid_) {
203  addSV(bv, vui_pid, 3, mvs_pid, 33);
204  }
205  bm = make_unique<AssnsABX_t>(*b);
206  bvm = make_unique<AssnsVoid_t>(*bv);
207  addS(bm, bvm, vui_pid, 1, mvs_pid, 0, AssnTestData(1, 0, "AA"));
208  if (dinkVoid_) {
209  addSV(bvm, vui_pid, 3, mvs_pid, 33);
210  }
211  }
212 
213  e.put(std::move(vui));
214  e.put(std::move(vs));
215  if (wantMV_) {
216  e.put(std::move(mvs), "mv");
217  e.put(std::move(b), "mapvec");
218  if (wantMany_) {
219  e.put(std::move(bm), "manymapvec");
220  }
221  if (wantVoid_ != "NONE") {
222  e.put(std::move(bv), "mapvec");
223  if (wantMany_) {
224  e.put(std::move(bvm), "manymapvec");
225  }
226  }
227  }
228  e.put(std::move(a));
229  if (wantMany_) {
230  e.put(std::move(am), "many");
231  }
232  if (wantVoid_ == "ALL") {
233  e.put(std::move(av));
234  if (wantMany_) {
235  e.put(std::move(avm), "many");
236  }
237  }
238  if (wantAmbiguous_) {
239  e.put(std::move(ay));
240  }
241 }
map_vector_key key_type
Definition: map_vector.h:87
ProductID getProductID(std::string const &instance_name="") const
Definition: DataViewImpl.h:347
std::vector< std::string > stringvec
const double e
const double a
EDProductGetter const * productGetter(ProductID const pid) const
vector< size_t > uintvec
ProductID put(std::unique_ptr< PROD > &&edp, FullSemantic< Level::Run > const semantic)
Definition: DataViewImpl.h:692
Definition: fwd.h:26
std::string key_t
Definition: KeyAssembler.h:71

Member Data Documentation

bool const arttest::AssnsProducer::dinkVoid_
private

Definition at line 48 of file AssnsProducer_module.cc.

bool const arttest::AssnsProducer::wantAmbiguous_
private

Definition at line 49 of file AssnsProducer_module.cc.

bool const arttest::AssnsProducer::wantMany_
private

Definition at line 47 of file AssnsProducer_module.cc.

bool const arttest::AssnsProducer::wantMV_
private

Definition at line 46 of file AssnsProducer_module.cc.

std::string const arttest::AssnsProducer::wantVoid_
private

Definition at line 45 of file AssnsProducer_module.cc.


The documentation for this class was generated from the following file: