ATLAS Offline Software
Loading...
Searching...
No Matches
count_bunch_neighbors.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
5// System include(s):
6#include <algorithm>
7#include <functional>
8
9// Local include(s):
12
13namespace Trig {
14
16 count_bunch_neighbors( const std::vector< int >& bunches,
17 int maxBunchSpacing )
18 : m_bunches( bunches ), m_maxBunchSpacing( maxBunchSpacing ) {
19
20 }
21
22 int count_bunch_neighbors::operator()( int bunch ) const {
23
24 // Count how many neighbors the bunch has:
25 const int maxBunchSpacing = m_maxBunchSpacing;
26 const int neighbors =
27 std::count_if( m_bunches.begin(), m_bunches.end(),
28 [ maxBunchSpacing, bunch ]( int b ) {
29 return ( Trig::distance( bunch, b ) <=
30 maxBunchSpacing );
31 } );
32
33 // Remember that the above expression always counts the bunch itself
34 // as its own neighbor. So the real value we're looking for is 1 less.
35 return ( neighbors - 1 );
36 }
37
38} // namespace Trig
const std::vector< int > & m_bunches
Filled bunches in the current configuration.
int operator()(int bunch) const
Count how many neighbors can be found for the specified bunch crossing.
count_bunch_neighbors(const std::vector< int > &bunches, int maxBunchSpacing)
Constructor with colliding bunches, and maximum bunch spacing.
const int m_maxBunchSpacing
Maximum bunch spacing to consider.
The common trigger namespace for trigger analysis tools.