ATLAS Offline Software
Loading...
Searching...
No Matches
BunchCrossingCondAlg Class Reference

Conditions algorithm to unpack fill parameters from COOL. More...

#include <BunchCrossingCondAlg.h>

Inheritance diagram for BunchCrossingCondAlg:
Collaboration diagram for BunchCrossingCondAlg:

Public Types

typedef BunchCrossingCondData::bunchTrain_t bunchTrain_t

Public Member Functions

virtual StatusCode initialize () override
 Gaudi initialize method.
virtual StatusCode execute (const EventContext &ctx) const override
 Algorithm execute method.
virtual bool isReEntrant () const override final
virtual StatusCode sysInitialize () override
 Override sysInitialize.
virtual bool isClonable () const override
 Specify if the algorithm is clonable.
virtual unsigned int cardinality () const override
 Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentrant.
virtual StatusCode sysExecute (const EventContext &ctx) override
 Execute an algorithm.
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies.
virtual bool filterPassed (const EventContext &ctx) const
virtual void setFilterPassed (bool state, const EventContext &ctx) const
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

std::vector< bunchTrain_tfindTrains (const std::bitset< BunchCrossingCondData::m_MAX_BCID > &pairsToConsume, const int maxSpacingInTrain, const unsigned minBunchesPerTrain) const
 internal methods:
std::vector< float > tokenize (const std::string &pattern) const
 This helper function is used to convert a string of type "[0.0, 0.0, 1.0, 1.0, 1.0]" into a vector of floats.
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

SG::ReadCondHandleKey< AthenaAttributeListm_fillParamsFolderKey { this, "FillParamsFolderKey", "/TDAQ/OLC/LHC/FILLPARAMS", "" }
 Input conditions object.
SG::ReadCondHandleKey< LuminosityCondDatam_lumiCondDataKey {this, "LumiCondData", "LuminosityCondData", "Lumi cond data key"}
SG::ReadCondHandleKey< TrigConf::L1BunchGroupSetm_bunchGroupCondDataKey {this, "L1BunchGroupCondData", "L1BunchGroup", "Bunch group cond data key"}
SG::WriteCondHandleKey< BunchCrossingCondDatam_outputKey {this, "OutputKey", "BunchCrossingData", "Key of output CDO" }
 Output conditions object.
const ServiceHandle< TrigConf::ILVL1ConfigSvcm_trigConfigSvc {this, "TrigConfigSvc", "TrigConf::xAODConfigSvc/xAODConfigSvc", "Trig Config Svc"}
Gaudi::Property< unsigned > m_maxBunchSpacing {this, "MaxBunchSpacing",5, "Maximal bunch-spacing to be considered a 'bunch train'"}
Gaudi::Property< unsigned > m_minBunchesPerTrain {this, "MinBunchesPerTrain",32, "Minimal number of bunches to be considerd a 'bunch train'"}
Gaudi::Property< bool > m_isRun1 {this,"Run1",false,"Assume run-1 database"}
Gaudi::Property< int > m_mode {this, "Mode", 1, "Alg mode (COOL FILLPARAMS = 0, MC = 1, TrigConf = 2, Luminosity = 3)"}
DataObjIDColl m_extendedExtraObjects
 Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Conditions algorithm to unpack fill parameters from COOL.

Definition at line 30 of file BunchCrossingCondAlg.h.

Member Typedef Documentation

◆ bunchTrain_t

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Member Function Documentation

◆ cardinality()

unsigned int AthCommonReentrantAlgorithm< Gaudi::Algorithm >::cardinality ( ) const
overridevirtualinherited

Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentrant.

Override this to return 0 for reentrant algorithms.

Definition at line 75 of file AthCommonReentrantAlgorithm.cxx.

64{
65 return 0;
66}

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ execute()

StatusCode BunchCrossingCondAlg::execute ( const EventContext & ctx) const
overridevirtual

Algorithm execute method.

Definition at line 28 of file BunchCrossingCondAlg.cxx.

