20 bool MaxOnStart =
false;
21 bool MaxInMiddle =
false, MaxOnEnd =
false;
25 if (ampls.size() != 1 &&
26 ((ampls[0] > ampls[1]) ||
27 (ampls.size() > 2 && ampls[0] == ampls[1] && ampls[1] > ampls[2] && ampls[0] != 254 && ampls[0] != 255) ||
28 (ampls.size() == 2 && ampls[0] == ampls[1] && ampls[0] != 254 && ampls[0] != 255))) {
34 if (ampls.size() > 2) {
35 for (
unsigned int i = 1;
i < ampls.size() - 1
U;
i++) {
36 if ((ampls[
i] > ampls[
i - 1] && ampls[
i] > ampls[
i + 1]) ||
37 (ampls.size() > 3 &&
i > 0 &&
i < ampls.size() - 2
U && ampls[
i] == ampls[
i + 1] &&
38 ampls[
i] > ampls[
i - 1] && ampls[
i] > ampls[
i + 2] && ampls[
i] != 254 && ampls[
i] != 255)) {
43 if (ampls[
i] == 255 && ampls[
i] == ampls[
i - 1]) {
44 recur255 = recur255 + 1;
45 MaxPos =
i - (recur255 / 2);
46 if (ampls[
i] > ampls[
i + 1]) {
51 if (ampls[
i] == 254 && ampls[
i] == ampls[
i - 1]) {
52 recur254 = recur254 + 1;
53 MaxPos =
i - (recur254 / 2);
54 if (ampls[
i] > ampls[
i + 1]) {
63 if (ampls.size() > 1) {
64 if (ampls[ampls.size() - 1] > ampls[ampls.size() - 2] ||
65 (ampls.size() > 2 && ampls[ampls.size() - 1] == ampls[ampls.size() - 2] &&
66 ampls[ampls.size() - 2] > ampls[ampls.size() - 3]) ||
67 ampls[ampls.size() - 1] == 255) {
74 if (ampls.size() == 1) {
90 bool shapecdtn =
false;
96 Float_t C_Mnn = 10000;
97 Float_t C_Dnn = 10000;
100 Float_t coeff2 = 2.0;
101 Float_t coeffn = 0.10;
102 Float_t coeffnn = 0.02;
106 if (MaxOnStart ==
true) {
107 C_M = (Float_t)ampls[0];
108 C_D = (Float_t)ampls[1];
109 if (ampls.size() < 3)
111 else if (ampls.size() == 3) {
112 C_Dn = (Float_t)ampls[2];
113 if (C_Dn <= coeff1 * coeffn * C_D + coeff2 * coeffnn * C_M + 2 *
noise || C_D == 255)
115 }
else if (ampls.size() > 3) {
116 C_Dn = (Float_t)ampls[2];
117 C_Dnn = (Float_t)ampls[3];
118 if ((C_Dn <= coeff1 * coeffn * C_D + coeff2 * coeffnn * C_M + 2 *
noise || C_D == 255) &&
119 C_Dnn <= coeff1 * coeffn * C_Dn + coeff2 * coeffnn * C_D + 2 *
noise) {
125 if (MaxOnEnd ==
true) {
126 C_M = (Float_t)ampls[ampls.size() - 1];
127 C_D = (Float_t)ampls[ampls.size() - 2];
128 if (ampls.size() < 3)
130 else if (ampls.size() == 3) {
131 C_Dn = (Float_t)ampls[0];
132 if (C_Dn <= coeff1 * coeffn * C_D + coeff2 * coeffnn * C_M + 2 *
noise || C_D == 255)
134 }
else if (ampls.size() > 3) {
135 C_Dn = (Float_t)ampls[ampls.size() - 3];
136 C_Dnn = (Float_t)ampls[ampls.size() - 4];
137 if ((C_Dn <= coeff1 * coeffn * C_D + coeff2 * coeffnn * C_M + 2 *
noise || C_D == 255) &&
138 C_Dnn <= coeff1 * coeffn * C_Dn + coeff2 * coeffnn * C_D + 2 *
noise) {
144 if (MaxInMiddle ==
true) {
145 C_M = (Float_t)ampls[MaxPos];
146 int LeftOfMaxPos = MaxPos - 1;
147 if (LeftOfMaxPos <= 0)
149 int RightOfMaxPos = MaxPos + 1;
150 if (RightOfMaxPos >= (
int)ampls.size())
151 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& offsetDU_) {
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() - offsetDU_];
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& offsetDU_) {
259 auto const& dus = tkGeom.
detUnits();
260 calibGains.resize(dus.size() - offsetDU_);
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 (
Record ==
"SiStripDeDxMip_3D_Rcd") {
287 if (
Record ==
"SiStripDeDxPion_3D_Rcd") {
290 if (
Record ==
"SiStripDeDxKaon_3D_Rcd") {
293 if (
Record ==
"SiStripDeDxProton_3D_Rcd") {
296 if (
Record ==
"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") <<
"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;
444 trapezoidalBounds ? (*trapezoidalBounds).parameters()[3] : it->
surface().
bounds().
length() / 2.0;
446 if (fabs(HitLocalPos.y()) + HitLocalError.
yy() >= (
HalfLength - DistFromBorder))
uint16_t firstStrip() const
virtual float length() const =0
const TrackerGeomDet * idToDetUnit(DetId) const override
Return the pointer to the GeomDetUnit corresponding to a given DetId.
const LocalTrajectoryError & localError() const
LocalPoint localPosition() const
const DetContainer & detUnits() const override
Returm a vector of all GeomDet.
LocalError positionError() const
SiStripCluster const & amplitudes() const
bool getData(T &iHolder) const
constexpr float gains[NGAINS]
Log< level::Info, false > LogInfo
const Plane & surface() const
The nominal surface of the GeomDet.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float >, ROOT::Math::LocalCoordinateSystemTag > LocalPoint
point in local coordinate system
const Bounds & bounds() const