-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34295 from MilanoBicocca-pix/BSOnlineProducer_12_X
modified the various (ES)producers for express stream and HLT
- Loading branch information
Showing
5 changed files
with
160 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
author: Francisco Yumiceva, Fermilab ([email protected]) | ||
modified by: Simone Gennai, INFN MIB | ||
________________________________________________________________**/ | ||
|
@@ -15,6 +16,9 @@ ________________________________________________________________**/ | |
#include "DataFormats/Scalers/interface/BeamSpotOnline.h" | ||
#include "CondFormats/BeamSpotObjects/interface/BeamSpotObjects.h" | ||
#include "CondFormats/DataRecord/interface/BeamSpotObjectsRcd.h" | ||
#include "CondFormats/DataRecord/interface/BeamSpotTransientObjectsRcd.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" | ||
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" | ||
#include "FWCore/Framework/interface/ESHandle.h" | ||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/Framework/interface/EventSetup.h" | ||
|
@@ -31,13 +35,18 @@ class BeamSpotOnlineProducer : public edm::stream::EDProducer<> { | |
/// produce a beam spot class | ||
void produce(edm::Event& iEvent, const edm::EventSetup& iSetup) override; | ||
|
||
///Fill descriptor | ||
static void fillDescriptions(edm::ConfigurationDescriptions& iDesc); | ||
|
||
private: | ||
const bool changeFrame_; | ||
const double theMaxZ, theSetSigmaZ; | ||
double theMaxR2; | ||
const bool useTransientRecord_; | ||
const edm::EDGetTokenT<BeamSpotOnlineCollection> scalerToken_; | ||
const edm::EDGetTokenT<L1GlobalTriggerEvmReadoutRecord> l1GtEvmReadoutRecordToken_; | ||
const edm::ESGetToken<BeamSpotObjects, BeamSpotObjectsRcd> beamToken_; | ||
const edm::ESGetToken<BeamSpotObjects, BeamSpotTransientObjectsRcd> beamTransientToken_; | ||
|
||
const unsigned int theBeamShoutMode; | ||
}; | ||
|
@@ -48,17 +57,35 @@ BeamSpotOnlineProducer::BeamSpotOnlineProducer(const ParameterSet& iconf) | |
: changeFrame_(iconf.getParameter<bool>("changeToCMSCoordinates")), | ||
theMaxZ(iconf.getParameter<double>("maxZ")), | ||
theSetSigmaZ(iconf.getParameter<double>("setSigmaZ")), | ||
useTransientRecord_(iconf.getParameter<bool>("useTransientRecord")), | ||
scalerToken_(consumes<BeamSpotOnlineCollection>(iconf.getParameter<InputTag>("src"))), | ||
l1GtEvmReadoutRecordToken_(consumes<L1GlobalTriggerEvmReadoutRecord>(iconf.getParameter<InputTag>("gtEvmLabel"))), | ||
beamToken_(esConsumes<BeamSpotObjects, BeamSpotObjectsRcd>()), | ||
beamTransientToken_(esConsumes<BeamSpotObjects, BeamSpotTransientObjectsRcd>()), | ||
theBeamShoutMode(iconf.getUntrackedParameter<unsigned int>("beamMode", 11)) { | ||
theMaxR2 = iconf.getParameter<double>("maxRadius"); | ||
theMaxR2 *= theMaxR2; | ||
|
||
produces<reco::BeamSpot>(); | ||
} | ||
|
||
void BeamSpotOnlineProducer::fillDescriptions(edm::ConfigurationDescriptions& iDesc) { | ||
edm::ParameterSetDescription ps; | ||
ps.add<bool>("changeToCMSCoordinates", false); | ||
ps.add<double>("maxZ", 40.); | ||
ps.add<double>("setSigmaZ", -1.); | ||
ps.addUntracked<unsigned int>("beamMode", 11); | ||
ps.add<InputTag>("src", InputTag("hltScalersRawToDigi")); | ||
ps.add<InputTag>("gtEvmLabel", InputTag("")); | ||
ps.add<double>("maxRadius", 2.0); | ||
ps.add<bool>("useTransientRecord", false); | ||
iDesc.addWithDefaultLabel(ps); | ||
} | ||
|
||
void BeamSpotOnlineProducer::produce(Event& iEvent, const EventSetup& iSetup) { | ||
// product is a reco::BeamSpot object | ||
auto result = std::make_unique<reco::BeamSpot>(); | ||
reco::BeamSpot aSpot; | ||
//shout MODE only in stable beam | ||
bool shoutMODE = false; | ||
edm::Handle<L1GlobalTriggerEvmReadoutRecord> gtEvmReadoutRecord; | ||
|
@@ -68,74 +95,107 @@ void BeamSpotOnlineProducer::produce(Event& iEvent, const EventSetup& iSetup) { | |
} else { | ||
shoutMODE = true; | ||
} | ||
|
||
// get scalar collection | ||
Handle<BeamSpotOnlineCollection> handleScaler; | ||
iEvent.getByToken(scalerToken_, handleScaler); | ||
|
||
// beam spot scalar object | ||
BeamSpotOnline spotOnline; | ||
|
||
// product is a reco::BeamSpot object | ||
auto result = std::make_unique<reco::BeamSpot>(); | ||
|
||
reco::BeamSpot aSpot; | ||
|
||
bool fallBackToDB = false; | ||
if (!handleScaler->empty()) { | ||
// get one element | ||
spotOnline = *(handleScaler->begin()); | ||
|
||
// 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 * spotOnline.x(), spotOnline.y(), f * spotOnline.z()); | ||
|
||
reco::BeamSpot::CovarianceMatrix matrix; | ||
matrix(0, 0) = spotOnline.err_x() * spotOnline.err_x(); | ||
matrix(1, 1) = spotOnline.err_y() * spotOnline.err_y(); | ||
matrix(2, 2) = spotOnline.err_z() * spotOnline.err_z(); | ||
matrix(3, 3) = spotOnline.err_sigma_z() * spotOnline.err_sigma_z(); | ||
|
||
double sigmaZ = spotOnline.sigma_z(); | ||
if (theSetSigmaZ > 0) | ||
sigmaZ = theSetSigmaZ; | ||
|
||
aSpot = reco::BeamSpot(apoint, sigmaZ, spotOnline.dxdz(), f * spotOnline.dydz(), spotOnline.width_x(), matrix); | ||
|
||
aSpot.setBeamWidthY(spotOnline.width_y()); | ||
aSpot.setEmittanceX(0.); | ||
aSpot.setEmittanceY(0.); | ||
aSpot.setbetaStar(0.); | ||
aSpot.setType(reco::BeamSpot::LHC); // flag value from scalars | ||
|
||
// check if we have a valid beam spot fit result from online DQM | ||
if (spotOnline.x() == 0 && spotOnline.y() == 0 && spotOnline.z() == 0 && spotOnline.width_x() == 0 && | ||
spotOnline.width_y() == 0) { | ||
if (useTransientRecord_) { | ||
auto const& spotDB = iSetup.getData(beamTransientToken_); | ||
if (spotDB.GetBeamType() != 2) { | ||
if (shoutMODE) { | ||
edm::LogWarning("BeamSpotFromDB") | ||
<< "Online Beam Spot producer falls back to DB value because the scaler values are zero "; | ||
<< "Online Beam Spot producer falls back to DB value because the ESProducer returned a fake beamspot "; | ||
} | ||
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.GetX(), f * spotDB.GetY(), f * spotDB.GetZ()); | ||
|
||
reco::BeamSpot::CovarianceMatrix matrix; | ||
for (int i = 0; i < 7; ++i) { | ||
for (int j = 0; j < 7; ++j) { | ||
matrix(i, j) = spotDB.GetCovariance(i, j); | ||
} | ||
} | ||
double sigmaZ = spotDB.GetSigmaZ(); | ||
if (theSetSigmaZ > 0) | ||
sigmaZ = theSetSigmaZ; | ||
|
||
// this assume beam width same in x and y | ||
aSpot = reco::BeamSpot(apoint, sigmaZ, spotDB.Getdxdz(), spotDB.Getdydz(), spotDB.GetBeamWidthX(), matrix); | ||
aSpot.setBeamWidthY(spotDB.GetBeamWidthY()); | ||
aSpot.setEmittanceX(spotDB.GetEmittanceX()); | ||
aSpot.setEmittanceY(spotDB.GetEmittanceY()); | ||
aSpot.setbetaStar(spotDB.GetBetaStar()); | ||
aSpot.setType(reco::BeamSpot::Tracker); | ||
} | ||
double r2 = spotOnline.x() * spotOnline.x() + spotOnline.y() * spotOnline.y(); | ||
if (fabs(spotOnline.z()) >= theMaxZ || r2 >= theMaxR2) { | ||
if (shoutMODE) { | ||
edm::LogError("BeamSpotFromDB") | ||
<< "Online Beam Spot producer falls back to DB value because the scaler values are too big to be true :" | ||
<< spotOnline.x() << " " << spotOnline.y() << " " << spotOnline.z(); | ||
} else { | ||
// get scalar collection | ||
Handle<BeamSpotOnlineCollection> handleScaler; | ||
iEvent.getByToken(scalerToken_, handleScaler); | ||
|
||
// beam spot scalar object | ||
BeamSpotOnline spotOnline; | ||
|
||
// product is a reco::BeamSpot object | ||
auto result = std::make_unique<reco::BeamSpot>(); | ||
|
||
if (!handleScaler->empty()) { | ||
// get one element | ||
spotOnline = *(handleScaler->begin()); | ||
|
||
// 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 * spotOnline.x(), spotOnline.y(), f * spotOnline.z()); | ||
|
||
reco::BeamSpot::CovarianceMatrix matrix; | ||
matrix(0, 0) = spotOnline.err_x() * spotOnline.err_x(); | ||
matrix(1, 1) = spotOnline.err_y() * spotOnline.err_y(); | ||
matrix(2, 2) = spotOnline.err_z() * spotOnline.err_z(); | ||
matrix(3, 3) = spotOnline.err_sigma_z() * spotOnline.err_sigma_z(); | ||
|
||
double sigmaZ = spotOnline.sigma_z(); | ||
if (theSetSigmaZ > 0) | ||
sigmaZ = theSetSigmaZ; | ||
|
||
aSpot = reco::BeamSpot(apoint, sigmaZ, spotOnline.dxdz(), f * spotOnline.dydz(), spotOnline.width_x(), matrix); | ||
|
||
aSpot.setBeamWidthY(spotOnline.width_y()); | ||
aSpot.setEmittanceX(0.); | ||
aSpot.setEmittanceY(0.); | ||
aSpot.setbetaStar(0.); | ||
aSpot.setType(reco::BeamSpot::LHC); // flag value from scalars | ||
|
||
// check if we have a valid beam spot fit result from online DQM | ||
if (spotOnline.x() == 0 && spotOnline.y() == 0 && spotOnline.z() == 0 && spotOnline.width_x() == 0 && | ||
spotOnline.width_y() == 0) { | ||
if (shoutMODE) { | ||
edm::LogWarning("BeamSpotFromDB") | ||
<< "Online Beam Spot producer falls back to DB value because the scaler values are zero "; | ||
} | ||
fallBackToDB = true; | ||
} | ||
double r2 = spotOnline.x() * spotOnline.x() + spotOnline.y() * spotOnline.y(); | ||
if (std::abs(spotOnline.z()) >= theMaxZ || r2 >= theMaxR2) { | ||
if (shoutMODE) { | ||
edm::LogError("BeamSpotFromDB") | ||
<< "Online Beam Spot producer falls back to DB value because the scaler values are too big to be true :" | ||
<< spotOnline.x() << " " << spotOnline.y() << " " << spotOnline.z(); | ||
} | ||
fallBackToDB = true; | ||
} | ||
} else { | ||
//empty online beamspot collection: FED data was empty | ||
//the error should probably have been send at unpacker level | ||
fallBackToDB = true; | ||
} | ||
} else { | ||
//empty online beamspot collection: FED data was empty | ||
//the error should probably have been send at unpacker level | ||
fallBackToDB = true; | ||
} | ||
|
||
if (fallBackToDB) { | ||
edm::ESHandle<BeamSpotObjects> beamhandle = iSetup.getHandle(beamToken_); | ||
const BeamSpotObjects* spotDB = beamhandle.product(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.