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 207 of file TFWLiteSelectorBasic.cc.

208  everythingOK_(false) {
209 }
edm::propagate_const< std::shared_ptr< edm::root::TFWLiteSelectorMembers > > m_
TFWLiteSelectorBasic::~TFWLiteSelectorBasic ( )
override

Definition at line 216 of file TFWLiteSelectorBasic.cc.

216  {
217 }
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 235 of file TFWLiteSelectorBasic.cc.

References begin(), and Init().

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

Definition at line 247 of file TFWLiteSelectorBasic.cc.

References m_.

Referenced by Begin(), and SlaveBegin().

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

Definition at line 254 of file TFWLiteSelectorBasic.cc.

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

254  {
255  //std::cout << "Notify start" << std::endl;
256  //we have switched to a new file
257  //get new file from Tree
258  if(nullptr == m_->tree_) {
259  std::cout << "No tree" << std::endl;
260  return kFALSE;
261  }
262  TFile* file = m_->tree_->GetCurrentFile();
263  if(nullptr == file) {
264  //When in Rome, do as the Romans
265  TChain* chain = dynamic_cast<TChain*>(m_->tree());
266  if(nullptr == chain) {
267  std::cout << "No file" << std::endl;
268  return kFALSE;
269  }
270  file = chain->GetFile();
271  if(nullptr == file) {
272  std::cout << "No file" << std::endl;
273  return kFALSE;
274  }
275  }
276  setupNewFile(*file);
277  return everythingOK_ ? kTRUE: kFALSE;
278 }
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 292 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().

292  {
293  //std::cout << "Process start" << std::endl;
294  if(everythingOK_) {
295  std::unique_ptr<edm::EventAuxiliary> eaux = std::make_unique<edm::EventAuxiliary>();
296  edm::EventAuxiliary& aux = *eaux;
297  edm::EventAuxiliary* pAux= eaux.get();
298  TBranch* branch = m_->tree_->GetBranch(edm::BranchTypeToAuxiliaryBranchName(edm::InEvent).c_str());
299 
300  branch->SetAddress(&pAux);
301  branch->GetEntry(iEntry);
302 
303 //NEW m_->processNames_ = aux.processHistory();
304 
305 // std::cout << "ProcessNames\n";
306 // for(auto const& name : m_->processNames_) {
307 // std::cout << " " << name << std::endl;
308 // }
309 
310  edm::EventSelectionIDVector eventSelectionIDs;
311  edm::EventSelectionIDVector* pEventSelectionIDVector = &eventSelectionIDs;
312  TBranch* eventSelectionsBranch = m_->tree_->GetBranch(edm::poolNames::eventSelectionsBranchName().c_str());
313  if(!eventSelectionsBranch) {
315  << "Failed to find event Selections branch in event tree";
316  }
317  eventSelectionsBranch->SetAddress(&pEventSelectionIDVector);
318  eventSelectionsBranch->GetEntry(iEntry);
319 
320  edm::BranchListIndexes branchListIndexes;
321  edm::BranchListIndexes* pBranchListIndexes = &branchListIndexes;
322  TBranch* branchListIndexBranch = m_->tree_->GetBranch(edm::poolNames::branchListIndexesBranchName().c_str());
323  if(!branchListIndexBranch) {
325  << "Failed to find branch list index branch in event tree";
326  }
327  branchListIndexBranch->SetAddress(&pBranchListIndexes);
328  branchListIndexBranch->GetEntry(iEntry);
329  m_->branchIDListHelper_->fixBranchListIndexes(branchListIndexes);
330 
331  try {
332  m_->reader_->setEntry(iEntry);
333  auto runAux = std::make_shared<edm::RunAuxiliary>(aux.run(), aux.time(), aux.time());
334  auto rp = std::make_shared<edm::RunPrincipal>(runAux, m_->reg(), m_->pc_, nullptr, 0);
335  auto lbp = std::make_shared<edm::LuminosityBlockPrincipal>(m_->reg(), m_->pc_, nullptr, 0);
336  lbp->setAux(edm::LuminosityBlockAuxiliary(rp->run(), 1, aux.time(), aux.time()));
337  m_->ep_->fillEventPrincipal(*eaux,
338  *m_->phreg_,
339  std::move(eventSelectionIDs),
340  std::move(branchListIndexes),
341  *(m_->provRetriever_),
342  m_->reader_.get());
343  lbp->setRunPrincipal(rp);
344  m_->ep_->setLuminosityBlockPrincipal(lbp.get());
345  m_->processNames_ = m_->ep_->processHistory();
346 
347  edm::Event event(*m_->ep_, m_->md_, nullptr);
348 
349  //Make the event principal accessible to edm::Ref's
350  Operate sentry(m_->ep_->prodGetter());
351  process(event);
352  } catch(std::exception const& iEx) {
353  std::cout << "While processing entry " << iEntry << " the following exception was caught \n"
354  << iEx.what() << std::endl;
355  } catch(...) {
356  std::cout << "While processing entry " << iEntry << " an unknown exception was caught" << std::endl;
357  }
358  }
359  return everythingOK_ ? kTRUE: kFALSE;
360 }
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 373 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().

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

References postProcessing().

363  {
364  postProcessing(*fOutput);
365 }
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 368 of file TFWLiteSelectorBasic.cc.

References terminate().

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

Definition at line 96 of file TFWLiteSelectorBasic.h.

96 { return 1; }

Member Data Documentation

bool TFWLiteSelectorBasic::everythingOK_
private

Definition at line 101 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 100 of file TFWLiteSelectorBasic.h.

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