5 #ifndef _VrtSecInclusive_NtupleVars_H
6 #define _VrtSecInclusive_NtupleVars_H
47 namespace varHolder_detail {
49 template<
typename T>
void clear( std::vector<T>&
var ) {
var.clear(); }
50 template<
typename T>
void clear( std::vector< std::vector<T> >&
var ) {
51 for(
auto &
v :
var )
v.clear();
55 static std::map<const std::string, const std::string> create_tree_str() {
56 std::map<const std::string, const std::string>
m;
58 m.insert( std::make_pair( std::string(abi::__cxa_demangle(
typeid(
char ) .
name(), 0, 0, &
stat)), std::string(
"/B") ) );
59 m.insert( std::make_pair( std::string(abi::__cxa_demangle(
typeid(
unsigned char ) .
name(), 0, 0, &
stat)), std::string(
"/b") ) );
60 m.insert( std::make_pair( std::string(abi::__cxa_demangle(
typeid(
short ) .
name(), 0, 0, &
stat)), std::string(
"/S") ) );
61 m.insert( std::make_pair( std::string(abi::__cxa_demangle(
typeid(
unsigned short ) .
name(), 0, 0, &
stat)), std::string(
"/s") ) );
62 m.insert( std::make_pair( std::string(abi::__cxa_demangle(
typeid(
int ) .
name(), 0, 0, &
stat)), std::string(
"/I") ) );
63 m.insert( std::make_pair( std::string(abi::__cxa_demangle(
typeid(
unsigned int ) .
name(), 0, 0, &
stat)), std::string(
"/i") ) );
64 m.insert( std::make_pair( std::string(abi::__cxa_demangle(
typeid(
long long int ) .
name(), 0, 0, &
stat)), std::string(
"/L") ) );
65 m.insert( std::make_pair( std::string(abi::__cxa_demangle(
typeid(
unsigned long long int ) .
name(), 0, 0, &
stat)), std::string(
"/l") ) );
66 m.insert( std::make_pair( std::string(abi::__cxa_demangle(
typeid(
float ) .
name(), 0, 0, &
stat)), std::string(
"/F") ) );
67 m.insert( std::make_pair( std::string(abi::__cxa_demangle(
typeid(
double ) .
name(), 0, 0, &
stat)), std::string(
"/D") ) );
72 static const std::map<const std::string, const std::string> tree_str_map = create_tree_str();
76 {
tree->Branch(
name.c_str(),
var, (
name+tree_str_map.at(type_name) ).c_str() ); }
80 {
tree->Branch(
name.c_str(), type_name.c_str(),
var ); }
94 char*
name = abi::__cxa_demangle(
typeid( T ).
name(), 0, 0, &
stat);
140 std::cerr <<
"Warning<TImprovedTree::isAvailable>: "
141 <<
"couldn't find the variable name " <<
varname
147 char*
name = abi::__cxa_demangle(
typeid( T ).
name(), 0, 0, &
stat);
149 if(
var->get_typename() ==
name ) {
154 std::cerr <<
"Info<TImprovedTree::isAvailable>: " <<
"typeid didn't match." << std::endl;
155 std::cerr <<
"Possible candidates are..." << std::endl;
156 std::cerr <<
"========" << std::endl;
157 std::cerr <<
varname <<
" (" <<
var->get_typename() <<
")" << std::endl;
158 std::cerr <<
"========" << std::endl;
167 if( !isAvailable<T>(
varname) ) {
172 return holder->
get();
174 }
catch( std::string&
varname ) {
175 std::cerr <<
"Variable " <<
varname <<
" is not found in the list!" << std::endl;
176 std::cerr <<
"Candidates are..." << std::endl;
179 char*
name = abi::__cxa_demangle(
typeid( T ).
name(), 0, 0, &
stat);
180 if( pair.second->get_typename() ==
name ) {
181 std::cerr <<
" " << pair.second->get_typename() <<
" : " << pair.first << std::endl;