Public Member Functions | Public Attributes | List of all members
EventTestFixture Struct Reference

Public Member Functions

 EventTestFixture ()
 
template<class T >
ProductID addSourceProduct (std::unique_ptr< T > &&product, std::string const &tag, std::string const &instanceName={})
 
ProductTablesFixtureptf ()
 

Public Attributes

std::unique_ptr< RunPrincipalrunPrincipal_ {}
 
std::unique_ptr< SubRunPrincipalsubRunPrincipal_ {}
 
std::unique_ptr< EventPrincipalprincipal_ {nullptr}
 
ModuleContext currentModuleContext_ {ModuleContext::invalid()}
 
std::unique_ptr< EventcurrentEvent_ {nullptr}
 

Detailed Description

Definition at line 227 of file Event_t.cc.

Constructor & Destructor Documentation

EventTestFixture::EventTestFixture ( )

Definition at line 244 of file Event_t.cc.

245 {
246  // Construct process history for event. This takes several lines of
247  // code but other than the process names none of it is used or
248  // interesting.
249  ProcessHistory processHistory;
250  for (auto const& process : ptf().moduleConfigurations_) {
251  auto const& process_name = process.first;
252  // Skip current process since it is not yet part of the history.
253  if (process_name == "CURRENT") {
254  continue;
255  }
256 
257  // Construct the ParameterSet for each process
258  auto const& module_configurations = process.second;
259  ParameterSet processParameterSet;
260  processParameterSet.put("process_name", process_name);
261  for (auto const& modConfig : module_configurations) {
262  processParameterSet.put(modConfig.first, modConfig.second);
263  }
264 
265  ProcessConfiguration const processConfiguration{
266  process.first, processParameterSet.id(), getReleaseVersion()};
267  processHistory.push_back(processConfiguration);
268  }
269 
270  auto const processHistoryID = processHistory.id();
271  ProcessHistoryRegistry::emplace(processHistoryID, processHistory);
272 
273  // When any new product is added to the event principal at
274  // movePutProductsToPrincipal, the "CURRENT" process will go into the
275  // ProcessHistory because the process name comes from the
276  // currentModuleDescription stored in the principal. On the other hand, when
277  // addSourceProduct is called, another event is created with a fake
278  // moduleDescription containing the old process name and that is used to
279  // create the group in the principal used to look up the object.
280 
281  constexpr auto time = make_timestamp();
282  EventID const id{make_id()};
283  ProcessConfiguration const& pc =
285 
286  RunAuxiliary const runAux{id.run(), time, time};
287  runPrincipal_ = std::make_unique<RunPrincipal>(runAux, pc, nullptr);
288 
289  SubRunAuxiliary const subRunAux{runPrincipal_->run(), 1u, time, time};
290  subRunPrincipal_ = std::make_unique<SubRunPrincipal>(subRunAux, pc, nullptr);
291  subRunPrincipal_->setRunPrincipal(runPrincipal_.get());
292 
293  EventAuxiliary const eventAux{id, time, true};
294  auto history = std::make_unique<History>();
295  const_cast<ProcessHistoryID&>(history->processHistoryID()) = processHistoryID;
296  principal_ = std::make_unique<EventPrincipal>(
297  eventAux, pc, &ptf().presentProducts_, std::move(history));
298  principal_->setSubRunPrincipal(subRunPrincipal_.get());
299  principal_->createGroupsForProducedProducts(ptf().producedProducts_);
300  principal_->enableLookupOfProducedProducts(ptf().producedProducts_);
301 
303  currentEvent_ = std::make_unique<Event>(*principal_, currentModuleContext_);
304 }
ProductTablesFixture & ptf()
Definition: Event_t.cc:333
ModuleContext currentModuleContext_
Definition: Event_t.cc:240
std::unique_ptr< SubRunPrincipal > subRunPrincipal_
Definition: Event_t.cc:238
std::unique_ptr< RunPrincipal > runPrincipal_
Definition: Event_t.cc:237
ProcessHistoryID id() const
def process(f, kind)
Definition: search.py:254
std::unique_ptr< EventPrincipal > principal_
Definition: Event_t.cc:239
def move(depos, offset)
Definition: depos.py:107
std::string const & getReleaseVersion()
std::unique_ptr< Event > currentEvent_
Definition: Event_t.cc:241
ProcessConfiguration const & processConfiguration() const
ParameterSetID id() const
RunNumber_t run() const noexcept
void push_back(const_reference t)
ProductTable presentProducts_
Definition: Event_t.cc:128
void put(std::string const &key)
ModuleDescription currentModuleDescription_
Definition: Event_t.cc:116

Member Function Documentation

template<class T >
ProductID EventTestFixture::addSourceProduct ( std::unique_ptr< T > &&  product,
std::string const &  tag,
std::string const &  instanceName = {} 
)

Definition at line 310 of file Event_t.cc.

313 {
314  auto description = ptf().moduleDescriptions_.find(tag);
315  if (description == ptf().moduleDescriptions_.end())
317  << "Failed to find a module description for tag: " << tag << '\n';
318 
319  auto lookup = ptf().earlyLookup_.find(tag);
320  if (lookup == ptf().earlyLookup_.end())
322  << "Failed to find a product lookup for tag: " << tag << '\n';
323 
324  ModuleContext const tempMC{description->second};
325  Event temporaryEvent{*principal_, tempMC};
326  ProductID const id{temporaryEvent.put(std::move(product), instanceName)};
327 
328  EDProducer::commitEvent(*principal_, temporaryEvent);
329  return id;
330 }
ProductTablesFixture & ptf()
Definition: Event_t.cc:333
std::unique_ptr< EventPrincipal > principal_
Definition: Event_t.cc:239
def move(depos, offset)
Definition: depos.py:107
std::map< std::string, ModuleDescription > moduleDescriptions_
Definition: Event_t.cc:122
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
std::map< std::string, TypeLabelLookup_t > earlyLookup_
Definition: Event_t.cc:129
ProductTablesFixture & EventTestFixture::ptf ( )

Definition at line 333 of file Event_t.cc.

334 {
335  static ProductTablesFixture ptf_s;
336  return ptf_s;
337 }

Member Data Documentation

std::unique_ptr<Event> EventTestFixture::currentEvent_ {nullptr}

Definition at line 241 of file Event_t.cc.

ModuleContext EventTestFixture::currentModuleContext_ {ModuleContext::invalid()}

Definition at line 240 of file Event_t.cc.

std::unique_ptr<EventPrincipal> EventTestFixture::principal_ {nullptr}

Definition at line 239 of file Event_t.cc.

std::unique_ptr<RunPrincipal> EventTestFixture::runPrincipal_ {}

Definition at line 237 of file Event_t.cc.

std::unique_ptr<SubRunPrincipal> EventTestFixture::subRunPrincipal_ {}

Definition at line 238 of file Event_t.cc.


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