#include <FWCore/FWLite/interface/TFWLiteSelectorBasic.h>
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 TFWLiteSelectorBasic & | operator= (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_ |
boost::shared_ptr < edm::root::TFWLiteSelectorMembers > | m_ |
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 41 of file TFWLiteSelectorBasic.h.
TFWLiteSelectorBasic::TFWLiteSelectorBasic | ( | ) |
Definition at line 154 of file TFWLiteSelectorBasic.cc.
: m_(new edm::root::TFWLiteSelectorMembers), everythingOK_(false) { }
TFWLiteSelectorBasic::~TFWLiteSelectorBasic | ( | ) | [virtual] |
Definition at line 163 of file TFWLiteSelectorBasic.cc.
{ }
TFWLiteSelectorBasic::TFWLiteSelectorBasic | ( | const TFWLiteSelectorBasic & | ) | [private] |
virtual void TFWLiteSelectorBasic::begin | ( | TList *& | in | ) | [pure virtual] |
Called each time the 'client' begins processing (remote 'slaves' do not see this message)
in | an 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 tselname, tfwliteselectortest::ThingsTSelector, tfwliteselectortest::ThingsTSelector2, and examples::TrackTSelector.
Referenced by Begin().
void TFWLiteSelectorBasic::Begin | ( | TTree * | iTree | ) | [private, virtual] |
void TFWLiteSelectorBasic::Init | ( | TTree * | iTree | ) | [private, virtual] |
Definition at line 194 of file TFWLiteSelectorBasic.cc.
References m_.
Referenced by Begin(), and SlaveBegin().
{ if(iTree == 0) return; m_->setTree(iTree); }
Bool_t TFWLiteSelectorBasic::Notify | ( | ) | [private, virtual] |
Definition at line 201 of file TFWLiteSelectorBasic.cc.
References gather_cfg::cout, everythingOK_, mergeVDriftHistosByStation::file, m_, and setupNewFile().
{ //std::cout << "Notify start" << std::endl; //we have switched to a new file //get new file from Tree if(0 == m_->tree_) { std::cout << "No tree" << std::endl; return kFALSE; } TFile* file = m_->tree_->GetCurrentFile(); if(0 == file) { //When in Rome, do as the Romans TChain* chain = dynamic_cast<TChain*>(m_->tree_); if(0 == chain) { std::cout << "No file" << std::endl; return kFALSE; } file = chain->GetFile(); if(0 == file) { std::cout << "No file" << std::endl; return kFALSE; } } setupNewFile(*file); return everythingOK_ ? kTRUE: kFALSE; }
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
out | the 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 >, tfwliteselectortest::ThingsTSelector, TFWLiteSelector< tselnameWorker >, TFWLiteSelector< ThingsWorker >, and TFWLiteSelector< TrackAnalysisAlgorithm >.
Referenced by SlaveTerminate().
virtual void TFWLiteSelectorBasic::preProcessing | ( | const TList * | in, |
TList & | out | ||
) | [pure virtual] |
Called each time the 'slave' is about to start processing
in | a pointer to the list of objects created in 'begin()'. The pointer can be 0 |
out | a 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 >, tfwliteselectortest::ThingsTSelector, TFWLiteSelector< tselnameWorker >, TFWLiteSelector< ThingsWorker >, and TFWLiteSelector< TrackAnalysisAlgorithm >.
Referenced by SlaveBegin().
Bool_t TFWLiteSelectorBasic::Process | ( | Long64_t | iEntry | ) | [private, virtual] |
Definition at line 239 of file TFWLiteSelectorBasic.cc.
References printConversionInfo::aux, edm::poolNames::branchListIndexesBranchName(), edm::BranchTypeToAuxiliaryBranchName(), gather_cfg::cout, event(), edm::poolNames::eventSelectionsBranchName(), everythingOK_, exception, Exception, edm::errors::FatalRootError, edm::BranchIDListHelper::fixBranchListIndexes(), edm::InEvent, m_, process(), edm::EventAuxiliary::run(), and edm::EventAuxiliary::time().
{ //std::cout << "Process start" << std::endl; if(everythingOK_) { std::auto_ptr<edm::EventAuxiliary> eaux(new edm::EventAuxiliary()); edm::EventAuxiliary& aux = *eaux; edm::EventAuxiliary* pAux= eaux.get(); TBranch* branch = m_->tree_->GetBranch(edm::BranchTypeToAuxiliaryBranchName(edm::InEvent).c_str()); branch->SetAddress(&pAux); branch->GetEntry(iEntry); //NEW m_->processNames_ = aux.processHistory(); // std::cout << "ProcessNames\n"; // for(edm::ProcessNameList::const_iterator itName = m_->processNames_.begin(), // itNameEnd = m_->processNames_.end(); // itName != itNameEnd; // ++itName) { // std::cout << " " << *itName << std::endl; // } boost::shared_ptr<edm::EventSelectionIDVector> eventSelectionIDs_(new edm::EventSelectionIDVector); edm::EventSelectionIDVector* pEventSelectionIDVector = eventSelectionIDs_.get(); TBranch* eventSelectionsBranch = m_->tree_->GetBranch(edm::poolNames::eventSelectionsBranchName().c_str()); if(!eventSelectionsBranch) { throw edm::Exception(edm::errors::FatalRootError) << "Failed to find event Selections branch in event tree"; } eventSelectionsBranch->SetAddress(&pEventSelectionIDVector); eventSelectionsBranch->GetEntry(iEntry); boost::shared_ptr<edm::BranchListIndexes> branchListIndexes_(new edm::BranchListIndexes); edm::BranchListIndexes* pBranchListIndexes = branchListIndexes_.get(); TBranch* branchListIndexBranch = m_->tree_->GetBranch(edm::poolNames::branchListIndexesBranchName().c_str()); if(!branchListIndexBranch) { throw edm::Exception(edm::errors::FatalRootError) << "Failed to find branch list index branch in event tree"; } branchListIndexBranch->SetAddress(&pBranchListIndexes); branchListIndexBranch->GetEntry(iEntry); edm::BranchIDListHelper::fixBranchListIndexes(*branchListIndexes_); try { m_->reader_->setEntry(iEntry); boost::shared_ptr<edm::RunAuxiliary> runAux(new edm::RunAuxiliary(aux.run(), aux.time(), aux.time())); boost::shared_ptr<edm::RunPrincipal> rp(new edm::RunPrincipal(runAux, m_->reg_, m_->pc_)); boost::shared_ptr<edm::LuminosityBlockAuxiliary> lumiAux( new edm::LuminosityBlockAuxiliary(rp->run(), 1, aux.time(), aux.time())); boost::shared_ptr<edm::LuminosityBlockPrincipal>lbp( new edm::LuminosityBlockPrincipal(lumiAux, m_->reg_, m_->pc_, rp)); m_->ep_->fillEventPrincipal(*eaux, lbp, eventSelectionIDs_, branchListIndexes_, m_->mapper_, m_->reader_.get()); m_->processNames_ = m_->ep_->processHistory(); edm::Event event(*m_->ep_, m_->md_); //Make the event principal accessible to edm::Ref's Operate sentry(m_->ep_->prodGetter()); process(event); } catch(std::exception const& iEx) { std::cout << "While processing entry " << iEntry << " the following exception was caught \n" << iEx.what() << std::endl; } catch(...) { std::cout << "While processing entry " << iEntry << " an unknown exception was caught" << std::endl; } } return everythingOK_ ? kTRUE: kFALSE; }
virtual void TFWLiteSelectorBasic::process | ( | const edm::Event & | event | ) | [pure virtual] |
Call each time the 'slave' gets a new Event
event | a standard edm::Event which works just like it does in cmsRun |
Implemented in TFWLiteSelector< TWorker >, tfwliteselectortest::ThingsTSelector, TFWLiteSelector< tselnameWorker >, TFWLiteSelector< ThingsWorker >, and TFWLiteSelector< TrackAnalysisAlgorithm >.
Referenced by Process().
void TFWLiteSelectorBasic::setupNewFile | ( | TFile & | iFile | ) | [private] |
Definition at line 318 of file TFWLiteSelectorBasic.cc.
References edm::poolNames::branchIDListBranchName(), edm::BranchDescription::branchName(), edm::BranchDescription::branchType(), edm::BranchDescription::className(), gather_cfg::cout, everythingOK_, Exception, edm::poolNames::fileFormatVersionBranchName(), edm::errors::FileReadError, edm::fillProductRegistryTransients(), edm::BranchDescription::friendlyClassName(), edm::friendlyname::friendlyName(), i, edm::poolNames::idToParameterSetBlobsBranchName(), edm::InEvent, edm::BranchDescription::init(), edm::detail::ThreadSafeRegistry< KEY, T, E >::insertMapped(), instance, m_, edm::poolNames::metaDataTreeName(), edm::poolNames::parameterSetMapBranchName(), edm::poolNames::parameterSetsTreeName(), edm::poolNames::processConfigurationBranchName(), edm::poolNames::processHistoryBranchName(), parseEventContent::prod, edm::poolNames::productDescriptionBranchName(), edm::BranchDescription::setDropped(), edm::ParameterSet::setID(), groupFilesInBlocks::temp, edm::errors::UnimplementedFeature, edm::BranchDescription::updateFriendlyClassName(), and edm::BranchIDListHelper::updateFromInput().
Referenced by Notify().
{ //look up meta-data //get product registry //std::vector<edm::EventProcessHistoryID> eventProcessHistoryIDs_; TTree* metaDataTree = dynamic_cast<TTree*>(iFile.Get(edm::poolNames::metaDataTreeName().c_str())); if(!metaDataTree) { std::cout << "could not find TTree " << edm::poolNames::metaDataTreeName() << std::endl; everythingOK_ = false; return; } edm::FileFormatVersion* fftPtr = &(m_->fileFormatVersion_); if(metaDataTree->FindBranch(edm::poolNames::fileFormatVersionBranchName().c_str()) != 0) { metaDataTree->SetBranchAddress(edm::poolNames::fileFormatVersionBranchName().c_str(), &fftPtr); } edm::ProductRegistry* pReg = &(*m_->reg_); metaDataTree->SetBranchAddress(edm::poolNames::productDescriptionBranchName().c_str(), &(pReg)); m_->reg_->setFrozen(); typedef std::map<edm::ParameterSetID, edm::ParameterSetBlob> PsetMap; PsetMap psetMap; PsetMap *psetMapPtr = &psetMap; if(metaDataTree->FindBranch(edm::poolNames::parameterSetMapBranchName().c_str()) != 0) { metaDataTree->SetBranchAddress(edm::poolNames::parameterSetMapBranchName().c_str(), &psetMapPtr); } else { TTree* psetTree = dynamic_cast<TTree *>(iFile.Get(edm::poolNames::parameterSetsTreeName().c_str())); if(0 == psetTree) { throw edm::Exception(edm::errors::FileReadError) << "Could not find tree " << edm::poolNames::parameterSetsTreeName() << " in the input file.\n"; } typedef std::pair<edm::ParameterSetID, edm::ParameterSetBlob> IdToBlobs; IdToBlobs idToBlob; IdToBlobs* pIdToBlob = &idToBlob; psetTree->SetBranchAddress(edm::poolNames::idToParameterSetBlobsBranchName().c_str(), &pIdToBlob); for(long long i = 0; i != psetTree->GetEntries(); ++i) { psetTree->GetEntry(i); psetMap.insert(idToBlob); } } edm::ProcessHistoryRegistry::vector_type pHistVector; edm::ProcessHistoryRegistry::vector_type *pHistVectorPtr = &pHistVector; if(metaDataTree->FindBranch(edm::poolNames::processHistoryBranchName().c_str()) != 0) { metaDataTree->SetBranchAddress(edm::poolNames::processHistoryBranchName().c_str(), &pHistVectorPtr); } edm::ProcessConfigurationVector procConfigVector; edm::ProcessConfigurationVector* procConfigVectorPtr = &procConfigVector; if(metaDataTree->FindBranch(edm::poolNames::processConfigurationBranchName().c_str()) != 0) { metaDataTree->SetBranchAddress(edm::poolNames::processConfigurationBranchName().c_str(), &procConfigVectorPtr); } std::auto_ptr<edm::BranchIDListRegistry::collection_type> branchIDListsAPtr(new edm::BranchIDListRegistry::collection_type); edm::BranchIDListRegistry::collection_type *branchIDListsPtr = branchIDListsAPtr.get(); if(metaDataTree->FindBranch(edm::poolNames::branchIDListBranchName().c_str()) != 0) { metaDataTree->SetBranchAddress(edm::poolNames::branchIDListBranchName().c_str(), &branchIDListsPtr); } metaDataTree->GetEntry(0); // Merge into the registries. For now, we do NOT merge the product registry. edm::pset::Registry& psetRegistry = *edm::pset::Registry::instance(); for(PsetMap::const_iterator i = psetMap.begin(), iEnd = psetMap.end(); i != iEnd; ++i) { edm::ParameterSet pset(i->second.pset()); pset.setID(i->first); psetRegistry.insertMapped(pset); } edm::ProcessHistoryRegistry::instance()->insertCollection(pHistVector); edm::ProcessConfigurationRegistry::instance()->insertCollection(procConfigVector); m_->pointerToBranchBuffer_.erase(m_->pointerToBranchBuffer_.begin(), m_->pointerToBranchBuffer_.end()); fillProductRegistryTransients(procConfigVector, *m_->reg_); std::auto_ptr<edm::ProductRegistry> newReg(new edm::ProductRegistry()); edm::ProductRegistry::ProductList const& prodList = m_->reg_->productList(); { for(edm::ProductRegistry::ProductList::const_iterator it = prodList.begin(), itEnd = prodList.end(); it != itEnd; ++it) { edm::BranchDescription const& prod = it->second; //std::cout << "productname = " << it->second << " end " << std::endl; std::string newFriendlyName = edm::friendlyname::friendlyName(prod.className()); if(newFriendlyName == prod.friendlyClassName()) { newReg->copyProduct(prod); } else { if(m_->fileFormatVersion_.splitProductIDs()) { throw edm::Exception(edm::errors::UnimplementedFeature) << "Cannot change friendly class name algorithm without more development work\n" << "to update BranchIDLists. Contact the framework group.\n"; } edm::BranchDescription newBD(prod); newBD.updateFriendlyClassName(); newReg->copyProduct(newBD); // Need to call init to get old branch name. prod.init(); } } newReg->setFrozen(); m_->reg_.reset(newReg.release()); } edm::ProductRegistry::ProductList const& prodList2 = m_->reg_->productList(); std::vector<edm::EventEntryDescription> temp(prodList2.size(), edm::EventEntryDescription()); m_->prov_.swap(temp); std::vector<edm::EventEntryDescription>::iterator itB = m_->prov_.begin(); m_->pointerToBranchBuffer_.reserve(prodList2.size()); for(edm::ProductRegistry::ProductList::const_iterator it = prodList2.begin(), itEnd = prodList2.end(); it != itEnd; ++it, ++itB) { edm::BranchDescription const& prod = it->second; if(prod.branchType() == edm::InEvent) { prod.init(); //NEED to do this and check to see if branch exists if(m_->tree_->GetBranch(prod.branchName().c_str()) == 0) { prod.setDropped(); } //std::cout << "id " << it->first << " branch " << it->second << std::endl; //m_->pointerToBranchBuffer_.push_back(&(*itB)); //void* tmp = &(m_->pointerToBranchBuffer_.back()); //edm::EventEntryDescription* tmp = &(*itB); //CDJ need to fix provenance and be backwards compatible, for now just don't read the branch //m_->metaTree_->SetBranchAddress(prod.branchName().c_str(), tmp); } } edm::BranchIDListHelper::updateFromInput(*branchIDListsAPtr, ""); m_->ep_.reset(new edm::EventPrincipal(m_->reg_, m_->pc_)); everythingOK_ = true; }
void TFWLiteSelectorBasic::SlaveBegin | ( | TTree * | iTree | ) | [private, virtual] |
Definition at line 188 of file TFWLiteSelectorBasic.cc.
References Init(), and preProcessing().
{ Init(iTree); preProcessing(fInput, *fOutput); }
void TFWLiteSelectorBasic::SlaveTerminate | ( | ) | [private, virtual] |
Definition at line 308 of file TFWLiteSelectorBasic.cc.
References postProcessing().
{ postProcessing(*fOutput); }
void TFWLiteSelectorBasic::Terminate | ( | ) | [private, virtual] |
Definition at line 313 of file TFWLiteSelectorBasic.cc.
References terminate().
{ terminate(*fOutput); }
virtual void TFWLiteSelectorBasic::terminate | ( | TList & | out | ) | [pure virtual] |
Called each time the 'client' has finished processing.
out | contains the accumulated output of all slaves. |
Implemented in tselname, tfwliteselectortest::ThingsTSelector, tfwliteselectortest::ThingsTSelector2, and examples::TrackTSelector.
Referenced by Terminate().
virtual Int_t TFWLiteSelectorBasic::Version | ( | ) | const [inline, private, virtual] |
Definition at line 95 of file TFWLiteSelectorBasic.h.
{ return 1; }
bool TFWLiteSelectorBasic::everythingOK_ [private] |
Definition at line 100 of file TFWLiteSelectorBasic.h.
Referenced by Notify(), Process(), and setupNewFile().
boost::shared_ptr<edm::root::TFWLiteSelectorMembers> TFWLiteSelectorBasic::m_ [private] |
Definition at line 99 of file TFWLiteSelectorBasic.h.
Referenced by Init(), Notify(), Process(), and setupNewFile().