10 #include "Geometry/GeometryCore.h" 15 #include "cetlib_except/exception.h" 19 #include "TGeoManager.h" 21 #include "TGeoVolume.h" 22 #include "TGeoMatrix.h" 25 #include "TGeoVolume.h" 27 #include "TGeoCompositeShape.h" 41 #include <boost/format.hpp> 47 inline T sqr(
T v) {
return v * v; }
52 : fSurfaceY (pset.
get< double >(
"SurfaceY" ))
54 , fPositionWiggle (pset.
get< double >(
"PositionEpsilon", 1.
e-4))
55 , fPointInWarnings (pset.
get<
bool >(
"PointInWarnings", false))
56 , fECALEndcapOutside (pset.
get<
bool >(
"ECALEndcapOutsidePV", true))
74 pChannelMap->Initialize(*
this);
81 pECALSegmentationAlg->Initialize(*
this);
88 pMinervaSegmentationAlg->Initialize(*
this);
95 pMuIDSegmentationAlg->Initialize(*
this);
102 if (gdmlfile.empty()) {
104 <<
"No GDML Geometry file specified!\n";
107 if (rootfile.empty()) {
109 <<
"No ROOT Geometry file specified!\n";
117 if( !gGeoManager || bForceReload ){
118 if (gGeoManager) TGeoManager::UnlockGeometry();
129 TGeoManager::LockDefaultUnits(
false);
130 TGeoManager::SetDefaultUnits(TGeoManager::kRootUnits);
131 TGeoManager::LockDefaultUnits(
true);
134 gGeoManager->LockGeometry();
141 <<
"New detector geometry loaded from " 150 TGeoNode *node = gGeoManager->FindNode(point.x(), point.y(), point.z());
163 TGeoVolume *vol = node->GetVolume();
167 bool isBarrel =
true;
170 if (volname.find(
"barrel") == std::string::npos &&
171 volname.find(
"Barrel") == std::string::npos) {
174 if (volname.find(
"PV") != std::string::npos) {
178 if (volname.find(
"ECal") != std::string::npos || volname.find(
"ecal") != std::string::npos)
184 std::array<double, 3> shape = {0., 0., 0.};
188 TGeoBBox *box = (TGeoBBox*)(vol->GetShape());
191 shape[0] = box->GetDX();
192 shape[1] = box->GetDY();
198 shape[0] = box->GetDX();
199 shape[1] = box->GetDY();
203 shape[2] = box->GetDZ();
209 <<
"Could not find the volume associated to node " 210 << node->GetName() <<
"\n";
238 : vol_names(&names) {}
241 bool operator() (TGeoNode
const& node)
const 243 if (!vol_names)
return true;
244 return vol_names->find(node.GetVolume()->GetName()) != vol_names->end();
256 void operator() (TGeoNode
const& node)
257 {
if (matcher(node)) nodes.push_back(&node); }
260 { operator() (**iter); }
268 std::vector<std::vector<TGeoNode const*>>
paths;
274 {
if (matcher(**iter)) paths.push_back(iter.
get_path()); }
283 std::vector<TGeoNode const*> path = {
ROOTGeoManager()->GetTopNode() };
292 assert(!path.empty());
293 auto const* pCurrent = path.back();
294 auto const* pCurrentVolume = pCurrent->GetVolume();
297 if (strncmp(name.c_str(), pCurrentVolume->GetName(), name.length()) == 0)
301 unsigned int nd = pCurrentVolume->GetNdaughters();
302 for(
unsigned int i = 0; i < nd; ++i) {
303 path.push_back(pCurrentVolume->GetNode(i));
317 unsigned int nmodule = 7;
320 for(
unsigned int idet = 0; idet < 2; idet++) {
321 for(
unsigned int istave = 0; istave < nstave; istave++) {
322 for(
unsigned int imodule = 0; imodule < nmodule; imodule++) {
323 for(
unsigned int ilayer = 0; ilayer < nlayer; ilayer++) {
324 boost::format bname =
boost::format(
"%sECal_stave%02i_module%02i_layer_%02i_slice2_vol") % det[idet].c_str() % istave % imodule % ilayer;
327 if(!path.empty()) map.emplace(vol_name, path);
342 TGeoNode
const* pCurrentNode;
344 while ((pCurrentNode = *iNode)) {
345 node_collector(*pCurrentNode);
349 return node_collector.
nodes;
360 path_collector(iNode);
364 return path_collector.
paths;
369 TGeoNode* GeometryCore::FindNode<float>(
float const &
x,
float const &
y,
float const &
z)
const 371 return gGeoManager->FindNode(x, y,
z);
376 TGeoNode* GeometryCore::FindNode<double>(
double const &
x,
double const &
y,
double const &
z)
const 378 return gGeoManager->FindNode(x, y,
z);
384 return gGeoManager->FindNode(point[0], point[1], point[2]);
390 return gGeoManager->FindNode(point.x(), point.y(), point.z());
396 TVector3 point(world[0], world[1], world[2]);
398 std::vector<const TGeoNode*> path;
409 throw cet::exception(
"GeometryCore::WorldToLocal") <<
" can't find volume '" << name <<
"'\n";
414 trans.
SetPath(path, path.size() - 1);
415 std::array<double, 3> wd{ {world[0], world[1], world[2]} },
loc;
417 local = {loc.at(0), loc.at(1), loc.at(2)};
427 <<
" LocalTransformation has no nodes! -- Call WorldToLocal first!" <<
"\n";
432 std::array<double, 3>
loc{ {local[0], local[1], local[2]} }, wd;
434 world = {wd.at(0), wd.at(1), wd.at(2)};
453 float* ylo,
float* yhi,
454 float* zlo,
float* zhi)
const 456 const TGeoShape*
s = gGeoManager->GetVolume(
"volWorld")->GetShape();
458 throw cet::exception(
"GeometryCore") <<
"no pointer to world volume TGeoShape\n";
462 s->GetAxisRange(1,x1,x2);
if (xlo) *xlo =
x1;
if (xhi) *xhi =
x2;
466 s->GetAxisRange(2,y1,y2);
if (ylo) *ylo = y1;
if (yhi) *yhi = y2;
470 s->GetAxisRange(3,z1,z2);
if (zlo) *zlo = z1;
if (zhi) *zhi = z2;
478 TGeoVolume *volWorld = gGeoManager->FindVolumeFast(
"volWorld");
479 float halflength = ((TGeoBBox*)volWorld->GetShape())->GetDZ();
480 float halfheight = ((TGeoBBox*)volWorld->GetShape())->GetDY();
481 float halfwidth = ((TGeoBBox*)volWorld->GetShape())->GetDX();
482 if (
std::abs(point.x()) > halfwidth ||
491 <<
"is not inside the world volume " 492 <<
" half width = " << halfwidth
493 <<
" half height = " << halfheight
494 <<
" half length = " << halflength;
515 <<
"is not inside the detector enclosure volume " 530 TVector3 new_point = point - tpc_origin;
541 <<
"is not inside the MPD volume " 566 <<
"is not inside the GArTPC volume " 580 TGeoVolume *volLArTPC = gGeoManager->FindVolumeFast(
"volArgonCubeActive");
582 float halflength = ((TGeoBBox*)volLArTPC->GetShape())->GetDZ();
583 float halfheight = ((TGeoBBox*)volLArTPC->GetShape())->GetDY();
584 float halfwidth = ((TGeoBBox*)volLArTPC->GetShape())->GetDX();
585 if (
std::abs(point.x()) > halfwidth ||
594 <<
"is not inside the LArTPC volume " 595 <<
" half width = " << halfwidth
596 <<
" half height = " << halfheight
597 <<
" half length = " << halflength;
610 if (vol_name.find(
"barrel") == std::string::npos &&
611 vol_name.find(
"Barrel") == std::string::npos) {
616 if (vol_name.find(
"PV") != std::string::npos) {
628 if (vol_name.find(
"endcap") == std::string::npos &&
629 vol_name.find(
"Endcap") == std::string::npos) {
634 if (vol_name.find(
"PV") != std::string::npos) {
674 TGeoVolume *gvol = gGeoManager->FindVolumeFast(vol);
675 if(gvol)
return gvol->Weight();
677 throw cet::exception(
"GeometryCore") <<
"could not find specified volume " 679 <<
" to determine total mass\n";
700 double length = std::sqrt(
sqr(p2[0]-p1[0])
703 double dxyz[3] = {(p2[0]-p1[0])/length, (p2[1]-p1[1])/length, (p2[2]-p1[2])/length};
705 gGeoManager->InitTrack(p1,dxyz);
708 TGeoNode *node = gGeoManager->GetCurrentNode();
713 while(!gGeoManager->IsSameLocation(p2[0], p2[1], p2[2])){
714 gGeoManager->FindNextBoundary();
715 columnD += gGeoManager->GetStep()*node->GetMedium()->GetMaterial()->GetDensity();
718 node = gGeoManager->Step();
723 const double *
current = gGeoManager->GetCurrentPoint();
724 length = std::sqrt(
sqr(p2[0]-current[0]) +
725 sqr(p2[1]-current[1]) +
726 sqr(p2[2]-current[2]));
727 columnD += length*node->GetMedium()->GetMaterial()->GetDensity();
771 float loc[3] = {worldLoc[0], worldLoc[1], worldLoc[2]};
779 float loc[3] = {(
float)worldLoc[0], (
float)worldLoc[1], (
float)worldLoc[2]};
805 gar::raw::CellID_t GeometryCore::GetCellID(
const TGeoNode *node,
const unsigned int& det_id,
const unsigned int& stave,
const unsigned int& module,
const unsigned int& layer,
const unsigned int& slice,
const std::array<double, 3>& localPosition)
const 810 if(node_name.find(
"ECal") != std::string::npos || node_name.find(
"ECAL") != std::string::npos || node_name.find(
"ecal") != std::string::npos) {
812 const std::array<double, 3> shape = this->
FindShapeSize(node);
814 cellID =
fECALSegmentationAlg->GetCellID(*
this, det_id, stave, module, layer, slice, localPosition);
816 }
else if(node_name.find(
"TrackerSc") != std::string::npos || node_name.find(
"trackersc") != std::string::npos || node_name.find(
"Tracker") != std::string::npos || node_name.find(
"tracker") != std::string::npos) {
818 const std::array<double, 3> shape = this->
FindShapeSize(node);
822 }
else if(node_name.find(
"Yoke") != std::string::npos || node_name.find(
"yoke") != std::string::npos) {
824 const std::array<double, 3> shape = this->
FindShapeSize(node);
826 cellID =
fMuIDSegmentationAlg->GetCellID(*
this, det_id, stave, module, layer, slice, localPosition);
830 <<
"Detector id " << det_id <<
" unknown!" 831 <<
" Node name " << node_name;
868 std::array<double, 3>
pos;
870 if(node_name.find(
"ECal") != std::string::npos || node_name.find(
"ECAL") != std::string::npos || node_name.find(
"ecal") != std::string::npos) {
871 const std::array<double, 3> shape = this->
FindShapeSize(node);
877 if(node_name.find(
"Yoke") != std::string::npos || node_name.find(
"yoke") != std::string::npos) {
878 const std::array<double, 3> shape = this->
FindShapeSize(node);
893 if(node_name.find(
"ECal") != std::string::npos || node_name.find(
"ECAL") != std::string::npos || node_name.find(
"ecal") != std::string::npos) {
897 if(node_name.find(
"Yoke") != std::string::npos || node_name.find(
"yoke") != std::string::npos) {
907 double strip_width = 0.;
910 if(node_name.find(
"ECal") != std::string::npos || node_name.find(
"ECAL") != std::string::npos || node_name.find(
"ecal") != std::string::npos) {
914 if(node_name.find(
"Yoke") != std::string::npos || node_name.find(
"yoke") != std::string::npos) {
924 double tilesize = 0.;
927 if(node_name.find(
"ECal") != std::string::npos || node_name.find(
"ECAL") != std::string::npos || node_name.find(
"ecal") != std::string::npos) {
937 double strip_length = 0.;
938 const TGeoNode *node = this->
FindNode(point);
941 std::array<double, 3> localtemp;
946 if(node_name.find(
"ECal") != std::string::npos || node_name.find(
"ECAL") != std::string::npos || node_name.find(
"ecal") != std::string::npos) {
952 if(node_name.find(
"Yoke") != std::string::npos || node_name.find(
"yoke") != std::string::npos) {
965 std::pair<TVector3, TVector3> localStripEnds;
968 std::array<double, 3> localtemp;
973 if(node_name.find(
"ECal") != std::string::npos || node_name.find(
"ECAL") != std::string::npos || node_name.find(
"ecal") != std::string::npos) {
979 if(node_name.find(
"Yoke") != std::string::npos || node_name.find(
"yoke") != std::string::npos) {
986 std::array<double, 3> stripEnd1local = { localStripEnds.first.X(), localStripEnds.first.Y(), localStripEnds.first.Z() };
987 std::array<double, 3> stripEnd2local = { localStripEnds.second.X(), localStripEnds.second.Y(), localStripEnds.second.Z() };
988 std::array<double, 3> stripEnd1;
989 std::array<double, 3> stripEnd2;
993 return std::make_pair( TVector3(stripEnd1[0], stripEnd1[1], stripEnd1[2]), TVector3(stripEnd2[0], stripEnd2[1], stripEnd2[2]) );
999 std::pair<float, float> light_prop;
1003 if(node_name.find(
"ECal") != std::string::npos || node_name.find(
"ECAL") != std::string::npos || node_name.find(
"ecal") != std::string::npos) {
1009 if(node_name.find(
"Yoke") != std::string::npos || node_name.find(
"yoke") != std::string::npos) {
1021 std::array<double, 3>
pos;
1025 if(node_name.find(
"ECal") != std::string::npos || node_name.find(
"ECAL") != std::string::npos || node_name.find(
"ecal") != std::string::npos) {
1031 if(node_name.find(
"Yoke") != std::string::npos || node_name.find(
"yoke") != std::string::npos) {
1160 std::cout <<
"Geometry loaded with \n" <<
std::endl;
1161 std::cout <<
"------------------------------" <<
std::endl;
1165 std::cout <<
"------------------------------" <<
std::endl;
1166 std::cout <<
"World Geometry" <<
std::endl;
1171 std::cout <<
"------------------------------" <<
std::endl;
1172 std::cout <<
"Rock Geometry" <<
std::endl;
1178 std::cout <<
"------------------------------" <<
std::endl;
1179 std::cout <<
"Enclosure Geometry" <<
std::endl;
1185 std::cout <<
"------------------------------" <<
std::endl;
1186 std::cout <<
"LArArgonCube Geometry" <<
std::endl;
1189 std::cout <<
"------------------------------" <<
std::endl;
1190 std::cout <<
"LArActiveArgonCube Geometry" <<
std::endl;
1196 std::cout <<
"------------------------------" <<
std::endl;
1197 std::cout <<
"ND-GAr Geometry" <<
std::endl;
1202 std::cout <<
"------------------------------" <<
std::endl;
1203 std::cout <<
"TPC Geometry" <<
std::endl;
1210 std::cout <<
"------------------------------" <<
std::endl;
1211 std::cout <<
"ECAL Geometry" <<
std::endl;
1232 std::cout <<
"------------------------------" <<
std::endl;
1233 std::cout <<
"ND-GAr Lite Geometry" <<
std::endl;
1236 std::cout <<
"Number of planes (from Segmentation alg) " <<
GetNLayers(
"TrackerSc") <<
std::endl;
1240 std::cout <<
"------------------------------" <<
std::endl;
1241 std::cout <<
"MuID Geometry" <<
std::endl;
1250 std::cout <<
"------------------------------\n" <<
std::endl;
1256 std::vector<TGeoNode const*> path = this->
FindVolumePath(
"volWorld");
1257 if(path.size() == 0)
return false;
1259 const TGeoNode *world_node = path.at(path.size()-1);
1260 if(world_node ==
nullptr) {
1261 std::cout <<
"Cannot find node volWorld_0" <<
std::endl;
1265 const double *
origin = world_node->GetMatrix()->GetTranslation();
1271 fWorldHalfWidth = ((TGeoBBox*)world_node->GetVolume()->GetShape())->GetDZ();
1272 fWorldHalfHeight = ((TGeoBBox*)world_node->GetVolume()->GetShape())->GetDY();
1273 fWorldLength = 2.0 * ((TGeoBBox*)world_node->GetVolume()->GetShape())->GetDX();
1281 std::vector<TGeoNode const*> path = this->
FindVolumePath(
"rockBox_lv");
1282 if(path.size() == 0)
return false;
1284 const TGeoNode *rock_node = path.at(path.size()-1);
1285 if(rock_node ==
nullptr) {
1286 std::cout <<
"Cannot find node rockBox_lv_0" <<
std::endl;
1290 const double *
origin = rock_node->GetMatrix()->GetTranslation();
1296 fRockHalfWidth = ((TGeoBBox*)rock_node->GetVolume()->GetShape())->GetDZ();
1297 fRockHalfHeight = ((TGeoBBox*)rock_node->GetVolume()->GetShape())->GetDY();
1298 fRockLength = 2.0 * ((TGeoBBox*)rock_node->GetVolume()->GetShape())->GetDX();
1306 std::vector<TGeoNode const*> path = this->
FindVolumePath(
"volDetEnclosure");
1307 if(path.size() == 0)
return false;
1309 const TGeoNode *enc_node = path.at(path.size()-1);
1310 if(enc_node ==
nullptr) {
1311 std::cout <<
"Cannot find node volDetEnclosure_0" <<
std::endl;
1315 const double *
origin = enc_node->GetMatrix()->GetTranslation();
1323 fEnclosureLength = 2.0 * ((TGeoBBox*)enc_node->GetVolume()->GetShape())->GetDX();
1331 std::vector<TGeoNode const*> path = this->
FindVolumePath(
"volArgonCubeDetector");
1332 if(path.size() == 0)
1335 const TGeoNode *lar_node = path.at(path.size()-1);
1336 if(lar_node ==
nullptr) {
1337 std::cout <<
"Cannot find node volArgonCubeDetector_0" <<
std::endl;
1341 const double *
origin = lar_node->GetMatrix()->GetTranslation();
1347 fLArTPCHalfWidth = ((TGeoBBox*)lar_node->GetVolume()->GetShape())->GetDZ();
1349 fLArTPCLength = 2.0 * ((TGeoBBox*)lar_node->GetVolume()->GetShape())->GetDX();
1357 std::vector<TGeoNode const*> path = this->
FindVolumePath(
"volMPD");
1358 if(path.size() == 0)
1361 const TGeoNode *mpd_node = path.at(path.size()-1);
1362 if(mpd_node ==
nullptr) {
1363 std::cout <<
"Cannot find node volMPD_0" <<
std::endl;
1367 const double *
origin = mpd_node->GetMatrix()->GetTranslation();
1373 fMPDHalfWidth = ((TGeoBBox*)mpd_node->GetVolume()->GetShape())->GetDZ();
1374 fMPDHalfHeight = ((TGeoBBox*)mpd_node->GetVolume()->GetShape())->GetDY();
1375 fMPDLength = 2.0 * ((TGeoBBox*)mpd_node->GetVolume()->GetShape())->GetDX();
1386 std::vector<TGeoNode const*> path = this->
FindVolumePath(
"volArgonCubeActive");
1387 if(path.size() == 0)
1390 const TGeoNode *LArTPC_node = path.at(path.size()-1);
1391 if(LArTPC_node ==
nullptr) {
1392 std::cout <<
"Cannot find node volArgonCubeActive_0" <<
std::endl;
1396 TGeoMatrix *mat = LArTPC_node->GetMatrix();
1397 const double *
origin = mat->GetTranslation();
1417 std::vector<TGeoNode const*> path = this->
FindVolumePath(
"TPCGas_vol");
1418 if(path.size() == 0)
1420 if(path.size() == 0)
1423 const TGeoNode *GArTPC_node = path.at(path.size()-1);
1424 if(GArTPC_node ==
nullptr) {
1425 std::cout <<
"Cannot find node TPCGas_vol_0/TPCGas_vol_0" <<
std::endl;
1429 TGeoMatrix *mat = GArTPC_node->GetMatrix();
1430 const double *
origin = mat->GetTranslation();
1438 TGeoVolume *activeVol = GArTPC_node->GetVolume();
1439 float rOuter = ((TGeoTube*)activeVol->GetShape())->GetRmax();
1442 fTPCLength = 2.0 * ((TGeoTube*)activeVol->GetShape())->GetDZ();
1453 TGeoVolume *vol = gGeoManager->FindVolumeFast(
"volGArTPC");
1463 TGeoVolume *vol = gGeoManager->FindVolumeFast(
"BarrelECal_vol");
1465 vol = gGeoManager->FindVolumeFast(
"volBarrelECal");
1475 TGeoVolume *vol = gGeoManager->FindVolumeFast(
"volYokeBarrel");
1485 TGeoVolume *vol = gGeoManager->FindVolumeFast(
"BarrelECal_vol");
1487 vol = gGeoManager->FindVolumeFast(
"volBarrelECal");
1491 fECALRinner = ((TGeoPgon*)vol->GetShape())->GetRmin(0);
1499 TGeoVolume *vol = gGeoManager->FindVolumeFast(
"BarrelECal_vol");
1501 vol = gGeoManager->FindVolumeFast(
"volBarrelECal");
1505 fECALRouter = ((TGeoPgon*)vol->GetShape())->GetRmax(0);
1513 TGeoVolume *vol = gGeoManager->FindVolumeFast(
"EndcapECal_vol");
1515 vol = gGeoManager->FindVolumeFast(
"volEndcapECal");
1531 TGeoVolume *vol = gGeoManager->FindVolumeFast(
"EndcapECal_vol");
1533 vol = gGeoManager->FindVolumeFast(
"volEndcapECal");
1546 TGeoVolume *vol = gGeoManager->FindVolumeFast(
"PVBarrel_vol");
1548 vol = gGeoManager->FindVolumeFast(
"volPVBarrel");
1552 float min = ((TGeoTube*)vol->GetShape())->GetRmin();
1553 float max = ((TGeoTube*)vol->GetShape())->GetRmax();
1563 TGeoVolume *vol = gGeoManager->FindVolumeFast(
"BarrelECal_vol");
1565 vol = gGeoManager->FindVolumeFast(
"volBarrelECal");
1579 TGeoVolume *vol_pv = gGeoManager->FindVolumeFast(
"PVEndcap_vol");
1581 vol_pv = gGeoManager->FindVolumeFast(
"volPVEndcap");
1585 TGeoVolume *vol_tpc_chamber = gGeoManager->FindVolumeFast(
"volGArTPC");
1586 if(!vol_tpc_chamber)
return false;
1589 fECALEndcapStartX = ((TGeoBBox*)vol_pv->GetShape())->GetDZ()*2 + ((TGeoBBox*)vol_tpc_chamber->GetShape())->GetDZ();
1591 TGeoVolume *vol_tpc_chamber = gGeoManager->FindVolumeFast(
"volGArTPC");
1592 if(!vol_tpc_chamber)
return false;
1605 TGeoVolume *vol_e = gGeoManager->FindVolumeFast(
"EndcapECal_vol");
1607 vol_e = gGeoManager->FindVolumeFast(
"volEndcapECal");
1628 if(det.compare(
"ECAL") == 0)
1631 if(det.compare(
"TrackerSc") == 0)
1634 if(det.compare(
"MuID") == 0)
1657 for(
unsigned int i = 0; i <
GetNLayers(
"ECAL"); i++)
1659 float nRadiationLengths = 0.;
1660 float nInteractionLengths = 0.;
1661 float thickness_sum = 0.;
1662 float layer_thickness = 0.;
1663 float abs_thickness = 0.;
1671 TGeoVolume *volLayer = gGeoManager->FindVolumeFast(
TString::Format(
"BarrelECal_stave01_module01_layer_%02i_vol", i+1));
1675 for(
int islice = 0; islice < volLayer->GetNdaughters(); islice++)
1677 TGeoVolume *slice = volLayer->GetNode(islice)->GetVolume();
1678 TGeoMaterial *mat = slice->GetMaterial();
1679 double rad_len = mat->GetRadLen();
1680 double int_len = mat->GetIntLen();
1681 const char *
material = mat->GetName();
1683 double slice_thickness = ((TGeoBBox*)slice->GetShape())->GetDZ();
1685 nRadiationLengths += slice_thickness/rad_len;
1686 nInteractionLengths += slice_thickness/int_len;
1687 thickness_sum += slice_thickness;
1688 layer_thickness += slice_thickness;
1690 MF_LOG_DEBUG(
"GeometryCore::FindECALLayeredCalorimeterData")
1691 <<
" Slice " << islice
1692 <<
" RadLen " << nRadiationLengths
1693 <<
" IntLen " << nInteractionLengths
1694 <<
" ThicknessSum " << thickness_sum
1695 <<
" Material " << mat->GetName();
1697 if(
strcmp(material,
"Copper") == 0 ||
strcmp(material,
"Steel") == 0 ||
strcmp(material,
"Lead") == 0) {
1698 abs_thickness += slice_thickness * 2;
1701 if(
strcmp(material,
"Scintillator") == 0) {
1707 nRadiationLengths = 0.;
1708 nInteractionLengths = 0.;
1712 nRadiationLengths += slice_thickness/rad_len;
1713 nInteractionLengths += slice_thickness/int_len;
1714 thickness_sum += slice_thickness;
1715 layer_thickness += slice_thickness;
1742 for(
unsigned int i = 0; i <
GetNLayers(
"ECAL"); i++)
1744 float nRadiationLengths = 0.;
1745 float nInteractionLengths = 0.;
1746 float thickness_sum = 0.;
1747 float layer_thickness = 0.;
1748 float abs_thickness = 0.;
1756 TGeoVolume *volLayer = gGeoManager->FindVolumeFast(
TString::Format(
"EndcapECal_stave01_module00_layer_%02i_vol", i+1));
1760 for(
int islice = 0; islice < volLayer->GetNdaughters(); islice++)
1762 TGeoVolume *slice = volLayer->GetNode(islice)->GetVolume();
1763 TGeoMaterial *mat = slice->GetMaterial();
1764 double rad_len = mat->GetRadLen();
1765 double int_len = mat->GetIntLen();
1766 const char *
material = mat->GetName();
1768 double slice_thickness = ((TGeoBBox*)slice->GetShape())->GetDZ();
1770 nRadiationLengths += slice_thickness/rad_len;
1771 nInteractionLengths += slice_thickness/int_len;
1772 thickness_sum += slice_thickness;
1773 layer_thickness += slice_thickness;
1775 MF_LOG_DEBUG(
"GeometryCore::FindECALLayeredCalorimeterData")
1776 <<
" Slice " << islice
1777 <<
" RadLen " << nRadiationLengths
1778 <<
" IntLen " << nInteractionLengths
1779 <<
" ThicknessSum " << thickness_sum
1780 <<
" Material " << mat->GetName();
1782 if(
strcmp(material,
"Copper") == 0 ||
strcmp(material,
"Steel") == 0 ||
strcmp(material,
"Lead") == 0) {
1783 abs_thickness += slice_thickness * 2;
1786 if(
strcmp(material,
"Scintillator") == 0) {
1792 nRadiationLengths = 0.;
1793 nInteractionLengths = 0.;
1797 nRadiationLengths += slice_thickness/rad_len;
1798 nInteractionLengths += slice_thickness/int_len;
1799 thickness_sum += slice_thickness;
1800 layer_thickness += slice_thickness;
1819 TGeoVolume *vol = gGeoManager->FindVolumeFast(
"YokeBarrel_vol");
1821 vol = gGeoManager->FindVolumeFast(
"volYokeBarrel");
1825 fMuIDRinner = ((TGeoPgon*)vol->GetShape())->GetRmin(0);
1833 TGeoVolume *vol = gGeoManager->FindVolumeFast(
"YokeBarrel_vol");
1835 vol = gGeoManager->FindVolumeFast(
"volYokeBarrel");
1839 fMuIDRouter = ((TGeoPgon*)vol->GetShape())->GetRmax(0);
1847 TGeoVolume *vol = gGeoManager->FindVolumeFast(
"YokeBarrel_vol");
1849 vol = gGeoManager->FindVolumeFast(
"volYokeBarrel");
1870 std::vector<TGeoNode const*> path = this->
FindVolumePath(
"volTracker");
1871 if(path.size() == 0)
1874 const TGeoNode *Tracker_node = path.at(path.size()-1);
1875 if(Tracker_node ==
nullptr) {
1876 std::cout <<
"Cannot find node volTracker_0" <<
std::endl;
1880 TGeoMatrix *mat = Tracker_node->GetMatrix();
1881 const double *
origin = mat->GetTranslation();
1889 TGeoVolume *activeVol = Tracker_node->GetVolume();
1890 float rOuter = ((TGeoTube*)activeVol->GetShape())->GetRmax();
1893 fGArLiteLength = 2.0 * ((TGeoTube*)activeVol->GetShape())->GetDZ();
1995 if (current_path.empty())
return *
this;
1996 if (current_path.size() == 1) { current_path.pop_back();
return *
this; }
2002 if (++(current.
sibling) < parent.
self->GetNdaughters()) {
2005 reach_deepest_descendant();
2007 else current_path.pop_back();
2015 std::vector<TGeoNode const*> node_path(current_path.size());
2017 std::transform(current_path.begin(), current_path.end(), node_path.begin(),
2018 [](
NodeInfo_t const& node_info){
return node_info.self; });
2026 Node_t descendent = current_path.back().self;
2027 while (descendent->GetNdaughters() > 0) {
2028 descendent = descendent->GetDaughter(0);
2029 current_path.emplace_back(descendent, 0U);
2035 current_path.clear();
2036 if (!start_node)
return;
2037 current_path.emplace_back(start_node, 0U);
2038 reach_deepest_descendant();
std::vector< gar::geo::ChanWithPos > ChanWithNeighbors
TGeoNode * FindNode(T const &x, T const &y, T const &z) const
float GetActiveLArTPCHalfHeight() const
std::vector< TGeoNode const * > FindAllVolumes(std::set< std::string > const &vol_names) const
Returns all the nodes with volumes with any of the specified names.
bool fECALEndcapOutside
Is the ECAL Endcap outside the PV.
float GetActiveLArTPCZ() const
bool PointInDetEnclosure(TVector3 const &point) const
float GetEnclosureX() const
float GetEnclosureHalfWidth() const
bool MakeECALLayeredCalorimeterData()
std::pair< TVector3, TVector3 > GetStripEnds(const std::array< double, 3 > &point, const gar::raw::CellID_t &cID) const
float fMuIDRouter
Minimum radius of the MuID outer barrel.
bool FindActiveLArTPCVolume()
float fEnclosureHalfWidth
bool WorldToLocal(std::array< double, 3 > const &world, std::array< double, 3 > &local, gar::geo::LocalTransformation< TGeoHMatrix > &trans) const
float GetSensVolumeThickness(const TVector3 &point) const
float GetRockHalfWidth() const
double TotalMass(const char *vol="volWorld") const
double outer_nInteractionLengths
float GetMPDLength() const
float fTPCXCent
center of TPC: X
float fECALEndcapOuterX
Position of the end xplane of the ECAL endcap.
MinervaSegmentationAlgPtr fMinervaSegmentationAlg
Object containing the segmentation for the Sc Tracker.
const std::string GetMuIDCellIDEncoding() const
int GetECALInnerSymmetry() const
float GetOROCOuterRadius() const
ROOTGeoNodeForwardIterator & operator++()
Points to the next node, or to nullptr if there are no more.
bool HasLArTPCDetector() const
float GetActiveLArTPCHalfWidth() const
float fMuIDRinner
Minimum radius of the MuID inner barrel.
float GetRockLength() const
std::vector< TGeoNode const * > nodes
float GetMuIDInnerBarrelRadius() const
bool PointInECALEndcap(TVector3 const &point) const
double inner_nInteractionLengths
void FinalizeGeometryParameters()
bool FindECALOuterEndcapRadius()
int TPCNumDriftVols() const
Returns number of TPC drift volumes.
double getStripWidth(const std::array< double, 3 > &point) const
bool PointInLArTPC(TVector3 const &point) const
void StoreECALParameters()
bool PointInGArTPC(TVector3 const &point) const
float fPVThickness
Pressure Vessel thickness.
static bool format(QChar::Decomposition tag, QString &str, int index, int len)
NodeNameMatcherClass matcher
float GetLArTPCHalfWidth() const
bool PointInMPD(TVector3 const &point) const
float GArLiteLength() const
ECALSegmentationAlgPtr fECALSegmentationAlg
Object containing the segmentation for the ECAL.
static constexpr UndefinedPos_t undefined_pos
float GetOROCInnerRadius() const
float fTPCLength
length of the TPC
float TPCXCent() const
Returns the X location of the center of the TPC in cm.
std::vector< TGeoNode const * > FindVolumePath(std::string const &vol_name) const
Returns all the nodes with volumes with any of the specified names.
float GArLiteYCent() const
const std::array< double, 3 > FindShapeSize(const TGeoNode *node) const
float GetOROCPadHeightChangeRadius() const
double sensitive_thickness
gar::raw::CellID_t GetCellID(const TGeoNode *node, const unsigned int &det_id, const unsigned int &stave, const unsigned int &module, const unsigned int &layer, const unsigned int &slice, const std::array< double, 3 > &localPosition) const
bool fPointInWarnings
Generate warnings from failed inputs to PointIn* methods.
float GetECALOuterEndcapRadius() const
float fTPCRadius
Radius of the TPC.
bool HasEnclosure() const
double getStripLength(const std::array< double, 3 > &point, const gar::raw::CellID_t &cID) const
bool FindActiveTPCVolume()
bool HasGasTPCDetector() const
float GetPVThickness() const
bool PointInWorld(TVector3 const &point) const
float GetMuIDInnerAngle() const
bool FindTrackerScVolume()
float fLArTPCActiveHalfWidth
float fECALRouter
Minimum radius of the ECAL outer barrel.
std::string fROOTfile
path to geometry file for geometry in GeometryCore
void LoadGeometryFile(std::string const &gdmlfile, std::string const &rootfile, bool bForceReload=false)
Loads the geometry information from the specified files.
float fECALEndcapStartX
Position of the start xplane of the ECAL endcap.
float GetECALInnerAngle() const
std::enable_if_t< std::is_arithmetic_v< T >, T > hypot(T x, T y)
double MassBetweenPoints(double *p1, double *p2) const
Return the column density between two points.
double getTileSize(const std::array< double, 3 > &point) const
unsigned int fTrackerScnPlanes
void WorldBox(float *xlo, float *xhi, float *ylo, float *yhi, float *zlo, float *zhi) const
Fills the arguments with the boundaries of the world.
bool FindMuIDInnerSymmetry()
void NearestChannelInfo(float const *xyz, gar::geo::ChanWithNeighbors &cwn) const
bool isTile(const std::array< double, 3 > &point, const gar::raw::CellID_t &cID) const
static constexpr EndPos_t end_pos
void ApplyMinervaSegmentationAlg(std::shared_ptr< gar::geo::seg::SegmentationAlg > pMinervaSegmentationAlg)
std::array< double, 3 > GetPosition(const TGeoNode *node, const gar::raw::CellID_t &cID) const
void StoreECALNodes(std::map< std::string, std::vector< const TGeoNode * >> &map) const
unsigned int NearestChannel(float const worldLoc[3]) const
Returns the ID of the channel nearest to the specified position.
float GetECALBarrelApothemLength() const
bool FindECALEndcapStartX()
double outer_nRadiationLengths
const std::string MaterialName(TVector3 const &point)
Name of the deepest material containing the point xyz.
float fLArTPCActiveLength
bool FindECALInnerSymmetry()
float TPCRadius() const
Returns the radius of the TPC (y or z direction)
constexpr ProductStatus unknown() noexcept
std::vector< std::vector< TGeoNode const * > > paths
bool FindECALInnerBarrelRadius()
float GetECALInnerEndcapRadius() const
unsigned int fECALnLayers
number of ECAL layers from the seg algorithm
ECALLayeredCalorimeterData fECALLayeredCalorimeterData
std::string fDetectorName
Name of the detector.
std::vector< TGeoNode const * > get_path() const
Returns the full path of the current node.
NodeNameMatcherClass(std::set< std::string > const &names)
static constexpr BeginPos_t begin_pos
bool LocalToWorld(std::array< double, 3 > const &local, std::array< double, 3 > &world, gar::geo::LocalTransformation< TGeoHMatrix > const &trans) const
float GetActiveLArTPCLength() const
TGeoManager * ROOTGeoManager() const
Access to the ROOT geometry description manager.
bool FindTrackerScnPlanes()
void StoreOtherParameters()
void ApplyChannelMap(std::shared_ptr< gar::geo::seg::ChannelMapAlg > pChannelMap)
Initializes the geometry to work with this channel map.
float TPCZCent() const
Returns the Z location of the center of the TPC in cm.
float fTPCYCent
center of TPC: Y
float GetRockHalfHeight() const
float GetEnclosureZ() const
void PrintGeometry() const
Iterator to navigate through all the nodes.
float fECALRinner
Minimum radius of the ECAL inner barrel.
bool HasTrackerScDetector() const
float GetWorldHalfHeight() const
bool PointInECALBarrel(TVector3 const &point) const
unsigned int fMuIDnLayers
number of MuID layers from the seg algorithm
CollectNodesByName(std::set< std::string > const &names)
bool FindFirstVolume(std::string const &name, std::vector< const TGeoNode * > &path) const
int fTPCNumDriftVols
2 if standard ALICE detector, 1 if single drift vol
static int max(int a, int b)
bool FindMuIDInnerBarrelRadius()
float GetWorldLength() const
int fECALSymmetry
Number of sides of the Barrel.
#define MF_LOG_INFO(category)
MuIDSegmentationAlgPtr fMuIDSegmentationAlg
Object containing the segmentation for the Sc Tracker.
void reach_deepest_descendant()
float GetEnclosureHalfHeight() const
void init(TGeoNode const *start_node)
float GetIROCOuterRadius() const
float GetIROCInnerRadius() const
radii query methods passing through to the channel map algorithm
float GetECALEndcapStartX() const
float GetMuIDOuterBarrelRadius() const
float GetActiveLArTPCY() const
int fMuIDSymmetry
Number of sides of the MuID Barrel.
float GetECALEndcapApothemLength() const
float GetECALOuterBarrelRadius() const
float GetMuIDBarrelSideLength() const
unsigned int GapChannelNumber() const
Returns the ID of the channel representing a gap if you call NearestChannel and get this channel numb...
General GArSoft Utilities.
bool HasECALDetector() const
std::map< std::string, std::vector< const TGeoNode * > > fECALNodePath
Stored map of vectors of nodes for the ecal to speedup node searching.
bool FindECALEndcapOuterX()
void ApplyMuIDSegmentationAlg(std::shared_ptr< gar::geo::seg::SegmentationAlg > pMuIDSegmentationAlg)
float fLArTPCActiveHalfHeight
float GetEnclosureY() const
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
GeometryCore(fhicl::ParameterSet const &pset)
Initialize geometry from a given configuration.
bool FindMuIDOuterBarrelRadius()
float GArLiteXCent() const
int strcmp(const String &s1, const String &s2)
bool FindEnclosureVolume()
~GeometryCore()
Destructor.
void GetGeometryParameters()
void ClearGeometry()
Deletes the detector geometry structures.
double inner_nRadiationLengths
float TPCYCent() const
Returns the Y location of the center of the TPC in cm.
float GetEnclosureLength() const
void ApplyECALSegmentationAlg(std::shared_ptr< gar::geo::seg::SegmentationAlg > pECALSegmentationAlg)
std::set< std::string > const * vol_names
bool HasMuonDetector() const
const std::string GetECALCellIDEncoding() const
std::vector< std::vector< TGeoNode const * > > FindAllVolumePaths(std::set< std::string > const &vol_names) const
Returns paths of all nodes with volumes with the specified names.
float GetMuIDBarrelApothemLength() const
std::array< double, 3 > ReconstructStripHitPosition(const std::array< double, 3 > &point, const std::array< double, 3 > &local, const float &xlocal, const gar::raw::CellID_t &cID) const
float GetMPDHalfHeight() const
float GetECALInnerBarrelRadius() const
float GetLArTPCLength() const
const std::string GetMinervaCellIDEncoding() const
std::string fGDMLfile
path to geometry file used for Geant4 simulation
float fTPCZCent
center of TPC: Z
float TPCLength() const
Returns the length of the TPC (x direction)
CollectPathsByName(std::set< std::string > const &names)
const std::string VolumeName(TVector3 const &point) const
Returns the name of the deepest volume containing specified point.
std::pair< float, float > CalculateLightPropagation(const std::array< double, 3 > &point, const std::array< double, 3 > &local, const gar::raw::CellID_t &cID) const
bool FindECALOuterBarrelRadius()
static std::vector< std::string > const names
auto const & get(AssnsNode< L, R, D > const &r)
#define MF_LOG_WARNING(category)
float GetECALBarrelSideLength() const
Structures to distinguish the constructors.
unsigned int NChannels() const
float fEnclosureHalfHeight
LArSoft geometry interface.
int GetMuIDInnerSymmetry() const
ChannelMapPtr fChannelMapAlg
Object containing the channel to wire mapping.
void ChannelToPosition(unsigned int const channel, float *const worldLoc) const
void StoreMuIDParameters()
float GetActiveLArTPCX() const
unsigned int GetNLayers(std::string det) const
float GetMPDHalfWidth() const
NodeNameMatcherClass matcher
def parent(G, child, parent_type)
void GetDetectorsPresent()
bool fHasTrackerScDetector
constexpr Point origin()
Returns a origin position with a point of the specified type.
cet::coded_exception< error, detail::translate > exception
bool FindECALInnerEndcapRadius()
QTextStream & endl(QTextStream &s)
float GetECALEndcapOuterX() const
float GetLArTPCHalfHeight() const
float GetWorldHalfWidth() const
void StoreTPCParameters()
float GArLiteRadius() const
float GetECALEndcapSideLength() const
float GArLiteZCent() const
LayeredCalorimeterStruct LayeredCalorimeterData