ATLAS Offline Software
Loading...
Searching...
No Matches
EventInfo_v1.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5// System include(s):
6#include <atomic>
7#include <iostream>
8#include <iomanip>
9#include <stdexcept>
10
11// EDM include(s):
14#include "CxxUtils/stall.h"
15
16// Local include(s):
20
21#ifndef XAOD_STANDALONE
24#endif
25
27
28 // Forward declaration(s):
29 template< typename T >
30 std::ostream& operator<<( std::ostream& out, const std::set< T >& s );
31
33 template< typename T >
34 std::ostream& operator<<( std::ostream& out, const std::vector< T >& vec ) {
35
36 out << "[";
37 for( size_t i = 0; i < vec.size(); ++i ) {
38 out << vec[ i ];
39 if( i != ( vec.size() - 1 ) ) {
40 out << ", ";
41 }
42 }
43 out << "]";
44 return out;
45 }
46
48 template< typename T >
49 std::ostream& operator<<( std::ostream& out, const std::set< T >& s ) {
50
51 return out << std::vector< T >( begin( s ), end( s ) );
52 }
53
58 static std::atomic< bool > uninitPileupAccessPrinted = false;
59 if( ! uninitPileupAccessPrinted ) {
60 std::cout << "xAOD::EventInfo WARNING Uninitialised pileup value was "
61 "accessed.\n"
62 " Debug it by breaking on "
63 "xAODEventInfoPrivate::pileupUnsetHook function calls!"
64 << std::endl;
65 uninitPileupAccessPrinted = true;
66 }
67 return;
68 }
69
70 // register attributes' types early (before I/O) for schema evolution
71 static const SG::AuxElement::Accessor< uint64_t > accEvNum( "eventNumber" );
72 static const SG::AuxElement::Accessor< uint64_t > accMcEvNum( "mcEventNumber" );
73 static const SG::AuxElement::Accessor< uint64_t > accLow( "pileUpMixtureIDLowBits" );
74 static const SG::AuxElement::Accessor< uint64_t > accHigh( "pileUpMixtureIDHighBits" );
75
76} // private namespace
77
78namespace xAOD {
79
80 using xAODEventInfoPrivate::operator<<;
81
87
89 : SG::AuxElement(parent), m_streamTags(),
91 m_evtStore( parent.m_evtStore ) {
92
93 makePrivateStore( parent );
94 }
95
97
98 if (&rhs != this) {
99 // Clear out the caches:
100 m_streamTags.store (std::vector< StreamTag >());
101 m_streamTags.reset();
102 m_subEvents.store (std::vector< SubEvent >());
103 m_subEvents.reset();
104
105 // Copy the event store pointer:
107
108 // Copy the auxiliary variables:
110 }
111
112 // Return this object:
113 return *this;
114 }
115
117 //
118 // Implementation of the basic event properties
119 //
120
122 runNumber, setRunNumber )
124 eventNumber, setEventNumber )
126 lumiBlock, setLumiBlock )
128 timeStamp, setTimeStamp )
130 timeStampNSOffset,
131 setTimeStampNSOffset )
133 bcid, setBCID )
135 detectorMask0, setDetectorMask0 )
137 detectorMask1, setDetectorMask1 )
139 detectorMask2, setDetectorMask2 )
141 detectorMask3, setDetectorMask3 )
142
144
145 return ( ( static_cast< uint64_t >( detectorMask1() ) << 32 ) |
146 detectorMask0() );
147 }
148
150
151 setDetectorMask0( mask0 );
152 setDetectorMask1( mask1 );
153 return;
154 }
155
157
158 setDetectorMask0( static_cast< uint32_t >( mask & 0xffffffff ) );
159 setDetectorMask1( static_cast< uint32_t >( ( mask >> 32 ) &
160 0xffffffff ) );
161 return;
162 }
163
165
166 return ( ( static_cast< uint64_t >( detectorMask3() ) << 32 ) |
167 detectorMask2() );
168 }
169
171
172 setDetectorMask2( mask2 );
174 return;
175 }
176
178
179 setDetectorMask2( static_cast< uint32_t >( mask & 0xffffffff ) );
180 setDetectorMask3( static_cast< uint32_t >( ( mask >> 32 ) &
181 0xffffffff ) );
182 return;
183 }
184
185 //
187
189 //
190 // Implementation of the event type properties
191 //
192
195 detDescrTags, setDetDescrTags )
197 mcChannelNumber, setMCChannelNumber )
199 mcEventNumber, setMCEventNumber )
201 mcEventWeights, setMCEventWeights )
202
203 float EventInfo_v1::mcEventWeight( size_t i ) const {
204
205 // Throw an exception when asked for an impossible index:
206 return mcEventWeights().at( i );
207 }
208
210 eventTypeBitmask, setEventTypeBitmask )
211
213
214 return ( eventTypeBitmask() & static_cast< uint32_t >( type ) );
215 }
216
217 //
219
221 //
222 // Implementation of the trigger related properties
223 //
224
226 statusElement, setStatusElement )
228 extendedLevel1ID, setExtendedLevel1ID )
230 level1TriggerType,
231 setLevel1TriggerType )
232
233 EventInfo_v1::StreamTag::StreamTag( const std::string& name,
234 const std::string& type,
235 bool obeysLumiblock,
236 const std::set< uint32_t >& robs,
237 const std::set< uint32_t >& dets )
238 : m_name( name ), m_type( type ), m_obeysLumiblock( obeysLumiblock ),
239 m_robs( robs ), m_dets( dets ) {
240
241 }
242
243 const std::string& EventInfo_v1::StreamTag::name() const {
244
245 return m_name;
246 }
247
248 const std::string& EventInfo_v1::StreamTag::type() const {
249
250 return m_type;
251 }
252
254
255 return m_obeysLumiblock;
256 }
257
258 const std::set< uint32_t >& EventInfo_v1::StreamTag::robs() const {
259
260 return m_robs;
261 }
262
263 const std::set< uint32_t >& EventInfo_v1::StreamTag::dets() const {
264
265 return m_dets;
266 }
267
268 //
269 // Accessor objects for the stream properties:
270 //
272 names( "streamTagNames" );
274 types( "streamTagTypes" );
276 olb( "streamTagObeysLumiblock" );
278 robsets( "streamTagRobs" );
280 detsets( "streamTagDets" );
281
282 const std::vector< EventInfo_v1::StreamTag >&
284
285 // Cache the new information if necessary:
286 if( !m_streamTags.isValid() ) {
287 std::vector< StreamTag > tags;
288
289 // A little sanity check:
290 if( ( names( *this ).size() != types( *this ).size() ) ||
291 ( names( *this ).size() != olb( *this ).size() ) ||
292 ( robsets.isAvailable( *this ) &&
293 ( names( *this ).size() != robsets( *this ).size() ) ) ||
294 ( detsets.isAvailable( *this ) &&
295 ( names( *this ).size() != detsets( *this ).size() ) ) ) {
296 std::cerr << "<xAOD::EventInfo_v1::streamTags> ERROR "
297 << "Corrupt information found!" << std::endl;
298 std::cerr << " streamTagNames = " << names( *this )
299 << std::endl;
300 std::cerr << " streamTagTypes = " << types( *this )
301 << std::endl;
302 std::cerr << " streamTagObeysLumiblock = " << olb( *this )
303 << std::endl;
304 std::cerr << " streamTagRobs = ";
305 if( robsets.isAvailable( *this ) ) {
306 std::cerr << "N/A" << std::endl;
307 } else {
308 std::cerr << robsets( *this ) << std::endl;
309 }
310 std::cerr << " streamTagDets = ";
311 if( detsets.isAvailable( *this ) ) {
312 std::cerr << "N/A" << std::endl;
313 } else {
314 std::cerr << detsets( *this ) << std::endl;
315 }
316 }
317
318 else {
319 // Fill the tags.
320 for( size_t i = 0; i < names( *this ).size(); ++i ) {
321 static const std::set< uint32_t > dummySet;
322 tags.emplace_back( names( *this )[ i ],
323 types( *this )[ i ],
324 olb( *this )[ i ],
325 ( robsets.isAvailable( *this ) ?
326 robsets( *this )[ i ] :
327 dummySet ),
328 ( detsets.isAvailable( *this ) ?
329 detsets( *this )[ i ] :
330 dummySet ) );
331 }
332 }
333
334 // Set the cache.
335 m_streamTags.set (std::move (tags));
336 }
337
338 // Return the cached object:
339 return *m_streamTags.ptr();
340 }
341
342 void EventInfo_v1::setStreamTags( const std::vector< StreamTag >& value ) {
343
344 // Update the cached information:
345 m_streamTags.store (value);
346
347 // Clear the persistent information:
348 names( *this ).clear(); types( *this ).clear(); olb( *this ).clear();
349 robsets( *this ).clear(); detsets( *this ).clear();
350
351 // Fill the persistent information:
352 std::vector< StreamTag >::const_iterator itr = value.begin();
353 std::vector< StreamTag >::const_iterator end = value.end();
354 for( ; itr != end; ++itr ) {
355 names( *this ).push_back( itr->name() );
356 types( *this ).push_back( itr->type() );
357 olb( *this ).push_back( itr->obeysLumiblock() );
358 robsets( *this ).push_back( itr->robs() );
359 detsets( *this ).push_back( itr->dets() );
360 }
361
362 return;
363 }
364
365 //
367
369 //
370 // Implementation of the pileup information functions
371 //
372
375 accActualInteractionsPerCrossing( "actualInteractionsPerCrossing" );
378 accAverageInteractionsPerCrossing( "averageInteractionsPerCrossing" );
379
381
382 // If the value is not available, then return 0.0, but allow users to
383 // find out about this issue.
384 if( ! accActualInteractionsPerCrossing.isAvailable( *this ) ) {
386 return 0.0f;
387 }
388 return accActualInteractionsPerCrossing( *this );
389 }
390
392
393 accActualInteractionsPerCrossing( *this ) = value;
394 return;
395 }
396
398
399 // If the value is not available, then return 0.0, but allow users to
400 // find out about this issue.
401 if( ! accAverageInteractionsPerCrossing.isAvailable( *this ) ) {
403 return 0.0f;
404 }
405 return accAverageInteractionsPerCrossing( *this );
406 }
407
409
410 accAverageInteractionsPerCrossing( *this ) = value;
411 return;
412 }
413
415 pileUpMixtureIDLowBits,
416 setPileUpMixtureIDLowBits )
419 setPileUpMixtureIDHighBits )
420
422
423 PileUpMixtureID id{};
424
425 // We need to check if the values are actually stored
428 id.lowBits = pileUpMixtureIDLowBits();
429 id.highBits = pileUpMixtureIDHighBits();
430 }
431
432 return id;
433
434 }
435
437
438 setPileUpMixtureIDLowBits( value.lowBits );
439 setPileUpMixtureIDHighBits( value.highBits );
440
441 }
442
443 EventInfo_v1::SubEvent::
446 : m_time( time ), m_index( index ), m_type( type ), m_link( link ) {
447
448 }
449
451
452 return m_time;
453 }
454
456
457 return m_index;
458 }
459
464
465 const std::string& EventInfo_v1::SubEvent::typeName() const {
466
467 // This is a really inefficienct implementation, but didn't
468 // feel like writing a short and efficient implementation for C++11,
469 // and a longer but still efficient version for C++03. This is a
470 // medium-sized, slow implementation that works everywhere... :-P
471 if( m_type == Signal ) {
472 static const std::string name = "Signal";
473 return name;
474 } else if( m_type == MinimumBias ) {
475 static const std::string name = "MinimumBias";
476 return name;
477 } else if( m_type == Cavern ) {
478 static const std::string name = "Cavern";
479 return name;
480 } else if( m_type == HaloGas ) {
481 static const std::string name = "HaloGas";
482 return name;
483 } else if( m_type == HighPtMinimumBias ) {
484 static const std::string name = "HighPtMinimumBias";
485 return name;
486 } else if( m_type == ZeroBias ) {
487 static const std::string name = "ZeroBias";
488 return name;
489 } else {
490 static const std::string name = "Unknown";
491 return name;
492 }
493 }
494
497
498 return m_link;
499 }
500
502
503 if( m_link.isValid() ) {
504 return *m_link;
505 } else {
506 return nullptr;
507 }
508 }
509
510 //
511 // Accessor objects for the sub-event properties:
512 //
514 timeAcc( "subEventTime" );
516 indexAcc( "subEventIndex" );
518 linkAcc( "subEventLink" );
520 typeAcc( "subEventType" );
521
522 std::vector< EventInfo_v1::SubEvent >
524 {
525 std::vector< SubEvent > subEvents;
526
527 // Check if any of the information is available:
528 if( ( ! timeAcc.isAvailable( *this ) ) &&
529 ( ! indexAcc.isAvailable( *this ) ) &&
530 ( ! linkAcc.isAvailable( *this ) ) &&
531 ( ! typeAcc.isAvailable( *this ) ) )
532 {
533 // If not, return right away:
534 return subEvents;
535 }
536 // A little sanity check:
537 size_t size = 0;
538 if( timeAcc.isAvailable( *this ) ) {
539 size = timeAcc( *this ).size();
540 } else if( indexAcc.isAvailable( *this ) ) {
541 size = indexAcc( *this ).size();
542 } else if( linkAcc.isAvailable( *this ) ) {
543 size = linkAcc( *this ).size();
544 } else if( typeAcc.isAvailable( *this ) ) {
545 size = typeAcc( *this ).size();
546 } else {
547 std::cerr << "xAOD::EventInfo_v1 ERROR Logic error in subEvents()"
548 << std::endl;
549 return subEvents;
550 }
551 if( ( timeAcc.isAvailable( *this ) &&
552 ( size != timeAcc( *this ).size() ) ) ||
553 ( indexAcc.isAvailable( *this ) &&
554 ( size != indexAcc( *this ).size() ) ) ||
555 ( linkAcc.isAvailable( *this ) &&
556 ( size != linkAcc( *this ).size() ) ) ||
557 ( typeAcc.isAvailable( *this ) &&
558 ( size != typeAcc( *this ).size() ) ) ) {
559 std::cerr << "xAOD::EventInfo_v1 ERROR Data corruption found in "
560 << "the sub-event information" << std::endl;
561 std::cerr << "subEventTime = "
562 << ( timeAcc.isAvailable( *this ) ? timeAcc( *this ) :
563 std::vector< int16_t >() ) << std::endl;
564 std::cerr << "subEventIndex = "
565 << ( indexAcc.isAvailable( *this ) ? indexAcc( *this ) :
566 std::vector< uint16_t >() ) << std::endl;
567 std::cerr << "subEventLink = "
568 << ( linkAcc.isAvailable( *this ) ? linkAcc( *this ) :
569 std::vector< ElementLink< EventInfoContainer_v1 > >() )
570 << std::endl;
571 std::cerr << "subEventType = "
572 << ( typeAcc.isAvailable( *this ) ? typeAcc( *this ) :
573 std::vector< uint16_t >() ) << std::endl;
574 return subEvents;
575 }
576 // Fill up the cache:
577 for( size_t i = 0; i < size; ++i ) {
578 const int16_t time =
579 timeAcc.isAvailable( *this ) ? timeAcc( *this )[ i ] : 0;
580 const uint16_t index =
581 indexAcc.isAvailable( *this ) ? indexAcc( *this )[ i ] : 0;
583 linkAcc.isAvailable( *this ) ? linkAcc( *this )[ i ] :
585 const PileUpType type =
586 ( typeAcc.isAvailable( *this ) ?
587 static_cast< PileUpType >( typeAcc( *this )[ i ] ) :
588 Unknown );
589 subEvents.emplace_back( time, index, type, link );
590 }
591
592 return subEvents;
593 }
594
595 const std::vector< EventInfo_v1::SubEvent >&
597
598 // Cache the new information if necessary:
599 if( !m_subEvents.isValid() ) {
601 }
602
603 // Return the cached vector:
604 return *m_subEvents.ptr();
605 }
606
607 void EventInfo_v1::setSubEvents( const std::vector< SubEvent >& value ) {
608
609 // Update the cached information:
610 m_subEvents.store (value);
611
612 // Clear the persistent information:
613 timeAcc( *this ).clear(); indexAcc( *this ).clear();
614 typeAcc( *this ).clear(); linkAcc( *this ).clear();
615
616 // Fill the persistent information:
617 std::vector< SubEvent >::const_iterator itr = value.begin();
618 std::vector< SubEvent >::const_iterator end = value.end();
619 for( ; itr != end; ++itr ) {
620 timeAcc( *this ).push_back( itr->time() );
621 indexAcc( *this ).push_back( itr->index() );
622 typeAcc( *this ).push_back( static_cast< uint16_t >( itr->type() ) );
623 linkAcc( *this ).push_back( itr->link() );
624 }
625
626 return;
627 }
628
629 void EventInfo_v1::addSubEvent( const SubEvent& subEvent ) {
630
631 // First, make sure that the persistent and transient variables are in
632 // sync:
633 subEvents();
634
635 // Now, add the new sub-event:
636 std::vector<SubEvent> subEvents = *m_subEvents.ptr();
637 subEvents.push_back( subEvent );
638 m_subEvents.store (std::move (subEvents));
639 timeAcc( *this ).push_back( subEvent.time() );
640 indexAcc( *this ).push_back( subEvent.index() );
641 typeAcc( *this ).push_back( static_cast< uint16_t >( subEvent.type() ) );
642 linkAcc( *this ).push_back( subEvent.link() );
643
644 return;
645 }
646
648
649 // Clear both the transient and persistent variables:
650 m_subEvents.store (std::vector<SubEvent>());
651 m_subEvents.reset();
652 timeAcc( *this ).clear(); indexAcc( *this ).clear();
653 typeAcc( *this ).clear(); linkAcc( *this ).clear();
654
655 return;
656 }
657
659 {
660 static const std::string typNam[PileUp_NTYPES+1] = {
661 "Unknown" /*99*/,
662 "Signal" /*0*/,
663 "MinimumBias" /*1*/,
664 "Cavern" /*2*/,
665 "HaloGas"/*3*/,
666 "ZeroBias"/*4*/ };
667 int t = (typ==Unknown)? 0: (int)typ+1;
668 assert( t <= PileUp_NTYPES );
669 return typNam[t];
670 }
671
673 {
674 static const PileUpType typEnum[PileUp_NTYPES+1] = {
675 Unknown /*99*/, Signal /*0*/, MinimumBias /*1*/, Cavern /*2*/, HaloGas /*3*/, ZeroBias /*4*/
676 };
677 int t = (typ==99)? 0: (int)typ+1;
678 assert( t <= PileUp_NTYPES );
679 return typEnum[t];
680 }
681
682 //
684
686 //
687 // Implementation of the detector flags
688 //
689
691 static const uint32_t EF_BITS = 0x0FFFFFFF;
693 static const uint32_t EF_ERROR_BITS = 0xF0000000;
695 static const uint32_t EF_ERROR_SHIFT = 28;
696
698
699 return ( ( *eventFlagsConstAccessorsV1( subDet ) )( *this ) &
700 EF_BITS );
701 }
702
704 size_t bit ) const {
705
706 // A little sanity check:
707 if( bit >= EF_ERROR_SHIFT ) {
708 throw std::runtime_error( "EventInfo_v1::isEventFlagBitSet: Asked for "
709 "non-existent bit" );
710 }
711
712 // Get the value of the flags:
713 uint32_t value = ( *eventFlagsConstAccessorsV1( subDet ) )( *this );
714
715 // Dig out the bit we are asking for:
716 return ( ( value >> bit ) & 0x1 );
717 }
718
720
721 // Get the accessor:
723 if( ! acc ) {
724 return false;
725 }
726
727 // Construct the value that we want to store, taking the current error
728 // flags into account:
729 std::atomic<uint32_t>& a = (*acc)(*this);
730 uint32_t orig = a;
731 uint32_t value = ( ( orig & EF_ERROR_BITS ) | ( flags & EF_BITS ) );
732 while (!a.compare_exchange_strong (orig, value)) {
734 value = ( ( orig & EF_ERROR_BITS ) | ( flags & EF_BITS ) );
735 }
736
737 // Tell the user that we were successful:
738 return true;
739 }
740
741 bool EventInfo_v1::setEventFlagBit( EventFlagSubDet subDet, size_t bit) const
742 {
743 return updateEventFlagBit (subDet, bit);
744 }
745
746 bool EventInfo_v1::updateEventFlagBit( EventFlagSubDet subDet, size_t bit) const
747 {
748 // Check if the bit makes sense:
749 if( bit >= EF_ERROR_SHIFT ) {
750 return false;
751 }
752
753 // Don't try to write if the requested flag is already set.
754 uint32_t existingFlags = (*eventFlagsConstAccessorsV1( subDet ))( *this );
755 if (existingFlags & (1u << bit)) {
756 return true;
757 }
758
759 // Get the accessor:
761 if( ! acc ) {
762 return false;
763 }
764
765 // Set the new value:
766 ( *acc )( *this ) |= ( 1u << bit );
767
768 // Tell the user that we were successful:
769 return true;
770 }
771
773 {
774 // Get the accessor:
776 if( ! acc ) {
777 return false;
778 }
779
780 // Check if the bit makes sense:
781 if( bit >= EF_ERROR_SHIFT ) {
782 return false;
783 }
784
785 // Set the new value:
786 ( *acc )( *this ) &= ~( 1u << bit );
787
788 // Tell the user that we were successful:
789 return true;
790 }
791
793 const uint32_t flags_in) const
794 {
795 uint32_t flags = flags_in & EF_BITS;
796
797 // Don't try to write if all requested flags are already set.
798 uint32_t existingFlags = (*eventFlagsConstAccessorsV1( subDet ))( *this );
799 if ((existingFlags | flags) == existingFlags) {
800 return true;
801 }
802
803 // Get the accessor:
805 if( ! acc ) {
806 return false;
807 }
808
809 // Set the new value:
810 ( *acc )( *this ) |= ( flags & EF_BITS );
811
812 // Tell the user that we were successful:
813 return true;
814 }
815
818
819 // Get the value in one go:
820 return static_cast< EventFlagErrorState >(
821 ( ( *eventFlagsConstAccessorsV1( subDet ) )( *this ) >> EF_ERROR_SHIFT ) &
822 0xF );
823 }
824
826 EventFlagErrorState state ) {
827
828 // Get the accessor:
830 if( ! acc ) {
831 return false;
832 }
833
834 // Check its value:
835 if( ( state != NotSet ) && ( state != Warning ) && ( state != Error ) ) {
836 return false;
837 }
838
839 // Construct the new value:
840 std::atomic<uint32_t>& a = (*acc)(*this);
841 uint32_t orig = a;
842 uint32_t value = ( ( orig & EF_BITS ) |
843 ( static_cast< uint32_t >( state ) <<
844 EF_ERROR_SHIFT ) );
845 while (!a.compare_exchange_strong (orig, value)) {
847 value = ( ( orig & EF_BITS ) |
848 ( static_cast< uint32_t >( state ) <<
849 EF_ERROR_SHIFT ) );
850 }
851
852 // Tell the user that we were successful:
853 return true;
854 }
855
857 const EventFlagErrorState state ) const
858 {
859 // Check its value:
860 if( ( state != NotSet ) && ( state != Warning ) && ( state != Error ) ) {
861 return false;
862 }
863
864 // Return without trying to write if the desired state is
865 // already set.
866 if (errorState (subDet) == state) {
867 return true;
868 }
869
870 // Get the accessor:
872 if( ! acc ) {
873 return false;
874 }
875
876 // Construct the new value:
877 std::atomic<uint32_t>& a = (*acc)(*this);
878 uint32_t orig = a;
879
880 // Only allow increasing the error state in an update.
881 if (state < ((orig >> EF_ERROR_SHIFT) & 0xf)) {
882 return false;
883 }
884
885 uint32_t value = ( ( orig & EF_BITS ) |
886 ( static_cast< uint32_t >( state ) <<
887 EF_ERROR_SHIFT ) );
888 while (!a.compare_exchange_strong (orig, value)) {
889 if (state < ((orig >> EF_ERROR_SHIFT) & 0xf)) {
890 return false;
891 }
892
893 value = ( ( orig & EF_BITS ) |
894 ( static_cast< uint32_t >( state ) <<
895 EF_ERROR_SHIFT ) );
896
898 }
899
900 // Tell the user that we were successful:
901 return true;
902 }
903
904 //
906
908 //
909 // Implementation of the beam spot functions
910 //
911
915
916 void EventInfo_v1::setBeamPos( float x, float y, float z ) {
917
918 // The accessor objects:
919 static const Accessor< float > accX( "beamPosX" );
920 static const Accessor< float > accY( "beamPosY" );
921 static const Accessor< float > accZ( "beamPosZ" );
922
923 // Set the variables:
924 accX( *this ) = x;
925 accY( *this ) = y;
926 accZ( *this ) = z;
927
928 return;
929 }
930
934
935 void EventInfo_v1::setBeamPosSigma( float x, float y, float z ) {
936
937 // The accessor objects:
938 static const Accessor< float > accX( "beamPosSigmaX" );
939 static const Accessor< float > accY( "beamPosSigmaY" );
940 static const Accessor< float > accZ( "beamPosSigmaZ" );
941
942 // Set the variables:
943 accX( *this ) = x;
944 accY( *this ) = y;
945 accZ( *this ) = z;
946
947 return;
948 }
949
952
957
960
961
963 static const SG::AuxElement::Accessor< float >
964 accBeamSpotWeight( "beamSpotWeight" );
965
967 return accBeamSpotWeight.isAvailable( *this );
968 }
969
971 // If the value is not available, then return 1.0
972 if( ! hasBeamSpotWeight() ) return 1.0f;
973 return accBeamSpotWeight( *this );
974 }
975
977 accBeamSpotWeight( *this ) = value;
978 return;
979 }
980
981
982 //
984
985 StoreGateSvc* EventInfo_v1::evtStore() const {
986
987 return m_evtStore;
988 }
989
991
992 m_evtStore = svc;
993 return;
994 }
995
997
998 // Check if the ElementLink variable is available, and writable:
999 if( linkAcc.isAvailableWritable( *this ) ) {
1000 // Prepare the ElementLink objects for ROOT I/O:
1001 std::vector< ElementLink< EventInfoContainer_v1 > >::iterator
1002 el_itr = linkAcc( *this ).begin();
1003 std::vector< ElementLink< EventInfoContainer_v1 > >::iterator
1004 el_end = linkAcc( *this ).end();
1005 for( ; el_itr != el_end; ++el_itr ) {
1006 el_itr->toPersistent();
1007 }
1008 }
1009
1010 return;
1011 }
1012
1019
1020 m_streamTags.reset();
1021 m_subEvents.reset();
1022#ifdef XAOD_STANDALONE
1023 m_evtStore = nullptr;
1024#else
1026#endif
1027
1028 if( usingStandaloneStore() ) {
1029 setStore( ( SG::IAuxStore* ) nullptr );
1030 }
1031
1032 return;
1033 }
1034
1054 std::ostream& operator<< ( std::ostream& out,
1055 const xAOD::EventInfo_v1& ei ) {
1056
1057 // Get the current state of the stream:
1058 const char fillChar = out.fill();
1059 const std::ios_base::fmtflags flags = out.flags();
1060 const std::streamsize width = out.width();
1061
1062 // Do the printout:
1063 out << "[Run,Evt,Lumi,Time,BunchCross,DetMask] = ["
1064 << ei.runNumber()
1065 << "," << ei.eventNumber()
1066 << "," << ei.lumiBlock()
1067 << "," << ei.timeStamp()
1068 << ":" << ei.timeStampNSOffset()
1069 << "," << ei.bcid()
1070 << ",0x" << std::hex << std::setw( 16 ) << std::setfill( '0' )
1071 << ei.detectorMask()
1072 << "]";
1073
1074 // Restore the original state of the stream:
1075 out.fill( fillChar );
1076 out.flags( flags );
1077 out.width( width );
1078
1079 // Return the stream:
1080 return out;
1081 }
1082
1090 std::ostream& operator<<( std::ostream &out,
1092
1093 // Get the current state of the stream:
1094 const char fillChar = out.fill();
1095 const std::ios_base::fmtflags flags = out.flags();
1096 const std::streamsize width = out.width();
1097
1098 // Do the printout:
1099 out << std::hex << std::setw( 16 ) << std::setfill( '0' );
1100 out << id.lowBits;
1101 out << id.highBits;
1102
1103 // Restore the original state of the stream:
1104 out.fill( fillChar );
1105 out.flags( flags );
1106 out.width( width );
1107
1108
1109 // Return the stream:
1110 return out;
1111 }
1112
1122
1123 return a.lowBits == b.lowBits && a.highBits == b.highBits;
1124
1125 }
1126
1127} // namespace xAOD
Access an auxiliary variable atomically.
#define AUXSTORE_PRIMITIVE_GETTER(CL, TYPE, NAME)
Macro creating the reader function for a primitive auxiliary property.
#define AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(CL, TYPE, NAME, SETTER)
Macro creating the accessors of primitive auxiliary properties.
#define AUXSTORE_OBJECT_SETTER_AND_GETTER(CL, TYPE, NAME, SETTER)
Macro creating the accessors of complex auxiliary properties.
std::vector< size_t > vec
static Double_t a
static const std::vector< std::string > types
static const uint32_t mask3
Hold a pointer to the current event store.
const double width
#define y
#define x
#define z
This class represents the "type of event" where the type is given by one or more "characteristics".
Definition EventType.h:92
Access an auxiliary variable atomically.
void makePrivateStore()
Create a new (empty) private store for this object.
AuxElement & operator=(const AuxElement &other)
Assignment.
void setStore(const SG::IConstAuxStore *store)
Set the store associated with this object.
bool usingStandaloneStore() const
Test to see if this object is currently using a standalone store.
XAOD_AUXDATA_DEPRECATED bool isAvailable(const std::string &name, const std::string &clsname="") const
Check if an aux variable is available for reading.
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
AuxElement()
Default constructor.
static IProxyDict * store()
Fetch the current store.
Interface for non-const operations on an auxiliary store.
Definition IAuxStore.h:48
The Athena Transient Store API.
bool obeysLumiblock() const
Get whether the the stream obeys the luminosity block boundaires.
StreamTag(const std::string &name, const std::string &type, bool obeysLumiblock, const std::set< uint32_t > &robs=std::set< uint32_t >(), const std::set< uint32_t > &dets=std::set< uint32_t >())
Constructor giving all relevant information to the object.
const std::set< uint32_t > & dets() const
Get the (optional) list of detector IDs for partial event building.
std::set< uint32_t > m_dets
Optional list of detector IDs for PEB.
bool m_obeysLumiblock
Whether the stream obeys luminosity block boundaries.
const std::string & type() const
Get the type of the stream.
std::string m_type
The type of the stream.
std::string m_name
The name of the stream.
const std::string & name() const
Get the name of the stream.
std::set< uint32_t > m_robs
Optional list of RoB IDs for PEB.
const std::set< uint32_t > & robs() const
Get the (optional) list of RoB IDs for partial event building.
Class describing the properties of one pileup sub-event.
uint16_t m_index
The index of the pileup event.
PileUpType m_type
The type of the pileup event.
ElementLink< EventInfoContainer_v1 > m_link
Link to the EventInfo object in question.
uint16_t index() const
Get the index of the sub-event.
const ElementLink< EventInfoContainer_v1 > & link() const
Get a link to the EventInfo object describing the pileup event.
int16_t m_time
The time wrt. the signal event.
int16_t time() const
Get the time wrt. the signal event (which has time() == 0)
const EventInfo_v1 * ptr() const
Get a pointer to the EventInfo object describing the pileup event.
PileUpType type() const
Get the type of the pileup event.
const std::string & typeName() const
The string name of the type.
Class describing the basic event information.
void setBeamPosSigma(float x, float y, float z)
Set the size of the beam spot.
static const std::string & PileUpType2Name(PileUpType typ)
Convert PileUpType enum value to string.
uint32_t detectorMask3() const
Bit field indicating which TTC zones are present in the event.
void setAverageInteractionsPerCrossing(float value)
Set average interactions per crossing for all BCIDs.
CxxUtils::CachedValue< std::vector< StreamTag > > m_streamTags
Cached stream tag objects.
bool resetEventFlagBit(EventFlagSubDet subDet, size_t bit)
Reset one particular bit of one particular sub-detector.
uint64_t pileUpMixtureIDLowBits() const
Unique pile-up mixture identifier low bits.
float beamPosSigmaY() const
The width of the beam spot in the Y direction.
void setDetectorMask(uint32_t mask0, uint32_t mask1)
Set the bit fields indicating with TTC timezones were present.
uint32_t lumiBlock() const
The current event's luminosity block number.
bool eventType(EventType type) const
Check for one particular bitmask value.
std::vector< EventInfo_v1::SubEvent > makeSubEvents() const
void toPersistent()
Prepare the object for writing.
std::vector< std::pair< std::string, std::string > > DetDescrTags_t
Type of the detector description tags.
uint32_t eventTypeBitmask() const
The event type bitmask.
uint32_t bcid() const
The bunch crossing ID of the event.
EventFlagSubDet
Sub-detector types for which we store event-level flags.
float beamPosX() const
X coordinate of the beam spot position.
void setDetectorMask1(uint32_t value)
Set the bit field indicating with TTC timezones were present.
bool updateEventFlagBit(const EventFlagSubDet subDet, const size_t bit) const
Change detector flags with update semantics.
void setStreamTags(const std::vector< StreamTag > &value)
Set the streams that the event was put in.
void setBeamTiltYZ(float value)
Set the beam's tilt in radians in YZ.
bool setErrorState(EventFlagSubDet subDet, EventFlagErrorState state)
Set the error state for a particular sub-detector.
void clearSubEvents()
Clear all the currently held sub-events.
StoreGateSvc * m_evtStore
Transient pointer to the StoreGateSvc instance associated with the event (Needed for pile-up digitisa...
float beamPosSigmaXY() const
The beam spot shape's X-Y correlation.
float beamSpotWeight() const
Weight for beam spot size reweighting.
void toTransient()
Cleanse the object after being read in.
bool updateEventFlags(const EventFlagSubDet subDet, const uint32_t flags_in) const
Turn on a set of event flags for one particular sub-detector.
void setDetectorMask0(uint32_t value)
Set the bit field indicating with TTC timezones were present.
bool setEventFlags(EventFlagSubDet subDet, uint32_t flags)
Set the event flags for a particular sub-detector.
EventInfo_v1 & operator=(const EventInfo_v1 &rhs)
Assignment operator.
bool isEventFlagBitSet(EventFlagSubDet subDet, size_t bit) const
Check one particular bit of one particular sub-detector.
void setDetectorMaskExt(uint32_t mask2, uint32_t mask3)
Set the bit fields indicating with TTC timezones were present.
void setSubEvents(const std::vector< SubEvent > &value)
Set the pileup events that were used in the simulation.
void setBeamSpotWeight(float value)
Set weight for beam spot size reweighting.
float averageInteractionsPerCrossing() const
Average interactions per crossing for all BCIDs - for out-of-time pile-up.
void setBeamPos(float x, float y, float z)
Set the beam spot position.
EventFlagErrorState
States that a given sub-detector could be in.
@ Warning
The sub-detector issued a warning.
@ NotSet
The flag was not set to anything.
@ Error
The sub-detector issued an error.
float beamTiltYZ() const
The beam's tilt in radians in YZ.
PileUpMixtureID pileUpMixtureID() const
Unique pile-up mixture identifier.
void setBeamPosSigmaXY(float value)
Set the beam spot shape's X-Y correlation.
float actualInteractionsPerCrossing() const
Average interactions per crossing for the current BCID - for in-time pile-up.
CxxUtils::CachedValue< std::vector< SubEvent > > m_subEvents
Cached sub-event objects.
uint32_t timeStamp() const
POSIX time in seconds from 1970. January 1st.
void addSubEvent(const SubEvent &subEvent)
Add one sub-event to the existing list.
void setPileUpMixtureID(const PileUpMixtureID &value)
Set unique pile-up mixture identifier.
void setDetectorMask2(uint32_t value)
Set the bit field indicating with TTC timezones were present.
void setBeamStatus(uint32_t value)
Set the beam spot's status word.
uint32_t eventFlags(EventFlagSubDet subDet) const
Get the event flags for a particular sub-detector.
uint64_t detectorMaskExt() const
Bit field indicating which TTC zones are present in the event.
const std::vector< SubEvent > & subEvents() const
Get the pileup events that were used in the simulation.
const std::vector< StreamTag > & streamTags() const
Get the streams that the event was put in.
void setDetectorMask3(uint32_t value)
Set the bit field indicating with TTC timezones were present.
EventInfo_v1()
Default constructor.
void setEvtStore(StoreGateSvc *svc)
Set the pointer to the event store associated with this event.
float beamPosSigmaX() const
The width of the beam spot in the X direction.
uint32_t detectorMask0() const
Bit field indicating which TTC zones are present in the event.
PileUpType
Enumerator describing the types of pileup events.
@ HaloGas
Halo-gas non-collision background.
@ HighPtMinimumBias
High pT Minimum bias pileup event.
@ MinimumBias
(Low pT) Minimum bias pileup event
@ ZeroBias
Zero bias pileup event.
@ Signal
The signal event.
@ Cavern
Cavern background pileup event.
@ Unknown
Type not known/specified.
void setBeamTiltXZ(float value)
Set the beam's tilt in radians in XZ.
float beamPosZ() const
Z coordinate of the beam spot position.
uint64_t pileUpMixtureIDHighBits() const
Unique pile-up mixture identifier high bits.
bool updateErrorState(const EventFlagSubDet subDet, const EventFlagErrorState state) const
Update the error state for one particular sub-detector.
uint32_t runNumber() const
The current event's run number.
bool hasBeamSpotWeight() const
Check if weight for beam spot size reweighting exists.
void setPileUpMixtureIDHighBits(uint64_t value)
Set unique pile-up mixture identifier high bits.
uint32_t detectorMask2() const
Bit field indicating which TTC zones are present in the event.
uint32_t timeStampNSOffset() const
Nanosecond time offset wrt. the time stamp.
EventFlagErrorState errorState(EventFlagSubDet subDet) const
Get the error state for a particular sub-detector.
uint64_t eventNumber() const
The current event's event number.
float beamPosSigmaZ() const
The length of the beam spot in the Z direction.
float beamPosY() const
Y coordinate of the beam spot position.
float mcEventWeight(size_t i=0) const
The weight of one specific MC event used in the simulation.
bool setEventFlagBit(EventFlagSubDet subDet, size_t bit) const
Set one particular bit of one particular sub-detector.
uint64_t detectorMask() const
Bit field indicating which TTC zones are present in the event.
static PileUpType PileUpInt2Type(unsigned short typ)
Convert int to PileUpType enum value.
void setPileUpMixtureIDLowBits(uint64_t value)
Set unique pile-up mixture identifier low bits.
void setActualInteractionsPerCrossing(float value)
Set average interactions per crossing for the current BCID.
std::vector< std::string > tags
Definition hcg.cxx:105
void stall()
Emit stall instruction for use in a spin loop.
Definition stall.h:37
Forward declaration.
Definition index.py:1
STL namespace.
std::ostream & operator<<(std::ostream &out, const std::set< T > &s)
Convenience operator for printing the contents of sets.
static const SG::AuxElement::Accessor< uint64_t > accMcEvNum("mcEventNumber")
void pileupUnsetHook()
Function that would be possible to use to debug what client is trying to access pileup values from an...
static const SG::AuxElement::Accessor< uint64_t > accHigh("pileUpMixtureIDHighBits")
static const SG::AuxElement::Accessor< uint64_t > accLow("pileUpMixtureIDLowBits")
static const SG::AuxElement::Accessor< uint64_t > accEvNum("eventNumber")
ICaloAffectedTool is abstract interface for tools checking if 4 mom is in calo affected region.
static const SG::AuxElement::Accessor< std::vector< int16_t > > timeAcc("subEventTime")
const SG::AtomicDecorator< uint32_t > * eventFlagsAccessorsV1(EventInfo_v1::EventFlagSubDet subDet)
Helper function for accessing event flag variables.
static const SG::AuxElement::Accessor< std::vector< uint16_t > > typeAcc("subEventType")
static const EventInfo_v1::Accessor< std::vector< std::set< uint32_t > > > detsets("streamTagDets")
setEventNumber timeStamp
static const EventInfo_v1::Accessor< std::vector< std::set< uint32_t > > > robsets("streamTagRobs")
static const EventInfo_v1::Accessor< std::vector< char > > olb("streamTagObeysLumiblock")
static const uint32_t EF_ERROR_SHIFT
Shift used to store the sub-detector error states.
setMCChannelNumber mcEventWeights
pileUpMixtureIDHighBits
setRawEt setRawPhi int
setTeId lumiBlock
static const uint32_t EF_BITS
Bits that store the "user defined" detector flags.
bool operator==(const xAOD::EventInfo_v1::PileUpMixtureID &a, const xAOD::EventInfo_v1::PileUpMixtureID &b)
This operator is provided to make it convenient to compare two instances of PileUpMixtureID directly.
static const EventInfo_v1::Accessor< std::vector< std::string > > types("streamTagTypes")
static const SG::AuxElement::Accessor< float > accAverageInteractionsPerCrossing("averageInteractionsPerCrossing")
Accessor for "averageInteractionsPerCrossing".
setScaleOne setStatusOne setSaturated int16_t
static const SG::AuxElement::Accessor< std::vector< std::string > > names("thrNames")
Accessor for the names of the passed thresholds.
AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(BTagging_v1, float, IP2D_pb, setIP2D_pb) AUXSTORE_PRIMITIVE_SETTER_AND_GETTER(BTagging_v1
static const SG::AuxElement::Accessor< float > accActualInteractionsPerCrossing("actualInteractionsPerCrossing")
Accessor for "actualInteractionsPerCrossing".
setEventNumber setTimeStamp setBCID setDetectorMask1 detectorMask3
static const uint32_t EF_ERROR_BITS
Bits that store the error state of the sub-detectors.
setBeamTiltXZ static setBeamStatus const SG::AuxElement::Accessor< float > accBeamSpotWeight("beamSpotWeight")
Accessor for "BeamSpotWeight".
static const SG::AuxElement::Accessor< ElementLink< IParticleContainer > > acc("originalObjectLink")
Object used for setting/getting the dynamic decoration in question.
setEventNumber setTimeStamp bcid
std::ostream & operator<<(std::ostream &out, const std::pair< FIRST, SECOND > &pair)
Helper print operator.
setWord1 uint16_t
JetConstituentVector::iterator iterator
setBeamTiltXZ beamStatus
AUXSTORE_OBJECT_SETTER_AND_GETTER(CaloRings_v1, RingSetLinks, ringSetLinks, setRingSetLinks) unsigned CaloRings_v1
setEventNumber setTimeStamp setBCID detectorMask1
static const SG::AuxElement::Accessor< std::vector< ElementLink< EventInfoContainer_v1 > > > linkAcc("subEventLink")
setEventNumber uint32_t
static const SG::AuxElement::Accessor< std::vector< uint16_t > > indexAcc("subEventIndex")
const SG::AtomicConstAccessor< uint32_t > * eventFlagsConstAccessorsV1(EventInfo_v1::EventFlagSubDet subDet)
Helper function for accessing event flag variables, for const access.
Emit stall instruction for use in a spin loop.
Unique pile-up mixture identifier definition.