CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
TFWLiteSelectorBasic Class Referenceabstract

#include <FWCore/FWLite/interface/TFWLiteSelectorBasic.h>

Inheritance diagram for TFWLiteSelectorBasic:
TFWLiteSelector< TWorker > TFWLiteSelector< __class__Worker > TFWLiteSelector< ThingsWorker > TFWLiteSelector< TrackAnalysisAlgorithm > tfwliteselectortest::ThingsTSelector __class__< T > tfwliteselectortest::ThingsTSelector2 examples::TrackTSelector

Public Member Functions

virtual void begin (TList *&in)=0
 
virtual void postProcessing (TList &out)=0
 
virtual void preProcessing (const TList *in, TList &out)=0
 
virtual void process (const edm::Event &event)=0
 
virtual void terminate (TList &out)=0
 
 TFWLiteSelectorBasic ()
 
 ~TFWLiteSelectorBasic () override
 

Private Member Functions

void Begin (TTree *) override
 
void Init (TTree *) override
 
Bool_t Notify () override
 
const TFWLiteSelectorBasicoperator= (const TFWLiteSelectorBasic &)
 
Bool_t Process (Long64_t) override
 
void setupNewFile (TFile &)
 
void SlaveBegin (TTree *) override
 
void SlaveTerminate () override
 
void Terminate () override
 
 TFWLiteSelectorBasic (const TFWLiteSelectorBasic &)
 
Int_t Version () const override
 

Private Attributes

bool everythingOK_
 
edm::propagate_const< std::shared_ptr< edm::root::TFWLiteSelectorMembers > > m_
 

Detailed Description

Description: A ROOT TSelector which accesses data using an edm::Event

Usage: By inheriting from this class one can make a TSelector for ROOT which works with PROOF and which allows you to access data using an edm::Event.

Definition at line 42 of file TFWLiteSelectorBasic.h.

Constructor & Destructor Documentation

TFWLiteSelectorBasic::TFWLiteSelectorBasic ( )

Definition at line 212 of file TFWLiteSelectorBasic.cc.

edm::propagate_const< std::shared_ptr< edm::root::TFWLiteSelectorMembers > > m_
TFWLiteSelectorBasic::~TFWLiteSelectorBasic ( )
override

Definition at line 219 of file TFWLiteSelectorBasic.cc.

219 {}
TFWLiteSelectorBasic::TFWLiteSelectorBasic ( const TFWLiteSelectorBasic )
private

Member Function Documentation

virtual void TFWLiteSelectorBasic::begin ( TList *&  in)
pure virtual

Called each time the 'client' begins processing (remote 'slaves' do not see this message)

Parameters
inan assignable pointer to a list of objects you want passed to 'preProcessing'. This list is used to communicate with remote slaves. NOTE: you are responsible for deleting this TList and its content once you are done with it.

Implemented in __class__< T >, tfwliteselectortest::ThingsTSelector2, examples::TrackTSelector, and tfwliteselectortest::ThingsTSelector.

Referenced by Begin().

void TFWLiteSelectorBasic::Begin ( TTree *  iTree)
overrideprivate

Definition at line 236 of file TFWLiteSelectorBasic.cc.

References begin(), and Init().

236  {
237  Init(iTree);
238  begin(fInput);
239 }
void Init(TTree *) override
virtual void begin(TList *&in)=0
void TFWLiteSelectorBasic::Init ( TTree *  iTree)
overrideprivate

Definition at line 246 of file TFWLiteSelectorBasic.cc.

References m_.

Referenced by Begin(), and SlaveBegin().

246  {
247  if (iTree == nullptr)
248  return;
249  m_->setTree(iTree);
250 }
edm::propagate_const< std::shared_ptr< edm::root::TFWLiteSelectorMembers > > m_
Bool_t TFWLiteSelectorBasic::Notify ( )
overrideprivate

Definition at line 252 of file TFWLiteSelectorBasic.cc.

