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 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 71 of file PoolOutputModule.h.

Constructor & Destructor Documentation

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

Definition at line 124 of file PoolOutputModule.cc.

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

124  : treeMap_(new std::map<std::string, int>) {
125  // Fill a map mapping branch names to an index specifying the order in the tree.
126  if(tree != 0) {
127  TObjArray* branches = tree->GetListOfBranches();
128  for(int i = 0; i < branches->GetEntries(); ++i) {
129  TBranchElement* br = (TBranchElement*)branches->At(i);
130  treeMap_->insert(std::make_pair(std::string(br->GetName()), i));
131  }
132  }
133  }
int i
Definition: DBlmapReader.cc:9
std::shared_ptr< std::map< std::string, int > > treeMap_

Member Function Documentation

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

Definition at line 136 of file PoolOutputModule.cc.

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

136  {
137  // Provides a comparison for sorting branches according to the index values in treeMap_.
138  // Branches not found are always put at the end (i.e. not found > found).
139  if(treeMap_->empty()) return lh < rh;
140  std::string const& lstring = lh.branchDescription_->branchName();
141  std::string const& rstring = rh.branchDescription_->branchName();
142  std::map<std::string, int>::const_iterator lit = treeMap_->find(lstring);
143  std::map<std::string, int>::const_iterator rit = treeMap_->find(rstring);
144  bool lfound = (lit != treeMap_->end());
145  bool rfound = (rit != treeMap_->end());
146  if(lfound && rfound) {
147  return lit->second < rit->second;
148  } else if(lfound) {
149  return true;
150  } else if(rfound) {
151  return false;
152  }
153  return lh < rh;
154  }
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 76 of file PoolOutputModule.h.

Referenced by Sorter().