6 #include "CoolKernel/IObject.h"
8 #include "CoralBase/Blob.h"
13 #include "CoralBase/AttributeListException.h"
24 return StatusCode::SUCCESS;
33 return StatusCode::SUCCESS;
41 auto bccd=std::make_unique<BunchCrossingCondData>();
49 return StatusCode::FAILURE;
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);
69 if (bgs->size() >= 15) {
70 for (
const auto&
pos : bgs->getBunchGroup(13)->bunches() ) {
71 bccd->m_beam1.set(
pos);
73 for (
const auto&
pos : bgs->getBunchGroup(14)->bunches() ) {
74 bccd->m_beam2.set(
pos);
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));
93 float avMu = prefLumiHdl->lbAverageInteractionsPerCrossing();
94 const auto& lumiVec = prefLumiHdl->lbLuminosityPerBCIDVector();
95 float cutLumi = avMu/1000.f*prefLumiHdl->muToLumi();
98 if (lumiVec[
bcid] > cutLumi) {
99 bccd->m_beam1.set(
bcid);
100 bccd->m_beam2.set(
bcid);
101 bccd->m_luminous.set(
bcid);
118 ATH_MSG_INFO(
"Got AttributeList with size " << attrList->size());
119 std::string sbunches;
121 const coral::Attribute& attr=(*attrList)[std::string(
"BeamIntensityPattern")];
123 ATH_MSG_ERROR(
"Got NULL attribute for BeamIntensityPattern");
124 return StatusCode::FAILURE;
126 sbunches = attr.data< std::string >();
127 }
catch (coral::AttributeListException&
e) {
130 return StatusCode::FAILURE;
133 const float minBunchIntensity=0.001;
134 std::vector<float> bunches=
tokenize(sbunches);
135 if (!bunches.empty()) {
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);
151 if( bunches[ pos2 ] > minBunchIntensity) {
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);
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)");
179 bccd->m_luminous.set();
183 if ((*attrList)[
"BCIDmasks"].isNull()) {
185 return StatusCode::FAILURE;
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>();
203 if (
static_cast<cool::UInt32
>(
blob.size() ) != 2 * (nb1 + nb2 + ncol)) {
205 return StatusCode::SUCCESS;
211 bccd->m_beam1.set(
bcid);
217 bccd->m_beam2.set(
bcid);
223 bccd->m_luminous.set(
bcid);
232 return StatusCode::FAILURE;
236 if (blobAddr[
bcid] & 0
x1) {
237 bccd->m_beam1.set(
bcid);
239 if (blobAddr[
bcid] & 0
x2) {
240 bccd->m_beam2.set(
bcid);
242 if ((blobAddr[
bcid] & 0x3) == 0x3) {
243 bccd->m_luminous.set(
bcid);
248 if (bccd->m_beam1.count()!= nb1) {
249 ATH_MSG_WARNING(
"Found " << bccd->m_beam1.count() <<
" bunches in beam1, expected " << nb1);
252 if (bccd->m_beam2.count()!= nb2) {
253 ATH_MSG_WARNING(
"Found " << bccd->m_beam2.count() <<
" bunches in beam2, expected " << nb2);
256 if (bccd->m_luminous.count()!= ncol) {
257 ATH_MSG_WARNING(
"Found " << bccd->m_luminous.count() <<
" colliding bunches, expected " << ncol);
266 return StatusCode::SUCCESS;
273 std::vector<bunchTrain_t>
result;
275 std::vector<std::pair<int,int> >
holes;
279 while (
stop<MAX_BCID) {
289 ATH_MSG_DEBUG(
"Found " <<
holes.size() <<
" gaps larger than " << maxSpacingInTrain <<
" in the bunch structure");
298 ATH_MSG_ERROR(
"Looks like we have bunch train spanning the entire ring w/o any gap. Really?");
303 if (
holes.size()>1) {
305 for (
unsigned i=0;
i<
holes.size()-1;++
i) {
317 if (
holes.size()==1 || (
holes.front().first!=0 &&
holes.back().second!=MAX_BCID-1)) {
340 result.push_back(lasttrain);
344 ATH_MSG_DEBUG(
"Found " <<
result.size() <<
" Bunch trains separated by gaps of at least " << maxSpacingInTrain <<
" bcids ");
347 std::vector<bunchTrain_t> result1;
348 result1.reserve(
result.size());
350 if (train.m_nColl >= minBunchesPerTrain) {
351 result1.emplace_back(train);
355 ATH_MSG_INFO(
"Found " << result1.size() <<
" Bunch trains having at least " << minBunchesPerTrain <<
" colliding bunches and separated by at least " << maxSpacingInTrain <<
" bcids");
359 for (
auto&
r : result1) {
360 msg(
MSG::VERBOSE) <<
"Train " <<
r.m_first <<
" - " <<
r.m_last <<
", " <<
r.m_nColl <<
" colliding bcids" <<
endmsg;
379 std::vector< float >
result;
381 const char* cEnd=
c +
pattern.size();