References gather_cfg::cout, everythingOK_, FrontierConditions_GlobalTag_cff::file, m_, edm::setRefCoreStreamer(), and setupNewFile().

252  {
253  //std::cout << "Notify start" << std::endl;
254  //we have switched to a new file
255  //get new file from Tree
256  if (nullptr == m_->tree_) {
257  std::cout << "No tree" << std::endl;
258  return kFALSE;
259  }
260  TFile* file = m_->tree_->GetCurrentFile();
261  if (nullptr == file) {
262  //When in Rome, do as the Romans
263  TChain* chain = dynamic_cast<TChain*>(m_->tree());
264  if (nullptr == chain) {
265  std::cout << "No file" << std::endl;
266  return kFALSE;
267  }
268  file = chain->GetFile();
269  if (nullptr == file) {
270  std::cout << "No file" << std::endl;
271  return kFALSE;
272  }
273  }
274  setupNewFile(*file);
275  return everythingOK_ ? kTRUE : kFALSE;
276 }
Definition: chain.py:1
edm::propagate_const< std::shared_ptr< edm::root::TFWLiteSelectorMembers > > m_
const TFWLiteSelectorBasic& TFWLiteSelectorBasic::operator= ( const TFWLiteSelectorBasic )
private
virtual void TFWLiteSelectorBasic::postProcessing ( TList &  out)
pure virtual

Called each time the 'slave' has seen all the events

Parameters
outthe list of objects that will be sent to 'terminate'. You can Add() additional objects to 'out' at this point as well.

Implemented in TFWLiteSelector< TWorker >, TFWLiteSelector< ThingsWorker >, TFWLiteSelector< __class__Worker >, TFWLiteSelector< TrackAnalysisAlgorithm >, and tfwliteselectortest::ThingsTSelector.

Referenced by SlaveTerminate().

virtual void TFWLiteSelectorBasic::preProcessing ( const TList *  in,
TList &  out 
)
pure virtual

Called each time the 'slave' is about to start processing

Parameters
ina pointer to the list of objects created in 'begin()'. The pointer can be 0
outa list of objects that are the result of processing (e.g. histograms). You should call 'Add()' for each object you want sent to the 'terminate' method.

Implemented in TFWLiteSelector< TWorker >, TFWLiteSelector< ThingsWorker >, TFWLiteSelector< __class__Worker >, TFWLiteSelector< TrackAnalysisAlgorithm >, and tfwliteselectortest::ThingsTSelector.

Referenced by SlaveBegin().

virtual void TFWLiteSelectorBasic::process ( const edm::Event event)
pure virtual

Call each time the 'slave' gets a new Event

Parameters
eventa standard edm::Event which works just like it does in cmsRun

Implemented in TFWLiteSelector< TWorker >, TFWLiteSelector< ThingsWorker >, TFWLiteSelector< __class__Worker >, TFWLiteSelector< TrackAnalysisAlgorithm >, and tfwliteselectortest::ThingsTSelector.

Referenced by Process().

Bool_t TFWLiteSelectorBasic::Process ( Long64_t  iEntry)
overrideprivate

Definition at line 289 of file TFWLiteSelectorBasic.cc.

References printConversionInfo::aux, MicroEventContent_cff::branch, edm::poolNames::branchListIndexesBranchName(), edm::BranchTypeToAuxiliaryBranchName(), gather_cfg::cout, event(), edm::poolNames::eventSelectionsBranchName(), everythingOK_, cppFunctionSkipper::exception, Exception, edm::errors::FatalRootError, edm::propagate_const< T >::get(), edm::InEvent, m_, eostools::move(), and process().

