From b3617334e20e106c0f282b47444851388fe5527a Mon Sep 17 00:00:00 2001 From: claralasa Date: Thu, 15 Oct 2020 17:26:04 +0200 Subject: [PATCH 1/8] Fix pixel translation bug --- .../SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc index ad814a4bac115..dd8cfe33bb7ea 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc +++ b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc @@ -322,7 +322,9 @@ std::vector Pixel3DDigitizerAlgorithm::drift( const float pixel_x = current_pixel_int.first + (mc.x() + center_proxy_cell.x()) / pitch.first; const float pixel_y = current_pixel_int.second + (mc.y() + center_proxy_cell.y()) / pitch.second; const auto lp = pixdet->specificTopology().localPosition(MeasurementPoint(pixel_x, pixel_y)); - mc.migrate_position(LocalPoint(lp.x(), lp.y(), mc.z())); + //Remember: the drift function will move the reference system to the bottom. We need to add what we previously subtract + //in order to avoid a double translation when calling the drift function once again below + mc.migrate_position(LocalPoint(lp.x(), lp.y(), mc.z() + center_proxy_cell.z())); } if (!migrated_charges.empty()) { LogDebug("Pixel3DDigitizerAlgorithm::drift") << "****************" From cc93d7f704f47feba07180b7ad21c516af49205a Mon Sep 17 00:00:00 2001 From: claralasa Date: Thu, 15 Oct 2020 17:26:54 +0200 Subject: [PATCH 2/8] Generate charge underneath the n-column --- .../plugins/Pixel3DDigitizerAlgorithm.cc | 15 ++++++++------- .../plugins/Pixel3DDigitizerAlgorithm.h | 10 ++++++---- .../python/phase2TrackerDigitizer_cfi.py | 5 +++++ 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc index dd8cfe33bb7ea..9fb1c671e0d02 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc +++ b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc @@ -53,9 +53,9 @@ void Pixel3DDigitizerAlgorithm::init(const edm::EventSetup& es) { Pixel3DDigitizerAlgorithm::Pixel3DDigitizerAlgorithm(const edm::ParameterSet& conf) : Phase2TrackerDigitizerAlgorithm(conf.getParameter("AlgorithmCommon"), conf.getParameter("Pixel3DDigitizerAlgorithm")), - // The size of the column np-junction (XXX: to be included via config) - _np_column_radius(5.0_um), - _ohm_column_radius(5.0_um) { + _np_column_radius((conf.getParameter("Pixel3DDigitizerAlgorithm").getParameter("NPColumnRadius"))*1.0_um), + _ohm_column_radius((conf.getParameter("Pixel3DDigitizerAlgorithm").getParameter("OhmicColumnRadius"))*1.0_um), + _np_column_gap((conf.getParameter("Pixel3DDigitizerAlgorithm").getParameter("NPColumnGap"))*1.0_um) { // XXX - NEEDED? pixelFlag_ = true; @@ -80,8 +80,9 @@ bool Pixel3DDigitizerAlgorithm::select_hit(const PSimHit& hit, double tCorr, dou return (time >= theTofLowerCut_ && time < theTofUpperCut_); } -const bool Pixel3DDigitizerAlgorithm::_is_inside_n_column(const LocalPoint& p) const { - return (p.perp() <= _np_column_radius); +const bool Pixel3DDigitizerAlgorithm::_is_inside_n_column(const LocalPoint& p, const float & sensor_thickness) const { + // The insensitive volume of the column: sensor thickness - column gap distance + return (p.perp() <= _np_column_radius && p.z() <= (sensor_thickness - _np_column_gap)); } const bool Pixel3DDigitizerAlgorithm::_is_inside_ohmic_column(const LocalPoint& p, @@ -95,7 +96,7 @@ const bool Pixel3DDigitizerAlgorithm::_is_inside_ohmic_column(const LocalPoint& // Diffusion algorithm: Probably not needed, // Assuming the position point is given in the reference system of the proxy -// cell, centered at the n-column corner. +// cell, centered at the n-column. // The algorithm assumes only 1-axis could produce the charge migration, this assumption // could be enough given that the p-columns (5 um radius) are in the corners of the cell // (no producing charge in there) @@ -304,7 +305,7 @@ std::vector Pixel3DDigitizerAlgorithm::drift( << "\nNe=" << super_charge.energy() << " electrons"; // Check if the point is inside any of the column --> no charge was actually created then - if (_is_inside_n_column(position_at_pc) || _is_inside_ohmic_column(position_at_pc, half_pitch)) { + if (_is_inside_n_column(position_at_pc, thickness) || _is_inside_ohmic_column(position_at_pc, half_pitch)) { LogDebug("Pixel3DDigitizerAlgorithm::drift") << "Remove charge, inside the n-column or p-column!!"; continue; } diff --git a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.h b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.h index 98685ffd70b93..096cd22b61a04 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.h +++ b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.h @@ -55,13 +55,15 @@ class Pixel3DDigitizerAlgorithm : public Phase2TrackerDigitizerAlgorithm { const std::vector& collection_points) override; private: - // Raidus of Column np and ohmic - float _np_column_radius; - float _ohm_column_radius; + // Radius of Column np and ohmic + const float _np_column_radius; + const float _ohm_column_radius; + // Gap of np column + const float _np_column_gap; // Check if a carrier is inside the column: The point should // be described in the pixel cell frame - const bool _is_inside_n_column(const LocalPoint& p) const; + const bool _is_inside_n_column(const LocalPoint& p, const float & sensor_thickness) const; const bool _is_inside_ohmic_column(const LocalPoint& p, const std::pair& pitch) const; }; #endif diff --git a/SimTracker/SiPhase2Digitizer/python/phase2TrackerDigitizer_cfi.py b/SimTracker/SiPhase2Digitizer/python/phase2TrackerDigitizer_cfi.py index e4982335446af..e25168592bec7 100644 --- a/SimTracker/SiPhase2Digitizer/python/phase2TrackerDigitizer_cfi.py +++ b/SimTracker/SiPhase2Digitizer/python/phase2TrackerDigitizer_cfi.py @@ -203,6 +203,11 @@ ) ) +# Add some additional parameters for 3D pixels +phase2TrackerDigitizer.Pixel3DDigitizerAlgorithm.NPColumnRadius = cms.double(4.0) +phase2TrackerDigitizer.Pixel3DDigitizerAlgorithm.OhmicColumnRadius = cms.double(4.0) +phase2TrackerDigitizer.Pixel3DDigitizerAlgorithm.NPColumnGap = cms.double(46.0) + # For premixing stage1 # - add noise as by default # - do not add noisy pixels (to be done in stage2) From 968575eceb3cb3d1c9fff216391666783e094feb Mon Sep 17 00:00:00 2001 From: claralasa Date: Fri, 23 Oct 2020 18:45:06 +0200 Subject: [PATCH 3/8] Add missing change in commit b3617334 --- .../SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc index 9fb1c671e0d02..f9f518095c99c 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc +++ b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc @@ -292,7 +292,7 @@ std::vector Pixel3DDigitizerAlgorithm::drift( // Changing the reference frame to the proxy pixel cell LocalPoint position_at_pc(relative_position_at_pc.first - center_proxy_cell.x(), relative_position_at_pc.second - center_proxy_cell.y(), - super_charge.z()); + super_charge.z() - center_proxy_cell.z()); LogDebug("Pixel3DDigitizerAlgorithm::drift") << "(super-)Charge\nlocal position: (" << super_charge.x() * 1.0_um_inv << ", " << super_charge.y() * 1.0_um_inv From 23d42ab1ee9723a3f095d212a46b17793eb5f5b9 Mon Sep 17 00:00:00 2001 From: claralasa Date: Wed, 28 Oct 2020 11:18:48 +0100 Subject: [PATCH 4/8] Improve validator logic: loop based on PSimHit --- .../test/PixelTestBeamValidation.cc | 302 +++++++++--------- .../test/PixelTestBeamValidation.h | 6 + 2 files changed, 156 insertions(+), 152 deletions(-) diff --git a/SimTracker/SiPhase2Digitizer/test/PixelTestBeamValidation.cc b/SimTracker/SiPhase2Digitizer/test/PixelTestBeamValidation.cc index 7b25fd9166494..b8a9049d0274d 100644 --- a/SimTracker/SiPhase2Digitizer/test/PixelTestBeamValidation.cc +++ b/SimTracker/SiPhase2Digitizer/test/PixelTestBeamValidation.cc @@ -20,7 +20,6 @@ #include "DataFormats/Math/interface/CMSUnits.h" #include "DataFormats/TrackerCommon/interface/TrackerTopology.h" #include "DataFormats/Common/interface/Handle.h" -#include "DataFormats/DetId/interface/DetId.h" // system #include @@ -192,175 +191,154 @@ void PixelTestBeamValidation::analyze(const edm::Event& iEvent, const edm::Event const int layer = topo->layer(detId); // Get the relevant histo key const auto& me_unit = meUnit_(tkDetUnit->type().isBarrel(), layer, topo->side(detId)); + + // Get the id of the detector unit + const unsigned int detId_raw = detId.rawId(); + + // Loop over the simhits to obtain the list of PSimHits created + // in this detector unit + std::vector it_simhits; + + for (const auto* sh_c : simhits){ + for (const auto& sh : *sh_c){ + if (sh.detUnitId() == detId_raw){ + it_simhits.push_back(&sh); //insert and/or reserve (?) + } + } + } - // Find simulated digis links on this det unit - const auto& it_simdigilink = simdigis->find(detId); - if (it_simdigilink == simdigis->end()) { - // FIXME: CHeck if there is any digi ... Should not + if (it_simhits.size() == 0){ continue; } - // Find created RAW digis on this det unit + // Find RAW digis (digis) created in this det unit const auto& it_digis = digis->find(detId); - /*if(it_digilink == digis->end()) - { - // FIXME: CHeck if there is any digi ... Should not - //continue; - }*/ + //std::cout << "DETECTOR: " << tkDetUnit->type().name() << " ME UNIT: " << me_unit << std::endl; - // Loop over the simulated digi links to obtain the list channels - // illuminated by each trackId. Use the trackIds to get the PSimHit - // (the actual particle deposits per detector unit) and try to match them - // with the raw digi, using the channels associated with the trackIds - std::map> stracks_channels; - for (const auto& dhsim : *it_simdigilink) { - const int current_channel = dhsim.channel(); - // Already processed (ignoring fractions in the same pixel channel) - if (stracks_channels.find(dhsim.SimTrackId()) != stracks_channels.end()) { - if (stracks_channels[dhsim.SimTrackId()].find(current_channel) != stracks_channels[dhsim.SimTrackId()].end()) { + // Loop over the list of PSimHits (i.e. the deposits created + // by the primary+secundaries) to check if they are associated with + // some digi, that is, if the simdigi link exists and to obtain the list + // of channels illuminated + for (const auto* psh : it_simhits){ + + // Check user conditions to accept the hits + if (!use_this_track_(psh)) { + continue; + } + // Fill some sim histograms + const GlobalPoint tk_ep_gbl(dunit->surface().toGlobal(psh->entryPoint())); + vME_track_XYMap_->Fill(tk_ep_gbl.x(), tk_ep_gbl.y()); + vME_track_RZMap_->Fill(tk_ep_gbl.z(), std::hypot(tk_ep_gbl.x(), tk_ep_gbl.y())); + vME_track_dxdzAngle_[me_unit]->Fill(std::atan2(psh->momentumAtEntry().x(), psh->momentumAtEntry().z())); + vME_track_dydzAngle_[me_unit]->Fill(std::atan2(psh->momentumAtEntry().y(), psh->momentumAtEntry().z())); + + // Obtain the detected position of the sim particle: + // the middle point between the entry and the exit + const auto psh_pos = tkDetUnit->specificTopology().measurementPosition(psh->localPosition()); + + // MC Cluster finding: get the channels illuminated during digitization by this PSimHit + // based on MC truth info (simdigi links) + const auto psh_channels = get_illuminated_channels_(*psh, detId, simdigis); + + // Get the total charge for this cluster size + // and obtain the center of the cluster using a charge-weighted mean + int cluster_tot = 0; + double cluster_tot_elec = 0.0; + int cluster_size = 0; + std::pair, std::set> cluster_size_xy; + std::pair cluster_position({0.0, 0.0}); + std::set used_channel; + for (const auto& ch : psh_channels) { + // Not re-using the digi XXX + if (used_channel.find(ch) != used_channel.end()) { continue; } + const PixelDigi& current_digi = get_digi_from_channel_(ch, it_digis); + used_channel.insert(ch); + // Fill the digi histograms + vME_digi_charge1D_[me_unit]->Fill(current_digi.adc()); + // Fill maps: get the position in the sensor local frame to convert into global + const LocalPoint digi_local_pos( + tkDetUnit->specificTopology().localPosition(MeasurementPoint(current_digi.row(), current_digi.column()))); + const GlobalPoint digi_global_pos(dunit->surface().toGlobal(digi_local_pos)); + vME_digi_XYMap_->Fill(digi_global_pos.x(), digi_global_pos.y()); + vME_digi_RZMap_->Fill(digi_global_pos.z(), std::hypot(digi_global_pos.x(), digi_global_pos.y())); + // Create the MC-cluster + cluster_tot += current_digi.adc(); + // Add 0.5 to allow ToT = 0 (valid value) + cluster_tot_elec += (current_digi.adc() + 0.5) * electronsPerADC_; + // Use the center of the pixel + cluster_position.first += current_digi.adc() * (current_digi.row() + 0.5); + cluster_position.second += current_digi.adc() * (current_digi.column() + 0.5); + // Size + cluster_size_xy.first.insert(current_digi.row()); + cluster_size_xy.second.insert(current_digi.column()); + ++cluster_size; } - // Create/update the list of channels created by this - // simtrackId: remember primaries and secondaries share the same id - stracks_channels[dhsim.SimTrackId()].insert(current_channel); - } - // Loop over each trackId to get the list of PSimHits (i.e. the deposits created - // by the primary+secundaries) - for (const auto& st_ch : stracks_channels) { - // -- Get the set of simulated hits from this trackid. - // -- Each Particle SimHit (PSimHit) is defining a particle passing through the detector unit - const std::vector current_psimhits = - get_simhits_from_trackid_(st_ch.first, detId.rawId(), simhits); - //const auto current_pixel(PixelDigi::channelToPixel(ch)); - - // -- Loop over the PSimHits and match with the digi clusters - for (const auto* ps : current_psimhits) { - // Check user conditions to accept the hits - if (!use_this_track_(ps)) { - continue; - } - // Fill some sim histograms - const GlobalPoint tk_ep_gbl(dunit->surface().toGlobal(ps->entryPoint())); - vME_track_XYMap_->Fill(tk_ep_gbl.x(), tk_ep_gbl.y()); - vME_track_RZMap_->Fill(tk_ep_gbl.z(), std::hypot(tk_ep_gbl.x(), tk_ep_gbl.y())); - vME_track_dxdzAngle_[me_unit]->Fill(std::atan2(ps->momentumAtEntry().x(), ps->momentumAtEntry().z())); - vME_track_dydzAngle_[me_unit]->Fill(std::atan2(ps->momentumAtEntry().y(), ps->momentumAtEntry().z())); - - // Obtain the detected position of the sim particle: - // the middle point between the entry and the exit - const auto psh_pos = tkDetUnit->specificTopology().measurementPosition(ps->localPosition()); - - // Build the digi MC-truth clusters by matching each Particle - // sim hit position pixel cell. The matching condition: - // - a digi is created by the i-PSimHit if PsimHit_{pixel}+-1 - - // Get the total charge for this cluster size - // and obtain the center of the cluster using a charge-weighted mean - int cluster_tot = 0; - double cluster_tot_elec = 0.0; - int cluster_size = 0; - std::pair, std::set> cluster_size_xy; - std::pair cluster_position({0.0, 0.0}); - std::set used_channel; - for (const auto& ch : st_ch.second) { - // Not re-using the digi - if (used_channel.find(ch) != used_channel.end()) { - continue; - } - // Digi was created by the current psimhit? - // Accepting +-2 pixel -- XXX: Actually the entryPoint-exitPoint - // could provide the extension of the cluster - //if( ! channel_iluminated_by_(psh_pos,ch,2.0) ) - // XXX FIXME: CHANGE the loop in order to use get_illuminated_pixels_ XXX - if (!channel_iluminated_by_(*ps, ch, tkDetUnit)) { - continue; - } - const PixelDigi& current_digi = get_digi_from_channel_(ch, it_digis); - used_channel.insert(ch); - // Fill the digi histograms - vME_digi_charge1D_[me_unit]->Fill(current_digi.adc()); - // Fill maps: get the position in the sensor local frame to convert into global - const LocalPoint digi_local_pos( - tkDetUnit->specificTopology().localPosition(MeasurementPoint(current_digi.row(), current_digi.column()))); - const GlobalPoint digi_global_pos(dunit->surface().toGlobal(digi_local_pos)); - vME_digi_XYMap_->Fill(digi_global_pos.x(), digi_global_pos.y()); - vME_digi_RZMap_->Fill(digi_global_pos.z(), std::hypot(digi_global_pos.x(), digi_global_pos.y())); - // Create the MC-cluster - cluster_tot += current_digi.adc(); - // Add 0.5 to allow ToT = 0 (valid value) - cluster_tot_elec += (current_digi.adc() + 0.5) * electronsPerADC_; - // Use the center of the pixel - cluster_position.first += current_digi.adc() * (current_digi.row() + 0.5); - cluster_position.second += current_digi.adc() * (current_digi.column() + 0.5); - // Size - cluster_size_xy.first.insert(current_digi.row()); - cluster_size_xy.second.insert(current_digi.column()); - ++cluster_size; - } - // Be careful here, there is 1 entry per each simhit - vME_clsize1D_[me_unit]->Fill(cluster_size); - vME_clsize1Dx_[me_unit]->Fill(cluster_size_xy.first.size()); - vME_clsize1Dy_[me_unit]->Fill(cluster_size_xy.second.size()); - - // mean weighted - cluster_position.first /= double(cluster_tot); - cluster_position.second /= double(cluster_tot); - - // -- XXX Be careful, secondaries with already used the digis - // are going the be lost (then lost on efficiency) - // Efficiency --> It was found a cluster of digis? - const bool is_cluster_present = (cluster_size > 0); - - // Get topology info of the module sensor - //-const int n_rows = tkDetUnit->specificTopology().nrows(); - //-const int n_cols = tkDetUnit->specificTopology().ncolumns(); - const auto pitch = tkDetUnit->specificTopology().pitch(); - // Residuals, convert them to longitud units (so far, in units of row, col) - const double dx_um = (psh_pos.x() - cluster_position.first) * pitch.first * 1.0_inv_um; - const double dy_um = (psh_pos.y() - cluster_position.second) * pitch.second * 1.0_inv_um; + // Be careful here, there is 1 entry per each simhit + vME_clsize1D_[me_unit]->Fill(cluster_size); + vME_clsize1Dx_[me_unit]->Fill(cluster_size_xy.first.size()); + vME_clsize1Dy_[me_unit]->Fill(cluster_size_xy.second.size()); + + // mean weighted + cluster_position.first /= double(cluster_tot); + cluster_position.second /= double(cluster_tot); + + // -- XXX Be careful, secondaries with already used the digis + // are going the be lost (then lost on efficiency) + // Efficiency --> It was found a cluster of digis? + const bool is_cluster_present = (cluster_size > 0); + + // Get topology info of the module sensor + //-const int n_rows = tkDetUnit->specificTopology().nrows(); + //-const int n_cols = tkDetUnit->specificTopology().ncolumns(); + const auto pitch = tkDetUnit->specificTopology().pitch(); + // Residuals, convert them to longitud units (so far, in units of row, col) + const double dx_um = (psh_pos.x() - cluster_position.first) * pitch.first * 1.0_inv_um; + const double dy_um = (psh_pos.y() - cluster_position.second) * pitch.second * 1.0_inv_um; + if (is_cluster_present) { + vME_charge1D_[me_unit]->Fill(cluster_tot); + vME_charge_elec1D_[me_unit]->Fill(cluster_tot_elec); + vME_dx1D_[me_unit]->Fill(dx_um); + vME_dy1D_[me_unit]->Fill(dy_um); + // The track energy loss corresponding to that cluster + vME_sim_cluster_charge_[me_unit]->Fill(psh->energyLoss() * 1.0_inv_keV, cluster_tot_elec); + } + // Histograms per cell + for (unsigned int i = 0; i < vME_position_cell_[me_unit].size(); ++i) { + // Convert the PSimHit center position to the IxI-cell + const std::pair icell_psh = pixel_cell_transformation_(psh_pos, i, pitch); + // Efficiency: (PSimHit matched to a digi-cluster)/PSimHit + vME_eff_cell_[me_unit][i]->Fill( + icell_psh.first * 1.0_inv_um, icell_psh.second * 1.0_inv_um, is_cluster_present); + vME_pshpos_cell_[me_unit][i]->Fill(icell_psh.first * 1.0_inv_um, icell_psh.second * 1.0_inv_um); + // Digi clusters related histoos if (is_cluster_present) { - vME_charge1D_[me_unit]->Fill(cluster_tot); - vME_charge_elec1D_[me_unit]->Fill(cluster_tot_elec); - vME_dx1D_[me_unit]->Fill(dx_um); - vME_dy1D_[me_unit]->Fill(dy_um); - // The track energy loss corresponding to that cluster - vME_sim_cluster_charge_[me_unit]->Fill(ps->energyLoss() * 1.0_inv_keV, cluster_tot_elec); - } - // Histograms per cell - for (unsigned int i = 0; i < vME_position_cell_[me_unit].size(); ++i) { - // Convert the PSimHit center position to the IxI-cell - const std::pair icell_psh = pixel_cell_transformation_(psh_pos, i, pitch); - // Efficiency: (PSimHit matched to a digi-cluster)/PSimHit - vME_eff_cell_[me_unit][i]->Fill( - icell_psh.first * 1.0_inv_um, icell_psh.second * 1.0_inv_um, is_cluster_present); - vME_pshpos_cell_[me_unit][i]->Fill(icell_psh.first * 1.0_inv_um, icell_psh.second * 1.0_inv_um); - // Digi clusters related histoos - if (is_cluster_present) { - // Convert to the i-cell - //const std::pair icell_digi_cluster = pixel_cell_transformation_(cluster_position,i,pitch); - // Position - vME_position_cell_[me_unit][i]->Fill(icell_psh.first * 1.0_inv_um, icell_psh.second * 1.0_inv_um); - // Residuals - vME_dx_cell_[me_unit][i]->Fill(icell_psh.first * 1.0_inv_um, icell_psh.second * 1.0_inv_um, dx_um); - vME_dy_cell_[me_unit][i]->Fill(icell_psh.first * 1.0_inv_um, icell_psh.second * 1.0_inv_um, dy_um); - // Charge - vME_charge_cell_[me_unit][i]->Fill( - icell_psh.first * 1.0_inv_um, icell_psh.second * 1.0_inv_um, cluster_tot); - vME_charge_elec_cell_[me_unit][i]->Fill( - icell_psh.first * 1.0_inv_um, icell_psh.second * 1.0_inv_um, cluster_tot_elec); - // Cluster size - vME_clsize_cell_[me_unit][i]->Fill( - icell_psh.first * 1.0_inv_um, icell_psh.second * 1.0_inv_um, cluster_size); - } + // Convert to the i-cell + //const std::pair icell_digi_cluster = pixel_cell_transformation_(cluster_position,i,pitch); + // Position + vME_position_cell_[me_unit][i]->Fill(icell_psh.first * 1.0_inv_um, icell_psh.second * 1.0_inv_um); + // Residuals + vME_dx_cell_[me_unit][i]->Fill(icell_psh.first * 1.0_inv_um, icell_psh.second * 1.0_inv_um, dx_um); + vME_dy_cell_[me_unit][i]->Fill(icell_psh.first * 1.0_inv_um, icell_psh.second * 1.0_inv_um, dy_um); + // Charge + vME_charge_cell_[me_unit][i]->Fill( + icell_psh.first * 1.0_inv_um, icell_psh.second * 1.0_inv_um, cluster_tot); + vME_charge_elec_cell_[me_unit][i]->Fill( + icell_psh.first * 1.0_inv_um, icell_psh.second * 1.0_inv_um, cluster_tot_elec); + // Cluster size + vME_clsize_cell_[me_unit][i]->Fill( + icell_psh.first * 1.0_inv_um, icell_psh.second * 1.0_inv_um, cluster_size); } } } } } + + // // -- Book Histograms // @@ -705,6 +683,26 @@ bool PixelTestBeamValidation::channel_iluminated_by_(const PSimHit& ps, return false; } +std::set PixelTestBeamValidation::get_illuminated_channels_(const PSimHit& ps, + const DetId& detid, + const edm::DetSetVector* simdigis){ + // Find simulated digi links (simdigis) created in this det unit + const auto& it_simdigilink = simdigis->find(detid); + + if (it_simdigilink == simdigis->end()){ + return std::set(); + } + + std::set channels; + for (const auto& hdsim : *it_simdigilink){ + if (ps.trackId() == hdsim.SimTrackId()){ + channels.insert(hdsim.channel()); + } + } + return channels; +} + + std::set> PixelTestBeamValidation::get_illuminated_pixels_(const PSimHit& ps, const PixelGeomDetUnit* tkDetUnit) { auto ps_key = reinterpret_cast(&ps); diff --git a/SimTracker/SiPhase2Digitizer/test/PixelTestBeamValidation.h b/SimTracker/SiPhase2Digitizer/test/PixelTestBeamValidation.h index 230433d42d625..bc246c7f51515 100644 --- a/SimTracker/SiPhase2Digitizer/test/PixelTestBeamValidation.h +++ b/SimTracker/SiPhase2Digitizer/test/PixelTestBeamValidation.h @@ -31,6 +31,7 @@ #include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h" #include "SimDataFormats/TrackerDigiSimLink/interface/PixelDigiSimLink.h" #include "SimDataFormats/Track/interface/SimTrackContainer.h" +#include "DataFormats/DetId/interface/DetId.h" // system #include @@ -91,6 +92,11 @@ class PixelTestBeamValidation : public DQMEDAnalyzer { //bool channel_iluminated_by_(const MeasurementPoint & localpos,int channel, double tolerance) const; bool channel_iluminated_by_(const PSimHit &localpos, int channel, const PixelGeomDetUnit *tkDet); + // The list of channels illuminated by the PSimHit + std::set get_illuminated_channels_(const PSimHit& ps, + const DetId& detid, + const edm::DetSetVector* simdigis); + // The list of pixels illuminated by the PSimHit std::set> get_illuminated_pixels_(const PSimHit &ps, const PixelGeomDetUnit *tkDetUnit); From 1769b9fde9ddbd689fd8f4bf668cc57362555585 Mon Sep 17 00:00:00 2001 From: claralasa Date: Wed, 28 Oct 2020 18:36:24 +0100 Subject: [PATCH 5/8] Fix code style --- .../plugins/Pixel3DDigitizerAlgorithm.cc | 20 +++++++---- .../plugins/Pixel3DDigitizerAlgorithm.h | 4 +-- .../test/PixelTestBeamValidation.cc | 36 ++++++++----------- .../test/PixelTestBeamValidation.h | 6 ++-- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc index f9f518095c99c..8db9c5a20675f 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc +++ b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc @@ -53,9 +53,15 @@ void Pixel3DDigitizerAlgorithm::init(const edm::EventSetup& es) { Pixel3DDigitizerAlgorithm::Pixel3DDigitizerAlgorithm(const edm::ParameterSet& conf) : Phase2TrackerDigitizerAlgorithm(conf.getParameter("AlgorithmCommon"), conf.getParameter("Pixel3DDigitizerAlgorithm")), - _np_column_radius((conf.getParameter("Pixel3DDigitizerAlgorithm").getParameter("NPColumnRadius"))*1.0_um), - _ohm_column_radius((conf.getParameter("Pixel3DDigitizerAlgorithm").getParameter("OhmicColumnRadius"))*1.0_um), - _np_column_gap((conf.getParameter("Pixel3DDigitizerAlgorithm").getParameter("NPColumnGap"))*1.0_um) { + _np_column_radius( + (conf.getParameter("Pixel3DDigitizerAlgorithm").getParameter("NPColumnRadius")) * + 1.0_um), + _ohm_column_radius( + (conf.getParameter("Pixel3DDigitizerAlgorithm").getParameter("OhmicColumnRadius")) * + 1.0_um), + _np_column_gap( + (conf.getParameter("Pixel3DDigitizerAlgorithm").getParameter("NPColumnGap")) * + 1.0_um) { // XXX - NEEDED? pixelFlag_ = true; @@ -80,7 +86,7 @@ bool Pixel3DDigitizerAlgorithm::select_hit(const PSimHit& hit, double tCorr, dou return (time >= theTofLowerCut_ && time < theTofUpperCut_); } -const bool Pixel3DDigitizerAlgorithm::_is_inside_n_column(const LocalPoint& p, const float & sensor_thickness) const { +const bool Pixel3DDigitizerAlgorithm::_is_inside_n_column(const LocalPoint& p, const float& sensor_thickness) const { // The insensitive volume of the column: sensor thickness - column gap distance return (p.perp() <= _np_column_radius && p.z() <= (sensor_thickness - _np_column_gap)); } @@ -323,9 +329,9 @@ std::vector Pixel3DDigitizerAlgorithm::drift( const float pixel_x = current_pixel_int.first + (mc.x() + center_proxy_cell.x()) / pitch.first; const float pixel_y = current_pixel_int.second + (mc.y() + center_proxy_cell.y()) / pitch.second; const auto lp = pixdet->specificTopology().localPosition(MeasurementPoint(pixel_x, pixel_y)); - //Remember: the drift function will move the reference system to the bottom. We need to add what we previously subtract - //in order to avoid a double translation when calling the drift function once again below - mc.migrate_position(LocalPoint(lp.x(), lp.y(), mc.z() + center_proxy_cell.z())); + //Remember: the drift function will move the reference system to the bottom. We need to add what we previously subtract + //in order to avoid a double translation when calling the drift function once again below + mc.migrate_position(LocalPoint(lp.x(), lp.y(), mc.z() + center_proxy_cell.z())); } if (!migrated_charges.empty()) { LogDebug("Pixel3DDigitizerAlgorithm::drift") << "****************" diff --git a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.h b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.h index 096cd22b61a04..6bb7f3ca369b4 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.h +++ b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.h @@ -59,11 +59,11 @@ class Pixel3DDigitizerAlgorithm : public Phase2TrackerDigitizerAlgorithm { const float _np_column_radius; const float _ohm_column_radius; // Gap of np column - const float _np_column_gap; + const float _np_column_gap; // Check if a carrier is inside the column: The point should // be described in the pixel cell frame - const bool _is_inside_n_column(const LocalPoint& p, const float & sensor_thickness) const; + const bool _is_inside_n_column(const LocalPoint& p, const float& sensor_thickness) const; const bool _is_inside_ohmic_column(const LocalPoint& p, const std::pair& pitch) const; }; #endif diff --git a/SimTracker/SiPhase2Digitizer/test/PixelTestBeamValidation.cc b/SimTracker/SiPhase2Digitizer/test/PixelTestBeamValidation.cc index b8a9049d0274d..d7145e4c8ef7e 100644 --- a/SimTracker/SiPhase2Digitizer/test/PixelTestBeamValidation.cc +++ b/SimTracker/SiPhase2Digitizer/test/PixelTestBeamValidation.cc @@ -191,7 +191,7 @@ void PixelTestBeamValidation::analyze(const edm::Event& iEvent, const edm::Event const int layer = topo->layer(detId); // Get the relevant histo key const auto& me_unit = meUnit_(tkDetUnit->type().isBarrel(), layer, topo->side(detId)); - + // Get the id of the detector unit const unsigned int detId_raw = detId.rawId(); @@ -199,15 +199,15 @@ void PixelTestBeamValidation::analyze(const edm::Event& iEvent, const edm::Event // in this detector unit std::vector it_simhits; - for (const auto* sh_c : simhits){ - for (const auto& sh : *sh_c){ - if (sh.detUnitId() == detId_raw){ - it_simhits.push_back(&sh); //insert and/or reserve (?) - } + for (const auto* sh_c : simhits) { + for (const auto& sh : *sh_c) { + if (sh.detUnitId() == detId_raw) { + it_simhits.push_back(&sh); //insert and/or reserve (?) + } } } - if (it_simhits.size() == 0){ + if (it_simhits.size() == 0) { continue; } @@ -220,8 +220,7 @@ void PixelTestBeamValidation::analyze(const edm::Event& iEvent, const edm::Event // by the primary+secundaries) to check if they are associated with // some digi, that is, if the simdigi link exists and to obtain the list // of channels illuminated - for (const auto* psh : it_simhits){ - + for (const auto* psh : it_simhits) { // Check user conditions to accept the hits if (!use_this_track_(psh)) { continue; @@ -324,21 +323,17 @@ void PixelTestBeamValidation::analyze(const edm::Event& iEvent, const edm::Event vME_dx_cell_[me_unit][i]->Fill(icell_psh.first * 1.0_inv_um, icell_psh.second * 1.0_inv_um, dx_um); vME_dy_cell_[me_unit][i]->Fill(icell_psh.first * 1.0_inv_um, icell_psh.second * 1.0_inv_um, dy_um); // Charge - vME_charge_cell_[me_unit][i]->Fill( - icell_psh.first * 1.0_inv_um, icell_psh.second * 1.0_inv_um, cluster_tot); + vME_charge_cell_[me_unit][i]->Fill(icell_psh.first * 1.0_inv_um, icell_psh.second * 1.0_inv_um, cluster_tot); vME_charge_elec_cell_[me_unit][i]->Fill( icell_psh.first * 1.0_inv_um, icell_psh.second * 1.0_inv_um, cluster_tot_elec); // Cluster size - vME_clsize_cell_[me_unit][i]->Fill( - icell_psh.first * 1.0_inv_um, icell_psh.second * 1.0_inv_um, cluster_size); + vME_clsize_cell_[me_unit][i]->Fill(icell_psh.first * 1.0_inv_um, icell_psh.second * 1.0_inv_um, cluster_size); } } } } } - - // // -- Book Histograms // @@ -684,25 +679,24 @@ bool PixelTestBeamValidation::channel_iluminated_by_(const PSimHit& ps, } std::set PixelTestBeamValidation::get_illuminated_channels_(const PSimHit& ps, - const DetId& detid, - const edm::DetSetVector* simdigis){ + const DetId& detid, + const edm::DetSetVector* simdigis) { // Find simulated digi links (simdigis) created in this det unit const auto& it_simdigilink = simdigis->find(detid); - if (it_simdigilink == simdigis->end()){ + if (it_simdigilink == simdigis->end()) { return std::set(); } std::set channels; - for (const auto& hdsim : *it_simdigilink){ - if (ps.trackId() == hdsim.SimTrackId()){ + for (const auto& hdsim : *it_simdigilink) { + if (ps.trackId() == hdsim.SimTrackId()) { channels.insert(hdsim.channel()); } } return channels; } - std::set> PixelTestBeamValidation::get_illuminated_pixels_(const PSimHit& ps, const PixelGeomDetUnit* tkDetUnit) { auto ps_key = reinterpret_cast(&ps); diff --git a/SimTracker/SiPhase2Digitizer/test/PixelTestBeamValidation.h b/SimTracker/SiPhase2Digitizer/test/PixelTestBeamValidation.h index bc246c7f51515..25720d0020e37 100644 --- a/SimTracker/SiPhase2Digitizer/test/PixelTestBeamValidation.h +++ b/SimTracker/SiPhase2Digitizer/test/PixelTestBeamValidation.h @@ -93,9 +93,9 @@ class PixelTestBeamValidation : public DQMEDAnalyzer { bool channel_iluminated_by_(const PSimHit &localpos, int channel, const PixelGeomDetUnit *tkDet); // The list of channels illuminated by the PSimHit - std::set get_illuminated_channels_(const PSimHit& ps, - const DetId& detid, - const edm::DetSetVector* simdigis); + std::set get_illuminated_channels_(const PSimHit &ps, + const DetId &detid, + const edm::DetSetVector *simdigis); // The list of pixels illuminated by the PSimHit std::set> get_illuminated_pixels_(const PSimHit &ps, const PixelGeomDetUnit *tkDetUnit); From 7b5c3720b6b9640812c7aa8f41278ca2acd71712 Mon Sep 17 00:00:00 2001 From: claralasa Date: Thu, 29 Oct 2020 10:24:36 +0100 Subject: [PATCH 6/8] Fix variable naming and code structure --- .../plugins/Pixel3DDigitizerAlgorithm.cc | 58 +++++++++---------- .../plugins/Pixel3DDigitizerAlgorithm.h | 10 ++-- .../python/phase2TrackerDigitizer_cfi.py | 13 +++-- 3 files changed, 41 insertions(+), 40 deletions(-) diff --git a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc index 8db9c5a20675f..51d7ebd9b36aa 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc +++ b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc @@ -53,13 +53,13 @@ void Pixel3DDigitizerAlgorithm::init(const edm::EventSetup& es) { Pixel3DDigitizerAlgorithm::Pixel3DDigitizerAlgorithm(const edm::ParameterSet& conf) : Phase2TrackerDigitizerAlgorithm(conf.getParameter("AlgorithmCommon"), conf.getParameter("Pixel3DDigitizerAlgorithm")), - _np_column_radius( + np_column_radius_( (conf.getParameter("Pixel3DDigitizerAlgorithm").getParameter("NPColumnRadius")) * 1.0_um), - _ohm_column_radius( + ohm_column_radius_( (conf.getParameter("Pixel3DDigitizerAlgorithm").getParameter("OhmicColumnRadius")) * 1.0_um), - _np_column_gap( + np_column_gap_( (conf.getParameter("Pixel3DDigitizerAlgorithm").getParameter("NPColumnGap")) * 1.0_um) { // XXX - NEEDED? @@ -86,18 +86,18 @@ bool Pixel3DDigitizerAlgorithm::select_hit(const PSimHit& hit, double tCorr, dou return (time >= theTofLowerCut_ && time < theTofUpperCut_); } -const bool Pixel3DDigitizerAlgorithm::_is_inside_n_column(const LocalPoint& p, const float& sensor_thickness) const { +const bool Pixel3DDigitizerAlgorithm::is_inside_n_column_(const LocalPoint& p, const float& sensor_thickness) const { // The insensitive volume of the column: sensor thickness - column gap distance - return (p.perp() <= _np_column_radius && p.z() <= (sensor_thickness - _np_column_gap)); + return (p.perp() <= np_column_radius_ && p.z() <= (sensor_thickness - np_column_gap_)); } -const bool Pixel3DDigitizerAlgorithm::_is_inside_ohmic_column(const LocalPoint& p, +const bool Pixel3DDigitizerAlgorithm::is_inside_ohmic_column_(const LocalPoint& p, const std::pair& half_pitch) const { // The four corners of the cell - return ((p - LocalVector(half_pitch.first, half_pitch.second, 0)).perp() <= _ohm_column_radius) || - ((p - LocalVector(-half_pitch.first, half_pitch.second, 0)).perp() <= _ohm_column_radius) || - ((p - LocalVector(half_pitch.first, -half_pitch.second, 0)).perp() <= _ohm_column_radius) || - ((p - LocalVector(-half_pitch.first, -half_pitch.second, 0)).perp() <= _ohm_column_radius); + return ((p - LocalVector(half_pitch.first, half_pitch.second, 0)).perp() <= ohm_column_radius_) || + ((p - LocalVector(-half_pitch.first, half_pitch.second, 0)).perp() <= ohm_column_radius_) || + ((p - LocalVector(half_pitch.first, -half_pitch.second, 0)).perp() <= ohm_column_radius_) || + ((p - LocalVector(-half_pitch.first, -half_pitch.second, 0)).perp() <= ohm_column_radius_); } // Diffusion algorithm: Probably not needed, @@ -119,17 +119,17 @@ std::vector Pixel3DDigitizerAlgorithm::diff // With the current sigma, this value is dependent of the thickness, // Note that this formulae is coming from planar sensors, a similar // study with data will be needed to extract the sigma for 3D - const float _max_migration_radius = 0.4_um; + const float max_migration_radius_ = 0.4_um; // Need to know which axis is the relevant one int displ_ind = -1; float pitch = 0.0; // Check the group is near the edge of the pixel, so diffusion will // be relevant in order to migrate between pixel cells - if (std::abs(pos.x() - hpitches.first) < _max_migration_radius) { + if (std::abs(pos.x() - hpitches.first) < max_migration_radius_) { displ_ind = 0; pitch = hpitches.first; - } else if (std::abs(pos.y() - hpitches.second) < _max_migration_radius) { + } else if (std::abs(pos.y() - hpitches.second) < max_migration_radius_) { displ_ind = 1; pitch = hpitches.second; } else { @@ -142,30 +142,30 @@ std::vector Pixel3DDigitizerAlgorithm::diff std::vector migrated_charge; // FIXME -- DM - const float _diffusion_step = 0.1_um; + const float diffusion_step_ = 0.1_um; // The position while drifting std::vector pos_moving({pos.x(), pos.y(), pos.z()}); // The drifting: drift field and steps std::function(int)> do_step = - [&pos_moving, &u_drift, _diffusion_step](int i) -> std::vector { + [&pos_moving, &u_drift, diffusion_step_](int i) -> std::vector { auto dd = u_drift(pos_moving[0], pos_moving[1]); return std::vector( - {i * _diffusion_step * dd.x(), i * _diffusion_step * dd.y(), i * _diffusion_step * dd.z()}); + {i * diffusion_step_ * dd.x(), i * diffusion_step_ * dd.y(), i * diffusion_step_ * dd.z()}); }; LogDebug("Pixel3DDigitizerAlgorithm::diffusion") - << "\nMax. radius from the pixel edge to migrate charge: " << _max_migration_radius * 1.0_um_inv << " [um]" + << "\nMax. radius from the pixel edge to migrate charge: " << max_migration_radius_ * 1.0_um_inv << " [um]" << "\nMigration axis: " << displ_ind << "\n(super-)Charge distance to the pixel edge: " << (pitch - pos_moving[displ_ind]) * 1.0_um_inv << " [um]"; // FIXME -- Sigma reference, DM? - const float _distance0 = 300.0_um; - const float _sigma0 = 3.4_um; + const float distance0_ = 300.0_um; + const float sigma0_ = 3.4_um; // FIXME -- Tolerance, DM? - const float _TOL = 1e-6; + const float TOL_ = 1e-6; // How many sigmas (probably a configurable, to be decided not now) - const float _N_SIGMA = 3.0; + const float N_SIGMA_ = 3.0; // Start the drift and check every step // initial position @@ -178,7 +178,7 @@ std::vector Pixel3DDigitizerAlgorithm::diff std::transform(pos_moving.begin(), pos_moving.end(), do_step(i).begin(), pos_moving.begin(), std::plus()); distance_edge = std::abs(pos_moving[displ_ind] - pitch); // current diffusion value - double sigma = std::sqrt(i * _diffusion_step / _distance0) * (_distance0 / thickness) * _sigma0; + double sigma = std::sqrt(i * diffusion_step_ / distance0_) * (distance0_ / thickness) * sigma0_; // Get the amount of charge on the neighbor pixel: note the // transformation to a Normal float migrated_e = current_carriers * (1.0 - std::erf(distance_edge / sigma)); @@ -191,7 +191,7 @@ std::vector Pixel3DDigitizerAlgorithm::diff // No charge was migrated (ignore creation time) if (i != 0) { // At least 1 electron migrated - if ((migrated_e - _TOL) < 1.0) { + if ((migrated_e - TOL_) < 1.0) { break; } // Move the migrated charge @@ -202,12 +202,12 @@ std::vector Pixel3DDigitizerAlgorithm::diff // except the direction of migration std::vector newpos(pos_moving); // Lest create the new charges around 3 sigmas away - newpos[displ_ind] += std::copysign(_N_SIGMA * sigma, newpos[displ_ind]); + newpos[displ_ind] += std::copysign(N_SIGMA_ * sigma, newpos[displ_ind]); migrated_charge.push_back(DigitizerUtility::EnergyDepositUnit(migrated_e, newpos[0], newpos[1], newpos[2])); } // Next step ++i; - } while (std::abs(distance_edge) < _max_migration_radius); + } while (std::abs(distance_edge) < max_migration_radius_); return migrated_charge; } @@ -273,7 +273,7 @@ std::vector Pixel3DDigitizerAlgorithm::drift( // Radiation damage limit of application // (XXX: No sense for 3D, let this be until decided what algorithm to use) - const float _RAD_DAMAGE = 0.001; + const float RAD_DAMAGE_ = 0.001; for (const auto& super_charge : ionization_points) { // Extract the pixel cell @@ -311,7 +311,7 @@ std::vector Pixel3DDigitizerAlgorithm::drift( << "\nNe=" << super_charge.energy() << " electrons"; // Check if the point is inside any of the column --> no charge was actually created then - if (_is_inside_n_column(position_at_pc, thickness) || _is_inside_ohmic_column(position_at_pc, half_pitch)) { + if (is_inside_n_column_(position_at_pc, thickness) || is_inside_ohmic_column_(position_at_pc, half_pitch)) { LogDebug("Pixel3DDigitizerAlgorithm::drift") << "Remove charge, inside the n-column or p-column!!"; continue; } @@ -348,14 +348,14 @@ std::vector Pixel3DDigitizerAlgorithm::drift( // Perform the drift, and check a potential lost of carriers because // they reach the pasivation region (-z < thickness/2) // XXX: not doing nothing, the carriers reach the electrode surface, - const float drift_distance = position_at_pc.perp() - _np_column_radius; + const float drift_distance = position_at_pc.perp() - np_column_radius_; // Insert a charge loss due to Rad Damage here // XXX: ?? float energyOnCollector = nelectrons; // FIXME: is this correct? Not for 3D... - if (pseudoRadDamage_ >= _RAD_DAMAGE) { + if (pseudoRadDamage_ >= RAD_DAMAGE_) { const float module_radius = pixdet->surface().position().perp(); if (module_radius <= pseudoRadDamageRadius_) { const float kValue = pseudoRadDamage_ / (module_radius * module_radius); diff --git a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.h b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.h index 6bb7f3ca369b4..955315960a5ac 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.h +++ b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.h @@ -56,14 +56,14 @@ class Pixel3DDigitizerAlgorithm : public Phase2TrackerDigitizerAlgorithm { private: // Radius of Column np and ohmic - const float _np_column_radius; - const float _ohm_column_radius; + const float np_column_radius_; + const float ohm_column_radius_; // Gap of np column - const float _np_column_gap; + const float np_column_gap_; // Check if a carrier is inside the column: The point should // be described in the pixel cell frame - const bool _is_inside_n_column(const LocalPoint& p, const float& sensor_thickness) const; - const bool _is_inside_ohmic_column(const LocalPoint& p, const std::pair& pitch) const; + const bool is_inside_n_column_(const LocalPoint& p, const float& sensor_thickness) const; + const bool is_inside_ohmic_column_(const LocalPoint& p, const std::pair& pitch) const; }; #endif diff --git a/SimTracker/SiPhase2Digitizer/python/phase2TrackerDigitizer_cfi.py b/SimTracker/SiPhase2Digitizer/python/phase2TrackerDigitizer_cfi.py index e25168592bec7..4fed519b3cd25 100644 --- a/SimTracker/SiPhase2Digitizer/python/phase2TrackerDigitizer_cfi.py +++ b/SimTracker/SiPhase2Digitizer/python/phase2TrackerDigitizer_cfi.py @@ -84,7 +84,13 @@ #Pixel Digitizer Algorithm PixelDigitizerAlgorithm = PixelDigitizerAlgorithmCommon.clone(), #Pixel-3D Digitizer Algorithm - Pixel3DDigitizerAlgorithm = PixelDigitizerAlgorithmCommon.clone(SigmaCoeff = cms.double(1.80)), + Pixel3DDigitizerAlgorithm = PixelDigitizerAlgorithmCommon.clone( + SigmaCoeff = cms.double(1.80), + NPColumnRadius = cms.double(4.0), + OhmicColumnRadius = cms.double(4.0), + NPColumnGap = cms.double(46.0) + ), + #Pixel in PS Module PSPDigitizerAlgorithm = cms.PSet( ElectronPerAdc = cms.double(135.0), @@ -203,11 +209,6 @@ ) ) -# Add some additional parameters for 3D pixels -phase2TrackerDigitizer.Pixel3DDigitizerAlgorithm.NPColumnRadius = cms.double(4.0) -phase2TrackerDigitizer.Pixel3DDigitizerAlgorithm.OhmicColumnRadius = cms.double(4.0) -phase2TrackerDigitizer.Pixel3DDigitizerAlgorithm.NPColumnGap = cms.double(46.0) - # For premixing stage1 # - add noise as by default # - do not add noisy pixels (to be done in stage2) From 5a0df5627b7309cbb2d89b1c8f4dd026f3caeb86 Mon Sep 17 00:00:00 2001 From: claralasa Date: Thu, 29 Oct 2020 14:58:00 +0100 Subject: [PATCH 7/8] Fix variable naming --- .../plugins/Pixel3DDigitizerAlgorithm.cc | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc index 51d7ebd9b36aa..a1a47e6961501 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc +++ b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc @@ -119,17 +119,17 @@ std::vector Pixel3DDigitizerAlgorithm::diff // With the current sigma, this value is dependent of the thickness, // Note that this formulae is coming from planar sensors, a similar // study with data will be needed to extract the sigma for 3D - const float max_migration_radius_ = 0.4_um; + const float max_migration_radius = 0.4_um; // Need to know which axis is the relevant one int displ_ind = -1; float pitch = 0.0; // Check the group is near the edge of the pixel, so diffusion will // be relevant in order to migrate between pixel cells - if (std::abs(pos.x() - hpitches.first) < max_migration_radius_) { + if (std::abs(pos.x() - hpitches.first) < max_migration_radius) { displ_ind = 0; pitch = hpitches.first; - } else if (std::abs(pos.y() - hpitches.second) < max_migration_radius_) { + } else if (std::abs(pos.y() - hpitches.second) < max_migration_radius) { displ_ind = 1; pitch = hpitches.second; } else { @@ -142,30 +142,30 @@ std::vector Pixel3DDigitizerAlgorithm::diff std::vector migrated_charge; // FIXME -- DM - const float diffusion_step_ = 0.1_um; + const float diffusion_step = 0.1_um; // The position while drifting std::vector pos_moving({pos.x(), pos.y(), pos.z()}); // The drifting: drift field and steps std::function(int)> do_step = - [&pos_moving, &u_drift, diffusion_step_](int i) -> std::vector { + [&pos_moving, &u_drift, diffusion_step](int i) -> std::vector { auto dd = u_drift(pos_moving[0], pos_moving[1]); return std::vector( - {i * diffusion_step_ * dd.x(), i * diffusion_step_ * dd.y(), i * diffusion_step_ * dd.z()}); + {i * diffusion_step * dd.x(), i * diffusion_step * dd.y(), i * diffusion_step * dd.z()}); }; LogDebug("Pixel3DDigitizerAlgorithm::diffusion") - << "\nMax. radius from the pixel edge to migrate charge: " << max_migration_radius_ * 1.0_um_inv << " [um]" + << "\nMax. radius from the pixel edge to migrate charge: " << max_migration_radius * 1.0_um_inv << " [um]" << "\nMigration axis: " << displ_ind << "\n(super-)Charge distance to the pixel edge: " << (pitch - pos_moving[displ_ind]) * 1.0_um_inv << " [um]"; // FIXME -- Sigma reference, DM? - const float distance0_ = 300.0_um; - const float sigma0_ = 3.4_um; + const float distance0 = 300.0_um; + const float sigma0 = 3.4_um; // FIXME -- Tolerance, DM? - const float TOL_ = 1e-6; + const float TOL = 1e-6; // How many sigmas (probably a configurable, to be decided not now) - const float N_SIGMA_ = 3.0; + const float N_SIGMA = 3.0; // Start the drift and check every step // initial position @@ -178,7 +178,7 @@ std::vector Pixel3DDigitizerAlgorithm::diff std::transform(pos_moving.begin(), pos_moving.end(), do_step(i).begin(), pos_moving.begin(), std::plus()); distance_edge = std::abs(pos_moving[displ_ind] - pitch); // current diffusion value - double sigma = std::sqrt(i * diffusion_step_ / distance0_) * (distance0_ / thickness) * sigma0_; + double sigma = std::sqrt(i * diffusion_step / distance0) * (distance0 / thickness) * sigma0; // Get the amount of charge on the neighbor pixel: note the // transformation to a Normal float migrated_e = current_carriers * (1.0 - std::erf(distance_edge / sigma)); @@ -191,7 +191,7 @@ std::vector Pixel3DDigitizerAlgorithm::diff // No charge was migrated (ignore creation time) if (i != 0) { // At least 1 electron migrated - if ((migrated_e - TOL_) < 1.0) { + if ((migrated_e - TOL) < 1.0) { break; } // Move the migrated charge @@ -202,12 +202,12 @@ std::vector Pixel3DDigitizerAlgorithm::diff // except the direction of migration std::vector newpos(pos_moving); // Lest create the new charges around 3 sigmas away - newpos[displ_ind] += std::copysign(N_SIGMA_ * sigma, newpos[displ_ind]); + newpos[displ_ind] += std::copysign(N_SIGMA * sigma, newpos[displ_ind]); migrated_charge.push_back(DigitizerUtility::EnergyDepositUnit(migrated_e, newpos[0], newpos[1], newpos[2])); } // Next step ++i; - } while (std::abs(distance_edge) < max_migration_radius_); + } while (std::abs(distance_edge) < max_migration_radius); return migrated_charge; } @@ -273,7 +273,7 @@ std::vector Pixel3DDigitizerAlgorithm::drift( // Radiation damage limit of application // (XXX: No sense for 3D, let this be until decided what algorithm to use) - const float RAD_DAMAGE_ = 0.001; + const float RAD_DAMAGE = 0.001; for (const auto& super_charge : ionization_points) { // Extract the pixel cell @@ -355,7 +355,7 @@ std::vector Pixel3DDigitizerAlgorithm::drift( float energyOnCollector = nelectrons; // FIXME: is this correct? Not for 3D... - if (pseudoRadDamage_ >= RAD_DAMAGE_) { + if (pseudoRadDamage_ >= RAD_DAMAGE) { const float module_radius = pixdet->surface().position().perp(); if (module_radius <= pseudoRadDamageRadius_) { const float kValue = pseudoRadDamage_ / (module_radius * module_radius); From 6e2272103b2d9c0141d636384215ac0587f07a84 Mon Sep 17 00:00:00 2001 From: claralasa Date: Thu, 29 Oct 2020 15:11:15 +0100 Subject: [PATCH 8/8] Fix code style --- .../SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc index a1a47e6961501..220858ae8ea8a 100644 --- a/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc +++ b/SimTracker/SiPhase2Digitizer/plugins/Pixel3DDigitizerAlgorithm.cc @@ -150,8 +150,7 @@ std::vector Pixel3DDigitizerAlgorithm::diff std::function(int)> do_step = [&pos_moving, &u_drift, diffusion_step](int i) -> std::vector { auto dd = u_drift(pos_moving[0], pos_moving[1]); - return std::vector( - {i * diffusion_step * dd.x(), i * diffusion_step * dd.y(), i * diffusion_step * dd.z()}); + return std::vector({i * diffusion_step * dd.x(), i * diffusion_step * dd.y(), i * diffusion_step * dd.z()}); }; LogDebug("Pixel3DDigitizerAlgorithm::diffusion")