inlib  1.2.0
Classes | Functions
inlib::aida Namespace Reference

Classes

class  base_col
class  base_ntu
class  aida_base_col
class  aida_col
class  ntuple
class  aida_col_ntu
 some special column that can't be done with aida_col<T> //// More...
class  base_looper
class  stat_looper

Functions

const std::string & s_aida_type (short)
const std::string & s_aida_type (int)
const std::string & s_aida_type (float)
const std::string & s_aida_type (double)
const std::string & s_aida_type (bool)
const std::string & s_aida_type (const std::string &)
const std::string & s_aida_type (int64)
const std::string & s_aida_type (const std::vector< double > &)
const std::string & s_aida_type_ituple ()
const std::string & s_aida_type (unsigned short)
 not AIDA ! //////////////////////////
const std::string & s_aida_type (uint64)
bool s__fill (const std::string &a_s, std::string &a_v)
bool s__fill (const std::string &a_s, char &a_v)
bool s__fill (const std::string &a_s, unsigned char &a_v)
bool s__fill (const std::string &a_s, bool &a_v)
bool s__fill (const std::string &a_s, short &a_v)
bool s__fill (const std::string &a_s, unsigned short &a_v)
bool s__fill (const std::string &a_s, int &a_v)
bool s__fill (const std::string &a_s, unsigned int &a_v)
bool s__fill (const std::string &a_s, int64 &a_v)
bool s__fill (const std::string &a_s, uint64 &a_v)
bool s__fill (const std::string &a_s, float &a_v)
bool s__fill (const std::string &a_s, double &a_v)
bool create_cols_from_vals (ntuple &a_ntu, const std::vector< value > &a_vars, bool a_verbose=false)
bool create_col (ntuple &a_ntu, const std::string &a_type, const std::string &a_name, const std::string &a_s, bool a_is_ntu)
bool create_cols_from_string (ntuple &a_ntu, const std::string &a_booking, bool a_verbose=false)
aida_col_ntufind_col_ntu (ntuple &a_ntu, const std::string &a_name)
template<class T >
bool column_infos (inlib::aida::base_ntu &a_ntu, inlib::aida::base_col &a_col, T &a_mn, T &a_mx, T &a_S, T &a_S2, inlib::uint64 &a_count)
base_colfind_leaf_column (const base_ntu &a_ntu, const std::string &a_name)

Function Documentation

template<class T >
bool inlib::aida::column_infos ( inlib::aida::base_ntu a_ntu,
inlib::aida::base_col a_col,
T &  a_mn,
T &  a_mx,
T &  a_S,
T &  a_S2,
inlib::uint64 a_count 
) [inline]

Definition at line 1213 of file aida_ntuple.

                                              {
  inlib::aida::stat_looper<T> lpr(a_ntu,a_col);
  bool status = lpr.process();
  a_mn = lpr.mn();
  a_mx = lpr.mx();
  a_S = lpr.S();
  a_S2 = lpr.S2();
  a_count = lpr.counter();
  if(!status) return false;
  if(!a_count) return false;
  return true;
}
bool inlib::aida::create_col ( ntuple &  a_ntu,
const std::string &  a_type,
const std::string &  a_name,
const std::string &  a_s,
bool  a_is_ntu 
) [inline]

