From a56db92485aafadbd4e2f797633d1874f6126cd4 Mon Sep 17 00:00:00 2001 From: Andrey Erokhin Date: Sat, 10 Oct 2020 03:03:22 +0300 Subject: [PATCH] Algorithm Common: add braces to single statements --- Algorithm/include/Algorithm/Parser.h | 37 +++++++++++++------ Algorithm/include/Algorithm/TableView.h | 30 ++++++++++----- Algorithm/test/pageparser.cxx | 3 +- CCDB/include/CCDB/BasicCCDBManager.h | 3 +- Common/Field/src/MagFieldFast.cxx | 25 ++++++++----- Common/Field/src/MagFieldParam.cxx | 30 ++++++++++----- Common/Field/src/MagneticField.cxx | 22 +++++++---- Common/Field/src/MagneticWrapperChebyshev.cxx | 3 +- Common/MathUtils/include/MathUtils/MathBase.h | 24 ++++++++---- Common/MathUtils/src/Chebyshev3D.cxx | 6 ++- Common/MathUtils/test/testUtils.cxx | 3 +- Common/Utils/include/CommonUtils/TreeStream.h | 3 +- Common/Utils/src/TreeStream.cxx | 24 ++++++++---- Common/Utils/src/TreeStreamRedirector.cxx | 15 +++++--- Common/Utils/test/testTreeStream.cxx | 18 ++++++--- run/O2HitMerger.h | 6 ++- 16 files changed, 167 insertions(+), 85 deletions(-) diff --git a/Algorithm/include/Algorithm/Parser.h b/Algorithm/include/Algorithm/Parser.h index 960e9e6a18751..43ec4daa90aec 100644 --- a/Algorithm/include/Algorithm/Parser.h +++ b/Algorithm/include/Algorithm/Parser.h @@ -158,25 +158,30 @@ class ForwardParser { static_assert(sizeof(InputType) == 1, "ForwardParser currently only supports byte type buffer"); - if (buffer == nullptr || bufferSize == 0) + if (buffer == nullptr || bufferSize == 0) { return 0; + } + size_t position = 0; std::vector frames; do { FrameInfo entry; // check the header - if (sizeof(HeaderType) + position > bufferSize) + if (sizeof(HeaderType) + position > bufferSize) { break; + } entry.header = reinterpret_cast(buffer + position); - if (!checkHeader(*entry.header)) + if (!checkHeader(*entry.header)) { break; + } // extract frame size from header, this is expected to be the // total frome size including header, payload and optional trailer auto frameSize = getFrameSize(*entry.header); - if (frameSize + position > bufferSize) + if (frameSize + position > bufferSize) { break; + } // payload starts right after the header entry.payload = reinterpret_cast(entry.header + 1); @@ -188,8 +193,9 @@ class ForwardParser } else { auto trailerStart = buffer + position + frameSize - tailOffset; entry.trailer = reinterpret_cast(trailerStart); - if (!CheckTrailer(entry, checkTrailer)) + if (!CheckTrailer(entry, checkTrailer)) { break; + } } // store the extracted frame info and continue with remaining buffer @@ -201,8 +207,9 @@ class ForwardParser // frames found and format consistent, insert entries to target // Note: the complete block must be consistent for (auto entry : frames) { - if (!insert(entry)) + if (!insert(entry)) { break; + } } return frames.size(); } else if (frames.size() == 0) { @@ -332,30 +339,35 @@ class ReverseParser { static_assert(sizeof(InputType) == 1, "ReverseParser currently only supports byte type buffer"); - if (buffer == nullptr || bufferSize == 0) + if (buffer == nullptr || bufferSize == 0) { return 0; + } auto position = bufferSize; std::vector frames; do { FrameInfo entry; // start from end, extract and check trailer - if (sizeof(TrailerType) > position) + if (sizeof(TrailerType) > position) { break; + } entry.trailer = reinterpret_cast(buffer + position - sizeof(TrailerType)); - if (!checkTrailer(*entry.trailer)) + if (!checkTrailer(*entry.trailer)) { break; + } // get the total frame size auto frameSize = getFrameSize(*entry.trailer); - if (frameSize > position) + if (frameSize > position) { break; + } // extract and check header auto headerStart = buffer + position - frameSize; entry.header = reinterpret_cast(headerStart); - if (!checkHeader(*entry.header)) + if (!checkHeader(*entry.header)) { break; + } // payload immediately after header entry.payload = reinterpret_cast(entry.header + 1); @@ -367,8 +379,9 @@ class ReverseParser if (position == 0) { // frames found and format consistent, the complete block must be consistent for (auto entry : frames) { - if (!insert(entry)) + if (!insert(entry)) { break; + } } return frames.size(); } else if (frames.size() == 0) { diff --git a/Algorithm/include/Algorithm/TableView.h b/Algorithm/include/Algorithm/TableView.h index 3aa2e5b91dd5f..462a5ef74d74c 100644 --- a/Algorithm/include/Algorithm/TableView.h +++ b/Algorithm/include/Algorithm/TableView.h @@ -67,10 +67,12 @@ class TableView bool operator<(const FrameIndex& rh) const { - if (rh.columnIndex < columnIndex) + if (rh.columnIndex < columnIndex) { return false; - if (columnIndex < rh.columnIndex) + } + if (columnIndex < rh.columnIndex) { return true; + } return row < rh.row; } }; @@ -143,8 +145,9 @@ class TableView /// get row data for a data set const RowDescType& getRowData(size_t row) const { - if (row < mRowData.size()) + if (row < mRowData.size()) { return mRowData[row]; + } // TODO: better to throw exception? static RowDescType dummy; return dummy; @@ -180,22 +183,26 @@ class TableView iterator(IteratorDirections direction, TableView* parent, unsigned row = 0, unsigned column = 0) : mDirection(direction), mRow(row), mColumn(column), mEnd(direction == kAlongRow ? parent->getNColumns() : parent->getNRows()), mParent(parent), mCache(), mIsCached(false) { - while (!isValid() && !isEnd()) + while (!isValid() && !isEnd()) { operator++(); + } } self_type& operator++() { mIsCached = false; if (mDirection == kAlongRow) { - if (mColumn < mEnd) + if (mColumn < mEnd) { mColumn++; + } } else { - if (mRow < mEnd) + if (mRow < mEnd) { mRow++; + } } - while (!isEnd() && !isValid()) + while (!isEnd() && !isValid()) { operator++(); + } return *this; } @@ -265,11 +272,13 @@ class TableView self_type& operator++() { if (base::mDirection == iterator::kAlongRow) { - if (base::mColumn < base::mEnd) + if (base::mColumn < base::mEnd) { base::mColumn++; + } } else { - if (base::mRow < base::mEnd) + if (base::mRow < base::mEnd) { base::mRow++; + } } return *this; } @@ -314,8 +323,9 @@ class TableView /// private access function for the iterators bool get(unsigned row, unsigned column, FrameData& data) { - if (this->mColumns.size() == 0) + if (this->mColumns.size() == 0) { return false; + } auto element = this->mFrames.find(FrameIndex{this->mColumns[column], row}); if (element != this->mFrames.end()) { data = element->second; diff --git a/Algorithm/test/pageparser.cxx b/Algorithm/test/pageparser.cxx index 10a918beb23cf..a7b03ecb36816 100644 --- a/Algorithm/test/pageparser.cxx +++ b/Algorithm/test/pageparser.cxx @@ -78,8 +78,9 @@ std::pair, size_t> MakeBuffer(size_t pagesize, } while (nPages * pagesize < totalSize); } else { auto nRequiredPages = dataset.size() / maxElementsPerPage; - if (dataset.size() % maxElementsPerPage > 0) + if (dataset.size() % maxElementsPerPage > 0) { ++nRequiredPages; + } totalSize = (nRequiredPages > 0 ? nRequiredPages : 1) * pagesize; } diff --git a/CCDB/include/CCDB/BasicCCDBManager.h b/CCDB/include/CCDB/BasicCCDBManager.h index b34cce62fc93a..2a6a85b840981 100644 --- a/CCDB/include/CCDB/BasicCCDBManager.h +++ b/CCDB/include/CCDB/BasicCCDBManager.h @@ -147,8 +147,9 @@ T* BasicCCDBManager::getForTimeStamp(std::string const& path, long timestamp) mCreatedNotBefore ? std::to_string(mCreatedNotBefore) : ""); } auto& cached = mCache[path]; - if (mCheckObjValidityEnabled && cached.isValid(timestamp)) + if (mCheckObjValidityEnabled && cached.isValid(timestamp)) { return reinterpret_cast(cached.objPtr.get()); + } T* ptr = mCCDBAccessor.retrieveFromTFileAny(path, mMetaData, timestamp, &mHeaders, cached.uuid, mCreatedNotAfter ? std::to_string(mCreatedNotAfter) : "", diff --git a/Common/Field/src/MagFieldFast.cxx b/Common/Field/src/MagFieldFast.cxx index 2016012e02b24..aabbb4d016b01 100644 --- a/Common/Field/src/MagFieldFast.cxx +++ b/Common/Field/src/MagFieldFast.cxx @@ -68,22 +68,25 @@ bool MagFieldFast::LoadData(const string inpFName) SolParam* curParam = nullptr; while (std::getline(in, line)) { - if (line.empty() || line[0] == '#') + if (line.empty() || line[0] == '#') { continue; // empy or comment + } std::stringstream ss(line); int cnt = 0; if (component < 0) { - while (cnt < 4 && (ss >> header[cnt++])) + while (cnt < 4 && (ss >> header[cnt++])) { ; + } if (cnt != 4) { LOG(FATAL) << "Wrong header " << line; return false; } curParam = &mSolPar[header[0]][header[1]][header[2]]; } else { - while (cnt < header[3] && (ss >> curParam->parBxyz[component][cnt++])) + while (cnt < header[3] && (ss >> curParam->parBxyz[component][cnt++])) { ; + } if (cnt != header[3]) { LOG(FATAL) << "Wrong data (npar=" << cnt << ") for param " << header[0] << " " << header[1] << " " << header[2] << " " << header[3] << " " << line; @@ -215,20 +218,24 @@ bool MagFieldFast::GetSegment(float x, float y, float z, int& zSeg, int& rSeg, i const float zGridSpaceInv = 1.f / (kSolZMax * 2 / kNSolZRanges); zSeg = -1; if (z < kSolZMax) { - if (z > -kSolZMax) + if (z > -kSolZMax) { zSeg = (z + kSolZMax) * zGridSpaceInv; // solenoid params - else { // need to check dipole params + } else { // need to check dipole params return false; } - } else + } else { return false; + } // R segment float xx = x * x, yy = y * y, rr = xx + yy; - for (rSeg = 0; rSeg < kNSolRRanges; rSeg++) - if (rr < kSolR2Max[rSeg]) + for (rSeg = 0; rSeg < kNSolRRanges; rSeg++) { + if (rr < kSolR2Max[rSeg]) { break; - if (rSeg == kNSolRRanges) + } + } + if (rSeg == kNSolRRanges) { return kFALSE; + } quadrant = GetQuadrant(x, y); return true; } diff --git a/Common/Field/src/MagFieldParam.cxx b/Common/Field/src/MagFieldParam.cxx index 66310ea7b4117..dd7fb68978c7f 100644 --- a/Common/Field/src/MagFieldParam.cxx +++ b/Common/Field/src/MagFieldParam.cxx @@ -48,8 +48,9 @@ void MagFieldParam::SetParam(const MagneticField* field) void MagFieldParam::putParams(FairParamList* list) { /// store parameters in the list - if (!list) + if (!list) { return; + } list->add("Map Type ID", int(mMapType)); list->add("Beam Type ID", int(mBeamType)); list->add("Integral Type", mDefaultIntegration); @@ -65,33 +66,42 @@ Bool_t MagFieldParam::getParams(FairParamList* list) { /// retried parameters int int2enum = 0; - if (!list->fill("Map Type ID", &int2enum)) + if (!list->fill("Map Type ID", &int2enum)) { return kFALSE; + } mMapType = static_cast(int2enum); - if (!list->fill("Beam Type ID", &int2enum)) + if (!list->fill("Beam Type ID", &int2enum)) { return kFALSE; + } mBeamType = static_cast(int2enum); // - if (!list->fill("Integral Type", &mDefaultIntegration)) + if (!list->fill("Integral Type", &mDefaultIntegration)) { return kFALSE; - if (!list->fill("Fact.Solenoid", &mFactorSol)) + } + if (!list->fill("Fact.Solenoid", &mFactorSol)) { return kFALSE; - if (!list->fill("Fact.Dipole ", &mFactorDip)) + } + if (!list->fill("Fact.Dipole ", &mFactorDip)) { return kFALSE; - if (!list->fill("Beam Energy ", &mBeamEnergy)) + } + if (!list->fill("Beam Energy ", &mBeamEnergy)) { return kFALSE; - if (!list->fill("Max. Field ", &mMaxField)) + } + if (!list->fill("Max. Field ", &mMaxField)) { return kFALSE; + } FairParamObj* parpath = list->find("Path to map "); - if (!parpath) + if (!parpath) { return kFALSE; + } int lgt = parpath->getLength(); // RS: is there a bug in FairParamList::fill(const Text_t* name,Text_t* value,const Int_t length)? // I think the "if (lfill("Path to map ", cbuff, lgt + 2)) + if (!list->fill("Path to map ", cbuff, lgt + 2)) { return kFALSE; + } mMapPath = cbuff; return kTRUE; } diff --git a/Common/Field/src/MagneticField.cxx b/Common/Field/src/MagneticField.cxx index f53ac5a42cfdc..3afabde8a0bbb 100644 --- a/Common/Field/src/MagneticField.cxx +++ b/Common/Field/src/MagneticField.cxx @@ -185,16 +185,18 @@ void MagneticField::CreateField() << "; Helix tracking chosen instead"; mDefaultIntegration = 2; } - if (mDefaultIntegration == 0) + if (mDefaultIntegration == 0) { mPrecisionInteg = 0; + } if (mBeamEnergy <= 0 && mBeamType != MagFieldParam::kNoBeamField) { - if (mBeamType == MagFieldParam::kBeamTypepp) + if (mBeamType == MagFieldParam::kBeamTypepp) { mBeamEnergy = 7000.; // max proton energy - else if (mBeamType == MagFieldParam::kBeamTypeAA) + } else if (mBeamType == MagFieldParam::kBeamTypeAA) { mBeamEnergy = 2760; // max PbPb energy - else if (mBeamType == MagFieldParam::kBeamTypepA || mBeamType == MagFieldParam::kBeamTypeAp) + } else if (mBeamType == MagFieldParam::kBeamTypepA || mBeamType == MagFieldParam::kBeamTypeAp) { mBeamEnergy = 2760; // same rigitiy max PbPb energy + } // LOG(INFO) << "MagneticField::CreateField: Maximim possible beam energy for requested beam is assumed"; } @@ -257,8 +259,9 @@ void MagneticField::Field(const Double_t* __restrict__ xyz, Double_t* __restrict */ // b[0]=b[1]=b[2]=0.0; - if (mFastField && mFastField->Field(xyz, b)) + if (mFastField && mFastField->Field(xyz, b)) { return; + } if (mMeasuredMap && xyz[2] > mMeasuredMap->getMinZ() && xyz[2] < mMeasuredMap->getMaxZ()) { mMeasuredMap->Field(xyz, b); @@ -284,8 +287,9 @@ Double_t MagneticField::getBz(const Double_t* xyz) const if (mFastField) { double bz = 0; - if (mFastField->GetBz(xyz, bz)) + if (mFastField->GetBz(xyz, bz)) { return bz; + } } if (mMeasuredMap && xyz[2] > mMeasuredMap->getMinZ() && xyz[2] < mMeasuredMap->getMaxZ()) { double bz = mMeasuredMap->getBz(xyz); @@ -478,8 +482,9 @@ void MagneticField::setFactorSolenoid(Float_t fc) mMultipicativeFactorSolenoid = fc; break; // case kConvMap2005: mMultipicativeFactorSolenoid = fc; break; } - if (mFastField) + if (mFastField) { mFastField->setFactorSol(getFactorSolenoid()); + } } void MagneticField::setFactorDipole(Float_t fc) @@ -665,8 +670,9 @@ void MagneticField::FillParContainer() void MagneticField::AllowFastField(bool v) { if (v) { - if (!mFastField) + if (!mFastField) { mFastField = std::make_unique(getFactorSolenoid(), mMapType == MagFieldParam::k2kG ? 2 : 5); + } } else { mFastField.reset(nullptr); } diff --git a/Common/Field/src/MagneticWrapperChebyshev.cxx b/Common/Field/src/MagneticWrapperChebyshev.cxx index 10e8d7d8924d1..db73f2bf7ce45 100644 --- a/Common/Field/src/MagneticWrapperChebyshev.cxx +++ b/Common/Field/src/MagneticWrapperChebyshev.cxx @@ -1403,8 +1403,9 @@ void MagneticWrapperChebyshev::saveData(const char* outfile) const // TPCIntegral part fprintf(stream, "START TPCINT\n#Number of pieces\n%d\n", mNumberOfParameterizationTPC); - for (int ip = 0; ip < mNumberOfParameterizationTPC; ip++) + for (int ip = 0; ip < mNumberOfParameterizationTPC; ip++) { getParameterTPCIntegral(ip)->saveData(stream); + } fprintf(stream, "#\nEND TPCINT\n"); // TPCRatIntegral part diff --git a/Common/MathUtils/include/MathUtils/MathBase.h b/Common/MathUtils/include/MathUtils/MathBase.h index f4c26c4a0adfc..16d7d46b2b99c 100644 --- a/Common/MathUtils/include/MathUtils/MathBase.h +++ b/Common/MathUtils/include/MathUtils/MathBase.h @@ -170,18 +170,22 @@ Double_t fitGaus(const size_t nBins, const T* arr, const T xMin, const T xMax, s for (Int_t i = 0; i < nBins; i++) { entries += arr[i]; - if (arr[i] > 0) + if (arr[i] > 0) { nfilled++; + } } // TODO: Check why this is needed - if (max < 4) + if (max < 4) { return -4; - if (entries < 12) + } + if (entries < 12) { return -4; + } - if (rms < kTol) + if (rms < kTol) { return -4; + } param[3] = entries; @@ -224,16 +228,19 @@ Double_t fitGaus(const size_t nBins, const T* arr, const T xMin, const T xMax, s fitter.GetCovarianceMatrix(mat); chi2 = fitter.GetChisquare() / Double_t(npoints); } - if (TMath::Abs(par[1]) < kTol) + if (TMath::Abs(par[1]) < kTol) { return -4; - if (TMath::Abs(par[2]) < kTol) + } + if (TMath::Abs(par[2]) < kTol) { return -4; + } param[1] = T(par[1] / (-2. * par[2])); param[2] = T(1. / TMath::Sqrt(TMath::Abs(-2. * par[2]))); Double_t lnparam0 = par[0] + par[1] * param[1] + par[2] * param[1] * param[1]; - if (lnparam0 > 307) + if (lnparam0 > 307) { return -4; + } param[0] = TMath::Exp(lnparam0); return chi2; @@ -299,8 +306,9 @@ StatisticsData getStatisticsData(const T* arr, const size_t nBins, const double ++npoints; } } - if (sum == 0) + if (sum == 0) { return data; + } mean /= sum; data.mCOG = mean; diff --git a/Common/MathUtils/src/Chebyshev3D.cxx b/Common/MathUtils/src/Chebyshev3D.cxx index 963df5ae1ba60..2fd984640b6af 100644 --- a/Common/MathUtils/src/Chebyshev3D.cxx +++ b/Common/MathUtils/src/Chebyshev3D.cxx @@ -524,8 +524,9 @@ Int_t Chebyshev3D::chebyshevFit(int dmOut) Chebyshev3DCalc* cheb = getChebyshevCalc(dmOut); Float_t prec = cheb->getPrecision(); - if (prec < sMinimumPrecision) + if (prec < sMinimumPrecision) { prec = mPrecision; // no specific precision for this dim. + } Float_t rTiny = 0.1 * prec / Float_t(maxDim); // neglect coefficient below this threshold float ncals2count = mNumberOfPoints[2] * mNumberOfPoints[1] * mNumberOfPoints[0]; @@ -864,8 +865,9 @@ TH1* Chebyshev3D::TestRMS(int idim, int npoints, TH1* histo) } float prc = getChebyshevCalc(idim)->getPrecision(); - if (prc < sMinimumPrecision) + if (prc < sMinimumPrecision) { prc = mPrecision; // no dimension specific precision + } for (int ip = npoints; ip--;) { gRandom->RndmArray(3, (Float_t*)mTemporaryCoefficient); diff --git a/Common/MathUtils/test/testUtils.cxx b/Common/MathUtils/test/testUtils.cxx index 804a246765c8b..caae0e40e55a3 100644 --- a/Common/MathUtils/test/testUtils.cxx +++ b/Common/MathUtils/test/testUtils.cxx @@ -38,8 +38,9 @@ BOOST_AUTO_TEST_CASE(Utils_test) double diff = phi - phi0; p->Fill(phi0, diff); diff = fabs(diff); - if (diff > maxDiff) + if (diff > maxDiff) { maxDiff = diff; + } } //p->Draw(); diff --git a/Common/Utils/include/CommonUtils/TreeStream.h b/Common/Utils/include/CommonUtils/TreeStream.h index 35ed0616302ef..d1df4ca48f600 100644 --- a/Common/Utils/include/CommonUtils/TreeStream.h +++ b/Common/Utils/include/CommonUtils/TreeStream.h @@ -177,8 +177,9 @@ Int_t TreeStream::CheckIn(T* obj) { // check in arbitrary class having dictionary TClass* pClass = nullptr; - if (obj) + if (obj) { pClass = obj->IsA(); + } if (mCurrentIndex >= static_cast(mElements.size())) { mElements.emplace_back(); diff --git a/Common/Utils/src/TreeStream.cxx b/Common/Utils/src/TreeStream.cxx index 664f002423b61..24171ff647ad3 100644 --- a/Common/Utils/src/TreeStream.cxx +++ b/Common/Utils/src/TreeStream.cxx @@ -59,16 +59,18 @@ void TreeStream::BuildTree() // Build the Tree int entriesFilled = mTree.GetEntries(); - if (mBranches.size() < mElements.size()) + if (mBranches.size() < mElements.size()) { mBranches.resize(mElements.size()); + } TString name; TBranch* br = nullptr; for (int i = 0; i < static_cast(mElements.size()); i++) { // auto& element = mElements[i]; - if (mBranches[i]) + if (mBranches[i]) { continue; + } name = element.name.data(); if (name.IsNull()) { name = TString::Format("B%d", i); @@ -111,16 +113,19 @@ void TreeStream::Fill() } for (int i = 0; i < entries; i++) { auto& element = mElements[i]; - if (!element.type) + if (!element.type) { continue; + } auto br = mBranches[i]; if (br) { - if (element.type) + if (element.type) { br->SetAddress(element.ptr); + } } } - if (!mStatus) + if (!mStatus) { mTree.Fill(); // fill only in case of non conflicts + } mStatus = 0; } @@ -129,8 +134,9 @@ TreeStream& TreeStream::Endl() { // Perform pseudo endl operation - if (mTree.GetNbranches() == 0) + if (mTree.GetNbranches() == 0) { BuildTree(); + } Fill(); mStatus = 0; mCurrentIndex = 0; @@ -147,14 +153,16 @@ TreeStream& TreeStream::operator<<(const Char_t* name) } // // if tree was already defined ignore - if (mTree.GetEntries() > 0) + if (mTree.GetEntries() > 0) { return *this; + } // check branch name if tree was not // Int_t last = 0; for (last = 0;; last++) { - if (name[last] == 0) + if (name[last] == 0) { break; + } } if (last > 0 && name[last - 1] == '=') { diff --git a/Common/Utils/src/TreeStreamRedirector.cxx b/Common/Utils/src/TreeStreamRedirector.cxx index 0fa91c7f8d2ad..6218c0998ce3d 100644 --- a/Common/Utils/src/TreeStreamRedirector.cxx +++ b/Common/Utils/src/TreeStreamRedirector.cxx @@ -76,8 +76,9 @@ TreeStream& TreeStreamRedirector::operator<<(Int_t id) mDataLayouts.emplace_back(std::unique_ptr(new TreeStream(Form("Tree%d", id)))); auto layout = mDataLayouts.back().get(); layout->setID(id); - if (backup) + if (backup) { backup->cd(); + } return *layout; } @@ -88,8 +89,9 @@ TreeStream& TreeStreamRedirector::operator<<(const char* name) // if not existing - creates new for (auto& layout : mDataLayouts) { - if (!std::strcmp(layout->getName(), name)) + if (!std::strcmp(layout->getName(), name)) { return *layout.get(); + } } // create new @@ -98,8 +100,9 @@ TreeStream& TreeStreamRedirector::operator<<(const char* name) mDataLayouts.emplace_back(std::unique_ptr(new TreeStream(name))); auto layout = mDataLayouts.back().get(); layout->setID(-1); - if (backup) + if (backup) { backup->cd(); + } return *layout; } @@ -114,8 +117,9 @@ void TreeStreamRedirector::Close() layout->getTree().Write(layout->getName()); } mDataLayouts.clear(); - if (backup) + if (backup) { backup->cd(); + } if (mOwnDirectory) { mDirectory->Close(); @@ -143,8 +147,9 @@ void TreeStreamRedirector::FixLeafNameBug(TTree* tree) // After the fix unit test code with pairs of sprse friend trees worked properly // Side effects of fix: // - if (!tree) + if (!tree) { return; + } TObjArray* brArray = tree->GetListOfBranches(); TObjArray* lArray = tree->GetListOfLeaves(); for (int i = 0; i < brArray->GetLast(); i++) { diff --git a/Common/Utils/test/testTreeStream.cxx b/Common/Utils/test/testTreeStream.cxx index a401e2530baa4..d9a857ff091f6 100644 --- a/Common/Utils/test/testTreeStream.cxx +++ b/Common/Utils/test/testTreeStream.cxx @@ -124,16 +124,19 @@ bool UnitTestSparse(Double_t scale, Int_t testEntries) // Input parameter scale => downscaling of sprse element std::string outFName("testTreeStreamSparse.root"); - if (scale <= 0) + if (scale <= 0) { scale = 1; - if (scale > 1) + } + if (scale > 1) { scale = 1; + } TreeStreamRedirector* pcstream = new TreeStreamRedirector(outFName.data(), "recreate"); for (Int_t ientry = 0; ientry < testEntries; ientry++) { TVectorD vecRandom(200); TVectorD vecZerro(200); // zerro vector - for (Int_t j = 0; j < 200; j++) + for (Int_t j = 0; j < 200; j++) { vecRandom[j] = j + ientry + 0.1 * gRandom->Rndm(); + } Bool_t isSelected = (gRandom->Rndm() < scale); TVectorD* pvecFull = &vecRandom; TVectorD* pvecSparse = isSelected ? &vecRandom : nullptr; @@ -192,12 +195,15 @@ bool UnitTestSparse(Double_t scale, Int_t testEntries) treeSparseSkip0->SetBranchAddress("vec.", &pvecRead); Bool_t readOK = kTRUE; for (Int_t ientry = 0; ientry < testEntries; ientry++) { - if (!pvecRead) + if (!pvecRead) { continue; - if (pvecRead->GetNrows() == 0) + } + if (pvecRead->GetNrows() == 0) { continue; - if (TMath::Abs((*pvecRead)[0] - ientry) > 0.5) + } + if (TMath::Abs((*pvecRead)[0] - ientry) > 0.5) { readOK = kFALSE; + } } printf("#UnitTest:\tTestSparse(%f)\tReadOK\t%d\n", scale, readOK); // diff --git a/run/O2HitMerger.h b/run/O2HitMerger.h index 386558fc404ba..1815fe4ed5eff 100644 --- a/run/O2HitMerger.h +++ b/run/O2HitMerger.h @@ -430,8 +430,9 @@ class O2HitMerger : public FairMQDevice } else { // loop over subevents Int_t nprimTot = 0; - for (auto entry = 0; entry < entries; entry++) + for (auto entry = 0; entry < entries; entry++) { nprimTot += nprimaries[entry]; + } Int_t idelta0 = 0; Int_t idelta1 = nprimTot; for (auto entry = entries - 1; entry >= 0; --entry) { @@ -461,8 +462,9 @@ class O2HitMerger : public FairMQDevice { Int_t cId = track.getMotherTrackId(); Int_t ioffset = (cId < nprim) ? idelta0 : idelta1; - if (cId != -1) + if (cId != -1) { track.SetMotherTrackId(cId + ioffset); + } } void updateTrackIdWithOffset(TrackReference& ref, Int_t nprim, Int_t idelta0, Int_t idelta1)