17 bool MaxOnStart =
false;
18 bool MaxInMiddle =
false, MaxOnEnd =
false;
21 if (ampls.size() != 1 &&
22 ((ampls[0] > ampls[1]) ||
23 (ampls.size() > 2 && ampls[0] == ampls[1] && ampls[1] > ampls[2] && ampls[0] != 254 && ampls[0] != 255) ||
24 (ampls.size() == 2 && ampls[0] == ampls[1] && ampls[0] != 254 && ampls[0] != 255))) {
30 if (ampls.size() > 2) {
31 for (
unsigned int i = 1;
i < ampls.size() - 1
U;
i++) {
32 if ((ampls[
i] > ampls[
i - 1] && ampls[
i] > ampls[
i + 1]) ||
33 (ampls.size() > 3 &&
i > 0 &&
i < ampls.size() - 2
U && ampls[
i] == ampls[
i + 1] &&
34 ampls[
i] > ampls[
i - 1] && ampls[
i] > ampls[
i + 2] && ampls[
i] != 254 && ampls[
i] != 255)) {
39 if (ampls[
i] == 255 && ampls[
i] == ampls[
i - 1]) {
40 recur255 = recur255 + 1;
41 MaxPos =
i - (recur255 / 2);
42 if (ampls[
i] > ampls[
i + 1]) {
47 if (ampls[
i] == 254 && ampls[
i] == ampls[
i - 1]) {
48 recur254 = recur254 + 1;
49 MaxPos =
i - (recur254 / 2);
50 if (ampls[
i] > ampls[
i + 1]) {
58 if (ampls.size() > 1) {
59 if (ampls[ampls.size() - 1] > ampls[ampls.size() - 2] ||
60 (ampls.size() > 2 && ampls[ampls.size() - 1] == ampls[ampls.size() - 2] &&
61 ampls[ampls.size() - 2] > ampls[ampls.size() - 3]) ||
62 ampls[ampls.size() - 1] == 255) {
68 if (ampls.size() == 1) {
85 bool shapecdtn =
false;
92 Float_t C_Mnn = 10000;
93 Float_t C_Dnn = 10000;
97 Float_t coeffn = 0.10;
98 Float_t coeffnn = 0.02;
102 if (MaxOnStart ==
true) {
103 C_M = (Float_t)ampls[0];
104 C_D = (Float_t)ampls[1];
105 if (ampls.size() < 3)
107 else if (ampls.size() == 3) {
108 C_Dn = (Float_t)ampls[2];
109 if (C_Dn <= coeff1 * coeffn * C_D + coeff2 * coeffnn * C_M + 2 *
noise || C_D == 255)
111 }
else if (ampls.size() > 3) {
112 C_Dn = (Float_t)ampls[2];
113 C_Dnn = (Float_t)ampls[3];
114 if ((C_Dn <= coeff1 * coeffn * C_D + coeff2 * coeffnn * C_M + 2 *
noise || C_D == 255) &&
115 C_Dnn <= coeff1 * coeffn * C_Dn + coeff2 * coeffnn * C_D + 2 *
noise) {
121 if (MaxOnEnd ==
true) {
122 C_M = (Float_t)ampls[ampls.size() - 1];
123 C_D = (Float_t)ampls[ampls.size() - 2];
124 if (ampls.size() < 3)
126 else if (ampls.size() == 3) {
127 C_Dn = (Float_t)ampls[0];
128 if (C_Dn <= coeff1 * coeffn * C_D + coeff2 * coeffnn * C_M + 2 *
noise || C_D == 255)
130 }
else if (ampls.size() > 3) {
131 C_Dn = (Float_t)ampls[ampls.size() - 3];
132 C_Dnn = (Float_t)ampls[ampls.size() - 4];
133 if ((C_Dn <= coeff1 * coeffn * C_D + coeff2 * coeffnn * C_M + 2 *
noise || C_D == 255) &&
134 C_Dnn <= coeff1 * coeffn * C_Dn + coeff2 * coeffnn * C_D + 2 *
noise) {
140 if (MaxInMiddle ==
true) {
141 C_M = (Float_t)ampls[MaxPos];
142 int LeftOfMaxPos = MaxPos - 1;
143 if (LeftOfMaxPos <= 0)
145 int RightOfMaxPos = MaxPos + 1;
146 if (RightOfMaxPos >= (
int)ampls.size())
147 RightOfMaxPos = ampls.size() - 1;
149 if (ampls[LeftOfMaxPos] < ampls[RightOfMaxPos]) {
150 C_D = (Float_t)ampls[RightOfMaxPos];
151 C_Mn = (Float_t)ampls[LeftOfMaxPos];
152 CDPos = RightOfMaxPos;
154 C_D = (Float_t)ampls[LeftOfMaxPos];
155 C_Mn = (Float_t)ampls[RightOfMaxPos];
156 CDPos = LeftOfMaxPos;
158 if (C_Mn < coeff1 * coeffn * C_M + coeff2 * coeffnn * C_D + 2 *
noise || C_M == 255) {
159 if (ampls.size() == 3)
161 else if (ampls.size() > 3) {
162 if (CDPos > MaxPos) {
163 if (ampls.size() - CDPos - 1 == 0) {
167 if (ampls.size() - CDPos - 1 == 1) {
168 C_Dn = (Float_t)ampls[CDPos + 1];
171 if (ampls.size() - CDPos - 1 > 1) {
172 C_Dn = (Float_t)ampls[CDPos + 1];
173 C_Dnn = (Float_t)ampls[CDPos + 2];
176 C_Mnn = (Float_t)ampls[MaxPos - 2];
177 }
else if (MaxPos < 2)
180 if (CDPos < MaxPos) {
186 C_Dn = (Float_t)ampls[0];
190 C_Dn = (Float_t)ampls[CDPos - 1];
191 C_Dnn = (Float_t)ampls[CDPos - 2];
193 if (ampls.size() - LeftOfMaxPos > 1 && MaxPos + 2 < (
int)(ampls.size()) - 1) {
194 C_Mnn = (Float_t)ampls[MaxPos + 2];
198 if ((C_Dn <= coeff1 * coeffn * C_D + coeff2 * coeffnn * C_M + 2 *
noise || C_D == 255) &&
199 C_Mnn <= coeff1 * coeffn * C_Mn + coeff2 * coeffnn * C_M + 2 *
noise &&
200 C_Dnn <= coeff1 * coeffn * C_Dn + coeff2 * coeffnn * C_D + 2 *
noise) {
207 if (ampls.size() == 1) {
217 const std::vector<std::vector<float> >& calibGains,
218 const unsigned int& m_off) {
224 if (calibGains.empty()) {
225 for (
unsigned int i = 0;
i < Ampls.size();
i++) {
226 int calibratedCharge = Ampls[
i];
227 charge += calibratedCharge;
228 if (calibratedCharge >= 254)
232 for (
unsigned int i = 0;
i < Ampls.size();
i++) {
233 int calibratedCharge = Ampls[
i];
235 auto& gains = calibGains[detUnit.
index() - m_off];
236 calibratedCharge = (
int)(calibratedCharge / gains[(cluster->
firstStrip() +
i) / 128]);
237 if (calibratedCharge >= 255) {
238 if (calibratedCharge >= 1025)
239 calibratedCharge = 255;
241 calibratedCharge = 254;
244 charge += calibratedCharge;
245 if (calibratedCharge >= 254)
255 const unsigned int& m_off) {
256 auto const& dus = tkGeom.
detUnits();
257 calibGains.resize(dus.size() - m_off);
259 TChain*
t1 =
new TChain(
"SiStripCalib/APVGain");
260 t1->Add(m_calibrationPath.c_str());
262 unsigned int tree_DetId;
263 unsigned char tree_APVId;
265 t1->SetBranchAddress(
"DetId", &tree_DetId);
266 t1->SetBranchAddress(
"APVId", &tree_APVId);
267 t1->SetBranchAddress(
"Gain", &tree_Gain);
269 for (
unsigned int ientry = 0; ientry <
t1->GetEntries(); ientry++) {
270 t1->GetEntry(ientry);
272 if (gains.size() < (size_t)(tree_APVId + 1)) {
273 gains.resize(tree_APVId + 1);
275 gains[tree_APVId] = tree_Gain;
284 TH3F*& Prob_ChargePath) {
286 if (strcmp(
Reccord.c_str(),
"SiStripDeDxMip_3D_Rcd") == 0) {
288 }
else if (strcmp(
Reccord.c_str(),
"SiStripDeDxPion_3D_Rcd") == 0) {
290 }
else if (strcmp(
Reccord.c_str(),
"SiStripDeDxKaon_3D_Rcd") == 0) {
292 }
else if (strcmp(
Reccord.c_str(),
"SiStripDeDxProton_3D_Rcd") == 0) {
294 }
else if (strcmp(
Reccord.c_str(),
"SiStripDeDxElectron_3D_Rcd") == 0) {
308 delete Prob_ChargePath;
309 Prob_ChargePath =
new TH3F(
"Prob_ChargePath",
322 for (
int i = 0;
i <= Prob_ChargePath->GetXaxis()->GetNbins() + 1;
i++) {
323 for (
int j = 0;
j <= Prob_ChargePath->GetYaxis()->GetNbins() + 1;
j++) {
325 for (
int k = 0;
k <= Prob_ChargePath->GetZaxis()->GetNbins() + 1;
k++) {
328 for (
int k = 0;
k <= Prob_ChargePath->GetZaxis()->GetNbins() + 1;
k++) {
330 for (
int l = 0;
l <=
k;
l++) {
334 Prob_ChargePath->SetBinContent(
i,
j,
k,
tmp / Ni);
336 Prob_ChargePath->SetBinContent(
i,
j,
k, 0);
342 for (
int i = 0;
i <= Prob_ChargePath->GetXaxis()->GetNbins() + 1;
i++) {
343 for (
int j = 0;
j <= Prob_ChargePath->GetYaxis()->GetNbins() + 1;
j++) {
345 for (
int k = 0;
k <= Prob_ChargePath->GetZaxis()->GetNbins() + 1;
k++) {
348 for (
int k = 0;
k <= Prob_ChargePath->GetZaxis()->GetNbins() + 1;
k++) {
351 Prob_ChargePath->SetBinContent(
i,
j,
k,
tmp / Ni);
353 Prob_ChargePath->SetBinContent(
i,
j,
k, 0);
366 if (FirstStrip == 128)
368 if (FirstStrip == 256)
370 if (FirstStrip == 384)
372 if (FirstStrip == 512)
374 if (FirstStrip == 640)
377 if (FirstStrip <= 127 && FirstStrip + ClusterSize > 127)
379 if (FirstStrip <= 255 && FirstStrip + ClusterSize > 255)
381 if (FirstStrip <= 383 && FirstStrip + ClusterSize > 383)
383 if (FirstStrip <= 511 && FirstStrip + ClusterSize > 511)
385 if (FirstStrip <= 639 && FirstStrip + ClusterSize > 639)
405 if (dynamic_cast<const StripGeomDetUnit*>(it) ==
nullptr && dynamic_cast<const PixelGeomDetUnit*>(it) ==
nullptr) {
406 edm::LogInfo(
"DeDxTools::IsFarFromBorder") <<
"this detID doesn't seem to belong to the Tracker" << std::endl;
414 const TrapezoidalPlaneBounds* trapezoidalBounds(dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
415 const RectangularPlaneBounds* rectangularBounds(dynamic_cast<const RectangularPlaneBounds*>(&(plane.bounds())));
417 if (!trapezoidalBounds && !rectangularBounds)
420 double DistFromBorder = 1.0;
423 trapezoidalBounds ? (*trapezoidalBounds).parameters()[3] : it->
surface().
bounds().
length() / 2.0;
426 if (fabs(HitLocalPos.y()) + HitLocalError.
yy() >= (
HalfLength - DistFromBorder))