@@ -161,11 +161,14 @@ namespace edm::test {
161161 actReg_ = items.actReg_ ;
162162 branchIDListHelper_ = items.branchIDListHelper ();
163163 thinnedAssociationsHelper_ = items.thinnedAssociationsHelper ();
164+ processConfiguration_ = items.processConfiguration ();
165+
164166 processContext_.setProcessConfiguration (processConfiguration_.get ());
165167 preg_ = items.preg ();
166168 principalCache_.setNumberOfConcurrentPrincipals (preallocations_);
167169
168170 preg_->setFrozen ();
171+ mergeableRunProductProcesses_.setProcessesWithMergeableRunProducts (*preg_);
169172
170173 for (unsigned int index = 0 ; index < preallocations_.numberOfStreams (); ++index) {
171174 // Reusable event principal
@@ -174,7 +177,8 @@ namespace edm::test {
174177 principalCache_.insert (std::move (ep));
175178 }
176179 for (unsigned int index = 0 ; index < preallocations_.numberOfRuns (); ++index) {
177- auto rp = std::make_unique<RunPrincipal>(preg_, *processConfiguration_, historyAppender_.get (), index);
180+ auto rp = std::make_unique<RunPrincipal>(
181+ preg_, *processConfiguration_, historyAppender_.get (), index, true , &mergeableRunProductProcesses_);
178182 principalCache_.insert (std::move (rp));
179183 }
180184 for (unsigned int index = 0 ; index < preallocations_.numberOfLuminosityBlocks (); ++index) {
@@ -190,12 +194,28 @@ namespace edm::test {
190194 source_->doBeginJob ();
191195 }
192196
197+ TestSourceProcessor::~TestSourceProcessor () {
198+ // make the services available
199+ ServiceRegistry::Operate operate (serviceToken_);
200+ try {
201+ source_.reset ();
202+ } catch (std::exception const & iExcept) {
203+ std::cerr << " caught exception while destroying TestSourceProcessor\n " << iExcept.what ();
204+ }
205+ }
206+
193207 edm::InputSource::ItemTypeInfo TestSourceProcessor::findNextTransition () {
208+ // make the services available
209+ ServiceRegistry::Operate operate (serviceToken_);
210+
194211 lastTransition_ = source_->nextItemType ();
195212 return lastTransition_;
196213 }
197214
198215 std::shared_ptr<FileBlock> TestSourceProcessor::openFile () {
216+ // make the services available
217+ ServiceRegistry::Operate operate (serviceToken_);
218+
199219 size_t size = preg_->size ();
200220 fb_ = source_->readFile ();
201221 if (size < preg_->size ()) {
@@ -217,6 +237,9 @@ namespace edm::test {
217237 << " closeFile given a FileBlock that does not correspond to the one returned by openFile" ;
218238 }
219239 if (fb_) {
240+ // make the services available
241+ ServiceRegistry::Operate operate (serviceToken_);
242+
220243 source_->closeFile (fb_.get (), false );
221244 }
222245 }
@@ -225,12 +248,15 @@ namespace edm::test {
225248 if (lastTransition_.itemType () != edm::InputSource::ItemType::IsRun) {
226249 throw cms::Exception (" NotARun" ) << " The last transition is " << name (lastTransition_.itemType ()) << " not a Run" ;
227250 }
251+ // make the services available
252+ ServiceRegistry::Operate operate (serviceToken_);
253+
228254 // NOTE: should probably handle merging as well
229255 runPrincipal_ = principalCache_.getAvailableRunPrincipalPtr ();
230256 runPrincipal_->setAux (*source_->runAuxiliary ());
231257 source_->readRun (*runPrincipal_, *historyAppender_);
232258
233- return edm::test::RunFromSource (runPrincipal_);
259+ return edm::test::RunFromSource (runPrincipal_, serviceToken_ );
234260 }
235261
236262 edm::test::LuminosityBlockFromSource TestSourceProcessor::readLuminosityBlock () {
@@ -239,25 +265,30 @@ namespace edm::test {
239265 << " The last transition is " << name (lastTransition_.itemType ()) << " not a LuminosityBlock" ;
240266 }
241267
268+ // make the services available
269+ ServiceRegistry::Operate operate (serviceToken_);
270+
242271 lumiPrincipal_ = principalCache_.getAvailableLumiPrincipalPtr ();
243272 assert (lumiPrincipal_);
244273 lumiPrincipal_->setAux (*source_->luminosityBlockAuxiliary ());
245274 source_->readLuminosityBlock (*lumiPrincipal_, *historyAppender_);
246275
247- return edm::test::LuminosityBlockFromSource (lumiPrincipal_);
276+ return edm::test::LuminosityBlockFromSource (lumiPrincipal_, serviceToken_ );
248277 }
249278
250279 edm::test::EventFromSource TestSourceProcessor::readEvent () {
251280 if (lastTransition_.itemType () != edm::InputSource::ItemType::IsEvent) {
252281 throw cms::Exception (" NotAnEvent" ) << " The last transition is " << name (lastTransition_.itemType ())
253282 << " not a Event" ;
254283 }
284+ // make the services available
285+ ServiceRegistry::Operate operate (serviceToken_);
255286
256287 auto & event = principalCache_.eventPrincipal (0 );
257288 StreamContext streamContext (event.streamID (), &processContext_);
258289
259290 source_->readEvent (event, streamContext);
260291
261- return edm::test::EventFromSource (event);
292+ return edm::test::EventFromSource (event, serviceToken_ );
262293 }
263294} // namespace edm::test
0 commit comments