23 constexpr
double operator""_um(
long double length) {
return length * 1
e-4; }
24 constexpr
double operator""_um_inv(
long double length) {
return length * 1
e4; }
30 (conf.getParameter<
edm::
ParameterSet>(
"Pixel3DDigitizerAlgorithm").getParameter<double>(
"NPColumnRadius")) *
33 (conf.getParameter<
edm::
ParameterSet>(
"Pixel3DDigitizerAlgorithm").getParameter<double>(
"OhmicColumnRadius")) *
36 (conf.getParameter<
edm::
ParameterSet>(
"Pixel3DDigitizerAlgorithm").getParameter<double>(
"NPColumnGap")) *
42 <<
"Algorithm constructed \n" 43 <<
"Configuration parameters:\n" 58 double time =
hit.tof() - tCorr;
68 const std::pair<float, float>& half_pitch)
const {
87 const float& ncarriers,
89 const std::pair<float, float> hpitches,
95 const float max_migration_radius = 0.4_um;
102 if (hpitches.first -
std::abs(
pos.x()) < max_migration_radius) {
104 pitch = hpitches.first;
105 }
else if (hpitches.second -
std::abs(
pos.y()) < max_migration_radius) {
107 pitch = hpitches.second;
110 return std::vector<DigitizerUtility::EnergyDepositUnit>();
115 std::vector<DigitizerUtility::EnergyDepositUnit> migrated_charge;
118 const float diffusion_step = 0.1_um;
121 std::vector<float> pos_moving({
pos.x(),
pos.y(),
pos.z()});
123 std::function<std::vector<float>(
int)> do_step =
124 [&pos_moving, &u_drift, diffusion_step](
int i) -> std::vector<float> {
125 auto dd = u_drift(pos_moving[0], pos_moving[1]);
126 return std::vector<float>({
i * diffusion_step *
dd.x(),
i * diffusion_step *
dd.y(),
i * diffusion_step *
dd.z()});
129 LogDebug(
"Pixel3DDigitizerAlgorithm::diffusion")
130 <<
"\nMax. radius from the pixel edge to migrate charge: " << max_migration_radius * 1.0_um_inv <<
" [um]" 131 <<
"\nMigration axis: " << displ_ind
132 <<
"\n(super-)Charge distance to the pixel edge: " << (pitch - pos_moving[displ_ind]) * 1.0_um_inv <<
" [um]";
139 float current_carriers = ncarriers;
140 std::vector<float> newpos({pos_moving[0], pos_moving[1], pos_moving[2]});
141 float distance_edge = 0.0_um;
143 const float sigma = 0.4_um;
144 for (
int i = 1;; ++
i) {
145 std::transform(pos_moving.begin(), pos_moving.end(), do_step(
i).begin(), pos_moving.begin(), std::plus<float>());
146 distance_edge = pitch -
std::abs(pos_moving[displ_ind]);
149 float migrated_e = current_carriers * 0.5 * (1.0 - std::erf(distance_edge / (sigma *
std::sqrt(2.0))));
151 LogDebug(
"(super-)charge diffusion") <<
"step-" <<
i <<
", Current carriers Ne= " << current_carriers <<
"," 152 <<
"r=(" << pos_moving[0] * 1.0_um_inv <<
", " << pos_moving[1] * 1.0_um_inv
153 <<
", " << pos_moving[2] * 1.0_um_inv <<
") [um], " 154 <<
"Migrated charge: " << migrated_e;
157 current_carriers -= migrated_e;
160 if (
std::abs(distance_edge) >= max_migration_radius || current_carriers <= 0.5 * ncarriers) {
168 std::vector<float> newpos(pos_moving);
170 newpos[displ_ind] += std::copysign(
N_SIGMA * sigma, newpos[displ_ind]);
173 return migrated_charge;
186 const std::vector<DigitizerUtility::EnergyDepositUnit>& ionization_points)
const {
187 return drift(
hit, pixdet, bfield, ionization_points,
true);
193 const std::vector<DigitizerUtility::EnergyDepositUnit>& ionization_points,
194 bool diffusion_activated)
const {
204 const auto half_pitch = std::make_pair<float, float>(pitch.first * 0.5, pitch.second * 0.5);
208 const float pix_rounding = 0.99;
211 const float max_radial_distance =
212 std::sqrt(half_pitch.first * half_pitch.first + half_pitch.second * half_pitch.second);
221 LogDebug(
"Pixel3DDigitizerAlgorithm::drift")
222 <<
"Pixel pitch:" << pitch.first * 1.0_um_inv <<
", " << pitch.second * 1.0_um_inv <<
" [um]";
226 std::function<LocalVector(float, float)> drift_direction = [](
float x,
float y) ->
LocalVector {
227 const float theta = std::atan2(
y,
x);
231 std::vector<DigitizerUtility::SignalPoint> collection_points;
233 collection_points.reserve(ionization_points.size());
237 const float RAD_DAMAGE = 0.001;
239 for (
const auto& super_charge : ionization_points) {
248 current_pixel.first = std::clamp(current_pixel.first,
float(0.0), (nrows - 1) + pix_rounding);
249 current_pixel.second = std::clamp(current_pixel.second,
float(0.0), (ncolumns - 1) + pix_rounding);
251 const auto current_pixel_int = std::make_pair(std::floor(current_pixel.first), std::floor(current_pixel.second));
255 const auto relative_position_at_pc =
256 std::make_pair((current_pixel.first - current_pixel_int.first) * pitch.first,
257 (current_pixel.second - current_pixel_int.second) * pitch.second);
260 LocalPoint position_at_pc(relative_position_at_pc.first - center_proxy_cell.
x(),
261 relative_position_at_pc.second - center_proxy_cell.
y(),
262 super_charge.z() - center_proxy_cell.
z());
264 LogDebug(
"Pixel3DDigitizerAlgorithm::drift")
265 <<
"(super-)Charge\nlocal position: (" << super_charge.x() * 1.0_um_inv <<
", " << super_charge.y() * 1.0_um_inv
266 <<
", " << super_charge.z() * 1.0_um_inv <<
") [um]" 267 <<
"\nMeasurement Point (row,column) (" << current_pixel.first <<
", " << current_pixel.second <<
")" 268 <<
"\nProxy pixel-cell frame (centered at left-back corner): (" << relative_position_at_pc.first * 1.0_um_inv
269 <<
", " << relative_position_at_pc.second * 1.0_um_inv <<
") [um]" 270 <<
"\nProxy pixel-cell frame (centered at n-column): (" << position_at_pc.x() * 1.0_um_inv <<
", " 271 << position_at_pc.y() * 1.0_um_inv <<
") [um] " 272 <<
"\nNe=" << super_charge.energy() <<
" electrons";
276 LogDebug(
"Pixel3DDigitizerAlgorithm::drift") <<
"Remove charge, inside the n-column or p-column!!";
282 if (diffusion_activated) {
283 auto migrated_charges =
diffusion(position_at_pc, super_charge.energy(), drift_direction, half_pitch,
thickness);
284 for (
auto&
mc : migrated_charges) {
290 const float pixel_x = current_pixel_int.first + (
mc.x() + center_proxy_cell.
x()) / pitch.first;
291 const float pixel_y = current_pixel_int.second + (
mc.y() + center_proxy_cell.
y()) / pitch.second;
297 mc.migrate_position(
LocalPoint(lp.x(), lp.y(),
mc.z() + center_proxy_cell.
z()));
299 if (!migrated_charges.empty()) {
300 LogDebug(
"Pixel3DDigitizerAlgorithm::drift") <<
"****************" 301 <<
"MIGRATING (super-)charges" 302 <<
"****************";
304 auto mig_colpoints =
drift(
hit, pixdet, bfield, migrated_charges,
false);
305 collection_points.insert(
std::end(collection_points), mig_colpoints.begin(), mig_colpoints.end());
306 LogDebug(
"Pixel3DDigitizerAlgorithm::drift") <<
"*****************" 308 <<
"****************";
326 energyOnCollector = energyOnCollector *
std::exp(-1.0 * kValue * drift_distance / max_radial_distance);
329 LogDebug(
"Pixel3DDigitizerAlgorithm::drift")
330 <<
"Drift distance = " << drift_distance * 1.0_um_inv <<
" [um], " 331 <<
"Initial electrons = " << super_charge.energy()
332 <<
" [electrons], Electrons after loss/diff= " << energyOnCollector <<
" [electrons] ";
336 current_pixel_int.first, current_pixel_int.second, 0.0, 0.0,
hit.tof(), energyOnCollector));
339 return collection_points;
347 const size_t hitIndex,
348 const uint32_t tofBin,
350 const std::vector<DigitizerUtility::SignalPoint>& collection_points) {
363 for (
const auto&
pt : collection_points) {
369 the_signal[channel] +=
375 LogDebug(
"Pixel3DDigitizerAlgorithm::induce_signal")
376 <<
" Induce charge at row,col:" <<
pt.position() <<
" N_electrons:" <<
pt.amplitude() <<
" [Channel:" << channel
377 <<
"]\n [Accumulated signal in this channel:" << the_signal[channel].ampl() <<
"] " 378 <<
" Global index linked PSimHit:" << hitIndex;
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
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_
Sin< T >::type sin(const T &t)
virtual int nrows() const =0
const float theThresholdInE_Endcap_
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_
void induce_signal(const PSimHit &hit, const size_t hitIndex, const uint32_t tofBin, const Phase2TrackerGeomDetUnit *pixdet, const std::vector< DigitizerUtility::SignalPoint > &collection_points) override
DetId geographicalId() const
The label of this GeomDet.
std::map< int, DigitizerUtility::Amplitude, std::less< int > > signal_map_type
bool select_hit(const PSimHit &hit, double tCorr, double &sigScale) const override
const bool is_inside_n_column_(const LocalPoint &p, const float &sensor_thickness) const
const float theTofLowerCut_
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_
const float theTofUpperCut_
std::vector< DigitizerUtility::SignalPoint > drift(const PSimHit &hit, const Phase2TrackerGeomDetUnit *pixdet, const GlobalVector &bfield, const std::vector< DigitizerUtility::EnergyDepositUnit > &ionization_points) const override
const Bounds & bounds() const