Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accommodate breaking changes in geometry #38

Merged
merged 1 commit into from
Dec 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 11 additions & 19 deletions sbnci/Common/Modules/MCRecoUtils/RecoUtils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,9 @@ int RecoUtils::TrueParticleIDFromTotalRecoHits(const detinfo::DetectorClocksData


bool RecoUtils::IsInsideTPC(TVector3 position, double distance_buffer){
double vtx[3] = {position.X(), position.Y(), position.Z()};
bool inside = false;
art::ServiceHandle<geo::Geometry> geom;
geo::TPCID idtpc = geom->FindTPCAtPosition(vtx);
geo::TPCID idtpc = geom->FindTPCAtPosition(geo::vect::toPoint(position));

if (geom->HasTPC(idtpc))
{
Expand All @@ -111,19 +110,14 @@ bool RecoUtils::IsInsideTPC(TVector3 position, double distance_buffer){
double miny = tpcgeo.MinY(); double maxy = tpcgeo.MaxY();
double minz = tpcgeo.MinZ(); double maxz = tpcgeo.MaxZ();

for (size_t c = 0; c < geom->Ncryostats(); c++)
for (auto const& tpcg : geom->Iterate<geo::TPCGeo>())
{
const geo::CryostatGeo& cryostat = geom->Cryostat(c);
for (size_t t = 0; t < cryostat.NTPC(); t++)
{
const geo::TPCGeo& tpcg = cryostat.TPC(t);
if (tpcg.MinX() < minx) minx = tpcg.MinX();
if (tpcg.MaxX() > maxx) maxx = tpcg.MaxX();
if (tpcg.MinY() < miny) miny = tpcg.MinY();
if (tpcg.MaxY() > maxy) maxy = tpcg.MaxY();
if (tpcg.MinZ() < minz) minz = tpcg.MinZ();
if (tpcg.MaxZ() > maxz) maxz = tpcg.MaxZ();
}
if (tpcg.MinX() < minx) minx = tpcg.MinX();
if (tpcg.MaxX() > maxx) maxx = tpcg.MaxX();
if (tpcg.MinY() < miny) miny = tpcg.MinY();
if (tpcg.MaxY() > maxy) maxy = tpcg.MaxY();
if (tpcg.MinZ() < minz) minz = tpcg.MinZ();
if (tpcg.MaxZ() > maxz) maxz = tpcg.MaxZ();
}

//x
Expand Down Expand Up @@ -339,7 +333,7 @@ std::map<geo::PlaneID,int> RecoUtils::NumberofHitsThatContainEnergyDepositedByTr

//Loop over the planes and create the initial PlaneMap
std::map<geo::PlaneID,int> HitPlaneMap;
for(geo::PlaneID plane_id: geom->IteratePlaneIDs()){HitPlaneMap[plane_id] = 0;}
for(geo::PlaneID plane_id: geom->Iterate<geo::PlaneID>()){HitPlaneMap[plane_id] = 0;}

//Loop over the hits and find the IDE
for (std::vector<art::Ptr<recob::Hit> >::const_iterator hitIt = hits.begin(); hitIt != hits.end(); ++hitIt) {
Expand All @@ -364,7 +358,7 @@ std::map<geo::PlaneID,int> RecoUtils::NumberofHitsThatContainEnergyDepositedByTr
//Loop over the planes and create the initial PlaneMap
art::ServiceHandle<geo::Geometry> geom;
std::map<geo::PlaneID,int> HitPlaneMap;
for(geo::PlaneID plane_id: geom->IteratePlaneIDs()){HitPlaneMap[plane_id] = 0;}
for(geo::PlaneID plane_id: geom->Iterate<geo::PlaneID>()){HitPlaneMap[plane_id] = 0;}

//Loop over the hits and find the IDE
for (std::vector<art::Ptr<recob::Hit> >::const_iterator hitIt = hits.begin(); hitIt != hits.end(); ++hitIt) {
Expand Down Expand Up @@ -394,7 +388,7 @@ std::map<geo::PlaneID,int> RecoUtils::NumberofMCWiresHit(int TrackID, const std:

int breaking_int = 0;

for(geo::PlaneID plane_id: geom->IteratePlaneIDs()){WirePlaneMap[plane_id] = 0;}
for(geo::PlaneID plane_id: geom->Iterate<geo::PlaneID>()){WirePlaneMap[plane_id] = 0;}

// Loop over SimChannel
for(size_t simch_index=0; simch_index<simchannels.size(); ++simch_index) {
Expand Down Expand Up @@ -618,5 +612,3 @@ float RecoUtils::TotalEnergyDepinHitsFromTrack(const detinfo::DetectorClocksData

return DepEnergy;
}


Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ void ana::ShowerValidation::analyze(const art::Event& evt) {
art::Handle<std::vector<recob::Hit> > hitListHandle;
std::vector<art::Ptr<recob::Hit> > hits;
for(auto const& fHitModuleLabel: fHitModuleLabels){

if(evt.getByLabel(fHitModuleLabel,hitListHandle)){
art::fill_ptr_vector(hits, hitListHandle);
}
Expand Down Expand Up @@ -613,7 +613,7 @@ void ana::ShowerValidation::analyze(const art::Event& evt) {
}

//Calculate how much energy was deposited in the hits
for(geo::PlaneID plane_id: geom->IteratePlaneIDs()){
for(geo::PlaneID plane_id: geom->Iterate<geo::PlaneID>()){

float TotalEnergyDepinHits = RecoUtils::TotalEnergyDepinHits(clockData, hits,plane_id.Plane);
float hitCompleteness = TotalEnergyDepinHits!=0 ? TotalEnergyDepinHits/TotalEnergyDeposited : -99999;
Expand Down Expand Up @@ -649,7 +649,7 @@ void ana::ShowerValidation::analyze(const art::Event& evt) {

art::Handle<std::vector<recob::PFParticle> > pfpListHandle;
std::vector<art::Ptr<recob::PFParticle> > pfps;

if(evt.getByLabel(fPFParticleLabel,pfpListHandle)){
art::fill_ptr_vector(pfps,pfpListHandle);
}
Expand Down Expand Up @@ -905,7 +905,7 @@ void ana::ShowerValidation::analyze(const art::Event& evt) {
//Calculate the true Energy deposited By Shower
for (auto const& daughter: showerMothers[ShowerTrackID]){
TrueEnergyDep_FromShower += MCTrack_Energy_map[daughter];
for(geo::PlaneID plane_id: geom->IteratePlaneIDs()){
for(geo::PlaneID plane_id: geom->Iterate<geo::PlaneID>()){
TrueHitDep_FromTrueShower += MCTrack_hit_map[showerhit_productid][daughter][plane_id];
}
}
Expand Down Expand Up @@ -1374,7 +1374,7 @@ void ana::ShowerValidation::analyze(const art::Event& evt) {
for (auto const& showermother: showerMothers){
int TrueHitDep_FromTrueShowers = 0;
for (auto const& track_id: showermother.second){
for(geo::PlaneID plane_id: geom->IteratePlaneIDs()){
for(geo::PlaneID plane_id: geom->Iterate<geo::PlaneID>()){
TrueHitDep_FromTrueShowers += MCTrack_hit_map[showerhit_productid][track_id][plane_id];
}
}
Expand Down