Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions TrackerConditions/inc/StrawElectronics.hh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ namespace mu2e {
_sigma(sigma), _t0(t0) {};
};

// distance-dependent terms of the response of one cluster on one straw; maxResponseTime and maxLinearResponse use only distIndex and distFrac
struct ResponseGeometry {
int distIndex = 0;
double distFrac = 0.0;
double reflectionTime = 0.0;
double reflectionScale = 0.0;
};

typedef std::shared_ptr<StrawElectronics> ptr_t;
typedef std::shared_ptr<const StrawElectronics> cptr_t;
constexpr static const char* cxname = {"StrawElectronics"};
Expand Down Expand Up @@ -108,11 +116,15 @@ namespace mu2e {
// linear response to a charge pulse. This does NOT include saturation effects,
// since those are cumulative and cannot be computed for individual charges
double linearResponse(Straw const& straw, Path ipath, double time, double charge, double distance, bool forsaturation=false) const; // mvolts per pCoulomb
// same as above, with the distance-dependent terms precomputed by responseGeometry
double linearResponse(Straw const& straw, Path ipath, double time, double charge, ResponseGeometry const& rgeom, bool forsaturation=false) const;
ResponseGeometry responseGeometry(Straw const& straw, double distance) const;
double adcImpulseResponse(StrawId sid, double time, double charge) const;
// Given a (linear) total voltage, compute the saturated voltage
double saturatedResponse(double lineearresponse) const;
// relative time when linear response is maximal
double maxResponseTime(StrawId id, Path ipath,double distance) const;
double maxResponseTime(StrawId id, Path ipath, ResponseGeometry const& rgeom) const;
// digization
TrkTypes::ADCValue adcResponse(StrawId id, double mvolts) const; // ADC response to analog inputs
TrkTypes::TDCValue tdcResponse(double time) const; // TDC response to a signal input to electronics at a given time (in ns since eventWindowMarker)
Expand Down Expand Up @@ -155,6 +167,7 @@ namespace mu2e {

double currentToVoltage(StrawId sid, Path ipath) const { return _dVdI[ipath][sid.uniqueStraw()]; }
double maxLinearResponse(StrawId sid, Path ipath,double distance,double charge=1.0) const;
double maxLinearResponse(StrawId sid, Path ipath, ResponseGeometry const& rgeom, double charge=1.0) const;
double clusterLookbackTime() const { return _clusterLookbackTime;}

double truncationTime(Path ipath) const { return _ttrunc[ipath];}
Expand Down Expand Up @@ -216,6 +229,8 @@ namespace mu2e {
double timeDigitalToAnalog(TrkTypes::TDCValue time, StrawId& sid) const;

private:
// wire-distance interpolation interval and weight
void fillDistanceInterval(double distance, ResponseGeometry& rgeom) const;
bool _overrideDbTimeOffsets; // for digitization we override Db parameters and zero all time offsets

// generic waveform parameters
Expand Down
69 changes: 43 additions & 26 deletions TrackerConditions/src/StrawElectronics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,30 +67,45 @@ namespace mu2e {
response[i] *= 1 / gain_160;
}

void StrawElectronics::fillDistanceInterval(double distance, ResponseGeometry& rgeom) const {
rgeom.distIndex = 0;
for (size_t i=1;i<_wPoints.size()-1;i++){
if (distance < _wPoints[i]._distance)
break;
rgeom.distIndex = i;
}
rgeom.distFrac = 1 - (distance - _wPoints[rgeom.distIndex]._distance)/(_wPoints[rgeom.distIndex+1]._distance - _wPoints[rgeom.distIndex]._distance);
}

StrawElectronics::ResponseGeometry StrawElectronics::responseGeometry(Straw const& straw, double distance) const {
ResponseGeometry rgeom;
double straw_length = 2*straw.halfLength();
rgeom.reflectionTime = _reflectionTimeShift + (2*straw_length-2*distance)/_reflectionVelocity;
rgeom.reflectionScale = _reflectionFrac * exp(-(2*straw_length-2*distance)/_reflectionALength);
fillDistanceInterval(distance,rgeom);
return rgeom;
}

double StrawElectronics::linearResponse(Straw const& straw, Path ipath, double time, double charge, double distance, bool forsaturation) const {
return linearResponse(straw,ipath,time,charge,responseGeometry(straw,distance),forsaturation);
}

double StrawElectronics::linearResponse(Straw const& straw, Path ipath, double time, double charge, ResponseGeometry const& rgeom, bool forsaturation) const {
int index = time*_sampleRate + _responseBins/2.;
if ( index >= _responseBins)
index = _responseBins-1;
if (index < 0)
index = 0;

double straw_length = 2*straw.halfLength();
double reflection_time = _reflectionTimeShift + (2*straw_length-2*distance)/_reflectionVelocity;
int index_refl = (time - reflection_time)*_sampleRate + _responseBins/2.;
int index_refl = (time - rgeom.reflectionTime)*_sampleRate + _responseBins/2.;
if (index_refl >= _responseBins)
index_refl = _responseBins-1;
if (index_refl < 0)
index_refl = 0;

double reflection_scale = _reflectionFrac * exp(-(2*straw_length-2*distance)/_reflectionALength);

int distIndex = 0;
for (size_t i=1;i<_wPoints.size()-1;i++){
if (distance < _wPoints[i]._distance)
break;
distIndex = i;
}
double distFrac = 1 - (distance - _wPoints[distIndex]._distance)/(_wPoints[distIndex+1]._distance - _wPoints[distIndex]._distance);
double reflection_scale = rgeom.reflectionScale;
int distIndex = rgeom.distIndex;
double distFrac = rgeom.distFrac;
double p0, p1;
if (ipath == thresh){
if (forsaturation){
Expand Down Expand Up @@ -124,27 +139,29 @@ namespace mu2e {
}

double StrawElectronics::maxResponseTime(StrawId sid, Path ipath,double distance) const {
int distIndex = 0;
for (size_t i=1;i<_wPoints.size()-1;i++){
if (distance < _wPoints[i]._distance)
break;
distIndex = i;
}
double distFrac = 1 - (distance - _wPoints[distIndex]._distance)/(_wPoints[distIndex+1]._distance - _wPoints[distIndex]._distance);
ResponseGeometry rgeom;
fillDistanceInterval(distance,rgeom);
return maxResponseTime(sid,ipath,rgeom);
}

double StrawElectronics::maxResponseTime(StrawId sid, Path ipath, ResponseGeometry const& rgeom) const {
int distIndex = rgeom.distIndex;
double distFrac = rgeom.distFrac;
double p0 = _wPoints[distIndex]._tmax[ipath][sid.getStraw()];
double p1 = _wPoints[distIndex + 1]._tmax[ipath][sid.getStraw()];

return p0 * distFrac + p1 * (1 - distFrac);
}

double StrawElectronics::maxLinearResponse(StrawId sid, Path ipath,double distance,double charge) const {
int distIndex = 0;
for (size_t i=1;i<_wPoints.size()-1;i++){
if (distance < _wPoints[i]._distance)
break;
distIndex = i;
}
double distFrac = 1 - (distance - _wPoints[distIndex]._distance)/(_wPoints[distIndex+1]._distance - _wPoints[distIndex]._distance);
ResponseGeometry rgeom;
fillDistanceInterval(distance,rgeom);
return maxLinearResponse(sid,ipath,rgeom,charge);
}

double StrawElectronics::maxLinearResponse(StrawId sid, Path ipath, ResponseGeometry const& rgeom, double charge) const {
int distIndex = rgeom.distIndex;
double distFrac = rgeom.distFrac;
double p0 = _wPoints[distIndex]._linmax[ipath][sid.getStraw()];
double p1 = _wPoints[distIndex + 1]._linmax[ipath][sid.getStraw()];

Expand Down
9 changes: 8 additions & 1 deletion TrackerMC/inc/StrawCluster.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
#include "Offline/DataProducts/inc/StrawEnd.hh"
#include "Offline/TrackerMC/inc/StrawPosition.hh"
#include "Offline/MCDataProducts/inc/StrawGasStep.hh"
#include "Offline/TrackerConditions/inc/StrawElectronics.hh"
// toolkit includes
#include "canvas/Persistency/Common/Ptr.h"

namespace mu2e {
class Straw;
namespace TrackerMC {
class StrawCluster{
public:
Expand All @@ -41,7 +43,9 @@ namespace mu2e {
float drifttime,
float proptime,
art::Ptr<StrawGasStep> const& sgs,
float ctime);
float ctime,
StrawElectronics const& strawele,
Straw const& straw);
// use compiler version of copy, assignment
// Accessors
ClusterType type() const { return _type; }
Expand All @@ -57,6 +61,8 @@ namespace mu2e {
float propTime() const { return _proptime; }
art::Ptr<StrawGasStep> const& strawGasStep() const { return _sgsptr; }
float cluTime() const { return _ctime; }
// distance-dependent electronics response terms of this cluster on its straw
StrawElectronics::ResponseGeometry const& responseGeometry() const { return _rgeom; }
// Print contents of the object.
void print( std::ostream& ost = std::cout, bool doEndl = true ) const;
private:
Expand All @@ -71,6 +77,7 @@ namespace mu2e {
float _proptime; // propagation time to the wire end
art::Ptr<StrawGasStep> _sgsptr;
float _ctime;
StrawElectronics::ResponseGeometry _rgeom; // computed at construction from _wdist
};
} // namespace TrackerMC
} // namespace mu2e
Expand Down
8 changes: 6 additions & 2 deletions TrackerMC/src/StrawCluster.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
//
// mu2e includes
#include "Offline/TrackerMC/inc/StrawCluster.hh"
#include "Offline/TrackerGeom/inc/Straw.hh"
// general includes

using namespace std;
Expand All @@ -22,8 +23,11 @@ namespace mu2e {
float drifttime,
float proptime,
art::Ptr<StrawGasStep> const& sgsptr,
float ctime) : _type(type), _strawId(sid), _end(end), _time(time),
_charge(charge), _wdist(wdist), _pos(pos), _drifttime(drifttime), _proptime(proptime), _sgsptr(sgsptr), _ctime(ctime) {}
float ctime,
StrawElectronics const& strawele,
Straw const& straw) : _type(type), _strawId(sid), _end(end), _time(time),
_charge(charge), _wdist(wdist), _pos(pos), _drifttime(drifttime), _proptime(proptime), _sgsptr(sgsptr), _ctime(ctime),
_rgeom(strawele.responseGeometry(straw,_wdist)) {}

// delegating constructors in C++11!
StrawCluster::StrawCluster(const StrawCluster& primary, StrawId const& id, float xfactor) :
Expand Down
2 changes: 1 addition & 1 deletion TrackerMC/src/StrawDigisFromStrawGasSteps_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ namespace mu2e {
// compute the time the signal arrives at the wire end
double gtime = ctime + wireq._time + weq._time;
// create the clust
StrawCluster clust(StrawCluster::primary,sid,end,(float)gtime,weq._charge,weq._wdist,wireq._pos,(float)wireq._time,(float)weq._time,sgsptr,(float)ctime);
StrawCluster clust(StrawCluster::primary,sid,end,(float)gtime,weq._charge,weq._wdist,wireq._pos,(float)wireq._time,(float)weq._time,sgsptr,(float)ctime,strawele,straw);
// add the clusts to the appropriate sequence.
shsp.clustSequence(end).insert(clust);
// if required, add a 'ghost' copy of this clust
Expand Down
12 changes: 6 additions & 6 deletions TrackerMC/src/StrawWaveform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ namespace mu2e {
//// check if this clust could cross threshold
//if(wfx._vstart + maxLinearResponse(wfx._iclust) > threshold){
// check the actual response
double maxtime = wfx._iclust->time()+strawele.maxResponseTime(_straw.id(),StrawElectronics::thresh,wfx._iclust->wireDistance());
double maxtime = wfx._iclust->time()+strawele.maxResponseTime(_straw.id(),StrawElectronics::thresh,wfx._iclust->responseGeometry());
double maxresp = sampleWaveform(strawele,StrawElectronics::thresh,maxtime);
if(maxresp > threshold){
// interpolate to find the precise crossing
Expand All @@ -64,7 +64,7 @@ namespace mu2e {
void StrawWaveform::returnCrossing(StrawElectronics const& strawele, double threshold, WFX& wfx) const {
while(wfx._iclust != _cseq.clustList().end() && wfx._vstart > threshold) {
// move forward in time at least as twice the time to the maxium for this clust
double time = wfx._iclust->time()+strawele.clusterLookbackTime() + 2*strawele.maxResponseTime(_straw.id(),StrawElectronics::thresh,wfx._iclust->wireDistance());
double time = wfx._iclust->time()+strawele.clusterLookbackTime() + 2*strawele.maxResponseTime(_straw.id(),StrawElectronics::thresh,wfx._iclust->responseGeometry());
while(wfx._iclust != _cseq.clustList().end() &&
wfx._iclust->time()-strawele.clusterLookbackTime() < time){
++(wfx._iclust);
Expand Down Expand Up @@ -95,7 +95,7 @@ namespace mu2e {
bool StrawWaveform::fineCrossing(StrawElectronics const& strawele, double threshold,double maxresp, WFX& wfx) const {
static double timestep(0.020); // interpolation minimum to use linear threshold crossing calculation
double pretime = wfx._iclust->time()-strawele.clusterLookbackTime();
double posttime = pretime + strawele.clusterLookbackTime() + strawele.maxResponseTime(_straw.id(),StrawElectronics::thresh,wfx._iclust->wireDistance());
double posttime = pretime + strawele.clusterLookbackTime() + strawele.maxResponseTime(_straw.id(),StrawElectronics::thresh,wfx._iclust->responseGeometry());
double presample = wfx._vstart;
double postsample = maxresp;
static const unsigned maxstep(10); // 10 steps max
Expand Down Expand Up @@ -141,7 +141,7 @@ namespace mu2e {

double StrawWaveform::maxLinearResponse(StrawElectronics const& strawele,StrawClusterList::const_iterator const& iclust) const {
// ignore saturation effects
double linresp = strawele.maxLinearResponse(_straw.id(),StrawElectronics::thresh,iclust->wireDistance(),iclust->charge());
double linresp = strawele.maxLinearResponse(_straw.id(),StrawElectronics::thresh,iclust->responseGeometry(),iclust->charge());
linresp *= (_xtalk._preamp + _xtalk._postamp);
return linresp;
}
Expand All @@ -153,7 +153,7 @@ namespace mu2e {
auto iclust = hlist.begin();
while(iclust != hlist.end() && iclust->time()-strawele.clusterLookbackTime() < time){
// compute the linear straw electronics response to this charge. This is pre-saturation
linresp += strawele.linearResponse(_straw,ipath,time-iclust->time(),iclust->charge(),iclust->wireDistance());
linresp += strawele.linearResponse(_straw,ipath,time-iclust->time(),iclust->charge(),iclust->responseGeometry());
// move to next clust
++iclust;
}
Expand Down Expand Up @@ -207,7 +207,7 @@ namespace mu2e {
double response = 0;
auto jclust = iclust;
while(jclust != _cseq.clustList().end() && jclust->time()-strawele.clusterLookbackTime() < time){
response += strawele.linearResponse(_straw,StrawElectronics::thresh,time-jclust->time(),jclust->charge(),jclust->wireDistance(),true);
response += strawele.linearResponse(_straw,StrawElectronics::thresh,time-jclust->time(),jclust->charge(),jclust->responseGeometry(),true);
++jclust;
}
// now saturate it
Expand Down