CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
edm::PoolOutputModule::OutputItem::Sorter Class Reference

#include <PoolOutputModule.h>

Public Member Functions

bool operator() (OutputItem const &lh, OutputItem const &rh) const
 
 Sorter (TTree *tree)
 

Private Attributes

std::shared_ptr< std::map< std::string, int > > treeMap_
 

Detailed Description

Definition at line 79 of file PoolOutputModule.h.

Constructor & Destructor Documentation

edm::PoolOutputModule::OutputItem::Sorter::Sorter ( TTree *  tree)
explicit

Definition at line 135 of file PoolOutputModule.cc.

References beamvalidation::br, mps_fire::i, AlCaHLTBitMon_QueryRunRegistry::string, and treeMap_.

135  : treeMap_(new std::map<std::string, int>) {
136  // Fill a map mapping branch names to an index specifying the order in the tree.
137  if (tree != nullptr) {
138  TObjArray* branches = tree->GetListOfBranches();
139  for (int i = 0; i < branches->GetEntries(); ++i) {
140  TBranchElement* br = (TBranchElement*)branches->At(i);
141  treeMap_->insert(std::make_pair(std::string(br->GetName()), i));
142  }
143  }
144  }
std::shared_ptr< std::map< std::string, int > > treeMap_
Definition: tree.py:1

Member Function Documentation

bool edm::PoolOutputModule::OutputItem::Sorter::operator() ( OutputItem const &  lh,
OutputItem const &  rh 
) const

Definition at line 146 of file PoolOutputModule.cc.

References edm::PoolOutputModule::OutputItem::branchDescription_, edm::BranchDescription::branchName(), AlCaHLTBitMon_QueryRunRegistry::string, and treeMap_.

146  {
147  // Provides a comparison for sorting branches according to the index values in treeMap_.
148  // Branches not found are always put at the end (i.e. not found > found).
149  if (treeMap_->empty())
150  return lh < rh;
151  std::string const& lstring = lh.branchDescription_->branchName();
152  std::string const& rstring = rh.branchDescription_->branchName();
153  std::map<std::string, int>::const_iterator lit = treeMap_->find(lstring);
154  std::map<std::string, int>::const_iterator rit = treeMap_->find(rstring);
155  bool lfound = (lit != treeMap_->end());
156  bool rfound = (rit != treeMap_->end());
157  if (lfound && rfound) {
158  return lit->second < rit->second;
159  } else if (lfound) {
160  return true;
161  } else if (rfound) {
162  return false;
163  }
164  return lh < rh;
165  }
bool int lh
Definition: SIMDVec.h:21
std::shared_ptr< std::map< std::string, int > > treeMap_

Member Data Documentation

std::shared_ptr<std::map<std::string, int> > edm::PoolOutputModule::OutputItem::Sorter::treeMap_
private

Definition at line 85 of file PoolOutputModule.h.

Referenced by operator()(), and Sorter().