test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
virtual ~TFWLiteSelectorBasic ()
 

Private Member Functions

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

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

197  everythingOK_(false) {
198 }
edm::propagate_const< std::shared_ptr< edm::root::TFWLiteSelectorMembers > > m_
TFWLiteSelectorBasic::~TFWLiteSelectorBasic ( )
virtual

Definition at line 205 of file TFWLiteSelectorBasic.cc.

205  {
206 }
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)
privatevirtual

Definition at line 224 of file TFWLiteSelectorBasic.cc.

References begin(), and Init().

224  {
225  Init(iTree);
226  begin(fInput);
227 }
virtual void Init(TTree *)
virtual void begin(TList *&in)=0
void TFWLiteSelectorBasic::Init ( TTree *  iTree)
privatevirtual

Definition at line 236 of file TFWLiteSelectorBasic.cc.

References m_.

Referenced by Begin(), and SlaveBegin().

236  {
237  if(iTree == nullptr) return;
238  m_->setTree(iTree);
239 }
edm::propagate_const< std::shared_ptr< edm::root::TFWLiteSelectorMembers > > m_
Bool_t TFWLiteSelectorBasic::Notify ( )
privatevirtual

Definition at line 243 of file TFWLiteSelectorBasic.cc.

References gather_cfg::cout, everythingOK_, mergeVDriftHistosByStation::file, m_, and setupNewFile().

243  {
244  //std::cout << "Notify start" << std::endl;
245  //we have switched to a new file
246  //get new file from Tree
247  if(nullptr == m_->tree_) {
248  std::cout << "No tree" << std::endl;
249  return kFALSE;
250  }
251  TFile* file = m_->tree_->GetCurrentFile();
252  if(nullptr == file) {
253  //When in Rome, do as the Romans
254  TChain* chain = dynamic_cast<TChain*>(m_->tree());
255  if(nullptr == chain) {
256  std::cout << "No file" << std::endl;
257  return kFALSE;
258  }
259  file = chain->GetFile();
260  if(nullptr == file) {
261  std::cout << "No file" << std::endl;
262  return kFALSE;
263  }
264  }
265  setupNewFile(*file);
266  return everythingOK_ ? kTRUE: kFALSE;
267 }
edm::propagate_const< std::shared_ptr< edm::root::TFWLiteSelectorMembers > > m_
tuple cout
Definition: gather_cfg.py:145
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
Bool_t TFWLiteSelectorBasic::Process ( Long64_t  iEntry)
privatevirtual

Definition at line 281 of file TFWLiteSelectorBasic.cc.

References printConversionInfo::aux, 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().

