23 m_filledBunches(), m_singleBunches(), m_unpairedBunches(),
45 std::set< BunchTrain >::const_iterator itr =
m_bunchTrains.begin();
47 for( ; itr !=
end; ++itr ) {
48 if( itr->find(
bcid ) != itr->end() ) {
69 std::set< BunchCrossing >::const_iterator itr_fill =
76 std::set< BunchCrossing >::const_iterator itr_unp =
79 ( itr_unp->intensityBeam1() > 0.001 ) ) {
89 std::set< BunchCrossing >::const_iterator itr_fill =
96 std::set< BunchCrossing >::const_iterator itr_unp =
99 ( itr_unp->intensityBeam2() > 0.001 ) ) {
110 std::set< BunchCrossing >::const_iterator itr;
114 if( itr->intensityBeam2() > 0.001 ) {
116 <<
"separate beam intensities instead" );
119 return itr->intensityBeam1();
122 if( std::abs( itr->intensityBeam2() ) < 0.001 ) {
124 <<
"for the crossing intensity instead" );
127 return itr->intensityBeam1();
131 return itr->intensityBeam2();
145 return itr->intensityBeam1();
148 return itr->intensityBeam2();
152 <<
"bcid=" <<
bcid <<
")" );
179 std::set< BunchTrain >::const_iterator itr =
m_bunchTrains.begin();
181 for( ; itr !=
end; ++itr ) {
182 if( itr->isInside(
bcid ) ) {
243 std::set< BunchTrain >::const_iterator itr =
m_bunchTrains.begin();
245 for( ; itr !=
end; ++itr ) {
246 BunchTrain::const_iterator element;
247 if( ( element = itr->find(
bcid ) ) != itr->end() ) {
252 *( itr->train_front() ) );
258 if( *( itr->train_front() ) > *( itr->train_back() ) ) {
260 return ( std::count_if( itr->begin(), element,
261 std::bind( std::not_equal_to< BunchCrossing >(),
262 *element, std::placeholders::_1 ) ) +
263 std::count_if( itr->train_front(), itr->end(),
264 std::bind( std::not_equal_to< BunchCrossing >(),
265 *element, std::placeholders::_1 ) ) );
267 return std::count_if( itr->train_front(), element,
268 std::bind( std::not_equal_to< BunchCrossing >(),
269 *element, std::placeholders::_1 ) );
272 return std::count_if( itr->begin(), element,
273 std::bind( std::not_equal_to< BunchCrossing >(),
274 *element, std::placeholders::_1 ) );
320 std::set< BunchTrain >::const_iterator itr =
m_bunchTrains.begin();
322 for( ; itr !=
end; ++itr ) {
323 BunchTrain::const_iterator element;
324 if( ( element = itr->find(
bcid ) ) != itr->end() ) {
335 if( *( itr->train_front() ) > *( itr->train_back() ) ) {
337 return ( std::count_if( element, itr->end(),
338 std::bind( std::not_equal_to< BunchCrossing >(),
339 *element, std::placeholders::_1 ) ) +
340 std::count_if( itr->begin(), ++( itr->train_back() ),
341 std::bind( std::not_equal_to< BunchCrossing >(),
342 *element, std::placeholders::_1 ) ) );
344 return std::count_if( element, ++( itr->train_back() ),
345 std::bind( std::not_equal_to< BunchCrossing >(),
346 *element, std::placeholders::_1 ) );
349 return std::count_if( element, itr->end(),
350 std::bind( std::not_equal_to< BunchCrossing >(),
351 *element, std::placeholders::_1 ) );
378 std::set< BunchTrain >::const_iterator itr =
m_bunchTrains.begin();
380 std::set< BunchTrain >::const_iterator train =
m_bunchTrains.end();
381 for( ; itr !=
end; ++itr ) {
382 if( itr->find(
bcid ) != itr->end() ) {
405 train->train_front()->distance( train_tail );
408 return train->train_front()->distance( train_tail );
411 ATH_MSG_ERROR(
"You can only use NanoSec or BunchCrossings for type "
412 "for gapBeforeTrain" );
433 std::set< BunchTrain >::const_iterator itr =
m_bunchTrains.begin();
435 std::set< BunchTrain >::const_iterator train =
m_bunchTrains.end();
436 for( ; itr !=
end; ++itr ) {
437 if( itr->find(
bcid ) != itr->end() ) {
451 while( !
isFilled( train_front ) ) {
460 train_front.
distance( *( train->train_back() ) );
463 return train_front.
distance( *( train->train_back() ) );
466 ATH_MSG_ERROR(
"You can only use NanoSec or BunchCrossings for type "
467 "for gapAfterTrain" );
497 int loop_counter = 0;
503 while( ( !
isFilled( prev_bunch ) ) &&
510 <<
bcid <<
" to a filled bunch! This shouldn't have "
566 <<
bcid <<
" to an empty bunch! This shouldn't have "
584 return bunch.
gapFrom( prev_bunch );
587 ATH_MSG_ERROR(
"You can only use NanoSec or BunchCrossings for type "
588 "for gapBeforeBunch" );
618 int loop_counter = 0;
624 while( ( !
isFilled( next_bunch ) ) &&
631 <<
bcid <<
" to a filled bunch! This shouldn't have "
687 <<
bcid <<
" to an empty bunch! This shouldn't have "
705 return bunch.
gapTo( next_bunch );
708 ATH_MSG_ERROR(
"You can only use NanoSec or BunchCrossings for type "
709 "for gapBeforeBunch" );
719 int bunches )
const {
724 std::vector< bool >
result;
725 for(
int i = 0;
i < bunches; ++
i ) {
735 int bunches )
const {
740 std::vector< bool >
result;
741 for(
int i = 0;
i < bunches; ++
i ) {
754 std::vector< float >
result;
755 for(
int i = 0;
i < bunches; ++
i ) {
756 std::set< BunchCrossing >::const_iterator itr =
762 result.push_back( itr->intensityBeam1() );
765 result.push_back( itr->intensityBeam2() );
785 std::vector< float >
result;
786 for(
int i = 0;
i < bunches; ++
i ) {
787 std::set< BunchCrossing >::const_iterator itr =
793 result.push_back( itr->intensityBeam1() );
796 result.push_back( itr->intensityBeam2() );
840 ATH_MSG_ERROR(
"Function should not be called with argument: "
853 ATH_MSG_FATAL(
"The code should never reach this line. Check the code!" );
872 const std::vector< float >& bunch_int1,
873 const std::vector< float >& bunch_int2 ) {
876 if( ( ( bunches.size() != bunch_int1.size() ) && bunch_int1.size() ) ||
877 ( ( bunches.size() != bunch_int2.size() ) && bunch_int2.size() ) ) {
878 ATH_MSG_ERROR(
"Received vectors of different sizes for the bunch "
879 "IDs and bunch intensities\n"
880 "Function can not work like this..." );
881 return StatusCode::FAILURE;
883 if( ! bunch_int1.size() ) {
884 ATH_MSG_DEBUG(
"Not using bunch intensity for the calculation" );
886 if( ( ! bunch_int2.size() ) && bunch_int1.size() ) {
903 std::vector< int >::const_iterator b_itr = bunches.begin();
904 std::vector< int >::const_iterator b_end = bunches.end();
905 std::vector< float >::const_iterator i1_itr = bunch_int1.begin();
906 std::vector< float >::const_iterator i2_itr = bunch_int2.begin();
907 for( ; b_itr != b_end; ++b_itr ) {
910 const float intensity1 = bunch_int1.size() ? *i1_itr : 1.0;
911 const float intensity2 = bunch_int2.size() ? *i2_itr : 0.0;
934 const int neighbours =
935 std::count_if( bunches.begin(), bunches.end(),
936 [ maxBCSpacing, &b_itr ](
int bunch ) {
937 return ( Trig::distance( bunch, *b_itr ) <=
946 if( neighbours == 1 ) {
948 <<
" seems to be a single bunch" );
954 if( bunch_int1.size() ) ++i1_itr;
955 if( bunch_int2.size() ) ++i2_itr;
963 return StatusCode::SUCCESS;
988 const std::vector< float >& bunch_int1,
989 const std::vector< float >& bunch_int2 ) {
992 if( ( ( bunches.size() != bunch_int1.size() ) && bunch_int1.size() ) ||
993 ( ( bunches.size() != bunch_int2.size() ) && bunch_int2.size() ) ) {
994 ATH_MSG_ERROR(
"Received vectors of different sizes for the bunch "
995 "IDs and bunch intensities\n"
996 "Function can not work like this..." );
997 return StatusCode::FAILURE;
999 if( ! bunch_int1.size() ) {
1000 ATH_MSG_DEBUG(
"Not using bunch intensity for the calculation" );
1002 if( ( ! bunch_int2.size() ) && bunch_int1.size() ) {
1019 std::set< BunchCrossing > cache;
1020 std::vector< int >::const_iterator b_itr = bunches.begin();
1021 std::vector< int >::const_iterator b_end = bunches.end();
1022 std::vector< float >::const_iterator i1_itr = bunch_int1.begin();
1023 std::vector< float >::const_iterator i2_itr = bunch_int2.begin();
1024 for( ; b_itr != b_end; ++b_itr ) {
1028 (
float )( bunch_int1.size() ? *i1_itr :
1030 (
float )( bunch_int2.size() ? *i2_itr :
1033 if( bunch_int1.size() ) ++i1_itr;
1034 if( bunch_int2.size() ) ++i2_itr;
1042 while( cache.size() ) {
1046 bt.insert( *cache.begin() );
1050 size_t prev_size = 0;
1051 while( prev_size != cache.size() ) {
1054 prev_size = cache.size();
1057 std::set< BunchCrossing >::const_iterator c_itr = cache.begin();
1058 std::set< BunchCrossing >::const_iterator c_end = cache.end();
1059 for( ; c_itr != c_end; ++c_itr ) {
1060 if( bt.
distance( *c_itr ) <= maxBCSpacing ) {
1062 <<
" to Bunch Train " << bt );
1063 bt.insert( *c_itr );
1068 BunchTrain::const_iterator itr = bt.begin();
1069 BunchTrain::const_iterator
end = bt.end();
1070 for( ; itr !=
end; ++itr ) {
1071 cache.erase( *itr );
1087 std::set< BunchTrain >::const_iterator train_itr =
m_bunchTrains.begin();
1088 std::set< BunchTrain >::const_iterator train_end =
m_bunchTrains.end();
1090 for( ; train_itr != train_end; ++train_itr ) {
1092 spacing = train_itr->spacing();
1095 if( train_itr->spacing() != spacing ) {
1104 return StatusCode::SUCCESS;
1119 const std::vector< int >&
beam2,
1120 const std::vector< float >& bunch_int1,
1121 const std::vector< float >& bunch_int2 ) {
1124 if( ( (
beam1.size() != bunch_int1.size() ) && bunch_int1.size() ) ||
1125 ( (
beam2.size() != bunch_int2.size() ) && bunch_int2.size() ) ) {
1126 ATH_MSG_ERROR(
"Received vectors of different sizes for the bunch "
1127 "IDs and bunch intensities\n"
1128 "Function can not work like this..." );
1129 return StatusCode::FAILURE;
1131 if( ( ! bunch_int1.size() ) && ( ! bunch_int2.size() ) ) {
1132 ATH_MSG_DEBUG(
"Not using bunch intensity for the calculation" );
1141 std::vector< int >::const_iterator b_itr =
beam1.begin();
1142 std::vector< int >::const_iterator b_end =
beam1.end();
1143 std::vector< float >::const_iterator i_itr = bunch_int1.begin();
1144 for( ; b_itr != b_end; ++b_itr ) {
1147 const float intensity = bunch_int1.size() ? *i_itr : 1.0;
1153 if( bunch_int1.size() ) ++i_itr;
1159 b_itr =
beam2.begin();
1160 b_end =
beam2.end();
1161 i_itr = bunch_int2.begin();
1162 for( ; b_itr != b_end; ++b_itr ) {
1165 const float intensity = bunch_int2.size() ? *i_itr : 1.0;
1183 if( bunch_int2.size() ) ++i_itr;
1191 return StatusCode::SUCCESS;
1226 bunchSpacing(
const std::vector< int >& bunches )
const {
1237 const int nbunches =
1238 std::count_if( bunches.begin(), bunches.end(),
1241 <<
" BC neighbors: " << nbunches );
1251 if(
result != maxSpacing ) {