Skip to content
Closed
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
cee3459
initial development
sophieMu2e Nov 25, 2025
9162348
added new Kinkal vols
sophieMu2e Nov 25, 2025
3b9699e
added many surfaces, need positions
sophieMu2e Nov 25, 2025
8219beb
updated coords
sophieMu2e Nov 25, 2025
20c7dc8
updated surfaces
sophieMu2e Nov 25, 2025
0a5a985
builds
sophieMu2e Nov 25, 2025
10d9916
compiles
sophieMu2e Nov 26, 2025
5525394
prints out, not tested
sophieMu2e Nov 26, 2025
a5e9665
added surface steps from front and back of calo
sophieMu2e Dec 1, 2025
7c5bb42
added
sophieMu2e Dec 1, 2025
556b4cf
works
sophieMu2e Dec 1, 2025
1d47bee
autoplay
sophieMu2e Dec 1, 2025
23ab8d1
updated Calo
sophieMu2e Jan 20, 2026
959d8f6
Merge branch 'main' of github.com:Mu2e/Offline into interdet
sophieMu2e Jan 26, 2026
2610df8
removed
sophieMu2e Mar 12, 2026
7b108ae
surface id
sophieMu2e Apr 9, 2026
1ef11f8
Merge branch 'main' of github.com:Mu2e/Offline into interdet
sophieMu2e Apr 22, 2026
a04f426
merged daves code, integrated and adapted calo
sophieMu2e Apr 22, 2026
67899a5
works with geom service
sophieMu2e Apr 23, 2026
08e83c4
fixed the calo front
sophieMu2e Apr 23, 2026
d99b486
seems to work
sophieMu2e Apr 23, 2026
7564a99
calo intersections in correct location - calo mother
sophieMu2e Apr 24, 2026
22ed712
tested with central helix
sophieMu2e Apr 24, 2026
28174e8
added code
sophieMu2e Apr 24, 2026
26cdc86
merged main
sophieMu2e Apr 28, 2026
fedf7fe
merged
sophieMu2e Apr 28, 2026
5aba283
merged
sophieMu2e Apr 28, 2026
e1d169e
builds with merge
sophieMu2e Apr 28, 2026
9b47730
remvoed old module
sophieMu2e Apr 30, 2026
f7baeaf
solved major issues
May 6, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion CommonMC/src/MakeSurfaceSteps_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,20 @@ namespace mu2e {
vdmap_[VirtualDetectorId(VirtualDetectorId::TT_Back)] = SurfaceId("TT_Back");
vdmap_[VirtualDetectorId(VirtualDetectorId::TT_OutSurf)] = SurfaceId("TT_Outer");
vdmap_[VirtualDetectorId(VirtualDetectorId::TT_InSurf)] = SurfaceId("TT_Inner");
}

vdmap_[VirtualDetectorId(VirtualDetectorId::EMC_Disk_0_SurfIn)] = SurfaceId("EMC_Disk_0_Front");
vdmap_[VirtualDetectorId(VirtualDetectorId::EMC_Disk_1_SurfIn)] = SurfaceId("EMC_Disk_1_Front");
vdmap_[VirtualDetectorId(VirtualDetectorId::EMC_Disk_0_SurfOut)] = SurfaceId("EMC_Disk_0_Back");
vdmap_[VirtualDetectorId(VirtualDetectorId::EMC_Disk_1_SurfOut)] = SurfaceId("EMC_Disk_1_Back");

vdmap_[VirtualDetectorId(VirtualDetectorId::EMC_Disk_0_EdgeIn)] = SurfaceId("EMC_Disk_0_Inner");
vdmap_[VirtualDetectorId(VirtualDetectorId::EMC_Disk_1_EdgeIn)] = SurfaceId("EMC_Disk_1_Inner");
vdmap_[VirtualDetectorId(VirtualDetectorId::EMC_Disk_0_EdgeOut)] = SurfaceId("EMC_Disk_0_Outer");
vdmap_[VirtualDetectorId(VirtualDetectorId::EMC_Disk_1_EdgeOut)] = SurfaceId("EMC_Disk_1_Outer");
}

