Skip to content

Commit

Permalink
Accommodate geometry-refactoring changes
Browse files Browse the repository at this point in the history
  • Loading branch information
knoepfel committed Jun 4, 2024
1 parent 6affcbb commit 77c3a5e
Show file tree
Hide file tree
Showing 82 changed files with 922 additions and 1,387 deletions.
28 changes: 12 additions & 16 deletions sbndcode/AnalysisTree/AnalysisTree_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3677,17 +3677,15 @@ bool sbnd::AnalysisTree::TrackIdToMCTruth( Int_t const trkID, art::Ptr<simb::MCT
double sbnd::AnalysisTree::bdist(const recob::Track::Point_t& pos)
{
// Get geometry.
art::ServiceHandle<geo::Geometry> geom;

geo::TPCGeo const& tpc = art::ServiceHandle<geo::Geometry>()->TPC({0, 0});
double d1 = pos.X(); // Distance to right side (wires).
double d2 = 2.*geom->DetHalfWidth() - pos.X(); // Distance to left side (cathode).
double d3 = pos.Y() + geom->DetHalfHeight(); // Distance to bottom.
double d4 = geom->DetHalfHeight() - pos.Y(); // Distance to top.
double d2 = 2.*tpc.HalfWidth() - pos.X(); // Distance to left side (cathode).
double d3 = pos.Y() + tpc.HalfHeight(); // Distance to bottom.
double d4 = tpc.HalfHeight() - pos.Y(); // Distance to top.
double d5 = pos.Z(); // Distance to front.
double d6 = geom->DetLength() - pos.Z(); // Distance to back.
double d6 = tpc.Length() - pos.Z(); // Distance to back.

double result = std::min(std::min(std::min(std::min(std::min(d1, d2), d3), d4), d5), d6);
return result;
return std::min({d1, d2, d3, d4, d5, d6});
}


Expand All @@ -3701,16 +3699,14 @@ double sbnd::AnalysisTree::length(const recob::Track& track)
// Length of MC particle, trajectory by trajectory.
double sbnd::AnalysisTree::length(const simb::MCParticle& part, TVector3& start, TVector3& end)
{
// Get geometry.
art::ServiceHandle<geo::Geometry> geom;

// Get active volume boundary.
double xmin = -2.0 * geom->DetHalfWidth() - 1e-8;
double xmax = 2.0 * geom->DetHalfWidth() + 1e-8;
double ymin = -geom->DetHalfHeight() -1e-8;
double ymax = geom->DetHalfHeight() + 1e-8;
geo::TPCGeo const& tpc = art::ServiceHandle<geo::Geometry>()->TPC({0, 0});
double xmin = -2.0 * tpc.HalfWidth() - 1e-8;
double xmax = 2.0 * tpc.HalfWidth() + 1e-8;
double ymin = -tpc.HalfHeight() -1e-8;
double ymax = tpc.HalfHeight() + 1e-8;
double zmin = 0. -1e-8;
double zmax = geom->DetLength() + 1e-8;
double zmax = tpc.Length() + 1e-8;

// Get number traj points
int n = part.NumberTrajectoryPoints();
Expand Down
1 change: 0 additions & 1 deletion sbndcode/AnalysisTree/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ set( MODULE_LIBRARIES larcorealg::Geometry
lardata::RecoObjects
larpandora::LArPandoraInterface
sbndcode_CRTUtils
sbndcode_CRT
sbnobj::Common_CRT
nusimdata::SimulationBase
art::Framework_Core
Expand Down
73 changes: 31 additions & 42 deletions sbndcode/CRT/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,37 @@ add_subdirectory(CRTSimulation)
add_subdirectory(CRTTPCMatching)
add_subdirectory(CRTUtils)

art_make(
EXCLUDE
CRTChannelMapAlg.cxx
CRTGeometryHelper_service.cc
LIBRARY_NAME
sbndcode_CRTData
LIB_LIBRARIES
larcorealg::Geometry
larcore::Geometry_Geometry_service
lardataobj::RecoBase
art::Framework_Core
art::Framework_IO_Sources
art::Framework_Principal
canvas::canvas
art::Framework_Services_Registry
messagefacility::MF_MessageLogger

fhiclcpp::fhiclcpp
ROOT::Core
ROOT::Geom
cetlib::cetlib
)

art_make_library(
SOURCE CRTChannelMapAlg.cxx
LIBRARIES
larcorealg::Geometry
sbndcode_CRTData
cetlib_except::cetlib_except
messagefacility::MF_MessageLogger
fhiclcpp::fhiclcpp
ROOT::Core
ROOT::Geom
cetlib::cetlib
SOURCE
CRTGeoObjectSorter.cxx
LIBRARY_NAME
sbndcode_CRTData
LIBRARIES
larcorealg::Geometry
larcore::Geometry_Geometry_service
lardataobj::RecoBase
art::Framework_Core
art::Framework_IO_Sources
art::Framework_Principal
canvas::canvas
art::Framework_Services_Registry
messagefacility::MF_MessageLogger
fhiclcpp::fhiclcpp
ROOT::Core
ROOT::Geom
cetlib::cetlib
)
simple_plugin(
CRTGeometryHelper service
sbndcode_CRT
art::Framework_Core
art::Framework_IO_Sources
art::Framework_Principal
canvas::canvas
art::Framework_Services_Registry
messagefacility::MF_MessageLogger

cet_build_plugin( CRTAuxDetInitializer art::tool
LIBRARIES REG
larcorealg::Geometry
sbndcode_CRTData
cetlib_except::cetlib_except
messagefacility::MF_MessageLogger
fhiclcpp::fhiclcpp
cetlib::cetlib
)

install_headers()
install_fhicl()
install_source()
12 changes: 6 additions & 6 deletions sbndcode/CRT/CRTAna/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
art_make(
MODULE_LIBRARIES
ROOT::Tree
larsim::Utils
sbnobj::SBND_CRT
sbndcode_GeoWrappers
sbndcode_CRT_CRTBackTracker
MODULE_LIBRARIES
ROOT::Tree
larsim::Utils
sbnobj::SBND_CRT
sbndcode_GeoWrappers
sbndcode_CRT_CRTBackTracker
)

install_fhicl()
64 changes: 64 additions & 0 deletions sbndcode/CRT/CRTAuxDetInitializer_tool.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#include "larcorealg/Geometry/AuxDetGeo.h"
#include "larcorealg/Geometry/AuxDetSensitiveGeo.h"
#include "larcorealg/Geometry/AuxDetGeometryCore.h"

#include "art/Utilities/ToolMacros.h"

namespace {
class CRTAuxDetInitializer : public geo::AuxDetInitializer {
public:
explicit CRTAuxDetInitializer(fhicl::ParameterSet const&) {}

private:
geo::AuxDetReadoutInitializers
initialize(std::vector<geo::AuxDetGeo> const& adgeo) const override
{
geo::AuxDetReadoutInitializers result;
// Map the AuxDetGeo names to their position in the sorted vector
//
// Each tagger is composed of scintillator modules, composed of 16 strips.
// In the geometry, CRTStripArrays are AuxDets and CRTStrips are the
// AuxDetSensitives. Each strip has two SiPM channels, one per optical
// fiber (not in the geometry).
//
// 2x TaggerTop: (5x2 +5x2)x16 = 320 strips, 640 channels
// 2x TaggerSide: (4x2 +5x2)x16 = 288 strips, 576 channels
// 1x TaggerFace: (4x2 +4x2)x16 = 256 strips, 512 channels
// 1x TaggerFace: (4x2-1+4x2)x16 = 240 strips, 480 channels
// 1x TaggerBot: 34x16 = 544 strips, 1088 channels

for (size_t a=0; a<adgeo.size(); a++){
std::string volName(adgeo[a].TotalVolume()->GetName());

long unsigned int number_scintillating_strips = 0;

if (strncmp(((adgeo[a].TotalVolume())->GetShape())->GetName(), "CRTstripMINOSArray", 18) == 0) {
number_scintillating_strips = 20; //To account for the MINOS modules.
}
else {number_scintillating_strips = 16;}

size_t nsv = adgeo[a].NSensitiveVolume();
if (nsv != number_scintillating_strips) {
throw cet::exception("CRTChannelMap")
<< "Wrong number of sensitive volumes for CRT volume "
<< volName << " (got " << nsv << ", expected 16)" << std::endl;
}

result.ADGeoToName[a] = volName;
result.NameToADGeo[volName] = a;

if (volName.find("CRTStripArray") != std::string::npos) {
for (size_t svID=0; svID<number_scintillating_strips; svID++) {
for (size_t ich=0; ich<2; ich++) {
size_t chID = 2 * svID + ich;
result.ADGeoToChannelAndSV[a].push_back(std::make_pair(chID, svID));
}
}
}
}
return result;
}
};
}

DEFINE_ART_CLASS_TOOL(CRTAuxDetInitializer)
2 changes: 1 addition & 1 deletion sbndcode/CRT/CRTBackTracker/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ art_make_library(
SOURCE CRTBackTrackerAlg.cc
LIBRARIES
sbnobj::SBND_CRT
sbndcode_GeoWrappers
sbndcode::GeoWrappers
larsim::MCCheater_ParticleInventoryService_service
)

Expand Down
168 changes: 0 additions & 168 deletions sbndcode/CRT/CRTChannelMapAlg.cxx

This file was deleted.

Loading

0 comments on commit 77c3a5e

Please sign in to comment.