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< ThingsWorker > TFWLiteSelector< TrackAnalysisAlgorithm > TFWLiteSelector< tselnameWorker > tfwliteselectortest::ThingsTSelector tfwliteselectortest::ThingsTSelector2 examples::TrackTSelector tselname

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_
 
boost::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 41 of file TFWLiteSelectorBasic.h.

Constructor & Destructor Documentation

TFWLiteSelectorBasic::TFWLiteSelectorBasic ( )

Definition at line 154 of file TFWLiteSelectorBasic.cc.

155  everythingOK_(false) {
156 }
boost::shared_ptr< edm::root::TFWLiteSelectorMembers > m_
TFWLiteSelectorBasic::~TFWLiteSelectorBasic ( )
virtual

Definition at line 163 of file TFWLiteSelectorBasic.cc.

163  {
164 }
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 tselname, tfwliteselectortest::ThingsTSelector2, examples::TrackTSelector, and tfwliteselectortest::ThingsTSelector.

Referenced by Begin().

void TFWLiteSelectorBasic::Begin ( TTree *  iTree)
privatevirtual

Definition at line 182 of file TFWLiteSelectorBasic.cc.

References begin(), and Init().

182  {
183  Init(iTree);
184  begin(fInput);
185 }
virtual void Init(TTree *)
virtual void begin(TList *&in)=0
void TFWLiteSelectorBasic::Init ( TTree *  iTree)
privatevirtual

Definition at line 194 of file TFWLiteSelectorBasic.cc.

References m_.

Referenced by Begin(), and SlaveBegin().

194  {
195  if(iTree == 0) return;
196  m_->setTree(iTree);
197 }
boost::shared_ptr< edm::root::TFWLiteSelectorMembers > m_
Bool_t TFWLiteSelectorBasic::Notify ( )
privatevirtual

Definition at line 201 of file TFWLiteSelectorBasic.cc.

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

201  {
202  //std::cout << "Notify start" << std::endl;
203  //we have switched to a new file
204  //get new file from Tree
205  if(0 == m_->tree_) {
206  std::cout << "No tree" << std::endl;
207  return kFALSE;
208  }
209  TFile* file = m_->tree_->GetCurrentFile();
210  if(0 == file) {
211  //When in Rome, do as the Romans
212  TChain* chain = dynamic_cast<TChain*>(m_->tree_);
213  if(0 == chain) {
214  std::cout << "No file" << std::endl;
215  return kFALSE;
216  }
217  file = chain->GetFile();
218  if(0 == file) {
219  std::cout << "No file" << std::endl;
220  return kFALSE;
221  }
222  }
223  setupNewFile(*file);
224  return everythingOK_ ? kTRUE: kFALSE;
225 }
boost::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< tselnameWorker >, TFWLiteSelector< ThingsWorker >, 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< tselnameWorker >, TFWLiteSelector< ThingsWorker >, 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 239 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::BranchIDListHelper::fixBranchListIndexes(), edm::InEvent, m_, process(), edm::EventAuxiliary::run(), and edm::EventAuxiliary::time().

