diff --git a/DataFormats/Parameters/src/GRPLHCIFData.cxx b/DataFormats/Parameters/src/GRPLHCIFData.cxx index 66155fbd48ad2..8c7398bf0616c 100644 --- a/DataFormats/Parameters/src/GRPLHCIFData.cxx +++ b/DataFormats/Parameters/src/GRPLHCIFData.cxx @@ -80,7 +80,9 @@ void GRPLHCIFData::translateBucketsToBCNumbers(std::vector& bcNb, std:: { // to translate the vector of bucket numbers to BC numbers for (auto i : buckets) { - bcNb.push_back(i = 0 ? 0 : (i / 10 + o2::constants::lhc::BunchOffsetsP2[beam]) % o2::constants::lhc::LHCMaxBunches); + if (i) { + bcNb.push_back((i / 10 + o2::constants::lhc::BunchOffsetsP2[beam]) % o2::constants::lhc::LHCMaxBunches); + } } } diff --git a/DataFormats/common/include/CommonDataFormat/BunchFilling.h b/DataFormats/common/include/CommonDataFormat/BunchFilling.h index 777cb7976ff84..9f7aaf31aa655 100644 --- a/DataFormats/common/include/CommonDataFormat/BunchFilling.h +++ b/DataFormats/common/include/CommonDataFormat/BunchFilling.h @@ -50,6 +50,9 @@ class BunchFilling // get pattern of interacting BCs (-1) or beams filled BCs at P2 (0,1) const auto& getPattern(int dir = -1) const { return dir < 0 ? getBCPattern() : getBeamPattern(dir); } + // create pattern from filled bucket + void buckets2BeamPattern(const std::vector& buckets, int ibeam); + // get number of interacting bunches (-1) and number of filled bunches for clockwise (0, A) and anticlockwise (1, C) beams int getNBunches(int dir = -1) const { return dir < 0 ? mPattern.count() : mBeamAC[dir].count(); } diff --git a/DataFormats/common/src/BunchFilling.cxx b/DataFormats/common/src/BunchFilling.cxx index 2b406ec4b34bd..8e73cd02e896a 100644 --- a/DataFormats/common/src/BunchFilling.cxx +++ b/DataFormats/common/src/BunchFilling.cxx @@ -206,6 +206,18 @@ std::string BunchFilling::buckets2PatternString(const std::vector& buckets, return pattS; } +//_________________________________________________ +void BunchFilling::buckets2BeamPattern(const std::vector& buckets, int ibeam) +{ + // create bunches pattern string from filled buckets, in the format parsed by o2::BunchFilling::createPattern + Pattern& patt = mBeamAC[ibeam]; + for (int b : buckets) { + if (b) { + patt[o2::constants::lhc::LHCBunch2P2BC(b / 10, o2::constants::lhc::BeamDirection(ibeam))] = true; + } + } +} + //_________________________________________________ bool BunchFilling::parsePattern(const unsigned char*& input, BunchFilling::Pattern& patt, int& ibit, int& level) { diff --git a/Detectors/GRP/workflows/src/GRPLHCIFfileSpec.cxx b/Detectors/GRP/workflows/src/GRPLHCIFfileSpec.cxx index 4b0b3268b338e..248c2d4d39e47 100644 --- a/Detectors/GRP/workflows/src/GRPLHCIFfileSpec.cxx +++ b/Detectors/GRP/workflows/src/GRPLHCIFfileSpec.cxx @@ -131,7 +131,7 @@ void GRPLHCIFfileProcessor::run(o2::framework::ProcessingContext& pc) if (nMeas == 0) { LOG(fatal) << "Bunch Config Beam 1 not present"; } - if (nEle != 1 || nMeas != 1) { + if (nMeas != 1) { LOG(error) << "More than one value/measurement found for Bunch Config Beam 1, keeping the last one"; } @@ -140,28 +140,14 @@ void GRPLHCIFfileProcessor::run(o2::framework::ProcessingContext& pc) if (nMeas == 0) { LOG(fatal) << "Bunch Config Beam 2 not present"; } - if (nEle != 1 || nMeas != 1) { + if (nMeas != 1) { LOG(error) << "More than one value/measurement found for Bunch Config Beam 2, keeping the last one"; } - if (nMeas != o2::constants::lhc::LHCMaxBunches) { - LOG(error) << "We don't have the right number of bunches information for Beam 2"; - } // Building Bunch Filling - std::vector bcNumbersB1, bcNumbersB2; - lhcifdata.translateBucketsToBCNumbers(bcNumbersB1, bunchConfigB1.back().second, 1); - lhcifdata.translateBucketsToBCNumbers(bcNumbersB2, bunchConfigB2.back().second, 2); o2::BunchFilling bunchFilling; - for (int i = 0; i < bcNumbersB1.size(); ++i) { - int bc = bcNumbersB1[i]; - int val = (bc == 0 ? 0 : 1); - bunchFilling.setBC(bc, val, 0); - } - for (int i = 0; i < bcNumbersB2.size(); ++i) { - int bc = bcNumbersB2[i]; - int val = (bc == 0 ? 0 : 1); - bunchFilling.setBC(bc, val, 1); - } + bunchFilling.buckets2BeamPattern(bunchConfigB1.back().second, 0); + bunchFilling.buckets2BeamPattern(bunchConfigB2.back().second, 1); bunchFilling.setInteractingBCsFromBeams(); lhcifdata.setBunchFillingWithTime((bunchConfigB1.back().first + bunchConfigB2.back().first) / 2, bunchFilling);