CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
ShallowTree Class Reference

#include <ShallowTree.h>

Inheritance diagram for ShallowTree:
edm::EDAnalyzer

Classes

class  BranchConnector
 
class  TypedBranchConnector
 

Public Types

enum  LEAFTYPE {
  BOOL =1, BOOL_V, SHORT, SHORT_V,
  U_SHORT, U_SHORT_V, INT, INT_V,
  U_INT, U_INT_V, FLOAT, FLOAT_V,
  DOUBLE, DOUBLE_V, LONG, LONG_V,
  U_LONG, U_LONG_V, CHAR, CHAR_V,
  U_CHAR, U_CHAR_V
}
 
- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 

Public Member Functions

 ShallowTree (const edm::ParameterSet &iConfig)
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
 
virtual void beginJob ()
 
virtual void endJob ()
 

Private Attributes

std::vector< BranchConnector * > connectors
 
edm::Service< TFileServicefs
 
edm::ParameterSet pset
 
TTree * tree
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Makes a tree out of C++ standard types and vectors of C++ standard types

This class, which is an EDAnalyzer, takes the same "keep" and "drop" outputCommands parameter as the PoolOutputSource, making a tree of the selected variables, which it obtains from the EDM tree.

See the file python/test_cfg.py for an example configuration.

See the file doc/README for more detailed documentation, including advantages, disadvantages, and use philosophy.

Date:
2010/01/13 17:04:34
Revision:
1.3
Author
Burt Betchart - University of Rochester burto.nosp@m.n.an.nosp@m.drew..nosp@m.betc.nosp@m.hart@.nosp@m.cern.nosp@m..ch

Definition at line 34 of file ShallowTree.h.

Member Enumeration Documentation

Enumerator
BOOL 
BOOL_V 
SHORT 
SHORT_V 
U_SHORT 
U_SHORT_V 
INT 
INT_V 
U_INT 
U_INT_V 
FLOAT 
FLOAT_V 
DOUBLE 
DOUBLE_V 
LONG 
LONG_V 
U_LONG 
U_LONG_V 
CHAR 
CHAR_V 
U_CHAR 
U_CHAR_V 

Definition at line 66 of file ShallowTree.h.

Constructor & Destructor Documentation

ShallowTree::ShallowTree ( const edm::ParameterSet iConfig)
inlineexplicit

Definition at line 64 of file ShallowTree.h.

64 : pset(iConfig) {}
edm::ParameterSet pset
Definition: ShallowTree.h:61

Member Function Documentation

void ShallowTree::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
privatevirtual

Implements edm::EDAnalyzer.

Definition at line 13 of file ShallowTree.cc.

References ShallowTree::BranchConnector::connect(), connectors, and tree.

13  {
14  BOOST_FOREACH( BranchConnector* connector, connectors)
15  connector->connect(iEvent);
16  tree->Fill();
17 }
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
TTree * tree
Definition: ShallowTree.h:59
std::vector< BranchConnector * > connectors
Definition: ShallowTree.h:60
tuple connect
process.AlignmentProducer.algoConfig.uvarFile = &#39;.
Definition: align_tpl.py:66
void ShallowTree::beginJob ( void  )
privatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 42 of file ShallowTree.cc.

References edm::ConstProductRegistry::allBranchDescriptions(), BOOL, BOOL_V, CHAR, CHAR_V, edm::errors::Configuration, connectors, DOUBLE, DOUBLE_V, edm::hlt::Exception, FLOAT, FLOAT_V, fs, edm::GroupSelector::initialize(), INT, INT_V, python.Node::leaf, LONG, LONG_V, TFileDirectory::make(), pset, edm::second(), edm::GroupSelector::selected(), elec_selection::selection(), SHORT, SHORT_V, tree, U_CHAR, U_CHAR_V, U_INT, U_INT_V, U_LONG, U_LONG_V, U_SHORT, and U_SHORT_V.

