662 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
" ******************************** \n";
663 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
" ******************************** \n";
664 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
" ******************************** \n";
665 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
" ***** INCONSISTENCY !!! ***** \n";
667 <<
" applyLateReweighting_ and UseReweighting can not be true at the same time for PU ! \n";
668 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
" ---> DO NOT APPLY CHARGE REWEIGHTING TWICE !!! \n";
669 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
" ******************************** \n";
670 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
" ******************************** \n";
674 SignalType theDigiSignal;
676 int irow_min = topol->
nrows();
681 float chargeBefore = 0;
682 float chargeAfter = 0;
685 std::vector<PixelDigi>::const_iterator loopDigi;
686 for (loopDigi = digis.begin(); loopDigi != digis.end(); ++loopDigi) {
687 unsigned int chan = loopDigi->channel();
689 float corresponding_charge = loopDigi->adc();
690 if constexpr (std::is_same_v<AmplitudeType, digitizerUtility::Ph2Amplitude>) {
692 <<
"Phase-2 late charge reweighting not supported (not sure we need it at all)";
695 theDigiSignal[
chan] += AmplitudeType(corresponding_charge, corresponding_charge);
697 chargeBefore += corresponding_charge;
698 if (loopDigi->row() < irow_min)
699 irow_min = loopDigi->row();
700 if (loopDigi->row() > irow_max)
701 irow_max = loopDigi->row();
702 if (loopDigi->column() < icol_min)
703 icol_min = loopDigi->column();
704 if (loopDigi->column() > icol_max)
705 icol_max = loopDigi->column();
712 float trajectoryScaleToPosition =
std::abs(hitEntryPoint.
z() / direction.
z());
713 LocalPoint hitPosition = hitEntryPoint + trajectoryScaleToPosition * direction;
717 LocalPoint hitLocalPosition = hitEntryPoint + 0.5 * direction;
719 std::pair<int, int> hitPixel =
720 std::pair<int, int>(
int(floor(hitPositionPixel.
x())),
int(floor(hitPositionPixel.
y())));
727 std::pair<int, int> entryPixel =
728 std::pair<int, int>(
int(floor(hitEntryPointPixel.
x())),
int(floor(hitEntryPointPixel.
y())));
729 std::pair<int, int> exitPixel =
730 std::pair<int, int>(
int(floor(hitExitPointPixel.
x())),
int(floor(hitExitPointPixel.
y())));
732 int hitcol_min, hitcol_max, hitrow_min, hitrow_max;
733 if (entryPixel.first > exitPixel.first) {
734 hitrow_min = exitPixel.first;
735 hitrow_max = entryPixel.first;
737 hitrow_min = entryPixel.first;
738 hitrow_max = exitPixel.first;
741 if (entryPixel.second > exitPixel.second) {
742 hitcol_min = exitPixel.second;
743 hitcol_max = entryPixel.second;
745 hitcol_min = entryPixel.second;
746 hitcol_max = exitPixel.second;
749 if (!(irow_min <= hitrow_max && irow_max >= hitrow_min && icol_min <= hitcol_max && icol_max >= hitcol_min)) {
757 track[3] = direction.x();
758 track[4] = direction.y();
759 track[5] = direction.z();
771 for (
int row = 0; row <
TXSIZE; ++row) {
779 for (
int row = 0; row <
TXSIZE; ++row) {
788 LogDebug(
"SiPixelChargeReweightingAlgorithm") <<
" Cluster before reweighting: ";
799 LogDebug(
"SiPixelChargeReweightingAlgorithm") <<
" same template for num and den ";
804 edm::LogError(
"SiPixelChargeReweightingAlgorithm") <<
"Cluster Charge Reweighting did not work properly.";
808 LogDebug(
"SiPixelChargeReweightingAlgorithm") <<
" Cluster after reweighting: ";
812 for (
int row = 0; row <
TXSIZE; ++row) {
816 if ((hitPixel.first + row -
THX) >= 0 && (hitPixel.first + row -
THX) < topol->
nrows() &&
819 if constexpr (std::is_same_v<AmplitudeType, digitizerUtility::Ph2Amplitude>) {
821 <<
"Phase-2 late charge reweighting not supported (not sure we need it at all)";
831 if (chargeBefore != 0. && chargeAfter == 0.) {
836 LogDebug(
"SiPixelChargeReweightingAlgorithm")
837 <<
"Charges (before->after): " << chargeBefore <<
" -> " << chargeAfter;
838 LogDebug(
"SiPixelChargeReweightingAlgorithm") <<
"Charge loss: " << (1 - chargeAfter / chargeBefore) * 100 <<
" %";
842 for (
auto&
i : theDigiSignal) {
844 int chanDigi =
i.first;
846 int row_digi = ip.first;
847 int col_digi = ip.second;
848 int i_transformed_row = row_digi - hitPixel.first +
THX;
849 int i_transformed_col = col_digi - hitPixel.second +
THY;
850 if (i_transformed_row < 0 || i_transformed_row >
TXSIZE || i_transformed_col < 0 || i_transformed_col >
TYSIZE) {
852 if (chanDigi >= 0 &&
i.second > 0) {
853 if constexpr (std::is_same_v<AmplitudeType, digitizerUtility::Ph2Amplitude>) {
855 <<
"Phase-2 late charge reweighting not supported (not sure we need it at all)";
858 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