635 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
" ******************************** \n";
636 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
" ******************************** \n";
637 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
" ******************************** \n";
638 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
" ***** INCONSISTENCY !!! ***** \n";
640 <<
" applyLateReweighting_ and UseReweighting can not be true at the same time for PU ! \n";
641 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
" ---> DO NOT APPLY CHARGE REWEIGHTING TWICE !!! \n";
642 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
" ******************************** \n";
643 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
" ******************************** \n";
647 SignalType theDigiSignal;
649 int irow_min = topol->
nrows();
654 float chargeBefore = 0;
655 float chargeAfter = 0;
658 std::vector<PixelDigi>::const_iterator loopDigi;
659 for (loopDigi = digis.begin(); loopDigi != digis.end(); ++loopDigi) {
660 unsigned int chan = loopDigi->channel();
662 float corresponding_charge = loopDigi->adc();
663 if constexpr (std::is_same_v<AmplitudeType, digitizerUtility::Ph2Amplitude>) {
665 <<
"Phase-2 late charge reweighting not supported (not sure we need it at all)";
668 theDigiSignal[
chan] += AmplitudeType(corresponding_charge, corresponding_charge);
670 chargeBefore += corresponding_charge;
671 if (loopDigi->row() < irow_min)
672 irow_min = loopDigi->row();
673 if (loopDigi->row() > irow_max)
674 irow_max = loopDigi->row();
675 if (loopDigi->column() < icol_min)
676 icol_min = loopDigi->column();
677 if (loopDigi->column() > icol_max)
678 icol_max = loopDigi->column();
685 float trajectoryScaleToPosition =
std::abs(hitEntryPoint.
z() / direction.
z());
686 LocalPoint hitPosition = hitEntryPoint + trajectoryScaleToPosition * direction;
690 LocalPoint hitLocalPosition = hitEntryPoint + 0.5 * direction;
692 std::pair<int, int> hitPixel =
693 std::pair<int, int>(
int(floor(hitPositionPixel.
x())),
int(floor(hitPositionPixel.
y())));
700 std::pair<int, int> entryPixel =
701 std::pair<int, int>(
int(floor(hitEntryPointPixel.
x())),
int(floor(hitEntryPointPixel.
y())));
702 std::pair<int, int> exitPixel =
703 std::pair<int, int>(
int(floor(hitExitPointPixel.
x())),
int(floor(hitExitPointPixel.
y())));
705 int hitcol_min, hitcol_max, hitrow_min, hitrow_max;
706 if (entryPixel.first > exitPixel.first) {
707 hitrow_min = exitPixel.first;
708 hitrow_max = entryPixel.first;
710 hitrow_min = entryPixel.first;
711 hitrow_max = exitPixel.first;
714 if (entryPixel.second > exitPixel.second) {
715 hitcol_min = exitPixel.second;
716 hitcol_max = entryPixel.second;
718 hitcol_min = entryPixel.second;
719 hitcol_max = exitPixel.second;
722 if (!(irow_min <= hitrow_max && irow_max >= hitrow_min && icol_min <= hitcol_max && icol_max >= hitcol_min)) {
730 track[3] = direction.x();
731 track[4] = direction.y();
732 track[5] = direction.z();
744 for (
int row = 0; row <
TXSIZE; ++row) {
752 for (
int row = 0; row <
TXSIZE; ++row) {
761 LogDebug(
"SiPixelChargeReweightingAlgorithm") <<
" Cluster before reweighting: ";
772 LogDebug(
"SiPixelChargeReweightingAlgorithm") <<
" same template for num and den ";
777 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
"Cluster Charge Reweighting did not work properly.";
781 LogDebug(
"SiPixelChargeReweightingAlgorithm") <<
" Cluster after reweighting: ";
785 for (
int row = 0; row <
TXSIZE; ++row) {
789 if ((hitPixel.first + row -
THX) >= 0 && (hitPixel.first + row -
THX) < topol->
nrows() &&
792 if constexpr (std::is_same_v<AmplitudeType, digitizerUtility::Ph2Amplitude>) {
794 <<
"Phase-2 late charge reweighting not supported (not sure we need it at all)";
804 if (chargeBefore != 0. && chargeAfter == 0.) {
809 LogDebug(
"SiPixelChargeReweightingAlgorithm")
810 <<
"Charges (before->after): " << chargeBefore <<
" -> " << chargeAfter;
811 LogDebug(
"SiPixelChargeReweightingAlgorithm") <<
"Charge loss: " << (1 - chargeAfter / chargeBefore) * 100 <<
" %";
815 for (
auto&
i : theDigiSignal) {
817 int chanDigi =
i.first;
819 int row_digi = ip.first;
820 int col_digi = ip.second;
821 int i_transformed_row = row_digi - hitPixel.first +
THX;
822 int i_transformed_col = col_digi - hitPixel.second +
THY;
823 if (i_transformed_row < 0 || i_transformed_row >
TXSIZE || i_transformed_col < 0 || i_transformed_col >
TYSIZE) {
825 if (chanDigi >= 0 &&
i.second > 0) {
826 if constexpr (std::is_same_v<AmplitudeType, digitizerUtility::Ph2Amplitude>) {
828 <<
"Phase-2 late charge reweighting not supported (not sure we need it at all)";
831 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