28 {
29
30 SG::WriteCondHandle<BunchCrossingCondData> writeHdl(m_outputKey, ctx);
31 if (writeHdl.isValid()) {
32 ATH_MSG_DEBUG("Found valid write handle");
33 return StatusCode::SUCCESS;
34 }
35 // make sure that the output IOV has a valid timestamp, otherwise the conditions
36 // data cannot be added to the "mixed" conditions data container. A mixed container
37 // is needed when the conditions depends on e.g. the LuminosityCondData
38 writeHdl.addDependency(IOVInfiniteRange::infiniteMixed());
39
40 //Output object & range:
41 auto bccd=std::make_unique<BunchCrossingCondData>();
42
43 if (m_mode == 2) { // use trigger bunch groups
44 const TrigConf::L1BunchGroupSet* bgs{nullptr};
45 if (!m_bunchGroupCondDataKey.empty()) {
46 SG::ReadCondHandle<TrigConf::L1BunchGroupSet> bgsh(m_bunchGroupCondDataKey, ctx);
47 if (! bgsh.isValid()) {
48 ATH_MSG_ERROR("Unable to retrieve L1BunchGroupSet object " << m_bunchGroupCondDataKey);
49 return StatusCode::FAILURE;
50 }
51 bgs = *bgsh;
52 } else {
53 bgs = &(m_trigConfigSvc->l1BunchGroupSet(ctx));
54 }
55 // bunch group 1 = paired
56 if (bgs->size() >= 2) {
57 ATH_MSG_DEBUG("from BunchGroupCondData: BG1 bunches " << bgs->getBunchGroup(1)->bunches() );
58 for (const auto& pos : bgs->getBunchGroup(1)->bunches() ) {
59 bccd->m_beam1.set(pos);
60 bccd->m_beam2.set(pos);
61 bccd->m_luminous.set(pos);
62 }
63 }
64 else {
65 ATH_MSG_ERROR("missing bunch group data");
66 }
67 // in Run 1 we don't have bunch group information to determine beam 1 or beam 2 unpaired
68 // so test if we have at least 15 bunch groups, then assume BG13/14 are the unpaired bunches
69 if (bgs->size() >= 15) {
70 for (const auto& pos : bgs->getBunchGroup(13)->bunches() ) {
71 bccd->m_beam1.set(pos);
72 }
73 for (const auto& pos : bgs->getBunchGroup(14)->bunches() ) {
74 bccd->m_beam2.set(pos);
75 }
76 }
77 // find trains
78 bccd->m_trains=findTrains(bccd->m_luminous, m_maxBunchSpacing,m_minBunchesPerTrain);
79 // we will only trust the validity for 1 LB but that's OK
80 const auto& thisevt = ctx.eventID();
81 EventIDRange range = EventIDRange(EventIDBase(thisevt.run_number(), EventIDBase::UNDEFEVT,
82 EventIDBase::UNDEFNUM, 0, thisevt.lumi_block()),
83 EventIDBase(thisevt.run_number(), EventIDBase::UNDEFEVT,
84 EventIDBase::UNDEFNUM, 0, thisevt.lumi_block()+1));
85 writeHdl.addDependency(range);
86 }
87
88 if (m_mode == 3) { // use luminosity data
89 SG::ReadCondHandle<LuminosityCondData> prefLumiHdl{m_lumiCondDataKey, ctx};
90 writeHdl.addDependency(prefLumiHdl);
91
92 // consider BCID filled if mu < 1000*average mu
93 float avMu = prefLumiHdl->lbAverageInteractionsPerCrossing();
94 const auto& lumiVec = prefLumiHdl->lbLuminosityPerBCIDVector();
95 float cutLumi = avMu/1000.f*prefLumiHdl->muToLumi();
96
97 for (size_t bcid = 0; bcid < LuminosityCondData::TOTAL_LHC_BCIDS; ++bcid ) {
98 if (lumiVec[bcid] > cutLumi) {
99 bccd->m_beam1.set(bcid);
100 bccd->m_beam2.set(bcid);
101 bccd->m_luminous.set(bcid);
102 }
103 }
104 // find trains
105 bccd->m_trains=findTrains(bccd->m_luminous, m_maxBunchSpacing,m_minBunchesPerTrain);
106 }
107
108 if (m_mode == 0 || m_mode == 1) { // use FILLPARAMS (data) or /Digitization/Parameters (MC)
109
110 SG::ReadCondHandle<AthenaAttributeList> fillParamsHdl (m_fillParamsFolderKey, ctx);
111 writeHdl.addDependency(fillParamsHdl);
112
113 const AthenaAttributeList* attrList=*fillParamsHdl;
114
115
116 if (m_mode == 1) {
117 ATH_MSG_INFO("Assuming MC case");
118 ATH_MSG_INFO("Got AttributeList with size " << attrList->size());
119 std::string sbunches;
120 try {
121 const coral::Attribute& attr=(*attrList)[std::string("BeamIntensityPattern")];
122 if (attr.isNull()) {
123 ATH_MSG_ERROR("Got NULL attribute for BeamIntensityPattern");
124 return StatusCode::FAILURE;
125 }
126 sbunches = attr.data< std::string >();
127 } catch (coral::AttributeListException& e) {
128 ATH_MSG_ERROR(e.what());
129 ATH_MSG_ERROR("Failed to get Attribute 'BeamIntensityPattern' from AttributeList in " << m_fillParamsFolderKey);
130 return StatusCode::FAILURE;
131 }
132
133 const float minBunchIntensity=0.001;
134 std::vector<float> bunches=tokenize(sbunches);
135 if (!bunches.empty()) {
136 // Check if the pattern "fits into" the LHC:
137 if( BunchCrossingCondData::m_MAX_BCID % bunches.size() ) {
138
139 ATH_MSG_INFO( "Bunch pattern doesn't \"fit into\" " << BunchCrossingCondData::m_MAX_BCID );
140 // The loop doesn't go all the way up to MAX_BCID/2 in order not to produce "weird"
141 // patterns half way. This should be pretty safe to do, because the MC BCIDs will
142 // only be in the range defined by the pattern from the metadata.
143 for( int i = 0; i < ( BunchCrossingCondData::m_MAX_BCID / 2 - 20 ); ++i ) {
144 const int pos1 = i % bunches.size();
145 const int pos2 = bunches.size() - 1 - ( i % bunches.size() );
146 if( bunches[ pos1 ] > minBunchIntensity) {
147 bccd->m_beam1.set(i);
148 bccd->m_beam2.set(i);
149 bccd->m_luminous.set(i);
150 }
151 if( bunches[ pos2 ] > minBunchIntensity) {
152 bccd->m_beam1.set(BunchCrossingCondData::m_MAX_BCID - 1 -i);
153 bccd->m_beam2.set(BunchCrossingCondData::m_MAX_BCID - 1 -i);
154 bccd->m_luminous.set(BunchCrossingCondData::m_MAX_BCID - 1 -i);
155 }
156 }
157
158 } else {
159 // If the sample size fits into the number of available bunches, the algorithm
160 // is pretty simple:
161 ATH_MSG_INFO( "Bunch pattern \"fits into\" " << BunchCrossingCondData::m_MAX_BCID );
162 for( int i = 0; i < BunchCrossingCondData::m_MAX_BCID; ++i ) {
163 const int pos = i % bunches.size();
164 if( bunches[ pos ] > minBunchIntensity) {
165 bccd->m_beam1.set(i);
166 bccd->m_beam2.set(i);
167 bccd->m_luminous.set(i);
168 }
169 }
170 }
171 //Filled bcid-bitsets, now extract trains:
172 bccd->m_trains=findTrains(bccd->m_luminous, m_maxBunchSpacing,m_minBunchesPerTrain);
173 }
174 else {//got no bunches from metadata
175 ATH_MSG_INFO("Bunch structure information not found in metadata");
176 ATH_MSG_INFO("Will consider all BCIDs as single filled bunches (no trains)");
177 bccd->m_beam1.set();
178 bccd->m_beam2.set();
179 bccd->m_luminous.set();
180 }
181 }
182 else { // mode == 0, Data-case
183 if ((*attrList)["BCIDmasks"].isNull()) {
184 ATH_MSG_ERROR( "BunchCode is NULL in " << m_fillParamsFolderKey.key() << "!" );
185 return StatusCode::FAILURE;
186 }
187
188
189 // Do everything here for now, but should copy this to a vanilla object based on attrList
190 cool::UInt32 nb1 = (*attrList)["Beam1Bunches"].data<cool::UInt32>();
191 cool::UInt32 nb2 = (*attrList)["Beam2Bunches"].data<cool::UInt32>();
192 cool::UInt32 ncol = (*attrList)["LuminousBunches"].data<cool::UInt32>();
193
194 ATH_MSG_DEBUG( "Beam1Bunches: " << nb1 );
195 ATH_MSG_DEBUG( "Beam2Bunches: " << nb2 );
196 ATH_MSG_DEBUG( "LuminousBunches: " << ncol );
197
198 const coral::Blob& blob = (*attrList)["BCIDmasks"].data<coral::Blob>();
199
200 if (m_isRun1) { //Assume run1 layout as explained at https://twiki.cern.ch/twiki/bin/view/AtlasComputing/CoolOnlineData
201 ATH_MSG_DEBUG("Assuming run 1 database");
202 // Verify length
203 if ( static_cast<cool::UInt32>( blob.size() ) != 2 * (nb1 + nb2 + ncol)) {
204 ATH_MSG_WARNING( "BCIDmasks length " << blob.size() << " != 2 * " << (nb1+nb2+ncol) );
205 return StatusCode::SUCCESS;
206 }
207 const uint16_t* blobAddr=static_cast<const uint16_t*>(blob.startingAddress());
208 //Decode beam1 filling:
209 for (size_t idx=0;idx<nb1;++idx) {
210 const uint32_t bcid=blobAddr[idx];
211 bccd->m_beam1.set(bcid);
212 }
213
214 //Decode beam2 filling:
215 for (size_t idx=nb1;idx<nb2;++idx) {
216 const uint32_t bcid=blobAddr[idx];
217 bccd->m_beam2.set(bcid);
218 }
219
220 //Decode colliding:
221 for (size_t idx=nb2;idx<ncol;++idx) {
222 const uint32_t bcid=blobAddr[idx];
223 bccd->m_luminous.set(bcid);
224 }
225 }
226 else {
227 ATH_MSG_DEBUG("Assuming run 2/3 database");
228 //Assume run2 layout as explained at https://twiki.cern.ch/twiki/bin/view/AtlasComputing/CoolOnlineData
229 //Verify length
231 ATH_MSG_ERROR("Found blob with unexpected length " << blob.size() << "(expect " << BunchCrossingCondData::m_MAX_BCID <<") in folder " << m_fillParamsFolderKey.key());
232 return StatusCode::FAILURE;
233 }
234 const uint8_t* blobAddr=static_cast<const uint8_t*>(blob.startingAddress());
235 for (uint32_t bcid=0;bcid<BunchCrossingCondData::m_MAX_BCID;++bcid) {
236 if (blobAddr[bcid] & 0x1) {
237 bccd->m_beam1.set(bcid);
238 }
239 if (blobAddr[bcid] & 0x2) {
240 bccd->m_beam2.set(bcid);
241 }
242 if ((blobAddr[bcid] & 0x3) == 0x3) {
243 bccd->m_luminous.set(bcid);
244 }
245 }
246
247 //Consistency checks:
248 if (bccd->m_beam1.count()!= nb1) {
249 ATH_MSG_WARNING("Found " << bccd->m_beam1.count() << " bunches in beam1, expected " << nb1);
250 }
251
252 if (bccd->m_beam2.count()!= nb2) {
253 ATH_MSG_WARNING("Found " << bccd->m_beam2.count() << " bunches in beam2, expected " << nb2);
254 }
255
256 if (bccd->m_luminous.count()!= ncol) {
257 ATH_MSG_WARNING("Found " << bccd->m_luminous.count() << " colliding bunches, expected " << ncol);
258 }
259 }//end else run2
260 //Filled bcid-bitsets, now extract trains
261 bccd->m_trains=findTrains(bccd->m_luminous, m_maxBunchSpacing,m_minBunchesPerTrain);
262 }//end else is data
263 }
264
265 ATH_CHECK( writeHdl.record (std::move (bccd)) );
266 return StatusCode::SUCCESS;
267}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
std::vector< float > tokenize(const std::string &pattern) const
This helper function is used to convert a string of type "[0.0, 0.0, 1.0, 1.0, 1.0]" into a vector of...
Gaudi::Property< bool > m_isRun1
Gaudi::Property< int > m_mode
SG::WriteCondHandleKey< BunchCrossingCondData > m_outputKey
Output conditions object.
Gaudi::Property< unsigned > m_maxBunchSpacing
Gaudi::Property< unsigned > m_minBunchesPerTrain
std::vector< bunchTrain_t > findTrains(const std::bitset< BunchCrossingCondData::m_MAX_BCID > &pairsToConsume, const int maxSpacingInTrain, const unsigned minBunchesPerTrain) const
internal methods:
SG::ReadCondHandleKey< TrigConf::L1BunchGroupSet > m_bunchGroupCondDataKey
SG::ReadCondHandleKey< LuminosityCondData > m_lumiCondDataKey
const ServiceHandle< TrigConf::ILVL1ConfigSvc > m_trigConfigSvc
SG::ReadCondHandleKey< AthenaAttributeList > m_fillParamsFolderKey
Input conditions object.
static constexpr int m_MAX_BCID
static EventIDRange infiniteMixed()
Produces an mixed EventIDRange that is infinite in Time and RunLumi.
static constexpr unsigned int TOTAL_LHC_BCIDS
std::size_t size() const
Accessor to the number of defined bunchgroups.
const std::shared_ptr< L1BunchGroup > & getBunchGroup(const std::string &name) const
Accessor to the bunchgroup by name.
setEventNumber setTimeStamp bcid
setWord1 uint16_t
setEventNumber uint32_t

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthCommonReentrantAlgorithm< Gaudi::Algorithm >::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 94 of file AthCommonReentrantAlgorithm.cxx.