289  {
290  //std::cout << "Process start" << std::endl;
291  if (everythingOK_) {
292  std::unique_ptr<edm::EventAuxiliary> eaux = std::make_unique<edm::EventAuxiliary>();
293  edm::EventAuxiliary& aux = *eaux;
294  edm::EventAuxiliary* pAux = eaux.get();
295  TBranch* branch = m_->tree_->GetBranch(edm::BranchTypeToAuxiliaryBranchName(edm::InEvent).c_str());
296 
297  branch->SetAddress(&pAux);
298  branch->GetEntry(iEntry);
299 
300  //NEW m_->processNames_ = aux.processHistory();
301 
302  // std::cout << "ProcessNames\n";
303  // for(auto const& name : m_->processNames_) {
304  // std::cout << " " << name << std::endl;
305  // }
306 
307  edm::EventSelectionIDVector eventSelectionIDs;
308  edm::EventSelectionIDVector* pEventSelectionIDVector = &eventSelectionIDs;
309  TBranch* eventSelectionsBranch = m_->tree_->GetBranch(edm::poolNames::eventSelectionsBranchName().c_str());
310  if (!eventSelectionsBranch) {
311  throw edm::Exception(edm::errors::FatalRootError) << "Failed to find event Selections branch in event tree";
312  }
313  eventSelectionsBranch->SetAddress(&pEventSelectionIDVector);
314  eventSelectionsBranch->GetEntry(iEntry);
315 
316  edm::BranchListIndexes branchListIndexes;
317  edm::BranchListIndexes* pBranchListIndexes = &branchListIndexes;
318  TBranch* branchListIndexBranch = m_->tree_->GetBranch(edm::poolNames::branchListIndexesBranchName().c_str());
319  if (!branchListIndexBranch) {
320  throw edm::Exception(edm::errors::FatalRootError) << "Failed to find branch list index branch in event tree";
321  }
322  branchListIndexBranch->SetAddress(&pBranchListIndexes);
323  branchListIndexBranch->GetEntry(iEntry);
324  m_->branchIDListHelper_->fixBranchListIndexes(branchListIndexes);
325 
326  try {
327  m_->reader_->setEntry(iEntry);
328  auto runAux = std::make_shared<edm::RunAuxiliary>(aux.run(), aux.time(), aux.time());
329  auto rp = std::make_shared<edm::RunPrincipal>(runAux, m_->reg(), m_->pc_, nullptr, 0);
330  auto lbp = std::make_shared<edm::LuminosityBlockPrincipal>(m_->reg(), m_->pc_, nullptr, 0);
331  lbp->setAux(edm::LuminosityBlockAuxiliary(rp->run(), 1, aux.time(), aux.time()));
332  m_->ep_->fillEventPrincipal(*eaux,
333  *m_->phreg_,
334  std::move(eventSelectionIDs),
335  std::move(branchListIndexes),
336  *(m_->provRetriever_),
337  m_->reader_.get());
338  lbp->setRunPrincipal(rp);
339  m_->ep_->setLuminosityBlockPrincipal(lbp.get());
340  m_->processNames_ = m_->ep_->processHistory();
341 
342  edm::Event event(*m_->ep_, m_->md_, nullptr);
343 
344  //Make the event principal accessible to edm::Ref's
345  Operate sentry(m_->ep_->prodGetter());
346  process(event);
347  } catch (std::exception const& iEx) {
348  std::cout << "While processing entry " << iEntry << " the following exception was caught \n"
349  << iEx.what() << std::endl;
350  } catch (...) {
351  std::cout << "While processing entry " << iEntry << " an unknown exception was caught" << std::endl;
352  }
353  }
354  return everythingOK_ ? kTRUE : kFALSE;
355 }
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
Definition: BranchType.cc:116
edm::propagate_const< std::shared_ptr< edm::root::TFWLiteSelectorMembers > > m_
std::string const & eventSelectionsBranchName()
Definition: BranchType.cc:249
virtual void process(const edm::Event &event)=0
std::vector< EventSelectionID > EventSelectionIDVector
std::vector< BranchListIndex > BranchListIndexes
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
element_type const * get() const
std::string const & branchListIndexesBranchName()
Definition: BranchType.cc:253
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1
void TFWLiteSelectorBasic::setupNewFile ( TFile &  iFile)
private

