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),
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;
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;
167 <<
"Particle ID is: " <<
hit.particleType() <<
"\n"
168 <<
"Process type: " <<
hit.processType() <<
"\n"
171 <<
"Hit entry x/y/z: " <<
hit.entryPoint().
x() <<
" " <<
hit.entryPoint().
y() <<
" "
172 <<
hit.entryPoint().
z() <<
" "
173 <<
"Hit exit x/y/z: " <<
hit.exitPoint().
x() <<
" " <<
hit.exitPoint().
y() <<
" "
174 <<
hit.exitPoint().
z() <<
" "
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"
187 <<
"Entry - X: " <<
hit.entryPoint().
x() <<
" Y: " <<
hit.entryPoint().
y()
188 <<
" Z: " <<
hit.entryPoint().
z() <<
"\n"
189 <<
"Exit - X: " <<
hit.exitPoint().
x() <<
" Y: " <<
hit.exitPoint().
y()
190 <<
" Z: " <<
hit.exitPoint().
z() <<
"\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) {
230 for (
int row = 0; row <
TXSIZE; ++row) {
239 std::cout <<
"Cluster before reweighting: " << std::endl;
259 LogDebug(
"PixelDigitizer ") <<
"Cluster Charge Reweighting did not work properly.";
265 std::cout <<
"Cluster after reweighting: " << std::endl;
269 for (
int row = 0; row <
TXSIZE; ++row) {
273 if ((hitPixel.first + row -
THX) >= 0 && (hitPixel.first + row -
THX) < topol->
nrows() &&
283 if (chargeBefore != 0. && chargeAfter == 0.) {
289 std::cout <<
"Charges (before->after): " << chargeBefore <<
" -> " << chargeAfter << std::endl;
290 std::cout <<
"Charge loss: " << (1 - chargeAfter / chargeBefore) * 100 <<
" %" << std::endl << std::endl;
307 int i,
j,
k,
l, kclose;
309 float xsize,
ysize, q50i, q100i, q50r, q10r, q100r, xhit2D, yhit2D, qclust, dist2, dmin2;
312 int goodWeightsUsed, nearbyWeightsUsed, noWeightsUsed;
313 float cotalpha, cotbeta;
331 LogDebug(
"Pixel Digitizer") <<
"Reweighting angle is not good!" << std::endl;
351 xy_rewgt[
j][
i] = 0.f;
362 LogDebug(
"Pixel Digitizer") <<
"No matching template found" << std::endl;
368 std::cout <<
"Template unirrad: " << std::endl;
378 if (cluster.num_dimensions() != 2) {
379 LogWarning(
"Pixel Digitizer") <<
"Cluster is not 2-dimensional. Return." << std::endl;
382 nclusx = (
int)cluster.shape()[0];
383 nclusy = (
int)cluster.shape()[1];
385 LogWarning(
"Pixel Digitizer") <<
"Sizes in x do not match: nclusx=" << nclusx <<
" xdoubleSize=" <<
xdouble.size()
386 <<
" TXSIZE=" <<
TXSIZE <<
". Return." << std::endl;
390 LogWarning(
"Pixel Digitizer") <<
"Sizes in y do not match. Return." << std::endl;
399 xy_clust[
j][
i] = 0.f;
400 denx_clust[
j][
i] = 0;
401 deny_clust[
j][
i] = 0;
402 if (cluster[
j][
i] > q100i) {
403 qclust += cluster[
j][
i];
415 std::cout <<
"Template irrad: " << std::endl;
427 std::vector<int> ytclust;
428 std::vector<int> xtclust;
429 std::vector<int> ycclust;
430 std::vector<int> xcclust;
434 if (xy_in[
j + 1][
i + 1] > q100i) {
436 ytclust.push_back(
i);
437 xtclust.push_back(
j);
438 xy_clust[
j][
i] = xy_rewgt[
j + 1][
i + 1] / xy_in[
j + 1][
i + 1];
439 denx_clust[
j][
i] =
j;
440 deny_clust[
j][
i] =
i;
449 if (xy_rewgt[
j + 1][
i + 1] > q10r && xy_clust[
j][
i] == 0.
f && ntpix > 0) {
453 for (
k = 0;
k < ntpix; ++
k) {
454 dist2 = (
i - ytclust[
k]) * (
i - ytclust[
k]) + 0.44444f * (
j - xtclust[
k]) * (
j - xtclust[
k]);
460 xy_clust[
j][
i] = xy_rewgt[
j + 1][
i + 1] / xy_in[xtclust[kclose] + 1][ytclust[kclose] + 1];
461 denx_clust[
j][
i] = xtclust[kclose];
462 deny_clust[
j][
i] = ytclust[kclose];
474 nearbyWeightsUsed = 0;
479 if (xy_clust[
j][
i] > 0.
f) {
480 cluster[
j][
i] = xy_clust[
j][
i] * clust[denx_clust[
j][
i]][deny_clust[
j][
i]];
481 if (cluster[
j][
i] > q100r) {
482 qclust += cluster[
j][
i];
484 if (cluster[
j][
i] > 0) {
488 if (clust[
j][
i] > 0.
f) {
490 ycclust.push_back(
i);
491 xcclust.push_back(
j);
500 for (
l = 0;
l < ncpix; ++
l) {
505 for (
k = 0;
k < ntpix; ++
k) {
506 dist2 = (
i - ytclust[
k]) * (
i - ytclust[
k]) + 0.44444f * (
j - xtclust[
k]) * (
j - xtclust[
k]);
514 cluster[
j][
i] *= xy_clust[xtclust[kclose]][ytclust[kclose]];
515 if (cluster[
j][
i] > q100r) {
516 qclust += cluster[
j][
i];
530 for (
int row = 0; row <
TXSIZE; ++row) {
541 for (
int row = 0; row <
BXM2; ++row) {
552 for (
int row = 0; row <
TXSIZE; ++row) {