90{
91 // If we didn't find any symlinks to add, just return the collection
92 // from the base class. Otherwise, return the extended collection.
93 if (!m_extendedExtraObjects.empty()) {
95 }
97}
An algorithm that can be simultaneously executed in multiple threads.

◆ filterPassed()

virtual bool AthCommonReentrantAlgorithm< Gaudi::Algorithm >::filterPassed ( const EventContext & ctx) const
inlinevirtualinherited

Definition at line 96 of file AthCommonReentrantAlgorithm.h.

96 {
97 return execState( ctx ).filterPassed();
98 }
virtual bool filterPassed(const EventContext &ctx) const

◆ findTrains()

std::vector< BunchCrossingCondData::bunchTrain_t > BunchCrossingCondAlg::findTrains ( const std::bitset< BunchCrossingCondData::m_MAX_BCID > & pairsToConsume,
const int maxSpacingInTrain,
const unsigned minBunchesPerTrain ) const
private

internal methods:

Definition at line 270 of file BunchCrossingCondAlg.cxx.

270 {
271
272 const int MAX_BCID=collidingBCIDs.size();
273 std::vector<bunchTrain_t> result;
274
275 std::vector<std::pair<int,int> > holes;
276 int start=0;
277 int stop=0;
278
279 while (stop<MAX_BCID) { //Outer loop, over holes
280 for (start=stop;stop<MAX_BCID && !collidingBCIDs.test(stop); ++stop) {};//Count consecutive holes
281 //stop points now to the next filled bcid (or MAX)
282 if ((stop-start)>maxSpacingInTrain) {
283 holes.emplace_back(start,stop);
284 }//end if >maxSpacingInTrain
285 ++stop;
286 }//end outer loop
287
288
289 ATH_MSG_DEBUG("Found " << holes.size() << " gaps larger than " << maxSpacingInTrain << " in the bunch structure");
290 if (msgLvl(MSG::VERBOSE)) {
291 for (auto& h : holes) {
292 msg(MSG::VERBOSE) << "Hole: " << h.first << " - " << h.second << endmsg;
293 }
294 }
295
296
297 if (holes.empty()) {
298 ATH_MSG_ERROR("Looks like we have bunch train spanning the entire ring w/o any gap. Really?");
299 return result;
300 }
301
302
303 if (holes.size()>1) {
304 //generic case of having at least 2 gaps int the bunch structure
305 for (unsigned i=0;i<holes.size()-1;++i) {
306 //Count colliding bunches in this train:
307 unsigned ncoll=0;
308 for (int idx=holes[i].second;idx<holes[i+1].first-1;++idx) {
309 if (collidingBCIDs.test(idx)) {
310 ++ncoll;
311 }
312 }
313 result.emplace_back(holes[i].second,holes[i+1].first-1,ncoll);
314 }
315 }
316
317 if (holes.size()==1 || (holes.front().first!=0 && holes.back().second!=MAX_BCID-1)) {
318 //Special case of only one hole and/or first/last BCIDs populated (train across the wrap-around)
319
320 //To simplify the distanceToFront and distanceToTail methods we duplicate this train
321 //Once as first train wiht a starting point in the negative range, and
322 //once as last train with a ending point beyond MAX_BCID
323
324 //Count the number of collisions in this train:
325 unsigned ncoll=0;
326 for (int idx=0;idx<holes.front().first;++idx) {
327 if (collidingBCIDs.test(idx)) {
328 ++ncoll;
329 }
330 }
331 for (int idx=holes.back().second;idx<MAX_BCID;++idx) {
332 if (collidingBCIDs.test(idx)) {
333 ++ncoll;
334 }
335 }
336
337 BunchCrossingCondData::bunchTrain_t firsttrain(holes.back().second-MAX_BCID, holes.front().first-1,ncoll);
338 BunchCrossingCondData::bunchTrain_t lasttrain(holes.back().second,MAX_BCID+holes.front().first-1,ncoll);
339 result.insert(result.begin(),firsttrain);
340 result.push_back(lasttrain);
341 }//end if wrap-around populated
342
343
344 ATH_MSG_DEBUG("Found " << result.size() << " Bunch trains separated by gaps of at least " << maxSpacingInTrain << " bcids ");
345
346 //copy the vector, cleaning out trains with too few colliding bunches
347 std::vector<bunchTrain_t> result1;
348 result1.reserve(result.size());
349 for (const bunchTrain_t& train: result) {
350 if (train.m_nColl >= minBunchesPerTrain) {
351 result1.emplace_back(train);
352 }
353 }
354
355 ATH_MSG_INFO("Found " << result1.size() << " Bunch trains having at least " << minBunchesPerTrain << " colliding bunches and separated by at least " << maxSpacingInTrain << " bcids");
356
357
358 if (msgLvl(MSG::VERBOSE)) {
359 for (auto& r : result1) {
360 msg(MSG::VERBOSE) << "Train " << r.m_first << " - " << r.m_last << ", " << r.m_nColl << " colliding bcids" << endmsg;
361 }
362 }
363
364 return result1;
365}
#define endmsg
bool msgLvl(const MSG::Level lvl) const
BunchCrossingCondData::bunchTrain_t bunchTrain_t
int r
Definition globals.cxx:22

