From af2651fdd44276d14fed465c6ee297bc993316cd Mon Sep 17 00:00:00 2001 From: ddobrigk Date: Wed, 25 Oct 2023 06:15:43 +0200 Subject: [PATCH] Add collBC conditional in QA (#3686) * Add collBC conditional in QA * Please consider the following formatting changes (#179) --------- Co-authored-by: David Dobrigkeit Chinellato Co-authored-by: ALICE Builder --- Common/DataModel/Multiplicity.h | 4 +- .../TableProducer/multiplicityExtraTable.cxx | 59 ++++++++++++++++--- 2 files changed, 53 insertions(+), 10 deletions(-) diff --git a/Common/DataModel/Multiplicity.h b/Common/DataModel/Multiplicity.h index d971a0671b6..aa6440fb96d 100644 --- a/Common/DataModel/Multiplicity.h +++ b/Common/DataModel/Multiplicity.h @@ -116,6 +116,7 @@ DECLARE_SOA_COLUMN(MultBCTVX, multBCTVX, bool); //! DECLARE_SOA_COLUMN(MultBCFV0OrA, multBCFV0OrA, bool); //! DECLARE_SOA_COLUMN(MultBCV0triggerBits, multBCV0triggerBits, uint8_t); //! DECLARE_SOA_COLUMN(MultBCTriggerMask, multBCTriggerMask, uint64_t); //! CTP trigger mask +DECLARE_SOA_COLUMN(MultBCColliding, multBCColliding, bool); //! CTP trigger mask } // namespace multDebug DECLARE_SOA_TABLE(MultsBC, "AOD", "MULTBC", //! multBC::MultBCFT0A, @@ -124,7 +125,8 @@ DECLARE_SOA_TABLE(MultsBC, "AOD", "MULTBC", //! multBC::MultBCTVX, multBC::MultBCFV0OrA, multBC::MultBCV0triggerBits, - multBC::MultBCTriggerMask); + multBC::MultBCTriggerMask, + multBC::MultBCColliding); using MultBC = MultsBC::iterator; } // namespace o2::aod diff --git a/Common/TableProducer/multiplicityExtraTable.cxx b/Common/TableProducer/multiplicityExtraTable.cxx index eecda5efb63..729d90fa8c4 100644 --- a/Common/TableProducer/multiplicityExtraTable.cxx +++ b/Common/TableProducer/multiplicityExtraTable.cxx @@ -9,27 +9,43 @@ // granted to it by virtue of its status as an Intergovernmental Organization // or submit itself to any jurisdiction. #include "Framework/ConfigParamSpec.h" - -using namespace o2; -using namespace o2::framework; - #include "Framework/runDataProcessing.h" #include "Framework/AnalysisTask.h" #include "Framework/AnalysisDataModel.h" -#include #include "Common/DataModel/EventSelection.h" #include "Common/DataModel/Multiplicity.h" #include "DataFormatsFIT/Triggers.h" #include "TableHelper.h" -#include "iostream" + +#include "CCDB/CcdbApi.h" +#include "CommonDataFormat/BunchFilling.h" +#include +#include "DataFormatsParameters/GRPObject.h" +#include "DataFormatsParameters/GRPLHCIFData.h" +#include + +using namespace o2; +using namespace o2::framework; +using namespace o2::framework::expressions; +using BCPattern = std::bitset; +const int nBCsPerOrbit = o2::constants::lhc::LHCMaxBunches; struct MultiplicityExtraTable { Produces multBC; - unsigned int randomSeed = 0; + o2::ccdb::CcdbApi ccdbApi; + Service ccdb; + BCPattern CollidingBunch; + + int newRunNumber = -999; + int oldRunNumber = -999; + void init(InitContext& context) { - // empty for now + ccdbApi.init("http://alice-ccdb.cern.ch"); + ccdb->setURL("http://alice-ccdb.cern.ch"); + ccdb->setCaching(true); + ccdb->setLocalObjectValidityChecking(); } using BCsWithRun3Matchings = soa::Join; @@ -44,6 +60,31 @@ struct MultiplicityExtraTable { uint8_t multFV0TriggerBits = 0; uint64_t multBCTriggerMask = bc.triggerMask(); + // initialize - from Arvind + newRunNumber = bc.runNumber(); + int localBC = bc.globalBC() % nBCsPerOrbit; + + if (newRunNumber != oldRunNumber) { + uint64_t ts{}; + std::map metadataRCT, headers; + headers = ccdbApi.retrieveHeaders(Form("RCT/Info/RunInformation/%i", newRunNumber), metadataRCT, -1); + ts = atol(headers["SOR"].c_str()); + + LOG(info) << " newRunNumber " << newRunNumber << " time stamp " << ts; + oldRunNumber = newRunNumber; + std::map mapMetadata; + std::map mapHeader; + auto grplhcif = ccdb->getForTimeStamp("GLO/Config/GRPLHCIF", ts); + CollidingBunch = grplhcif->getBunchFilling().getBCPattern(); + for (int i = 0; i < (int)CollidingBunch.size(); i++) { + if (CollidingBunch.test(i)) { + LOG(info) << i << " "; + } + } + } // new run number + + bool collidingBC = CollidingBunch.test(localBC); + if (bc.has_ft0()) { auto ft0 = bc.ft0(); std::bitset<8> triggers = ft0.triggerMask(); @@ -69,7 +110,7 @@ struct MultiplicityExtraTable { } // fv0 } - multBC(multFT0A, multFT0C, multFV0A, Tvx, isFV0OrA, multFV0TriggerBits, multBCTriggerMask); + multBC(multFT0A, multFT0C, multFV0A, Tvx, isFV0OrA, multFV0TriggerBits, multBCTriggerMask, collidingBC); } };