Skip to content

Commit

Permalink
Revert "Revert "Merge pull request #38 from knoepfel/geom-iterator-in…
Browse files Browse the repository at this point in the history
…terface" as this requires larsoft v09_65_00, not yet availavble in sbndcode/icaruscode"

This reverts commit cfc3229. Requisite changes now made in sbnd/icaruscode.`
  • Loading branch information
chilge committed Mar 29, 2023
1 parent 1672ac5 commit 14907b7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 24 deletions.
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

0 comments on commit 14907b7

Please sign in to comment.