◆ initialize()

StatusCode BunchCrossingCondAlg::initialize ( )
overridevirtual

Gaudi initialize method.

Definition at line 16 of file BunchCrossingCondAlg.cxx.

16 {
17 if (m_mode == 2) {
18 ATH_CHECK( m_trigConfigSvc.retrieve() );
19 }
20 ATH_CHECK( m_bunchGroupCondDataKey.initialize( m_mode == 2 && !m_bunchGroupCondDataKey.empty() ) );
21 ATH_CHECK( m_fillParamsFolderKey.initialize( m_mode == 0 || m_mode == 1 ) );
22 ATH_CHECK( m_lumiCondDataKey.initialize( m_mode == 3 ) );
23 ATH_CHECK( m_outputKey.initialize() );
24 return StatusCode::SUCCESS;
25}

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ isClonable()

◆ isReEntrant()

virtual bool BunchCrossingCondAlg::isReEntrant ( ) const
inlinefinaloverridevirtual

Definition at line 44 of file BunchCrossingCondAlg.h.

44{ return false; }

◆ msg()

MsgStream & AthCommonMsg< Gaudi::Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< Gaudi::Algorithm >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ setFilterPassed()

virtual void AthCommonReentrantAlgorithm< Gaudi::Algorithm >::setFilterPassed ( bool state,
const EventContext & ctx ) const
inlinevirtualinherited

