#include <TupleDetail.h>
Inheritance diagram for Tuples::detail::TupleObjImp< HANDLER1, HANDLER2 >:
Public Types | |
typedef NTuple::Item< int > | Int |
basic type for 'integer' items It has the fixed bit-length (32) for all platforms (?) | |
typedef NTuple::Item< float > | Float |
basic type for 'float/double' items It has the fixed bit-length (32) for all platforms (?) | |
typedef NTuple::Item< IOpaqueAddress * > | Address |
basic type for address items | |
typedef NTuple::Array< float > | FArray |
basic type for array of floats | |
typedef NTuple::Matrix< float > | FMatrix |
basic type for matrix of floats | |
typedef unsigned short | MIndex |
typedef std::map< std::string, std::string > | ItemMap |
Public Member Functions | |
TupleObjImp (HANDLER1 handler1, HANDLER2 handler2, const std::string &name, NTuple::Tuple *tuple, const CLID &clid=CLID_ColumnWiseTuple, const Tuples::Type type=Tuples::NTUPLE) | |
constructor | |
virtual StatusCode | Error (const std::string &msg, const StatusCode sc=StatusCode::FAILURE) const |
virtual StatusCode | Warning (const std::string &msg, const StatusCode sc=StatusCode::FAILURE) const |
StatusCode | column (const std::string &name, const int value) |
Set the value for selected tuple column. | |
StatusCode | column (const std::string &name, const int value, const int minv, const int maxv) |
Set the value for selected tuple column. | |
StatusCode | column (const std::string &name, const unsigned int value) |
Set the value for selected tuple column. | |
StatusCode | column (const std::string &name, const long value) |
Set the value for the selected tuple column. | |
StatusCode | column (const std::string &name, const unsigned long value) |
Set the value for selected tuple column. | |
StatusCode | column (const std::string &name, const short value) |
Set the value for selected tuple column. | |
StatusCode | column (const std::string &name, const unsigned short value) |
Set the value for selected tuple column. | |
StatusCode | column (const std::string &name, const char value) |
Set the value for selected tuple column. | |
StatusCode | column (const std::string &name, const unsigned char value) |
Set the value for the selected tuple column. | |
StatusCode | column (const std::string &name, const signed char value) |
Set the value for the selected tuple column. | |
StatusCode | column (const std::string &name, const float value) |
Set the value for selected tuple column. | |
StatusCode | column (const std::string &name, const double value) |
Set the value for the selected tuple column If the column does not exist, it will be automatically created and appended to the tuple. | |
StatusCode | column (const std::string &name, const bool value) |
Set the value for selected tuple column. | |
StatusCode | column (const std::string &name, IOpaqueAddress *address) |
Put IOpaqueAddress in POOL-based NTuple. | |
StatusCode | column (IOpaqueAddress *address) |
Put IOpaqueAddress in NTuple. | |
template<class TYPE> | |
StatusCode | column (const std::string &name, const ROOT::Math::LorentzVector< TYPE > &v) |
Useful shortcut to put LorentzVector directly into N-Tuple:. | |
template<class TYPE, class TAG> | |
StatusCode | column (const std::string &name, const ROOT::Math::DisplacementVector3D< TYPE, TAG > &v) |
Useful shortcut to put 3D-Vector directly into N-Tuple:. | |
template<class TYPE, class TAG> | |
StatusCode | column (const std::string &name, const ROOT::Math::PositionVector3D< TYPE, TAG > &v) |
Useful shortcut to put 3D-Vector directly into N-Tuple:. | |
StatusCode | fill (const char *format...) |
Set the values for several columns simultaneously. | |
template<class DATA> | |
StatusCode | farray (const std::string &name, DATA first, DATA last, const std::string &length, const size_t maxv) |
Add an indexed array (of type float) to N-tuple. | |
template<class DATA> | |
StatusCode | farray (const std::string &name, const DATA &data, const std::string &length, const size_t maxv) |
Add an indexed array (of type float) to N-tuple. | |
template<class FUNCTION, class DATA> | |
StatusCode | farray (const std::string &name, const FUNCTION &function, DATA first, DATA last, const std::string &length, const size_t maxv) |
Put an indexed array into LoKi-style N-Tuple. | |
template<class FUNC1, class FUNC2, class DATA> | |
StatusCode | farray (const std::string &name1, const FUNC1 &func1, const std::string &name2, const FUNC2 &func2, DATA first, DATA last, const std::string &length, const size_t maxv) |
Put two functions from one data array into LoKi-style N-Tuple simultaneously (effective!). | |
template<class FUNC1, class FUNC2, class FUNC3, class DATA> | |
StatusCode | farray (const std::string &name1, const FUNC1 &func1, const std::string &name2, const FUNC2 &func2, const std::string &name3, const FUNC3 &func3, DATA first, DATA last, const std::string &length, const size_t maxv) |
Put three functions from one data array into LoKi-style N-Tuple simultaneously (effective!). | |
template<class FUNC1, class FUNC2, class FUNC3, class FUNC4, class DATA> | |
StatusCode | farray (const std::string &name1, const FUNC1 &func1, const std::string &name2, const FUNC2 &func2, const std::string &name3, const FUNC3 &func3, const std::string &name4, const FUNC4 &func4, DATA first, DATA last, const std::string &length, const size_t maxv) |
Put four functions from one data array into LoKi-style N-Tuple simultaneously (effective!). | |
template<class MATRIX> | |
StatusCode | fmatrix (const std::string &name, const MATRIX &data, size_t rows, const MIndex &cols, const std::string &length, const size_t maxv) |
Fill N-Tuple with data from variable-size matrix. | |
template<class DATA> | |
StatusCode | fmatrix (const std::string &name, DATA first, DATA last, const MIndex &cols, const std::string &length, const size_t maxv) |
Fill N-Tuple with data from variable-size matrix. | |
template<class FUN, class DATA> | |
StatusCode | fmatrix (const std::string &name, FUN funF, FUN funL, DATA first, DATA last, const std::string &length, const size_t maxv) |
fill N-Tuple with matrix of "direct-product" of "data-vector" [first,last) and "function-vector" [funF, funL) | |
template<class KEY, class VALUE> | |
StatusCode | fmatrix (const std::string &name, const GaudiUtils::VectorMap< KEY, VALUE > &info, const std::string &length, const size_t maxv=100) |
shortcut to put "ExtraInfo" fields of major into N-Tuple | |
template<class DATA> | |
StatusCode | array (const std::string &name, DATA first, DATA last) |
fill N-Tuple with fixed-size array | |
template<class ARRAY> | |
StatusCode | array (const std::string &name, const ARRAY &data, const MIndex &length) |
fill N-Tuple with fixed-size array | |
template<class ARRAY> | |
StatusCode | array (const std::string &name, const ARRAY &data) |
fill N-Tuple with fixed-size array | |
template<class TYPE, unsigned int DIM> | |
StatusCode | array (const std::string &name, const ROOT::Math::SVector< TYPE, DIM > &vect) |
shortcut to put SVector into N-tuple: | |
template<class MATRIX> | |
StatusCode | matrix (const std::string &name, const MATRIX &data, const MIndex &rows, const MIndex &cols) |
fill N-Tuple with fixed-size matrix | |
template<class TYPE, unsigned int D1, unsigned int D2, class REP> | |
StatusCode | matrix (const std::string &name, const ROOT::Math::SMatrix< TYPE, D1, D2, REP > &mtrx) |
shortcut to put Smatrix into N-tuple: | |
template<class TYPE> | |
StatusCode | put (const std::string &name, const TYPE *obj) |
The function allows to add almost arbitrary object into N-tuple. | |
StatusCode | write () |
write a record to NTuple | |
const std::string & | name () const |
get the name | |
NTuple::Tuple * | tuple () const |
provide the access to underlying Gaudi N-tuple | |
unsigned long | refCount () const |
return the reference counter | |
unsigned long | addRef () |
add the reference to TupleObj | |
void | release () |
release the reference to TupleObj if reference counter becomes zero, object will be automatically deleted | |
const CLID & | clid () const |
accessor to the N-Tuple CLID | |
Tuples::Type | type () const |
accessor to the N-Tuple type | |
bool | columnWise () const |
column wise NTuple ? | |
bool | rowWise () const |
row wise NTuple ? | |
bool | evtColType () const |
Event collection ? | |
bool | valid () const |
valid pointer to tuple ? | |
bool | invalid () const |
invalid pointer to tuple ? | |
bool | addItem (const std::string &name, const std::string &type) |
add the item name into the list of known items | |
bool | goodItem (const std::string &name) const |
check the uniquness of the name | |
const ItemMap & | items () const |
get the full list of booked items | |
Protected Member Functions | |
virtual | ~TupleObjImp () |
empty protected destructor | |
Private Attributes | |
HANDLER1 | m_handler1 |
HANDLER2 | m_handler2 |
) which supports the semantics
HANDLER obj = .. ; StatusCode obj( msg , sc )
can be used as error handler, e.g.
void print_error ( const std::string& msg , StatusCode sc ) { std::cout << "Error" << msg << " code " << sc.getCode() << std::endl ; } void print_warning ( const std::string& msg , StatusCode sc ) { std::cout << "Warning" << msg << " code " << sc.getCode() << std::endl ; } void print_print ( const std::string& msg , StatusCode sc ) { std::cout << msg << " code " << sc.getCode() << std::endl ; } NTuple::Tuple* tuple = ... ; TupleObj* obj = createTupleObj( print_errror , print_warning , print_print , " my tuple " , ntuple ) ;
Templated helper functions allow to avoid heavy semantics of dealing with explicit type
Few concrete error handlers for dealing with classes, which suports member functions Erorr and Warning ( e.g. class GaudiAlgorithm or class GaudiTool ) are provided
Definition at line 79 of file TupleDetail.h.
typedef NTuple::Item<int> Tuples::TupleObj::Int [inherited] |
basic type for 'integer' items It has the fixed bit-length (32) for all platforms (?)
Definition at line 187 of file TupleObj.h.
typedef NTuple::Item<float> Tuples::TupleObj::Float [inherited] |
basic type for 'float/double' items It has the fixed bit-length (32) for all platforms (?)
Definition at line 192 of file TupleObj.h.
typedef NTuple::Item<IOpaqueAddress*> Tuples::TupleObj::Address [inherited] |
typedef NTuple::Array<float> Tuples::TupleObj::FArray [inherited] |
typedef NTuple::Matrix<float> Tuples::TupleObj::FMatrix [inherited] |
typedef unsigned short Tuples::TupleObj::MIndex [inherited] |
Definition at line 204 of file TupleObj.h.
typedef std::map<std::string,std::string> Tuples::TupleObj::ItemMap [inherited] |
Definition at line 207 of file TupleObj.h.
Tuples::detail::TupleObjImp< HANDLER1, HANDLER2 >::TupleObjImp | ( | HANDLER1 | handler1, | |
HANDLER2 | handler2, | |||
const std::string & | name, | |||
NTuple::Tuple * | tuple, | |||
const CLID & | clid = CLID_ColumnWiseTuple , |
|||
const Tuples::Type | type = Tuples::NTUPLE | |||
) | [inline] |
constructor
handler1 | error handler | |
handler2 | warning handler | |
name | Name of the NTuple | |
tuple | NTuple itself | |
clid | NTuple CLID | |
type | NTuple type |
Definition at line 90 of file TupleDetail.h.
00096 : TupleObj ( name , tuple , clid, type ) 00097 , m_handler1 ( handler1 ) 00098 , m_handler2 ( handler2 ) 00099 {};
virtual Tuples::detail::TupleObjImp< HANDLER1, HANDLER2 >::~TupleObjImp | ( | ) | [inline, protected, virtual] |
virtual StatusCode Tuples::detail::TupleObjImp< HANDLER1, HANDLER2 >::Error | ( | const std::string & | msg, | |
const StatusCode | sc = StatusCode::FAILURE | |||
) | const [inline, virtual] |
Implements Tuples::TupleObj.
Definition at line 103 of file TupleDetail.h.
00105 { m_handler1 ( name() + msg , sc ) ; return sc ; }
virtual StatusCode Tuples::detail::TupleObjImp< HANDLER1, HANDLER2 >::Warning | ( | const std::string & | msg, | |
const StatusCode | sc = StatusCode::FAILURE | |||
) | const [inline, virtual] |
Implements Tuples::TupleObj.
Definition at line 108 of file TupleDetail.h.
00110 { m_handler2 ( name() + msg , sc ) ; return sc ; }
StatusCode Tuples::TupleObj::column | ( | const std::string & | name, | |
const int | value | |||
) | [inline, inherited] |
Set the value for selected tuple column.
If the column does not exist yet, it will be automatically created and appended to the tuple
int number = ... ; tuple->column("num", number );
name | name of the column | |
value | value of tve variable |
Definition at line 246 of file TupleObj.h.
00248 { 00249 if ( invalid() ) { return InvalidTuple ; } 00250 Int* item = ints( name ) ; 00251 if ( 0 == item ) { return InvalidColumn ; } 00252 *item = value ; 00253 return StatusCode::SUCCESS ; 00254 }
StatusCode Tuples::TupleObj::column | ( | const std::string & | name, | |
const int | value, | |||
const int | minv, | |||
const int | maxv | |||
) | [inline, inherited] |
Set the value for selected tuple column.
If the column does not exist yet, it will be automatically created and appended to the tuple
long number = ... ; tuple->column("num", number );
name | name of the column | |
value | value of tve variable | |
minv | minimum value of the variable | |
maxv | maximum value of the variable |
Definition at line 273 of file TupleObj.h.
00277 { 00278 if ( invalid() ) { return InvalidTuple ; } 00279 Int* item = ints ( name , minv , maxv ) ; 00280 if ( 0 == item ) { return InvalidColumn ; } 00281 *item = value ; 00282 return StatusCode::SUCCESS ; 00283 }
StatusCode Tuples::TupleObj::column | ( | const std::string & | name, | |
const unsigned int | value | |||
) | [inline, inherited] |
Set the value for selected tuple column.
If the column does not exist yet, it will be automatically created and appended to the tuple
int number = ... ; tuple->column("num", number );
name | name of the column | |
value | value of tve variable |
Definition at line 302 of file TupleObj.h.
00304 { 00305 StatusCode sc1 = StatusCode::SUCCESS ; 00306 static const unsigned int s_max = std::numeric_limits<int>::max() ; 00307 if ( s_max < value ) 00308 { sc1 = Warning 00309 (" column('" + name + "'): truncate unsigned int" , TruncateValue ) ; } 00310 const int val = (int) value ; 00311 StatusCode sc2 = column ( name , val ) ; 00312 return sc2.isFailure() ? sc2 : sc1 ; 00313 }
StatusCode Tuples::TupleObj::column | ( | const std::string & | name, | |
const long | value | |||
) | [inline, inherited] |
Set the value for the selected tuple column.
If the column does not exist yet, it will be automatically created and appended to the tuple
name | the name of the column | |
value | the value of the variable |
Definition at line 331 of file TupleObj.h.
00333 { 00334 StatusCode sc1 = StatusCode::SUCCESS ; 00335 if ( sizeof(int) != sizeof(long) 00336 && ( std::numeric_limits<int>::max() < value || 00337 std::numeric_limits<int>::min() > value ) ) 00338 { sc1 = Warning (" column('" + name + "'): truncate long value" , 00339 TruncateValue ) ; } 00340 const int val = (int) value ; 00341 StatusCode sc2 = column ( name , val ) ; 00342 return sc2.isFailure() ? sc2 : sc1 ; 00343 }
StatusCode Tuples::TupleObj::column | ( | const std::string & | name, | |
const unsigned long | value | |||
) | [inline, inherited] |
Set the value for selected tuple column.
If the column does not exist yet, it will be automatically created and appended to the tuple
name | the name of the column | |
value | the value of the variable |
Definition at line 361 of file TupleObj.h.
00363 { 00364 StatusCode sc1 = StatusCode::SUCCESS ; 00365 static const unsigned long s_max = std::numeric_limits<int>::max() ; 00366 if ( sizeof (int) != sizeof (unsigned long) && s_max < value ) 00367 { sc1 = Warning (" column('" + name + "'): truncate unsigned long value" , 00368 TruncateValue ) ; } 00369 const int val = (int) value ; 00370 StatusCode sc2 = column ( name , val ) ; 00371 return sc2.isFailure() ? sc2 : sc1 ; 00372 }
StatusCode Tuples::TupleObj::column | ( | const std::string & | name, | |
const short | value | |||
) | [inline, inherited] |
Set the value for selected tuple column.
If the column does not exist yet, it will be automatically created and appended to the tuple
name | the name of the column | |
value | the value of the variable |
Definition at line 389 of file TupleObj.h.
00391 { 00392 return column 00393 ( name , 00394 value , 00395 std::numeric_limits<short>::min() , 00396 std::numeric_limits<short>::max() ) ; 00397 }
StatusCode Tuples::TupleObj::column | ( | const std::string & | name, | |
const unsigned short | value | |||
) | [inline, inherited] |
Set the value for selected tuple column.
If the column does not exist yet, it will be automatically created and appended to the tuple
name | the name of the column | |
value | the value of the variable |
Definition at line 414 of file TupleObj.h.
00416 { 00417 return column 00418 ( name , 00419 value , 00420 std::numeric_limits<unsigned short>::min() , 00421 std::numeric_limits<unsigned short>::max() ) ; 00422 }
StatusCode Tuples::TupleObj::column | ( | const std::string & | name, | |
const char | value | |||
) | [inline, inherited] |
Set the value for selected tuple column.
If the column does not exist yet, it will be automatically created and appended to the tuple
name | the name of the column | |
value | the value of tve variable |
Definition at line 439 of file TupleObj.h.
00441 { 00442 return column 00443 ( name , 00444 value , 00445 std::numeric_limits<char>::min() , 00446 std::numeric_limits<char>::max() ) ; 00447 }
StatusCode Tuples::TupleObj::column | ( | const std::string & | name, | |
const unsigned char | value | |||
) | [inline, inherited] |
Set the value for the selected tuple column.
If the column does not exist yet, it will be automatically created and appended to the tuple
unsigned char number = ... ; tuple->column("num", number );
name | the name of the column | |
value | the value of tve variable |
Definition at line 464 of file TupleObj.h.
00466 { 00467 return column 00468 ( name , 00469 value , 00470 std::numeric_limits<unsigned char>::min() , 00471 std::numeric_limits<unsigned char>::max() ) ; 00472 }
StatusCode Tuples::TupleObj::column | ( | const std::string & | name, | |
const signed char | value | |||
) | [inline, inherited] |
Set the value for the selected tuple column.
If the column does not exist yet, it will be automatically created and appended to the tuple
signed char number = ... ; tuple->column("num", number );
name | the name of the column | |
value | the value of tve variable |
Definition at line 489 of file TupleObj.h.
00491 { 00492 return column 00493 ( name , 00494 value , 00495 std::numeric_limits<signed char>::min() , 00496 std::numeric_limits<signed char>::max() ) ; 00497 }
StatusCode Tuples::TupleObj::column | ( | const std::string & | name, | |
const float | value | |||
) | [inline, inherited] |
Set the value for selected tuple column.
If column does not exist, it will be automatically created and appended to the tuple
// const float mass = ... ; tuple->column("m", mass ); //
name | the name of the column | |
value | the value of the variable |
Definition at line 516 of file TupleObj.h.
00518 { 00519 if ( invalid() ) { return InvalidTuple ; } 00520 Float* item = floats ( name ) ; 00521 if ( 0 == item ) { return InvalidColumn ; } 00522 *item = value ; 00523 return StatusCode::SUCCESS ; 00524 }
StatusCode Tuples::TupleObj::column | ( | const std::string & | name, | |
const double | value | |||
) | [inline, inherited] |
Set the value for the selected tuple column If the column does not exist, it will be automatically created and appended to the tuple.
// const double mass = ... ; tuple->column("m", mass ); //
name | the name of the column | |
value | the value of the variable |
Definition at line 542 of file TupleObj.h.
00544 { 00545 StatusCode sc1 = StatusCode::SUCCESS ; 00546 static const double s_max = std::numeric_limits<float>::max() ; 00547 static const double s_min = -1 * std::numeric_limits<float>::max() ; 00548 if ( s_max < value || s_min > value ) 00549 { sc1 = Warning (" column('" + name + "'): truncate double value " , 00550 TruncateValue ) ; } 00551 const float val = (float) value ; 00552 StatusCode sc2 = column ( name , val ) ; 00553 return sc2.isFailure() ? sc2 : sc1 ; 00554 }
StatusCode Tuples::TupleObj::column | ( | const std::string & | name, | |
const bool | value | |||
) | [inline, inherited] |
Set the value for selected tuple column.
If the column does not exist yet, it will be automatically create and appended to the tuple
tuple->column( "empty" , v.empty() );
name | the name of the column | |
value | the value of the variable |
Definition at line 570 of file TupleObj.h.
StatusCode Tuples::TupleObj::column | ( | const std::string & | name, | |
IOpaqueAddress * | address | |||
) | [inherited] |
Put IOpaqueAddress in POOL-based NTuple.
If the column does not exist, it will be automatically created and appended to the tuple.
IOpaqueAddress* address = ... ; tuple->column( "Address", address );
name | name of the column ("Address" is a recommended convention!) | |
address | IOpaqueAddress |
Definition at line 282 of file TupleObj.cpp.
00284 { 00285 if ( invalid () ) { return InvalidTuple ; } 00286 if ( !evtColType () ) { return InvalidOperation ; } 00287 if ( 0 == address ) 00288 { return Error ( "column('" + name + 00289 "') IOpaqueAddress* is NULL!" , InvalidObject ) ; } 00290 Address* item = addresses( name ); 00291 if ( 0 == item ) { return InvalidItem ; } 00292 *item = address ; 00293 return StatusCode::SUCCESS ; 00294 }
StatusCode Tuples::TupleObj::column | ( | IOpaqueAddress * | address | ) | [inherited] |
Put IOpaqueAddress in NTuple.
If the column does not exist, it will be automatically created and appended to the tuple. The column name is set to be "Address"
IOpaqueAddress* address = ... ; tuple->column ( address );
address | IOpaqueAddress |
Definition at line 299 of file TupleObj.cpp.
00300 { 00301 return column ("Address" , address ) ; 00302 }
StatusCode Tuples::TupleObj::column | ( | const std::string & | name, | |
const ROOT::Math::LorentzVector< TYPE > & | v | |||
) | [inline, inherited] |
Useful shortcut to put LorentzVector directly into N-Tuple:.
const LHCb::Particle* B = ... Tuple tuple = nTuple("My N-Tuple") ; // put 4-vector of B-candidate into N-tuple: tuple -> column ("B" , B->momentum() ) ;
Definition at line 1681 of file TupleObj.h.
01683 { 01684 if ( invalid() ) { return InvalidTuple ; } 01685 // fill all separate columns: 01686 StatusCode sc1 = this -> column ( name + "E" , v.E () ) ; 01687 StatusCode sc2 = this -> column ( name + "X" , v.Px () ) ; 01688 StatusCode sc3 = this -> column ( name + "Y" , v.Py () ) ; 01689 StatusCode sc4 = this -> column ( name + "Z" , v.Pz () ) ; 01690 return 01691 sc1.isFailure () ? sc1 : 01692 sc2.isFailure () ? sc2 : 01693 sc3.isFailure () ? sc3 : 01694 sc4.isFailure () ? sc4 : StatusCode(StatusCode::SUCCESS) ; 01695 }
StatusCode Tuples::TupleObj::column | ( | const std::string & | name, | |
const ROOT::Math::DisplacementVector3D< TYPE, TAG > & | v | |||
) | [inline, inherited] |
Useful shortcut to put 3D-Vector directly into N-Tuple:.
const LHCb::Vertex* V = ... Tuple tuple = nTuple("My N-Tuple") ; // put vertex position into N-tuple: tuple -> column ("B" , B->position() ) ;
fill separate columns
Definition at line 1715 of file TupleObj.h.
01717 { 01718 if ( invalid() ) { return InvalidTuple ; } 01720 StatusCode sc1 = this -> column ( name + "X" , v.X () ) ; 01721 StatusCode sc2 = this -> column ( name + "Y" , v.Y () ) ; 01722 StatusCode sc3 = this -> column ( name + "Z" , v.Z () ) ; 01723 return 01724 sc1.isFailure () ? sc1 : 01725 sc2.isFailure () ? sc2 : 01726 sc3.isFailure () ? sc3 : StatusCode(StatusCode::SUCCESS) ; 01727 }
StatusCode Tuples::TupleObj::column | ( | const std::string & | name, | |
const ROOT::Math::PositionVector3D< TYPE, TAG > & | v | |||
) | [inline, inherited] |
Useful shortcut to put 3D-Vector directly into N-Tuple:.
const LHCb::Vertex* V = ... Tuple tuple = nTuple("My N-Tuple") ; // put vertex position into N-tuple: tuple -> column ("B" , B->position() ) ;
fill separate columns
Definition at line 1747 of file TupleObj.h.
01749 { 01750 if ( invalid() ) { return InvalidTuple ; } 01752 StatusCode sc1 = this -> column ( name + "X" , v.X () ) ; 01753 StatusCode sc2 = this -> column ( name + "Y" , v.Y () ) ; 01754 StatusCode sc3 = this -> column ( name + "Z" , v.Z () ) ; 01755 return 01756 sc1.isFailure () ? sc1 : 01757 sc2.isFailure () ? sc2 : 01758 sc3.isFailure () ? sc3 : StatusCode(StatusCode::SUCCESS) ; 01759 }
StatusCode Tuples::TupleObj::fill | ( | const char * | format... | ) | [inherited] |
Set the values for several columns simultaneously.
Number of columns is arbitrary, but it should not be less than number of blank or comma separated tags in format
string. Non-existing columns will be automatically created and appended to the ntuple.
double r1 , r2 , r3 , r4 , mass , length ; tuple->fill( "var1 var2, radius rad4 mass len" , r1, r2, r3, r4, mass, length);
double
format | blank-separated list of variables, followed by variable number of arguments. |
double
numbers decode arguments
Definition at line 252 of file TupleObj.cpp.
00253 { 00254 // check the underlying tuple 00255 if ( invalid() ) { return InvalidTuple ; } 00256 // decode format string into tokens 00257 Tokens tokens ; 00258 tokenize( format , tokens , " ,;" ); 00259 if ( tokens.empty() ) { return StatusCode::SUCCESS ; } 00261 va_list valist ; 00262 va_start( valist , format ) ; 00263 // loop over all tokens 00264 StatusCode status = StatusCode::SUCCESS ; 00265 for( Tokens::const_iterator token = tokens.begin() ; 00266 tokens.end() != token && status.isSuccess() ; ++token ) 00267 { 00268 const double val = va_arg( valist , double ); 00269 status = column( *token , val ); 00270 if( status.isFailure() ) 00271 { Error ( " fill(): Can not add column '" + *token + "' " ) ; } 00272 } 00273 // mandatory !!! 00274 va_end( valist ); 00275 // 00276 return status ; 00277 }
StatusCode Tuples::TupleObj::farray | ( | const std::string & | name, | |
DATA | first, | |||
DATA | last, | |||
const std::string & | length, | |||
const size_t | maxv | |||
) | [inline, inherited] |
Add an indexed array (of type float) to N-tuple.
The method is not VERY efficient since it copies the data.
std::vector<double> values = ... ; tuple->farray( "Values" , // item name values.begin () , // begin of sequence values.end () , // end of sequence "Length" , // name of "length" item 10000 ) ;
The name of "length" item can be reused for several arrays. The last assignement "wins"
std::vector<double> val1 = ... ; std::vector<double> val2 = ... ; tuple->farray( "Val1" , // item name val1.begin () , // begin of sequence val1.end () , // end of sequence "Length" , // name of "length" item 10000 ) ; // maximal length tuple->farray( "Val2" , // item name val2.begin () , // begin of sequence val2.end () , // end of sequence "Length" , // name of "length" item 10000 ) ; // maximal length
Any sequence [first:last[
of objects which can be converted to type float
can be used as input data, e.g. std::vector<double>
, std::vector<float>
, plain C-array, or whatever else
name | name of N-tuple item | |
first | begin of data sequence | |
last | end of data sequence | |
length | name of "length" item | |
maxv | maximal length of array |
fill the array
Definition at line 696 of file TupleObj.h.
00701 { 00702 if ( invalid () ) { return InvalidTuple ; } 00703 if ( rowWise () ) { return InvalidOperation ; } 00704 00705 // adjust the length 00706 if( first + maxv < last ) 00707 { 00708 Warning(" farray('"+name+"'): array is overflow, skip extra items") ; 00709 last = first + maxv ; 00710 }; 00711 00712 // get the length item 00713 Int* len = ints( length , 0 , maxv ) ; 00714 if( 0 == len ) { return InvalidColumn; } 00715 00716 // adjust the length item 00717 *len = last - first ; 00718 00719 // get the array itself 00720 FArray* var = fArray ( name , len ) ; 00721 if( 0 == var ) { return InvalidColumn ; } 00722 00724 size_t index = 0 ; 00725 for( ; first != last ; ++first ) 00726 { (*var)[ index ] = (float)(*first) ; ++index ; } 00727 00728 return StatusCode::SUCCESS ; 00729 }
StatusCode Tuples::TupleObj::farray | ( | const std::string & | name, | |
const DATA & | data, | |||
const std::string & | length, | |||
const size_t | maxv | |||
) | [inline, inherited] |
Add an indexed array (of type float) to N-tuple.
it is just a small adaptor for the previous method
std::vector<double> values = ... ; tuple->farray( "Values" , // item name values , // sequence "Length" , // name of "length" item 10000 ) ;
The name of "length" item can be reused for several arrays. The last assignement "wins"
std::vector<double> val1 = ... ; std::vector<double> val2 = ... ; tuple->farray( "Val1" , // item name val1 , // begin of sequence "Length" , // name of "length" item 10000 ) ; // maximal length tuple->farray( "Val2" , // item name val2 , // begin of sequence "Length" , // name of "length" item 10000 ) ; // maximal length
Any sequence which provides begin()
and end()
methods can be used.
name | name of N-tuple item | |
data | data sequence | |
length | name of "length" item | |
maxv | maximal length of array |
Definition at line 774 of file TupleObj.h.
StatusCode Tuples::TupleObj::farray | ( | const std::string & | name, | |
const FUNCTION & | function, | |||
DATA | first, | |||
DATA | last, | |||
const std::string & | length, | |||
const size_t | maxv | |||
) | [inline, inherited] |
Put an indexed array into LoKi-style N-Tuple.
std::vector<double> data = ... ; Tuple tuple = ntuple( "My Ntuple" ); tuple->farray( "data" , // data item name sqrt , // "function" to be applied data.begin () , // begin of data sequence data.end () , // end of data sequence "length" , // name of "length" tuple item 10000 ) ; // maximal array length
Since the method is templated, one can use arbitrary combinations of "sequences" and "functions", e.g. one can directly manipulate with complex objects. The only on ething is required - the result of FUNCTION(*DATA)
formal operation MUST be convertible to type float
// some container of particles. ParticleVector particles = ... ; Tuple tuple = ntuple( "My Ntuple" ); // put the transverse momentum of all particles into N-Tuple tuple->farray( "pt" , // data item name PT , // function object particles.begin () , // begin of data sequence particles.end () , // end of data sequence "num" , // name of "length" tuple item 10000 ) ; // maximal array length // create the appropriate function object Fun fun = Q / P ; // put Q/P of all particles into N-Tuple tuple->farray( "qp" , // data item name fun , // function object particles.begin () , // begin of data sequence particles.end () , // end of data sequence "num" , // name of "length" tuple item 10000 ) ; // maximal array length
name | tuple item name | |
function | function to be applied | |
first | begin of data sequence | |
last | end of data sequence | |
length | name of "length" tupel name | |
maxv | maximal length of the array |
Definition at line 843 of file TupleObj.h.
00849 { 00850 if ( invalid () ) { return InvalidTuple ; } 00851 if ( rowWise () ) { return InvalidOperation ; } 00852 00853 // adjust the length 00854 if( first + maxv < last ) 00855 { 00856 Warning(" farray('" 00857 + name + "'): array is overflow, skip extra entries") ; 00858 last = first + maxv ; 00859 }; 00860 00861 // get the length item 00862 Int* len = ints( length , 0 , maxv ) ; 00863 if( 0 == len ) { return InvalidColumn ; } 00864 00865 // adjust the length 00866 *len = last - first ; 00867 00868 // get the array itself 00869 FArray* var = fArray ( name , len ) ; 00870 if( 0 == var ) { return InvalidColumn ; } 00871 00872 // fill the array 00873 size_t index = 0 ; 00874 for( ; first != last ; ++first ) 00875 { (*var)[ index ] = function( *first ) ; ++index ; } 00876 00877 return StatusCode::SUCCESS ; 00878 }
StatusCode Tuples::TupleObj::farray | ( | const std::string & | name1, | |
const FUNC1 & | func1, | |||
const std::string & | name2, | |||
const FUNC2 & | func2, | |||
DATA | first, | |||
DATA | last, | |||
const std::string & | length, | |||
const size_t | maxv | |||
) | [inline, inherited] |
Put two functions from one data array into LoKi-style N-Tuple simultaneously (effective!).
std::vector<double> data = ... ; Tuple tuple = ntuple( "My Ntuple" ); tuple->farray( "sqr" , // the first data item name sqrt , // "func1" to be used "sinus" , // the second data item name sin , // "func2" to be used data.begin () , // begin of data sequence data.end () , // end of data sequence "length" , // name of "length" tuple item 10000 ) ; // maximal array length
name1 | the first tuple item name | |
func1 | the first function to be applied | |
name2 | the second tuple item name | |
func2 | the second function to be applied | |
first | begin of data sequence | |
last | end of data sequence | |
length | name of "length" tupel name | |
maxv | maximal length of the array |
Definition at line 912 of file TupleObj.h.
00920 { 00921 if ( invalid () ) { return InvalidTuple ; } 00922 if ( rowWise () ) { return InvalidOperation ; } 00923 00924 // adjust the lenfth 00925 if( first + maxv < last ) 00926 { 00927 Warning(" farray('" 00928 + name1 + "," 00929 + name2 + "'): array is overflow, skip extra entries") ; 00930 Warning(" farray('"+name1+"'): array is overflow, skip extra items") ; 00931 last = first + maxv ; 00932 }; 00933 00934 // get the length item 00935 Int* len = ints ( length , 0 , maxv ) ; 00936 if ( 0 == len ) { return InvalidColumn ; } 00937 00938 // adjust the length 00939 *len = last - first ; 00940 00941 // get the array itself 00942 FArray* var1 = fArray ( name1 , len ) ; 00943 if ( 0 == var1 ) { return InvalidColumn ; } 00944 00945 // get the array itself 00946 FArray* var2 = fArray ( name2 , len ) ; 00947 if ( 0 == var2 ) { return InvalidColumn ; } 00948 00949 // fill the array 00950 size_t index = 0 ; 00951 for( ; first != last ; ++first ) 00952 { 00953 ( *var1 ) [ index ] = func1 ( *first ) ; 00954 ( *var2 ) [ index ] = func2 ( *first ) ; 00955 ++index ; 00956 } 00957 00958 return StatusCode::SUCCESS ; 00959 }
StatusCode Tuples::TupleObj::farray | ( | const std::string & | name1, | |
const FUNC1 & | func1, | |||
const std::string & | name2, | |||
const FUNC2 & | func2, | |||
const std::string & | name3, | |||
const FUNC3 & | func3, | |||
DATA | first, | |||
DATA | last, | |||
const std::string & | length, | |||
const size_t | maxv | |||
) | [inline, inherited] |
Put three functions from one data array into LoKi-style N-Tuple simultaneously (effective!).
std::vector<double> data = ... ; Tuple tuple = ntuple( "My Ntuple" ); tuple->farray( "sqr" , // the first data item name sqrt , // "func1" to be used "sinus" , // the second data item name sin , // "func2" to be used "tan" , // the third data item name tan , // "func3" to be used data.begin () , // begin of data sequence data.end () , // end of data sequence "length" , // name of "length" tuple item 10000 ) ; // maximal array length
name1 | the first tuple item name | |
func1 | the first function to be applied | |
name2 | the second tuple item name | |
func2 | the second function to be applied | |
name3 | the third tuple item name | |
func3 | the third function to be applied | |
first | begin of data sequence | |
last | end of data sequence | |
length | name of "length" tupel name | |
maxv | maximal length of the array |
Definition at line 998 of file TupleObj.h.
01008 { 01009 if ( invalid () ) { return InvalidTuple ; } 01010 if ( rowWise () ) { return InvalidOperation ; } 01011 01012 // adjust the lenfth 01013 if( first + maxv < last ) 01014 { 01015 Warning(" farray('" 01016 + name1 + "," 01017 + name2 + "," 01018 + name3 + "'): array is overflow, skip extra entries") ; 01019 last = first + maxv ; 01020 }; 01021 01022 // get the length item 01023 Int* len = ints ( length , 0 , maxv ) ; 01024 if( 0 == len ) { return InvalidColumn ; } 01025 01026 // adjust the length 01027 *len = last - first ; 01028 01029 // get the array itself 01030 FArray* var1 = fArray ( name1 , len ) ; 01031 if( 0 == var1 ) { return InvalidColumn ; } 01032 01033 // get the array itself 01034 FArray* var2 = fArray ( name2 , len ) ; 01035 if( 0 == var2 ) { return InvalidColumn ; } 01036 01037 // get the array itself 01038 FArray* var3 = fArray ( name3 , len ) ; 01039 if( 0 == var3 ) { return InvalidColumn ; } 01040 01041 // fill the array 01042 size_t index = 0 ; 01043 for( ; first != last ; ++first ) 01044 { 01045 ( *var1 ) [ index ] = (float)func1 ( *first ) ; 01046 ( *var2 ) [ index ] = (float)func2 ( *first ) ; 01047 ( *var3 ) [ index ] = (float)func3 ( *first ) ; 01048 ++index ; 01049 } 01050 return StatusCode::SUCCESS ; 01051 }
StatusCode Tuples::TupleObj::farray | ( | const std::string & | name1, | |
const FUNC1 & | func1, | |||
const std::string & | name2, | |||
const FUNC2 & | func2, | |||
const std::string & | name3, | |||
const FUNC3 & | func3, | |||
const std::string & | name4, | |||
const FUNC4 & | func4, | |||
DATA | first, | |||
DATA | last, | |||
const std::string & | length, | |||
const size_t | maxv | |||
) | [inline, inherited] |
Put four functions from one data array into LoKi-style N-Tuple simultaneously (effective!).
std::vector<double> data = ... ; Tuple tuple = ntuple( "My Ntuple" ); tuple->farray( "sqr" , // the first data item name sqrt , // "func1" to be used "sinus" , // the second data item name sin , // "func2" to be used "tan" , // the third data item name tan , // "func3" to be used "tanh" , // tanh , // data.begin () , // begin of data sequence data.end () , // end of data sequence "length" , // name of "length" tuple item 10000 ) ; // maximal array length
name1 | the first tuple item name | |
func1 | the first function to be applied | |
name2 | the second tuple item name | |
func2 | the second function to be applied | |
name3 | the third tuple item name | |
func3 | the third function to be applied | |
name4 | the fourthtuple item name | |
func4 | the fourth function to be applied | |
first | begin of data sequence | |
last | end of data sequence | |
length | name of "length" tuple name | |
maxv | maximal length of the array |
Definition at line 1093 of file TupleObj.h.
01105 { 01106 if ( invalid () ) { return InvalidTuple ; } 01107 if ( rowWise () ) { return InvalidOperation ; } 01108 01109 // adjust the lenfth 01110 if( first + maxv < last ) 01111 { 01112 Warning(" farray('" 01113 + name1 + "," 01114 + name2 + "," 01115 + name3 + "," 01116 + name4 + "'): array is overflow, skip extra entries") ; 01117 last = first + maxv ; 01118 }; 01119 01120 // get the length item 01121 Int* len = ints ( length , 0 , maxv ) ; 01122 if( 0 == len ) { return InvalidColumn ; } 01123 01124 // adjust the length 01125 *len = last - first ; 01126 01127 // get the array itself 01128 FArray* var1 = fArray ( name1 , len ) ; 01129 if( 0 == var1 ) { return InvalidColumn ; } 01130 01131 // get the array itself 01132 FArray* var2 = fArray ( name2 , len ) ; 01133 if( 0 == var2 ) { return InvalidColumn ; } 01134 01135 // get the array itself 01136 FArray* var3 = fArray ( name3 , len ) ; 01137 if( 0 == var3 ) { return InvalidColumn ; } 01138 01139 // get the array itself 01140 FArray* var4 = fArray ( name4 , len ) ; 01141 if( 0 == var4 ) { return InvalidColumn ; } 01142 01143 // fill the array 01144 size_t index = 0 ; 01145 for( ; first != last ; ++first ) 01146 { 01147 ( *var1 ) [ index ] = static_cast<float> ( func1 ( *first ) ); 01148 ( *var2 ) [ index ] = static_cast<float> ( func2 ( *first ) ); 01149 ( *var3 ) [ index ] = static_cast<float> ( func3 ( *first ) ); 01150 ( *var4 ) [ index ] = static_cast<float> ( func4 ( *first ) ); 01151 ++index ; 01152 } 01153 01154 return StatusCode::SUCCESS ; 01155 }
StatusCode Tuples::TupleObj::fmatrix | ( | const std::string & | name, | |
const MATRIX & | data, | |||
size_t | rows, | |||
const MIndex & | cols, | |||
const std::string & | length, | |||
const size_t | maxv | |||
) | [inline, inherited] |
Fill N-Tuple with data from variable-size matrix.
"Matrix" could be of any type, which supports data[iRow][iCol] indexing, e.g.
typedef std::vector<double> Row ; typedef std::vector<Row> Mtrx ; // number of columns (fixed!) const size_t numCols = 5 ; // maximal number of rows const size_t maxRows = 300 ; // number of rows (variable) size_t numRows = .... ; ... tuple -> fMatrix ( "mtrx" , // "column" name mtrx , // matrix numRows , // number of rows (variable!) numCols , // number of columns (fixed) "Length" , // name for "lenghth" column maxRows ) ; // maximal number of columns
CLHEP::HepMatrix mtrx = ... ; ... tuple -> fMatrix ( "mtrx" , // "column" name mtrx , // matrix mtrx.num_row() , // number of rows (variable!) mtrx.num_col() , // number of columns (fixed) "Length" , // name for "lenghth" column maxRows ) ; // maximal number of columns
name | entry name in N-Tuple | |
data | matrix itself | |
rows | number of rows of matrix (variable) | |
cols | number of columns of matrix (fixed) | |
length | entry name in NTuple for number of matrix column | |
maxv | maximal number of rows in matrix |
fill the matrix
Definition at line 1210 of file TupleObj.h.
01216 { 01217 if ( invalid () ) { return InvalidTuple ; } 01218 if ( rowWise () ) { return InvalidOperation ; } 01219 01220 // adjust the length 01221 if ( rows >= maxv ) 01222 { 01223 Warning ( " fmatrix('"+name+"'): matrix is overflow, skip extra items") ; 01224 rows = ( 0 < maxv ) ? ( maxv - 1 ) : 0 ; 01225 }; 01226 01227 // get the length item 01228 Int* len = ints( length , 0 , maxv ) ; 01229 if ( 0 == len ) { return InvalidColumn; } 01230 01231 // adjust the length item 01232 *len = rows ; 01233 01234 // get the array itself 01235 FMatrix* var = fMatrix ( name , len , cols ) ; 01236 if ( 0 == var ) { return InvalidColumn ; } 01237 01239 for ( size_t iCol = 0 ; iCol < cols ; ++iCol ) 01240 { 01241 for ( MIndex iRow = 0 ; iRow < rows ; ++iRow ) 01242 { (*var)[ iRow ] [ iCol ] = (float)(data[ iRow ][ iCol ]) ; } 01243 }; 01244 01245 return StatusCode::SUCCESS ; 01246 }
StatusCode Tuples::TupleObj::fmatrix | ( | const std::string & | name, | |
DATA | first, | |||
DATA | last, | |||
const MIndex & | cols, | |||
const std::string & | length, | |||
const size_t | maxv | |||
) | [inline, inherited] |
Fill N-Tuple with data from variable-size matrix.
"Matrix" could be of any type, which supports iteration from the first column to the last column and for each iterating column supports the indexing: (*first)[iCol]
typedef std::vector<double> Row ; typedef std::vector<Row> Mtrx ; // number of rows (fixed!) const size_t numRows = 5 ; // maximal number of columns const size_t maxCols = 300 ; // number of columns (variable) size_t numCols = .... ; ... tuple -> fMatrix ( "mtrx" , // entry name mtrx.begin() , // first row of matrix mtrx.end () , // last row of matrix numCols , // number of columns (fixed!) "Length" , // name for "lenght" column maxRows ) ; // maximal number of rows
name | entry name in N-Tuple | |
first | iterator for the first row of matrix | |
last | iterator for the last row of matrix | |
cols | number of columns for matrix (fixed!) | |
length | entry name in NTuple for number of matrix column | |
maxv | maximal number of rows in matrix |
fill the matrix
Definition at line 1285 of file TupleObj.h.
01291 { 01292 if ( invalid () ) { return InvalidTuple ; } 01293 if ( rowWise () ) { return InvalidOperation ; } 01294 01295 // adjust the length 01296 if ( first + maxv < last ) 01297 { 01298 Warning(" fmatrix('"+name+"'): matrix is overflow, skip extra items") ; 01299 last = first + maxv ; 01300 }; 01301 01302 // get the length item 01303 Int* len = ints( length , 0 , maxv ) ; 01304 if ( 0 == len ) { return InvalidColumn; } 01305 01306 // adjust the length item 01307 *len = last - first ; 01308 01309 // get the array itself 01310 FMatrix* var = fMatrix ( name , len , cols ) ; 01311 if ( 0 == var ) { return InvalidColumn ; } 01312 01314 size_t iRow = 0 ; 01315 for ( ; first != last ; ++first ) 01316 { 01317 // 01318 for ( MIndex iCol = 0 ; iCol < cols ; ++iCol ) 01319 { (*var)[ iRow ] [ iCol ] = (float)((*first)[ iCol ]) ; } 01320 // 01321 ++iRow ; 01322 }; 01323 01324 return StatusCode::SUCCESS ; 01325 }
StatusCode Tuples::TupleObj::fmatrix | ( | const std::string & | name, | |
FUN | funF, | |||
FUN | funL, | |||
DATA | first, | |||
DATA | last, | |||
const std::string & | length, | |||
const size_t | maxv | |||
) | [inline, inherited] |
fill N-Tuple with matrix of "direct-product" of "data-vector" [first,last) and "function-vector" [funF, funL)
The elements of effective matrix are:
mtrx[iCol][iRow] = (*(funF+iRow))( *(first+iCol) )
typedef std::vector<double> Array ; Array array = ... ; typedef double (*fun)( double ) ; typedef std::vector<fun> Funs ; Funs funs ; funs.push_back( sin ) ; funs.push_back( cos ) ; funs.push_back( tan ) ; funs.push_back( sinh ) ; funs.push_back( cosh ) ; funs.push_back( tanh ) ; tuple->fmatrix ( "mtrx" , // N-Tuple entry name funs.begin () , // begin of "function-vector" funs.end () , // end of "function-vector" array.begin () , // begin of "data-vector" array.end () , // end of "data-vector" "Length" , 100 ) ;
This method is very convinient e.g. for using within LoKi:
typedef std::vector<Fun> VctFun ; // sequence of Particles Range particles = .... ; // vector of functions: VctFun funs ; funs.push_back( E / GeV ) ; funs.push_back( PX / GeV ) ; funs.push_back( PY / GeV ) ; funs.push_back( PZ / GeV ) ; funs.push_back( PT / GeV ) ; funs.push_back( M / GeV ) ; funs.push_back( ID ) ; // fill N-Tuple with information abvout each particle tuple -> fmatrix ( "vars" , funs.begin () , funs.end () , particles.begin () , particles.end () , "nParts" , 200 ) ;
name | entry name in N-Tuple | |
funF | "begin"-iterator for vector of functions | |
funL | "end"-iterator for vector of functions | |
first | "begin"-iterator for vector of data | |
last | "end"-iterator for vector of data | |
length | entry name in NTuple for number of matrix column | |
maxv | maximal number of rows in matrix |
fill the matrix
Definition at line 1406 of file TupleObj.h.
01413 { 01414 if ( invalid () ) { return InvalidTuple ; } 01415 if ( rowWise () ) { return InvalidOperation ; } 01416 01417 // adjust the length 01418 if ( first + maxv < last ) 01419 { 01420 Warning(" fmatrix('"+name+"'): matrix is overflow, skip extra items") ; 01421 last = first + maxv ; 01422 }; 01423 01424 // get the length item 01425 Int* len = ints( length , 0 , maxv ) ; 01426 if ( 0 == len ) { return InvalidColumn; } 01427 01428 // adjust the length item 01429 *len = last - first ; 01430 01431 // get the array itself 01432 const size_t cols = funL - funF ; 01433 FMatrix* var = fMatrix ( name , len , cols ) ; 01434 if ( 0 == var ) { return InvalidColumn ; } 01435 01437 size_t iRow = 0 ; 01438 for ( ; first != last ; ++first ) 01439 { 01440 // 01441 for ( FUN fun = funF ; fun < funL ; ++fun ) 01442 { (*var)[ iRow ] [ fun - funF ] = (float)((*fun) ( *first )) ; } 01443 // 01444 ++iRow; 01445 }; 01446 01447 return StatusCode::SUCCESS ; 01448 }
StatusCode Tuples::TupleObj::fmatrix | ( | const std::string & | name, | |
const GaudiUtils::VectorMap< KEY, VALUE > & | info, | |||
const std::string & | length, | |||
const size_t | maxv = 100 | |||
) | [inline, inherited] |
shortcut to put "ExtraInfo" fields of major into N-Tuple
const LHCb::Particle* B = ... Tuple tuple = nTuple("My N-Tuple") ; // put the vector into N-Tuple: tuple -> fmatrix ( "Info" , B->extraInfo() , "nInfo" , 100 ) ;
fill the matrix
Definition at line 1834 of file TupleObj.h.
01838 { 01839 01840 if ( invalid () ) { return InvalidTuple ; } 01841 if ( rowWise () ) { return InvalidOperation ; } 01842 01843 typename GaudiUtils::VectorMap<KEY,VALUE>::const_iterator begin = info.begin () ; 01844 typename GaudiUtils::VectorMap<KEY,VALUE>::const_iterator end = info.end () ; 01845 01846 // adjust the length 01847 if ( maxv < info.size() ) 01848 { 01849 Warning(" fmatrix('"+name+"'): matrix is overflow, skip extra items") ; 01850 end = begin + maxv ; 01851 } ; 01852 01853 // get the length item 01854 Int* len = ints( length , 0 , maxv ) ; 01855 if ( 0 == len ) { return InvalidColumn; } 01856 01857 // adjust the length item 01858 *len = end - begin ; 01859 01860 // get the array itself 01861 FMatrix* var = fMatrix ( name , len , 2 ) ; 01862 if ( 0 == var ) { return InvalidColumn ; } 01863 01865 size_t iRow = 0 ; 01866 for ( ; begin != end ; ++begin) 01867 { 01868 // 01869 (*var)[iRow][0] = (float) begin->first ; 01870 (*var)[iRow][1] = (float) begin->second ; 01871 // 01872 ++iRow ; 01873 } ; 01874 01875 return StatusCode::SUCCESS ; 01876 }
StatusCode Tuples::TupleObj::array | ( | const std::string & | name, | |
DATA | first, | |||
DATA | last | |||
) | [inline, inherited] |
fill N-Tuple with fixed-size array
Sequence may be of any onkects, implicitey convertibel iuto "float"
name | N-Tuple entry name | |
first | begin-iterator for data sequence | |
last | end-iterator for data sequence |
fill the array
Definition at line 1475 of file TupleObj.h.
01479 { 01480 if ( invalid () ) { return InvalidTuple ; } 01481 if ( rowWise () ) { return InvalidOperation ; } 01482 01483 // get the length (fixed!) 01484 const size_t length = last - first ; 01485 01486 // get the array itself 01487 FArray* var = fArray ( name , length ) ; 01488 if ( 0 == var ) { return InvalidColumn ; } 01489 01491 size_t iCol = 0 ; 01492 for ( ; first != last ; ++first ) 01493 { (*var)[ iCol ] = (float)(*first) ; ++iCol ; } 01494 01495 return StatusCode::SUCCESS ; 01496 }
StatusCode Tuples::TupleObj::array | ( | const std::string & | name, | |
const ARRAY & | data, | |||
const MIndex & | length | |||
) | [inline, inherited] |
fill N-Tuple with fixed-size array
"ARRAY" must support indexing operations: e.g it coudl be of type:
The content of array shodul be implicitely convertible to "float"
CLHEP::HepVector vct1(10) ; ... tuple -> array ( "vct1" , vct1 , 10 ) ; double vct2[40]; ... tuple -> array ( "vct2" , vct2 , 40 ) ; long vct3[4]; ... tuple -> array ( "vct3" , vct4 , 4 ) ; std::vector<long double> vct4(15) ; ... tuple -> array ( "vct4" , vct4 , 15 ) ;
name | N-Tuple entry name | |
data | data sequence | |
length | data length (fixed!) |
fill the array
Definition at line 1537 of file TupleObj.h.
01540 { 01541 if ( invalid () ) { return InvalidTuple ; } 01542 if ( rowWise () ) { return InvalidOperation ; } 01543 01544 // get the array itself 01545 FArray* var = fArray ( name , length ) ; 01546 if ( 0 == var ) { return InvalidColumn ; } 01547 01549 for ( size_t index = 0 ; index < length ; ++index ) 01550 { (*var)[ index ] = (float) data[index] ; } 01551 01552 return StatusCode::SUCCESS ; 01553 }
StatusCode Tuples::TupleObj::array | ( | const std::string & | name, | |
const ARRAY & | data | |||
) | [inline, inherited] |
fill N-Tuple with fixed-size array
"ARRAY" is any sequence, which supports ARRAY::begin() and ARRAY::end() protocol, e.g.
The content of array shodul be implicitely convertible to "float"
typedef std::vector<double> Seq ; Seq data( 10 ) ; for ( int i = 0 ; i < 10 ; ++i ) { data[i] = ... ; } tuple -> array( "data" , data ) ;
name | N-Tupel entry name | |
data | data sequence |
Definition at line 1585 of file TupleObj.h.
StatusCode Tuples::TupleObj::array | ( | const std::string & | name, | |
const ROOT::Math::SVector< TYPE, DIM > & | vect | |||
) | [inline, inherited] |
shortcut to put SVector into N-tuple:
ROOT::Math::SVector<double,15> vct = ... ; Tuple tuple = nTuple("My N-Tuple") ; // put the vector into N-Tuple: tuple -> array ( "v" , vct ) ;
Definition at line 1779 of file TupleObj.h.
StatusCode Tuples::TupleObj::matrix | ( | const std::string & | name, | |
const MATRIX & | data, | |||
const MIndex & | rows, | |||
const MIndex & | cols | |||
) | [inline, inherited] |
fill N-Tuple with fixed-size matrix
"MATRIX" must support indexing operations: data[iRow][iCol]
e.g it could be of type:
The content of MATRIX shoudl be implicitely convertible to "float"
CLHEP::HepMatrix mtrx1(3,20) ; ... tuple -> matrix ( "m1" , mtrx1 , mtrx1.num_row() , mtrx1.num_col() ) ; typedef std::vector<double> Row ; typedef std:vector<Row> Mtrx ; Mtrx mtrx2( 3 , Row(10) ) ; ... tuple -> matrix ( "m2" , mtrx2 , 3 , 10 ) ; float mtrx3[3][10] ; ... tuple -> matrix ( "m3" , mtrx3 , 3 , 10 ) ;
name | N-Tuple entry name | |
data | data source (matrix) | |
cols | number of columns | |
rows | number of rows |
fill the matrix
Definition at line 1640 of file TupleObj.h.
01644 { 01645 if ( invalid () ) { return InvalidTuple ; } 01646 if ( rowWise () ) { return InvalidOperation ; } 01647 01648 // get the matrix itself 01649 FMatrix* var = fMatrix ( name , rows , cols ) ; 01650 if ( 0 == var ) { return InvalidColumn ; } 01651 01653 for ( size_t iCol = 0 ; iCol < cols ; ++iCol ) 01654 { 01655 for ( size_t iRow = 0 ; iRow < rows ; ++iRow ) 01656 { (*var)[iRow][iCol] = (float)(data[iRow][iCol]) ; } 01657 }; 01658 return StatusCode::SUCCESS ; 01659 }
StatusCode Tuples::TupleObj::matrix | ( | const std::string & | name, | |
const ROOT::Math::SMatrix< TYPE, D1, D2, REP > & | mtrx | |||
) | [inline, inherited] |
shortcut to put Smatrix into N-tuple:
fill the matrix
Definition at line 1795 of file TupleObj.h.
01797 { 01798 if ( invalid () ) { return InvalidTuple ; } 01799 if ( rowWise () ) { return InvalidOperation ; } 01800 01801 // get the matrix itself 01802 FMatrix* var = fMatrix ( name , D1 , D2 ) ; 01803 if ( 0 == var ) { return InvalidColumn ; } 01804 01806 for ( size_t iCol = 0 ; iCol < D2 ; ++iCol ) 01807 { 01808 for ( size_t iRow = 0 ; iRow < D1 ; ++iRow ) 01809 { (*var)[iRow][iCol] = (float) mtrx(iRow,iCol) ; } 01810 }; 01811 01812 return StatusCode::SUCCESS ; 01813 }
StatusCode Tuples::TupleObj::put | ( | const std::string & | name, | |
const TYPE * | obj | |||
) | [inline, inherited] |
The function allows to add almost arbitrary object into N-tuple.
name | column name | |
obj | pointer to the object |
Definition at line 129 of file TuplePut.h.
00130 { 00131 if ( invalid () ) { return InvalidTuple ; } // RETURN 00132 if ( !evtColType () ) { return InvalidOperation ; } // RETURN 00133 00134 // static block: The Reflex type description & the flag 00135 static bool s_fail = false ; // STATIC 00136 static ROOT::Reflex::Type s_type ; // STATIC 00137 // check the status 00138 if ( s_fail ) { return InvalidItem ; } // RETURN 00139 else if ( !s_type ) 00140 { 00141 const std::string class_name = System::typeinfoName ( typeid ( TYPE ) ) ; 00142 s_type = ROOT::Reflex::Type::ByName( class_name ) ; 00143 if ( !s_type ) 00144 { 00145 s_fail = true ; 00146 return Error ( " put('"+name+"'," + class_name + 00147 ") :Invalid ROOT::Reflex::Type", InvalidItem ) ; // RETURN 00148 } 00149 } 00150 // the local storage of items 00151 static Tuples::ItemStore<TYPE*> s_map ; 00152 // get the variable by name: 00153 NTuple::Item<TYPE*>* item = s_map.getItem ( name , this ) ; 00154 if ( 0 == item ) 00155 { return Error ( " put('" + name + "'): invalid item detected", InvalidItem ) ; } 00156 // assign the item! 00157 (*item) = const_cast<TYPE*> ( obj ) ; // THATS ALL!! 00158 // 00159 return StatusCode::SUCCESS ; // RETURN 00160 }
StatusCode Tuples::TupleObj::write | ( | ) | [inherited] |
write a record to NTuple
Definition at line 210 of file TupleObj.cpp.
00211 { 00212 if ( invalid() ) { return InvalidTuple ; } 00213 return tuple()->write() ; 00214 }
const std::string& Tuples::TupleObj::name | ( | ) | const [inline, inherited] |
NTuple::Tuple* Tuples::TupleObj::tuple | ( | ) | const [inline, inherited] |
provide the access to underlying Gaudi N-tuple
Definition at line 1904 of file TupleObj.h.
01904 { return m_tuple ; }
unsigned long Tuples::TupleObj::refCount | ( | ) | const [inline, inherited] |
return the reference counter
Definition at line 1909 of file TupleObj.h.
01909 { return m_refCount ; }
unsigned long Tuples::TupleObj::addRef | ( | ) | [inline, inherited] |
add the reference to TupleObj
Definition at line 1914 of file TupleObj.h.
01914 { return ++m_refCount ; }
void Tuples::TupleObj::release | ( | ) | [inherited] |
release the reference to TupleObj if reference counter becomes zero, object will be automatically deleted
Definition at line 198 of file TupleObj.cpp.
00199 { 00200 // decrease the reference counter 00201 if( 0 < refCount() ) { --m_refCount; } 00202 // check references 00203 if( 0 != refCount() ) { return; } 00204 // delete the object 00205 delete this ; 00206 }
const CLID& Tuples::TupleObj::clid | ( | ) | const [inline, inherited] |
Tuples::Type Tuples::TupleObj::type | ( | ) | const [inline, inherited] |
bool Tuples::TupleObj::columnWise | ( | ) | const [inline, inherited] |
column wise NTuple ?
Definition at line 1929 of file TupleObj.h.
01929 { return CLID_ColumnWiseTuple == clid() ; }
bool Tuples::TupleObj::rowWise | ( | ) | const [inline, inherited] |
row wise NTuple ?
Definition at line 1932 of file TupleObj.h.
01932 { return CLID_RowWiseTuple == clid() ; }
bool Tuples::TupleObj::evtColType | ( | ) | const [inline, inherited] |
Event collection ?
Definition at line 1935 of file TupleObj.h.
01935 { return Tuples::EVTCOL == type() ; }
bool Tuples::TupleObj::valid | ( | ) | const [inline, inherited] |
bool Tuples::TupleObj::invalid | ( | ) | const [inline, inherited] |
invalid pointer to tuple ?
Definition at line 1941 of file TupleObj.h.
01941 { return 0 == tuple() ; }
bool Tuples::TupleObj::addItem | ( | const std::string & | name, | |
const std::string & | type | |||
) | [inline, inherited] |
add the item name into the list of known items
name | the name of the item | |
type | the type of the item |
Definition at line 1950 of file TupleObj.h.
bool Tuples::TupleObj::goodItem | ( | const std::string & | name | ) | const [inline, inherited] |
check the uniquness of the name
name | the name of the item |
Definition at line 1958 of file TupleObj.h.
const ItemMap& Tuples::TupleObj::items | ( | ) | const [inline, inherited] |
get the full list of booked items
Definition at line 1962 of file TupleObj.h.
01962 { return m_items ; }
HANDLER1 Tuples::detail::TupleObjImp< HANDLER1, HANDLER2 >::m_handler1 [private] |
Definition at line 116 of file TupleDetail.h.
HANDLER2 Tuples::detail::TupleObjImp< HANDLER1, HANDLER2 >::m_handler2 [private] |
Definition at line 117 of file TupleDetail.h.