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

Added protection from multiple creation of geometry #38640

Merged
merged 4 commits into from
Jul 9, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ class SiPixelLorentzAnglePCLHarvester : public DQMEDHarvester {
const std::string recordName_;
std::unique_ptr<TF1> f1;
float width_;
float theMagField{0.f};
civanch marked this conversation as resolved.
Show resolved Hide resolved

SiPixelLorentzAngleCalibrationHistograms hists;
const SiPixelLorentzAngle* currentLorentzAngle;
Expand Down Expand Up @@ -136,6 +137,10 @@ void SiPixelLorentzAnglePCLHarvester::beginRun(const edm::Run& iRun, const edm::
magField = &iSetup.getData(magneticFieldToken_);
civanch marked this conversation as resolved.
Show resolved Hide resolved
currentLorentzAngle = &iSetup.getData(siPixelLAEsToken_);

// B-field value
// nominalValue returns the magnetic field value in kgauss (1T = 10 kgauss)
theMagField = magField->nominalValue() / 10.;

PixelTopologyMap map = PixelTopologyMap(geom, tTopo);
hists.nlay = geom->numberOfLayers(PixelSubdetector::PixelBarrel);
hists.nModules_.resize(hists.nlay);
Expand Down Expand Up @@ -580,10 +585,6 @@ SiPixelLAHarvest::fitResults SiPixelLorentzAnglePCLHarvester::fitAndStore(
// output results
SiPixelLAHarvest::fitResults res;

// B-field value
// nominalValue returns the magnetic field value in kgauss (1T = 10 kgauss)
float theMagField = magField->nominalValue() / 10.;

double half_width = width_ * 10000 / 2; // pixel half thickness in units of micro meter

f1 = std::make_unique<TF1>("f1", "[0] + [1]*x + [2]*x*x + [3]*x*x*x + [4]*x*x*x*x + [5]*x*x*x*x*x", 5., 280.);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ namespace magneticfield {
edm::ESGetToken<MagFieldConfig, IdealMagneticFieldRecord> chosenConfigToken_;

edm::ESGetToken<FileBlob, MFGeometryFileRcd> mayConsumeBlobToken_;
cms::DDDetector* detector_{nullptr};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cms::DDDetector* detector_{nullptr};
std::unique_ptr<cms::DDDetector> detector_{nullptr};

unique_ptr is preferred over a bare pointer. Then the delete in the destructor is not needed.


const bool debug_;
const bool useMergeFileIfAvailable_;
};
Expand Down Expand Up @@ -187,9 +189,10 @@ std::unique_ptr<MagneticField> DD4hep_VolumeBasedMagneticFieldESProducerFromDB::
"<MaterialSection label=\"materials.xml\"><ElementaryMaterial name=\"materials:Vacuum\" density=\"1e-13*mg/cm3\" "
"symbol=\" \" atomicWeight=\"1*g/mole\" atomicNumber=\"1\"/></MaterialSection>");

auto ddet = make_unique<cms::DDDetector>("cmsMagneticField:MAGF", sblob, true);
if (nullptr == detector_)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This simple test seems like a bad idea. We also need to be sure this is the correct geometry to use as well.

detector_ = new cms::DDDetector("cmsMagneticField:MAGF", sblob, true);
civanch marked this conversation as resolved.
Show resolved Hide resolved

builder.build(ddet.get());
builder.build(detector_);

// Build the VB map. Ownership of the parametrization is transferred to it
return std::make_unique<VolumeBasedMagneticField>(conf->geometryVersion,
Expand Down