Definition at line 100 of file AthCommonReentrantAlgorithm.h.

100 {
102 }
virtual void setFilterPassed(bool state, const EventContext &ctx) const

◆ sysExecute()

StatusCode AthCommonReentrantAlgorithm< Gaudi::Algorithm >::sysExecute ( const EventContext & ctx)
overridevirtualinherited

Execute an algorithm.

We override this in order to work around an issue with the Algorithm base class storing the event context in a member variable that can cause crashes in MT jobs.

Definition at line 85 of file AthCommonReentrantAlgorithm.cxx.

77{
78 return BaseAlg::sysExecute (ctx);
79}

◆ sysInitialize()

StatusCode AthCommonReentrantAlgorithm< Gaudi::Algorithm >::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >.

Reimplemented in HypoBase, and InputMakerBase.

Definition at line 61 of file AthCommonReentrantAlgorithm.cxx.

107 {
109
110 if (sc.isFailure()) {
111 return sc;
112 }
113
114 ServiceHandle<ICondSvc> cs("CondSvc",name());
115 for (auto h : outputHandles()) {
116 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
117 // do this inside the loop so we don't create the CondSvc until needed
118 if ( cs.retrieve().isFailure() ) {
119 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
120 return StatusCode::SUCCESS;
121 }
122 if (cs->regHandle(this,*h).isFailure()) {
124 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
125 << " with CondSvc");
126 }
127 }
128 }
129 return sc;
130}
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ tokenize()

