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_
 
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 43 of file TFWLiteSelectorBasic.h.

Constructor & Destructor Documentation

TFWLiteSelectorBasic::TFWLiteSelectorBasic ( )

Definition at line 172 of file TFWLiteSelectorBasic.cc.

173  everythingOK_(false) {
174 }
std::shared_ptr< edm::root::TFWLiteSelectorMembers > m_
TFWLiteSelectorBasic::~TFWLiteSelectorBasic ( )
virtual

Definition at line 181 of file TFWLiteSelectorBasic.cc.

181  {
182 }
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 200 of file TFWLiteSelectorBasic.cc.

References begin(), and Init().

200  {
201  Init(iTree);
202  begin(fInput);
203 }
virtual void Init(TTree *)
virtual void begin(TList *&in)=0
void TFWLiteSelectorBasic::Init ( TTree *  iTree)
privatevirtual

Definition at line 212 of file TFWLiteSelectorBasic.cc.

References m_.

Referenced by Begin(), and SlaveBegin().

212  {
213  if(iTree == nullptr) return;
214  m_->setTree(iTree);
215 }
std::shared_ptr< edm::root::TFWLiteSelectorMembers > m_
Bool_t TFWLiteSelectorBasic::Notify ( )
privatevirtual

Definition at line 219 of file TFWLiteSelectorBasic.cc.

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

219  {
220  //std::cout << "Notify start" << std::endl;
221  //we have switched to a new file
222  //get new file from Tree
223  if(nullptr == m_->tree_) {
224  std::cout << "No tree" << std::endl;
225  return kFALSE;
226  }
227  TFile* file = m_->tree_->GetCurrentFile();
228  if(nullptr == file) {
229  //When in Rome, do as the Romans
230  TChain* chain = dynamic_cast<TChain*>(m_->tree_);
231  if(nullptr == chain) {
232  std::cout << "No file" << std::endl;
233  return kFALSE;
234  }
235  file = chain->GetFile();
236  if(nullptr == file) {
237  std::cout << "No file" << std::endl;
238  return kFALSE;
239  }
240  }
241  setupNewFile(*file);
242  return everythingOK_ ? kTRUE: kFALSE;
243 }
std::shared_ptr< edm::root::TFWLiteSelectorMembers > m_
tuple cout
Definition: gather_cfg.py:121
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 257 of file TFWLiteSelectorBasic.cc.

References printConversionInfo::aux, edm::poolNames::branchListIndexesBranchName(), edm::BranchTypeToAuxiliaryBranchName(), gather_cfg::cout, event(), edm::poolNames::eventSelectionsBranchName(), everythingOK_, cppFunctionSkipper::exception, edm::hlt::Exception, edm::errors::FatalRootError, edm::InEvent, m_, process(), edm::EventAuxiliary::run(), and edm::EventAuxiliary::time().

