47 std::set< BunchTrain >::const_iterator itr =
m_bunchTrains.begin();
48 std::set< BunchTrain >::const_iterator end =
m_bunchTrains.end();
49 for( ; itr != end; ++itr ) {
50 if( itr->find( bcid ) != itr->end() ) {
71 std::set< BunchCrossing >::const_iterator itr_fill =
78 std::set< BunchCrossing >::const_iterator itr_unp =
81 ( itr_unp->intensityBeam1() > 0.001 ) ) {
91 std::set< BunchCrossing >::const_iterator itr_fill =
98 std::set< BunchCrossing >::const_iterator itr_unp =
101 ( itr_unp->intensityBeam2() > 0.001 ) ) {
112 std::set< BunchCrossing >::const_iterator itr;
116 if( itr->intensityBeam2() > 0.001 ) {
118 <<
"separate beam intensities instead" );
121 return itr->intensityBeam1();
124 if( std::abs( itr->intensityBeam2() ) < 0.001 ) {
126 <<
"for the crossing intensity instead" );
129 return itr->intensityBeam1();
133 return itr->intensityBeam2();
147 return itr->intensityBeam1();
150 return itr->intensityBeam2();
154 <<
"bcid=" << bcid <<
")" );
181 std::set< BunchTrain >::const_iterator itr =
m_bunchTrains.begin();
182 std::set< BunchTrain >::const_iterator end =
m_bunchTrains.end();
183 for( ; itr != end; ++itr ) {
184 if( itr->isInside( bcid ) ) {
245 std::set< BunchTrain >::const_iterator itr =
m_bunchTrains.begin();
246 std::set< BunchTrain >::const_iterator end =
m_bunchTrains.end();
247 for( ; itr != end; ++itr ) {
248 BunchTrain::const_iterator element;
249 if( ( element = itr->find( bcid ) ) != itr->end() ) {
254 *( itr->train_front() ) );
260 if( *( itr->train_front() ) > *( itr->train_back() ) ) {
262 return ( std::count_if( itr->begin(), element,
263 std::bind( std::not_equal_to< BunchCrossing >(),
264 *element, std::placeholders::_1 ) ) +
265 std::count_if( itr->train_front(), itr->end(),
266 std::bind( std::not_equal_to< BunchCrossing >(),
267 *element, std::placeholders::_1 ) ) );
269 return std::count_if( itr->train_front(), element,
270 std::bind( std::not_equal_to< BunchCrossing >(),
271 *element, std::placeholders::_1 ) );
274 return std::count_if( itr->begin(), element,
275 std::bind( std::not_equal_to< BunchCrossing >(),
276 *element, std::placeholders::_1 ) );
322 std::set< BunchTrain >::const_iterator itr =
m_bunchTrains.begin();
323 std::set< BunchTrain >::const_iterator end =
m_bunchTrains.end();
324 for( ; itr != end; ++itr ) {
325 BunchTrain::const_iterator element;
326 if( ( element = itr->find( bcid ) ) != itr->end() ) {
337 if( *( itr->train_front() ) > *( itr->train_back() ) ) {
339 return ( std::count_if( element, itr->end(),
340 std::bind( std::not_equal_to< BunchCrossing >(),
341 *element, std::placeholders::_1 ) ) +
342 std::count_if( itr->begin(), ++( itr->train_back() ),
343 std::bind( std::not_equal_to< BunchCrossing >(),
344 *element, std::placeholders::_1 ) ) );
346 return std::count_if( element, ++( itr->train_back() ),
347 std::bind( std::not_equal_to< BunchCrossing >(),
348 *element, std::placeholders::_1 ) );
351 return std::count_if( element, itr->end(),
352 std::bind( std::not_equal_to< BunchCrossing >(),
353 *element, std::placeholders::_1 ) );
379 return bunchTrain.contains(bcid);
389 auto dist = train->train_front()->
distance( prevFilled );
399 ATH_MSG_ERROR(
"You can only use NanoSec or BunchCrossings for type "
400 "for gapBeforeTrain" );
417 return bunchTrain.contains(bcid);
425 do {++train_front; }
while (!
isFilled(train_front));
426 const auto dist = train_front.
distance(*train->train_back());
436 ATH_MSG_ERROR(
"You can only use NanoSec or BunchCrossings for type "
437 "for gapAfterTrain" );
464 int loop_counter = 0;
470 while( ( !
isFilled( prev_bunch ) ) &&
477 << bcid <<
" to a filled bunch! This shouldn't have "
533 << bcid <<
" to an empty bunch! This shouldn't have "
551 return bunch.
gapFrom( prev_bunch );
554 ATH_MSG_ERROR(
"You can only use NanoSec or BunchCrossings for type "
555 "for gapBeforeBunch" );
585 int loop_counter = 0;
591 while( ( !
isFilled( next_bunch ) ) &&
598 << bcid <<
" to a filled bunch! This shouldn't have "
654 << bcid <<
" to an empty bunch! This shouldn't have "
672 return bunch.
gapTo( next_bunch );
675 ATH_MSG_ERROR(
"You can only use NanoSec or BunchCrossings for type "
676 "for gapBeforeBunch" );
686 int bunches )
const {
691 std::vector< bool > result;
692 for(
int i = 0; i < bunches; ++i ) {
702 int bunches )
const {
707 std::vector< bool > result;
708 for(
int i = 0; i < bunches; ++i ) {
721 std::vector< float > result;
722 for(
int i = 0; i < bunches; ++i ) {
723 std::set< BunchCrossing >::const_iterator itr =
729 result.push_back( itr->intensityBeam1() );
732 result.push_back( itr->intensityBeam2() );
740 result.push_back( 0.0 );
752 std::vector< float > result;
753 for(
int i = 0; i < bunches; ++i ) {
754 std::set< BunchCrossing >::const_iterator itr =
760 result.push_back( itr->intensityBeam1() );
763 result.push_back( itr->intensityBeam2() );
771 result.push_back( 0.0 );
807 ATH_MSG_ERROR(
"Function should not be called with argument: "
820 ATH_MSG_FATAL(
"The code should never reach this line. Check the code!" );
839 const std::vector< float >& bunch_int1,
840 const std::vector< float >& bunch_int2 ) {
843 if( ( ( bunches.size() != bunch_int1.size() ) && bunch_int1.size() ) ||
844 ( ( bunches.size() != bunch_int2.size() ) && bunch_int2.size() ) ) {
845 ATH_MSG_ERROR(
"Received vectors of different sizes for the bunch "
846 "IDs and bunch intensities\n"
847 "Function can not work like this..." );
848 return StatusCode::FAILURE;
850 if( ! bunch_int1.size() ) {
851 ATH_MSG_DEBUG(
"Not using bunch intensity for the calculation" );
853 if( ( ! bunch_int2.size() ) && bunch_int1.size() ) {
870 std::vector< int >::const_iterator b_itr = bunches.begin();
871 std::vector< int >::const_iterator b_end = bunches.end();
872 std::vector< float >::const_iterator i1_itr = bunch_int1.begin();
873 std::vector< float >::const_iterator i2_itr = bunch_int2.begin();
874 for( ; b_itr != b_end; ++b_itr ) {
877 const float intensity1 = bunch_int1.size() ? *i1_itr : 1.0;
878 const float intensity2 = bunch_int2.size() ? *i2_itr : 0.0;
901 const int neighbours =
902 std::count_if( bunches.begin(), bunches.end(),
903 [ maxBCSpacing, &b_itr ](
int bunch ) {
904 return ( Trig::distance( bunch, *b_itr ) <=
913 if( neighbours == 1 ) {
915 <<
" seems to be a single bunch" );
921 if( bunch_int1.size() ) ++i1_itr;
922 if( bunch_int2.size() ) ++i2_itr;
930 return StatusCode::SUCCESS;
955 const std::vector< float >& bunch_int1,
956 const std::vector< float >& bunch_int2 ) {
959 if( ( ( bunches.size() != bunch_int1.size() ) && bunch_int1.size() ) ||
960 ( ( bunches.size() != bunch_int2.size() ) && bunch_int2.size() ) ) {
961 ATH_MSG_ERROR(
"Received vectors of different sizes for the bunch "
962 "IDs and bunch intensities\n"
963 "Function can not work like this..." );
964 return StatusCode::FAILURE;
966 if( ! bunch_int1.size() ) {
967 ATH_MSG_DEBUG(
"Not using bunch intensity for the calculation" );
969 if( ( ! bunch_int2.size() ) && bunch_int1.size() ) {
986 std::set< BunchCrossing > cache;
987 std::vector< int >::const_iterator b_itr = bunches.begin();
988 std::vector< int >::const_iterator b_end = bunches.end();
989 std::vector< float >::const_iterator i1_itr = bunch_int1.begin();
990 std::vector< float >::const_iterator i2_itr = bunch_int2.begin();
991 for( ; b_itr != b_end; ++b_itr ) {
995 (
float )( bunch_int1.size() ? *i1_itr :
997 (
float )( bunch_int2.size() ? *i2_itr :
1000 if( bunch_int1.size() ) ++i1_itr;
1001 if( bunch_int2.size() ) ++i2_itr;
1009 while( cache.size() ) {
1013 bt.insert( *cache.begin() );
1017 size_t prev_size = 0;
1018 while( prev_size != cache.size() ) {
1021 prev_size = cache.size();
1024 std::set< BunchCrossing >::const_iterator c_itr = cache.begin();
1025 std::set< BunchCrossing >::const_iterator c_end = cache.end();
1026 for( ; c_itr != c_end; ++c_itr ) {
1027 if( bt.
distance( *c_itr ) <= maxBCSpacing ) {
1029 <<
" to Bunch Train " << bt );
1030 bt.insert( *c_itr );
1035 BunchTrain::const_iterator itr = bt.begin();
1036 BunchTrain::const_iterator end = bt.end();
1037 for( ; itr != end; ++itr ) {
1038 cache.erase( *itr );
1054 std::set< BunchTrain >::const_iterator train_itr =
m_bunchTrains.begin();
1055 std::set< BunchTrain >::const_iterator train_end =
m_bunchTrains.end();
1057 for( ; train_itr != train_end; ++train_itr ) {
1059 spacing = train_itr->spacing();
1062 if( train_itr->spacing() != spacing ) {
1071 return StatusCode::SUCCESS;
1086 const std::vector< int >& beam2,
1087 const std::vector< float >& bunch_int1,
1088 const std::vector< float >& bunch_int2 ) {
1091 if( ( ( beam1.size() != bunch_int1.size() ) && bunch_int1.size() ) ||
1092 ( ( beam2.size() != bunch_int2.size() ) && bunch_int2.size() ) ) {
1093 ATH_MSG_ERROR(
"Received vectors of different sizes for the bunch "
1094 "IDs and bunch intensities\n"
1095 "Function can not work like this..." );
1096 return StatusCode::FAILURE;
1098 if( ( ! bunch_int1.size() ) && ( ! bunch_int2.size() ) ) {
1099 ATH_MSG_DEBUG(
"Not using bunch intensity for the calculation" );
1108 std::vector< int >::const_iterator b_itr = beam1.begin();
1109 std::vector< int >::const_iterator b_end = beam1.end();
1110 std::vector< float >::const_iterator i_itr = bunch_int1.begin();
1111 for( ; b_itr != b_end; ++b_itr ) {
1114 const float intensity = bunch_int1.size() ? *i_itr : 1.0;
1120 if( bunch_int1.size() ) ++i_itr;
1126 b_itr = beam2.begin();
1127 b_end = beam2.end();
1128 i_itr = bunch_int2.begin();
1129 for( ; b_itr != b_end; ++b_itr ) {
1132 const float intensity = bunch_int2.size() ? *i_itr : 1.0;
1135 std::set< BunchCrossing >::iterator itr =
1150 if( bunch_int2.size() ) ++i_itr;
1158 return StatusCode::SUCCESS;
1193 bunchSpacing(
const std::vector< int >& bunches )
const {
1200 int result = maxSpacing;
1201 for( ; result > 0; --result ) {
1204 const int nbunches =
1205 std::count_if( bunches.begin(), bunches.end(),
1208 <<
" BC neighbors: " << nbunches );
1218 if( result != maxSpacing ) {
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
A smart integer class representing bunch crossings.
int gapTo(const BunchCrossing &bc) const
Distance to a following bunch crossing.
int distance(const BunchCrossing &bc) const
The distance from another bunch crossing.
int gapFrom(const BunchCrossing &bc) const
Distance from a previous bunch crossing.
static const int MAX_BCID
The maximum number of bunches that can be in the LHC.
static const int BUNCH_SPACING
Minimum spacing between the bunches, in nanoseconds.
void setIntensityBeam2(float intensity)
Set the "intensity" of beam 2 in this bunch crossing.
A smart set of BunchCrossing objects.
bool validate()
Check the spacing of the bunches in the train.
int distance(const BunchCrossing &bc) const
"Distance" of a bunch crossing from this bunch train
Functor counting how many neighbors a given bunch crossing has.
The common trigger namespace for trigger analysis tools.
int distance(const BunchCrossing bc1, const BunchCrossing bc2)
I need this function only for technical reasons.