6 #include "CoolKernel/IObject.h"
7 #include "CoralBase/Blob.h"
13 #include "CoralBase/AttributeListException.h"
17 EventIDBase infiniteIOVBegin() {
18 return EventIDBase( 0,
19 EventIDBase::UNDEFEVT,
26 EventIDBase infiniteIOVEnd() {
28 EventIDBase::UNDEFEVT,
45 return StatusCode::SUCCESS;
54 return StatusCode::SUCCESS;
59 EventIDRange infinite_range(infiniteIOVBegin(),infiniteIOVEnd());
63 auto bccd=std::make_unique<BunchCrossingCondData>();
71 return StatusCode::FAILURE;
78 if (bgs->size() >= 2) {
79 ATH_MSG_DEBUG(
"from BunchGroupCondData: BG1 bunches " << bgs->getBunchGroup(1)->bunches() );
80 for (
const auto&
pos : bgs->getBunchGroup(1)->bunches() ) {
81 bccd->m_beam1.set(
pos);
82 bccd->m_beam2.set(
pos);
83 bccd->m_luminous.set(
pos);
91 if (bgs->size() >= 15) {
92 for (
const auto&
pos : bgs->getBunchGroup(13)->bunches() ) {
93 bccd->m_beam1.set(
pos);
95 for (
const auto&
pos : bgs->getBunchGroup(14)->bunches() ) {
96 bccd->m_beam2.set(
pos);
102 const auto& thisevt = ctx.eventID();
103 EventIDRange
range = EventIDRange(EventIDBase(thisevt.run_number(), EventIDBase::UNDEFEVT,
104 EventIDBase::UNDEFNUM, 0, thisevt.lumi_block()),
105 EventIDBase(thisevt.run_number(), EventIDBase::UNDEFEVT,
106 EventIDBase::UNDEFNUM, 0, thisevt.lumi_block()+1));
115 float avMu = prefLumiHdl->lbAverageInteractionsPerCrossing();
116 const auto& lumiVec = prefLumiHdl->lbLuminosityPerBCIDVector();
117 float cutLumi = avMu/1000.f*prefLumiHdl->muToLumi();
120 if (lumiVec[
bcid] > cutLumi) {
121 bccd->m_beam1.set(
bcid);
122 bccd->m_beam2.set(
bcid);
123 bccd->m_luminous.set(
bcid);
140 ATH_MSG_INFO(
"Got AttributeList with size " << attrList->size());
141 std::string sbunches;
143 const coral::Attribute& attr=(*attrList)[std::string(
"BeamIntensityPattern")];
145 ATH_MSG_ERROR(
"Got NULL attribute for BeamIntensityPattern");
146 return StatusCode::FAILURE;
148 sbunches = attr.data< std::string >();
149 }
catch (coral::AttributeListException&
e) {
152 return StatusCode::FAILURE;
155 const float minBunchIntensity=0.001;
156 std::vector<float> bunches=
tokenize(sbunches);
157 if (!bunches.empty()) {
166 const int pos1 =
i % bunches.size();
167 const int pos2 = bunches.size() - 1 - (
i % bunches.size() );
168 if( bunches[ pos1 ] > minBunchIntensity) {
169 bccd->m_beam1.set(
i);
170 bccd->m_beam2.set(
i);
171 bccd->m_luminous.set(
i);
173 if( bunches[ pos2 ] > minBunchIntensity) {
185 const int pos =
i % bunches.size();
186 if( bunches[
pos ] > minBunchIntensity) {
187 bccd->m_beam1.set(
i);
188 bccd->m_beam2.set(
i);
189 bccd->m_luminous.set(
i);
197 ATH_MSG_INFO(
"Bunch structure information not found in metadata");
198 ATH_MSG_INFO(
"Will consider all BCIDs as single filled bunches (no trains)");
201 bccd->m_luminous.set();
205 if ((*attrList)[
"BCIDmasks"].isNull()) {
207 return StatusCode::FAILURE;
212 cool::UInt32 nb1 = (*attrList)[
"Beam1Bunches"].data<cool::UInt32>();
213 cool::UInt32 nb2 = (*attrList)[
"Beam2Bunches"].data<cool::UInt32>();
214 cool::UInt32 ncol = (*attrList)[
"LuminousBunches"].data<cool::UInt32>();
225 if (
static_cast<cool::UInt32
>(
blob.size() ) != 2 * (nb1 + nb2 + ncol)) {
227 return StatusCode::SUCCESS;
233 bccd->m_beam1.set(
bcid);
239 bccd->m_beam2.set(
bcid);
245 bccd->m_luminous.set(
bcid);
254 return StatusCode::FAILURE;
258 if (blobAddr[
bcid] & 0
x1) {
259 bccd->m_beam1.set(
bcid);
261 if (blobAddr[
bcid] & 0
x2) {
262 bccd->m_beam2.set(
bcid);
264 if ((blobAddr[
bcid] & 0x3) == 0x3) {
265 bccd->m_luminous.set(
bcid);
270 if (bccd->m_beam1.count()!= nb1) {
271 ATH_MSG_WARNING(
"Found " << bccd->m_beam1.count() <<
" bunches in beam1, expected " << nb1);
274 if (bccd->m_beam2.count()!= nb2) {
275 ATH_MSG_WARNING(
"Found " << bccd->m_beam2.count() <<
" bunches in beam2, expected " << nb2);
278 if (bccd->m_luminous.count()!= ncol) {
279 ATH_MSG_WARNING(
"Found " << bccd->m_luminous.count() <<
" colliding bunches, expected " << ncol);
288 return StatusCode::SUCCESS;
295 std::vector<bunchTrain_t>
result;
297 std::vector<std::pair<int,int> >
holes;
301 while (
stop<MAX_BCID) {
311 ATH_MSG_DEBUG(
"Found " <<
holes.size() <<
" gaps larger than " << maxSpacingInTrain <<
" in the bunch structure");
320 ATH_MSG_ERROR(
"Looks like we have bunch train spanning the entire ring w/o any gap. Really?");
325 if (
holes.size()>1) {
327 for (
unsigned i=0;
i<
holes.size()-1;++
i) {
339 if (
holes.size()==1 || (
holes.front().first!=0 &&
holes.back().second!=MAX_BCID-1)) {
362 result.push_back(lasttrain);
366 ATH_MSG_DEBUG(
"Found " <<
result.size() <<
" Bunch trains separated by gaps of at least " << maxSpacingInTrain <<
" bcids ");
369 std::vector<bunchTrain_t> result1;
370 result1.reserve(
result.size());
372 if (train.m_nColl >= minBunchesPerTrain) {
373 result1.emplace_back(train);
377 ATH_MSG_INFO(
"Found " << result1.size() <<
" Bunch trains having at least " << minBunchesPerTrain <<
" colliding bunches and separated by at least " << maxSpacingInTrain <<
" bcids");
381 for (
auto&
r : result1) {
382 msg(
MSG::VERBOSE) <<
"Train " <<
r.m_first <<
" - " <<
r.m_last <<
", " <<
r.m_nColl <<
" colliding bcids" <<
endmsg;
401 std::vector< float >
result;
403 const char* cEnd=
c +
pattern.size();