257  {
258  //std::cout << "Process start" << std::endl;
259  if(everythingOK_) {
260  std::auto_ptr<edm::EventAuxiliary> eaux(new edm::EventAuxiliary());
261  edm::EventAuxiliary& aux = *eaux;
262  edm::EventAuxiliary* pAux= eaux.get();
263  TBranch* branch = m_->tree_->GetBranch(edm::BranchTypeToAuxiliaryBranchName(edm::InEvent).c_str());
264 
265  branch->SetAddress(&pAux);
266  branch->GetEntry(iEntry);
267 
268 //NEW m_->processNames_ = aux.processHistory();
269 
270 // std::cout << "ProcessNames\n";
271 // for(auto const& name : m_->processNames_) {
272 // std::cout << " " << name << std::endl;
273 // }
274 
275  edm::EventSelectionIDVector eventSelectionIDs;
276  edm::EventSelectionIDVector* pEventSelectionIDVector = &eventSelectionIDs;
277  TBranch* eventSelectionsBranch = m_->tree_->GetBranch(edm::poolNames::eventSelectionsBranchName().c_str());
278  if(!eventSelectionsBranch) {
280  << "Failed to find event Selections branch in event tree";
281  }
282  eventSelectionsBranch->SetAddress(&pEventSelectionIDVector);
283  eventSelectionsBranch->GetEntry(iEntry);
284 
285  edm::BranchListIndexes branchListIndexes;
286  edm::BranchListIndexes* pBranchListIndexes = &branchListIndexes;
287  TBranch* branchListIndexBranch = m_->tree_->GetBranch(edm::poolNames::branchListIndexesBranchName().c_str());
288  if(!branchListIndexBranch) {
290  << "Failed to find branch list index branch in event tree";
291  }
292  branchListIndexBranch->SetAddress(&pBranchListIndexes);
293  branchListIndexBranch->GetEntry(iEntry);
294  m_->branchIDListHelper_->fixBranchListIndexes(branchListIndexes);
295 
296  try {
297  m_->reader_->setEntry(iEntry);
298  auto runAux = std::make_shared<edm::RunAuxiliary>(aux.run(), aux.time(), aux.time());
299  auto rp = std::make_shared<edm::RunPrincipal>(runAux, m_->reg_, m_->pc_, nullptr, 0);
300  auto lumiAux = std::make_shared<edm::LuminosityBlockAuxiliary>(rp->run(), 1, aux.time(), aux.time());
301  auto lbp = std::make_shared<edm::LuminosityBlockPrincipal>(lumiAux, m_->reg_, m_->pc_, nullptr, 0);
302  m_->ep_->fillEventPrincipal(*eaux,
303  *m_->phreg_,
304  std::move(eventSelectionIDs),
305  std::move(branchListIndexes),
306  *(m_->provRetriever_),
307  m_->reader_.get());
308  lbp->setRunPrincipal(rp);
309  m_->ep_->setLuminosityBlockPrincipal(lbp);
310  m_->processNames_ = m_->ep_->processHistory();
311 
312  edm::Event event(*m_->ep_, m_->md_, nullptr);
313 
314  //Make the event principal accessible to edm::Ref's
315  Operate sentry(m_->ep_->prodGetter());
316  process(event);
317  } catch(std::exception const& iEx) {
318  std::cout << "While processing entry " << iEntry << " the following exception was caught \n"
319  << iEx.what() << std::endl;
320  } catch(...) {
321  std::cout << "While processing entry " << iEntry << " an unknown exception was caught" << std::endl;
322  }
323  }
324  return everythingOK_ ? kTRUE: kFALSE;
325 }
std::string const & BranchTypeToAuxiliaryBranchName(BranchType const &branchType)
Definition: BranchType.cc:114
Timestamp const & time() const
RunNumber_t run() const
std::string const & eventSelectionsBranchName()
Definition: BranchType.cc:237
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
std::shared_ptr< edm::root::TFWLiteSelectorMembers > m_
tuple cout
Definition: gather_cfg.py:121
std::string const & branchListIndexesBranchName()
Definition: BranchType.cc:241
void TFWLiteSelectorBasic::setupNewFile ( TFile &  iFile)
private

Definition at line 338 of file TFWLiteSelectorBasic.cc.

References edm::poolNames::branchIDListBranchName(), edm::BranchDescription::branchName(), edm::BranchDescription::branchType(), edm::BranchDescription::className(), gather_cfg::cout, everythingOK_, edm::hlt::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(), edm::BranchDescription::setDropped(), edm::ParameterSet::setID(), AlCaHLTBitMon_QueryRunRegistry::string, groupFilesInBlocks::temp, edm::errors::UnimplementedFeature, and edm::BranchDescription::updateFriendlyClassName().

Referenced by Notify().

