20 bool MaxOnStart =
false;
21 bool MaxInMiddle =
false, MaxOnEnd =
false;
24 if (ampls.size() != 1 &&
25 ((ampls[0] > ampls[1]) ||
26 (ampls.size() > 2 && ampls[0] == ampls[1] && ampls[1] > ampls[2] && ampls[0] != 254 && ampls[0] != 255) ||
27 (ampls.size() == 2 && ampls[0] == ampls[1] && ampls[0] != 254 && ampls[0] != 255))) {
33 if (ampls.size() > 2) {
34 for (
unsigned int i = 1;
i < ampls.size() - 1
U;
i++) {
35 if ((ampls[
i] > ampls[
i - 1] && ampls[
i] > ampls[
i + 1]) ||
36 (ampls.size() > 3 &&
i > 0 &&
i < ampls.size() - 2
U && ampls[
i] == ampls[
i + 1] &&
37 ampls[
i] > ampls[
i - 1] && ampls[
i] > ampls[
i + 2] && ampls[
i] != 254 && ampls[
i] != 255)) {
42 if (ampls[
i] == 255 && ampls[
i] == ampls[
i - 1]) {
43 recur255 = recur255 + 1;
44 MaxPos =
i - (recur255 / 2);
45 if (ampls[
i] > ampls[
i + 1]) {
50 if (ampls[
i] == 254 && ampls[
i] == ampls[
i - 1]) {
51 recur254 = recur254 + 1;
52 MaxPos =
i - (recur254 / 2);
53 if (ampls[
i] > ampls[
i + 1]) {
61 if (ampls.size() > 1) {
62 if (ampls[ampls.size() - 1] > ampls[ampls.size() - 2] ||
63 (ampls.size() > 2 && ampls[ampls.size() - 1] == ampls[ampls.size() - 2] &&
64 ampls[ampls.size() - 2] > ampls[ampls.size() - 3]) ||
65 ampls[ampls.size() - 1] == 255) {
71 if (ampls.size() == 1) {
88 bool shapecdtn =
false;
95 Float_t C_Mnn = 10000;
96 Float_t C_Dnn = 10000;
100 Float_t coeffn = 0.10;
101 Float_t coeffnn = 0.02;
105 if (MaxOnStart ==
true) {
106 C_M = (Float_t)ampls[0];
107 C_D = (Float_t)ampls[1];
108 if (ampls.size() < 3)
110 else if (ampls.size() == 3) {
111 C_Dn = (Float_t)ampls[2];
112 if (C_Dn <= coeff1 * coeffn * C_D + coeff2 * coeffnn * C_M + 2 *
noise || C_D == 255)
114 }
else if (ampls.size() > 3) {
115 C_Dn = (Float_t)ampls[2];
116 C_Dnn = (Float_t)ampls[3];
117 if ((C_Dn <= coeff1 * coeffn * C_D + coeff2 * coeffnn * C_M + 2 *
noise || C_D == 255) &&
118 C_Dnn <= coeff1 * coeffn * C_Dn + coeff2 * coeffnn * C_D + 2 *
noise) {
124 if (MaxOnEnd ==
true) {
125 C_M = (Float_t)ampls[ampls.size() - 1];
126 C_D = (Float_t)ampls[ampls.size() - 2];
127 if (ampls.size() < 3)
129 else if (ampls.size() == 3) {
130 C_Dn = (Float_t)ampls[0];
131 if (C_Dn <= coeff1 * coeffn * C_D + coeff2 * coeffnn * C_M + 2 *
noise || C_D == 255)
133 }
else if (ampls.size() > 3) {
134 C_Dn = (Float_t)ampls[ampls.size() - 3];
135 C_Dnn = (Float_t)ampls[ampls.size() - 4];
136 if ((C_Dn <= coeff1 * coeffn * C_D + coeff2 * coeffnn * C_M + 2 *
noise || C_D == 255) &&
137 C_Dnn <= coeff1 * coeffn * C_Dn + coeff2 * coeffnn * C_D + 2 *
noise) {
143 if (MaxInMiddle ==
true) {
144 C_M = (Float_t)ampls[MaxPos];
145 int LeftOfMaxPos = MaxPos - 1;
146 if (LeftOfMaxPos <= 0)
148 int RightOfMaxPos = MaxPos + 1;
149 if (RightOfMaxPos >= (
int)ampls.size())
150 RightOfMaxPos = ampls.size() - 1;
152 if (ampls[LeftOfMaxPos] < ampls[RightOfMaxPos]) {
153 C_D = (Float_t)ampls[RightOfMaxPos];
154 C_Mn = (Float_t)ampls[LeftOfMaxPos];
155 CDPos = RightOfMaxPos;
157 C_D = (Float_t)ampls[LeftOfMaxPos];
158 C_Mn = (Float_t)ampls[RightOfMaxPos];
159 CDPos = LeftOfMaxPos;
161 if (C_Mn < coeff1 * coeffn * C_M + coeff2 * coeffnn * C_D + 2 *
noise || C_M == 255) {
162 if (ampls.size() == 3)
164 else if (ampls.size() > 3) {
165 if (CDPos > MaxPos) {
166 if (ampls.size() - CDPos - 1 == 0) {
170 if (ampls.size() - CDPos - 1 == 1) {
171 C_Dn = (Float_t)ampls[CDPos + 1];
174 if (ampls.size() - CDPos - 1 > 1) {
175 C_Dn = (Float_t)ampls[CDPos + 1];
176 C_Dnn = (Float_t)ampls[CDPos + 2];
179 C_Mnn = (Float_t)ampls[MaxPos - 2];
180 }
else if (MaxPos < 2)
183 if (CDPos < MaxPos) {
189 C_Dn = (Float_t)ampls[0];
193 C_Dn = (Float_t)ampls[CDPos - 1];
194 C_Dnn = (Float_t)ampls[CDPos - 2];
196 if (ampls.size() - LeftOfMaxPos > 1 && MaxPos + 2 < (
int)(ampls.size()) - 1) {
197 C_Mnn = (Float_t)ampls[MaxPos + 2];
201 if ((C_Dn <= coeff1 * coeffn * C_D + coeff2 * coeffnn * C_M + 2 *
noise || C_D == 255) &&
202 C_Mnn <= coeff1 * coeffn * C_Mn + coeff2 * coeffnn * C_M + 2 *
noise &&
203 C_Dnn <= coeff1 * coeffn * C_Dn + coeff2 * coeffnn * C_D + 2 *
noise) {
210 if (ampls.size() == 1) {
220 const std::vector<std::vector<float> >& calibGains,
221 const unsigned int& m_off) {
227 if (calibGains.empty()) {
228 for (
unsigned int i = 0;
i < Ampls.size();
i++) {
229 int calibratedCharge = Ampls[
i];
230 charge += calibratedCharge;
231 if (calibratedCharge >= 254)
235 for (
unsigned int i = 0;
i < Ampls.size();
i++) {
236 int calibratedCharge = Ampls[
i];
238 auto& gains = calibGains[detUnit.
index() - m_off];
239 calibratedCharge = (
int)(calibratedCharge / gains[(cluster->
firstStrip() +
i) / 128]);
240 if (calibratedCharge >= 255) {
241 if (calibratedCharge >= 1025)
242 calibratedCharge = 255;
244 calibratedCharge = 254;
247 charge += calibratedCharge;
248 if (calibratedCharge >= 254)
258 const unsigned int& m_off) {
259 auto const& dus = tkGeom.
detUnits();
260 calibGains.resize(dus.size() - m_off);
262 TChain*
t1 =
new TChain(
"SiStripCalib/APVGain");
263 t1->Add(m_calibrationPath.c_str());
265 unsigned int tree_DetId;
266 unsigned char tree_APVId;
268 t1->SetBranchAddress(
"DetId", &tree_DetId);
269 t1->SetBranchAddress(
"APVId", &tree_APVId);
270 t1->SetBranchAddress(
"Gain", &tree_Gain);
272 for (
unsigned int ientry = 0; ientry <
t1->GetEntries(); ientry++) {
273 t1->GetEntry(ientry);
275 if (gains.size() < (size_t)(tree_APVId + 1)) {
276 gains.resize(tree_APVId + 1);
278 gains[tree_APVId] = tree_Gain;
284 if (
Reccord ==
"SiStripDeDxMip_3D_Rcd") {
287 if (
Reccord ==
"SiStripDeDxPion_3D_Rcd") {
290 if (
Reccord ==
"SiStripDeDxKaon_3D_Rcd") {
293 if (
Reccord ==
"SiStripDeDxProton_3D_Rcd") {
296 if (
Reccord ==
"SiStripDeDxElectron_3D_Rcd") {
304 switch (iToken.index()) {
306 return iES.
getData(std::get<0>(iToken));
308 return iES.
getData(std::get<1>(iToken));
310 return iES.
getData(std::get<2>(iToken));
312 return iES.
getData(std::get<3>(iToken));
314 return iES.
getData(std::get<4>(iToken));
321 TH3F*& Prob_ChargePath) {
330 delete Prob_ChargePath;
331 Prob_ChargePath =
new TH3F(
"Prob_ChargePath",
344 for (
int i = 0;
i <= Prob_ChargePath->GetXaxis()->GetNbins() + 1;
i++) {
345 for (
int j = 0;
j <= Prob_ChargePath->GetYaxis()->GetNbins() + 1;
j++) {
347 for (
int k = 0;
k <= Prob_ChargePath->GetZaxis()->GetNbins() + 1;
k++) {
350 for (
int k = 0;
k <= Prob_ChargePath->GetZaxis()->GetNbins() + 1;
k++) {
352 for (
int l = 0;
l <=
k;
l++) {
356 Prob_ChargePath->SetBinContent(
i,
j,
k,
tmp / Ni);
358 Prob_ChargePath->SetBinContent(
i,
j,
k, 0);
364 for (
int i = 0;
i <= Prob_ChargePath->GetXaxis()->GetNbins() + 1;
i++) {
365 for (
int j = 0;
j <= Prob_ChargePath->GetYaxis()->GetNbins() + 1;
j++) {
367 for (
int k = 0;
k <= Prob_ChargePath->GetZaxis()->GetNbins() + 1;
k++) {
370 for (
int k = 0;
k <= Prob_ChargePath->GetZaxis()->GetNbins() + 1;
k++) {
373 Prob_ChargePath->SetBinContent(
i,
j,
k,
tmp / Ni);
375 Prob_ChargePath->SetBinContent(
i,
j,
k, 0);
388 if (FirstStrip == 128)
390 if (FirstStrip == 256)
392 if (FirstStrip == 384)
394 if (FirstStrip == 512)
396 if (FirstStrip == 640)
399 if (FirstStrip <= 127 && FirstStrip + ClusterSize > 127)
401 if (FirstStrip <= 255 && FirstStrip + ClusterSize > 255)
403 if (FirstStrip <= 383 && FirstStrip + ClusterSize > 383)
405 if (FirstStrip <= 511 && FirstStrip + ClusterSize > 511)
407 if (FirstStrip <= 639 && FirstStrip + ClusterSize > 639)
427 if (dynamic_cast<const StripGeomDetUnit*>(it) ==
nullptr && dynamic_cast<const PixelGeomDetUnit*>(it) ==
nullptr) {
428 edm::LogInfo(
"DeDxTools::IsFarFromBorder") <<
"this detID doesn't seem to belong to the Tracker" << std::endl;
436 const TrapezoidalPlaneBounds* trapezoidalBounds(dynamic_cast<const TrapezoidalPlaneBounds*>(&(plane.bounds())));
437 const RectangularPlaneBounds* rectangularBounds(dynamic_cast<const RectangularPlaneBounds*>(&(plane.bounds())));
439 if (!trapezoidalBounds && !rectangularBounds)
442 double DistFromBorder = 1.0;
445 trapezoidalBounds ? (*trapezoidalBounds).parameters()[3] : it->
surface().
bounds().
length() / 2.0;
448 if (fabs(HitLocalPos.y()) + HitLocalError.
yy() >= (
HalfLength - DistFromBorder))