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

[Clang tidy] Apply checks for fastsim #30796

Merged
merged 2 commits into from
Jul 25, 2020
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,25 @@ Description: [one line class summary]
//
//

#include <memory>

#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/Math/interface/Point3D.h"
#include "DataFormats/Math/interface/Vector.h"
#include "DataFormats/Math/interface/Vector3D.h"
#include "DataFormats/Math/interface/Point3D.h"
#include "FastSimDataFormats/CTPPSFastSim/interface/CTPPSFastRecHit.h"
#include "FastSimDataFormats/CTPPSFastSim/interface/CTPPSFastRecHitContainer.h"
#include "FastSimDataFormats/CTPPSFastSim/interface/CTPPSFastTrack.h"
#include "FastSimDataFormats/CTPPSFastSim/interface/CTPPSFastTrackContainer.h"
#include "FastSimulation/CTPPSFastGeometry/interface/CTPPSToFDetector.h"
#include "FastSimulation/CTPPSFastGeometry/interface/CTPPSTrkDetector.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/ParameterSet/interface/FileInPath.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/StreamID.h"
#include "FastSimDataFormats/CTPPSFastSim/interface/CTPPSFastRecHit.h"
#include "FastSimDataFormats/CTPPSFastSim/interface/CTPPSFastRecHitContainer.h"
#include "FastSimDataFormats/CTPPSFastSim/interface/CTPPSFastTrack.h"
#include "FastSimDataFormats/CTPPSFastSim/interface/CTPPSFastTrackContainer.h"
#include "FastSimulation/CTPPSFastGeometry/interface/CTPPSToFDetector.h"
#include "FastSimulation/CTPPSFastGeometry/interface/CTPPSTrkDetector.h"
#include "Utilities/PPS/interface/PPSUnitConversion.h"
#include "Utilities/PPS/interface/PPSUtilities.h"

Expand Down Expand Up @@ -185,25 +187,26 @@ CTPPSFastTrackingProducer::CTPPSFastTrackingProducer(const edm::ParameterSet& iC
// Take care: the z inside the station is in meters
//
//Tracker Detector Description
det1F = std::unique_ptr<CTPPSTrkDetector>(
new CTPPSTrkDetector(fTrackerWidth, fTrackerHeight, fTrackerInsertion * fBeamXRMS_Trk1 + fTrk1XOffset));
det2F = std::unique_ptr<CTPPSTrkDetector>(
new CTPPSTrkDetector(fTrackerWidth, fTrackerHeight, fTrackerInsertion * fBeamXRMS_Trk2 + fTrk2XOffset));
det1B = std::unique_ptr<CTPPSTrkDetector>(
new CTPPSTrkDetector(fTrackerWidth, fTrackerHeight, fTrackerInsertion * fBeamXRMS_Trk1 + fTrk1XOffset));
det2B = std::unique_ptr<CTPPSTrkDetector>(
new CTPPSTrkDetector(fTrackerWidth, fTrackerHeight, fTrackerInsertion * fBeamXRMS_Trk2 + fTrk2XOffset));
det1F = std::make_unique<CTPPSTrkDetector>(
fTrackerWidth, fTrackerHeight, fTrackerInsertion * fBeamXRMS_Trk1 + fTrk1XOffset);
det2F = std::make_unique<CTPPSTrkDetector>(
fTrackerWidth, fTrackerHeight, fTrackerInsertion * fBeamXRMS_Trk2 + fTrk2XOffset);
det1B = std::make_unique<CTPPSTrkDetector>(
fTrackerWidth, fTrackerHeight, fTrackerInsertion * fBeamXRMS_Trk1 + fTrk1XOffset);
det2B = std::make_unique<CTPPSTrkDetector>(
fTrackerWidth, fTrackerHeight, fTrackerInsertion * fBeamXRMS_Trk2 + fTrk2XOffset);

//Timing Detector Description
std::vector<double> vToFCellWidth;
vToFCellWidth.reserve(8);
for (int i = 0; i < 8; i++) {
vToFCellWidth.push_back(fToFCellWidth[i]);
}
double pos_tof = fToFInsertion * fBeamXRMS_ToF + fToFXOffset;
detToF_F = std::unique_ptr<CTPPSToFDetector>(new CTPPSToFDetector(
fToFNCellX, fToFNCellY, vToFCellWidth, fToFCellHeight, fToFPitchX, fToFPitchY, pos_tof, fTimeSigma));
detToF_B = std::unique_ptr<CTPPSToFDetector>(new CTPPSToFDetector(
fToFNCellX, fToFNCellY, vToFCellWidth, fToFCellHeight, fToFPitchX, fToFPitchY, pos_tof, fTimeSigma));
detToF_F = std::make_unique<CTPPSToFDetector>(
fToFNCellX, fToFNCellY, vToFCellWidth, fToFCellHeight, fToFPitchX, fToFPitchY, pos_tof, fTimeSigma);
detToF_B = std::make_unique<CTPPSToFDetector>(
fToFNCellX, fToFNCellY, vToFCellWidth, fToFCellHeight, fToFPitchX, fToFPitchY, pos_tof, fTimeSigma);
//
}

