Skip to content

Commit

Permalink
Add collBC conditional in QA (AliceO2Group#3686)
Browse files Browse the repository at this point in the history
* Add collBC conditional in QA

* Please consider the following formatting changes (#179)

---------

Co-authored-by: David Dobrigkeit Chinellato <david.dobrigkeit.chinellato.cern.ch>
Co-authored-by: ALICE Builder <[email protected]>
  • Loading branch information
ddobrigk and alibuild authored Oct 25, 2023
1 parent 27b545f commit af2651f
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 10 deletions.
4 changes: 3 additions & 1 deletion Common/DataModel/Multiplicity.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
59 changes: 50 additions & 9 deletions Common/TableProducer/multiplicityExtraTable.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <CCDB/BasicCCDBManager.h>
#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 <CCDB/BasicCCDBManager.h>
#include "DataFormatsParameters/GRPObject.h"
#include "DataFormatsParameters/GRPLHCIFData.h"
#include <bitset>

using namespace o2;
using namespace o2::framework;
using namespace o2::framework::expressions;
using BCPattern = std::bitset<o2::constants::lhc::LHCMaxBunches>;
const int nBCsPerOrbit = o2::constants::lhc::LHCMaxBunches;

struct MultiplicityExtraTable {
Produces<aod::MultsBC> multBC;

unsigned int randomSeed = 0;
o2::ccdb::CcdbApi ccdbApi;
Service<o2::ccdb::BasicCCDBManager> 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<aod::BCs, aod::Timestamps, aod::Run3MatchedToBCSparse>;
Expand All @@ -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<string, string> 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<std::string, std::string> mapMetadata;
std::map<std::string, std::string> mapHeader;
auto grplhcif = ccdb->getForTimeStamp<o2::parameters::GRPLHCIFData>("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();
Expand All @@ -69,7 +110,7 @@ struct MultiplicityExtraTable {
} // fv0
}

multBC(multFT0A, multFT0C, multFV0A, Tvx, isFV0OrA, multFV0TriggerBits, multBCTriggerMask);
multBC(multFT0A, multFT0C, multFV0A, Tvx, isFV0OrA, multFV0TriggerBits, multBCTriggerMask, collidingBC);
}
};

Expand Down

0 comments on commit af2651f

Please sign in to comment.