CMS 3D CMS Logo

ThingProducer.cc
Go to the documentation of this file.
1 #include "ThingProducer.h"
6 
7 namespace edmtest {
9  : alg_(iConfig.getParameter<int>("offsetDelta"),
10  iConfig.getParameter<int>("nThings"),
11  iConfig.getParameter<bool>("grow")),
12  noPut_(iConfig.getUntrackedParameter<bool>("noPut")) // used for testing with missing products
13  {
14  evToken_ = produces<ThingCollection>();
15  blToken_ = produces<ThingCollection, edm::Transition::BeginLuminosityBlock>("beginLumi");
16  elToken_ = produces<ThingCollection, edm::Transition::EndLuminosityBlock>("endLumi");
17  brToken_ = produces<ThingCollection, edm::Transition::BeginRun>("beginRun");
18  erToken_ = produces<ThingCollection, edm::Transition::EndRun>("endRun");
19  }
20 
21  // Virtual destructor needed.
23 
24  // Functions that gets called by framework every event
26  // Step A: Get Inputs
27 
28  // Step B: Create empty output
29  ThingCollection result; //Empty
30 
31  // Step C: Invoke the algorithm, passing in inputs (NONE) and getting back outputs.
32  alg_.run(result);
33 
34  // Step D: Put outputs into event
35  if (!noPut_)
36  e.emplace(evToken_, std::move(result));
37  }
38 
39  // Functions that gets called by framework every luminosity block
41  // Step A: Get Inputs
42 
43  // Step B: Create empty output
44  ThingCollection result; //Empty
45 
46  // Step C: Invoke the algorithm, passing in inputs (NONE) and getting back outputs.
47  alg_.run(result);
48 
49  // Step D: Put outputs into lumi block
50  if (!noPut_)
52  }
53 
55  // Step A: Get Inputs
56 
57  // Step B: Create empty output
58  ThingCollection result; //Empty
59 
60  // Step C: Invoke the algorithm, passing in inputs (NONE) and getting back outputs.
61  alg_.run(result);
62 
63  // Step D: Put outputs into lumi block
64  if (!noPut_)
66  }
67 
68  // Functions that gets called by framework every run
70  // Step A: Get Inputs
71 
72  // Step B: Create empty output
73  ThingCollection result; //Empty
74 
75  // Step C: Invoke the algorithm, passing in inputs (NONE) and getting back outputs.
76  alg_.run(result);
77 
78  // Step D: Put outputs into event
79  if (!noPut_)
80  r.emplace(brToken_, std::move(result));
81  }
82 
84  // Step A: Get Inputs
85 
86  // Step B: Create empty output
87  ThingCollection result; //Empty
88 
89  // Step C: Invoke the algorithm, passing in inputs (NONE) and getting back outputs.
90  alg_.run(result);
91 
92  // Step D: Put outputs into event
93  if (!noPut_)
94  r.emplace(erToken_, std::move(result));
95  }
96 
99  desc.add<int>("offsetDelta", 0)
100  ->setComment(
101  "How much extra to increment the value used when creating Things for a new container. E.g. the last value "
102  "used to create Thing from the previous event is incremented by 'offsetDelta' to compute the value to use "
103  "of the first Thing created in the next Event.");
104  desc.add<int>("nThings", 20)->setComment("How many Things to put in each collection.");
105  desc.add<bool>("grow", false)
106  ->setComment("If true, multiply 'nThings' by the value of offset for each run of the algorithm.");
107  desc.addUntracked<bool>("noPut", false)
108  ->setComment("If true, data is not put into the Principal. This is used to test missing products.");
109  descriptions.add("thingProd", desc);
110  }
111 
112 } // namespace edmtest
void globalBeginRunProduce(edm::Run &r, edm::EventSetup const &c) const override
void produce(edm::StreamID, edm::Event &e, edm::EventSetup const &c) const override
void globalEndLuminosityBlockProduce(edm::LuminosityBlock &lb, edm::EventSetup const &c) const override
edm::EDPutTokenT< ThingCollection > evToken_
Definition: ThingProducer.h:42
edm::EDPutTokenT< ThingCollection > elToken_
Definition: ThingProducer.h:46
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void globalBeginLuminosityBlockProduce(edm::LuminosityBlock &lb, edm::EventSetup const &c) const override
void run(ThingCollection &thingCollection) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
ThingProducer(edm::ParameterSet const &ps)
Definition: ThingProducer.cc:8
void emplace(EDPutTokenT< PROD > token, Args &&... args)
puts a new product
void globalEndRunProduce(edm::Run &r, edm::EventSetup const &c) const override
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::EDPutTokenT< ThingCollection > blToken_
Definition: ThingProducer.h:45
edm::EDPutTokenT< ThingCollection > erToken_
Definition: ThingProducer.h:44
def move(src, dest)
Definition: eostools.py:511
Definition: Run.h:45
ThingAlgorithm alg_
Definition: ThingProducer.h:41
edm::EDPutTokenT< ThingCollection > brToken_
Definition: ThingProducer.h:43