CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
edmtest::ThingAlgorithm Class Reference

#include <ThingAlgorithm.h>

Public Member Functions

void run (ThingCollection &thingCollection) const
 
 ThingAlgorithm (long iOffsetDelta=0, int nThings=20, bool grow=false)
 

Private Attributes

const bool grow_
 
const int nThings_
 
std::atomic< long > offset_
 
const long offsetDelta_
 

Detailed Description

Definition at line 11 of file ThingAlgorithm.h.

Constructor & Destructor Documentation

◆ ThingAlgorithm()

edmtest::ThingAlgorithm::ThingAlgorithm ( long  iOffsetDelta = 0,
int  nThings = 20,
bool  grow = false 
)
inline

Definition at line 13 of file ThingAlgorithm.h.

14  : offset_(0), offsetDelta_(iOffsetDelta), nThings_(nThings), grow_(grow) {}
std::atomic< long > offset_

Member Function Documentation

◆ run()

void ThingAlgorithm::run ( ThingCollection &  thingCollection) const

Runs the algorithm and returns a list of Things The user declares the vector and calls this method.

Definition at line 5 of file ThingAlgorithm.cc.

References grow_, mps_fire::i, nThings_, hltrates_dqm_sourceclient-live_cfg::offset, offset_, and offsetDelta_.

Referenced by edmtest::ThingExtSource::beginLuminosityBlock(), edmtest::ThingSource::beginLuminosityBlock(), edmtest::ThingExtSource::beginRun(), edmtest::ThingSource::beginRun(), Types.EventID::cppID(), Types.LuminosityBlockID::cppID(), edmtest::ThingExtSource::endLuminosityBlock(), edmtest::ThingSource::endLuminosityBlock(), edmtest::ThingExtSource::endRun(), edmtest::ThingSource::endRun(), edmtest::ThingProducer::globalBeginLuminosityBlockProduce(), edmtest::ThingProducer::globalBeginRunProduce(), edmtest::ThingProducer::globalEndLuminosityBlockProduce(), edmtest::ThingProducer::globalEndRunProduce(), edmtest::ThingExtSource::produce(), edmtest::ThingProducer::produce(), edmtest::ThingSource::produce(), and edmtest::DetSetVectorThingProducer::produce().

5  {
6  thingCollection.reserve(nThings_);
7  auto offset = offset_.fetch_add(offsetDelta_);
8  int nItems = nThings_;
9  if (grow_) {
10  nItems *= offset;
11  }
12  for (int i = 0; i < nItems; ++i) {
13  Thing tc;
14  tc.a = i + offset;
15  thingCollection.push_back(tc);
16  }
17  }
std::atomic< long > offset_

Member Data Documentation

◆ grow_

const bool edmtest::ThingAlgorithm::grow_
private

Definition at line 24 of file ThingAlgorithm.h.

Referenced by run().

◆ nThings_

const int edmtest::ThingAlgorithm::nThings_
private

Definition at line 23 of file ThingAlgorithm.h.

Referenced by run().

◆ offset_

std::atomic<long> edmtest::ThingAlgorithm::offset_
mutableprivate

Definition at line 21 of file ThingAlgorithm.h.

Referenced by run().

◆ offsetDelta_

const long edmtest::ThingAlgorithm::offsetDelta_
private

Definition at line 22 of file ThingAlgorithm.h.

Referenced by run().