Skip to content
Snippets Groups Projects
Commit 99f4a5c7 authored by Pierre-Alain Loizeau's avatar Pierre-Alain Loizeau Committed by Florian Uhlig
Browse files

Remove all scripts as now in geometry repository

parent ed94155b
No related branches found
No related tags found
1 merge request!1038Add script to check rad length in various geo file sets + remove radlen CI
Pipeline #20783 passed
#/bin/bash
# check_radlen.sh - checks radiation length of materials in user supplied geometry
# Author: Eoin Clerkin (FAIR) 2022-01-31
echo "Scanning the geometry" $1
root -l -b -q '$VMCWORKDIR/macro/geometry/scan_geometry.C("'$1'")' 1>tmp
ROOT_EXIT=$?;
if [ 0 -ne $ROOT_EXIT ]; then
echo "root command failed, nothing more done";
exit ${ROOT_EXIT};
fi;
grep '^M\(at\|ix\)' tmp | \
sort | \
uniq -c | \
sort -g -k 1 1>MATERIALS
COUNT=0;
FAIL=0;
SKIP=0;
OKAY=0;
while IFS= read -r line;
do
variables=`echo "$line" | sed -e 's/eff//g' | sed -e 's/index/jndex/g' | sed -e 's/.*A=/ A=/g' | sed -e 's/ / -v /g'`
awk \
-v TOL=0.1 \
$variables \
'BEGIN{\
if(Z<1){
printf "SKIP \t "; \
exit 3;
};
cal_rad_len=(716.4*A/(Z*(Z+1)*log(287/sqrt(Z)))/rho);\
#print cal_rad_len;
diff=(cal_rad_len - radlen);\
if(diff*diff <= TOL*TOL*radlen*radlen ){\
printf "OKAY \t " cal_rad_len; exit 1;
}else{\
printf "FAIL \t " cal_rad_len; exit 2;
}}'
STATUS=$?;
if [ $STATUS -eq 1 ]; then OKAY=$((OKAY+1)); fi;
if [ $STATUS -eq 2 ]; then FAIL=$((FAIL+1)); fi;
if [ $STATUS -eq 3 ]; then SKIP=$((SKIP+1)); fi;
COUNT=$((COUNT+1));
echo " \t $line"
done < MATERIALS
rm tmp MATERIALS
echo ${FAIL}" failures in " $COUNT " materials"
echo "ENDED successfully"
exit ${FAIL};
/* Copyright (C) 2021 Facility for Antiproton and Ion Research in Europe, Darmstadt
SPDX-License-Identifier: GPL-3.0-only
Authors: Eoin Clerkin [committer] */
#if !defined(__CLING__)
#include "CbmSetup"
#include "CbmTransport.h"
#include "FairSystemInfo.h"
#include "TCanvas.h"
#include "TStopwatch.h"
#endif // !defined(__CLING__)
#include <cstdlib>
#include <fstream>
#include <iostream>
void scan_geometry(std::string fileName = "test.geo.root", uint32_t uMaxNodeDepth = 25)
{
TString myName = "scan_and_graph";
std::vector<TGeoNode*> node(uMaxNodeDepth, nullptr);
TGeoMedium* med = nullptr;
TGeoVolume* top = nullptr;
TFile file(fileName.c_str(), "READ");
if (!file.IsOpen()) {
std::cerr << "Was a root geo file supplied?" << std::endl;
exit(1);
};
gROOT->cd();
file.GetListOfKeys()->Print();
file.GetSize();
file.GetObject("FAIRGeom", gGeoManager);
if (gGeoManager != nullptr) { top = gGeoManager->GetTopVolume(); };
gROOT->cd();
if (top == nullptr) {
std::string geo_tag = fileName.substr(fileName.find_last_of('/') + 1);
geo_tag = geo_tag.substr(0, geo_tag.find(".geo.root"));
std::cout << "geo tag extracted from file name is: " << geo_tag << std::endl;
file.GetObject(geo_tag.data(), top);
// If still not there, may be an mCBM geometry not following the filename = tag convention
if (top == nullptr) {
std::string geo_tag_mcbm = geo_tag.substr(0, geo_tag.find("_mcbm"));
std::cout << "mcbm geo tag extracted from file name is: " << geo_tag_mcbm << std::endl;
file.GetObject(geo_tag_mcbm.data(), top);
}
// If still not there, may be a SIS18 geometry not following the filename = tag convention
if (top == nullptr) {
std::string geo_tag_sis18 = geo_tag.substr(0, geo_tag.find("_sis18"));
std::cout << "sis18 geo tag extracted from file name is: " << geo_tag_sis18 << std::endl;
file.GetObject(geo_tag_sis18.data(), top);
}
}
if (top == nullptr) file.GetObject("FAIRGeom", top);
if (top == nullptr) file.GetObject("top", top);
if (top == nullptr) file.GetObject("TOP", top);
if (top == nullptr) file.GetObject("Top", top);
if (top == nullptr) file.GetObject("geometryFromGDML", top);
if (top == nullptr) top = dynamic_cast<TGeoVolume*>(file.Get(file.GetListOfKeys()->First()->GetName()));
gROOT->cd();
if (top == nullptr) {
std::cerr << "No Top Volume found. Is the TGeoManager or Top Volume unusally named" << std::endl;
exit(1);
}
TObjArray* nodes = top->GetNodes();
if (nodes == nullptr) {
std::cerr << "Could not get the Nodes." << std::endl;
exit(1);
}
nodes->Print();
gROOT->cd();
std::vector<int32_t> i_array(uMaxNodeDepth, 0);
std::vector<int32_t> num_array(uMaxNodeDepth + 2, 0);
int32_t j = 0;
num_array[0] = nodes->GetEntries();
std::cout << "\n" << endl;
FILE* graph = fopen("geo.gv", "w+");
fprintf(graph, "digraph D {\n");
int k = 0;
while (num_array[0] != 0 && 0 <= j) {
k++; // Only used for stop.
//if(k==3)break;
if (j == 0) { node[0] = static_cast<TGeoNode*>(nodes->At(i_array[0])); }
else {
node[j] = static_cast<TGeoNode*>(node[j - 1]->GetDaughter(i_array[j]));
};
i_array[j]++; // Update number.
std::cout << "Node: \t";
for (int i = 0; i < j + 1 && i < uMaxNodeDepth; i++)
printf("%d/%d \t", i_array[i], num_array[i]);
printf("\n");
fprintf(graph, "%s -> %s \n", node[j]->GetMotherVolume()->GetName(), node[j]->GetVolume()->GetName());
std::cout << "Name: ";
node[j]->Print();
//std::cout << "Mother: ";
//node[j]->GetMotherVolume()->Print();
std::cout << "Shape: ";
node[j]->GetVolume()->GetShape()->Print();
std::cout << "Medium: ";
med = node[j]->GetMedium();
med->Print();
med->GetMaterial()->Print();
std::cout << "Position: ";
node[j]->GetMatrix()->Print();
num_array[j + 1] = node[j]->GetNdaughters();
std::cout << "Number of daughters: " << num_array[j + 1];
std::cout << endl << endl << endl;
if (j + 1 < uMaxNodeDepth && num_array[j + 1] > 0) {
j++;
num_array[j + 2] = 0;
};
while (0 <= j && i_array[j] == num_array[j]) {
num_array[j] = 0;
i_array[j] = 0; // Reset the counter before falling back.
j--;
};
if (0 <= j && j >= uMaxNodeDepth) {
std::cerr << "Maximum depth of " << uMaxNodeDepth << " exceeded (" << j
<< "). Increase uMaxNodeDepth which is the second parameter of the macro" << std::endl;
exit(uMaxNodeDepth);
};
};
fprintf(graph, "}\n");
fclose(graph);
gROOT->cd();
file.Close();
RemoveGeoManager();
printf("Processed %d nodes.\n", k);
std::cout << "Program Ends" << std::endl;
} // End of macro
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment