16 constexpr
double operator""_um(
long double length) {
return length * 1
e-4; }
17 constexpr
double operator""_um_inv(
long double length) {
return length * 1
e4; }
23 (conf.getParameter<
edm::
ParameterSet>(
"Pixel3DDigitizerAlgorithm").getParameter<double>(
"NPColumnRadius")) *
26 (conf.getParameter<
edm::
ParameterSet>(
"Pixel3DDigitizerAlgorithm").getParameter<double>(
"OhmicColumnRadius")) *
29 (conf.getParameter<
edm::
ParameterSet>(
"Pixel3DDigitizerAlgorithm").getParameter<double>(
"NPColumnGap")) *
35 <<
"Algorithm constructed \n" 36 <<
"Configuration parameters:\n" 53 const std::pair<float, float>& half_pitch)
const {
72 const float& ncarriers,
74 const std::pair<float, float> hpitches,
80 const float max_migration_radius = 0.4_um;
87 if (hpitches.first -
std::abs(
pos.x()) < max_migration_radius) {
89 pitch = hpitches.first;
90 }
else if (hpitches.second -
std::abs(
pos.y()) < max_migration_radius) {
92 pitch = hpitches.second;
95 return std::vector<digitizerUtility::EnergyDepositUnit>();
100 std::vector<digitizerUtility::EnergyDepositUnit> migrated_charge;
103 const float diffusion_step = 0.1_um;
106 std::vector<float> pos_moving({
pos.x(),
pos.y(),
pos.z()});
108 std::function<std::vector<float>(
int)> do_step =
109 [&pos_moving, &u_drift, diffusion_step](
int i) -> std::vector<float> {
110 auto dd = u_drift(pos_moving[0], pos_moving[1]);
111 return std::vector<float>({
i * diffusion_step *
dd.x(),
i * diffusion_step *
dd.y(),
i * diffusion_step *
dd.z()});
114 LogDebug(
"Pixel3DDigitizerAlgorithm::diffusion")
115 <<
"\nMax. radius from the pixel edge to migrate charge: " << max_migration_radius * 1.0_um_inv <<
" [um]" 116 <<
"\nMigration axis: " << displ_ind
117 <<
"\n(super-)Charge distance to the pixel edge: " << (pitch - pos_moving[displ_ind]) * 1.0_um_inv <<
" [um]";
124 float current_carriers = ncarriers;
125 std::vector<float> newpos({pos_moving[0], pos_moving[1], pos_moving[2]});
126 float distance_edge = 0.0_um;
128 const float sigma = 0.4_um;
129 for (
int i = 1;; ++
i) {
130 std::transform(pos_moving.begin(), pos_moving.end(), do_step(
i).begin(), pos_moving.begin(), std::plus<float>());
131 distance_edge = pitch -
std::abs(pos_moving[displ_ind]);
134 float migrated_e = current_carriers * 0.5 * (1.0 - std::erf(distance_edge / (sigma *
std::sqrt(2.0))));
136 LogDebug(
"(super-)charge diffusion") <<
"step-" <<
i <<
", Current carriers Ne= " << current_carriers <<
"," 137 <<
"r=(" << pos_moving[0] * 1.0_um_inv <<
", " << pos_moving[1] * 1.0_um_inv
138 <<
", " << pos_moving[2] * 1.0_um_inv <<
") [um], " 139 <<
"Migrated charge: " << migrated_e;
142 current_carriers -= migrated_e;
145 if (
std::abs(distance_edge) >= max_migration_radius || current_carriers <= 0.5 * ncarriers) {
153 std::vector<float> newpos(pos_moving);
155 newpos[displ_ind] += std::copysign(
N_SIGMA * sigma, newpos[displ_ind]);
158 return migrated_charge;
171 const std::vector<digitizerUtility::EnergyDepositUnit>& ionization_points)
const {
178 const std::vector<digitizerUtility::EnergyDepositUnit>& ionization_points,
179 bool diffusion_activated)
const {
189 const auto half_pitch = std::make_pair<float, float>(pitch.first * 0.5, pitch.second * 0.5);
193 const float pix_rounding = 0.99;
196 const float max_radial_distance =
197 std::sqrt(half_pitch.first * half_pitch.first + half_pitch.second * half_pitch.second);
206 LogDebug(
"Pixel3DDigitizerAlgorithm::drift")
207 <<
"Pixel pitch:" << pitch.first * 1.0_um_inv <<
", " << pitch.second * 1.0_um_inv <<
" [um]";
211 std::function<LocalVector(float, float)> drift_direction = [](
float x,
float y) ->
LocalVector {
212 const float theta = std::atan2(
y,
x);
216 std::vector<digitizerUtility::SignalPoint> collection_points;
218 collection_points.reserve(ionization_points.size());
222 const float RAD_DAMAGE = 0.001;
224 for (
const auto& super_charge : ionization_points) {
233 current_pixel.first = std::clamp(current_pixel.first,
float(0.0), (nrows - 1) + pix_rounding);
234 current_pixel.second = std::clamp(current_pixel.second,
float(0.0), (ncolumns - 1) + pix_rounding);
236 const auto current_pixel_int = std::make_pair(std::floor(current_pixel.first), std::floor(current_pixel.second));
240 const auto relative_position_at_pc =
241 std::make_pair((current_pixel.first - current_pixel_int.first) * pitch.first,
242 (current_pixel.second - current_pixel_int.second) * pitch.second);
245 LocalPoint position_at_pc(relative_position_at_pc.first - center_proxy_cell.
x(),
246 relative_position_at_pc.second - center_proxy_cell.
y(),
247 super_charge.z() - center_proxy_cell.
z());
249 LogDebug(
"Pixel3DDigitizerAlgorithm::drift")
250 <<
"(super-)Charge\nlocal position: (" << super_charge.x() * 1.0_um_inv <<
", " << super_charge.y() * 1.0_um_inv
251 <<
", " << super_charge.z() * 1.0_um_inv <<
") [um]" 252 <<
"\nMeasurement Point (row,column) (" << current_pixel.first <<
", " << current_pixel.second <<
")" 253 <<
"\nProxy pixel-cell frame (centered at left-back corner): (" << relative_position_at_pc.first * 1.0_um_inv
254 <<
", " << relative_position_at_pc.second * 1.0_um_inv <<
") [um]" 255 <<
"\nProxy pixel-cell frame (centered at n-column): (" << position_at_pc.x() * 1.0_um_inv <<
", " 256 << position_at_pc.y() * 1.0_um_inv <<
") [um] " 257 <<
"\nNe=" << super_charge.energy() <<
" electrons";
261 LogDebug(
"Pixel3DDigitizerAlgorithm::drift") <<
"Remove charge, inside the n-column or p-column!!";
267 if (diffusion_activated) {
268 auto migrated_charges =
diffusion(position_at_pc, super_charge.energy(), drift_direction, half_pitch,
thickness);
269 for (
auto&
mc : migrated_charges) {
275 const float pixel_x = current_pixel_int.first + (
mc.x() + center_proxy_cell.
x()) / pitch.first;
276 const float pixel_y = current_pixel_int.second + (
mc.y() + center_proxy_cell.
y()) / pitch.second;
282 mc.migrate_position(
LocalPoint(lp.x(), lp.y(),
mc.z() + center_proxy_cell.
z()));
284 if (!migrated_charges.empty()) {
285 LogDebug(
"Pixel3DDigitizerAlgorithm::drift") <<
"****************" 286 <<
"MIGRATING (super-)charges" 287 <<
"****************";
290 collection_points.insert(std::end(collection_points), mig_colpoints.begin(), mig_colpoints.end());
291 LogDebug(
"Pixel3DDigitizerAlgorithm::drift") <<
"*****************" 293 <<
"****************";
311 energyOnCollector = energyOnCollector *
std::exp(-1.0 * kValue * drift_distance / max_radial_distance);
314 LogDebug(
"Pixel3DDigitizerAlgorithm::drift")
315 <<
"Drift distance = " << drift_distance * 1.0_um_inv <<
" [um], " 316 <<
"Initial electrons = " << super_charge.energy()
317 <<
" [electrons], Electrons after loss/diff= " << energyOnCollector <<
" [electrons] ";
321 current_pixel_int.first, current_pixel_int.second, 0.0, 0.0,
hit.tof(), energyOnCollector));
324 return collection_points;
333 const size_t hitIndex,
334 const size_t firstHitIndex,
335 const uint32_t tofBin,
337 const std::vector<digitizerUtility::SignalPoint>& collection_points) {
350 for (
const auto&
pt : collection_points) {
356 the_signal[channel] +=
362 LogDebug(
"Pixel3DDigitizerAlgorithm")
363 <<
" Induce charge at row,col:" <<
pt.position() <<
" N_electrons:" <<
pt.amplitude() <<
" [Channel:" << channel
364 <<
"]\n [Accumulated signal in this channel:" << the_signal[channel].ampl() <<
"] " 365 <<
" Global index linked PSimHit:" << hitIndex;
Pixel3DDigitizerAlgorithm(const edm::ParameterSet &conf, edm::ConsumesCollector iC)
Local3DVector LocalVector
const float theElectronPerADC_
Point3DBase< Scalar, LocalTag > LocalPoint
virtual std::pair< float, float > pixel(const LocalPoint &p) const =0
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
virtual int ncolumns() const =0
const double pseudoRadDamage_
const double pseudoRadDamageRadius_
std::vector< digitizerUtility::EnergyDepositUnit > diffusion(const LocalPoint &pos, const float &ncarriers, const std::function< LocalVector(float, float)> &u_drift, const std::pair< float, float > pitches, const float &thickness) const
std::vector< digitizerUtility::SignalPoint > driftFor3DSensors(const PSimHit &hit, const Phase2TrackerGeomDetUnit *pixdet, const GlobalVector &bfield, const std::vector< digitizerUtility::EnergyDepositUnit > &ionization_points, bool diffusion_activated) const
Sin< T >::type sin(const T &t)
virtual int nrows() const =0
const float theThresholdInE_Endcap_
std::map< int, digitizerUtility::Ph2Amplitude, std::less< int > > signal_map_type
std::vector< digitizerUtility::SignalPoint > drift(const PSimHit &hit, const Phase2TrackerGeomDetUnit *pixdet, const GlobalVector &bfield, const std::vector< digitizerUtility::EnergyDepositUnit > &ionization_points) const override
static int pixelToChannel(int row, int col)
virtual float thickness() const =0
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
static PackedDigiType pixelToChannel(unsigned int row, unsigned int col)
const bool addPixelInefficiency_
Cos< T >::type cos(const T &t)
Abs< T >::type abs(const T &t)
const float theThresholdInE_Barrel_
DetId geographicalId() const
The label of this GeomDet.
const bool is_inside_n_column_(const LocalPoint &p, const float &sensor_thickness) const
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
Log< level::Info, false > LogInfo
const Plane & surface() const
The nominal surface of the GeomDet.
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
const PositionType & position() const
const float ohm_column_radius_
constexpr uint32_t rawId() const
get the raw id
const bool is_inside_ohmic_column_(const LocalPoint &p, const std::pair< float, float > &pitch) const
static const double N_SIGMA
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
const int theAdcFullScale_
~Pixel3DDigitizerAlgorithm() override
virtual std::pair< float, float > pitch() const =0
const bool makeDigiSimLinks_
const Plane & specificSurface() const
Same as surface(), kept for backward compatibility.
const float np_column_radius_
constexpr uint32_t pixelToChannel(int row, int col)
Geom::Theta< T > theta() const
const float np_column_gap_
void induce_signal(std::vector< PSimHit >::const_iterator inputBegin, const PSimHit &hit, const size_t hitIndex, const size_t firstHitIndex, const uint32_t tofBin, const Phase2TrackerGeomDetUnit *pixdet, const std::vector< digitizerUtility::SignalPoint > &collection_points) override
const Bounds & bounds() const