ATLAS Offline Software
Loading...
Searching...
No Matches
StaticBunchCrossingTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5// $Id: StaticBunchCrossingTool.cxx 749252 2016-05-24 09:30:51Z krasznaa $
6
7// Local include(s):
9#include "StaticConfigs.h"
10
11namespace Trig {
12
18 : BunchCrossingToolBase( name ),
20
21 // Declare the property of the tool:
22 declareProperty( "BGKey", m_bgkey = 0 );
23
24 //
25 // Learn the static bunch group configurations:
26 //
27 for( int i = 0; i < BGK_CONF_N; ++i ) {
28 for( int j = 0; j < BGK_CONF_NUM[ i ]; ++j ) {
29 m_knownBGKeys[ BGK_CONF_KEY[ i ] ].push_back( BGK_CONF[ i ][ j ] );
30 }
31 }
32 }
33
35
36 // Let the user know what's happening:
37 ATH_MSG_INFO( "Initialising tool" );
38 ATH_MSG_INFO( " Bunch group config : " << m_bgkey );
39
40 // Load the configuration specified by the tool's property:
42
43 // Return gracefully:
44 return StatusCode::SUCCESS;
45 }
46
56 StatusCode StaticBunchCrossingTool::loadConfig( int bgkey ) {
57
58 //
59 // Check if we have this configuration:
60 //
61 std::map< int, std::vector< int > >::const_iterator bgset;
62 if( ( bgset = m_knownBGKeys.find( bgkey ) ) == m_knownBGKeys.end() ) {
63 ATH_MSG_ERROR( "Couldn't find configuration for bunch group key: "
64 << bgkey );
65 return StatusCode::FAILURE;
66 }
67
68 //
69 // Now let the base class interpret the configuration:
70 //
71 ATH_CHECK( loadSingleBunches( bgset->second ) );
72 ATH_CHECK( loadBunchTrains( bgset->second ) );
73 ATH_CHECK( loadUnpairedBunches( std::vector< int >(),
74 std::vector< int >() ) );
75
76 // Print the configuration to give some feedback to the user:
78
79 return StatusCode::SUCCESS;
80 }
81
95 loadConfig( const std::vector< int >& filledBunches,
96 const std::vector< float >& filledIntensities,
97 const std::vector< int >& unpairedBunches,
98 const std::vector< float >& unpairedIntensities ) {
99
100 //
101 // Let the base class interpret the configuration:
102 //
103 ATH_CHECK( loadSingleBunches( filledBunches, filledIntensities ) );
104 ATH_CHECK( loadBunchTrains( filledBunches, filledIntensities ) );
105 ATH_CHECK( loadUnpairedBunches( unpairedBunches, unpairedBunches,
106 unpairedIntensities,
107 unpairedIntensities ) );
108
109 // Print the configuration to give some feedback to the user:
110 printConfig();
111
112 return StatusCode::SUCCESS;
113 }
114
129 loadConfig( const std::vector< float >& bunches ) {
130
131 // Check that the user specified something useful:
132 if( ! bunches.size() ) {
133 ATH_MSG_ERROR( "Empty container received" );
134 return StatusCode::FAILURE;
135 }
136
137 // Translate it into vectors of filled bunches and intensities:
138 std::vector< int > filled_bunches;
139 std::vector< float > filled_intensities;
140
141 // Minimum bunch intensity to consider a bunch filled:
142 static const float MIN_BUNCH_INTENSITY = 0.1;
143
144 // Check if the pattern "fits into" the LHC:
145 if( BunchCrossing::MAX_BCID % bunches.size() ) {
146
147 ATH_MSG_INFO( "Bunch pattern doesn't \"fit into\" "
149 // The loop doesn't go all the way up to MAX_BCID/2 in order not
150 // to produce "weird" patterns half way. This should be pretty safe
151 // to do, because the MC BCIDs will only be in the range defined by
152 // the pattern from the metadata.
153 for( int i = 0; i < ( BunchCrossing::MAX_BCID / 2 - 20 ); ++i ) {
154 const int pos1 = i % bunches.size();
155 const int pos2 = bunches.size() - 1 - ( i % bunches.size() );
156 if( bunches[ pos1 ] > MIN_BUNCH_INTENSITY ) {
157 filled_bunches.push_back( i );
158 filled_intensities.push_back( bunches[ pos1 ] );
159 }
160 if( bunches[ pos2 ] > MIN_BUNCH_INTENSITY ) {
161 filled_bunches.push_back( BunchCrossing::MAX_BCID - 1 - i );
162 filled_intensities.push_back( bunches[ pos2 ] );
163 }
164 }
165
166 } else {
167
168 // If the sample size fits into the number of available bunches,
169 // the algorithm is pretty simple:
170 ATH_MSG_INFO( "Bunch pattern \"fits into\" "
172 for( int i = 0; i < BunchCrossing::MAX_BCID; ++i ) {
173 const int pos = i % bunches.size();
174 if( bunches[ pos ] > MIN_BUNCH_INTENSITY ) {
175 filled_bunches.push_back( i );
176 filled_intensities.push_back( bunches[ pos ] );
177 }
178 }
179
180 }
181
182 //
183 // Now let the base class interpret the information:
184 //
185 ATH_CHECK( loadSingleBunches( filled_bunches, filled_intensities ) );
186 ATH_CHECK( loadBunchTrains( filled_bunches, filled_intensities ) );
187 ATH_CHECK( loadUnpairedBunches( std::vector< int >(),
188 std::vector< int >() ) );
189
190 // Print the configuration to give some feedback to the user:
191 printConfig();
192
193 // Return gracefully:
194 return StatusCode::SUCCESS;
195 }
196
197} // namespace Trig
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
static const int BGK_CONF_KEY[BGK_CONF_N]
static const int BGK_CONF_NUM[BGK_CONF_N]
static const int *const BGK_CONF[BGK_CONF_N]
static const int BGK_CONF_N
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
StatusCode loadBunchTrains(const std::vector< int > &bunches, const std::vector< float > &bunch_int1=std::vector< float >(), const std::vector< float > &bunch_int2=std::vector< float >())
Interpret the configuration for bunch trains.
BunchCrossingToolBase(const std::string &name="BunchCrossingToolBase")
Default constructor.
StatusCode loadSingleBunches(const std::vector< int > &bunches, const std::vector< float > &bunch_int1=std::vector< float >(), const std::vector< float > &bunch_int2=std::vector< float >())
Interpret the configuration for single bunches.
void printConfig() const
Function printing the configuration of the tool.
StatusCode loadUnpairedBunches(const std::vector< int > &beam1, const std::vector< int > &beam2, const std::vector< float > &bunch_int1=std::vector< float >(), const std::vector< float > &bunch_int2=std::vector< float >())
Interpret the configuration for unpaired bunches.
static const int MAX_BCID
The maximum number of bunches that can be in the LHC.
int m_bgkey
Default key to be loaded.
std::map< int, std::vector< int > > m_knownBGKeys
All the hard-coded configs.
virtual StatusCode initialize()
Function initialising the tool.
StaticBunchCrossingTool(const std::string &name="StaticBunchCrossingTool")
Create a proper constructor for Athena.
StatusCode loadConfig(int bgkey)
Load a hard-coded bunch group key.
The common trigger namespace for trigger analysis tools.