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" 51 double time =
hit.tof() - tCorr;
61 const std::pair<float, float>& half_pitch)
const {
80 const float& ncarriers,
82 const std::pair<float, float> hpitches,
88 const float max_migration_radius = 0.4_um;
95 if (hpitches.first -
std::abs(
pos.x()) < max_migration_radius) {
97 pitch = hpitches.first;
98 }
else if (hpitches.second -
std::abs(
pos.y()) < max_migration_radius) {
100 pitch = hpitches.second;
103 return std::vector<digitizerUtility::EnergyDepositUnit>();
108 std::vector<digitizerUtility::EnergyDepositUnit> migrated_charge;
111 const float diffusion_step = 0.1_um;
114 std::vector<float> pos_moving({
pos.x(),
pos.y(),
pos.z()});
116 std::function<std::vector<float>(
int)> do_step =
117 [&pos_moving, &u_drift, diffusion_step](
int i) -> std::vector<float> {
118 auto dd = u_drift(pos_moving[0], pos_moving[1]);
119 return std::vector<float>({
i * diffusion_step *
dd.x(),
i * diffusion_step *
dd.y(),
i * diffusion_step *
dd.z()});
122 LogDebug(
"Pixel3DDigitizerAlgorithm::diffusion")
123 <<
"\nMax. radius from the pixel edge to migrate charge: " << max_migration_radius * 1.0_um_inv <<
" [um]" 124 <<
"\nMigration axis: " << displ_ind
125 <<
"\n(super-)Charge distance to the pixel edge: " << (pitch - pos_moving[displ_ind]) * 1.0_um_inv <<
" [um]";
132 float current_carriers = ncarriers;
133 std::vector<float> newpos({pos_moving[0], pos_moving[1], pos_moving[2]});
134 float distance_edge = 0.0_um;
136 const float sigma = 0.4_um;
137 for (
int i = 1;; ++
i) {
138 std::transform(pos_moving.begin(), pos_moving.end(), do_step(
i).begin(), pos_moving.begin(), std::plus<float>());
139 distance_edge = pitch -
std::abs(pos_moving[displ_ind]);
142 float migrated_e = current_carriers * 0.5 * (1.0 - std::erf(distance_edge / (sigma *
std::sqrt(2.0))));
144 LogDebug(
"(super-)charge diffusion") <<
"step-" <<
i <<
", Current carriers Ne= " << current_carriers <<
"," 145 <<
"r=(" << pos_moving[0] * 1.0_um_inv <<
", " << pos_moving[1] * 1.0_um_inv
146 <<
", " << pos_moving[2] * 1.0_um_inv <<
") [um], " 147 <<
"Migrated charge: " << migrated_e;
150 current_carriers -= migrated_e;
153 if (
std::abs(distance_edge) >= max_migration_radius || current_carriers <= 0.5 * ncarriers) {
161 std::vector<float> newpos(pos_moving);
163 newpos[displ_ind] += std::copysign(
N_SIGMA * sigma, newpos[displ_ind]);
166 return migrated_charge;
179 const std::vector<digitizerUtility::EnergyDepositUnit>& ionization_points)
const {
180 return drift(
hit, pixdet, bfield, ionization_points,
true);
186 const std::vector<digitizerUtility::EnergyDepositUnit>& ionization_points,
187 bool diffusion_activated)
const {
197 const auto half_pitch = std::make_pair<float, float>(pitch.first * 0.5, pitch.second * 0.5);
201 const float pix_rounding = 0.99;
204 const float max_radial_distance =
205 std::sqrt(half_pitch.first * half_pitch.first + half_pitch.second * half_pitch.second);
214 LogDebug(
"Pixel3DDigitizerAlgorithm::drift")
215 <<
"Pixel pitch:" << pitch.first * 1.0_um_inv <<
", " << pitch.second * 1.0_um_inv <<
" [um]";
219 std::function<LocalVector(float, float)> drift_direction = [](
float x,
float y) ->
LocalVector {
220 const float theta = std::atan2(
y,
x);
224 std::vector<digitizerUtility::SignalPoint> collection_points;
226 collection_points.reserve(ionization_points.size());
230 const float RAD_DAMAGE = 0.001;
232 for (
const auto& super_charge : ionization_points) {
241 current_pixel.first = std::clamp(current_pixel.first,
float(0.0), (nrows - 1) + pix_rounding);
242 current_pixel.second = std::clamp(current_pixel.second,
float(0.0), (ncolumns - 1) + pix_rounding);
244 const auto current_pixel_int = std::make_pair(std::floor(current_pixel.first), std::floor(current_pixel.second));
248 const auto relative_position_at_pc =
249 std::make_pair((current_pixel.first - current_pixel_int.first) * pitch.first,
250 (current_pixel.second - current_pixel_int.second) * pitch.second);
253 LocalPoint position_at_pc(relative_position_at_pc.first - center_proxy_cell.
x(),
254 relative_position_at_pc.second - center_proxy_cell.
y(),
255 super_charge.z() - center_proxy_cell.
z());
257 LogDebug(
"Pixel3DDigitizerAlgorithm::drift")
258 <<
"(super-)Charge\nlocal position: (" << super_charge.x() * 1.0_um_inv <<
", " << super_charge.y() * 1.0_um_inv
259 <<
", " << super_charge.z() * 1.0_um_inv <<
") [um]" 260 <<
"\nMeasurement Point (row,column) (" << current_pixel.first <<
", " << current_pixel.second <<
")" 261 <<
"\nProxy pixel-cell frame (centered at left-back corner): (" << relative_position_at_pc.first * 1.0_um_inv
262 <<
", " << relative_position_at_pc.second * 1.0_um_inv <<
") [um]" 263 <<
"\nProxy pixel-cell frame (centered at n-column): (" << position_at_pc.x() * 1.0_um_inv <<
", " 264 << position_at_pc.y() * 1.0_um_inv <<
") [um] " 265 <<
"\nNe=" << super_charge.energy() <<
" electrons";
269 LogDebug(
"Pixel3DDigitizerAlgorithm::drift") <<
"Remove charge, inside the n-column or p-column!!";
275 if (diffusion_activated) {
276 auto migrated_charges =
diffusion(position_at_pc, super_charge.energy(), drift_direction, half_pitch,
thickness);
277 for (
auto&
mc : migrated_charges) {
283 const float pixel_x = current_pixel_int.first + (
mc.x() + center_proxy_cell.
x()) / pitch.first;
284 const float pixel_y = current_pixel_int.second + (
mc.y() + center_proxy_cell.
y()) / pitch.second;
290 mc.migrate_position(
LocalPoint(lp.x(), lp.y(),
mc.z() + center_proxy_cell.
z()));
292 if (!migrated_charges.empty()) {
293 LogDebug(
"Pixel3DDigitizerAlgorithm::drift") <<
"****************" 294 <<
"MIGRATING (super-)charges" 295 <<
"****************";
297 auto mig_colpoints =
drift(
hit, pixdet, bfield, migrated_charges,
false);
298 collection_points.insert(std::end(collection_points), mig_colpoints.begin(), mig_colpoints.end());
299 LogDebug(
"Pixel3DDigitizerAlgorithm::drift") <<
"*****************" 301 <<
"****************";
319 energyOnCollector = energyOnCollector *
std::exp(-1.0 * kValue * drift_distance / max_radial_distance);
322 LogDebug(
"Pixel3DDigitizerAlgorithm::drift")
323 <<
"Drift distance = " << drift_distance * 1.0_um_inv <<
" [um], " 324 <<
"Initial electrons = " << super_charge.energy()
325 <<
" [electrons], Electrons after loss/diff= " << energyOnCollector <<
" [electrons] ";
329 current_pixel_int.first, current_pixel_int.second, 0.0, 0.0,
hit.tof(), energyOnCollector));
332 return collection_points;
341 const size_t hitIndex,
342 const size_t firstHitIndex,
343 const uint32_t tofBin,
345 const std::vector<digitizerUtility::SignalPoint>& collection_points) {
358 for (
const auto&
pt : collection_points) {
364 the_signal[channel] +=
370 LogDebug(
"Pixel3DDigitizerAlgorithm")
371 <<
" Induce charge at row,col:" <<
pt.position() <<
" N_electrons:" <<
pt.amplitude() <<
" [Channel:" << channel
372 <<
"]\n [Accumulated signal in this channel:" << the_signal[channel].ampl() <<
"] " 373 <<
" 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
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.
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_
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