23#include "Math/GenVector/Cartesian3D.h"
26#include "TGeoManager.h"
27#include "TGeoVolume.h"
31#include "TVirtualPad.h"
47 Float_t aAir[nAir] = {12.0107, 14.0067, 15.9994, 39.948};
48 Float_t zAir[nAir] = {6., 7., 8., 18.};
49 Float_t wAir[nAir] = {0.000124, 0.755267, 0.231781, 0.012827};
50 Float_t dAirVacuum = 1.20479E-10;
53 mgr.Mixture(
"MCH", kID,
"Air", aAir, zAir, dAirVacuum, nAir, wAir);
54 mgr.Medium(
"MCH", kID,
"Air", kID,
63 return gGeoManager->MakeBox(
name, gGeoManager->GetMedium(
"MCH_Air"), 2000.0, 2000.0, 3000.0);
66void dump(std::ostream& out,
const TGeoNode&
n,
int level,
int maxdepth, std::string prefix)
68 if (
level >= maxdepth) {
73 out <<
n.GetName() <<
"\n";
76 if (
level < maxdepth) {
77 for (
int i = 0;
i <
n.GetNdaughters();
i++) {
78 TGeoNode* d =
n.GetDaughter(
i);
79 if (
i ==
n.GetNdaughters() - 1) {
80 out << prefix +
"└──" << d->GetName()
82 dump(out, *d,
level + 1, maxdepth, prefix +
" ");
84 out << prefix +
"├──" << d->GetName()
86 dump(out, *d,
level + 1, maxdepth, prefix +
"│ ");
98 TGeoNavigator* nav = gGeoManager->GetCurrentNavigator();
100 if (strlen(fromPath)) {
101 if (!nav->cd(fromPath)) {
102 std::cerr <<
"Could not get path " << fromPath <<
"\n";
107 TGeoNode* node = nav->GetCurrentNode();
109 dump(out, *node, 0, maxdepth,
"");
114 if (gGeoManager && gGeoManager->GetTopVolume()) {
115 std::cerr <<
"Can only call this function with an empty geometry, i.e. gGeoManager==nullptr "
116 <<
" or gGeoManager->GetTopVolume()==nullptr\n";
118 TGeoManager*
g =
new TGeoManager(
"MCH-ONLY",
"ALICE MCH Standalone Geometry");
120 g->SetTopVolume(
top);
124void addAlignableVolumes()
127 std::cerr <<
"gGeoManager == nullptr, must create a geometry first\n";
131 if (!gGeoManager->IsClosed()) {
132 gGeoManager->CloseGeometry();
143 std::cerr <<
"gGeoManager == nullptr, must create a geometry first\n";
147 if (!gGeoManager->IsClosed()) {
148 gGeoManager->CloseGeometry();
151 addAlignableVolumes();
153 std::vector<o2::detectors::AlignParam>
params;
163 const std::string& objectPath =
"";
165 if (!ccdbHost.empty()) {
167 LOGP(info,
"Storing alignment object on {}/{}", ccdbHost,
path);
169 map<string, string> metadata;
170 api.
init(ccdbHost.c_str());
175 if (!fileName.empty()) {
176 LOGP(info,
"Storing MCH alignment in local file {}", fileName);
177 TFile algFile(fileName.c_str(),
"recreate");
178 algFile.WriteObjectAny(&
params,
"std::vector<o2::detectors::AlignParam>",
"alignment");
186 std::cerr <<
"gGeoManager == nullptr, must create a geometry first\n";
190 if (!gGeoManager->IsClosed()) {
191 gGeoManager->CloseGeometry();
196 std::vector<o2::detectors::AlignParam>
params;
210 TIter next(gGeoManager->GetListOfVolumes());
213 while ((vol =
static_cast<TGeoVolume*
>(next()))) {
214 if (TString(vol->GetName()).Contains(re)) {
215 vol->SetVisibility(visible);
216 vol->SetVisDaughters(visibleDaughters);
224 TIter next(gGeoManager->GetListOfVolumes());
227 while ((vol =
static_cast<TGeoVolume*
>(next()))) {
228 if (TString(vol->GetName()).Contains(re)) {
229 vol->SetFillColor(fillColor);
230 vol->SetLineColor(lineColor);
237 gGeoManager->SetVisLevel(4);
272 gGeoManager->GetTopVolume()->Draw(
"ogl");
274 TGLViewer* gl =
static_cast<TGLViewer*
>(gPad->GetViewer3D(
"ogl"));
275 TGLCamera&
c = gl->CurrentCamera();
278 gl->SetStyle(TGLRnrCtx::kOutline);
291 os <<
"L=" <<
m.
length <<
" <Rho>=" <<
m.meanRho <<
" <A>=" <<
m.meanA
292 <<
" <Z>=" <<
m.meanZ <<
" <x/x0>=" <<
m.meanX2X0 <<
" nCross=" <<
m.nCross;
304 return a.Cross(
b).Unit();
307TH2*
getRadio(
int detElemId,
float xmin,
float ymin,
float xmax,
float ymax,
float xstep,
float ystep,
float thickness)
309 if (xmin >= xmax || ymin >= ymax) {
310 std::cerr <<
"incorrect limits\n";
313 TH2* hmatb =
new TH2F(
"hmatb",
"hmatb", (
int)((xmax - xmin) / xstep), xmin, xmax, (
int)((ymax - ymin) / ystep), ymin, ymax);
320 for (
auto x = xmin;
x < xmax;
x += xstep) {
321 for (
auto y = ymin;
y < ymax;
y += ystep) {
323 if (std::isfinite(matb.meanX2X0)) {
324 hmatb->Fill(
x,
y, matb.meanX2X0);
Definition of the base alignment parameters class.
Definition of the Names Generator class.
Definition of the GeometryManager class.
Interface for MCH geometry creation.
void createStandaloneGeometry(const char *name)
static std::string getAlignmentPath(DId d)
static MatBudgetExt meanMaterialBudgetExt(float x0, float y0, float z0, float x1, float y1, float z1)
static MaterialManager & Instance()
int storeAsTFileAny(const T *obj, std::string const &path, std::map< std::string, std::string > const &metadata, long startValidityTimestamp=-1, long endValidityTimestamp=-1, std::vector< char >::size_type maxSize=0) const
void init(std::string const &hosts)
Static class with identifiers, bitmasks and names for ALICE detectors.
void setCartMisAlig(double xmean, double xwidth, double ymean, double ywidth, double zmean=0., double zwidth=0.)
Set cartesian displacement parameters different along x, y.
void setModuleAngMisAlig(double xmean, double xwidth, double ymean, double ywidth, double zmean, double zwidth)
Set module (half chambers) cartesian displacement parameters.
void setModuleCartMisAlig(double xmean, double xwidth, double ymean, double ywidth, double zmean, double zwidth)
Set module (half chambers) cartesian displacement parameters.
void misAlign(std::vector< o2::detectors::AlignParam > &arr, bool verbose=false) const
void setAngMisAlig(double zmean, double zwidth, double xmean=0., double xwidth=0., double ymean=0., double ywidth=0.)
Set angular displacement.
void dump(const std::string what, DPMAP m, int verbose)
GLdouble GLdouble GLdouble GLdouble top
GLuint const GLchar * name
GLboolean GLboolean GLboolean b
GLenum const GLfloat * params
GLsizei const GLchar *const * path
GLboolean GLboolean GLboolean GLboolean a
void addAlignableVolumes(TGeoManager &geom)
TransformationCreator transformationFromTGeoManager(const TGeoManager &geo)
void createGeometry(TGeoManager &geom, TGeoVolume &topVolume)
TH2 * getRadio(int detElemId, float xmin, float ymin, float xmax, float ymax, float xstep, float ystep, float thickness)
get a radlen radiograph of a given detection element within box with the given granularity
void setVolumeVisibility(const char *pattern, bool visible, bool visibleDaughters)
set the volume and daughter visibility for all volumes with a name matching the regexp pattern
TGeoVolume * createAirVacuumCave(const char *name)
void setVolumeColor(const char *pattern, int lineColor, int fillColor)
set the volume line and fill for all volumes with a name matching the regexp pattern
void showGeometryAsTextTree(const char *fromPath, int maxdepth, std::ostream &out)
tree like textual dump of the geometry nodes
math_utils::Vector3D< double > getNormalVector(const o2::math_utils::Transform3D &t)
o2::base::GeometryManager::MatBudgetExt getMatBudgetExt(const o2::math_utils::Transform3D &t, math_utils::Vector3D< double > &n, float x, float y, float thickness)
void misAlignGeometry()
generates misalignments for MCH geometry
void drawGeometry()
basic drawing of the geometry
void zeroMisAlignGeometry(const std::string &ccdbHost, const std::string &fileName)
generates zero misalignments for MCH geometry
void drawOptionPresetBasic()
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
std::ostream & operator<<(std::ostream &stream, o2::InteractionRecord const &ir)
FIXME: do not use data model tables.
o2::mch::geo::MisAligner aGMA
o2::math_utils::Point3D< double > po
std::array< uint16_t, 5 > pattern