Skip to content

Commit 4b98180

Browse files
committed
Revert "Merge remote-tracking branch 'upstream/feature/geom' into feature/tjyang_cvnfix"
This reverts commit 1c310c8, reversing changes made to d22406f.
1 parent dcbc756 commit 4b98180

85 files changed

Lines changed: 1379 additions & 917 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

sbndcode/AnalysisTree/AnalysisTree_module.cc

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3677,15 +3677,17 @@ bool sbnd::AnalysisTree::TrackIdToMCTruth( Int_t const trkID, art::Ptr<simb::MCT
36773677
double sbnd::AnalysisTree::bdist(const recob::Track::Point_t& pos)
36783678
{
36793679
// Get geometry.
3680-
geo::TPCGeo const& tpc = art::ServiceHandle<geo::Geometry>()->TPC({0, 0});
3680+
art::ServiceHandle<geo::Geometry> geom;
3681+
36813682
double d1 = pos.X(); // Distance to right side (wires).
3682-
double d2 = 2.*tpc.HalfWidth() - pos.X(); // Distance to left side (cathode).
3683-
double d3 = pos.Y() + tpc.HalfHeight(); // Distance to bottom.
3684-
double d4 = tpc.HalfHeight() - pos.Y(); // Distance to top.
3683+
double d2 = 2.*geom->DetHalfWidth() - pos.X(); // Distance to left side (cathode).
3684+
double d3 = pos.Y() + geom->DetHalfHeight(); // Distance to bottom.
3685+
double d4 = geom->DetHalfHeight() - pos.Y(); // Distance to top.
36853686
double d5 = pos.Z(); // Distance to front.
3686-
double d6 = tpc.Length() - pos.Z(); // Distance to back.
3687+
double d6 = geom->DetLength() - pos.Z(); // Distance to back.
36873688

3688-
return std::min({d1, d2, d3, d4, d5, d6});
3689+
double result = std::min(std::min(std::min(std::min(std::min(d1, d2), d3), d4), d5), d6);
3690+
return result;
36893691
}
36903692

36913693

@@ -3699,14 +3701,16 @@ double sbnd::AnalysisTree::length(const recob::Track& track)
36993701
// Length of MC particle, trajectory by trajectory.
37003702
double sbnd::AnalysisTree::length(const simb::MCParticle& part, TVector3& start, TVector3& end)
37013703
{
3704+
// Get geometry.
3705+
art::ServiceHandle<geo::Geometry> geom;
3706+
37023707
// Get active volume boundary.
3703-
geo::TPCGeo const& tpc = art::ServiceHandle<geo::Geometry>()->TPC({0, 0});
3704-
double xmin = -2.0 * tpc.HalfWidth() - 1e-8;
3705-
double xmax = 2.0 * tpc.HalfWidth() + 1e-8;
3706-
double ymin = -tpc.HalfHeight() -1e-8;
3707-
double ymax = tpc.HalfHeight() + 1e-8;
3708+
double xmin = -2.0 * geom->DetHalfWidth() - 1e-8;
3709+
double xmax = 2.0 * geom->DetHalfWidth() + 1e-8;
3710+
double ymin = -geom->DetHalfHeight() -1e-8;
3711+
double ymax = geom->DetHalfHeight() + 1e-8;
37083712
double zmin = 0. -1e-8;
3709-
double zmax = tpc.Length() + 1e-8;
3713+
double zmax = geom->DetLength() + 1e-8;
37103714

37113715
// Get number traj points
37123716
int n = part.NumberTrajectoryPoints();

sbndcode/AnalysisTree/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ set( MODULE_LIBRARIES larcorealg::Geometry
1313
lardata::RecoObjects
1414
larpandora::LArPandoraInterface
1515
sbndcode_CRTUtils
16+
sbndcode_CRT
1617
sbnobj::Common_CRT
1718
nusimdata::SimulationBase
1819
art::Framework_Core

sbndcode/CRT/CMakeLists.txt

Lines changed: 42 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,48 @@ add_subdirectory(CRTSimulation)
66
add_subdirectory(CRTTPCMatching)
77
add_subdirectory(CRTUtils)
88

9-
art_make_library(
10-
SOURCE
11-
CRTGeoObjectSorter.cxx
12-
LIBRARY_NAME
13-
sbndcode_CRTData
14-
LIBRARIES
15-
larcorealg::Geometry
16-
larcore::Geometry_Geometry_service
17-
lardataobj::RecoBase
18-
art::Framework_Core
19-
art::Framework_IO_Sources
20-
art::Framework_Principal
21-
canvas::canvas
22-
art::Framework_Services_Registry
23-
messagefacility::MF_MessageLogger
24-
fhiclcpp::fhiclcpp
25-
ROOT::Core
26-
ROOT::Geom
27-
cetlib::cetlib
28-
)
9+
art_make(
10+
EXCLUDE
11+
CRTChannelMapAlg.cxx
12+
CRTGeometryHelper_service.cc
13+
LIBRARY_NAME
14+
sbndcode_CRTData
15+
LIB_LIBRARIES
16+
larcorealg::Geometry
17+
larcore::Geometry_Geometry_service
18+
lardataobj::RecoBase
19+
art::Framework_Core
20+
art::Framework_IO_Sources
21+
art::Framework_Principal
22+
canvas::canvas
23+
art::Framework_Services_Registry
24+
messagefacility::MF_MessageLogger
2925

30-
cet_build_plugin( CRTAuxDetInitializer art::tool
31-
LIBRARIES REG
32-
larcorealg::Geometry
33-
sbndcode_CRTData
34-
cetlib_except::cetlib_except
35-
messagefacility::MF_MessageLogger
36-
fhiclcpp::fhiclcpp
37-
cetlib::cetlib
26+
fhiclcpp::fhiclcpp
27+
ROOT::Core
28+
ROOT::Geom
29+
cetlib::cetlib
3830
)
3931

40-
install_headers()
41-
install_fhicl()
42-
install_source()
32+
art_make_library(
33+
SOURCE CRTChannelMapAlg.cxx
34+
LIBRARIES
35+
larcorealg::Geometry
36+
sbndcode_CRTData
37+
cetlib_except::cetlib_except
38+
messagefacility::MF_MessageLogger
39+
fhiclcpp::fhiclcpp
40+
ROOT::Core
41+
ROOT::Geom
42+
cetlib::cetlib
43+
)
44+
simple_plugin(
45+
CRTGeometryHelper service
46+
sbndcode_CRT
47+
art::Framework_Core
48+
art::Framework_IO_Sources
49+
art::Framework_Principal
50+
canvas::canvas
51+
art::Framework_Services_Registry
52+
messagefacility::MF_MessageLogger
53+
)

sbndcode/CRT/CRTAuxDetInitializer_tool.cc

Lines changed: 0 additions & 64 deletions
This file was deleted.

sbndcode/CRT/CRTBackTracker/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ art_make_library(
22
SOURCE CRTBackTrackerAlg.cc
33
LIBRARIES
44
sbnobj::SBND_CRT
5-
sbndcode::GeoWrappers
5+
sbndcode_GeoWrappers
66
larsim::MCCheater_ParticleInventoryService_service
77
)
88

sbndcode/CRT/CRTChannelMapAlg.cxx

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
///////////////////////////////////////////////////////////////////////////////
2+
/// \file CRTChannelMapAlg.cxx
3+
/// \brief Algorithm class for SBND auxiliary detector channel mapping
4+
///
5+
/// Ported from AuxDetChannelMapLArIATAlg.cxx (Author: brebel@fnal.gov)
6+
///
7+
/// \version $Id: $
8+
/// \author mastbaum@uchicago.edu
9+
///////////////////////////////////////////////////////////////////////////////
10+
11+
#include "art/Framework/Services/Registry/ServiceHandle.h"
12+
#include "messagefacility/MessageLogger/MessageLogger.h"
13+
#include "larcorealg/Geometry/AuxDetGeo.h"
14+
#include "larcorealg/Geometry/AuxDetSensitiveGeo.h"
15+
#include "larcorealg/Geometry/AuxDetGeometryCore.h"
16+
#include "sbndcode/CRT/CRTChannelMapAlg.h"
17+
#include "TVector3.h"
18+
#include <iostream>
19+
#include <ostream>
20+
21+
namespace geo {
22+
23+
//---------------------------------------------------------------------------
24+
CRTChannelMapAlg::CRTChannelMapAlg(
25+
fhicl::ParameterSet const& p)
26+
: fSorter(geo::CRTGeoObjectSorter(p)) {}
27+
28+
//---------------------------------------------------------------------------
29+
void CRTChannelMapAlg::Initialize(AuxDetGeometryData_t& geodata) {
30+
Uninitialize();
31+
32+
std::vector<geo::AuxDetGeo>& adgeo = geodata.auxDets;
33+
34+
// Sort the AuxDetGeo objects and map them to names of the detectors
35+
//fSorter.SortAuxDets(adgeo);
36+
37+
// Map the AuxDetGeo names to their position in the sorted vector
38+
//
39+
// Each tagger is composed of scintillator modules, composed of 16 strips.
40+
// In the geometry, CRTStripArrays are AuxDets and CRTStrips are the
41+
// AuxDetSensitives. Each strip has two SiPM channels, one per optical
42+
// fiber (not in the geometry).
43+
//
44+
// 2x TaggerTop: (5x2 +5x2)x16 = 320 strips, 640 channels
45+
// 2x TaggerSide: (4x2 +5x2)x16 = 288 strips, 576 channels
46+
// 1x TaggerFace: (4x2 +4x2)x16 = 256 strips, 512 channels
47+
// 1x TaggerFace: (4x2-1+4x2)x16 = 240 strips, 480 channels
48+
// 1x TaggerBot: 34x16 = 544 strips, 1088 channels
49+
50+
fADGeoToName.clear();
51+
fADGeoToChannelAndSV.clear();
52+
53+
for (size_t a=0; a<adgeo.size(); a++){
54+
std::string volName(adgeo[a].TotalVolume()->GetName());
55+
56+
long unsigned int number_scintillating_strips = 0;
57+
58+
if (strncmp(((adgeo[a].TotalVolume())->GetShape())->GetName(), "CRTstripMINOSArray", 18) == 0) {
59+
number_scintillating_strips = 20; //To account for the MINOS modules.
60+
}
61+
else {number_scintillating_strips = 16;}
62+
63+
size_t nsv = adgeo[a].NSensitiveVolume();
64+
if (nsv != number_scintillating_strips) {
65+
throw cet::exception("CRTChannelMap")
66+
<< "Wrong number of sensitive volumes for CRT volume "
67+
<< volName << " (got " << nsv << ", expected 16)" << std::endl;
68+
}
69+
70+
fADGeoToName[a] = volName;
71+
fNameToADGeo[volName] = a;
72+
73+
if (volName.find("CRTStripArray") != std::string::npos) {
74+
for (size_t svID=0; svID<number_scintillating_strips; svID++) {
75+
for (size_t ich=0; ich<2; ich++) {
76+
size_t chID = 2 * svID + ich;
77+
fADGeoToChannelAndSV[a].push_back(std::make_pair(chID, svID));
78+
}
79+
}
80+
}
81+
}
82+
}
83+
84+
//----------------------------------------------------------------------------
85+
void CRTChannelMapAlg::Uninitialize() {}
86+
87+
//----------------------------------------------------------------------------
88+
uint32_t CRTChannelMapAlg::PositionToAuxDetChannel(
89+
Point_t const& worldLoc,
90+
std::vector<geo::AuxDetGeo> const& auxDets,
91+
size_t& ad,
92+
size_t& sv) const {
93+
94+
// Set the default to be that we don't find the position in any AuxDet
95+
uint32_t channel = UINT_MAX;
96+
97+
// Figure out which detector we are in
98+
ad = 0;
99+
sv = this->NearestSensitiveAuxDet(worldLoc, auxDets, ad, 0.0001);
100+
101+
// Check to see which AuxDet this position corresponds to
102+
auto gnItr = fADGeoToName.find(ad);
103+
if (gnItr != fADGeoToName.end()){
104+
// Get the vector of channel and sensitive volume pairs
105+
auto csvItr = fADGeoToChannelAndSV.find(ad);
106+
107+
if (csvItr == fADGeoToChannelAndSV.end()) {
108+
throw cet::exception("CRTChannelMapAlg")
109+
<< "No entry in channel and sensitive volume map for AuxDet index "
110+
<< ad;
111+
}
112+
113+
// N.B. This is the ID on the nth channel, and the strip has n and n+1
114+
channel = 2 * sv + 0;
115+
}
116+
117+
if (channel == UINT_MAX) {
118+
mf::LogDebug("CRTChannelMapAlg") << "Can't find AuxDet for position ("
119+
<< worldLoc.X() << ","
120+
<< worldLoc.Y() << ","
121+
<< worldLoc.Z()
122+
<< ")\n";
123+
}
124+
125+
return channel;
126+
}
127+
128+
//----------------------------------------------------------------------------
129+
Point_t CRTChannelMapAlg::AuxDetChannelToPosition(
130+
uint32_t const channel,
131+
std::string const& auxDetName,
132+
std::vector<geo::AuxDetGeo> const& auxDets) const {
133+
134+
std::cout << "CRTChannelMapAlg::AuxDetChannelToPosition" << std::endl;
135+
136+
// Figure out which detector we are in
137+
size_t ad = UINT_MAX;
138+
if (fNameToADGeo.count(auxDetName) > 0) {
139+
ad = fNameToADGeo.find(auxDetName)->second;
140+
}
141+
else {
142+
throw cet::exception("CRTChannelMapAlg")
143+
<< "No AuxDetGeo with name " << auxDetName;
144+
}
145+
146+
// Get the vector of channel and sensitive volume pairs
147+
auto csvItr = fADGeoToChannelAndSV.find(ad);
148+
149+
if (csvItr == fADGeoToChannelAndSV.end()) {
150+
throw cet::exception("CRTChannelMapAlg")
151+
<< "No entry in channel and sensitive volume"
152+
<< " map for AuxDet index " << ad << " bail";
153+
}
154+
155+
// Loop over the vector of channel and sensitive volumes to determine the
156+
// sensitive volume for this channel. Then get the origin of the sensitive
157+
// volume in the world coordinate system.
158+
for (auto csv : csvItr->second) {
159+
if (csv.first == channel) {
160+
// Get the center of the sensitive volume for this channel
161+
return auxDets[ad].SensitiveVolume(csv.second).GetCenter();
162+
}
163+
}
164+
165+
return {};
166+
}
167+
168+
} // namespace geo

0 commit comments

Comments
 (0)