Definition at line 677 of file aida_ntuple.

                                     {
/*
  if(a_type==s_aida_type((char)0)) {
    char v;
    if(!to<char>(a_s,v)) {
      a_ntu.out() << "inlib::aida::create_col :" 
                  << " can't convert def " << sout(a_s)
                  << " to a " << a_type
                  << std::endl;
      return false;
    }
    if(!a_ntu.create_col<char>(a_name,v)) {
      a_ntu.out() << "inlib::aida::create_col :" 
                  << " can't create column of type " << sout(a_type)
                  << std::endl;
      return false;
    }

  } else*/ if(a_type==s_aida_type((short)0)) {
    short v;
    if(!to<short>(a_s,v)) {
      a_ntu.out() << "inlib::aida::create_col :" 
                  << " can't convert def " << sout(a_s)
                  << " to a " << a_type
                  << std::endl;
      return false;
    }
    if(!a_ntu.create_col<short>(a_name,v)) {
      a_ntu.out() << "inlib::aida::create_col :" 
                  << " can't create column of type " << sout(a_type)
                  << std::endl;
      return false;
    }

  } else if(a_type==s_aida_type((int)0)) {
    int v;
    if(!to<int>(a_s,v)) {
      a_ntu.out() << "inlib::aida::create_col :" 
                  << " can't convert def " << sout(a_s)
                  << " to a " << a_type
                  << std::endl;
      return false;
    }
    if(!a_ntu.create_col<int>(a_name,v)) {
      a_ntu.out() << "inlib::aida::create_col :" 
                  << " can't create column of type " << sout(a_type)
                  << std::endl;
      return false;
    }

  } else if(a_type==s_aida_type((int64)0)) {
    int64 v;
    if(!to<int64>(a_s,v)) {
      a_ntu.out() << "inlib::aida::create_col :" 
                  << " can't convert def " << sout(a_s)
                  << " to a " << a_type
                  << std::endl;
      return false;
    }
    if(!a_ntu.create_col<int64>(a_name,v)) {
      a_ntu.out() << "inlib::aida::create_col :" 
                  << " can't create column of type " << sout(a_type)
                  << std::endl;
      return false;
    }

  } else if(a_type==s_aida_type((float)0)) {
    float v;
    if(!to<float>(a_s,v)) {
      a_ntu.out() << "inlib::aida::create_col :" 
                  << " can't convert def " << sout(a_s)
                  << " to a " << a_type
                  << std::endl;
      return false;
    }
    if(!a_ntu.create_col<float>(a_name,v)) {
      a_ntu.out() << "inlib::aida::create_col :" 
                  << " can't create column of type " << sout(a_type)
                  << std::endl;
      return false;
    }


  } else if(a_type==s_aida_type((double)0)) {
    double v;
    if(!to<double>(a_s,v)) {
      a_ntu.out() << "inlib::aida::create_col :" 
                  << " can't convert def " << sout(a_s)
                  << " to a " << a_type
                  << std::endl;
      return false;
    }
    if(!a_ntu.create_col<double>(a_name,v)) {
      a_ntu.out() << "inlib::aida::create_col :" 
                  << " can't create column of type " << sout(a_type)
                  << std::endl;
      return false;
    }

/*  } else if(a_type==s_aida_type((unsigned char)0)) { //byte
    unsigned int v;
    if(!to<unsigned int>(a_s,v)) {
      a_ntu.out() << "inlib::aida::create_col :" 
                  << " can't convert def " << sout(a_s)
                  << " to a " << a_type
                  << std::endl;
      return false;
    }    
    if(v>=256) {
      a_ntu.out() << "inlib::aida::create_col :" 
                  << " can't convert def " << sout(a_s)
                  << " to byte."
                  << std::endl;
      return false;
    }
    if(!a_ntu.create_col<unsigned char>(a_name,v)) {
      a_ntu.out() << "inlib::aida::create_col :" 
                  << " can't create column of type " << sout(a_type)
                  << std::endl;
      return false;
    }
*/
  } else if(a_type==s_aida_type((unsigned short)0)) {
    unsigned short v;
    if(!to<unsigned short>(a_s,v)) {
      a_ntu.out() << "inlib::aida::create_col :" 
                  << " can't convert def " << sout(a_s)
                  << " to a " << a_type
                  << std::endl;
      return false;
    }
    if(!a_ntu.create_col<unsigned short>(a_name,v)) {
      a_ntu.out() << "inlib::aida::create_col :" 
                  << " can't create column of type " << sout(a_type)
                  << std::endl;
      return false;
    }

  } else if(a_type==s_aida_type((unsigned int)0)) {
    unsigned int v;
    if(!to<unsigned int>(a_s,v)) {
      a_ntu.out() << "inlib::aida::create_col :" 
                  << " can't convert def " << sout(a_s)
                  << " to a " << a_type
                  << std::endl;
      return false;
    }
    if(!a_ntu.create_col<unsigned int>(a_name,v)) {
      a_ntu.out() << "inlib::aida::create_col :" 
                  << " can't create column of type " << sout(a_type)
                  << std::endl;
      return false;
    }

  } else if(a_type==s_aida_type((uint64)0)) {
    uint64 v;
    if(!to<uint64>(a_s,v)) {
      a_ntu.out() << "inlib::aida::create_col :" 
                  << " can't convert def " << sout(a_s)
                  << " to a " << a_type
                  << std::endl;
      return false;
    }
    if(!a_ntu.create_col<uint64>(a_name,v)) {
      a_ntu.out() << "inlib::aida::create_col :" 
                  << " can't create column of type " << sout(a_type)
                  << std::endl;
      return false;
    }

  } else if(a_type==s_aida_type((bool)true)) {
    bool v;
    if(!to(a_s,v)) {
      a_ntu.out() << "inlib::aida::create_col :" 
                  << " can't convert def " << sout(a_s)
                  << " to a " << a_type
                  << std::endl;
      return false;
    }
    if(!a_ntu.create_col<bool>(a_name,v)) {
      a_ntu.out() << "inlib::aida::create_col :" 
                  << " can't create column of type " << sout(a_type)
                  << std::endl;
      return false;
    }

  } else if(a_type==s_aida_type(std::string())) {
    if(!a_ntu.create_col<std::string>(a_name,a_s)) {
      a_ntu.out() << "inlib::aida::create_col :" 
                  << " can't create column of type " << sout(a_type)
                  << std::endl;
      return false;
    }

  } else if(a_type==s_aida_type((int64)0)) {
    int64 v;
    if(!to<int64>(a_s,v)) {
      a_ntu.out() << "inlib::aida::create_col :" 
                  << " can't convert def " << sout(a_s)
                  << " to a " << a_type
                  << std::endl;
      return false;
    }
    if(!a_ntu.create_col<int64>(a_name,v)) {
      a_ntu.out() << "inlib::aida::create_col :" 
                  << " can't create column of type " << sout(a_type)
                  << std::endl;
      return false;
    }

  } else if(a_type==s_aida_type_ituple()) {
    // we expect a booking string on a_s.

    if(!a_is_ntu) {
      a_ntu.out() << "inlib::aida::create_col :" 
                  << " mismatch a_is_ntu/a_type."
                  << std::endl;
      return false;
    }
    if(a_s.empty()) {
      a_ntu.out() << "inlib::aida::create_col :" 
                  << " empty booking string."
                  << std::endl;
      return false;
    }

    columns::finder f(a_ntu.out(),a_s);
    if(!f.find_variables()) {
      a_ntu.out() << "inlib::aida::create_col :" 
            << " find_variables() failed for " << sout(a_s) << "."
            << std::endl;
      return false;
    }

    aida_col_ntu* col_ntu = new aida_col_ntu(a_ntu.out(),a_name);
    //create columns on the fillable.
    base_ntu* sub_base_ntu = col_ntu->get_to_fill();
    if(!sub_base_ntu) {delete col_ntu;return false;}
    ntuple* sub_aida = inlib::cast<base_ntu,ntuple>(*sub_base_ntu);
    if(!sub_aida) {delete col_ntu;return false;}

    std::vector<value> vars = f.result();
    if(!create_cols_from_vals(*sub_aida,vars)) {
      columns::delete_columns(vars);
      delete col_ntu;
      return false;
    }
    columns::delete_columns(vars);
    a_ntu.add_column(col_ntu);

    //FIXME : double[]

  } else {
    a_ntu.out() << "inlib::aida::create_col :" 
                << " col type " << sout(a_type)
                << " not yet handled."
                << std::endl;
    return false;
  }

  return true;
}
bool inlib::aida::create_cols_from_string ( ntuple &  a_ntu,
const std::string &  a_booking,
bool  a_verbose = false 
) [inline]