239  {
240  //std::cout << "Process start" << std::endl;
241  if(everythingOK_) {
242  std::auto_ptr<edm::EventAuxiliary> eaux(new edm::EventAuxiliary());
243  edm::EventAuxiliary& aux = *eaux;
244  edm::EventAuxiliary* pAux= eaux.get();
245  TBranch* branch = m_->tree_->GetBranch(edm::BranchTypeToAuxiliaryBranchName(edm::InEvent).c_str());
246 
247  branch->SetAddress(&pAux);
248  branch->GetEntry(iEntry);
249 
250 //NEW m_->processNames_ = aux.processHistory();
251 
252 // std::cout << "ProcessNames\n";
253 // for(edm::ProcessNameList::const_iterator itName = m_->processNames_.begin(),
254 // itNameEnd = m_->processNames_.end();
255 // itName != itNameEnd;
256 // ++itName) {
257 // std::cout << " " << *itName << std::endl;
258 // }
259 
260  boost::shared_ptr<edm::EventSelectionIDVector> eventSelectionIDs_(new edm::EventSelectionIDVector);
261  edm::EventSelectionIDVector* pEventSelectionIDVector = eventSelectionIDs_.get();
262  TBranch* eventSelectionsBranch = m_->tree_->GetBranch(edm::poolNames::eventSelectionsBranchName().c_str());
263  if(!eventSelectionsBranch) {
265  << "Failed to find event Selections branch in event tree";
266  }
267  eventSelectionsBranch->SetAddress(&pEventSelectionIDVector);
268  eventSelectionsBranch->GetEntry(iEntry);
269 
270  boost::shared_ptr<edm::BranchListIndexes> branchListIndexes_(new edm::BranchListIndexes);
271  edm::BranchListIndexes* pBranchListIndexes = branchListIndexes_.get();
272  TBranch* branchListIndexBranch = m_->tree_->GetBranch(edm::poolNames::branchListIndexesBranchName().c_str());
273  if(!branchListIndexBranch) {
275  << "Failed to find branch list index branch in event tree";
276  }
277  branchListIndexBranch->SetAddress(&pBranchListIndexes);
278  branchListIndexBranch->GetEntry(iEntry);
280 
281  try {
282  m_->reader_->setEntry(iEntry);
283  boost::shared_ptr<edm::RunAuxiliary> runAux(new edm::RunAuxiliary(aux.run(), aux.time(), aux.time()));
284  boost::shared_ptr<edm::RunPrincipal> rp(new edm::RunPrincipal(runAux, m_->reg_, m_->pc_));
285  boost::shared_ptr<edm::LuminosityBlockAuxiliary> lumiAux(
286  new edm::LuminosityBlockAuxiliary(rp->run(), 1, aux.time(), aux.time()));
287  boost::shared_ptr<edm::LuminosityBlockPrincipal>lbp(
288  new edm::LuminosityBlockPrincipal(lumiAux, m_->reg_, m_->pc_, rp));
289  m_->ep_->fillEventPrincipal(*eaux, lbp, eventSelectionIDs_, branchListIndexes_, m_->mapper_, m_->reader_.get());
290  m_->processNames_ = m_->ep_->processHistory();
291 
292  edm::Event event(*m_->ep_, m_->md_);
293 
294  //Make the event principal accessible to edm::Ref's
295  Operate sentry(m_->ep_->prodGetter());
296  process(event);
297  } catch(std::exception const& iEx) {
298  std::cout << "While processing entry " << iEntry << " the following exception was caught \n"
299  << iEx.what() << std::endl;
300  } catch(...) {
301  std::cout << "While processing entry " << iEntry << " an unknown exception was caught" << std::endl;
302  }
303  }
304  return everythingOK_ ? kTRUE: kFALSE;
305 }
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
static void fixBranchListIndexes(BranchListIndexes &indexes)
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
boost::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 318 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::fillProductRegistryTransients(), edm::BranchDescription::friendlyClassName(), edm::friendlyname::friendlyName(), i, edm::poolNames::idToParameterSetBlobsBranchName(), edm::InEvent, edm::BranchDescription::init(), edm::detail::ThreadSafeRegistry< KEY, T, E >::insertCollection(), edm::detail::ThreadSafeRegistry< KEY, T, E >::insertMapped(), edm::detail::ThreadSafeRegistry< KEY, T, E >::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().

