Skip to content

Commit

Permalink
Merge pull request #42284 from francescobrivio/alca-revert_BS_fallbac…
Browse files Browse the repository at this point in the history
…k_logic

Revert BeamSpot fallback logic
  • Loading branch information
cmsbuild authored Jul 19, 2023
2 parents ee1af99 + b21e838 commit 14dfdc9
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 38 deletions.
2 changes: 1 addition & 1 deletion DQM/BeamMonitor/plugins/OnlineBeamMonitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void OnlineBeamMonitor::bookHistograms(DQMStore::IBooker& ibooker,
ibooker.setCurrentFolder(monitorName_ + "Validation");
//Book histograms
bsChoice_ = ibooker.bookProfile("bsChoice",
"BS Choice (+1): HLT - (-1): Legacy - (-10): Fake BS - (0): No Transient ",
"BS Choice: +1=HLT / -1=Legacy / -10=Fake (fallback to PCL) / 0=No Transient ",
lastLumi - firstLumi + 1,
firstLumi - 0.5,
lastLumi + 0.5,
Expand Down
54 changes: 27 additions & 27 deletions RecoVertex/BeamSpotProducer/plugins/BeamSpotOnlineProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,39 +103,39 @@ void BeamSpotOnlineProducer::produce(Event& iEvent, const EventSetup& iSetup) {
bool fallBackToDB = false;
if (useTransientRecord_) {
auto const& spotDB = iSetup.getData(beamTransientToken_);

if (spotDB.beamType() != 2) {
if (shoutMODE && beamTransientRcdESWatcher_.check(iSetup)) {
edm::LogWarning("BeamSpotFromDB") << "Online Beam Spot producer writes a fake beamspot value because the "
"ESProducer returned a fake beamspot!";
edm::LogWarning("BeamSpotFromDB")
<< "Online Beam Spot producer falls back to DB value because the ESProducer returned a fake beamspot ";
}
}

// translate from BeamSpotObjects to reco::BeamSpot
// in case we need to switch to LHC reference frame
// ignore for the moment rotations, and translations
double f = 1.;
if (changeFrame_)
f = -1.;
reco::BeamSpot::Point apoint(f * spotDB.x(), f * spotDB.y(), f * spotDB.z());
fallBackToDB = true;
} else {
// translate from BeamSpotObjects to reco::BeamSpot
// in case we need to switch to LHC reference frame
// ignore for the moment rotations, and translations
double f = 1.;
if (changeFrame_)
f = -1.;
reco::BeamSpot::Point apoint(f * spotDB.x(), f * spotDB.y(), f * spotDB.z());

reco::BeamSpot::CovarianceMatrix matrix;
for (int i = 0; i < 7; ++i) {
for (int j = 0; j < 7; ++j) {
matrix(i, j) = spotDB.covariance(i, j);
reco::BeamSpot::CovarianceMatrix matrix;
for (int i = 0; i < 7; ++i) {
for (int j = 0; j < 7; ++j) {
matrix(i, j) = spotDB.covariance(i, j);
}
}
}
double sigmaZ = spotDB.sigmaZ();
if (theSetSigmaZ > 0)
sigmaZ = theSetSigmaZ;
double sigmaZ = spotDB.sigmaZ();
if (theSetSigmaZ > 0)
sigmaZ = theSetSigmaZ;

// this assume beam width same in x and y
aSpot = reco::BeamSpot(apoint, sigmaZ, spotDB.dxdz(), spotDB.dydz(), spotDB.beamWidthX(), matrix);
aSpot.setBeamWidthY(spotDB.beamWidthY());
aSpot.setEmittanceX(spotDB.emittanceX());
aSpot.setEmittanceY(spotDB.emittanceY());
aSpot.setbetaStar(spotDB.betaStar());
aSpot.setType(static_cast<reco::BeamSpot::BeamType>(spotDB.beamType()));
// this assume beam width same in x and y
aSpot = reco::BeamSpot(apoint, sigmaZ, spotDB.dxdz(), spotDB.dydz(), spotDB.beamWidthX(), matrix);
aSpot.setBeamWidthY(spotDB.beamWidthY());
aSpot.setEmittanceX(spotDB.emittanceX());
aSpot.setEmittanceY(spotDB.emittanceY());
aSpot.setbetaStar(spotDB.betaStar());
aSpot.setType(reco::BeamSpot::Tracker);
}
} else {
// get scalar collection
Handle<BeamSpotOnlineCollection> handleScaler;
Expand Down
22 changes: 12 additions & 10 deletions RecoVertex/BeamSpotProducer/plugins/OnlineBeamSpotESProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,22 +97,23 @@ const BeamSpotOnlineObjects* OnlineBeamSpotESProducer::compareBS(const BeamSpotO
// 3. If both are newer than the limit threshold return the BS that
// passes isGoodBS and has larger sigmaZ
if (diffBStime1 > limitTime && diffBStime2 > limitTime) {
edm::LogInfo("OnlineBeamSpotESProducer") << "Defaulting to fake because both payloads are too old.";
edm::LogWarning("OnlineBeamSpotESProducer")
<< "Defaulting to fake (fallback to PCL) because both payloads are too old.";
return nullptr;
} else if (diffBStime2 > limitTime) {
if (isGoodBS(bs1)) {
return bs1;
} else {
edm::LogInfo("OnlineBeamSpotESProducer")
<< "Defaulting to fake because the legacy Beam Spot is not suitable and HLT one is too old.";
edm::LogWarning("OnlineBeamSpotESProducer") << "Defaulting to fake (fallback to PCL) because the legacy Beam "
"Spot is not suitable and HLT one is too old.";
return nullptr;
}
} else if (diffBStime1 > limitTime) {
if (isGoodBS(bs2)) {
return bs2;
} else {
edm::LogInfo("OnlineBeamSpotESProducer")
<< "Defaulting to fake because the HLT Beam Spot is not suitable and the legacy one too old.";
edm::LogWarning("OnlineBeamSpotESProducer") << "Defaulting to fake (fallback to PCL) because the HLT Beam Spot "
"is not suitable and the legacy one too old.";
return nullptr;
}
} else {
Expand All @@ -121,8 +122,8 @@ const BeamSpotOnlineObjects* OnlineBeamSpotESProducer::compareBS(const BeamSpotO
} else if (bs2->sigmaZ() >= bs1->sigmaZ() && isGoodBS(bs2)) {
return bs2;
} else {
edm::LogInfo("OnlineBeamSpotESProducer")
<< "Defaulting to fake because despite both payloads are young enough, none has passed the fit sanity checks";
edm::LogWarning("OnlineBeamSpotESProducer") << "Defaulting to fake (fallback to PCL) because despite both "
"payloads are young enough, none has passed the fit sanity checks";
return nullptr;
}
}
Expand Down Expand Up @@ -161,7 +162,8 @@ std::shared_ptr<const BeamSpotObjects> OnlineBeamSpotESProducer::produce(const B
auto legacyRec = iRecord.tryToGetRecord<BeamSpotOnlineLegacyObjectsRcd>();
auto hltRec = iRecord.tryToGetRecord<BeamSpotOnlineHLTObjectsRcd>();
if (not legacyRec and not hltRec) {
edm::LogInfo("OnlineBeamSpotESProducer") << "None of the Beam Spots in ES are available! \n returning a fake one.";
edm::LogWarning("OnlineBeamSpotESProducer")
<< "None of the Beam Spots in ES are available! \n returning a fake one (fallback to PCL).";
return std::shared_ptr<const BeamSpotObjects>(&fakeBS_, edm::do_nothing_deleter());
}

Expand All @@ -177,8 +179,8 @@ std::shared_ptr<const BeamSpotObjects> OnlineBeamSpotESProducer::produce(const B
return std::shared_ptr<const BeamSpotObjects>(best, edm::do_nothing_deleter());
} else {
return std::shared_ptr<const BeamSpotObjects>(&fakeBS_, edm::do_nothing_deleter());
edm::LogInfo("OnlineBeamSpotESProducer")
<< "None of the Online BeamSpots in the ES is suitable, \n returning a fake one. ";
edm::LogWarning("OnlineBeamSpotESProducer")
<< "None of the Online BeamSpots in the ES is suitable, \n returning a fake one(fallback to PCL).";
}
};

Expand Down

0 comments on commit 14dfdc9

Please sign in to comment.