Definition at line 947 of file aida_ntuple.

                                                           {
  a_ntu.clear();
  if(a_booking.empty()) {
    a_ntu.out() << "inlib::aida::create_cols_from_string :"
                << " empty booking string."
                << std::endl;
    return false;
  }

  columns::finder f(a_ntu.out(),a_booking);
  if(!f.find_variables()) {
    a_ntu.out() << "inlib::aida::create_cols_from_string :"
          << " find_variables() failed."
          << std::endl;
    return false;
  }
  std::vector<value> vars = f.result();
  if(a_verbose) columns::dump_columns(a_ntu.out(),vars);

  if(!create_cols_from_vals(a_ntu,vars)) {
    columns::delete_columns(vars);
    a_ntu.clear();
    return false;
  }
  columns::delete_columns(vars);
  return true;
}
bool inlib::aida::create_cols_from_vals ( ntuple &  a_ntu,
const std::vector< value > &  a_vars,
bool  a_verbose = false 
) [inline]

Definition at line 577 of file aida_ntuple.

                                                         {
  std::vector<value>::const_iterator it;
  for(it=a_vars.begin();it!=a_vars.end();++it) {
      if((*it).type()==value::VOID_STAR) {
        if(a_verbose){
          a_ntu.out() << "inlib::aida::create_cols_from_vals :"
                      << " ITuple : " << (*it).label() << " : begin "
                      << std::endl;
        }
        std::vector<value>* vars = 
          (std::vector<value>*)(*it).get_void_star();

        aida_col_ntu* col_ntu = new aida_col_ntu(a_ntu.out(),(*it).label());
        // create sub columns on the the "fillable" of col_ntu :
        base_ntu* sub_base_ntu = col_ntu->get_to_fill();
        if(!sub_base_ntu) return false;
        ntuple* sub_aida =
          inlib::cast<base_ntu,ntuple>(*sub_base_ntu);
        if(!sub_aida) return false;

        if(!create_cols_from_vals(*sub_aida,*vars,a_verbose)) {
          delete col_ntu;
          return false;
        }

        a_ntu.add_column(col_ntu);

    } else {
        if(a_verbose){
          std::string stype;        
          (*it).s_type(stype);
          std::string sval;        
          (*it).tos(sval);
          a_ntu.out() << "inlib::aida::create_cols_from_vals :"
                      << " " << stype << " : " 
                      << (*it).label() << " : " 
                      << sval
                      << std::endl;
        }

        //   char,short,int,float,double
        //   byte,boolean,string,long(for int64)
        //   double[]

        base_col* col = 0;
      /*if((*it).type()==value::CHAR) {
          col = a_ntu.create_col<char>((*it).label(),(*it).get_char());
        } else*/ if((*it).type()==value::SHORT) {
          col = a_ntu.create_col<short>((*it).label(),(*it).get_short());
        } else if((*it).type()==value::INT) {
          col = a_ntu.create_col<int>((*it).label(),(*it).get_int());
        } else if((*it).type()==value::INT64) {
          col = a_ntu.create_col<int64>((*it).label(),(*it).get_int64());
        } else if((*it).type()==value::FLOAT) {
          col = a_ntu.create_col<float>((*it).label(),(*it).get_float());
        } else if((*it).type()==value::DOUBLE) {
          col = a_ntu.create_col<double>((*it).label(),(*it).get_double());

        //} else if((*it).type()==value::UNSIGNED_CHAR) {
        //  col = a_ntu.create_col<unsigned char>
        //          ((*it).label(),(*it).get_unsigned_char());
        } else if((*it).type()==value::UNSIGNED_SHORT) {
          col = a_ntu.create_col<unsigned short>
                  ((*it).label(),(*it).get_unsigned_short());
        } else if((*it).type()==value::UNSIGNED_INT) {
          col = a_ntu.create_col<unsigned int>
                  ((*it).label(),(*it).get_unsigned_int());
        } else if((*it).type()==value::UNSIGNED_INT64) {
          col = a_ntu.create_col<uint64>
                  ((*it).label(),(*it).get_unsigned_int64());

        } else if((*it).type()==value::BOOL) {
          col = a_ntu.create_col<bool>((*it).label(),(*it).get_bool());
        } else if((*it).type()==value::STRING) {
          col = a_ntu.create_col<std::string>
                  ((*it).label(),(*it).get_string());
        } else if((*it).type()==value::INT64) {
          col = a_ntu.create_col<int64>((*it).label(),(*it).get_int64());
        }

        if(!col) {
          std::string stype;        
          (*it).s_type(stype);
          std::string sval;        
          (*it).tos(sval);
          a_ntu.out() << "inlib::aida::create_cols_from_vals :"
                      << " failed for " << stype << " : " 
                      << (*it).label() << " : " 
                      << sval
                      << std::endl;
          return false;
        }
      }
  }
  return true;
}
aida_col_ntu* inlib::aida::find_col_ntu ( ntuple &  a_ntu,
const std::string &  a_name 
) [inline]