void MakeSurfaceSteps::produce(art::Event& event) {
std::cout<<"MakeSurfaceSteps ---> produce"<<std::endl;
GeomHandle<DetectorSystem> det;
// create output
std::unique_ptr<SurfaceStepCollection> ssc(new SurfaceStepCollection);
Expand All @@ -72,6 +83,7 @@ namespace mu2e {
for(auto const& vdspmc : vdspmccol) {
// only some VDs are kept
auto isid = vdmap_.find(vdspmc.virtualDetectorId());
std::cout<<" VID "<<vdspmc.virtualDetectorId().name()<<std::endl;
Comment thread
sophiemiddleton marked this conversation as resolved.
Outdated
if(isid != vdmap_.end())ssc->emplace_back(isid->second,vdspmc,det); // no aggregation of VD hits
}
auto nvdsteps = ssc->size();
Expand Down
7 changes: 5 additions & 2 deletions DataProducts/inc/SurfaceId.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ namespace mu2e {
IPA=90, IPA_Front, IPA_Back,
OPA=95, TSDA, // Absorbers in the DS
ST_Front=100,ST_Back, ST_Inner, ST_Outer, ST_Foils, ST_Wires, // stopping target bounding surfaces and components
TCRV=200 // CRV test planes
TCRV=200, // CRV test planes
EMC_Disk_0_Outer = 300, EMC_Disk_0_Inner, EMC_Disk_1_Inner, EMC_Disk_1_Outer,
EMC_Disk_0_Front, EMC_Disk_1_Front, EMC_Disk_0_Back, EMC_Disk_1_Back

};

static std::string const& typeName();
Expand All @@ -38,7 +41,7 @@ namespace mu2e {
// forward some accessors
auto const& id() const { return sid_; }
int index() const { return index_; }
auto const& name() const { return sid_.name(); }
auto const& name() const { return sid_.name();}

bool indexMatch(SurfaceId const& other) const { return index_ == other.index_ || index_ < 0 || other.index_ < 0; }
bool indexCompare(SurfaceId const& other) const { return index_<0 || other.index_ < 0 ? false : index_ < other.index_; }
Expand Down
11 changes: 10 additions & 1 deletion DataProducts/src/SurfaceId.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,16 @@ namespace mu2e {
std::make_pair(SurfaceIdEnum::ST_Inner, "ST_Inner"),
std::make_pair(SurfaceIdEnum::ST_Outer, "ST_Outer"),
std::make_pair(SurfaceIdEnum::ST_Foils, "ST_Foils"),
std::make_pair(SurfaceIdEnum::TCRV, "TCRV")
std::make_pair(SurfaceIdEnum::TCRV, "TCRV"),

std::make_pair(SurfaceIdEnum::EMC_Disk_0_Outer, "EMC_Disk_0_Outer"),
std::make_pair(SurfaceIdEnum::EMC_Disk_0_Inner, "EMC_Disk_0_Inner"),
std::make_pair(SurfaceIdEnum::EMC_Disk_1_Inner, "EMC_Disk_1_Inner"),
std::make_pair(SurfaceIdEnum::EMC_Disk_1_Outer, "EMC_Disk_1_Outer"),
std::make_pair(SurfaceIdEnum::EMC_Disk_0_Front, "EMC_Disk_0_Front"),
std::make_pair(SurfaceIdEnum::EMC_Disk_1_Front, "EMC_Disk_1_Front"),
std::make_pair(SurfaceIdEnum::EMC_Disk_0_Back, "EMC_Disk_0_Back"),
std::make_pair(SurfaceIdEnum::EMC_Disk_1_Back, "EMC_Disk_1_Back")
};
std::map<SurfaceIdEnum::enum_type,std::string> const& SurfaceIdDetail::names(){
return nam;
Expand Down
1 change: 1 addition & 0 deletions KinKalGeom/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ cet_make_library(
src/SurfaceMap.cc
src/TestCRV.cc
src/Tracker.cc
src/Calo.cc
LIBRARIES PUBLIC
KinKal::Geometry
Offline::GeneralUtilities
Expand Down
48 changes: 48 additions & 0 deletions KinKalGeom/inc/Calo.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//
// Define the nominal calorimeter boundary and reference surfaces, used to extrapolate and sample KinKal track fits, and to build
// the passive materials in the fit
// original author: Sophie Middleton (2025)
//
#ifndef KinKalGeom_Calo_hh
#define KinKalGeom_Calo_hh
#include "KinKal/Geometry/Cylinder.hh"
#include "KinKal/Geometry/Disk.hh"
#include "KinKal/Geometry/Annulus.hh"
#include <memory>
namespace mu2e {
namespace KinKalGeom {
class Calo {
public:
using CylPtr = std::shared_ptr<KinKal::Cylinder>;
using DiskPtr = std::shared_ptr<KinKal::Disk>;
// default constructor with nominal geometry
Calo();
// return by reference
auto const& EMC_Disk_0_Outer() const { return *EMC_Disk_0_Outer_;}
auto const& EMC_Disk_0_Inner() const { return *EMC_Disk_0_Inner_;}
auto const& EMC_Disk_1_Inner() const { return *EMC_Disk_1_Inner_;}
auto const& EMC_Disk_1_Outer() const { return *EMC_Disk_1_Outer_;}

auto const& EMC_Disk_0_Front() const { return *EMC_Disk_0_Front_;}
auto const& EMC_Disk_1_Front() const { return *EMC_Disk_1_Front_;}
auto const& EMC_Disk_0_Back() const { return *EMC_Disk_0_Back_;}
auto const& EMC_Disk_1_Back() const { return *EMC_Disk_1_Back_;}

// return by ptr
auto const& EMC_Disk_0_OuterPtr() const { return EMC_Disk_0_Outer_;}
auto const& EMC_Disk_0_InnerPtr() const { return EMC_Disk_0_Inner_;}
auto const& EMC_Disk_1_InnerPtr() const { return EMC_Disk_1_Inner_;}
auto const& EMC_Disk_1_OuterPtr() const { return EMC_Disk_1_Outer_;}
auto const& EMC_Disk_0_FrontPtr() const { return EMC_Disk_0_Front_;}
auto const& EMC_Disk_1_FrontPtr() const { return EMC_Disk_1_Front_;}
auto const& EMC_Disk_0_BackPtr() const { return EMC_Disk_0_Back_;}
auto const& EMC_Disk_1_BackPtr() const { return EMC_Disk_1_Back_;}

private:
CylPtr EMC_Disk_0_Inner_, EMC_Disk_0_Outer_ , EMC_Disk_1_Inner_, EMC_Disk_1_Outer_;
DiskPtr EMC_Disk_0_Front_, EMC_Disk_0_Back_, EMC_Disk_1_Front_, EMC_Disk_1_Back_;
};
}
}

#endif
3 changes: 3 additions & 0 deletions KinKalGeom/inc/SurfaceMap.hh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define KinKalGeom_SurfaceMap_hh
#include "Offline/KinKalGeom/inc/Tracker.hh"
#include "Offline/KinKalGeom/inc/StoppingTarget.hh"
#include "Offline/KinKalGeom/inc/Calo.hh"
#include "Offline/KinKalGeom/inc/DetectorSolenoid.hh"
#include "Offline/KinKalGeom/inc/TestCRV.hh"
#include "Offline/DataProducts/inc/SurfaceId.hh"
Expand All @@ -31,13 +32,15 @@ namespace mu2e {
auto const& DS() const {return ds_; }
auto const& ST() const {return st_; }
auto const& tracker() const {return tracker_; }
auto const& calo() const {return calo_; }
auto const& TCRV() const {return tcrv_; }
private:
// local copy of detector objects; these hold the actual (typed) surface objects
KinKalGeom::Tracker tracker_;
KinKalGeom::StoppingTarget st_;
KinKalGeom::DetectorSolenoid ds_;
KinKalGeom::TestCRV tcrv_;
KinKalGeom::Calo calo_;
// the actual map
std::multimap<SurfaceId,SurfacePtr> map_;
};
Expand Down
31 changes: 31 additions & 0 deletions KinKalGeom/src/Calo.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#include "Offline/KinKalGeom/inc/Calo.hh"
namespace mu2e {
namespace KinKalGeom {
using KinKal::VEC3;
using KinKal::Cylinder;
using KinKal::Disk;

// D0 = 11842 -10175.0 = 1667
// D1 = 13220 -10175.0 = 3045
/*
double calorimeter.caloDiskRadiusIn = 335;
double calorimeter.caloDiskRadiusOut = 719;
half length = 192.295


Cylinder(VEC3 const& axis, VEC3 const& center, double radius, double halflen );
Disk(VEC3 const& norm,VEC3 const& udir, VEC3 const& center, double radius)
*/
Calo::Calo() :
EMC_Disk_0_Inner_ { std::make_shared<Cylinder>(VEC3(0.0,0.0,1.0),VEC3(0.0,0.0,1667),335,192.295)},
Comment thread
sophiemiddleton marked this conversation as resolved.
Outdated
EMC_Disk_0_Outer_ { std::make_shared<Cylinder>(VEC3(0.0,0.0,1.0),VEC3(0.0,0.0,1667),719,192.295)},
EMC_Disk_1_Inner_ { std::make_shared<Cylinder>(VEC3(0.0,0.0,1.0),VEC3(0.0,0.0,3045),335,192.295)},
EMC_Disk_1_Outer_ { std::make_shared<Cylinder>(VEC3(0.0,0.0,1.0),VEC3(0.0,0.0,3045),719,192.295)},

EMC_Disk_0_Front_ { std::make_shared<Disk>(VEC3(0.0,0.0,1.0),VEC3(1.0,0.0,0.0),VEC3(0.0,0.0,1667-192.295),719.)},
EMC_Disk_0_Back_ { std::make_shared<Disk>(VEC3(0.0,0.0,1.0),VEC3(1.0,0.0,0.0),VEC3(0.0,0.0,1667+192.295),719.)},
EMC_Disk_1_Front_ { std::make_shared<Disk>(VEC3(0.0,0.0,1.0),VEC3(1.0,0.0,0.0),VEC3(0.0,0.0,3045-192.295),719.)},
EMC_Disk_1_Back_ { std::make_shared<Disk>(VEC3(0.0,0.0,1.0),VEC3(1.0,0.0,0.0),VEC3(0.0,0.0,3045+192.295 ),719.)}
{}
}
}
12 changes: 11 additions & 1 deletion KinKalGeom/src/SurfaceMap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,20 @@ namespace mu2e {
for(size_t ifoil=0;ifoil < st_.foils().size();++ifoil){
map_.emplace(std::make_pair(SurfaceId(SurfaceIdEnum::ST_Foils,ifoil),std::static_pointer_cast<Surface>(st_.foilPtr(ifoil))));
}
// test CRV; Planes are numbered by their vertical (y) position
// test CRV; Planes are numbered by their vertical (y) position
map_.emplace(std::make_pair(SurfaceId(SurfaceIdEnum::TCRV,0),std::static_pointer_cast<Surface>(tcrv_.t1Ptr())));
map_.emplace(std::make_pair(SurfaceId(SurfaceIdEnum::TCRV,1),std::static_pointer_cast<Surface>(tcrv_.ex1Ptr())));
map_.emplace(std::make_pair(SurfaceId(SurfaceIdEnum::TCRV,2),std::static_pointer_cast<Surface>(tcrv_.t2Ptr())));

//calo
map_.emplace(std::make_pair(SurfaceId(SurfaceIdEnum::EMC_Disk_0_Outer),std::static_pointer_cast<Surface>(calo_.EMC_Disk_0_OuterPtr())));
map_.emplace(std::make_pair(SurfaceId(SurfaceIdEnum::EMC_Disk_0_Inner),std::static_pointer_cast<Surface>(calo_.EMC_Disk_0_InnerPtr())));
map_.emplace(std::make_pair(SurfaceId(SurfaceIdEnum::EMC_Disk_1_Inner),std::static_pointer_cast<Surface>(calo_.EMC_Disk_1_InnerPtr())));
map_.emplace(std::make_pair(SurfaceId(SurfaceIdEnum::EMC_Disk_1_Outer),std::static_pointer_cast<Surface>(calo_.EMC_Disk_1_OuterPtr())));
map_.emplace(std::make_pair(SurfaceId(SurfaceIdEnum::EMC_Disk_0_Front),std::static_pointer_cast<Surface>(calo_.EMC_Disk_0_FrontPtr())));
map_.emplace(std::make_pair(SurfaceId(SurfaceIdEnum::EMC_Disk_1_Front),std::static_pointer_cast<Surface>(calo_.EMC_Disk_1_FrontPtr())));
map_.emplace(std::make_pair(SurfaceId(SurfaceIdEnum::EMC_Disk_0_Back),std::static_pointer_cast<Surface>(calo_.EMC_Disk_0_BackPtr())));
map_.emplace(std::make_pair(SurfaceId(SurfaceIdEnum::EMC_Disk_1_Back),std::static_pointer_cast<Surface>(calo_.EMC_Disk_1_BackPtr())));
}
void SurfaceMap::surfaces(SurfaceIdCollection const& ids,SurfacePairCollection& surfs) const {
surfs.clear();
Expand Down
6 changes: 6 additions & 0 deletions Mu2eKinKal/fcl/prolog.fcl
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ Mu2eKinKal : {
Upstream : true
BackToTracker : false
ToOPA : true
ToCaloD0 : true
ToCaloD1 : true
}

LHSEEDXTRAP : {
Expand All @@ -397,6 +399,8 @@ Mu2eKinKal : {
Upstream : false
BackToTracker : false
ToOPA : false
ToCaloD0 : true
ToCaloD1 : true
}

CENTRALHELIX : {
Expand Down Expand Up @@ -434,6 +438,8 @@ Mu2eKinKal : {
MaxDt : 200.0 # (ns)
MinV : 1e-5
ToCRV : true
ToCaloD0 : true
ToCaloD1 : true
}
}

Expand Down
160 changes: 160 additions & 0 deletions Mu2eKinKal/inc/ExtrapolateCalo.hh
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
// predicate to extrapolate to calo
// Sophie Middleton (2025)
#ifndef Mu2eKinKal_ExtrapolateCalo_hh
#define Mu2eKinKal_ExtrapolateCalo_hh
#include "Offline/Mu2eKinKal/inc/KKTrack.hh"
#include "KinKal/General/TimeDir.hh"
#include "KinKal/General/TimeRange.hh"
#include "KinKal/Geometry/Intersection.hh"
#include "KinKal/Geometry/ParticleTrajectoryIntersect.hh"
#include "Offline/KinKalGeom/inc/Calo.hh"
#include "cetlib_except/exception.h"
#include <memory>
#include <vector>
#include <limits>
namespace mu2e {
using KinKal::TimeDir;
using KinKal::TimeRange;
using KinKalGeom::Calo;
using KinKal::Annulus;
using KinKal::Intersection;
using AnnPtr = std::shared_ptr<KinKal::Annulus>;
using CaloDisk = std::vector<AnnPtr>;
using CylPtr = std::shared_ptr<KinKal::Cylinder>;
class ExtrapolateCalo {
public:
ExtrapolateCalo() : maxDt_(-1.0), dptol_(1e10), intertol_(1e10),
d0zmin_(std::numeric_limits<float>::max()),
d0zmax_(-std::numeric_limits<float>::max()),
d1zmin_(std::numeric_limits<float>::max()),
d1zmax_(-std::numeric_limits<float>::max()),
rmin_(std::numeric_limits<float>::max()),
rmax_(-std::numeric_limits<float>::max()),
debug_(0){}

ExtrapolateCalo(double maxdt, double dptol, double intertol, Calo const& calo, int debug=0) :
maxDt_(maxdt), dptol_(dptol), intertol_(intertol),
d0zmin_( (calo.EMC_Disk_0_Outer().center() - calo.EMC_Disk_0_Outer().axis()*calo.EMC_Disk_0_Outer().halfLength()).Z()),
d0zmax_( (calo.EMC_Disk_0_Outer().center() + calo.EMC_Disk_0_Outer().axis()*calo.EMC_Disk_0_Outer().halfLength()).Z()),
d1zmin_( (calo.EMC_Disk_1_Outer().center() - calo.EMC_Disk_1_Outer().axis()*calo.EMC_Disk_1_Outer().halfLength()).Z()),
d1zmax_( (calo.EMC_Disk_1_Outer().center() + calo.EMC_Disk_1_Outer().axis()*calo.EMC_Disk_1_Outer().halfLength()).Z()),
rmin_( calo.EMC_Disk_0_Inner().radius()), rmax_(calo.EMC_Disk_0_Outer().radius()),
disks_(2),debug_(debug) {}
// interface for extrapolation
double maxDt() const { return maxDt_; }
double dpTolerance() const { return dptol_; }
double interTolerance() const { return intertol_; }
double d0zmin() const { return d0zmin_; }
double d0zmax() const { return d0zmax_; }
double d1zmin() const { return d1zmin_; }
double d1zmax() const { return d1zmax_; }
double rmin() const { return rmin_; }
double rmax() const { return rmax_; }
auto const& disks () const { return disks_; }
auto const& intersection() const { return inter_; }

int debug() const { return debug_; }
// extrapolation predicate: the track will be extrapolated until this predicate returns false, subject to the maximum time
template <class KTRAJ> bool needsExtrapolation(KinKal::ParticleTrajectory<KTRAJ> const& fittraj, TimeDir tdir) const;
// reset between tracks
void reset() const { inter_ = Intersection(); sid_ = SurfaceId(); ann_ = AnnPtr();}
// find the nearest disk to a z positionin a given z direction
size_t nearestDisk(double zpos, double zdir) const;
private:
double maxDt_; // maximum extrapolation time
double dptol_; // fractional momentum tolerance
double intertol_; // intersection tolerance (mm)
mutable Intersection inter_; // cache of most recent intersection
mutable SurfaceId sid_; // cache of most recent intersection disk SID
mutable AnnPtr ann_; // cache of most recent intersection disk surface
// cache of front and back Z positions
double d0zmin_, d0zmax_; // z range of disk0 volume
double d1zmin_, d1zmax_; // z range of disk1 volume
double rmin_, rmax_; // inner and outer radii of the anuli
CaloDisk disks_; // disks
int debug_; // debug level
};

template <class KTRAJ> bool ExtrapolateCalo::needsExtrapolation(KinKal::ParticleTrajectory<KTRAJ> const& fittraj, TimeDir tdir) const {
// we are answering the question: did the segment last added to this extrapolated track hit a calo disk or not? If so we are done
// extrapolating (for now) and we want to find all the intersections in that piece. If not, and if we're still inside or heading towards the
// disks, keep going.
auto const& ktraj = tdir == TimeDir::forwards ? fittraj.back() : fittraj.front();
// add a small buffer to the test range to prevent re-intersection with the same piece
static const double epsilon(1e-7); // small difference to avoid re-intersecting
if(ktraj.range().range() <= epsilon) return true; // keep going if the step is very small
auto stime = tdir == TimeDir::forwards ? ktraj.range().begin()+epsilon : ktraj.range().end()-epsilon;
auto etime = tdir == TimeDir::forwards ? ktraj.range().end() : ktraj.range().begin();
auto vel = ktraj.velocity(stime); // physical velocity
if(tdir == TimeDir::backwards) vel *= -1.0;
auto spos = ktraj.position3(stime);
auto epos = ktraj.position3(etime);
if(debug_ > 2)std::cout << "calo extrap tdir " << tdir << " start z " << spos.Z() << " end z " << epos.Z() << " zvel " << vel.Z() << " rho " << spos.Rho() << std::endl;
// stop if the particle is heading away from the calo
if( (vel.Z() > 0 && spos.Z() > d1zmax_ ) || (vel.Z() < 0 && spos.Z() < d0zmin_)){
reset(); // clear any cache
if(debug_ > 1)std::cout << "Heading away from calo: done" << std::endl;
return false;
}
// if the particle is going in the right direction but haven't yet reached the calo in Z just keep going
if( (vel.Z() > 0 && epos.Z() < d0zmin_) || (vel.Z() < 0 && epos.Z() > d1zmax_) ){
reset();
if(debug_ > 2)std::cout << "Heading towards calo, z " << spos.Z()<< std::endl;
return true;
}
// if we get to here we are in the correct Z range. Test disks.
int idisk = nearestDisk(spos.Z(),vel.Z());
if(idisk >= (int)disks_.size())return true;
if(debug_ > 2)std::cout << "Looping on disks " << std::endl;
int ddisk = vel.Z() > 0.0 ? 1 : -1; // iteration direction
auto trange = tdir == TimeDir::forwards ? TimeRange(stime,ktraj.range().end()) : TimeRange(ktraj.range().begin(),stime);
// loop over disks in the z range of this piece
while(idisk >= 0 && idisk < (int)disks_.size() && (disks_[idisk]->center().Z() - epos.Z())*ddisk < 0.0){
auto diskptr = disks_[idisk];
if(debug_ > 2)std::cout << "disk " << idisk << " z " << diskptr->center().Z() << std::endl;
auto newinter = KinKal::intersect(ktraj,*diskptr,trange,intertol_,tdir);
if(debug_ > 2)std::cout << "calo disk inter " << newinter << std::endl;
if(newinter.good()){
// update the cache
inter_ = newinter;
ann_ = disks_[idisk];
//sid_ = SurfaceId(SurfaceIdEnum::calo_Foils,idisk); //FIXME
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is sid_ left out intentionally?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I agree, adding in the material corrections would be a good next step. I'll take a look and see what I can figure out as a future task here.

if(debug_ > 0)std::cout << "Good calo disk " << newinter << " sid " << sid_ << std::endl;
return false;
}
idisk += ddisk; // otherwise continue loopin on disks
}
// no more intersections: keep extending in Z till we clear the calo
reset();
if(debug_ > 1)std::cout << "Extrapolating to calo edge, z " << spos.Z() << std::endl;
if(vel.Z() > 0.0)
return spos.Z() < d1zmax_;
else
return spos.Z() > d0zmin_;
}

size_t ExtrapolateCalo::nearestDisk(double zpos, double zvel) const {
size_t retval = disks_.size();
if(zvel > 0.0){ // going forwards in z
for(auto idisk= disks_.begin(); idisk != disks_.end(); idisk++){
auto const& diskptr = *idisk;
if(diskptr->center().Z() > zpos){
retval = std::distance(disks_.begin(),idisk);
break;
}
}
} else {
for(auto idisk= disks_.rbegin(); idisk != disks_.rend(); idisk++){
auto const& diskptr = *idisk;
if(diskptr->center().Z() < zpos){
auto jdisk = idisk.base()-1; // points to the equivalent forwards object
retval = std::distance(disks_.begin(),jdisk);
break;
}
}
}
return retval;
}

}
#endif
Loading