| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

TupleObj.cpp
Go to the documentation of this file.
1 // ============================================================================
2 // Include files
3 // ============================================================================
4 // STD & STL
5 // ============================================================================
6 #include <cstdarg>
7 #include <algorithm>
8 #include <map>
9 // ============================================================================
10 // GaudiKernel
11 // ============================================================================
12 #include "GaudiKernel/GaudiException.h"
13 // ============================================================================
14 // GaudiAlg
15 // ============================================================================
16 #include "GaudiAlg/Tuples.h"
17 #include "GaudiAlg/TupleObj.h"
18 // ============================================================================
19 // Boost
20 // ============================================================================
21 #include "boost/integer_traits.hpp"
22 // ============================================================================
30 // ============================================================================
31
32 namespace {
33
34 template <typename T> struct tuple_type_ ;
35
36 template <> struct tuple_type_<typename Tuples::TupleObj::Float>
37 { static constexpr const char* fmt = "F";
38 static constexpr const char* typ = "floats"; };
39 template <> struct tuple_type_<typename Tuples::TupleObj::Double>
40 { static constexpr const char* fmt = "D";
41 static constexpr const char* typ = "doubles"; };
42 template <> struct tuple_type_<typename Tuples::TupleObj::Bool>
43 { static constexpr const char* fmt = "I";
44 static constexpr const char* typ = "bools";};
45 template <> struct tuple_type_<typename Tuples::TupleObj::Char>
46 { static constexpr const char* fmt = "I";
47 static constexpr const char* typ = "chars";};
48 template <> struct tuple_type_<typename Tuples::TupleObj::UChar>
49 { static constexpr const char* fmt = "I";
50 static constexpr const char* typ = "uchars";};
51 template <> struct tuple_type_<typename Tuples::TupleObj::Short>
52 { static constexpr const char* fmt = "I";
53 static constexpr const char* typ = "shorts";};
54 template <> struct tuple_type_<typename Tuples::TupleObj::UShort>
55 { static constexpr const char* fmt = "I";
56 static constexpr const char* typ = "ushorts";};
57 template <> struct tuple_type_<typename Tuples::TupleObj::Int>
58 { static constexpr const char* fmt = "I";
59 static constexpr const char* typ = "ints";};
60 template <> struct tuple_type_<typename Tuples::TupleObj::UInt>
61 { static constexpr const char* fmt = "I";
62 static constexpr const char* typ = "uints";};
63 template <> struct tuple_type_<typename Tuples::TupleObj::LongLong>
64 { static constexpr const char* fmt = "ULL";
65 static constexpr const char* typ = "longlongs";};
66 template <> struct tuple_type_<typename Tuples::TupleObj::ULongLong>
67 { static constexpr const char* fmt = "ULL";
68 static constexpr const char* typ = "ulonglongs";};
69 template <> struct tuple_type_<typename Tuples::TupleObj::Address>
70 { static constexpr const char* fmt = "IOpaqueAddress*" ;
71 static constexpr const char* typ = "addresses";};
72 template <> struct tuple_type_<typename Tuples::TupleObj::FArray>
73 { static constexpr const char* fmt = "FArray";
74 static constexpr const char* typ = "farray";};
75 template <> struct tuple_type_<typename Tuples::TupleObj::FMatrix>
76 { static constexpr const char* fmt = "FMatrix";
77 static constexpr const char* typ = "fmatrix"; };
78
79 // helper function to simplify things...
80 template <typename C, typename AddItem>
81 typename C::mapped_type::pointer create_(Tuples::TupleObj* parent, C& container, const std::string& name, AddItem addItem ) {
82 using element_t = typename C::mapped_type::element_type;
83 using map_t = struct tuple_type_<element_t> ;
84 auto item = container.emplace( name , std::unique_ptr<element_t>{new element_t()} ) ;
85 if (!item.second)
86 { parent->Error ( std::string{map_t::typ} + " ('" + name + "'): item is not inserted" ) ; }
87 StatusCode sc = addItem( name , *(item.first->second) );
88 if ( sc.isFailure() )
89 { parent->Error ( std::string{map_t::typ} + " ('" + name + "'): item is not added", sc ) ; }
90 if ( !parent->addItem(name,map_t::fmt) )
91 { parent->Error ( std::string{map_t::typ} + " ('" + name + "'): item is not unique" ) ; }
92 return item.first->second.get() ;
93 }
94 }
95 namespace Tuples
96 {
97 namespace Local
98 {
99 class Counter final
100 {
101 public:
102 // constructor
103 Counter ( std::string msg = " Misbalance ")
104 : m_message ( std::move(msg) )
105 {}
106 // destructor
107 ~Counter() { report(); }
108 // make the increment
109 long increment ( const std::string& object ) { return ++m_map[object]; }
110 // make the decrement
111 long decrement ( const std::string& object ) { return --m_map[object]; }
112 // current count
113 long counts ( const std::string& object ) const { return m_map.at(object); }
114 // make a report
115 void report() const
116 {
117 for ( auto& entry : m_map )
118 {
119 if( entry.second != 0 ) std::cout
120 << "Tuples::TupleObj WARNING " << m_message
121 << "'" << entry.first << "' Counts = " << entry.second
122 << std::endl ;
123 }
124 };
125
126 private:
127 std::map<std::string,long> m_map;
128 std::string m_message ;
129 };
130
136 static Counter s_InstanceCounter{ " Create/Destroy (mis)balance " };
137
138 }
139 }
140 // ============================================================================
141 // Standard constructor
142 // ============================================================================
143 Tuples::TupleObj::TupleObj
144 ( std::string name ,
145 NTuple::Tuple* tuple ,
146 const CLID& clid ,
147 const Tuples::Type type )
148 //
149 : m_name ( std::move(name) )
150 , m_tuple ( tuple )
151 , m_clid ( clid )
152 , m_type ( type )
153 {
154 // make counts
155 Tuples::Local::s_InstanceCounter.increment ( m_name ) ;
156 }
157 // ============================================================================
158 // destructor
159 // ============================================================================
160 Tuples::TupleObj::~TupleObj()
161 {
162 // make counts
163 Tuples::Local::s_InstanceCounter.decrement ( m_name ) ;
164 }
165 // ============================================================================
166 // release the reference to TupleObj
167 // if reference counter becomes zero,
168 // object will be automatically deleted
169 // ============================================================================
170 void Tuples::TupleObj::release ()
171 {
172 // decrease the reference counter
173 if( refCount() > 0 ) { --m_refCount; }
174 // check references -- delete if needed
175 if( 0 == refCount() ) delete this;
176 }
177 // ============================================================================
178 // write a record to NTuple
179 // ============================================================================
180 StatusCode Tuples::TupleObj::write ()
181 {
182 if ( invalid() ) { return InvalidTuple ; }
183 return tuple()->write() ;
184 }
185 // ============================================================================
186 namespace
187 {
192 std::vector<std::string> tokenize( const std::string& value ,
193 const std::string& separators = " " )
194 {
195 std::vector<std::string> tokens;
196 auto it1 = value.begin() ;
197 auto it2 = value.begin() ;
198 while( value.end() != it1 && value.end() != it2 )
199 {
200 it2 = std::find_first_of( it1 ,
201 value.end () ,
202 separators.begin () ,
203 separators.end () ) ;
204 if( it2 != it1 ) {
205 tokens.emplace_back( value , it1 - value.begin() , it2 - it1 ) ;
206 it1 = it2 ;
207 }
208 else { ++it1 ; }
209 }
210 return tokens;
211 }
212 }
213 // ============================================================================
214 StatusCode Tuples::TupleObj::fill( const char* format ... )
215 {
216 // check the underlying tuple
217 if ( invalid() ) { return InvalidTuple ; }
218 // decode format string into tokens
219 auto tokens = tokenize( format , " ,;" );
221 va_list valist ;
222 va_start( valist , format ) ;
223 // loop over all tokens
224 StatusCode status = StatusCode::SUCCESS ;
225 for( auto token = tokens.cbegin() ;
226 tokens.cend() != token && status.isSuccess() ; ++token )
227 {
228 double val = va_arg( valist , double );
229 status = column( *token , val );
230 if( status.isFailure() )
231 { Error ( "fill(): Can not add column '" + *token + "' " ) ; }
232 }
233 // mandatory !!!
234 va_end( valist );
235 //
236 return status ;
237 }
238
239 // ============================================================================
240 // put IOpaqueAddress in NTuple (has sense only for Event tag collection Ntuples)
241 // ============================================================================
242 StatusCode Tuples::TupleObj::column
243 ( const std::string& name ,
244 IOpaqueAddress* address )
245 {
246 if ( !evtColType () ) { return InvalidOperation ; }
247 if ( !address )
248 { return Error ( "column('" + name +
249 "') IOpaqueAddress* is NULL!" , InvalidObject ) ; }
250 return column_<IOpaqueAddress*,&Tuples::TupleObj::addresses>(name, address);
251 }
252
253 // ============================================================================
254 // put IOpaqueAddress in NTuple (has sense only for Event tag collection Ntuples)
255 // ============================================================================
256 StatusCode Tuples::TupleObj::column
257 ( IOpaqueAddress* address )
258 {
259 return column ( "Address" , address ) ;
260 }
261
262 // ============================================================================
263 StatusCode Tuples::TupleObj::column ( const std::string& name ,
264 float value )
265 {
266 return column_<float,&Tuples::TupleObj::floats>(name,value);
267 }
268 // ============================================================================
269 StatusCode Tuples::TupleObj::column ( const std::string& name ,
270 double value )
271 {
272 return column_<double,&Tuples::TupleObj::doubles>(name,value);
273 }
274 // ============================================================================
275 StatusCode Tuples::TupleObj::column ( const std::string& name ,
276 char value )
277 {
278 return column_<char,&Tuples::TupleObj::chars>(name,value);
279 }
280 // ============================================================================
281 StatusCode Tuples::TupleObj::column ( const std::string& name ,
282 char value ,
283 char minv ,
284 char maxv )
285 {
286 return column_<char,&Tuples::TupleObj::chars>(name,value,minv,maxv);
287 }
288 // ============================================================================
289 StatusCode Tuples::TupleObj::column ( const std::string& name ,
290 unsigned char value )
291 {
292 return column_<unsigned char,&Tuples::TupleObj::uchars>(name,value);
293 }
294 // ============================================================================
295 StatusCode Tuples::TupleObj::column ( const std::string& name ,
296 unsigned char value ,
297 unsigned char minv ,
298 unsigned char maxv )
299 {
300 return column_<unsigned char,&Tuples::TupleObj::uchars>(name,value,minv,maxv);
301 }
302 // ============================================================================
303 StatusCode Tuples::TupleObj::column ( const std::string& name ,
304 short value )
305 {
306 return column_<short,&Tuples::TupleObj::shorts>(name,value);
307 }
308 // ============================================================================
309 StatusCode Tuples::TupleObj::column ( const std::string& name ,
310 const short value ,
311 const short minv ,
312 const short maxv )
313 {
314 return column_<short,&Tuples::TupleObj::shorts>(name,value,minv,maxv);
315 }
316 // ============================================================================
317 StatusCode Tuples::TupleObj::column ( const std::string& name ,
318 const unsigned short value )
319 {
320 return column_<unsigned short,&Tuples::TupleObj::ushorts>( name, value );
321 }
322 // ============================================================================
323 StatusCode Tuples::TupleObj::column ( const std::string& name ,
324 unsigned short value ,
325 unsigned short minv ,
326 unsigned short maxv )
327 {
328 return column_<unsigned short,&Tuples::TupleObj::ushorts>( name, value, minv, maxv );
329 }
330 // ============================================================================
331 StatusCode Tuples::TupleObj::column ( const std::string& name ,
332 int value )
333 {
334 return column_<int,&Tuples::TupleObj::ints>( name, value );
335 }
336 // ============================================================================
337 StatusCode Tuples::TupleObj::column ( const std::string& name ,
338 int value ,
339 int minv ,
340 int maxv )
341 {
342 return column_<int,&Tuples::TupleObj::ints>(name,value,minv,maxv);
343 }
344 // ============================================================================
345 StatusCode Tuples::TupleObj::column ( const std::string& name ,
346 unsigned int value )
347 {
348 return column_<unsigned int,&Tuples::TupleObj::uints>(name,value);
349 }
350 // ============================================================================
351 StatusCode Tuples::TupleObj::column ( const std::string& name ,
352 unsigned int value ,
353 unsigned int minv ,
354 unsigned int maxv )
355 {
356 return column_<unsigned int, &Tuples::TupleObj::uints>(name,value,minv,maxv);
357 }
358 // ============================================================================
359 StatusCode Tuples::TupleObj::column ( const std::string& name ,
360 const long value )
361 {
362 Warning( "'long' has different sizes on 32/64 bit systems. Casting '" +
363 name + "' to 'long long'", StatusCode::SUCCESS ).ignore();
364 return column( name, (long long)value );
365 }
366 // ============================================================================
367 StatusCode Tuples::TupleObj::column ( const std::string& name ,
368 const long value ,
369 const long minv ,
370 const long maxv )
371 {
372 Warning( "'long' has different sizes on 32/64 bit systems. Casting '" +
373 name + "' to 'long long'", StatusCode::SUCCESS ).ignore();
374 return column( name,
375 (long long)value,
376 (long long)minv,
377 (long long)maxv );
378 }
379 // ============================================================================
380 StatusCode Tuples::TupleObj::column ( const std::string& name ,
381 const unsigned long value )
382 {
383 Warning( "'unsigned long' has different sizes on 32/64 bit systems. Casting '" +
384 name + "' to 'unsigned long long'", StatusCode::SUCCESS ).ignore();
385 return column( name, (unsigned long long)value );
386 }
387 // ============================================================================
388 StatusCode Tuples::TupleObj::column ( const std::string& name ,
389 const unsigned long value ,
390 const unsigned long minv ,
391 const unsigned long maxv )
392 {
393 Warning( "'unsigned long' has different sizes on 32/64 bit systems. Casting '" +
394 name + "' to 'unsigned long long'", StatusCode::SUCCESS ).ignore();
395 return column( name,
396 (unsigned long long)value,
397 (unsigned long long)minv,
398 (unsigned long long)maxv );
399 }
400 // ============================================================================
401 StatusCode Tuples::TupleObj::column ( const std::string& name ,
402 const long long value )
403 {
404 return column_<long long,&Tuples::TupleObj::longlongs>(name,value);
405 }
406 // ============================================================================
407 StatusCode Tuples::TupleObj::column ( const std::string& name ,
408 long long value ,
409 long long minv ,
410 long long maxv )
411 {
412 return column_<long long,&Tuples::TupleObj::longlongs>(name,value,minv,maxv);
413 }
414 // ============================================================================
415 StatusCode Tuples::TupleObj::column ( const std::string& name ,
416 unsigned long long value )
417 {
418 return column_<unsigned long long,&Tuples::TupleObj::ulonglongs>(name,value);
419 }
420 // ============================================================================
421 StatusCode Tuples::TupleObj::column ( const std::string& name ,
422 unsigned long long value ,
423 unsigned long long minv ,
424 unsigned long long maxv )
425 {
426 return column_<unsigned long long,&Tuples::TupleObj::ulonglongs>(name,value,minv,maxv);
427 }
428 // ============================================================================
429 StatusCode Tuples::TupleObj::column ( const std::string& name ,
430 bool value )
431 {
432 return column_<bool,&Tuples::TupleObj::bools>(name,value);
433 }
434 // ============================================================================
435 Tuples::TupleObj::Float* Tuples::TupleObj::floats
436 ( const std::string& name )
437 {
438 auto found = m_floats.find( name ) ;
439 if ( m_floats.end() != found ) { return found->second.get() ; }
440 return create_(this, m_floats,name,
441 [&](const std::string& n, Float& i)
442 { return this->tuple()->addItem(n,i); });
443 }
444 // ============================================================================
445 Tuples::TupleObj::Double* Tuples::TupleObj::doubles
446 ( const std::string& name )
447 {
448 auto found = m_doubles.find( name ) ;
449 if ( m_doubles.end() != found ) { return found->second.get() ; }
450 return create_(this, m_doubles,name,
451 [&](const std::string& n, Double& i)
452 { return this->tuple()->addItem(n,i); });
453 }
454 // ============================================================================
455 Tuples::TupleObj::Bool* Tuples::TupleObj::bools
456 ( const std::string& name )
457 {
458 auto found = m_bools.find( name ) ;
459 if( m_bools.end() != found ) { return found->second.get() ; }
460 return create_(this, m_bools, name,
461 [&](const std::string& n, Bool& i)
462 { return this->tuple()->addItem(n,i); });
463 }
464 // ============================================================================
465 Tuples::TupleObj::Char* Tuples::TupleObj::chars
466 ( const std::string& name )
467 {
468 auto found = m_chars.find( name ) ;
469 if( m_chars.end() != found ) { return found->second.get() ; }
470 return create_(this, m_chars, name,
471 [&](const std::string& n, Char& i)
472 { return this->tuple()->addItem(n,i); });
473 }
474 // ============================================================================
475 Tuples::TupleObj::Char* Tuples::TupleObj::chars
476 ( const std::string& name , char minv , char maxv )
477 {
478 auto found = m_chars.find( name ) ;
479 return ( found != m_chars.end() ) ? found->second.get()
480 : create_(this, m_chars, name,
481 [&](const std::string& n, Char& i)
482 { return this->tuple()->addItem(n,i,minv,maxv); });
483 }
484 // ============================================================================
485 Tuples::TupleObj::UChar* Tuples::TupleObj::uchars
486 ( const std::string& name )
487 {
488 auto found = m_uchars.find( name ) ;
489 return ( found != m_uchars.end() ) ? found->second.get()
490 : create_(this, m_uchars, name,
491 [&](const std::string& n, UChar& i)
492 { return this->tuple()->addItem(n,i); });
493 }
494 // ============================================================================
495 Tuples::TupleObj::UChar* Tuples::TupleObj::uchars
496 ( const std::string& name , unsigned char minv , unsigned char maxv )
497 {
498 auto found = m_uchars.find( name ) ;
499 return ( found != m_uchars.end() ) ? found->second.get()
500 : create_(this, m_uchars, name,
501 [&](const std::string& n, UChar& i)
502 { return this->tuple()->addItem(n,i,minv,maxv); });
503 }
504 // ============================================================================
505 Tuples::TupleObj::Short* Tuples::TupleObj::shorts
506 ( const std::string& name )
507 {
508 auto found = m_shorts.find( name ) ;
509 if( m_shorts.end() != found ) { return found->second.get() ; }
510 return create_(this, m_shorts, name,
511 [&](const std::string& n, Short& i)
512 { return this->tuple()->addItem(n,i); });
513 }
514 // ============================================================================
515 Tuples::TupleObj::Short* Tuples::TupleObj::shorts
516 ( const std::string& name ,
517 const short minv ,
518 const short maxv )
519 {
520 auto found = m_shorts.find( name ) ;
521 if( m_shorts.end() != found ) { return found->second.get(); }
522 return create_(this, m_shorts, name,
523 [&](const std::string& n, Short& i)
524 { return this->tuple()->addItem(n,i,minv,maxv); });
525 }
526 // ============================================================================
527 Tuples::TupleObj::UShort* Tuples::TupleObj::ushorts
528 ( const std::string& name )
529 {
530 auto found = m_ushorts.find( name ) ;
531 if( m_ushorts.end() != found ) { return found->second.get() ; }
532 return create_(this, m_ushorts, name,
533 [&](const std::string& n, UShort& i)
534 { return this->tuple()->addItem(n,i); });
535 }
536 // ============================================================================
537 Tuples::TupleObj::UShort* Tuples::TupleObj::ushorts
538 ( const std::string& name ,
539 const unsigned short minv ,
540 const unsigned short maxv )
541 {
542 auto found = m_ushorts.find( name ) ;
543 if( m_ushorts.end() != found ) { return found->second.get() ; }
544 return create_(this, m_ushorts, name,
545 [&](const std::string& n, UShort& i)
546 { return this->tuple()->addItem(n,i,minv,maxv); });
547 }
548 // ============================================================================
549 Tuples::TupleObj::Int* Tuples::TupleObj::ints
550 ( const std::string& name )
551 {
552 auto found = m_ints.find( name ) ;
553 if( m_ints.end() != found ) { return found->second.get() ; }
554 return create_(this, m_ints, name,
555 [&](const std::string& n, Int& i)
556 { return this->tuple()->addItem(n,i); });
557 }
558 // ============================================================================
559 Tuples::TupleObj::Int* Tuples::TupleObj::ints
560 ( const std::string& name ,
561 const int minv ,
562 const int maxv )
563 {
564 auto found = m_ints.find( name ) ;
565 if( m_ints.end() != found ) { return found->second.get() ; }
566 return create_(this, m_ints, name,
567 [&](const std::string& n, Int& i)
568 { return this->tuple()->addItem(n,i,minv,maxv); });
569 }
570 // ============================================================================
571 Tuples::TupleObj::UInt* Tuples::TupleObj::uints
572 ( const std::string& name )
573 {
574 auto found = m_uints.find( name ) ;
575 if( m_uints.end() != found ) { return found->second.get() ; }
576 return create_(this, m_uints, name,
577 [&](const std::string& n, UInt& i)
578 { return this->tuple()->addItem(n,i); });
579 }
580 // ============================================================================
581 Tuples::TupleObj::UInt* Tuples::TupleObj::uints
582 ( const std::string& name ,
583 const unsigned int minv ,
584 const unsigned int maxv )
585 {
586 auto found = m_uints.find( name ) ;
587 if( m_uints.end() != found ) { return found->second.get() ; }
588 return create_(this, m_uints, name,
589 [&](const std::string& n, UInt& i)
590 { return this->tuple()->addItem(n,i,minv,maxv); });
591 }
592 // ============================================================================
593 Tuples::TupleObj::LongLong* Tuples::TupleObj::longlongs
594 ( const std::string& name )
595 {
596 auto found = m_longlongs.find( name ) ;
597 if( m_longlongs.end() != found ) { return found->second.get() ; }
598 return create_(this, m_longlongs, name,
599 [&](const std::string& n, LongLong& i)
600 { return this->tuple()->addItem(n,i); });
601 }
602 // ============================================================================
603 Tuples::TupleObj::LongLong* Tuples::TupleObj::longlongs
604 ( const std::string& name ,
605 const long long minv ,
606 const long long maxv )
607 {
608 auto found = m_longlongs.find( name ) ;
609 if( m_longlongs.end() != found ) { return found->second.get() ; }
610 return create_(this, m_longlongs, name,
611 [&](const std::string& n, LongLong& i)
612 { return this->tuple()->addItem(n,i,minv,maxv); });
613 }
614 // ============================================================================
615 Tuples::TupleObj::ULongLong* Tuples::TupleObj::ulonglongs
616 ( const std::string& name )
617 {
618 auto found = m_ulonglongs.find( name ) ;
619 if( m_ulonglongs.end() != found ) { return found->second.get() ; }
620 return create_(this, m_ulonglongs, name,
621 [&](const std::string& n, ULongLong& i)
622 { return this->tuple()->addItem(n,i); });
623 }
624 // ============================================================================
625 Tuples::TupleObj::ULongLong* Tuples::TupleObj::ulonglongs
626 ( const std::string& name ,
627 const unsigned long long minv ,
628 const unsigned long long maxv )
629 {
630 auto found = m_ulonglongs.find( name ) ;
631 if( m_ulonglongs.end() != found ) { return found->second.get() ; }
632 return create_(this, m_ulonglongs, name,
633 [&](const std::string& n, ULongLong& i)
634 { return this->tuple()->addItem(n,i,minv,maxv); });
635 }
636 // ============================================================================
637 Tuples::TupleObj::Address* Tuples::TupleObj::addresses
638 ( const std::string& name )
639 {
640 auto found = m_addresses.find( name ) ;
641 if( m_addresses.end() != found ) { return found->second.get() ; }
642 return create_(this, m_addresses, name,
643 [&](const std::string& n, Address& i)
644 { return this->tuple()->addItem(n,i); });
645 }
646 // ============================================================================
647 // retrieve (book on demand) array-items for ntuple
648 // ============================================================================
649 Tuples::TupleObj::FArray* Tuples::TupleObj::fArray
650 ( const std::string& name ,
651 Tuples::TupleObj::Int* length )
652 {
653 // existing array ?
654 auto found = m_farrays.find( name ) ;
655 if( m_farrays.end() != found ) { return found->second.get() ; }
656 return create_(this, m_farrays, name,
657 [&](const std::string& n, FArray& i)
658 { return this->tuple()->addIndexedItem(n,*length,i); });
659 }
660 // ============================================================================
661 // retrieve (book on demand) array-items for ntuple (fixed)
662 // ============================================================================
663 Tuples::TupleObj::FArray* Tuples::TupleObj::fArray
664 ( const std::string& name ,
665 const Tuples::TupleObj::MIndex& rows )
666 {
667 // existing array ?
668 auto found = m_arraysf.find( name ) ;
669 if( m_arraysf.end() != found ) { return found->second.get() ; }
670 return create_(this, m_arraysf, name,
671 [&](const std::string& n, FArray& i)
672 { return this->tuple()->addItem(n,rows,i); });
673 }
674 // ============================================================================
675 // retrieve (book on demand) matrix-items for ntuple
676 // ============================================================================
677 Tuples::TupleObj::FMatrix*
678 Tuples::TupleObj::fMatrix
679 ( const std::string& name ,
680 Tuples::TupleObj::Int* length ,
681 const Tuples::TupleObj::MIndex& cols )
682 {
683 // existing array ?
684 auto found = m_fmatrices.find( name ) ;
685 if( m_fmatrices.end() != found ) { return found->second.get() ; }
686 return create_(this, m_fmatrices, name,
687 [&](const std::string& n, FMatrix& i)
688 { return this->tuple()->addIndexedItem(n,*length,cols,i); });
689 }
690 // ============================================================================
691 // retrieve (book on demand) matrix-items for ntuple (fixed)
692 // ============================================================================
693 Tuples::TupleObj::FMatrix*
694 Tuples::TupleObj::fMatrix
695 ( const std::string& name ,
696 const Tuples::TupleObj::MIndex& rows ,
697 const Tuples::TupleObj::MIndex& cols )
698 {
699 // existing array ?
700 auto found = m_matricesf.find( name ) ;
701 if( m_matricesf.end() != found ) { return found->second.get() ; }
702 return create_(this, m_matricesf, name,
703 [&](const std::string& n, FMatrix& i)
704 { return this->tuple()->addItem(n,rows,cols,i); });
705 }
706 // ============================================================================
707 // The END
708 // ============================================================================
INTuple::write
virtual StatusCode write()=0
Write record of the NTuple (Shortcut of writeRecord)
Tuples::TupleObj::addresses
Address * addresses(const std::string &name)
get the column
Definition: TupleObj.cpp:638
Tuples::TupleObj::release
void release()
release the reference to TupleObj if reference counter becomes zero, object will be automatically del...
Definition: TupleObj.cpp:170
Tuples::Local::Counter::decrement
long decrement(const std::string &object)
Definition: TupleObj.cpp:111
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119
Tuples::TupleObj::floats
Float * floats(const std::string &name)
get the column
Definition: TupleObj.cpp:436
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:28
GaudiMP.FdsRegistry.msg
tuple msg
Definition: FdsRegistry.py:8
Tuples::Local::Counter::counts
long counts(const std::string &object) const
Definition: TupleObj.cpp:113
Tuples::InvalidTuple
Definition: TupleObj.h:94
TupleObj.h
Header file for class TupleObj.
NTuple::Matrix
Class acting as a smart pointer holding a N tuple _Item.
Definition: NTuple.h:44
Tuples::TupleObj::fill
StatusCode fill(const char *format...)
Set the values for several columns simultaneously.
Definition: TupleObj.cpp:214
Tuples::Local::Counter::report
void report() const
Definition: TupleObj.cpp:115
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
Tuples::TupleObj::column
StatusCode column(const std::string &name, float value)
Set the value for selected tuple column.
Definition: TupleObj.cpp:263
Tuples::TupleObj::bools
Bool * bools(const std::string &name)
get the column
Definition: TupleObj.cpp:456
std::endl
T endl(T...args)
Tuples::TupleObj::TupleObj
TupleObj()=delete
delete the default/copy constructor and assignment
std
STL namespace.
Tuples::TupleObj::ushorts
UShort * ushorts(const std::string &name)
get the column
Definition: TupleObj.cpp:528
std::string::end
T end(T...args)
Tuples::TupleObj::MIndex
unsigned short MIndex
Definition: TupleObj.h:243
Tuples::Local::Counter::m_map
std::map< std::string, long > m_map
Definition: TupleObj.cpp:124
Tuples::TupleObj::uchars
UChar * uchars(const std::string &name)
get the column
Definition: TupleObj.cpp:486
merge_files.sc
int sc
Definition: merge_files.py:167
std::map< std::string, long >
Tuples::TupleObj::m_name
std::string m_name
name
Definition: TupleObj.h:2230
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
GaudiPluginService.cpluginsvc.n
list n
Definition: cpluginsvc.py:217
Tuples::TupleObj::uints
UInt * uints(const std::string &name)
get the column
Definition: TupleObj.cpp:572
NTuple::Tuple::addIndexedItem
StatusCode addIndexedItem(const std::string &name, Item< INDEX > &index, Array< TYPE > &array, const RANGE low, const RANGE high)
Add an indexed Array of data to a column wise N tuple with a range.
Definition: NTuple.h:743
Tuples::InvalidOperation
Definition: TupleObj.h:96
Tuples::Local::Counter::Counter
Counter(std::string msg=" Misbalance ")
Definition: TupleObj.cpp:103
std::string
STL class.
std::map::at
T at(T...args)
Tuples::TupleObj::ulonglongs
ULongLong * ulonglongs(const std::string &name)
get the column
Definition: TupleObj.cpp:616
Tuples::TupleObj::addItem
bool addItem(std::string name, std::string type)
add the item name into the list of known items
Definition: TupleObj.h:2039
gaudirun.type
string type
Definition: gaudirun.py:151
Tuples::TupleObj
A simple wrapper class over standard Gaudi NTuple::Tuple facility.
Definition: TupleObj.h:196
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
GaudiException.h
Tuples::Local::Counter::~Counter
~Counter()
Definition: TupleObj.cpp:107
std::find_first_of
T find_first_of(T...args)
Tuples::TupleObj::write
StatusCode write()
write a record to NTuple
Definition: TupleObj.cpp:180
dump_component_properties.value
list value
Definition: dump_component_properties.py:12
NTuple::Item< bool >
Specialization acting as a smart pointer holding a N tuple _Item.
Definition: NTuple.h:297
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
Tuples::TupleObj::Error
virtual StatusCode Error(const std::string &msg, const StatusCode sc=StatusCode::FAILURE) const =0
std::move
T move(T...args)
NTuple::Tuple
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:370
Tuples::TupleObj::~TupleObj
virtual ~TupleObj()
destructor is protected
Definition: TupleObj.cpp:160
Tuples::TupleObj::fArray
FArray * fArray(const std::string &name, Int *item)
get the column
Definition: TupleObj.cpp:650
Tuples::TupleObj::shorts
Short * shorts(const std::string &name)
get the column
Definition: TupleObj.cpp:506
std::vector< std::string >
std::unique_ptr
STL class.
Tuples::TupleObj::chars
Char * chars(const std::string &name)
get the column
Definition: TupleObj.cpp:466
std::string::begin
T begin(T...args)
ana.item
tuple item
print s1,s2
Definition: ana.py:146
Tuples.h
NTuple::Tuple::addItem
StatusCode addItem(const std::string &name, Item< TYPE > &itm)
Add a scalar data item a N tuple.
Definition: NTuple.h:554
Tuples::TupleObj::fMatrix
FMatrix * fMatrix(const std::string &name, Int *item, const MIndex &cols)
get the column
Definition: TupleObj.cpp:679
Tuples::TupleObj::doubles
Double * doubles(const std::string &name)
get the column
Definition: TupleObj.cpp:446
Tuples::TupleObj::ints
Int * ints(const std::string &name)
get the column
Definition: TupleObj.cpp:550
IOpaqueAddress
Opaque address interface definition.
Definition: IOpaqueAddress.h:23
Tuples::InvalidObject
Definition: TupleObj.h:97
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:108
va_list
NTuple::Item
Class acting as a smart pointer holding a N tuple _Item.
Definition: NTuple.h:42
Tuples::Local::Counter::m_message
std::string m_message
Definition: TupleObj.cpp:128
NTuple::Array
Class acting as a smart pointer holding a N tuple _Item.
Definition: NTuple.h:43
ana.i
list i
Definition: ana.py:128
Tuples::Type
Type
the list of available types for ntuples
Definition: TupleObj.h:79
std::cout
Tuples::Local::Counter::increment
long increment(const std::string &object)
Definition: TupleObj.cpp:109
Tuples::Local::Counter
Definition: TupleObj.cpp:99
Tuples::TupleObj::longlongs
LongLong * longlongs(const std::string &name)
get the column
Definition: TupleObj.cpp:594
Tuples
General namespace for Tuple properties.
Definition: Maps.h:34
std::vector::emplace_back
T emplace_back(T...args)