Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion DataFormats/Parameters/src/GRPLHCIFData.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ void GRPLHCIFData::translateBucketsToBCNumbers(std::vector<int32_t>& 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);
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions DataFormats/common/include/CommonDataFormat/BunchFilling.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>& 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(); }

Expand Down
12 changes: 12 additions & 0 deletions DataFormats/common/src/BunchFilling.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,18 @@ std::string BunchFilling::buckets2PatternString(const std::vector<int>& buckets,
return pattS;
}

//_________________________________________________
void BunchFilling::buckets2BeamPattern(const std::vector<int>& 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)
{
Expand Down
22 changes: 4 additions & 18 deletions Detectors/GRP/workflows/src/GRPLHCIFfileSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

Expand All @@ -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<int32_t> 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);
Expand Down