Expand Down Expand Up @@ -285,8 +288,8 @@ void CTPPSFastTrackingProducer::ReadRecHits(edm::Handle<CTPPSFastRecHitContainer

} //LOOP TRK
//creating Stations
TrkStation_F = std::unique_ptr<CTPPSTrkStation>(new std::pair<CTPPSTrkDetector, CTPPSTrkDetector>(*det1F, *det2F));
TrkStation_B = std::unique_ptr<CTPPSTrkStation>(new std::pair<CTPPSTrkDetector, CTPPSTrkDetector>(*det1B, *det2B));
TrkStation_F = std::make_unique<CTPPSTrkStation>(*det1F, *det2F);
TrkStation_B = std::make_unique<CTPPSTrkStation>(*det1B, *det2B);
} // end function

void CTPPSFastTrackingProducer::Reconstruction() {
Expand Down Expand Up @@ -439,6 +442,7 @@ void CTPPSFastTrackingProducer::FastReco(int Direction, H_RecRPObject* station)
double pos_tof = fToFInsertion * fBeamXRMS_ToF + fToFXOffset;
int cellId = 0;
std::vector<double> vToFCellWidth;
vToFCellWidth.reserve(8);
for (int i = 0; i < 8; i++) {
vToFCellWidth.push_back(fToFCellWidth[i]);
}
Expand Down Expand Up @@ -512,14 +516,14 @@ bool CTPPSFastTrackingProducer::SetBeamLine() {
edm::FileInPath b2(beam2filename.c_str());
if (lengthctpps <= 0)
return false;
m_beamlineCTPPS1 = std::unique_ptr<H_BeamLine>(new H_BeamLine(-1, lengthctpps + 0.1)); // (direction, length)
m_beamlineCTPPS1 = std::make_unique<H_BeamLine>(-1, lengthctpps + 0.1); // (direction, length)
m_beamlineCTPPS1->fill(b2.fullPath(), 1, "IP5");
m_beamlineCTPPS2 = std::unique_ptr<H_BeamLine>(new H_BeamLine(1, lengthctpps + 0.1)); //
m_beamlineCTPPS2 = std::make_unique<H_BeamLine>(1, lengthctpps + 0.1); //
m_beamlineCTPPS2->fill(b1.fullPath(), 1, "IP5");
m_beamlineCTPPS1->offsetElements(120, 0.097);
m_beamlineCTPPS2->offsetElements(120, -0.097);
pps_stationF = std::unique_ptr<H_RecRPObject>(new H_RecRPObject(fz_tracker1, fz_tracker2, *m_beamlineCTPPS1));
pps_stationB = std::unique_ptr<H_RecRPObject>(new H_RecRPObject(fz_tracker1, fz_tracker2, *m_beamlineCTPPS2));
pps_stationF = std::make_unique<H_RecRPObject>(fz_tracker1, fz_tracker2, *m_beamlineCTPPS1);
pps_stationB = std::make_unique<H_RecRPObject>(fz_tracker1, fz_tracker2, *m_beamlineCTPPS2);
return true;
}
//define this as a plug-in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ void CTPPSRecHitProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe
double pos_tof = fToFInsertion * fBeamXRMS_ToF + fToFXOffset;

std::vector<double> vToFCellWidth;
vToFCellWidth.reserve(8);
for (int i = 0; i < 8; i++) {
vToFCellWidth.push_back(fToFCellWidth[i]);
}
Expand Down
8 changes: 5 additions & 3 deletions FastSimulation/Calorimetry/src/CalorimetryManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@
#include "FastSimulation/ShowerDevelopment/interface/FastHFShowerLibrary.h"

// STL headers
#include <vector>
#include <memory>

#include <iostream>
#include <vector>

//CMSSW headers
#include "DataFormats/DetId/interface/DetId.h"
Expand Down Expand Up @@ -111,8 +113,8 @@ CalorimetryManager::CalorimetryManager(FSimEvent* aSimEvent,
theMuonHcalEffects = new MaterialEffects(fastMuHCAL);

if (fastCalo.exists("ECALResponseScaling")) {
ecalCorrection = std::unique_ptr<KKCorrectionFactors>(
new KKCorrectionFactors(fastCalo.getParameter<edm::ParameterSet>("ECALResponseScaling")));
ecalCorrection =
std::make_unique<KKCorrectionFactors>(fastCalo.getParameter<edm::ParameterSet>("ECALResponseScaling"));
}
}

Expand Down
12 changes: 7 additions & 5 deletions FastSimulation/Muons/plugins/FastTSGFromPropagation.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "FastSimulation/Muons/plugins/FastTSGFromPropagation.h"

#include <memory>

/** \class FastTSGFromPropagation
*
* Emulate TSGFromPropagation in RecoMuon
Expand Down Expand Up @@ -316,7 +318,7 @@ void FastTSGFromPropagation::init(const MuonServiceProxy* service) {
theResetMethod = "discrete";
}

theEstimator.reset(new Chi2MeasurementEstimator(theMaxChi2));
theEstimator = std::make_unique<Chi2MeasurementEstimator>(theMaxChi2);

theCacheId_MT = 0;

Expand All @@ -332,21 +334,21 @@ void FastTSGFromPropagation::init(const MuonServiceProxy* service) {

theSelectStateFlag = theConfig.getParameter<bool>("SelectState");

theUpdator.reset(new KFUpdator());
theUpdator = std::make_unique<KFUpdator>();

theSigmaZ = theConfig.getParameter<double>("SigmaZ");

edm::ParameterSet errorMatrixPset = theConfig.getParameter<edm::ParameterSet>("errorMatrixPset");
if (theResetMethod == "matrix" && !errorMatrixPset.empty()) {
theAdjustAtIp = errorMatrixPset.getParameter<bool>("atIP");
theErrorMatrixAdjuster.reset(new MuonErrorMatrix(errorMatrixPset));
theErrorMatrixAdjuster = std::make_unique<MuonErrorMatrix>(errorMatrixPset);
} else {
theAdjustAtIp = false;
theErrorMatrixAdjuster.reset();
}

theService->eventSetup().get<TrackerRecoGeometryRecord>().get(theTracker);
theNavigation.reset(new DirectTrackerNavigation(theTracker));
theNavigation = std::make_unique<DirectTrackerNavigation>(theTracker);

edm::ESHandle<TrackerGeometry> geometry;
theService->eventSetup().get<TrackerDigiGeometryRecord>().get(geometry);
Expand Down Expand Up @@ -386,7 +388,7 @@ void FastTSGFromPropagation::setEvent(const edm::Event& iEvent) {
}

if (trackerGeomChanged && theTracker.product()) {
theNavigation.reset(new DirectTrackerNavigation(theTracker));
theNavigation = std::make_unique<DirectTrackerNavigation>(theTracker);
}
}

Expand Down
7 changes: 5 additions & 2 deletions FastSimulation/ParticleDecay/src/PythiaDecays.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
#include "FWCore/ServiceRegistry/interface/RandomEngineSentry.h"

#include <Pythia8/Pythia.h>

#include <memory>

#include "Pythia8Plugins/HepMC2.h"

PythiaDecays::PythiaDecays() {
// inspired by method Pythia8Hadronizer::residualDecay() in GeneratorInterface/Pythia8Interface/src/Py8GunBase.cc
decayer.reset(new Pythia8::Pythia);
p8RndmEngine.reset(new gen::P8RndmEngine);
decayer = std::make_unique<Pythia8::Pythia>();
p8RndmEngine = std::make_unique<gen::P8RndmEngine>();
decayer->setRndmEnginePtr(p8RndmEngine.get());
decayer->settings.flag("ProcessLevel:all", false);
decayer->settings.flag("PartonLevel:FSRinResonances", false);
Expand Down
8 changes: 5 additions & 3 deletions FastSimulation/ShowerDevelopment/src/FastHFShowerLibrary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,11 @@
#include "G4ParticleTypes.hh"

// STL headers
#include <vector>
#include <memory>

#include <iostream>
#include <mutex>
#include <vector>

//#define DebugLog

Expand All @@ -56,8 +58,8 @@ void const FastHFShowerLibrary::initHFShowerLibrary(const edm::EventSetup& iSetu
const HcalSimulationConstants* hsps = hdsc.product();

std::string name = "HcalHits";
numberingFromDDD.reset(new HcalNumberingFromDDD(hcalConstants));
hfshower.reset(new HFShowerLibrary(name, hcalConstants, hsps->hcalsimpar(), fast));
numberingFromDDD = std::make_unique<HcalNumberingFromDDD>(hcalConstants);
hfshower = std::make_unique<HFShowerLibrary>(name, hcalConstants, hsps->hcalsimpar(), fast);

//only one thread can be allowed to setup the G4 physics table.
std::call_once(initializeOnce, []() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,12 @@ FastSimProducer::FastSimProducer(const edm::ParameterSet& iConfig)
//---------------

if (simulateCalorimetry) {
myCalorimetry.reset(new CalorimetryManager(nullptr,
iConfig.getParameter<edm::ParameterSet>("Calorimetry"),
iConfig.getParameter<edm::ParameterSet>("MaterialEffectsForMuonsInECAL"),
iConfig.getParameter<edm::ParameterSet>("MaterialEffectsForMuonsInHCAL"),
iConfig.getParameter<edm::ParameterSet>("GFlash")));
myCalorimetry =
std::make_unique<CalorimetryManager>(nullptr,
iConfig.getParameter<edm::ParameterSet>("Calorimetry"),
iConfig.getParameter<edm::ParameterSet>("MaterialEffectsForMuonsInECAL"),
iConfig.getParameter<edm::ParameterSet>("MaterialEffectsForMuonsInHCAL"),
iConfig.getParameter<edm::ParameterSet>("GFlash"));
}

//----------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <vector>
#include <memory>

#include <memory>
#include <vector>

// framework
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/ProducesCollector.h"
Expand Down Expand Up @@ -119,7 +121,7 @@ void fastsim::TrackerSimHitProducer::registerProducts(edm::ProducesCollector pro

void fastsim::TrackerSimHitProducer::storeProducts(edm::Event& iEvent) {
iEvent.put(std::move(simHitContainer_), "TrackerHits");
simHitContainer_.reset(new edm::PSimHitContainer);
simHitContainer_ = std::make_unique<edm::PSimHitContainer>();
}

void fastsim::TrackerSimHitProducer::interact(Particle& particle,
Expand Down Expand Up @@ -316,18 +318,17 @@ std::pair<double, std::unique_ptr<PSimHit>> fastsim::TrackerSimHitProducer::crea
// Position of the hit in global coordinates
GlobalPoint hitPos(detector.surface().toGlobal(localPosition));

return std::pair<double, std::unique_ptr<PSimHit>>(
(hitPos - refPos).mag(),
std::unique_ptr<PSimHit>(new PSimHit(entry,
exit,
localMomentum.mag(),
tof,
eLoss,
pdgId,
detector.geographicalId().rawId(),
simTrackId,
localMomentum.theta(),
localMomentum.phi())));
return std::pair<double, std::unique_ptr<PSimHit>>((hitPos - refPos).mag(),
std::make_unique<PSimHit>(entry,
exit,
localMomentum.mag(),
tof,
eLoss,
pdgId,
detector.geographicalId().rawId(),
simTrackId,
localMomentum.theta(),
localMomentum.phi()));
}

DEFINE_EDM_PLUGIN(fastsim::InteractionModelFactory, fastsim::TrackerSimHitProducer, "fastsim::TrackerSimHitProducer");
3 changes: 2 additions & 1 deletion FastSimulation/SimplifiedGeometryPropagator/src/Geometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include <iostream>
#include <map>
#include <memory>

using namespace fastsim;

Expand Down Expand Up @@ -70,7 +71,7 @@ void Geometry::update(const edm::EventSetup& iSetup,
if (iSetup.get<IdealMagneticFieldRecord>().cacheIdentifier() != cacheIdentifierIdealMagneticField_) {
if (useFixedMagneticFieldZ_) // use constant magnetic field
{
ownedMagneticField_.reset(new UniformMagneticField(fixedMagneticFieldZ_));
ownedMagneticField_ = std::make_unique<UniformMagneticField>(fixedMagneticFieldZ_);
magneticField_ = ownedMagneticField_.get();
} else // get magnetic field from EventSetup
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <TH1F.h>
#include <cctype>
#include <memory>

fastsim::SimplifiedGeometryFactory::SimplifiedGeometryFactory(
const GeometricSearchTracker *geometricSearchTracker,
Expand Down Expand Up @@ -115,9 +116,9 @@ std::unique_ptr<fastsim::SimplifiedGeometry> fastsim::SimplifiedGeometryFactory:

std::unique_ptr<fastsim::SimplifiedGeometry> layer;
if (isForward) {
layer.reset(new fastsim::ForwardSimplifiedGeometry(position));
layer = std::make_unique<fastsim::ForwardSimplifiedGeometry>(position);
} else {
layer.reset(new fastsim::BarrelSimplifiedGeometry(position));
layer = std::make_unique<fastsim::BarrelSimplifiedGeometry>(position);
}
layer->detLayer_ = detLayer;

Expand Down Expand Up @@ -147,7 +148,7 @@ std::unique_ptr<fastsim::SimplifiedGeometry> fastsim::SimplifiedGeometryFactory:
<< "layer thickness and limits not configured properly! error in:" << cfgString;
}
// create the histogram
layer->thicknessHist_.reset(new TH1F("h", "h", limits.size() - 1, &limits[0]));
layer->thicknessHist_ = std::make_unique<TH1F>("h", "h", limits.size() - 1, &limits[0]);
layer->thicknessHist_->SetDirectory(nullptr);
for (unsigned i = 1; i < limits.size(); ++i) {
layer->thicknessHist_->SetBinContent(i, thickness[i - 1]);
Expand All @@ -164,8 +165,8 @@ std::unique_ptr<fastsim::SimplifiedGeometry> fastsim::SimplifiedGeometryFactory:
// magnetic field
// -----------------------------

layer->magneticFieldHist_.reset(
new TH1F("h", "h", 100, 0., isForward ? magneticFieldHistMaxR_ : magneticFieldHistMaxZ_));
layer->magneticFieldHist_ =
std::make_unique<TH1F>("h", "h", 100, 0., isForward ? magneticFieldHistMaxR_ : magneticFieldHistMaxZ_);
layer->magneticFieldHist_->SetDirectory(nullptr);
for (int i = 1; i <= 101; i++) {
GlobalPoint point = isForward ? GlobalPoint(layer->magneticFieldHist_->GetXaxis()->GetBinCenter(i), 0., position)
Expand Down
13 changes: 8 additions & 5 deletions FastSimulation/Tracking/plugins/RecoTrackAccumulator.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#include "FastSimulation/Tracking/plugins/RecoTrackAccumulator.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include <memory>

#include "DataFormats/Common/interface/ValueMap.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "FWCore/Framework/interface/ConsumesCollector.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

RecoTrackAccumulator::RecoTrackAccumulator(const edm::ParameterSet& conf,
edm::ProducesCollector producesCollector,
Expand All @@ -22,9 +25,9 @@ RecoTrackAccumulator::RecoTrackAccumulator(const edm::ParameterSet& conf,
RecoTrackAccumulator::~RecoTrackAccumulator() {}

void RecoTrackAccumulator::initializeEvent(edm::Event const& e, edm::EventSetup const& iSetup) {
newTracks_ = std::unique_ptr<reco::TrackCollection>(new reco::TrackCollection);
newHits_ = std::unique_ptr<TrackingRecHitCollection>(new TrackingRecHitCollection);
newTrackExtras_ = std::unique_ptr<reco::TrackExtraCollection>(new reco::TrackExtraCollection);
newTracks_ = std::make_unique<reco::TrackCollection>();
newHits_ = std::make_unique<TrackingRecHitCollection>();
newTrackExtras_ = std::make_unique<reco::TrackExtraCollection>();

// this is needed to get the ProductId of the TrackExtra and TrackingRecHit and Track collections
rNewTracks = const_cast<edm::Event&>(e).getRefBeforePut<reco::TrackCollection>(outputLabel);
Expand Down
2 changes: 1 addition & 1 deletion FastSimulation/Tracking/plugins/TrajectorySeedProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ TrajectorySeedProducer::TrajectorySeedProducer(const edm::ParameterSet& conf) {
std::string::size_type pos = 0;
unsigned int nHitsPerSeed = 0;
while (pos != std::string::npos) {
pos = line.find("+");
pos = line.find('+');
std::string layer = line.substr(0, pos);
TrackingLayer layerSpec = TrackingLayer::createFromString(layer);
trackingLayerList.push_back(layerSpec);
Expand Down