639 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
" ******************************** \n";
640 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
" ******************************** \n";
641 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
" ******************************** \n";
642 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
" ***** INCONSISTENCY !!! ***** \n";
644 <<
" applyLateReweighting_ and UseReweighting can not be true at the same time for PU ! \n";
645 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
" ---> DO NOT APPLY CHARGE REWEIGHTING TWICE !!! \n";
646 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
" ******************************** \n";
647 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
" ******************************** \n";
651 SignalType theDigiSignal;
653 int irow_min = topol->
nrows();
658 float chargeBefore = 0;
659 float chargeAfter = 0;
662 std::vector<PixelDigi>::const_iterator loopDigi;
663 for (loopDigi = digis.begin(); loopDigi != digis.end(); ++loopDigi) {
664 unsigned int chan = loopDigi->channel();
666 float corresponding_charge = loopDigi->adc();
667 if constexpr (std::is_same_v<AmplitudeType, digitizerUtility::Ph2Amplitude>) {
669 <<
"Phase-2 late charge reweighting not supported (not sure we need it at all)";
672 theDigiSignal[
chan] += AmplitudeType(corresponding_charge, corresponding_charge);
674 chargeBefore += corresponding_charge;
675 if (loopDigi->row() < irow_min)
676 irow_min = loopDigi->row();
677 if (loopDigi->row() > irow_max)
678 irow_max = loopDigi->row();
679 if (loopDigi->column() < icol_min)
680 icol_min = loopDigi->column();
681 if (loopDigi->column() > icol_max)
682 icol_max = loopDigi->column();
689 float trajectoryScaleToPosition =
std::abs(hitEntryPoint.
z() / direction.
z());
690 LocalPoint hitPosition = hitEntryPoint + trajectoryScaleToPosition * direction;
694 LocalPoint hitLocalPosition = hitEntryPoint + 0.5 * direction;
696 std::pair<int, int> hitPixel =
697 std::pair<int, int>(
int(floor(hitPositionPixel.
x())),
int(floor(hitPositionPixel.
y())));
704 std::pair<int, int> entryPixel =
705 std::pair<int, int>(
int(floor(hitEntryPointPixel.
x())),
int(floor(hitEntryPointPixel.
y())));
706 std::pair<int, int> exitPixel =
707 std::pair<int, int>(
int(floor(hitExitPointPixel.
x())),
int(floor(hitExitPointPixel.
y())));
709 int hitcol_min, hitcol_max, hitrow_min, hitrow_max;
710 if (entryPixel.first > exitPixel.first) {
711 hitrow_min = exitPixel.first;
712 hitrow_max = entryPixel.first;
714 hitrow_min = entryPixel.first;
715 hitrow_max = exitPixel.first;
718 if (entryPixel.second > exitPixel.second) {
719 hitcol_min = exitPixel.second;
720 hitcol_max = entryPixel.second;
722 hitcol_min = entryPixel.second;
723 hitcol_max = exitPixel.second;
726 if (!(irow_min <= hitrow_max && irow_max >= hitrow_min && icol_min <= hitcol_max && icol_max >= hitcol_min)) {
734 track[3] = direction.x();
735 track[4] = direction.y();
736 track[5] = direction.z();
748 for (
int row = 0; row <
TXSIZE; ++row) {
756 for (
int row = 0; row <
TXSIZE; ++row) {
765 LogDebug(
"SiPixelChargeReweightingAlgorithm") <<
" Cluster before reweighting: ";
776 LogDebug(
"SiPixelChargeReweightingAlgorithm") <<
" same template for num and den ";
781 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
"Cluster Charge Reweighting did not work properly.";
785 LogDebug(
"SiPixelChargeReweightingAlgorithm") <<
" Cluster after reweighting: ";
789 for (
int row = 0; row <
TXSIZE; ++row) {
793 if ((hitPixel.first + row -
THX) >= 0 && (hitPixel.first + row -
THX) < topol->
nrows() &&
796 if constexpr (std::is_same_v<AmplitudeType, digitizerUtility::Ph2Amplitude>) {
798 <<
"Phase-2 late charge reweighting not supported (not sure we need it at all)";
808 if (chargeBefore != 0. && chargeAfter == 0.) {
813 LogDebug(
"SiPixelChargeReweightingAlgorithm")
814 <<
"Charges (before->after): " << chargeBefore <<
" -> " << chargeAfter;
815 LogDebug(
"SiPixelChargeReweightingAlgorithm") <<
"Charge loss: " << (1 - chargeAfter / chargeBefore) * 100 <<
" %";
819 for (
auto&
i : theDigiSignal) {
821 int chanDigi =
i.first;
823 int row_digi = ip.first;
824 int col_digi = ip.second;
825 int i_transformed_row = row_digi - hitPixel.first +
THX;
826 int i_transformed_col = col_digi - hitPixel.second +
THY;
827 if (i_transformed_row < 0 || i_transformed_row >
TXSIZE || i_transformed_col < 0 || i_transformed_col >
TYSIZE) {
829 if (chanDigi >= 0 &&
i.second > 0) {
830 if constexpr (std::is_same_v<AmplitudeType, digitizerUtility::Ph2Amplitude>) {
832 <<
"Phase-2 late charge reweighting not supported (not sure we need it at all)";
835 theNewDigiSignal[chanDigi] += AmplitudeType(
i.second,
i.second);
static std::pair< int, int > channelToPixel(int ch)
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
virtual int ncolumns() const =0
std::vector< bool > xdouble
virtual int nrows() const =0
const bool UseReweighting
const SiPixel2DTemplateDBObject * dbobject_den
Log< level::Error, false > LogError
static int pixelToChannel(int row, int col)
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
virtual bool isItBigPixelInX(int ixbin) const =0
virtual bool isItBigPixelInY(int iybin) const =0
Abs< T >::type abs(const T &t)
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
DetId geographicalId() const
The label of this GeomDet.
boost::multi_array< float, 2 > array_2d
const SiPixel2DTemplateDBObject * dbobject_num
void printCluster(array_2d &cluster)
int PixelTempRewgt2D(int id_gen, int id_rewgt, array_2d &cluster)
constexpr uint32_t rawId() const
get the raw id
std::vector< bool > ydouble
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
short getTemplateID(const uint32_t &detid) const
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
std::vector< float > track
static constexpr float cmToMicrons