338  {
339  //look up meta-data
340  //get product registry
341 
342  //std::vector<edm::EventProcessHistoryID> eventProcessHistoryIDs_;
343  TTree* metaDataTree = dynamic_cast<TTree*>(iFile.Get(edm::poolNames::metaDataTreeName().c_str()));
344  if(!metaDataTree) {
345  std::cout << "could not find TTree " << edm::poolNames::metaDataTreeName() << std::endl;
346  everythingOK_ = false;
347  return;
348  }
349  edm::FileFormatVersion* fftPtr = &(m_->fileFormatVersion_);
350  if(metaDataTree->FindBranch(edm::poolNames::fileFormatVersionBranchName().c_str()) != nullptr) {
351  metaDataTree->SetBranchAddress(edm::poolNames::fileFormatVersionBranchName().c_str(), &fftPtr);
352  }
353 
354 
355  edm::ProductRegistry* pReg = &(*m_->reg_);
356  metaDataTree->SetBranchAddress(edm::poolNames::productDescriptionBranchName().c_str(), &(pReg));
357 
358  typedef std::map<edm::ParameterSetID, edm::ParameterSetBlob> PsetMap;
359  PsetMap psetMap;
360  PsetMap *psetMapPtr = &psetMap;
361  if(metaDataTree->FindBranch(edm::poolNames::parameterSetMapBranchName().c_str()) != nullptr) {
362  metaDataTree->SetBranchAddress(edm::poolNames::parameterSetMapBranchName().c_str(), &psetMapPtr);
363  } else {
364  TTree* psetTree = dynamic_cast<TTree *>(iFile.Get(edm::poolNames::parameterSetsTreeName().c_str()));
365  if(nullptr == psetTree) {
367  << " in the input file.\n";
368  }
369  typedef std::pair<edm::ParameterSetID, edm::ParameterSetBlob> IdToBlobs;
370  IdToBlobs idToBlob;
371  IdToBlobs* pIdToBlob = &idToBlob;
372  psetTree->SetBranchAddress(edm::poolNames::idToParameterSetBlobsBranchName().c_str(), &pIdToBlob);
373  for(long long i = 0; i != psetTree->GetEntries(); ++i) {
374  psetTree->GetEntry(i);
375  psetMap.insert(idToBlob);
376  }
377  }
378 
380  edm::ProcessHistoryRegistry::vector_type *pHistVectorPtr = &pHistVector;
381  if(metaDataTree->FindBranch(edm::poolNames::processHistoryBranchName().c_str()) != nullptr) {
382  metaDataTree->SetBranchAddress(edm::poolNames::processHistoryBranchName().c_str(), &pHistVectorPtr);
383  }
384 
385 
386  edm::ProcessConfigurationVector procConfigVector;
387  edm::ProcessConfigurationVector* procConfigVectorPtr = &procConfigVector;
388  if(metaDataTree->FindBranch(edm::poolNames::processConfigurationBranchName().c_str()) != nullptr) {
389  metaDataTree->SetBranchAddress(edm::poolNames::processConfigurationBranchName().c_str(), &procConfigVectorPtr);
390  }
391 
392  auto branchIDListsHelper = std::make_shared<edm::BranchIDListHelper>();
393  edm::BranchIDLists const* branchIDListsPtr = &branchIDListsHelper->branchIDLists();
394  if(metaDataTree->FindBranch(edm::poolNames::branchIDListBranchName().c_str()) != nullptr) {
395  metaDataTree->SetBranchAddress(edm::poolNames::branchIDListBranchName().c_str(), &branchIDListsPtr);
396  }
397 
398  metaDataTree->GetEntry(0);
399 
400  for(auto& prod : m_->reg_->productListUpdator()) {
401  prod.second.init();
402  }
403 
404  // Merge into the registries. For now, we do NOT merge the product registry.
406  for(auto const& entry : psetMap) {
407  edm::ParameterSet pset(entry.second.pset());
408  pset.setID(entry.first);
409  psetRegistry.insertMapped(pset);
410  }
411 
412  for(auto const& ph : pHistVector) {
413  m_->phreg_->registerProcessHistory(ph);
414  }
415 
416  m_->pointerToBranchBuffer_.erase(m_->pointerToBranchBuffer_.begin(),
417  m_->pointerToBranchBuffer_.end());
418 
419  std::auto_ptr<edm::ProductRegistry> newReg(new edm::ProductRegistry());
420 
421  edm::ProductRegistry::ProductList& prodList = m_->reg_->productListUpdator();
422  {
423  for(auto& item : prodList) {
424  edm::BranchDescription& prod = item.second;
425  //std::cout << "productname = " << item.second << " end " << std::endl;
426  std::string newFriendlyName = edm::friendlyname::friendlyName(prod.className());
427  if(newFriendlyName == prod.friendlyClassName()) {
428  newReg->copyProduct(prod);
429  } else {
430  if(m_->fileFormatVersion_.splitProductIDs()) {
432  << "Cannot change friendly class name algorithm without more development work\n"
433  << "to update BranchIDLists. Contact the framework group.\n";
434  }
435  edm::BranchDescription newBD(prod);
436  newBD.updateFriendlyClassName();
437  newReg->copyProduct(newBD);
438  }
439  prod.init();
440  }
441 
442  m_->reg_.reset(newReg.release());
443  }
444 
445  edm::ProductRegistry::ProductList& prodList2 = m_->reg_->productListUpdator();
446  std::vector<edm::EventEntryDescription> temp(prodList2.size(), edm::EventEntryDescription());
447  m_->prov_.swap(temp);
448  m_->pointerToBranchBuffer_.reserve(prodList2.size());
449 
450  for(auto& item : prodList2) {
451  edm::BranchDescription& prod = item.second;
452  if(prod.branchType() == edm::InEvent) {
453  prod.init();
454  //NEED to do this and check to see if branch exists
455  if(m_->tree_->GetBranch(prod.branchName().c_str()) == nullptr) {
456  prod.setDropped(true);
457  }
458 
459  //std::cout << "id " << it->first << " branch " << it->second << std::endl;
460  //m_->pointerToBranchBuffer_.push_back(&(*itB));
461  //void* tmp = &(m_->pointerToBranchBuffer_.back());
462  //edm::EventEntryDescription* tmp = &(*itB);
463  //CDJ need to fix provenance and be backwards compatible, for now just don't read the branch
464  //m_->metaTree_->SetBranchAddress(prod.branchName().c_str(), tmp);
465  }
466  }
467  m_->branchIDListHelper_->updateFromInput(*branchIDListsPtr);
468  m_->reg_->setFrozen();
469  m_->ep_.reset(new edm::EventPrincipal(m_->reg_, m_->branchIDListHelper_, m_->pc_, nullptr));
470  everythingOK_ = true;
471 }
void setID(ParameterSetID const &id)
std::string const & idToParameterSetBlobsBranchName()
Definition: BranchType.cc:249
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
std::map< BranchKey, BranchDescription > ProductList
std::string const & fileFormatVersionBranchName()
Definition: BranchType.cc:212
std::string const & parameterSetsTreeName()
Definition: BranchType.cc:245
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:167
std::string const & parameterSetMapBranchName()
Definition: BranchType.cc:182
std::string const & processHistoryBranchName()
Definition: BranchType.cc:197
std::string const & productDescriptionBranchName()
Definition: BranchType.cc:172
std::string const & processConfigurationBranchName()
Definition: BranchType.cc:202
std::shared_ptr< edm::root::TFWLiteSelectorMembers > m_
tuple cout
Definition: gather_cfg.py:121
std::string const & branchIDListBranchName()
Definition: BranchType.cc:207
bool insertMapped(value_type const &v)
Definition: Registry.cc:37
static Registry * instance()
Definition: Registry.cc:14
void TFWLiteSelectorBasic::SlaveBegin ( TTree *  iTree)
privatevirtual

Definition at line 206 of file TFWLiteSelectorBasic.cc.

References Init(), and preProcessing().

206  {
207  Init(iTree);
208  preProcessing(fInput, *fOutput);
209 }
virtual void preProcessing(const TList *in, TList &out)=0
virtual void Init(TTree *)
void TFWLiteSelectorBasic::SlaveTerminate ( )
privatevirtual

Definition at line 328 of file TFWLiteSelectorBasic.cc.

References postProcessing().

328  {
329  postProcessing(*fOutput);
330 }
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 333 of file TFWLiteSelectorBasic.cc.

References terminate().

333  {
334  terminate(*fOutput);
335 }
virtual void terminate(TList &out)=0
virtual Int_t TFWLiteSelectorBasic::Version ( ) const
inlineprivatevirtual

Definition at line 97 of file TFWLiteSelectorBasic.h.

97 { return 1; }

Member Data Documentation

bool TFWLiteSelectorBasic::everythingOK_
private

Definition at line 102 of file TFWLiteSelectorBasic.h.

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

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

Definition at line 101 of file TFWLiteSelectorBasic.h.

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