318  {
319  //look up meta-data
320  //get product registry
321 
322  //std::vector<edm::EventProcessHistoryID> eventProcessHistoryIDs_;
323  TTree* metaDataTree = dynamic_cast<TTree*>(iFile.Get(edm::poolNames::metaDataTreeName().c_str()));
324  if(!metaDataTree) {
325  std::cout << "could not find TTree " << edm::poolNames::metaDataTreeName() << std::endl;
326  everythingOK_ = false;
327  return;
328  }
329  edm::FileFormatVersion* fftPtr = &(m_->fileFormatVersion_);
330  if(metaDataTree->FindBranch(edm::poolNames::fileFormatVersionBranchName().c_str()) != 0) {
331  metaDataTree->SetBranchAddress(edm::poolNames::fileFormatVersionBranchName().c_str(), &fftPtr);
332  }
333 
334 
335  edm::ProductRegistry* pReg = &(*m_->reg_);
336  metaDataTree->SetBranchAddress(edm::poolNames::productDescriptionBranchName().c_str(), &(pReg));
337 
338  m_->reg_->setFrozen();
339 
340  typedef std::map<edm::ParameterSetID, edm::ParameterSetBlob> PsetMap;
341  PsetMap psetMap;
342  PsetMap *psetMapPtr = &psetMap;
343  if(metaDataTree->FindBranch(edm::poolNames::parameterSetMapBranchName().c_str()) != 0) {
344  metaDataTree->SetBranchAddress(edm::poolNames::parameterSetMapBranchName().c_str(), &psetMapPtr);
345  } else {
346  TTree* psetTree = dynamic_cast<TTree *>(iFile.Get(edm::poolNames::parameterSetsTreeName().c_str()));
347  if(0 == psetTree) {
349  << " in the input file.\n";
350  }
351  typedef std::pair<edm::ParameterSetID, edm::ParameterSetBlob> IdToBlobs;
352  IdToBlobs idToBlob;
353  IdToBlobs* pIdToBlob = &idToBlob;
354  psetTree->SetBranchAddress(edm::poolNames::idToParameterSetBlobsBranchName().c_str(), &pIdToBlob);
355  for(long long i = 0; i != psetTree->GetEntries(); ++i) {
356  psetTree->GetEntry(i);
357  psetMap.insert(idToBlob);
358  }
359  }
360 
362  edm::ProcessHistoryRegistry::vector_type *pHistVectorPtr = &pHistVector;
363  if(metaDataTree->FindBranch(edm::poolNames::processHistoryBranchName().c_str()) != 0) {
364  metaDataTree->SetBranchAddress(edm::poolNames::processHistoryBranchName().c_str(), &pHistVectorPtr);
365  }
366 
367 
368  edm::ProcessConfigurationVector procConfigVector;
369  edm::ProcessConfigurationVector* procConfigVectorPtr = &procConfigVector;
370  if(metaDataTree->FindBranch(edm::poolNames::processConfigurationBranchName().c_str()) != 0) {
371  metaDataTree->SetBranchAddress(edm::poolNames::processConfigurationBranchName().c_str(), &procConfigVectorPtr);
372  }
373 
374  std::auto_ptr<edm::BranchIDListRegistry::collection_type> branchIDListsAPtr(new edm::BranchIDListRegistry::collection_type);
375  edm::BranchIDListRegistry::collection_type *branchIDListsPtr = branchIDListsAPtr.get();
376  if(metaDataTree->FindBranch(edm::poolNames::branchIDListBranchName().c_str()) != 0) {
377  metaDataTree->SetBranchAddress(edm::poolNames::branchIDListBranchName().c_str(), &branchIDListsPtr);
378  }
379 
380  metaDataTree->GetEntry(0);
381 
382  // Merge into the registries. For now, we do NOT merge the product registry.
384  for(PsetMap::const_iterator i = psetMap.begin(), iEnd = psetMap.end();
385  i != iEnd; ++i) {
386  edm::ParameterSet pset(i->second.pset());
387  pset.setID(i->first);
388  psetRegistry.insertMapped(pset);
389  }
390 
393 
394  m_->pointerToBranchBuffer_.erase(m_->pointerToBranchBuffer_.begin(),
395  m_->pointerToBranchBuffer_.end());
396 
397  fillProductRegistryTransients(procConfigVector, *m_->reg_);
398  std::auto_ptr<edm::ProductRegistry> newReg(new edm::ProductRegistry());
399 
400  edm::ProductRegistry::ProductList const& prodList = m_->reg_->productList();
401  {
402  for(edm::ProductRegistry::ProductList::const_iterator it = prodList.begin(), itEnd = prodList.end();
403  it != itEnd; ++it) {
404  edm::BranchDescription const& prod = it->second;
405  //std::cout << "productname = " << it->second << " end " << std::endl;
406  std::string newFriendlyName = edm::friendlyname::friendlyName(prod.className());
407  if(newFriendlyName == prod.friendlyClassName()) {
408  newReg->copyProduct(prod);
409  } else {
410  if(m_->fileFormatVersion_.splitProductIDs()) {
412  << "Cannot change friendly class name algorithm without more development work\n"
413  << "to update BranchIDLists. Contact the framework group.\n";
414  }
415  edm::BranchDescription newBD(prod);
416  newBD.updateFriendlyClassName();
417  newReg->copyProduct(newBD);
418  // Need to call init to get old branch name.
419  prod.init();
420  }
421  }
422 
423  newReg->setFrozen();
424  m_->reg_.reset(newReg.release());
425  }
426 
427  edm::ProductRegistry::ProductList const& prodList2 = m_->reg_->productList();
428  std::vector<edm::EventEntryDescription> temp(prodList2.size(), edm::EventEntryDescription());
429  m_->prov_.swap(temp);
430  std::vector<edm::EventEntryDescription>::iterator itB = m_->prov_.begin();
431  m_->pointerToBranchBuffer_.reserve(prodList2.size());
432 
433  for(edm::ProductRegistry::ProductList::const_iterator it = prodList2.begin(), itEnd = prodList2.end();
434  it != itEnd; ++it, ++itB) {
435  edm::BranchDescription const& prod = it->second;
436  if(prod.branchType() == edm::InEvent) {
437  prod.init();
438  //NEED to do this and check to see if branch exists
439  if(m_->tree_->GetBranch(prod.branchName().c_str()) == 0) {
440  prod.setDropped();
441  }
442 
443  //std::cout << "id " << it->first << " branch " << it->second << std::endl;
444  //m_->pointerToBranchBuffer_.push_back(&(*itB));
445  //void* tmp = &(m_->pointerToBranchBuffer_.back());
446  //edm::EventEntryDescription* tmp = &(*itB);
447  //CDJ need to fix provenance and be backwards compatible, for now just don't read the branch
448  //m_->metaTree_->SetBranchAddress(prod.branchName().c_str(), tmp);
449  }
450  }
451  edm::BranchIDListHelper::updateFromInput(*branchIDListsAPtr, "");
452  m_->ep_.reset(new edm::EventPrincipal(m_->reg_, m_->pc_));
453  everythingOK_ = true;
454 }
std::string const & idToParameterSetBlobsBranchName()
Definition: BranchType.cc:249
int i
Definition: DBlmapReader.cc:9
BranchType const & branchType() const
std::string & branchName() const
std::map< BranchKey, BranchDescription > ProductList
static bool updateFromInput(BranchIDLists const &bidlists, std::string const &fileName)
std::string const & fileFormatVersionBranchName()
Definition: BranchType.cc:212
static ThreadSafeRegistry * instance()
void fillProductRegistryTransients(std::vector< ProcessConfiguration > const &pcVec, ProductRegistry const &preg, bool okToRegister=false)
std::string const & parameterSetsTreeName()
Definition: BranchType.cc:245
void setID(ParameterSetID const &id) const
ProcessConfigurationRegistry::vector_type ProcessConfigurationVector
std::string const & className() const
std::string friendlyName(std::string const &iFullName)
std::string const & friendlyClassName() const
std::string const & metaDataTreeName()
Definition: BranchType.cc:167
void insertCollection(collection_type const &c)
std::string const & parameterSetMapBranchName()
Definition: BranchType.cc:182
std::string const & processHistoryBranchName()
Definition: BranchType.cc:197
boost::shared_ptr< edm::root::TFWLiteSelectorMembers > m_
std::string const & productDescriptionBranchName()
Definition: BranchType.cc:172
std::string const & processConfigurationBranchName()
Definition: BranchType.cc:202
author Stefano ARGIRO author Bill Tanenbaum
std::vector< value_type > vector_type
tuple cout
Definition: gather_cfg.py:121
std::string const & branchIDListBranchName()
Definition: BranchType.cc:207
bool insertMapped(value_type const &v)
void TFWLiteSelectorBasic::SlaveBegin ( TTree *  iTree)
privatevirtual

Definition at line 188 of file TFWLiteSelectorBasic.cc.

References Init(), and preProcessing().

188  {
189  Init(iTree);
190  preProcessing(fInput, *fOutput);
191 }
virtual void preProcessing(const TList *in, TList &out)=0
virtual void Init(TTree *)
void TFWLiteSelectorBasic::SlaveTerminate ( )
privatevirtual

Definition at line 308 of file TFWLiteSelectorBasic.cc.

References postProcessing().

308  {
309  postProcessing(*fOutput);
310 }
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 tselname, tfwliteselectortest::ThingsTSelector2, examples::TrackTSelector, and tfwliteselectortest::ThingsTSelector.

Referenced by Terminate().

void TFWLiteSelectorBasic::Terminate ( )
privatevirtual

Definition at line 313 of file TFWLiteSelectorBasic.cc.

References terminate().

313  {
314  terminate(*fOutput);
315 }
virtual void terminate(TList &out)=0
virtual Int_t TFWLiteSelectorBasic::Version ( ) const
inlineprivatevirtual

Definition at line 95 of file TFWLiteSelectorBasic.h.

95 { return 1; }

Member Data Documentation

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