37 using namespace sipixelobjects;
42 dbobject_den = &es.
getData(SiPixel2DTemp_den_token_);
43 dbobject_num = &es.
getData(SiPixel2DTemp_num_token_);
45 int numOfTemplates = dbobject_den->numOfTempl() + dbobject_num->numOfTempl();
46 templateStores_.reserve(numOfTemplates);
60 templ2D(templateStores_),
63 IDnum(conf.exists(
"TemplateIDnumerator") ? conf.getParameter<int>(
"TemplateIDnumerator") : 0),
64 IDden(conf.exists(
"TemplateIDdenominator") ? conf.getParameter<int>(
"TemplateIDdenominator") : 0),
66 UseReweighting(conf.getParameter<bool>(
"UseReweighting")),
67 PrintClusters(conf.getParameter<bool>(
"PrintClusters")),
68 PrintTemplates(conf.getParameter<bool>(
"PrintTemplates")) {
73 edm::LogVerbatim(
"PixelDigitizer ") <<
"SiPixelChargeReweightingAlgorithm constructed"
79 LogDebug(
"PixelDigitizer") <<
"SiPixelChargeReweightingAlgorithm deleted";
85 std::map<
int,
float, std::less<int> >& hit_signal,
86 const size_t hitIndex,
87 const unsigned int tofBin,
91 unsigned short int processType,
92 const bool& boolmakeDigiSimLinks) {
93 int irow_min = topol->
nrows();
98 float chargeBefore = 0;
99 float chargeAfter = 0;
103 for (std::map<
int,
float, std::less<int> >::const_iterator im = hit_signal.begin(); im != hit_signal.end(); ++im) {
104 int chan = (*im).first;
109 : SiPixelDigitizerAlgorithm::Amplitude((*im).second, (*im).second));
110 chargeBefore += (*im).second;
112 if (pixelWithCharge.first < irow_min)
113 irow_min = pixelWithCharge.first;
114 if (pixelWithCharge.first > irow_max)
115 irow_max = pixelWithCharge.first;
116 if (pixelWithCharge.second < icol_min)
117 icol_min = pixelWithCharge.second;
118 if (pixelWithCharge.second > icol_max)
119 icol_max = pixelWithCharge.second;
124 float trajectoryScaleToPosition = hitEntryPoint.
z() / direction.
z();
126 if ((hitEntryPoint.
z() > 0 && direction.
z() < 0) || (hitEntryPoint.
z() < 0 && direction.
z() > 0)) {
127 trajectoryScaleToPosition *= -1;
130 LocalPoint hitPosition = hitEntryPoint + trajectoryScaleToPosition * direction;
133 std::pair<int, int> hitPixel =
134 std::pair<int, int>(int(floor(hitPositionPixel.
x())), int(floor(hitPositionPixel.
y())));
141 std::pair<int, int> entryPixel =
142 std::pair<int, int>(int(floor(hitEntryPointPixel.
x())), int(floor(hitEntryPointPixel.
y())));
143 std::pair<int, int> exitPixel =
144 std::pair<int, int>(int(floor(hitExitPointPixel.
x())), int(floor(hitExitPointPixel.
y())));
146 int hitcol_min, hitcol_max, hitrow_min, hitrow_max;
147 if (entryPixel.first > exitPixel.first) {
148 hitrow_min = exitPixel.first;
149 hitrow_max = entryPixel.first;
151 hitrow_min = entryPixel.first;
152 hitrow_max = exitPixel.first;
155 if (entryPixel.second > exitPixel.second) {
156 hitcol_min = exitPixel.second;
157 hitcol_max = entryPixel.second;
159 hitcol_min = entryPixel.second;
160 hitcol_max = exitPixel.second;
176 <<
"Pixel Pos - X: " << hitPositionPixel.
x() <<
" Y: " << hitPositionPixel.
y() <<
"\n"
177 <<
"Cart.Cor. - X: " << CMSSWhitPosition.
x() <<
" Y: " << CMSSWhitPosition.
y() <<
"\n"
178 <<
"Z=0 Pos - X: " << hitPosition.
x() <<
" Y: " << hitPosition.
y() <<
"\n"
180 <<
"Origin of the template:"
182 <<
"Pixel Pos - X: " << originPixel.x() <<
" Y: " << originPixel.y() <<
"\n"
183 <<
"Cart.Cor. - X: " << origin.
x() <<
" Y: " << origin.
y() <<
"\n"
192 <<
"Entry - X Pixel: " << hitEntryPointPixel.
x() <<
" Y Pixel: " << hitEntryPointPixel.
y()
194 <<
"Exit - X Pixel: " << hitExitPointPixel.
x() <<
" Y Pixel: " << hitExitPointPixel.
y()
197 <<
"row min: " << irow_min <<
" col min: " << icol_min <<
"\n";
200 if (!(irow_min <= hitrow_max && irow_max >= hitrow_min && icol_min <= hitcol_max && icol_max >= hitcol_min)) {
205 float cmToMicrons = 10000.f;
207 track[0] = (hitPosition.
x() - origin.
x()) * cmToMicrons;
208 track[1] = (hitPosition.
y() - origin.
y()) * cmToMicrons;
210 track[3] = direction.x();
211 track[4] = direction.y();
212 track[5] = direction.z();
216 for (
int row = 0; row <
TXSIZE; ++row) {
218 pixrewgt[row][
col] = 0;
222 for (
int row = 0; row <
TXSIZE; ++row) {
237 for (
int row = rowmin; row < rowmax; ++row) {
238 for (
int col = colmin;
col < colmax; ++
col) {
246 std::cout <<
"Cluster before reweighting: " << std::endl;
266 LogDebug(
"PixelDigitizer ") <<
"Cluster Charge Reweighting did not work properly.";
272 std::cout <<
"Cluster after reweighting: " << std::endl;
276 for (
int row = rowmin; row < rowmax; ++row) {
277 for (
int col = colmin;
col < colmax; ++
col) {
283 : SiPixelDigitizerAlgorithm::Amplitude(charge, charge));
288 if (chargeBefore != 0. && chargeAfter == 0.) {
294 std::cout <<
"Charges (before->after): " << chargeBefore <<
" -> " << chargeAfter << std::endl;
295 std::cout <<
"Charge loss: " << (1 - chargeAfter / chargeBefore) * 100 <<
" %" << std::endl << std::endl;
312 int i,
j,
k,
l, kclose;
314 float xsize,
ysize, q50i, q100i, q50r, q10r, q100r, xhit2D, yhit2D, qclust, dist2, dmin2;
317 int goodWeightsUsed, nearbyWeightsUsed, noWeightsUsed;
318 float cotalpha, cotbeta;
336 LogDebug(
"Pixel Digitizer") <<
"Reweighting angle is not good!" << std::endl;
353 for (i = 0; i <
BYM2; ++
i) {
354 for (j = 0; j <
BXM2; ++
j) {
356 xy_rewgt[
j][
i] = 0.f;
367 LogDebug(
"Pixel Digitizer") <<
"No matching template found" << std::endl;
373 std::cout <<
"Template unirrad: " << std::endl;
383 if (cluster.num_dimensions() != 2) {
384 LogWarning(
"Pixel Digitizer") <<
"Cluster is not 2-dimensional. Return." << std::endl;
387 nclusx = (int)cluster.shape()[0];
388 nclusy = (int)cluster.shape()[1];
390 LogWarning(
"Pixel Digitizer") <<
"Sizes in x do not match: nclusx=" << nclusx <<
" xdoubleSize=" <<
xdouble.size()
391 <<
" TXSIZE=" <<
TXSIZE <<
". Return." << std::endl;
395 LogWarning(
"Pixel Digitizer") <<
"Sizes in y do not match. Return." << std::endl;
404 xy_clust[
j][
i] = 0.f;
405 denx_clust[
j][
i] = 0;
406 deny_clust[
j][
i] = 0;
407 if (cluster[j][i] > q100i) {
408 qclust += cluster[
j][
i];
420 std::cout <<
"Template irrad: " << std::endl;
432 std::vector<int> ytclust;
433 std::vector<int> xtclust;
434 std::vector<int> ycclust;
435 std::vector<int> xcclust;
439 if (xy_in[j + 1][i + 1] > q100i) {
441 ytclust.push_back(i);
442 xtclust.push_back(j);
443 xy_clust[
j][
i] = xy_rewgt[j + 1][i + 1] / xy_in[j + 1][i + 1];
444 denx_clust[
j][
i] =
j;
445 deny_clust[
j][
i] =
i;
454 if (xy_rewgt[j + 1][i + 1] > q10r && xy_clust[j][i] == 0.
f && ntpix > 0) {
458 for (k = 0; k < ntpix; ++
k) {
459 dist2 = (i - ytclust[
k]) * (i - ytclust[k]) + 0.44444f * (j - xtclust[
k]) * (j - xtclust[k]);
465 xy_clust[
j][
i] = xy_rewgt[j + 1][i + 1] / xy_in[xtclust[kclose] + 1][ytclust[kclose] + 1];
466 denx_clust[
j][
i] = xtclust[kclose];
467 deny_clust[
j][
i] = ytclust[kclose];
479 nearbyWeightsUsed = 0;
484 if (xy_clust[j][i] > 0.
f) {
485 cluster[
j][
i] = xy_clust[
j][
i] * clust[denx_clust[
j][
i]][deny_clust[
j][
i]];
486 if (cluster[j][i] > q100r) {
487 qclust += cluster[
j][
i];
489 if (cluster[j][i] > 0) {
493 if (clust[j][i] > 0.
f) {
495 ycclust.push_back(i);
496 xcclust.push_back(j);
505 for (l = 0; l < ncpix; ++
l) {
510 for (k = 0; k < ntpix; ++
k) {
511 dist2 = (i - ytclust[
k]) * (i - ytclust[k]) + 0.44444f * (j - xtclust[
k]) * (j - xtclust[k]);
519 cluster[
j][
i] *= xy_clust[xtclust[kclose]][ytclust[kclose]];
520 if (cluster[j][i] > q100r) {
521 qclust += cluster[
j][
i];
535 for (
int row = 0; row <
TXSIZE; ++row) {
536 std::cout << std::setw(10) << std::setprecision(0) << std::fixed;
546 for (
int row = 0; row <
BXM2; ++row) {
547 std::cout << std::setw(10) << std::setprecision(0) << std::fixed;
557 for (
int row = 0; row <
TXSIZE; ++row) {
558 std::cout << std::setw(10) << std::fixed;
Log< level::Info, true > LogVerbatim
boost::multi_array< float, 2 > array_2d
const bool PrintTemplates
float xsize()
pixel x-size (microns)
bool xytemp(float xhit, float yhit, bool ydouble[21+2], bool xdouble[13+2], float template2d[13+2][21+2], bool dervatives, float dpdx2d[2][13+2][21+2], float &QTemplate)
static std::pair< int, int > channelToPixel(int ch)
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
edm::ESGetToken< SiPixel2DTemplateDBObject, SiPixel2DTemplateDBObjectRcd > SiPixel2DTemp_num_token_
virtual int ncolumns() const =0
tuple chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
std::vector< bool > xdouble
virtual int nrows() const =0
std::map< int, SiPixelDigitizerAlgorithm::Amplitude, std::less< int > > signal_map_type
const bool UseReweighting
bool hitSignalReweight(const PSimHit &hit, std::map< int, float, std::less< int > > &hit_signal, const size_t hitIndex, const unsigned int tofBin, const PixelTopology *topol, uint32_t detID, signal_map_type &theSignal, unsigned short int processType, const bool &boolmakeDigiSimLinks)
const SiPixel2DTemplateDBObject * dbobject_den
float s50()
1/2 of the pixel threshold signal in adc units
static int pixelToChannel(int row, int col)
bool getData(T &iHolder) const
Measurement2DPoint MeasurementPoint
Measurement points are two-dimensional by default.
SiPixelTemplate2D templ2D
Local3DPoint exitPoint() const
Exit point in the local Det frame.
Local3DPoint localPosition() const
virtual bool isItBigPixelInX(int ixbin) const =0
void init(const edm::EventSetup &es)
virtual bool isItBigPixelInY(int iybin) const =0
Abs< T >::type abs(const T &t)
virtual MeasurementPoint measurementPosition(const LocalPoint &) const =0
const SiPixel2DTemplateDBObject * dbobject_num
void printCluster(array_2d &cluster)
int PixelTempRewgt2D(int id_gen, int id_rewgt, array_2d &cluster)
short getTemplateID(const uint32_t &detid) const
SiPixelChargeReweightingAlgorithm(const edm::ParameterSet &conf, edm::ConsumesCollector iC)
~SiPixelChargeReweightingAlgorithm()
std::vector< bool > ydouble
unsigned short processType() const
float ysize()
pixel y-size (microns)
edm::ESGetToken< SiPixel2DTemplateDBObject, SiPixel2DTemplateDBObjectRcd > SiPixel2DTemp_den_token_
std::vector< float > track
static bool pushfile(int filenum, std::vector< SiPixelTemplateStore2D > &pixelTemp, std::string dir="CalibTracker/SiPixelESProducers/data/")
Log< level::Warning, false > LogWarning
Local3DPoint entryPoint() const
Entry point in the local Det frame.