Definition at line 361 of file TFWLiteSelectorBasic.cc.

References edm::poolNames::branchIDListBranchName(), edm::BranchDescription::branchName(), edm::BranchDescription::branchType(), edm::BranchDescription::className(), gather_cfg::cout, mps_splice::entry, everythingOK_, Exception, edm::poolNames::fileFormatVersionBranchName(), edm::errors::FileReadError, edm::BranchDescription::friendlyClassName(), edm::friendlyname::friendlyName(), mps_fire::i, edm::poolNames::idToParameterSetBlobsBranchName(), edm::InEvent, edm::BranchDescription::init(), edm::pset::Registry::insertMapped(), edm::pset::Registry::instance(), m_, edm::poolNames::metaDataTreeName(), AlCaHLTBitMon_ParallelJobs::p, edm::poolNames::parameterSetMapBranchName(), edm::poolNames::parameterSetsTreeName(), edm::poolNames::processConfigurationBranchName(), edm::poolNames::processHistoryBranchName(), parseEventContent::prod, edm::poolNames::productDescriptionBranchName(), muonDTDigis_cfi::pset, edm::BranchDescription::setDropped(), edm::setIsMergeable(), AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::temp, edm::errors::UnimplementedFeature, and edm::BranchDescription::updateFriendlyClassName().

Referenced by Notify().