Definition at line 977 of file aida_ntuple.

                                                          {
  base_col* col = find_named<base_col>(a_ntu.cols(),a_name);
  if(!col) return 0;
  return inlib::cast<base_col, aida_col_ntu >(*col);
}
base_col* inlib::aida::find_leaf_column ( const base_ntu &  a_ntu,
const std::string &  a_name 
) [inline]

Definition at line 1229 of file aida_ntuple.

                                                      {
  const std::vector<base_col*>& cols = a_ntu.cols();
  std::vector<base_col*>::const_iterator it;  
  for(it=cols.begin();it!=cols.end();++it) {
    aida_col_ntu* col = cast<base_col,aida_col_ntu>(*(*it));
    if(col) {
      base_ntu* sub = col->get_to_fill(); //it holds the "sub" cols schema.
      if(!sub) return 0;
      base_col* fcol = find_leaf_column(*sub,a_name);
      if(fcol) return fcol;      
    } else {
      if((*it)->name()==a_name) return *it;
    }
  }
  return 0;
}  
bool inlib::aida::s__fill ( const std::string &  a_s,
std::string &  a_v 
) [inline]

Definition at line 333 of file aida_ntuple.

                                                         {
  a_v = a_s;
  return true;
}
bool inlib::aida::s__fill ( const std::string &  a_s,
char &  a_v 
) [inline]

