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

Solving numerous compilation warnings #82

Merged
merged 2 commits into from
Dec 23, 2022
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
2 changes: 1 addition & 1 deletion inc/TRestGeant4Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ class TRestGeant4Event : public TRestEvent {
lowestID = GetTrack(0).GetTrackID();
}

for (int i = 0; i < GetNumberOfTracks(); i++) {
for (unsigned int i = 0; i < GetNumberOfTracks(); i++) {
auto tr = GetTrack(i);
if (tr.GetTrackID() < lowestID) lowestID = tr.GetTrackID();
}
Expand Down
2 changes: 1 addition & 1 deletion inc/TRestGeant4Metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ class TRestGeant4Metadata : public TRestMetadata {

/// \brief Returns the number of active volumes, or geometry volumes that have been
/// selected for data storage.
inline Int_t GetNumberOfActiveVolumes() const { return fActiveVolumes.size(); }
inline unsigned int GetNumberOfActiveVolumes() const { return fActiveVolumes.size(); }

inline bool IsActiveVolume(const char* volumeName) const {
return fActiveVolumesSet.count(volumeName) > 0;
Expand Down
4 changes: 2 additions & 2 deletions src/TRestGeant4AnalysisProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ void TRestGeant4AnalysisProcess::InitProcess() {
cout << "List of active volumes : " << endl;
cout << "------------------------ " << endl;

for (int n = 0; n < fG4Metadata->GetNumberOfActiveVolumes(); n++)
for (unsigned int n = 0; n < fG4Metadata->GetNumberOfActiveVolumes(); n++)
cout << "Volume " << n << " : " << fG4Metadata->GetActiveVolumeName(n) << endl;
cout << "??????????????????????????????????????????????????" << endl;
cout << endl;
Expand Down Expand Up @@ -334,7 +334,7 @@ void TRestGeant4AnalysisProcess::InitProcess() {
cout << "List of active volumes : " << endl;
cout << "------------------------ " << endl;

for (int n = 0; n < fG4Metadata->GetNumberOfActiveVolumes(); n++)
for (unsigned int n = 0; n < fG4Metadata->GetNumberOfActiveVolumes(); n++)
cout << "Volume " << n << " : " << fG4Metadata->GetActiveVolumeName(n) << endl;
cout << "??????????????????????????????????????????????????" << endl;
cout << endl;
Expand Down
2 changes: 1 addition & 1 deletion src/TRestGeant4BlobAnalysisProcess.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ TRestEvent* TRestGeant4BlobAnalysisProcess::ProcessEvent(TRestEvent* inputEvent)
Double_t xBlob1 = 0, yBlob1 = 0, zBlob1 = 0;
Double_t xBlob2 = 0, yBlob2 = 0, zBlob2 = 0;

for (int tck = 0; tck < fG4Event->GetNumberOfTracks(); tck++) {
for (unsigned int tck = 0; tck < fG4Event->GetNumberOfTracks(); tck++) {
const auto& track = fG4Event->GetTrack(tck);
if (track.GetParentID() == 0) {
if (track.GetParticleName() != "e-") {
Expand Down
54 changes: 27 additions & 27 deletions src/TRestGeant4Event.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ TVector3 TRestGeant4Event::GetMeanPositionInVolume(Int_t volID) const {
TVector3 pos;
Double_t eDep = 0;

for (int t = 0; t < GetNumberOfTracks(); t++) {
for (unsigned int t = 0; t < GetNumberOfTracks(); t++) {
const auto tck = GetTrack(t);
if (tck.GetEnergyInVolume(volID) > 0) {
pos += tck.GetMeanPositionInVolume(volID) * tck.GetEnergyInVolume(volID);
Expand Down Expand Up @@ -143,7 +143,7 @@ TVector3 TRestGeant4Event::GetPositionDeviationInVolume(Int_t volID) const {
Double_t edep = 0;
TVector3 deviation = TVector3(0, 0, 0);

for (int n = 0; n < hitsInVolume.GetNumberOfHits(); n++) {
for (unsigned int n = 0; n < hitsInVolume.GetNumberOfHits(); n++) {
Double_t en = hitsInVolume.GetEnergy(n);
TVector3 diff = meanPos - hitsInVolume.GetPosition(n);
diff.SetXYZ(diff.X() * diff.X(), diff.Y() * diff.Y(), diff.Z() * diff.Z());
Expand All @@ -164,7 +164,7 @@ TVector3 TRestGeant4Event::GetPositionDeviationInVolume(Int_t volID) const {
/// \param volID Int_t specifying volume ID
///
TVector3 TRestGeant4Event::GetFirstPositionInVolume(Int_t volID) const {
for (int t = 0; t < GetNumberOfTracks(); t++)
for (unsigned int t = 0; t < GetNumberOfTracks(); t++)
if (GetTrack(t).GetEnergyInVolume(volID) > 0) return GetTrack(t).GetFirstPositionInVolume(volID);

Double_t nan = TMath::QuietNaN();
Expand Down Expand Up @@ -233,9 +233,9 @@ size_t TRestGeant4Event::GetNumberOfPhysicalHits(Int_t volID) const {
///
TRestHits TRestGeant4Event::GetHits(Int_t volID) const {
TRestHits hits;
for (int t = 0; t < GetNumberOfTracks(); t++) {
for (unsigned int t = 0; t < GetNumberOfTracks(); t++) {
const auto& g4Hits = GetTrack(t).GetHits();
for (int n = 0; n < g4Hits.GetNumberOfHits(); n++) {
for (unsigned int n = 0; n < g4Hits.GetNumberOfHits(); n++) {
if (volID != -1 && g4Hits.GetVolumeId(n) != volID) continue;

Double_t x = g4Hits.GetX(n);
Expand Down Expand Up @@ -303,7 +303,7 @@ void TRestGeant4Event::SetBoundaries() {
Double_t minEnergy = 1e10, maxEnergy = -1e10;

Int_t nTHits = 0;
for (int ntck = 0; ntck < this->GetNumberOfTracks(); ntck++) {
for (unsigned int ntck = 0; ntck < this->GetNumberOfTracks(); ntck++) {
Int_t nHits = GetTrack(ntck).GetNumberOfHits();
const auto& hits = GetTrack(ntck).GetHits();

Expand Down Expand Up @@ -380,12 +380,12 @@ TMultiGraph* TRestGeant4Event::GetXYMultiGraph(Int_t gridElement, vector<TString
for (unsigned int p = 0; p < pcsList.size(); p++) legendAdded.push_back(0);

Int_t cnt = 0;
for (int ntck = 0; ntck < GetNumberOfTracks(); ntck++) {
for (unsigned int ntck = 0; ntck < GetNumberOfTracks(); ntck++) {
const auto hits = GetTrack(ntck).GetHits();

EColor color = GetTrack(ntck).GetParticleColor();

for (int nhit = 0; nhit < hits.GetNumberOfHits(); nhit++) {
for (unsigned int nhit = 0; nhit < hits.GetNumberOfHits(); nhit++) {
Double_t xPos = hits.GetX(nhit);
Double_t yPos = hits.GetY(nhit);
Double_t energy = hits.GetEnergy(nhit);
Expand Down Expand Up @@ -472,12 +472,12 @@ TMultiGraph* TRestGeant4Event::GetYZMultiGraph(Int_t gridElement, vector<TString
for (unsigned int p = 0; p < pcsList.size(); p++) legendAdded.push_back(0);

Int_t cnt = 0;
for (int ntck = 0; ntck < GetNumberOfTracks(); ntck++) {
for (unsigned int ntck = 0; ntck < GetNumberOfTracks(); ntck++) {
const auto& hits = GetTrack(ntck).GetHits();

EColor color = GetTrack(ntck).GetParticleColor();

for (int nhit = 0; nhit < hits.GetNumberOfHits(); nhit++) {
for (unsigned int nhit = 0; nhit < hits.GetNumberOfHits(); nhit++) {
Double_t yPos = hits.GetY(nhit);
Double_t zPos = hits.GetZ(nhit);
Double_t energy = hits.GetEnergy(nhit);
Expand Down Expand Up @@ -564,12 +564,12 @@ TMultiGraph* TRestGeant4Event::GetXZMultiGraph(Int_t gridElement, vector<TString
for (unsigned int p = 0; p < pcsList.size(); p++) legendAdded.push_back(0);

Int_t cnt = 0;
for (int ntck = 0; ntck < GetNumberOfTracks(); ntck++) {
for (unsigned int ntck = 0; ntck < GetNumberOfTracks(); ntck++) {
const auto& hits = GetTrack(ntck).GetHits();

EColor color = GetTrack(ntck).GetParticleColor();

for (int nhit = 0; nhit < hits.GetNumberOfHits(); nhit++) {
for (unsigned int nhit = 0; nhit < hits.GetNumberOfHits(); nhit++) {
Double_t xPos = hits.GetX(nhit);
Double_t zPos = hits.GetZ(nhit);
Double_t energy = hits.GetEnergy(nhit);
Expand Down Expand Up @@ -647,10 +647,10 @@ TH2F* TRestGeant4Event::GetXYHistogram(Int_t gridElement, vector<TString> optLis
fXYHisto = new TH2F("XY", "", nBinsX, fMinX - 10, fMinX + pitch * nBinsX, nBinsY, fMinY - 10,
fMinY + pitch * nBinsY);

for (int ntck = 0; ntck < GetNumberOfTracks(); ntck++) {
for (unsigned int ntck = 0; ntck < GetNumberOfTracks(); ntck++) {
const auto& hits = GetTrack(ntck).GetHits();

for (int nhit = 0; nhit < hits.GetNumberOfHits(); nhit++) {
for (unsigned int nhit = 0; nhit < hits.GetNumberOfHits(); nhit++) {
Double_t xPos = hits.GetX(nhit);
Double_t yPos = hits.GetY(nhit);
Double_t energy = hits.GetEnergy(nhit);
Expand Down Expand Up @@ -706,10 +706,10 @@ TH2F* TRestGeant4Event::GetXZHistogram(Int_t gridElement, vector<TString> optLis
fXZHisto = new TH2F("XZ", "", nBinsX, fMinX - 10, fMinX + pitch * nBinsX, nBinsZ, fMinZ - 10,
fMinZ + pitch * nBinsZ);

for (int ntck = 0; ntck < GetNumberOfTracks(); ntck++) {
for (unsigned int ntck = 0; ntck < GetNumberOfTracks(); ntck++) {
const auto& hits = GetTrack(ntck).GetHits();

for (int nhit = 0; nhit < hits.GetNumberOfHits(); nhit++) {
for (unsigned int nhit = 0; nhit < hits.GetNumberOfHits(); nhit++) {
Double_t xPos = hits.GetX(nhit);
Double_t zPos = hits.GetZ(nhit);
Double_t energy = hits.GetEnergy(nhit);
Expand Down Expand Up @@ -765,10 +765,10 @@ TH2F* TRestGeant4Event::GetYZHistogram(Int_t gridElement, vector<TString> optLis
fYZHisto = new TH2F("YZ", "", nBinsY, fMinY - 10, fMinY + pitch * nBinsY, nBinsZ, fMinZ - 10,
fMinZ + pitch * nBinsZ);

for (int ntck = 0; ntck < GetNumberOfTracks(); ntck++) {
for (unsigned int ntck = 0; ntck < GetNumberOfTracks(); ntck++) {
const auto& hits = GetTrack(ntck).GetHits();

for (int nhit = 0; nhit < hits.GetNumberOfHits(); nhit++) {
for (unsigned int nhit = 0; nhit < hits.GetNumberOfHits(); nhit++) {
Double_t yPos = hits.GetY(nhit);
Double_t zPos = hits.GetZ(nhit);
Double_t energy = hits.GetEnergy(nhit);
Expand Down Expand Up @@ -823,10 +823,10 @@ TH1D* TRestGeant4Event::GetXHistogram(Int_t gridElement, vector<TString> optList

fXHisto = new TH1D("X", "", nBinsX, fMinX - 10, fMinX + pitch * nBinsX);

for (int ntck = 0; ntck < GetNumberOfTracks(); ntck++) {
for (unsigned int ntck = 0; ntck < GetNumberOfTracks(); ntck++) {
const auto& hits = GetTrack(ntck).GetHits();

for (int nhit = 0; nhit < hits.GetNumberOfHits(); nhit++) {
for (unsigned int nhit = 0; nhit < hits.GetNumberOfHits(); nhit++) {
Double_t xPos = hits.GetX(nhit);
Double_t energy = hits.GetEnergy(nhit);

Expand Down Expand Up @@ -874,10 +874,10 @@ TH1D* TRestGeant4Event::GetZHistogram(Int_t gridElement, vector<TString> optList

fZHisto = new TH1D("Z", "", nBinsZ, fMinZ - 10, fMinZ + pitch * nBinsZ);

for (int ntck = 0; ntck < GetNumberOfTracks(); ntck++) {
for (unsigned int ntck = 0; ntck < GetNumberOfTracks(); ntck++) {
const auto& hits = GetTrack(ntck).GetHits();

for (int nhit = 0; nhit < hits.GetNumberOfHits(); nhit++) {
for (unsigned int nhit = 0; nhit < hits.GetNumberOfHits(); nhit++) {
Double_t zPos = hits.GetZ(nhit);
Double_t energy = hits.GetEnergy(nhit);

Expand Down Expand Up @@ -925,10 +925,10 @@ TH1D* TRestGeant4Event::GetYHistogram(Int_t gridElement, vector<TString> optList

fYHisto = new TH1D("Y", "", nBinsY, fMinY - 10, fMinY + pitch * nBinsY);

for (int ntck = 0; ntck < GetNumberOfTracks(); ntck++) {
for (unsigned int ntck = 0; ntck < GetNumberOfTracks(); ntck++) {
const auto& hits = GetTrack(ntck).GetHits();

for (int nhit = 0; nhit < hits.GetNumberOfHits(); nhit++) {
for (unsigned int nhit = 0; nhit < hits.GetNumberOfHits(); nhit++) {
Double_t yPos = hits.GetY(nhit);
Double_t energy = hits.GetEnergy(nhit);

Expand Down Expand Up @@ -1123,7 +1123,7 @@ TPad* TRestGeant4Event::DrawEvent(const TString& option, Bool_t autoBoundaries)
}
void TRestGeant4Event::PrintActiveVolumes() const {
cout << "Number of active volumes : " << GetNumberOfActiveVolumes() << endl;
for (int i = 0; i < fVolumeStoredNames.size(); i++) {
for (unsigned int i = 0; i < fVolumeStoredNames.size(); i++) {
if (isVolumeStored(i)) {
cout << "Active volume " << i << ":" << fVolumeStoredNames[i] << " has been stored." << endl;
cout << "Total energy deposit in volume " << i << ":" << fVolumeStoredNames[i] << " : "
Expand All @@ -1141,7 +1141,7 @@ void TRestGeant4Event::PrintEvent(int maxTracks, int maxHits) const {

cout << "- Primary source position: " << VectorToString(fPrimaryPosition) << " mm" << endl;

for (int i = 0; i < GetNumberOfPrimaries(); i++) {
for (unsigned int i = 0; i < GetNumberOfPrimaries(); i++) {
const char* sourceNumberString =
GetNumberOfPrimaries() <= 1 ? ""
: TString::Format(" %d of %zu", i + 1, GetNumberOfPrimaries()).Data();
Expand All @@ -1155,7 +1155,7 @@ void TRestGeant4Event::PrintEvent(int maxTracks, int maxHits) const {
cout << "Total number of tracks: " << GetNumberOfTracks() << endl;

int nTracks = GetNumberOfTracks();
if (maxTracks > 0 && maxTracks < GetNumberOfTracks()) {
if (maxTracks > 0 && (unsigned int)maxTracks < GetNumberOfTracks()) {
nTracks = min(maxTracks, int(GetNumberOfTracks()));
cout << "Printing only the first " << nTracks << " tracks" << endl;
}
Expand Down
6 changes: 3 additions & 3 deletions src/TRestGeant4EventViewer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ TEveStraightLineSet* GetTrackEveDrawable(const TRestGeant4Track& track) {
ToEnergyString(track.GetInitialKineticEnergy()).c_str()));

const auto& hits = track.GetHits();
for (int i = 0; i < hits.GetNumberOfHits() - 1; i++) {
for (unsigned int i = 0; i < hits.GetNumberOfHits() - 1; i++) {
lineSet->AddLine({static_cast<float>(GEOM_SCALE * hits.GetPosition(i).x()),
static_cast<float>(GEOM_SCALE * hits.GetPosition(i).y()),
static_cast<float>(GEOM_SCALE * hits.GetPosition(i).z())}, //
Expand Down Expand Up @@ -193,7 +193,7 @@ void TRestGeant4EventViewer::AddEvent(TRestEvent* event) {
trackCounter++;

const auto& hits = track.GetHits();
for (int i = 0; i < hits.GetNumberOfHits(); i++) {
for (unsigned int i = 0; i < hits.GetNumberOfHits(); i++) {
const auto& processName = physicsInfo.GetProcessName(hits.GetProcess(i));
const auto& processType = physicsInfo.GetProcessType(processName);
const auto& position = hits.GetPosition(i);
Expand Down Expand Up @@ -273,7 +273,7 @@ void TRestGeant4EventViewer::AddTrack(Int_t trkID, Int_t parentID, TVector3 from

fHitConnectors[trkID]->SetNextPoint(from.X() * GEOM_SCALE, from.Y() * GEOM_SCALE, from.Z() * GEOM_SCALE);

if (fHitConnectors.size() > parentID)
if (parentID >= 0 && fHitConnectors.size() > (unsigned int)parentID)
fHitConnectors[parentID]->AddElement(fHitConnectors[trkID]);
else {
RESTWarning << "Parent ID: " << parentID << " of track " << trkID << " was not found!" << RESTendl;
Expand Down
8 changes: 4 additions & 4 deletions src/TRestGeant4Hits.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void TRestGeant4Hits::RemoveG4Hits() {
Double_t TRestGeant4Hits::GetEnergyInVolume(Int_t volumeID) const {
Double_t energy = 0;

for (int n = 0; n < fNHits; n++) {
for (size_t n = 0; n < fNHits; n++) {
if (fVolumeID[n] == volumeID) {
energy += GetEnergy(n);
}
Expand All @@ -51,7 +51,7 @@ Double_t TRestGeant4Hits::GetEnergyInVolume(Int_t volumeID) const {
TVector3 TRestGeant4Hits::GetMeanPositionInVolume(Int_t volumeID) const {
TVector3 pos;
Double_t energy = 0;
for (int n = 0; n < fNHits; n++)
for (size_t n = 0; n < fNHits; n++)
if (fVolumeID[n] == volumeID) {
pos += GetPosition(n) * GetEnergy(n);
energy += GetEnergy(n);
Expand All @@ -67,7 +67,7 @@ TVector3 TRestGeant4Hits::GetMeanPositionInVolume(Int_t volumeID) const {
}

TVector3 TRestGeant4Hits::GetFirstPositionInVolume(Int_t volumeID) const {
for (int n = 0; n < fNHits; n++)
for (size_t n = 0; n < fNHits; n++)
if (fVolumeID[n] == volumeID) return GetPosition(n);

Double_t nan = TMath::QuietNaN();
Expand All @@ -86,7 +86,7 @@ TVector3 TRestGeant4Hits::GetLastPositionInVolume(Int_t volumeID) const {

size_t TRestGeant4Hits::GetNumberOfHitsInVolume(Int_t volumeID) const {
size_t result = 0;
for (int n = 0; n < fNHits; n++) {
for (size_t n = 0; n < fNHits; n++) {
if (fVolumeID[n] == volumeID) {
result++;
}
Expand Down
9 changes: 5 additions & 4 deletions src/TRestGeant4Metadata.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,8 @@ void TRestGeant4Metadata::InitFromConfigFile() {

// if "gdmlFile" is purely a file (without any path) and "geometryPath" is
// defined, we recombine them together
if ((((string)fGdmlFilename).find_first_not_of("./~") == 0 || ((string)fGdmlFilename).find("/") == -1) &&
if ((((string)fGdmlFilename).find_first_not_of("./~") == 0 ||
((string)fGdmlFilename).find("/") == string::npos) &&
fGeometryPath != "") {
if (fGeometryPath[fGeometryPath.Length() - 1] == '/') {
fGdmlFilename = fGeometryPath + GetParameter("gdmlFile");
Expand Down Expand Up @@ -1455,14 +1456,14 @@ void TRestGeant4Metadata::PrintMetadata() {
RESTMetadata << "Sensitive volume: " << sensitiveVolume << RESTendl;
}
RESTMetadata << "Number of active volumes: " << GetNumberOfActiveVolumes() << RESTendl;
for (int n = 0; n < GetNumberOfActiveVolumes(); n++) {
for (unsigned int n = 0; n < GetNumberOfActiveVolumes(); n++) {
RESTMetadata << "Name: " << GetActiveVolumeName(n)
<< ", ID: " << GetActiveVolumeID(GetActiveVolumeName(n))
<< ", maxStep: " << GetMaxStepSize(GetActiveVolumeName(n)) << "mm "
<< ", chance: " << GetStorageChance(GetActiveVolumeName(n)) << RESTendl;
}
}
for (int n = 0; n < GetNumberOfBiasingVolumes(); n++) {
for (unsigned int n = 0; n < GetNumberOfBiasingVolumes(); n++) {
GetBiasingVolume(n).PrintBiasingVolume();
}

Expand Down Expand Up @@ -1526,7 +1527,7 @@ void TRestGeant4Metadata::SetActiveVolume(const TString& name, Double_t chance,
/// data storage.
///
Bool_t TRestGeant4Metadata::isVolumeStored(const TString& volume) const {
for (int n = 0; n < GetNumberOfActiveVolumes(); n++)
for (unsigned int n = 0; n < GetNumberOfActiveVolumes(); n++)
if (GetActiveVolumeName(n) == volume) return true;

return false;
Expand Down
Loading