361  {
362  //look up meta-data
363  //get product registry
364 
365  //std::vector<edm::EventProcessHistoryID> eventProcessHistoryIDs_;
366  TTree* metaDataTree = dynamic_cast<TTree*>(iFile.Get(edm::poolNames::metaDataTreeName().c_str()));
367  if (!metaDataTree) {
368  std::cout << "could not find TTree " << edm::poolNames::metaDataTreeName() << std::endl;
369  everythingOK_ = false;
370  return;
371  }
372  edm::FileFormatVersion* fftPtr = &(m_->fileFormatVersion_);
373  if (metaDataTree->FindBranch(edm::poolNames::fileFormatVersionBranchName().c_str()) != nullptr) {
374  metaDataTree->SetBranchAddress(edm::poolNames::fileFormatVersionBranchName().c_str(), &fftPtr);
375  }
376 
377  edm::ProductRegistry* pReg = &(*m_->reg_);
378  metaDataTree->SetBranchAddress(edm::poolNames::productDescriptionBranchName().c_str(), &(pReg));
379 
380  typedef std::map<edm::ParameterSetID, edm::ParameterSetBlob> PsetMap;
381  PsetMap psetMap;
382  PsetMap* psetMapPtr = &psetMap;
383  if (metaDataTree->FindBranch(edm::poolNames::parameterSetMapBranchName().c_str()) != nullptr) {
384  metaDataTree->SetBranchAddress(edm::poolNames::parameterSetMapBranchName().c_str(), &psetMapPtr);
385  } else {
386  TTree* psetTree = dynamic_cast<TTree*>(iFile.Get(edm::poolNames::parameterSetsTreeName().c_str()));
387  if (nullptr == psetTree) {
389  << "Could not find tree " << edm::poolNames::parameterSetsTreeName() << " in the input file.\n";
390  }
391  typedef std::pair<edm::ParameterSetID, edm::ParameterSetBlob> IdToBlobs;
392  IdToBlobs idToBlob;
393  IdToBlobs* pIdToBlob = &idToBlob;
394  psetTree->SetBranchAddress(edm::poolNames::idToParameterSetBlobsBranchName().c_str(), &pIdToBlob);
395  for (long long i = 0; i != psetTree->GetEntries(); ++i) {
396  psetTree->GetEntry(i);
397  psetMap.insert(idToBlob);
398  }
399  }
400 
402  edm::ProcessHistoryRegistry::vector_type* pHistVectorPtr = &pHistVector;
403  if (metaDataTree->FindBranch(edm::poolNames::processHistoryBranchName().c_str()) != nullptr) {
404  metaDataTree->SetBranchAddress(edm::poolNames::processHistoryBranchName().c_str(), &pHistVectorPtr);
405  }
406 
407  edm::ProcessConfigurationVector procConfigVector;
408  edm::ProcessConfigurationVector* procConfigVectorPtr = &procConfigVector;
409  if (metaDataTree->FindBranch(edm::poolNames::processConfigurationBranchName().c_str()) != nullptr) {
410  metaDataTree->SetBranchAddress(edm::poolNames::processConfigurationBranchName().c_str(), &procConfigVectorPtr);
411  }
412 
413  auto branchIDListsHelper = std::make_shared<edm::BranchIDListHelper>();
414  edm::BranchIDLists const* branchIDListsPtr = &branchIDListsHelper->branchIDLists();
415  if (metaDataTree->FindBranch(edm::poolNames::branchIDListBranchName().c_str()) != nullptr) {
416  metaDataTree->SetBranchAddress(edm::poolNames::branchIDListBranchName().c_str(), &branchIDListsPtr);
417  }
418 
419  metaDataTree->GetEntry(0);
420 
421  for (auto& prod : m_->reg_->productListUpdator()) {
422  prod.second.init();
423  setIsMergeable(prod.second);
424  }
425 
426  // Merge into the registries. For now, we do NOT merge the product registry.
428  for (auto const& entry : psetMap) {
429  edm::ParameterSet pset(entry.second.pset());
430  pset.setID(entry.first);
431  psetRegistry.insertMapped(pset);
432  }
433 
434  for (auto const& ph : pHistVector) {
435  m_->phreg_->registerProcessHistory(ph);
436  }
437 
438  m_->pointerToBranchBuffer_.erase(m_->pointerToBranchBuffer_.begin(), m_->pointerToBranchBuffer_.end());
439 
440  std::unique_ptr<edm::ProductRegistry> newReg = std::make_unique<edm::ProductRegistry>();
441 
442  edm::ProductRegistry::ProductList& prodList = m_->reg_->productListUpdator();
443  {
444  for (auto& item : prodList) {
445  edm::BranchDescription& prod = item.second;
446  //std::cout << "productname = " << item.second << " end " << std::endl;
447  std::string newFriendlyName = edm::friendlyname::friendlyName(prod.className());
448  if (newFriendlyName == prod.friendlyClassName()) {
449  newReg->copyProduct(prod);
450  } else {
451  if (m_->fileFormatVersion_.splitProductIDs()) {
453  << "Cannot change friendly class name algorithm without more development work\n"
454  << "to update BranchIDLists. Contact the framework group.\n";
455  }
456  edm::BranchDescription newBD(prod);
457  newBD.updateFriendlyClassName();
458  newReg->copyProduct(newBD);
459  }
460  prod.init();
461  }
462 
463  m_->reg().reset(newReg.release());
464  }
465 
466  edm::ProductRegistry::ProductList& prodList2 = m_->reg_->productListUpdator();
467  std::vector<edm::EventEntryDescription> temp(prodList2.size(), edm::EventEntryDescription());
468  m_->prov_.swap(temp);
469  m_->pointerToBranchBuffer_.reserve(prodList2.size());
470 
471  for (auto& item : prodList2) {
472  edm::BranchDescription& prod = item.second;
473  if (prod.branchType() == edm::InEvent) {
474  prod.init();
475  //NEED to do this and check to see if branch exists
476  if (m_->tree_->GetBranch(prod.branchName().c_str()) == nullptr) {
477  prod.setDropped(true);
478  }
479 
480  //std::cout << "id " << it->first << " branch " << it->second << std::endl;
481  //m_->pointerToBranchBuffer_.push_back(&(*itB));
482  //void* tmp = &(m_->pointerToBranchBuffer_.back());
483  //edm::EventEntryDescription* tmp = &(*itB);
484  //CDJ need to fix provenance and be backwards compatible, for now just don't read the branch
485  //m_->metaTree_->SetBranchAddress(prod.branchName().c_str(), tmp);
486  }
487  }
488  m_->branchIDListHelper_->updateFromInput(*branchIDListsPtr);
489  m_->reg_->setFrozen();
490  m_->bidToDesc_->clear();
491  for (auto const& p : m_->reg_->productList()) {
492  m_->bidToDesc_->emplace(p.second.branchID().id(), &p.second);
493  }
494  m_->ep_ = std::make_shared<edm::EventPrincipal>(
495  m_->reg(), m_->branchIDListHelper(), m_->thinnedAssociationsHelper(), m_->pc_, nullptr);
496  everythingOK_ = true;
497 }
std::string const & idToParameterSetBlobsBranchName()
Definition: BranchType.cc:261
std::vector< ProcessConfiguration > ProcessConfigurationVector
std::string const & branchName() const
BranchType const & branchType() const
std::vector< BranchIDList > BranchIDLists
Definition: BranchIDList.h:19
edm::propagate_const< std::shared_ptr< edm::root::TFWLiteSelectorMembers > > m_
std::map< BranchKey, BranchDescription > ProductList
std::string const & fileFormatVersionBranchName()
Definition: BranchType.cc:219
std::string const & parameterSetsTreeName()
Definition: BranchType.cc:257
std::string const & className() const
std::string friendlyName(std::string const &iFullName)
std::string const & friendlyClassName() const
void setDropped(bool isDropped)
bool insertMapped(value_type const &v, bool forceUpdate=false)
Definition: Registry.cc:32
std::string const & metaDataTreeName()
Definition: BranchType.cc:169
std::string const & parameterSetMapBranchName()
Definition: BranchType.cc:184
std::string const & processHistoryBranchName()
Definition: BranchType.cc:199
std::string const & productDescriptionBranchName()
Definition: BranchType.cc:174
std::string const & processConfigurationBranchName()
Definition: BranchType.cc:204
std::string const & branchIDListBranchName()
Definition: BranchType.cc:209
void setIsMergeable(BranchDescription &)
static Registry * instance()
Definition: Registry.cc:12
void TFWLiteSelectorBasic::SlaveBegin ( TTree *  iTree)
overrideprivate

Definition at line 241 of file TFWLiteSelectorBasic.cc.

References Init(), and preProcessing().

241  {
242  Init(iTree);
243  preProcessing(fInput, *fOutput);
244 }
virtual void preProcessing(const TList *in, TList &out)=0
void Init(TTree *) override
void TFWLiteSelectorBasic::SlaveTerminate ( )
overrideprivate

Definition at line 357 of file TFWLiteSelectorBasic.cc.

References postProcessing().

357 { postProcessing(*fOutput); }
virtual void postProcessing(TList &out)=0
virtual void TFWLiteSelectorBasic::terminate ( TList &  out)
pure virtual

Called each time the 'client' has finished processing.

Parameters
outcontains the accumulated output of all slaves.

Implemented in __class__< T >, tfwliteselectortest::ThingsTSelector2, examples::TrackTSelector, and tfwliteselectortest::ThingsTSelector.

Referenced by Terminate().

void TFWLiteSelectorBasic::Terminate ( )
overrideprivate

Definition at line 359 of file TFWLiteSelectorBasic.cc.

References terminate().

359 { terminate(*fOutput); }
virtual void terminate(TList &out)=0
Int_t TFWLiteSelectorBasic::Version ( ) const
inlineoverrideprivate

Definition at line 94 of file TFWLiteSelectorBasic.h.

94 { return 1; }

Member Data Documentation

bool TFWLiteSelectorBasic::everythingOK_
private

Definition at line 99 of file TFWLiteSelectorBasic.h.

Referenced by Notify(), Process(), and setupNewFile().

edm::propagate_const<std::shared_ptr<edm::root::TFWLiteSelectorMembers> > TFWLiteSelectorBasic::m_
private

Definition at line 98 of file TFWLiteSelectorBasic.h.

Referenced by Init(), Notify(), Process(), and setupNewFile().