42  {
43  tree = fs->make<TTree>("tree", "");
44 
45  std::map<std::string, LEAFTYPE> leafmap;
46  leafmap["bool"] = BOOL; leafmap["bools"] = BOOL_V;
47  leafmap["short int"] = SHORT; leafmap["shorts"] = SHORT_V;
48  leafmap["ushort int"]= U_SHORT; leafmap["ushorts"] = U_SHORT_V;
49  leafmap["int"] = INT; leafmap["ints"] = INT_V;
50  leafmap["uint"] = U_INT; leafmap["uints"] = U_INT_V;
51  leafmap["float"] = FLOAT; leafmap["floats"] = FLOAT_V;
52  leafmap["double"] = DOUBLE; leafmap["doubles"] = DOUBLE_V;
53  leafmap["lint"] = LONG; leafmap["longs"] = LONG_V;
54  leafmap["ulint"] = U_LONG; leafmap["ulongs"] = U_LONG_V;
55  leafmap["char"] = CHAR; leafmap["chars"] = CHAR_V;
56  leafmap["uchar"] = U_CHAR; leafmap["uchars"] = U_CHAR_V;
57 
58 
60  edm::Selections allBranches = reg->allBranchDescriptions();
61  edm::GroupSelectorRules groupSelectorRules_(pset, "outputCommands", "ShallowTree");
62  edm::GroupSelector groupSelector_;
63  groupSelector_.initialize(groupSelectorRules_, allBranches);
64 
65  std::set<std::string> branchnames;
66 
67  BOOST_FOREACH( const edm::Selections::value_type& selection, allBranches) {
68  if(groupSelector_.selected(*selection)) {
69 
70  //Check for duplicate branch names
71  if (branchnames.find( selection->productInstanceName()) != branchnames.end() ) {
73  << "More than one branch named: "
74  << selection->productInstanceName() << std::endl
75  << "Exception thrown from ShallowTree::beginJob" << std::endl;
76  }
77  else {
78  branchnames.insert( selection->productInstanceName() );
79  }
80 
81  //Create ShallowTree branch
82  switch(leafmap.find( selection->friendlyClassName() )->second) {
83  case BOOL : connectors.push_back( new TypedBranchConnector <bool> (selection, "/O", tree) ); break;
84  case BOOL_V : connectors.push_back( new TypedBranchConnector<std::vector <bool> >(selection, "", tree) ); break;
85  case INT : connectors.push_back( new TypedBranchConnector <int> (selection, "/I", tree) ); break;
86  case INT_V : connectors.push_back( new TypedBranchConnector<std::vector <int> >(selection, "", tree) ); break;
87  case U_INT : connectors.push_back( new TypedBranchConnector <unsigned int> (selection, "/i", tree) ); break;
88  case U_INT_V : connectors.push_back( new TypedBranchConnector<std::vector <unsigned int> >(selection, "", tree) ); break;
89  case SHORT : connectors.push_back( new TypedBranchConnector <short> (selection, "/S", tree) ); break;
90  case SHORT_V : connectors.push_back( new TypedBranchConnector<std::vector <short> >(selection, "", tree) ); break;
91  case U_SHORT : connectors.push_back( new TypedBranchConnector <unsigned short> (selection, "/s", tree) ); break;
92  case U_SHORT_V: connectors.push_back( new TypedBranchConnector<std::vector<unsigned short> >(selection, "", tree) ); break;
93  case FLOAT : connectors.push_back( new TypedBranchConnector <float> (selection, "/F", tree) ); break;
94  case FLOAT_V : connectors.push_back( new TypedBranchConnector<std::vector <float> >(selection, "", tree) ); break;
95  case DOUBLE : connectors.push_back( new TypedBranchConnector <double> (selection, "/D", tree) ); break;
96  case DOUBLE_V : connectors.push_back( new TypedBranchConnector<std::vector <double> >(selection, "", tree) ); break;
97  case LONG : connectors.push_back( new TypedBranchConnector <long> (selection, "/L", tree) ); break;
98  case LONG_V : connectors.push_back( new TypedBranchConnector<std::vector <long> >(selection, "", tree) ); break;
99  case U_LONG : connectors.push_back( new TypedBranchConnector <unsigned long> (selection, "/l", tree) ); break;
100  case U_LONG_V : connectors.push_back( new TypedBranchConnector<std::vector <unsigned long> >(selection, "", tree) ); break;
101  case CHAR : connectors.push_back( new TypedBranchConnector <char> (selection, "/B", tree) ); break;
102  case CHAR_V : connectors.push_back( new TypedBranchConnector<std::vector <char> >(selection, "", tree) ); break;
103  case U_CHAR : connectors.push_back( new TypedBranchConnector <unsigned char> (selection, "/b", tree) ); break;
104  case U_CHAR_V : connectors.push_back( new TypedBranchConnector<std::vector <unsigned char> >(selection, "", tree) ); break;
105  default:
106  {
107  std::string leafstring = "";
108  typedef std::pair<std::string, LEAFTYPE> pair_t;
109  BOOST_FOREACH( const pair_t& leaf, leafmap)
110  leafstring+= "\t" + leaf.first + "\n";
111 
112  throw edm::Exception(edm::errors::Configuration)
113  << "class ShallowTree does not handle leaves of type " << selection->className() << " like\n"
114  << selection->friendlyClassName() << "_"
115  << selection->moduleLabel() << "_"
116  << selection->productInstanceName() << "_"
117  << selection->processName() << std::endl
118  << "Valid leaf types are (friendlyClassName):\n"
119  << leafstring
120  << "Exception thrown from ShallowTree::beginJob\n";
121  }
122  }
123  }
124  }
125 }
type
Definition: HCALResponse.h:22
std::vector< BranchDescription const * > Selections
Definition: Selections.h:10
virtual void beginJob()
Definition: ShallowTree.cc:42
edm::ParameterSet pset
Definition: ShallowTree.h:61
U second(std::pair< T, U > const &p)
tuple leaf
Definition: Node.py:62
tuple handle
Definition: patZpeak.py:22
TTree * tree
Definition: ShallowTree.h:59
bool first
Definition: L1TdeRCT.cc:79
Container::value_type value_type
static std::string from(" from ")
edm::Service< TFileService > fs
Definition: ShallowTree.h:58
std::vector< BranchConnector * > connectors
Definition: ShallowTree.h:60
bool selected(BranchDescription const &desc) const
T * make() const
make new ROOT object
std::vector< BranchDescription const * > allBranchDescriptions() const
void initialize(GroupSelectorRules const &rules, std::vector< BranchDescription const * > const &branchDescriptions)
std::string className(const T &t)
Definition: ClassName.h:30
const std::string * moduleLabel() const
Definition: HLTadd.h:40
virtual void ShallowTree::endJob ( void  )
inlineprivatevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 38 of file ShallowTree.h.

38 {}

Member Data Documentation

std::vector<BranchConnector*> ShallowTree::connectors
private

Definition at line 60 of file ShallowTree.h.

Referenced by analyze(), and beginJob().

edm::Service<TFileService> ShallowTree::fs
private

Definition at line 58 of file ShallowTree.h.

Referenced by beginJob().

edm::ParameterSet ShallowTree::pset
private

Definition at line 61 of file ShallowTree.h.

Referenced by beginJob().

TTree* ShallowTree::tree
private