15 double coupling_constant_ =
params.getParameter<
double>(
"RPixCoupling");
23 double chargeprobcollect;
24 int xUpper[] = {75, 150, 75, 150};
25 int yUpper[] = {50, 50, 100, 100};
27 for (
int i = 0;
i < 4;
i++) {
29 std::ifstream fChargeMap(
filename.fullPath().c_str());
30 if (fChargeMap.is_open()) {
31 while (fChargeMap >> xMap >> yMap >> chargeprobcollect) {
33 iy =
int((yMap + yUpper[
i]) / 5);
38 throw cms::Exception(
"PPS RPixChargeShare") <<
"Charge map file not found";
44 std::map<unsigned short, double> thePixelChargeMap;
46 edm::LogInfo(
"PPS") <<
"RPixChargeShare " <<
det_id_ <<
" : Clouds to be induced= " << charge_map.size();
50 for (std::vector<RPixSignalPoint>::const_iterator
i = charge_map.begin();
i != charge_map.end(); ++
i) {
51 double hit_pos_x, hit_pos_y;
53 if (((*i).Position().x() + ppt.
getSimXWidth() / 2.) < 0 ||
56 <<
"**** Attention ((*i).Position().x()+simX_width_/2.)<0||((*i).Position().x()+simX_width_/2.)>simX_width ";
57 edm::LogInfo(
"PPS RPixChargeShare") <<
"(*i).Position().x() = " << (*i).Position().x();
60 if (((*i).Position().y() + ppt.
getSimYWidth() / 2.) < 0 ||
63 <<
"**** Attention ((*i).Position().y()+simY_width_/2.)<0||((*i).Position().y()+simY_width_/2.)>simY_width ";
64 edm::LogInfo(
"PPS RPixChargeShare") <<
"(*i).Position().y() = " << (*i).Position().y();
69 ppt.
getPixelsInvolved((*i).Position().x(), (*i).Position().y(), (*i).Sigma(), hit_pos_x, hit_pos_y);
70 double effic = relevant_pixels.
effFactor();
74 unsigned short pixel_no = ppt.
pixelIndex(relevant_pixels);
76 double charge_in_pixel = (*i).Charge() * effic;
78 cH += charge_in_pixel;
81 edm::LogInfo(
"PPS RPixChargeShare ") <<
"Efficiency in detector " <<
det_id_ <<
" and pixel no " << pixel_no
82 <<
" : " << effic <<
" ch: " << charge_in_pixel <<
" CHtot: " << cH;
85 thePixelChargeMap[pixel_no] += charge_in_pixel;
89 double pixel_lower_x = 0;
90 double pixel_lower_y = 0;
91 double pixel_upper_x = 0;
92 double pixel_upper_y = 0;
94 ppt.
pixelRange(pixel_row, pixel_col, pixel_lower_x, pixel_upper_x, pixel_lower_y, pixel_upper_y);
95 double pixel_width_x = pixel_upper_x - pixel_lower_x;
96 double pixel_width_y = pixel_upper_y - pixel_lower_y;
97 double pixel_center_x = pixel_lower_x + (pixel_width_x) / 2.;
98 double pixel_center_y = pixel_lower_y + (pixel_width_y) / 2.;
109 if (pixel_row == 0) {
112 if (fabs((*i).Position().x() - pixel_center_x) > ppt.
getPitchSimX() / 2.) {
113 thePixelChargeMap[pixel_no] += charge_in_pixel;
116 if (pixel_col == 0) {
119 if (fabs((*i).Position().y() - pixel_center_y) > ppt.
getPitchSimY() / 2.) {
120 thePixelChargeMap[pixel_no] += charge_in_pixel;
126 pixel_center_y = pixel_lower_y + ppt.
getPitchSimY() / 2.;
127 if (fabs((*i).Position().y() - pixel_center_y) > ppt.
getPitchSimY() / 2.) {
128 thePixelChargeMap[pixel_no] += charge_in_pixel;
135 pixel_center_x = pixel_lower_x + ppt.
getPitchSimX() / 2.;
136 if (fabs((*i).Position().x() - pixel_center_x) > ppt.
getPitchSimX() / 2.) {
137 thePixelChargeMap[pixel_no] += charge_in_pixel;
140 if (pixel_col == 0) {
143 if (fabs((*i).Position().y() - pixel_center_y) > ppt.
getPitchSimY() / 2.) {
144 thePixelChargeMap[pixel_no] += charge_in_pixel;
150 pixel_center_y = pixel_lower_y + ppt.
getPitchSimY() / 2.;
151 if (fabs((*i).Position().y() - pixel_center_y) > ppt.
getPitchSimY() / 2.) {
152 thePixelChargeMap[pixel_no] += charge_in_pixel;
157 if (pixel_col == 0) {
160 if (fabs((*i).Position().y() - pixel_center_y) > ppt.
getPitchSimY() / 2.) {
161 thePixelChargeMap[pixel_no] += charge_in_pixel;
167 pixel_center_y = pixel_lower_y + ppt.
getPitchSimY() / 2.;
168 if (fabs((*i).Position().y() - pixel_center_y) > ppt.
getPitchSimY() / 2.) {
169 thePixelChargeMap[pixel_no] += charge_in_pixel;
175 int xbin =
int((((*i).Position().y() - pixel_center_y) + pixel_width_y / 2.) * 1.e3 / 5.);
176 int ybin =
int((((*i).Position().x() - pixel_center_x) + pixel_width_x / 2.) * 1.e3 / 5.);
177 if (pixel_width_x < 0.11 && pixel_width_y < 0.151) {
180 edm::LogError(
"PPS RPixChargeShare") <<
" Array index out of bounds 0";
184 if (pixel_width_x > 0.11 && pixel_width_y < 0.151) {
187 edm::LogError(
"PPS RPixChargeShare") <<
" Array index out of bounds 2";
191 if (pixel_width_x < 0.11 && pixel_width_y > 0.151) {
194 edm::LogError(
"PPS RPixChargeShare") <<
" Array index out of bounds 1";
198 if (pixel_width_x > 0.11 && pixel_width_y > 0.151) {
201 edm::LogError(
"PPS RPixChargeShare") <<
" Array index out of bounds 3";
205 if (xbin < 0 || ybin < 0) {
206 edm::LogError(
"PPS RPixChargeShare") <<
" Negative array index xbin or ybin";
209 double hit2neighbour[8];
211 thePixelChargeMap[pixel_no] += charge_in_pixel * collect_prob;
212 unsigned short neighbour_no[8];
213 unsigned short m = 0;
214 double closer_neighbour = 0;
215 unsigned short closer_no = 0;
217 for (
int k = pixel_row - 1;
k <= pixel_row + 1;
k++) {
218 for (
int l = pixel_col - 1;
l <= pixel_col + 1;
l++) {
221 if ((
k == pixel_row) && (
l == pixel_col))
223 double neighbour_pixel_lower_x = 0;
224 double neighbour_pixel_lower_y = 0;
225 double neighbour_pixel_upper_x = 0;
226 double neighbour_pixel_upper_y = 0;
227 double neighbour_pixel_center_x = 0;
228 double neighbour_pixel_center_y = 0;
231 k,
l, neighbour_pixel_lower_x, neighbour_pixel_upper_x, neighbour_pixel_lower_y, neighbour_pixel_upper_y);
232 neighbour_pixel_center_x = neighbour_pixel_lower_x + (neighbour_pixel_upper_x - neighbour_pixel_lower_x) / 2.;
233 neighbour_pixel_center_y = neighbour_pixel_lower_y + (neighbour_pixel_upper_y - neighbour_pixel_lower_y) / 2.;
234 hit2neighbour[
m] =
sqrt(
pow((*i).Position().x() - neighbour_pixel_center_x, 2.) +
235 pow((*i).Position().y() - neighbour_pixel_center_y, -2.));
237 if (hit2neighbour[
m] > closer_neighbour) {
238 closer_neighbour = hit2neighbour[
m];
239 closer_no = neighbour_no[
m];
245 thePixelChargeMap[closer_no] += charge_in_pixel * chargetransfereff;
249 return thePixelChargeMap;
unsigned short pixelColNo() const
double getPitchSimY() const
double getPitchSimX() const
Log< level::Error, false > LogError
std::map< unsigned short, double > Share(const std::vector< RPixSignalPoint > &charge_map, const PPSPixelTopology &ppt)
RPixChargeShare(const edm::ParameterSet ¶ms, uint32_t det_id, const PPSPixelTopology &ppt)
double getSimXWidth() const
unsigned short getNoPixels() const
unsigned short getNoPixelsSimY() const
void pixelRange(unsigned int arow, unsigned int acol, double &lower_x, double &higher_x, double &lower_y, double &higher_y) const
Log< level::Info, false > LogInfo
unsigned short pixelRowNo() const
double chargeMap2E_[4][60][40]
unsigned short pixelIndex(PixelInfo pI) const
PixelInfo getPixelsInvolved(double x, double y, double sigma, double &hit_pos_x, double &hit_pos_y) const
double getSimYWidth() const
unsigned short getNoPixelsSimX() const
std::vector< double > signalCoupling_
std::string ChargeMapFile2E_[4]
double getPhysActiveEdgeDist() const