std::vector< float > BunchCrossingCondAlg::tokenize ( const std::string & pattern) const
private

This helper function is used to convert a string of type "[0.0, 0.0, 1.0, 1.0, 1.0]" into a vector of floats.

As it happens, the digitization stores the bunch pattern in such a fancy style...

Parameters
patternThe pattern extracted from the MC file metadata
Returns
The "decoded" bunch pattern

Definition at line 376 of file BunchCrossingCondAlg.cxx.

376 {
377 ATH_MSG_VERBOSE("Input to tokenize: " << pattern);
378
379 std::vector< float > result;
380 const char* c= pattern.data();
381 const char* cEnd= c + pattern.size();
382 while(c<cEnd) {
383 //This loop swallows actually any string containing numbers
384 //separated by non-numbers
385 char* end;
386 float f=std::strtof(c,&end);
387 if (c==end) {//Can't convert, try next
388 c++;
389 }
390 else { //got a value
391 result.push_back(f);
392 c=end;
393 }
394 }//end while loop
395 return result;
396}
#define ATH_MSG_VERBOSE(x)

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }

Member Data Documentation

◆ m_bunchGroupCondDataKey

SG::ReadCondHandleKey<TrigConf::L1BunchGroupSet> BunchCrossingCondAlg::m_bunchGroupCondDataKey {this, "L1BunchGroupCondData", "L1BunchGroup", "Bunch group cond data key"}
private