281  {
282  //std::cout << "Process start" << std::endl;
283  if(everythingOK_) {
284  std::unique_ptr<edm::EventAuxiliary> eaux = std::make_unique<edm::EventAuxiliary>();
285  edm::EventAuxiliary& aux = *eaux;
286  edm::EventAuxiliary* pAux= eaux.get();
287  TBranch* branch = m_->tree_->GetBranch(edm::BranchTypeToAuxiliaryBranchName(edm::InEvent).c_str());
288 
289  branch->SetAddress(&pAux);
290  branch->GetEntry(iEntry);
291 
292 //NEW m_->processNames_ = aux.processHistory();
293 
294 // std::cout << "ProcessNames\n";
295 // for(auto const& name : m_->processNames_) {
296 // std::cout << " " << name << std::endl;
297 // }
298 
299  edm::EventSelectionIDVector eventSelectionIDs;
300  edm::EventSelectionIDVector* pEventSelectionIDVector = &eventSelectionIDs;
301  TBranch* eventSelectionsBranch = m_->tree_->GetBranch(edm::poolNames::eventSelectionsBranchName().c_str());
302  if(!eventSelectionsBranch) {
304  << "Failed to find event Selections branch in event tree";
305  }
306  eventSelectionsBranch->SetAddress(&pEventSelectionIDVector);
307  eventSelectionsBranch->GetEntry(iEntry);
308 
309  edm::BranchListIndexes branchListIndexes;
310  edm::BranchListIndexes* pBranchListIndexes = &branchListIndexes;
311  TBranch* branchListIndexBranch = m_->tree_->GetBranch(edm::poolNames::branchListIndexesBranchName().c_str());
312  if(!branchListIndexBranch) {
314  << "Failed to find branch list index branch in event tree";
315  }
316  branchListIndexBranch->SetAddress(&pBranchListIndexes);
317  branchListIndexBranch->GetEntry(iEntry);
318  m_->branchIDListHelper_->fixBranchListIndexes(branchListIndexes);
319 
320  try {
321  m_->reader_->setEntry(iEntry);
322  auto runAux = std::make_shared<edm::RunAuxiliary>(aux.run(), aux.time(), aux.time());
323  auto rp = std::make_shared<edm::RunPrincipal>(runAux, m_->reg(), m_->pc_, nullptr, 0);
324  auto lumiAux = std::make_shared<edm::LuminosityBlockAuxiliary>(rp->run(), 1, aux.time(), aux.time());
325  auto lbp = std::make_shared<edm::LuminosityBlockPrincipal>(lumiAux, m_->reg(), m_->pc_, nullptr, 0);
326  m_->ep_->fillEventPrincipal(*eaux,
327  *m_->phreg_,
328  std::move(eventSelectionIDs),
329  std::move(branchListIndexes),
330  *(m_->provRetriever_),
331  m_->reader_.get());
332  lbp->setRunPrincipal(rp);
333  m_->ep_->setLuminosityBlockPrincipal(lbp);
334  m_->processNames_ = m_->ep_->processHistory();
335 
336  edm::Event event(*m_->ep_, m_->md_, nullptr);
337 
338  //Make the event principal accessible to edm::Ref's
339  Operate sentry(m_->ep_->prodGetter());
340  process(event);
341  } catch(std::exception const& iEx) {
342  std::cout << "While processing entry " << iEntry << " the following exception was caught \n"
343  << iEx.what() << std::endl;
344  } catch(...) {
345  std::cout << "While processing entry " << iEntry << " an unknown exception was caught" << std::endl;
346  }
347  }
348  return everythingOK_ ? kTRUE: kFALSE;
349 }
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
Definition: BranchType.cc:115
edm::propagate_const< std::shared_ptr< edm::root::TFWLiteSelectorMembers > > m_
std::string const & eventSelectionsBranchName()
Definition: BranchType.cc:243
virtual void process(const edm::Event &event)=0
std::vector< EventSelectionID > EventSelectionIDVector
std::vector< BranchListIndex > BranchListIndexes
def move
Definition: eostools.py:510
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
tuple cout
Definition: gather_cfg.py:145
std::string const & branchListIndexesBranchName()
Definition: BranchType.cc:247
void TFWLiteSelectorBasic::setupNewFile ( TFile &  iFile)
private

Definition at line 362 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(), i, edm::poolNames::idToParameterSetBlobsBranchName(), edm::InEvent, edm::BranchDescription::init(), edm::pset::Registry::insertMapped(), edm::pset::Registry::instance(), m_, edm::poolNames::metaDataTreeName(), edm::poolNames::parameterSetMapBranchName(), edm::poolNames::parameterSetsTreeName(), edm::poolNames::processConfigurationBranchName(), edm::poolNames::processHistoryBranchName(), parseEventContent::prod, edm::poolNames::productDescriptionBranchName(), TrackValidation_cff::pset, edm::BranchDescription::setDropped(), AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::temp, edm::errors::UnimplementedFeature, and edm::BranchDescription::updateFriendlyClassName().

Referenced by Notify().

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

Definition at line 230 of file TFWLiteSelectorBasic.cc.

References Init(), and preProcessing().

230  {
231  Init(iTree);
232  preProcessing(fInput, *fOutput);
233 }
virtual void preProcessing(const TList *in, TList &out)=0
virtual void Init(TTree *)
void TFWLiteSelectorBasic::SlaveTerminate ( )
privatevirtual

Definition at line 352 of file TFWLiteSelectorBasic.cc.

References postProcessing().

352  {
353  postProcessing(*fOutput);
354 }
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 ( )
privatevirtual

Definition at line 357 of file TFWLiteSelectorBasic.cc.

References terminate().

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

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().