|
ATLAS Offline Software
|
Go to the documentation of this file.
16 #include "CoolKernel/IObject.h"
31 std::vector< float >
result;
33 const char* cEnd=
c +
pattern.size();
75 return StatusCode::SUCCESS;
86 auto lumi = std::make_unique<LuminosityCondData>();
94 EventIDRange
range = EventIDRange(EventIDBase(eventinfo->runNumber(),
95 EventIDBase::UNDEFEVT,
96 eventinfo->timeStamp(),
97 eventinfo->timeStampNSOffset(),
98 eventinfo->lumiBlock()),
99 EventIDBase(eventinfo->runNumber(),
100 EventIDBase::UNDEFEVT,
101 eventinfo->timeStamp()+1,
102 eventinfo->timeStampNSOffset(),
103 eventinfo->lumiBlock()+1));
109 const float avgMu = eventinfo->averageInteractionsPerCrossing();
110 const auto& attr = (**digitizationFolder)[std::string(
"BeamIntensityPattern")];
111 const std::string& sbunches = attr.data<std::string>();
112 std::vector<float> bunchpattern =
tokenize(sbunches);
115 ATH_MSG_ERROR(
"Decoding MC bunch structure failed, improper number of LHC BCIDs");
119 float totintensity = 0.;
120 for (
size_t i = 0;
i < bunchpattern.size(); ++
i) {
121 totintensity += bunchpattern[
i];
125 lumi->setLbAverageInteractionsPerCrossing(avgMu);
127 lumi->setLbLuminosityPerBCIDVector(std::move(bunchpattern));
135 unsigned int preferredChannel;
136 unsigned int calibChannel;
142 bunchInstLumiBlob) );
154 return StatusCode::SUCCESS;
175 unsigned int& preferredChannel,
176 unsigned int& calibChannel,
180 preferredChannel = 0;
182 bunchInstLumiBlob =
nullptr;
185 if (attrList.size() == 0 || attrList[
"Valid"].isNull()) {
187 return StatusCode::SUCCESS;
191 std::ostringstream attrStr1;
192 attrList.toOutputStream( attrStr1 );
198 if (attrList[
"LBAvInstLumi"].isNull() || attrList[
"LBAvEvtsPerBX"].isNull()) {
199 ATH_MSG_ERROR(
" NULL Luminosity information in database " );
200 return StatusCode::FAILURE;
209 ATH_MSG_INFO(
" Invalid LB Average luminosity ... set lumi to 0" );
211 return StatusCode::SUCCESS;
213 ATH_MSG_DEBUG(
" Invalid LB Average luminosity ... continuing because skipInvalid == FALSE" );
221 bool hasAlgorithmID =
false;
222 for (coral::AttributeList::const_iterator attr = attrList.begin();
223 attr != attrList.end(); ++attr) {
224 if (attr->specification().name() ==
"AlgorithmID") {
225 hasAlgorithmID =
true;
230 if (hasAlgorithmID) {
233 calibChannel = attrList[
"AlgorithmID"].data<cool::UInt32>();
237 preferredChannel = (
valid >> 22);
238 calibChannel = preferredChannel;
246 float LBAvInstLumi = attrList[
"LBAvInstLumi"].data<cool::Float>();
247 float LBAvEvtsPerBX = attrList[
"LBAvEvtsPerBX"].data<cool::Float>();
250 if ( std::isnan (LBAvInstLumi) ) {
251 ATH_MSG_WARNING(
" Luminosity is not a number.. " << LBAvInstLumi <<
" ... set it to 0 " );
255 if ( std::isnan (LBAvEvtsPerBX) ) {
256 ATH_MSG_WARNING(
" Luminosity is not a number.. " << LBAvEvtsPerBX <<
" ... set it to 0 " );
260 lumi.setLbAverageLuminosity (LBAvInstLumi);
261 lumi.setLbAverageInteractionsPerCrossing (LBAvEvtsPerBX);
264 int perBcidValid = ((
valid&0x3ff)/10) % 10;
266 return StatusCode::SUCCESS;
270 for (coral::AttributeList::const_iterator attr = attrList.begin();
271 attr != attrList.end(); ++attr)
273 if (attr->specification().name() ==
"BunchInstLumi") {
274 if (!attrList[
"BunchInstLumi"].isNull())
275 bunchInstLumiBlob = &attrList[
"BunchInstLumi"].data<coral::Blob>();
280 return StatusCode::SUCCESS;
298 unsigned int preferredChannel,
299 unsigned int calibChannel,
303 if (
lumi.lbAverageLuminosity() <= 0.) {
305 ATH_MSG_INFO(
"LBAvInstLumi is zero or negative in updatePerBunchLumi():"
306 <<
lumi.lbAverageLuminosity());
309 return StatusCode::SUCCESS;
319 else if (bunchInstLumiBlob !=
nullptr) {
332 << preferredChannel );
333 return StatusCode::SUCCESS;
348 unsigned int calibChannel,
359 float muToLumi = onlineLumiCalibration->
getMuToLumi (calibChannel);
363 ATH_MSG_WARNING(
" Found muToLumi = " << muToLumi <<
" for channel " << calibChannel <<
". Try backup channel..." );
368 lumi.setMuToLumi (muToLumi);
372 int perBcidValid = ((
lumi.lbAverageValid()&0x3ff)/10) % 10;
373 if ((
lumi.lbAverageValid() & 0x03) || (perBcidValid > 0)) {
377 <<
lumi.lbAverageValid() <<
"!" );
378 return StatusCode::SUCCESS;
381 <<
lumi.lbAverageValid()
382 <<
" continuing because skipInvalid == FALSE" );
396 lumi.setMuToLumi (muToLumi);
399 ATH_MSG_DEBUG(
" Found muToLumi = " << muToLumi <<
" for channel "
402 return StatusCode::SUCCESS;
414 unsigned int preferredChannel,
417 ATH_MSG_DEBUG(
"starting updatePerBunchLumiRun2() for alg: " << preferredChannel );
420 if (bunchInstLumiBlob.size() == 0) {
422 return StatusCode::FAILURE;
427 static_cast<const uint8_t*
>(bunchInstLumiBlob.startingAddress());
428 unsigned int bss = ((*pchar) % 100) / 10;
429 unsigned int smod = ((*pchar) % 10);
432 ATH_MSG_DEBUG(
"BunchInstLumi blob found with storage mode " << smod
433 <<
" and byte storage size " << bss );
436 if (bss != 4 || smod != 1) {
437 ATH_MSG_ERROR(
"BunchInstLumi blob found with storage mode " << smod <<
" and byte storage size " << bss <<
" - Unknown!");
438 return StatusCode::FAILURE;
442 unsigned int bloblength = bss * nbcids + 1;
444 if (
static_cast<cool::UInt32
>(bunchInstLumiBlob.size()) != bloblength) {
446 << bunchInstLumiBlob.size() <<
"in storage mode" << smod
447 <<
", expecting " << bloblength <<
"!" );
448 return StatusCode::FAILURE;
455 std::vector<float> instLumi (nbcids);
456 for (
unsigned int i=0;
i<nbcids;
i++) {
462 for (
unsigned int i=0;
i<nbcids;
i++) {
467 lumi.setLbLuminosityPerBCIDVector (std::move (instLumi));
469 return StatusCode::SUCCESS;
481 unsigned int preferredChannel,
485 ATH_MSG_DEBUG(
"starting updatePerBunchLumiRun1() for alg: " << preferredChannel );
487 if (preferredChannel == 0) {
488 return StatusCode::SUCCESS;
493 ATH_MSG_DEBUG(
"OnlineLumiCalibrationInputKey.empty() is TRUE, skipping..." );
494 return StatusCode::SUCCESS;
497 ATH_MSG_DEBUG(
"BunchLumisInputKey.empty() is TRUE, skipping..." );
498 return StatusCode::SUCCESS;
501 ATH_MSG_DEBUG(
"BunchGroupTool.empty() is TRUE, skipping..." );
502 return StatusCode::SUCCESS;
505 ATH_MSG_DEBUG(
"FillParamsInputKey.empty() is TRUE, skipping..." );
506 return StatusCode::SUCCESS;
523 const std::vector<float>& rawLumiVec = bunchLumis->
rawLuminosity(preferredChannel);
524 if (rawLumiVec.empty()) {
526 return StatusCode::SUCCESS;
539 float muToLumi = onlineLumiCalibration->
getMuToLumi (preferredChannel);
540 if (muToLumi <= 0.) {
541 ATH_MSG_ERROR(
" dont have calibration information for preferred channel "
542 << preferredChannel <<
"!" );
543 return StatusCode::FAILURE;
545 lumi.setMuToLumi (muToLumi);
550 if (rawLumiVec.at(
bcid) <= 0.) {
552 << rawLumiVec.at(
bcid) <<
" -> skipping" );
561 ATH_MSG_DEBUG(
"Calibrate BCID " <<
bcid <<
" with raw " << rawLumiVec[
bcid] <<
" -> calibration failed!" );
566 lumiSum += calLumiVec[
bcid];
572 float offlineOnlineRatio = 1.;
573 if (lumiSum > 0.) offlineOnlineRatio =
lumi.lbAverageLuminosity() / lumiSum;
576 <<
" / " << lumiSum <<
" = " << offlineOnlineRatio );
581 if (calLumiVec[
bcid] > 0.)
continue;
582 if (rawLumiVec[
bcid] <= 0.)
continue;
591 <<
" with raw lumi = " << rawLumiVec[
bcid] );
597 for (
float&
lumi : calLumiVec) {
598 lumi *= offlineOnlineRatio;
601 lumi.setLbLuminosityPerBCIDVector (std::move (calLumiVec));
603 return StatusCode::SUCCESS;
Conditions algorithm for luminosity data.
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
StatusCode updateMuToLumi(const EventContext &ctx, unsigned int calibChannel, SG::WriteCondHandle< LuminosityCondData > &wHdl, LuminosityCondData &lumi, bool &isValid) const
Fill in mu-to-lumi calibration.
const std::vector< unsigned int > & luminousBunches() const
SG::WriteCondHandleKey< LuminosityCondData > m_luminosityOutputKey
Output conditions object.
SG::ReadCondHandleKey< CondAttrListCollection > m_luminosityFolderInputKey
StatusCode updatePerBunchLumi(const EventContext &ctx, const coral::Blob *bunchInstLumiBlob, unsigned int preferredChannel, unsigned int calibChannel, SG::WriteCondHandle< LuminosityCondData > &wHdl, LuminosityCondData &lumi) const
Fill in per-bunch luminosity data.
std::vector< std::string > tokenize(const std::string &the_str, std::string_view delimiters)
Splits the string into smaller substrings.
SG::ReadCondHandleKey< OnlineLumiCalibrationCondData > m_onlineLumiCalibrationInputKey
bool msgLvl(const MSG::Level lvl) const
SG::ReadCondHandleKey< FillParamsCondData > m_fillParamsInputKey
static constexpr unsigned int TOTAL_LHC_BCIDS
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
bool empty() const
Test if the key is blank.
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
virtual StatusCode execute(const EventContext &ctx) const override
Algorithm execute method.
This class is a collection of AttributeLists where each one is associated with a channel number....
@ u
Enums for curvilinear frames.
Gaudi::Property< unsigned long > m_calibBackupChannel
float get_unaligned_float(const uint8_t *ATH_RESTRICT &p)
Read little-endian float value from a possibly unaligned pointer.
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
SG::ReadCondHandleKey< BunchGroupCondData > m_bunchGroupInputKey
Gaudi::Property< bool > m_expectInvalid
virtual StatusCode initialize() override
Gaudi initialize method.
::StatusCode StatusCode
StatusCode definition for legacy code.
Gaudi::Property< float > m_muToLumi
static EventIDRange infiniteRunLB()
Produces an EventIDRange that is infinite in RunLumi and invalid in Time.
SG::ReadDecorHandleKey< xAOD::EventInfo > m_actualMuKey
const AttributeList & attributeList(ChanNum chanNum) const
attribute list for a given channel number
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Read little-endian values through possibly unaligned pointers.
StatusCode updateAvgLumi(const CondAttrListCollection &lumiData, LuminosityCondData &lumi, unsigned int &preferredChannel, unsigned int &calibChannel, const coral::Blob *&bunchInstLumiBlob) const
Unpack luminosity data from the attribute list.
StatusCode updatePerBunchLumiRun1(const EventContext &ctx, unsigned int preferredChannel, SG::WriteCondHandle< LuminosityCondData > &wHdl, LuminosityCondData &lumi) const
Fill in per-bunch luminosity data, run 1.
const std::vector< float > & rawLuminosity(unsigned int channel) const
Return vector of per-BCID raw luminosity for a given channel.
StatusCode initialize(bool used=true)
setEventNumber setTimeStamp bcid
Gaudi::Property< bool > m_isMC
float getMuToLumi(unsigned int channel) const
Return muToLumi parameter.
const std::vector< unsigned int > & bunchGroup(unsigned int group) const
Return filled BCIDs for one bunch group.
StatusCode updatePerBunchLumiRun2(const coral::Blob &bunchInstLumiBlob, unsigned int preferredChannel, LuminosityCondData &lumi) const
Fill in per-bunch luminosity data, run 2 and later.
bool calibrateLumi(unsigned int channel, float raw, float &lumi) const
Luminosity calibration.
SG::ReadCondHandleKey< BunchLumisCondData > m_bunchLumisInputKey
#define ATH_MSG_WARNING(x)
bool strtof(const std::string &input, T &f)
Gaudi::Property< bool > m_skipInvalid
SG::ReadCondHandleKey< AthenaAttributeList > m_mcDigitizationInputKey
const T * get(const ReadHandleKey< T > &key)
Convenience function to retrieve an object given a ReadHandleKey.
Gaudi::Property< unsigned long > m_lumiChannel
SG::ReadDecorHandleKey< xAOD::EventInfo > m_averageMuKey
void addDependency(const EventIDRange &range)