Definition at line 337 of file aida_ntuple.

                                                    {
  //for exlib/cbk/aida_ntu
  if(a_s.empty()) return false;
  a_v = a_s[0];
  return true;
}
bool inlib::aida::s__fill ( const std::string &  a_s,
unsigned char &  a_v 
) [inline]

Definition at line 343 of file aida_ntuple.

                                                             {
  //for exlib/cbk/aida_ntu
  if(a_s.empty()) return false;
  a_v = a_s[0];
  return true;
}
bool inlib::aida::s__fill ( const std::string &  a_s,
bool &  a_v 
) [inline]

Definition at line 349 of file aida_ntuple.

                                                    {
  return to(a_s,a_v);
}
bool inlib::aida::s__fill ( const std::string &  a_s,
short &  a_v 
) [inline]

Definition at line 352 of file aida_ntuple.

                                                     {
  return to<short>(a_s,a_v);
}
bool inlib::aida::s__fill ( const std::string &  a_s,
unsigned short &  a_v 
) [inline]

Definition at line 355 of file aida_ntuple.

                                                              {
  return to<unsigned short>(a_s,a_v);
}
bool inlib::aida::s__fill ( const std::string &  a_s,
int &  a_v 
) [inline]

Definition at line 358 of file aida_ntuple.

                                                   {
  return to<int>(a_s,a_v);
}
bool inlib::aida::s__fill ( const std::string &  a_s,
unsigned int &  a_v 
) [inline]

Definition at line 361 of file aida_ntuple.

                                                            {
  return to<unsigned int>(a_s,a_v);
}
bool inlib::aida::s__fill ( const std::string &  a_s,
int64 &  a_v 
) [inline]

Definition at line 364 of file aida_ntuple.

                                                     {
  return to<int64>(a_s,a_v);
}
bool inlib::aida::s__fill ( const std::string &  a_s,
uint64 &  a_v 
) [inline]

Definition at line 367 of file aida_ntuple.

                                                      {
  return to<uint64>(a_s,a_v);
}
bool inlib::aida::s__fill ( const std::string &  a_s,
float &  a_v 
) [inline]

Definition at line 370 of file aida_ntuple.

                                                     {
  return to<float>(a_s,a_v);
}
bool inlib::aida::s__fill ( const std::string &  a_s,
double &  a_v 
) [inline]

Definition at line 373 of file aida_ntuple.

                                                      {
  return to<double>(a_s,a_v);
}
const std::string& inlib::aida::s_aida_type ( short  ) [inline]

Definition at line 241 of file aida_ntuple.

                                           {
  static const std::string s_v("short");
  return s_v;
}
const std::string& inlib::aida::s_aida_type ( int  ) [inline]

Definition at line 245 of file aida_ntuple.

                                         {
  static const std::string s_v("int");
  return s_v;
}
const std::string& inlib::aida::s_aida_type ( float  ) [inline]

Definition at line 249 of file aida_ntuple.

                                           {
  static const std::string s_v("float");
  return s_v;
}
const std::string& inlib::aida::s_aida_type ( double  ) [inline]

Definition at line 253 of file aida_ntuple.

                                            {
  static const std::string s_v("double");
  return s_v;
}
const std::string& inlib::aida::s_aida_type ( bool  ) [inline]

Definition at line 265 of file aida_ntuple.

                                          {
  static const std::string s_v("boolean");
  return s_v;
}
const std::string& inlib::aida::s_aida_type ( const std::string &  ) [inline]

Definition at line 269 of file aida_ntuple.

                                                      {
  static const std::string s_v("string");
  return s_v;
}
const std::string& inlib::aida::s_aida_type ( int64  ) [inline]

Definition at line 273 of file aida_ntuple.

                                           {
  static const std::string s_v("long");
  return s_v;
}
const std::string& inlib::aida::s_aida_type ( const std::vector< double > &  ) [inline]

Definition at line 277 of file aida_ntuple.

                                                              {
  static const std::string s_v("double[]");
  return s_v;
}
const std::string & inlib::aida::s_aida_type ( unsigned  short) [inline]

not AIDA ! //////////////////////////

Definition at line 290 of file aida_ntuple.

                                                    {
  static const std::string s_v("ushort");
  return s_v;
}
const std::string& inlib::aida::s_aida_type ( uint64  ) [inline]

Definition at line 298 of file aida_ntuple.

                                            {
  static const std::string s_v("ulong");
  return s_v;
}
const std::string& inlib::aida::s_aida_type_ituple ( ) [inline]

Definition at line 282 of file aida_ntuple.

                                             {
  static const std::string s_v("ITuple");
  return s_v;
}
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines