Skip to content

Commit

Permalink
Merge pull request #30809 from cms-sw/apply-new-ct-checks-for-visuali…
Browse files Browse the repository at this point in the history
…zation

[Clang tidy] Apply checks for visualization
  • Loading branch information
cmsbuild authored Jul 18, 2020
2 parents 3fb9370 + 962a881 commit 2e69bdc
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 21 deletions.
10 changes: 6 additions & 4 deletions Fireworks/Core/src/CmsShowMain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
//

// system include files
#include <memory>

#include <sstream>
#include <functional>
#include <boost/program_options.hpp>
Expand Down Expand Up @@ -561,8 +563,8 @@ void CmsShowMain::appendData() {

void CmsShowMain::openDataViaURL() {
if (m_searchFiles.get() == nullptr) {
m_searchFiles = std::unique_ptr<CmsShowSearchFiles>(
new CmsShowSearchFiles("", "Open Remote Data Files", guiManager()->getMainFrame(), 500, 400));
m_searchFiles =
std::make_unique<CmsShowSearchFiles>("", "Open Remote Data Files", guiManager()->getMainFrame(), 500, 400);
m_searchFiles->CenterOnParent(kTRUE, TGTransientFrame::kBottomRight);
}
std::string chosenFile = m_searchFiles->chooseFileFromURL();
Expand Down Expand Up @@ -716,7 +718,7 @@ void CmsShowMain::setLoadedAnyInputFileAfterStartup() {
}

void CmsShowMain::setupSocket(unsigned int iSocket) {
m_monitor = std::unique_ptr<TMonitor>(new TMonitor);
m_monitor = std::make_unique<TMonitor>();
TServerSocket* server = new TServerSocket(iSocket, kTRUE);
if (server->GetErrorCode()) {
fwLog(fwlog::kError) << "CmsShowMain::setupSocket, can't create socket on port " << iSocket << "." << std::endl;
Expand Down Expand Up @@ -835,7 +837,7 @@ void CmsShowMain::postFiltering(bool doDraw) {

void CmsShowMain::setLiveMode() {
m_live = true;
m_liveTimer.reset(new SignalTimer());
m_liveTimer = std::make_unique<SignalTimer>();
m_liveTimer->timeout_.connect(std::bind(&CmsShowMain::checkLiveMode, this));

Window_t rootw, childw;
Expand Down
3 changes: 2 additions & 1 deletion Fireworks/Core/src/CmsShowMainBase.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <netdb.h>

#include <functional>
#include <memory>

#include "TGLWidget.h"
#include "TGMsgBox.h"
Expand Down Expand Up @@ -205,7 +206,7 @@ void CmsShowMainBase::setup(FWNavigatorBase *navigator,

m_colorManager->initialize();
m_contextPtr->initEveElements();
m_guiManager.reset(new FWGUIManager(m_contextPtr, m_viewManager.get(), m_navigatorPtr));
m_guiManager = std::make_unique<FWGUIManager>(m_contextPtr, m_viewManager.get(), m_navigatorPtr);

m_eiManager->newItem_.connect(
std::bind(&FWModelChangeManager::newItemSlot, m_changeManager.get(), std::placeholders::_1));
Expand Down
8 changes: 4 additions & 4 deletions Fireworks/Core/src/CmsShowSearchFiles.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void CmsShowSearchFiles::prefixChoosen(Int_t iIndex) {

void CmsShowSearchFiles::fileEntryChanged(const char* iFileName) {
std::string fileName = iFileName;
size_t index = fileName.find_last_of(".");
size_t index = fileName.find_last_of('.');
std::string postfix;
if (index != std::string::npos) {
postfix = fileName.substr(index, std::string::npos);
Expand All @@ -149,7 +149,7 @@ void CmsShowSearchFiles::hyperlinkClicked(const char* iLink) {

m_webFile->addToVisited(iLink);
std::string fileName = iLink;
size_t index = fileName.find_last_of(".");
size_t index = fileName.find_last_of('.');
std::string postfix = fileName.substr(index, std::string::npos);

if (postfix != s_rootPostfix) {
Expand All @@ -175,7 +175,7 @@ void CmsShowSearchFiles::showPrefixes() {
int index = 0;
for (const char* const(*it)[s_columns] = s_prefixes; it != itEnd; ++it, ++index) {
//only add the protocols this version of the code actually can load
std::string prefix = std::string((*it)[0]).substr(0, std::string((*it)[0]).find_first_of(":") + 1);
std::string prefix = std::string((*it)[0]).substr(0, std::string((*it)[0]).find_first_of(':') + 1);
if (s_httpPrefix == prefix || s_filePrefix == prefix ||
(gPluginMgr->FindHandler("TSystem", prefix.c_str()) &&
gPluginMgr->FindHandler("TSystem", prefix.c_str())->CheckPlugin() != -1)) {
Expand Down Expand Up @@ -232,7 +232,7 @@ static std::string readRemote(const char* url) {
void CmsShowSearchFiles::sendToWebBrowser(std::string& fileName) {
// std::cout << "CmsShowSearchFiles::sendToWebBrowser " << fileName << std::endl ;

size_t index = fileName.find_first_of(":");
size_t index = fileName.find_first_of(':');
if (index != std::string::npos) {
++index;
} else {
Expand Down
10 changes: 6 additions & 4 deletions Fireworks/Core/src/FWConfiguration.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
//

// system include files
#include <memory>

#include <stdexcept>
#include <algorithm>
#include <functional>
Expand Down Expand Up @@ -58,7 +60,7 @@ FWConfiguration& FWConfiguration::addKeyValue(const std::string& iKey, const FWC
throw std::runtime_error("adding key/value to configuration containing string values");
}
if (not m_keyValues) {
m_keyValues.reset(new KeyValues(1, std::make_pair(iKey, iConfig)));
m_keyValues = std::make_unique<KeyValues>(1, std::make_pair(iKey, iConfig));
} else {
m_keyValues->push_back(std::make_pair(iKey, iConfig));
}
Expand All @@ -73,9 +75,9 @@ FWConfiguration& FWConfiguration::addKeyValue(const std::string& iKey, FWConfigu
}
if (not m_keyValues) {
if (not iDoSwap) {
m_keyValues.reset(new KeyValues(1, std::make_pair(iKey, iConfig)));
m_keyValues = std::make_unique<KeyValues>(1, std::make_pair(iKey, iConfig));
} else {
m_keyValues.reset(new KeyValues(1, std::make_pair(iKey, FWConfiguration())));
m_keyValues = std::make_unique<KeyValues>(1, std::make_pair(iKey, FWConfiguration()));
m_keyValues->back().second.swap(iConfig);
}
} else {
Expand All @@ -94,7 +96,7 @@ FWConfiguration& FWConfiguration::addValue(const std::string& iValue) {
throw std::runtime_error("adding string value to configuration containing key/value pairs");
}
if (not m_stringValues) {
m_stringValues.reset(new std::vector<std::string>(1, iValue));
m_stringValues = std::make_unique<std::vector<std::string>>(1, iValue);
} else {
m_stringValues->push_back(iValue);
}
Expand Down
2 changes: 1 addition & 1 deletion Fireworks/Core/src/FWExpressionValidator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ namespace fireworks {
namespace {
std::string descriptionFromMember(const edm::FunctionWithDict& iMember) {
std::string typeString = iMember.typeName();
std::string::size_type index = typeString.find_first_of("(");
std::string::size_type index = typeString.find_first_of('(');
if (index == std::string::npos) {
return iMember.name() + ":" + typeString;
} else {
Expand Down
8 changes: 5 additions & 3 deletions Fireworks/Core/src/FWGeometry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
// AMT deprication of tracker specific DetIds
#include "CalibTracker/StandaloneTrackerTopology/interface/StandaloneTrackerTopology.h"

#include <iostream>
#include <cassert>
#include <iostream>
#include <memory>

#include <sstream>
#include <stdexcept>
#include <algorithm>
Expand Down Expand Up @@ -191,8 +193,8 @@ void FWGeometry::loadMap(const char* iFileName) {
TNamed* ttopology = static_cast<TNamed*>(file->Get("TrackerTopology"));
if (ttopology) {
std::string xml = ttopology->GetTitle();
m_trackerTopology = std::unique_ptr<TrackerTopology>(
new TrackerTopology(StandaloneTrackerTopology::fromTrackerParametersXMLString(xml)));
m_trackerTopology =
std::make_unique<TrackerTopology>(StandaloneTrackerTopology::fromTrackerParametersXMLString(xml));
}

file->Close();
Expand Down
8 changes: 4 additions & 4 deletions Fireworks/FWInterface/src/FWPSetCellEditor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ bool editVInputTag(edm::ParameterSet &ps, bool tracked, const std::string &label
size_t fst, lst;

while (getline(iss, vitem, ',')) {
fst = vitem.find("[");
lst = vitem.find("]");
fst = vitem.find('[');
lst = vitem.find(']');

if (fst != std::string::npos)
vitem.erase(fst, 1);
Expand Down Expand Up @@ -193,8 +193,8 @@ void editVectorParameter(edm::ParameterSet &ps, bool tracked, const std::string
size_t fst, lst;

while (getline(iss, vitem, ',')) {
fst = vitem.find("[");
lst = vitem.find("]");
fst = vitem.find('[');
lst = vitem.find(']');

if (fst != std::string::npos)
vitem.erase(fst, 1);
Expand Down
2 changes: 2 additions & 0 deletions Fireworks/ParticleFlow/plugins/FWPFCandidateDetailView.cc
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ void FWPFCandidateDetailView::addHits(const std::vector<reco::PFRecHit>* hits) {
continue;

std::vector<TEveVector> hc;
hc.reserve(4);
for (int k = 0; k < 4; ++k) {
hc.push_back(TEveVector(corners[k].eta(), corners[k].phi(), 0));
// ps->SetNextPoint(corners[k].eta(),corners[k].phi(),0 ); //debug
Expand All @@ -367,6 +368,7 @@ void FWPFCandidateDetailView::addHits(const std::vector<reco::PFRecHit>* hits) {
centerOfGravity *= 0.25;

std::vector<TEveVector> radialVectors;
radialVectors.reserve(4);
for (int k = 0; k < 4; ++k)
radialVectors.push_back(TEveVector(hc[k] - centerOfGravity));

Expand Down

0 comments on commit 2e69bdc

Please sign in to comment.