CMS 3D CMS Logo

RPixChargeShare.cc
Go to the documentation of this file.
3 #include <iostream>
4 #include <fstream>
5 
7  : det_id_(det_id), theRPixDetTopology_() {
8  verbosity_ = params.getParameter<int>("RPixVerbosity");
9  signalCoupling_.clear();
10  ChargeMapFile2E_[0] = params.getParameter<std::string>("ChargeMapFile2E");
11  ChargeMapFile2E_[1] = params.getParameter<std::string>("ChargeMapFile2E_2X");
12  ChargeMapFile2E_[2] = params.getParameter<std::string>("ChargeMapFile2E_2Y");
13  ChargeMapFile2E_[3] = params.getParameter<std::string>("ChargeMapFile2E_2X2Y");
14 
15  double coupling_constant_ = params.getParameter<double>("RPixCoupling");
16 
17  signalCoupling_.push_back(coupling_constant_);
18  signalCoupling_.push_back((1.0 - coupling_constant_) / 2);
19 
21 
22  double xMap, yMap;
23  double chargeprobcollect;
24  int xUpper[] = {75, 150, 75, 150};
25  int yUpper[] = {50, 50, 100, 100};
26  int ix, iy;
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) {
32  ix = int((xMap + xUpper[i]) / 5);
33  iy = int((yMap + yUpper[i]) / 5);
34  chargeMap2E_[i][ix][iy] = chargeprobcollect;
35  }
36  fChargeMap.close();
37  } else
38  throw cms::Exception("RPixChargeShare") << "Charge map file not found";
39  }
40 }
41 
42 std::map<unsigned short, double> RPixChargeShare::Share(const std::vector<RPixSignalPoint> &charge_map) {
43  std::map<unsigned short, double> thePixelChargeMap;
44  if (verbosity_ > 1)
45  edm::LogInfo("RPixChargeShare") << det_id_ << " : Clouds to be induced= " << charge_map.size();
46 
47  double CH = 0;
48 
49  for (std::vector<RPixSignalPoint>::const_iterator i = charge_map.begin(); i != charge_map.end(); ++i) {
50  double hit_pos_x, hit_pos_y;
51  // Used to avoid the abort due to hits out of detector
52  if (((*i).Position().x() + 16.6 / 2) < 0 || ((*i).Position().x() + 16.6 / 2) > 16.6) {
53  edm::LogInfo("RPixChargeShare")
54  << "**** Attention ((*i).Position().x()+simX_width_/2.)<0||((*i).Position().x()+simX_width_/2.)>simX_width ";
55  edm::LogInfo("RPixChargeShare") << "(*i).Position().x() = " << (*i).Position().x();
56  continue;
57  }
58  if (((*i).Position().y() + 24.4 / 2.) < 0 || ((*i).Position().y() + 24.4 / 2.) > 24.4) {
59  edm::LogInfo("RPixChargeShare")
60  << "**** Attention ((*i).Position().y()+simY_width_/2.)<0||((*i).Position().y()+simY_width_/2.)>simY_width ";
61  edm::LogInfo("RPixChargeShare") << "(*i).Position().y() = " << (*i).Position().y();
62  continue;
63  }
64 
66  (*i).Position().x(), (*i).Position().y(), (*i).Sigma(), hit_pos_x, hit_pos_y);
67  double effic = relevant_pixels.effFactor();
68 
69  unsigned short pixel_no = relevant_pixels.pixelIndex();
70 
71  double charge_in_pixel = (*i).Charge() * effic;
72 
73  CH += charge_in_pixel;
74 
75  if (verbosity_ > 1)
76  edm::LogInfo("RPixChargeShare") << "Efficiency in detector " << det_id_ << " and pixel no " << pixel_no << " : "
77  << effic << " ch: " << charge_in_pixel << " CHtot: " << CH;
78 
79  // QUI SI POTREBBE INTRODURRE IL CHARGE SHARING TRA I PIXELS ..................................
80 
81  if (signalCoupling_[0] == 0.) {
82  thePixelChargeMap[pixel_no] += charge_in_pixel;
83  } else {
84  int pixel_row = relevant_pixels.pixelRowNo();
85  int pixel_col = relevant_pixels.pixelColNo();
86  double pixel_lower_x = 0;
87  double pixel_lower_y = 0;
88  double pixel_upper_x = 0;
89  double pixel_upper_y = 0;
90  int psize = 0;
91  theRPixDetTopology_.pixelRange(pixel_row, pixel_col, pixel_lower_x, pixel_upper_x, pixel_lower_y, pixel_upper_y);
92  double pixel_width_x = pixel_upper_x - pixel_lower_x;
93  double pixel_width_y = pixel_upper_y - pixel_lower_y;
94  if (pixel_row == 0 || pixel_row == pxlRowSize_ - 1)
95  pixel_width_x = 0.1; // Correct edge pixel width
96  if (pixel_col == 0 || pixel_col == pxlColSize_ - 1)
97  pixel_width_y = 0.15; //
98  double pixel_center_x = pixel_lower_x + (pixel_width_x) / 2.;
99  double pixel_center_y = pixel_lower_y + (pixel_width_y) / 2.;
100  // xbin and ybin are coordinates (um) ??nside the pixel as in the test beam, swapped wrt plane coodinates.
101  int xbin = int((((*i).Position().y() - pixel_center_y) + pixel_width_y / 2.) * 1.e3 / 5.);
102  int ybin = int((((*i).Position().x() - pixel_center_x) + pixel_width_x / 2.) * 1.e3 / 5.);
103  if (pixel_width_x < 0.11 && pixel_width_y < 0.151) { // pixel 100x150 um^2
104  psize = 0;
105  if (xbin > xBinMax_[psize] || ybin > yBinMax_[psize])
106  continue;
107  }
108  if (pixel_width_x > 0.11 && pixel_width_y < 0.151) { // pixel 200x150 um^2
109  psize = 2;
110  if (xbin > xBinMax_[psize] || ybin > yBinMax_[psize])
111  continue;
112  }
113  if (pixel_width_x < 0.11 && pixel_width_y > 0.151) { // pixel 100x300 um^2
114  psize = 1;
115  if (xbin > xBinMax_[psize] || ybin > yBinMax_[psize])
116  continue;
117  }
118  if (pixel_width_x > 0.11 && pixel_width_y > 0.151) { // pixel 200x300 um^2
119  psize = 3;
120  if (xbin > xBinMax_[psize] || ybin > yBinMax_[psize])
121  continue;
122  }
123  double hit2neighbour[8];
124  double collect_prob = chargeMap2E_[psize][xbin][ybin];
125  thePixelChargeMap[pixel_no] += charge_in_pixel * collect_prob;
126  unsigned short neighbour_no[8];
127  unsigned short m = 0;
128  double closer_neighbour = 0;
129  unsigned short closer_no = 0;
130  // Considering the 8 neighbours to share charge
131  for (int k = pixel_row - 1; k <= pixel_row + 1; k++) {
132  for (int l = pixel_col - 1; l <= pixel_col + 1; l++) {
133  if ((k < 0) || k > pxlRowSize_ - 1 || l < 0 || l > pxlColSize_ - 1)
134  continue;
135  if ((k == pixel_row) && (l == pixel_col))
136  continue;
137  double neighbour_pixel_lower_x = 0;
138  double neighbour_pixel_lower_y = 0;
139  double neighbour_pixel_upper_x = 0;
140  double neighbour_pixel_upper_y = 0;
141  double neighbour_pixel_center_x = 0;
142  double neighbour_pixel_center_y = 0;
143  // Check the hit approach to the neighbours
145  k, l, neighbour_pixel_lower_x, neighbour_pixel_upper_x, neighbour_pixel_lower_y, neighbour_pixel_upper_y);
146  neighbour_pixel_center_x = neighbour_pixel_lower_x + (neighbour_pixel_upper_x - neighbour_pixel_lower_x) / 2.;
147  neighbour_pixel_center_y = neighbour_pixel_lower_y + (neighbour_pixel_upper_y - neighbour_pixel_lower_y) / 2.;
148  hit2neighbour[m] = sqrt(pow((*i).Position().x() - neighbour_pixel_center_x, 2.) +
149  pow((*i).Position().y() - neighbour_pixel_center_y, -2.));
150  neighbour_no[m] = l * pxlRowSize_ + k;
151  if (hit2neighbour[m] > closer_neighbour) {
152  closer_neighbour = hit2neighbour[m];
153  closer_no = neighbour_no[m];
154  }
155  m++;
156  }
157  }
158  double chargetransfereff = (1 - collect_prob) * signalCoupling_[0];
159  thePixelChargeMap[closer_no] += charge_in_pixel * chargetransfereff;
160  }
161  }
162 
163  return thePixelChargeMap;
164 }
RPixChargeShare::RPixChargeShare
RPixChargeShare(const edm::ParameterSet &params, uint32_t det_id)
Definition: RPixChargeShare.cc:6
mps_fire.i
i
Definition: mps_fire.py:428
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
RPixChargeShare::ChargeMapFile2E_
std::string ChargeMapFile2E_[4]
Definition: RPixChargeShare.h:25
CTPPSPixelSimTopology::PixelInfo::pixelIndex
unsigned short pixelIndex() const
Definition: CTPPSPixelSimTopology.h:42
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
RPixChargeShare.h
RPixChargeShare::det_id_
uint32_t det_id_
Definition: RPixChargeShare.h:15
FileInPath.h
edm::FileInPath
Definition: FileInPath.h:64
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
RPixChargeShare::pxlRowSize_
const int pxlRowSize_
Definition: RPixChargeShare.h:19
dqmdumpme.k
k
Definition: dqmdumpme.py:60
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CTPPSPixelSimTopology::PixelInfo::pixelColNo
unsigned short pixelColNo() const
Definition: CTPPSPixelSimTopology.h:41
edm::ParameterSet
Definition: ParameterSet.h:47
RPixChargeShare::pxlColSize_
const int pxlColSize_
Definition: RPixChargeShare.h:20
RPixChargeShare::Share
std::map< unsigned short, double > Share(const std::vector< RPixSignalPoint > &charge_map)
Definition: RPixChargeShare.cc:42
createfilelist.int
int
Definition: createfilelist.py:10
RPixChargeShare::chargeMap2E_
double chargeMap2E_[4][60][40]
Definition: RPixChargeShare.h:26
CTPPSPixelSimTopology::pixelRange
void pixelRange(unsigned int arow, unsigned int acol, double &lower_x, double &higher_x, double &lower_y, double &higher_y) const
Definition: CTPPSPixelSimTopology.h:61
L1DTConfigBti_cff.CH
CH
LTS and SET for low trigger suppression.
Definition: L1DTConfigBti_cff.py:38
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
CTPPSPixelSimTopology::PixelInfo
Definition: CTPPSPixelSimTopology.h:17
RPixChargeShare::signalCoupling_
std::vector< double > signalCoupling_
Definition: RPixChargeShare.h:16
CTPPSPixelTopology::detPixelNo
unsigned short detPixelNo() const
Definition: CTPPSPixelTopology.h:32
CTPPSPixelSimTopology::PixelInfo::pixelRowNo
unsigned short pixelRowNo() const
Definition: CTPPSPixelSimTopology.h:40
RPixChargeShare::yBinMax_
const int yBinMax_[4]
Definition: RPixChargeShare.h:28
edmStreamStallGrapher.xUpper
xUpper
Definition: edmStreamStallGrapher.py:874
Exception
Definition: hltDiff.cc:246
RPixChargeShare::theRPixDetTopology_
CTPPSPixelSimTopology theRPixDetTopology_
Definition: RPixChargeShare.h:17
RPixChargeShare::xBinMax_
const int xBinMax_[4]
Definition: RPixChargeShare.h:27
CTPPSPixelSimTopology::PixelInfo::effFactor
double effFactor() const
Definition: CTPPSPixelSimTopology.h:39
RPixChargeShare::verbosity_
int verbosity_
Definition: RPixChargeShare.h:23
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
CTPPSPixelSimTopology::getPixelsInvolved
PixelInfo getPixelsInvolved(double x, double y, double sigma, double &hit_pos_x, double &hit_pos_y) const
Definition: CTPPSPixelSimTopology.cc:8
RPixChargeShare::no_of_pixels_
int no_of_pixels_
Definition: RPixChargeShare.h:21