Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[13_0_X] Adding a check on the BS transverse widths in OnlineBeamSpotESProducer #40766

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions RecoVertex/BeamSpotProducer/plugins/OnlineBeamSpotESProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class OnlineBeamSpotESProducer : public edm::ESProducer {
private:
const BeamSpotOnlineObjects* compareBS(const BeamSpotOnlineObjects* bs1, const BeamSpotOnlineObjects* bs2);
const BeamSpotOnlineObjects* checkSingleBS(const BeamSpotOnlineObjects* bs1);
bool isGoodBS(const BeamSpotOnlineObjects* bs1) const;

edm::ESGetToken<BeamSpotObjects, BeamSpotTransientObjectsRcd> const bsToken_;
edm::ESGetToken<BeamSpotOnlineObjects, BeamSpotOnlineHLTObjectsRcd> bsHLTToken_;
Expand All @@ -38,12 +39,14 @@ class OnlineBeamSpotESProducer : public edm::ESProducer {
BeamSpotObjects fakeBS_;
const int timeThreshold_;
const double sigmaZThreshold_;
const double sigmaXYThreshold_;
};

OnlineBeamSpotESProducer::OnlineBeamSpotESProducer(const edm::ParameterSet& p)
// get parameters
: timeThreshold_(p.getParameter<int>("timeThreshold")),
sigmaZThreshold_(p.getParameter<double>("sigmaZThreshold")) {
sigmaZThreshold_(p.getParameter<double>("sigmaZThreshold")),
sigmaXYThreshold_(p.getParameter<double>("sigmaXYThreshold") * 1E-4) {
auto cc = setWhatProduced(this);

fakeBS_.setBeamWidthX(0.1);
Expand All @@ -60,6 +63,7 @@ void OnlineBeamSpotESProducer::fillDescriptions(edm::ConfigurationDescriptions&
edm::ParameterSetDescription dsc;
dsc.add<int>("timeThreshold", 48)->setComment("hours");
dsc.add<double>("sigmaZThreshold", 2.)->setComment("cm");
dsc.add<double>("sigmaXYThreshold", 4.)->setComment("um");
desc.addWithDefaultLabel(dsc);
}

Expand All @@ -80,37 +84,37 @@ const BeamSpotOnlineObjects* OnlineBeamSpotESProducer::compareBS(const BeamSpotO

// Logic to choose between the two BeamSpots:
// 1. If both BS are older than limitTime retun fake BS
// 2. If only one BS is newer than limitTime return it only if it has
// sigmaZ larger than sigmaZthreshold_ and the fit converged (BeamType 2)
// 3. If both are newer than the limit threshold return
// the BS that converged and has larger sigmaZ
// 2. If only one BS is newer than limitTime return it only if
// it passes isGoodBS (checks on sigmaZ, sigmaXY and fit convergence)
// 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.";
return nullptr;
} else if (diffBStime2 > limitTime) {
if (bs1->sigmaZ() > sigmaZThreshold_ && bs1->beamType() == 2) {
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.";
return nullptr;
}
} else if (diffBStime1 > limitTime) {
if (bs2->sigmaZ() > sigmaZThreshold_ && bs2->beamType() == 2) {
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.";
return nullptr;
}
} else {
if (bs1->sigmaZ() > bs2->sigmaZ() && bs1->beamType() == 2) {
if (bs1->sigmaZ() > bs2->sigmaZ() && isGoodBS(bs1)) {
return bs1;
} else if (bs2->sigmaZ() >= bs1->sigmaZ() && bs2->beamType() == 2) {
} 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 the right BeamType.";
<< "Defaulting to fake because despite both payloads are young enough, none has passed the fit sanity checks";
return nullptr;
}
}
Expand All @@ -129,13 +133,22 @@ const BeamSpotOnlineObjects* OnlineBeamSpotESProducer::checkSingleBS(const BeamS
auto limitTime = std::chrono::microseconds((std::chrono::hours)timeThreshold_).count();

// Check that the BS is within the timeThreshold, converges and passes the sigmaZthreshold
if (diffBStime1 < limitTime && bs1->sigmaZ() > sigmaZThreshold_ && bs1->beamType() == 2) {
if (diffBStime1 < limitTime && isGoodBS(bs1)) {
return bs1;
} else {
return nullptr;
}
}

// This method is used to check the quality of the beamspot fit
bool OnlineBeamSpotESProducer::isGoodBS(const BeamSpotOnlineObjects* bs1) const {
if (bs1->sigmaZ() > sigmaZThreshold_ && bs1->beamType() == reco::BeamSpot::Tracker &&
bs1->beamWidthX() > sigmaXYThreshold_ && bs1->beamWidthY() > sigmaXYThreshold_)
return true;
else
return false;
}

std::shared_ptr<const BeamSpotObjects> OnlineBeamSpotESProducer::produce(const BeamSpotTransientObjectsRcd& iRecord) {
auto legacyRec = iRecord.tryToGetRecord<BeamSpotOnlineLegacyObjectsRcd>();
auto hltRec = iRecord.tryToGetRecord<BeamSpotOnlineHLTObjectsRcd>();
Expand Down