Definition at line 52 of file BunchCrossingCondAlg.h.

52{this, "L1BunchGroupCondData", "L1BunchGroup", "Bunch group cond data key"};

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthCommonReentrantAlgorithm< Gaudi::Algorithm >::m_extendedExtraObjects
privateinherited

Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.

Empty if no symlinks were found.

Definition at line 114 of file AthCommonReentrantAlgorithm.h.

◆ m_fillParamsFolderKey

SG::ReadCondHandleKey<AthenaAttributeList> BunchCrossingCondAlg::m_fillParamsFolderKey { this, "FillParamsFolderKey", "/TDAQ/OLC/LHC/FILLPARAMS", "" }
private

Input conditions object.

Definition at line 50 of file BunchCrossingCondAlg.h.

50{ this, "FillParamsFolderKey", "/TDAQ/OLC/LHC/FILLPARAMS", "" };

◆ m_isRun1

Gaudi::Property<bool> BunchCrossingCondAlg::m_isRun1 {this,"Run1",false,"Assume run-1 database"}
private

Definition at line 66 of file BunchCrossingCondAlg.h.

66{this,"Run1",false,"Assume run-1 database"};

◆ m_lumiCondDataKey

SG::ReadCondHandleKey<LuminosityCondData> BunchCrossingCondAlg::m_lumiCondDataKey {this, "LumiCondData", "LuminosityCondData", "Lumi cond data key"}
private

