Skip to content

Commit d7dc17a

Browse files
nburmasosawenzel
authored andcommitted
Clean-up for the BC table
1 parent 8b71870 commit d7dc17a

1 file changed

Lines changed: 35 additions & 22 deletions

File tree

Detectors/AOD/src/AODProducerWorkflowSpec.cxx

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc)
454454

455455
uint64_t globalBC;
456456
uint64_t BCid;
457+
std::vector<uint64_t> BCIDs;
457458

458459
findMinMaxBc(ft0RecPoints, primVertices, mcRecords);
459460

@@ -479,21 +480,6 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc)
479480
outfile->mkdir(dirName.c_str());
480481
}
481482

482-
// TODO: get real triggerMask
483-
uint64_t triggerMask = 1;
484-
for (uint64_t i = 0; i <= maxGlBC - minGlBC; i++) {
485-
bcCursor(0,
486-
runNumber,
487-
minGlBC + i,
488-
triggerMask);
489-
}
490-
491-
if (mIgnoreWriter) {
492-
std::shared_ptr<arrow::Table> tableBC = bcBuilder.finalize();
493-
std::string tableName("O2bc");
494-
writeTableToFile(outfile, tableBC, tableName, tfNumber);
495-
}
496-
497483
// TODO: add real FV0A, FV0C, FDD, ZDC tables instead of dummies
498484
uint64_t dummyBC = 0;
499485
float dummyTime = 0.f;
@@ -584,9 +570,10 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc)
584570
BCid = globalBC - minGlBC;
585571
if (BCid < 0) {
586572
BCid = 0;
587-
} else if (BCid > maxGlBC) {
588-
BCid = maxGlBC;
573+
} else if (BCid > maxGlBC - minGlBC) {
574+
BCid = maxGlBC - minGlBC;
589575
}
576+
BCIDs.push_back(BCid);
590577
auto& colParts = mcParts[index];
591578
for (auto colPart : colParts) {
592579
auto eventID = colPart.entryID;
@@ -635,9 +622,10 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc)
635622
BCid = globalBC - minGlBC;
636623
if (BCid < 0) {
637624
BCid = 0;
638-
} else if (BCid > maxGlBC) {
639-
BCid = maxGlBC;
625+
} else if (BCid > maxGlBC - minGlBC) {
626+
BCid = maxGlBC - minGlBC;
640627
}
628+
BCIDs.push_back(BCid);
641629
ft0Cursor(0,
642630
BCid,
643631
aAmplitudesA,
@@ -664,16 +652,17 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc)
664652
auto& cov = vertex.getCov();
665653
auto& timeStamp = vertex.getTimeStamp();
666654
Double_t tsTimeStamp = timeStamp.getTimeStamp() * 1E3; // mus to ns
667-
globalBC = std::round(startBCofTF + tsTimeStamp / o2::constants::lhc::LHCBunchSpacingNS);
655+
globalBC = std::round(tsTimeStamp / o2::constants::lhc::LHCBunchSpacingNS);
668656
LOG(DEBUG) << globalBC << " " << tsTimeStamp;
669657
// collision timestamp in ns wrt the beginning of collision BC
670658
tsTimeStamp = globalBC * o2::constants::lhc::LHCBunchSpacingNS - tsTimeStamp;
671659
BCid = globalBC - minGlBC;
672660
if (BCid < 0) {
673661
BCid = 0;
674-
} else if (BCid > maxGlBC) {
675-
BCid = maxGlBC;
662+
} else if (BCid > maxGlBC - minGlBC) {
663+
BCid = maxGlBC - minGlBC;
676664
}
665+
BCIDs.push_back(BCid);
677666
// TODO: get real collision time mask
678667
int collisionTimeMask = 0;
679668
collisionsCursor(0,
@@ -721,6 +710,30 @@ void AODProducerWorkflowDPL::run(ProcessingContext& pc)
721710
writeTableToFile(outfile, tableCollisions, tableName, tfNumber);
722711
}
723712

713+
// filling BC table
714+
// TODO: get real triggerMask
715+
uint64_t triggerMask = 1;
716+
std::sort(BCIDs.begin(), BCIDs.end());
717+
uint64_t prevBCid = BCIDs.back();
718+
for (auto& BCid : BCIDs) {
719+
if (BCid == prevBCid) {
720+
continue;
721+
}
722+
bcCursor(0,
723+
runNumber,
724+
startBCofTF + minGlBC + BCid,
725+
triggerMask);
726+
prevBCid = BCid;
727+
}
728+
729+
BCIDs.clear();
730+
731+
if (mIgnoreWriter) {
732+
std::shared_ptr<arrow::Table> tableBC = bcBuilder.finalize();
733+
std::string tableName("O2bc");
734+
writeTableToFile(outfile, tableBC, tableName, tfNumber);
735+
}
736+
724737
// filling mc particles table
725738
std::vector<std::vector<std::vector<int>>> toStore;
726739
for (int source = 0; source < mcReader.getNSources(); source++) {

0 commit comments

Comments
 (0)