647 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
" ******************************** \n";
648 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
" ******************************** \n";
649 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
" ******************************** \n";
650 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
" ***** INCONSISTENCY !!! ***** \n";
652 <<
" applyLateReweighting_ and UseReweighting can not be true at the same time for PU ! \n";
653 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
" ---> DO NOT APPLY CHARGE REWEIGHTING TWICE !!! \n";
654 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
" ******************************** \n";
655 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
" ******************************** \n";
659 SignalType theDigiSignal;
661 int irow_min = topol->
nrows();
666 float chargeBefore = 0;
667 float chargeAfter = 0;
670 std::vector<PixelDigi>::const_iterator loopDigi;
671 for (loopDigi = digis.begin(); loopDigi != digis.end(); ++loopDigi) {
672 unsigned int chan = loopDigi->channel();
674 float corresponding_charge = loopDigi->adc();
675 if constexpr (std::is_same_v<AmplitudeType, digitizerUtility::Ph2Amplitude>) {
677 <<
"Phase-2 late charge reweighting not supported (not sure we need it at all)";
680 theDigiSignal[
chan] += AmplitudeType(corresponding_charge, corresponding_charge);
682 chargeBefore += corresponding_charge;
683 if (loopDigi->row() < irow_min)
684 irow_min = loopDigi->row();
685 if (loopDigi->row() > irow_max)
686 irow_max = loopDigi->row();
687 if (loopDigi->column() < icol_min)
688 icol_min = loopDigi->column();
689 if (loopDigi->column() > icol_max)
690 icol_max = loopDigi->column();
697 float trajectoryScaleToPosition =
std::abs(hitEntryPoint.
z() / direction.
z());
698 LocalPoint hitPosition = hitEntryPoint + trajectoryScaleToPosition * direction;
702 LocalPoint hitLocalPosition = hitEntryPoint + 0.5 * direction;
704 std::pair<int, int> hitPixel =
705 std::pair<int, int>(
int(floor(hitPositionPixel.
x())),
int(floor(hitPositionPixel.
y())));
712 std::pair<int, int> entryPixel =
713 std::pair<int, int>(
int(floor(hitEntryPointPixel.
x())),
int(floor(hitEntryPointPixel.
y())));
714 std::pair<int, int> exitPixel =
715 std::pair<int, int>(
int(floor(hitExitPointPixel.
x())),
int(floor(hitExitPointPixel.
y())));
717 int hitcol_min, hitcol_max, hitrow_min, hitrow_max;
718 if (entryPixel.first > exitPixel.first) {
719 hitrow_min = exitPixel.first;
720 hitrow_max = entryPixel.first;
722 hitrow_min = entryPixel.first;
723 hitrow_max = exitPixel.first;
726 if (entryPixel.second > exitPixel.second) {
727 hitcol_min = exitPixel.second;
728 hitcol_max = entryPixel.second;
730 hitcol_min = entryPixel.second;
731 hitcol_max = exitPixel.second;
734 if (!(irow_min <= hitrow_max && irow_max >= hitrow_min && icol_min <= hitcol_max && icol_max >= hitcol_min)) {
742 track[3] = direction.x();
743 track[4] = direction.y();
744 track[5] = direction.z();
756 for (
int row = 0; row <
TXSIZE; ++row) {
764 for (
int row = 0; row <
TXSIZE; ++row) {
773 LogDebug(
"SiPixelChargeReweightingAlgorithm") <<
" Cluster before reweighting: ";
784 LogDebug(
"SiPixelChargeReweightingAlgorithm") <<
" same template for num and den ";
789 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
"Cluster Charge Reweighting did not work properly.";
793 LogDebug(
"SiPixelChargeReweightingAlgorithm") <<
" Cluster after reweighting: ";
797 for (
int row = 0; row <
TXSIZE; ++row) {
801 if ((hitPixel.first + row -
THX) >= 0 && (hitPixel.first + row -
THX) < topol->
nrows() &&
804 if constexpr (std::is_same_v<AmplitudeType, digitizerUtility::Ph2Amplitude>) {
806 <<
"Phase-2 late charge reweighting not supported (not sure we need it at all)";
816 if (chargeBefore != 0. && chargeAfter == 0.) {
821 LogDebug(
"SiPixelChargeReweightingAlgorithm")
822 <<
"Charges (before->after): " << chargeBefore <<
" -> " << chargeAfter;
823 LogDebug(
"SiPixelChargeReweightingAlgorithm") <<
"Charge loss: " << (1 - chargeAfter / chargeBefore) * 100 <<
" %";
827 for (
auto&
i : theDigiSignal) {
829 int chanDigi =
i.first;
831 int row_digi = ip.first;
832 int col_digi = ip.second;
833 int i_transformed_row = row_digi - hitPixel.first +
THX;
834 int i_transformed_col = col_digi - hitPixel.second +
THY;
835 if (i_transformed_row < 0 || i_transformed_row >
TXSIZE || i_transformed_col < 0 || i_transformed_col >
TYSIZE) {
837 if (chanDigi >= 0 &&
i.second > 0) {
838 if constexpr (std::is_same_v<AmplitudeType, digitizerUtility::Ph2Amplitude>) {
840 <<
"Phase-2 late charge reweighting not supported (not sure we need it at all)";
843 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