Definition at line 51 of file BunchCrossingCondAlg.h.

51{this, "LumiCondData", "LuminosityCondData", "Lumi cond data key"};

◆ m_maxBunchSpacing

Gaudi::Property<unsigned> BunchCrossingCondAlg::m_maxBunchSpacing {this, "MaxBunchSpacing",5, "Maximal bunch-spacing to be considered a 'bunch train'"}
private

Definition at line 64 of file BunchCrossingCondAlg.h.

64{this, "MaxBunchSpacing",5, "Maximal bunch-spacing to be considered a 'bunch train'"};

◆ m_minBunchesPerTrain

Gaudi::Property<unsigned> BunchCrossingCondAlg::m_minBunchesPerTrain {this, "MinBunchesPerTrain",32, "Minimal number of bunches to be considerd a 'bunch train'"}
private

Definition at line 65 of file BunchCrossingCondAlg.h.

65{this, "MinBunchesPerTrain",32, "Minimal number of bunches to be considerd a 'bunch train'"};

◆ m_mode

Gaudi::Property<int> BunchCrossingCondAlg::m_mode {this, "Mode", 1, "Alg mode (COOL FILLPARAMS = 0, MC = 1, TrigConf = 2, Luminosity = 3)"}
private

Definition at line 67 of file BunchCrossingCondAlg.h.

67{this, "Mode", 1, "Alg mode (COOL FILLPARAMS = 0, MC = 1, TrigConf = 2, Luminosity = 3)"};

◆ m_outputKey

SG::WriteCondHandleKey<BunchCrossingCondData> BunchCrossingCondAlg::m_outputKey {this, "OutputKey", "BunchCrossingData", "Key of output CDO" }
private

Output conditions object.

Definition at line 54 of file BunchCrossingCondAlg.h.

54{this, "OutputKey", "BunchCrossingData", "Key of output CDO" };

◆ m_trigConfigSvc

const ServiceHandle<TrigConf::ILVL1ConfigSvc> BunchCrossingCondAlg::m_trigConfigSvc {this, "TrigConfigSvc", "TrigConf::xAODConfigSvc/xAODConfigSvc", "Trig Config Svc"}
private

Definition at line 57 of file BunchCrossingCondAlg.h.

57{this, "TrigConfigSvc", "TrigConf::xAODConfigSvc/xAODConfigSvc", "Trig Config Svc"};

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: