10Int_t BmnVSPLayer::fUniqueIdL = 0;
11Int_t BmnVSPLayer::fUniqueIdU = 0;
28 AngleRad = AngleDeg*Pi()/180;
32 if(AngleDeg <= 0.0 && AngleDeg >= -90.0) {
36 if(AngleDeg > 0.0 && AngleDeg <= 90.0) {
41 ClusterFindingThreshold = 0.0;
48 Double_t xsize, Double_t ysize,
49 Double_t xorig, Double_t yorig,
50 Double_t pitch, Double_t adeg) {
55 LayerType = layer_type;
56 FirstStripNumber = first_strip_number;
59 XMaxLayer = xorig + xsize;
61 YMaxLayer = yorig + ysize;
65 AngleRad = AngleDeg*Pi()/180;
69 if(AngleDeg <= 0.0 && AngleDeg >= -90.0) {
73 if(AngleDeg > 0.0 && AngleDeg <= 90.0) {
78 ClusterFindingThreshold = 0.0;
92 Strips.resize(NStrips, 0.0);
101 BmnVSPLayer::fUniqueIdL = 0;
102 BmnVSPLayer::fUniqueIdU = 0;
112 Double_t n_strips = (xright_layer - xleft_layer)/Pitch;
122 return (Int_t)n_strips;
133 XMaxLayer = xorig + xsize;
135 YMaxLayer = yorig + ysize;
141 if(Abs(deg) <= 90.0) {
146 if(Verbosity) cerr <<
"WARNING: BmnVSPLayer::SetAngleDeg(): the strip angle is incorrect and has been set to zero\n";
149 AngleRad = AngleDeg*Pi()/180;
155 if(x_right < x_left)
return false;
157 XLeftPointOfStripNumbering = x_left;
158 YLeftPointOfStripNumbering = y_left;
159 XRightPointOfStripNumbering = x_right;
160 YRightPointOfStripNumbering = y_right;
170 if(Verbosity) cerr <<
"WARNING: SetStripNumberingBorders: left strip border point is incorrect\n";
174 if(Verbosity) cerr <<
"WARNING: SetStripNumberingBorders: right strip border point is incorrect\n";
178 XLeftPointOfStripNumbering = XMinLayer;
179 XRightPointOfStripNumbering = XMaxLayer;
183 YLeftPointOfStripNumbering = YMaxLayer;
186 YLeftPointOfStripNumbering = YMinLayer;
194 YRightPointOfStripNumbering = YMaxLayer;
197 YRightPointOfStripNumbering = YMinLayer;
209 StripOrder = strip_direction;
218 Bool_t status = dead_zone.
SetDeadZone(n_points, x_points, y_points);
220 DeadZones.push_back(dead_zone);
230 DeadZones.push_back(dead_zone);
239 for(
size_t izone = 0; izone < DeadZones.size(); ++izone) {
240 if(DeadZones[izone].IsInside(x,y))
return true;
247 if( x >= XMinLayer && x <= XMaxLayer &&
248 y >= YMinLayer && y <= YMaxLayer &&
255 if (strip_num >= FirstStripNumber && strip_num < (Int_t)(Strips.size()+FirstStripNumber))
257 Strips[strip_num-FirstStripNumber] = signal;
264 if (strip_num >= FirstStripNumber && strip_num < (Int_t)(Strips.size()+FirstStripNumber))
266 Strips[strip_num-FirstStripNumber] += signal;
273 if (strip_num >= FirstStripNumber && strip_num < (Int_t)(Strips.size()+FirstStripNumber))
275 return Strips[strip_num-FirstStripNumber];
281 if (strip_num >= FirstStripNumber && strip_num < (Int_t)(StripMatches.size()+FirstStripNumber))
283 StripMatches[strip_num-FirstStripNumber] = mc_match;
290 if (strip_num >= FirstStripNumber && strip_num < (Int_t)(StripMatches.size()+FirstStripNumber))
292 StripMatches[strip_num-FirstStripNumber].AddLink(weight, mc_num);
299 if (strip_num >= FirstStripNumber && strip_num < (Int_t)(StripDigitNumberMatches.size()+FirstStripNumber))
301 StripDigitNumberMatches[strip_num-FirstStripNumber] = digit_num_match;
308 if (strip_num >= FirstStripNumber && strip_num < (Int_t)(StripDigitNumberMatches.size()+FirstStripNumber))
310 StripDigitNumberMatches[strip_num-FirstStripNumber].AddLink(weight, digit_num);
317 if (strip_num >= FirstStripNumber && strip_num < (Int_t)(StripMatches.size()+FirstStripNumber))
319 return StripMatches[strip_num-FirstStripNumber];
325 if (strip_num >= FirstStripNumber && strip_num < (Int_t)(StripDigitNumberMatches.size()+FirstStripNumber))
327 return StripDigitNumberMatches[strip_num-FirstStripNumber];
335 StripMatches.clear();
336 StripMatches.resize(NStrips,
BmnMatch());
342 StripDigitNumberMatches.clear();
343 StripDigitNumberMatches.resize(NStrips,
BmnMatch());
347 if(num >= 0 && num < (Int_t)StripHits.size()) {
348 return StripHits[num];
354 if(num >= 0 && num < (Int_t)StripHitsTotalSignal.size()) {
355 return StripHitsTotalSignal[num];
361 if(num >= 0 && num < (Int_t)StripHitsErrors.size()) {
362 return StripHitsErrors[num];
368 if(num >= 0 && num < (Int_t)StripHitsClusterSize.size()) {
369 return StripHitsClusterSize[num];
376 StripHitsTotalSignal.clear();
377 StripHitsErrors.clear();
378 StripHitsClusterSize.clear();
379 StripClusters.clear();
383 Double_t XRotationCenter;
384 Double_t YRotationCenter;
387 XRotationCenter = XLeftPointOfStripNumbering;
388 YRotationCenter = YLeftPointOfStripNumbering;
392 XRotationCenter = XRightPointOfStripNumbering;
393 YRotationCenter = YRightPointOfStripNumbering;
396 Double_t StripX = (x - XRotationCenter)*Cos(-AngleRad) + (y - YRotationCenter)*Sin(-AngleRad) + XRotationCenter;
401 Double_t XRotationCenter;
402 Double_t YRotationCenter;
405 XRotationCenter = XLeftPointOfStripNumbering;
406 YRotationCenter = YLeftPointOfStripNumbering;
410 XRotationCenter = XRightPointOfStripNumbering;
411 YRotationCenter = YRightPointOfStripNumbering;
414 Double_t StripY = -(x - XRotationCenter)*Sin(-AngleRad) + (y - YRotationCenter)*Cos(-AngleRad) + YRotationCenter;
438 if(Abs(AngleDeg) != 90.0) {
439 Double_t x_strip_shift = ((strip_pos-FirstStripNumber)*Pitch)/Cos(Abs(AngleRad));
443 xcoord = XLeftPointOfStripNumbering + x_strip_shift;
444 b = YLeftPointOfStripNumbering - Tan(PiOver2()-AngleRad)*xcoord;
448 xcoord = XRightPointOfStripNumbering-x_strip_shift;
449 b = YRightPointOfStripNumbering - Tan(PiOver2()-AngleRad)*xcoord;
454 Double_t y_strip_shift = (strip_pos-FirstStripNumber)*Pitch*Sin(AngleRad);
457 b = YLeftPointOfStripNumbering - y_strip_shift;
461 b = YRightPointOfStripNumbering + y_strip_shift;
473 Double_t threshold = ClusterFindingThreshold;
478 Bool_t ascent =
false;
479 Bool_t descent =
false;
482 vector<Double_t> AnalyzableStrips = Strips;
489 for (Int_t is = 0; is < (Int_t)AnalyzableStrips.size(); is++)
491 if (AnalyzableStrips.at(is) <= threshold)
493 if(descent || ascent) {
524 cluster.
AddStrip(is, AnalyzableStrips.at(is));
529 Int_t lastnum = AnalyzableStrips.size()-1;
536 Double_t mean_strip_position = 0.0;
537 Double_t total_cluster_signal = 0.0;
538 Double_t cluster_rms = 0.0;
544 if(AnalyzableStrips.at(curcnt) >= AnalyzableStrips.at(curcnt-1)) {
546 AnalyzableStrips.at(curcnt-1) *= 0.5;
551 for(Int_t
i = 0;
i < NStripsInCluster; ++
i) {
552 Double_t strip_num = cluster.
Strips.at(
i) + FirstStripNumber;
553 Double_t signal = cluster.
Signals.at(
i);
554 total_cluster_signal += signal;
555 mean_strip_position += (strip_num+0.5)*signal;
557 mean_strip_position /= total_cluster_signal;
559 if(mean_strip_position < FirstStripNumber) mean_strip_position = FirstStripNumber;
560 if(mean_strip_position >= AnalyzableStrips.size()+FirstStripNumber) mean_strip_position = AnalyzableStrips.size() - 0.001;
580 Double_t sumW = total_cluster_signal;
582 Double_t sumWX2 = 0.;
583 if(NStripsInCluster > 1) {
584 for(Int_t
i = 0;
i < NStripsInCluster; ++
i) {
585 Double_t strip_num = cluster.
Strips.at(
i) + FirstStripNumber;
586 Double_t signal = cluster.
Signals.at(
i);
587 sumWX += strip_num * signal;
588 sumWX2 += strip_num * strip_num * signal;
590 cluster_rms = (sumWX2 - sumWX * sumWX / sumW) / sumW;
594 cluster_rms = 1.0 /TMath::Sqrt(12.0);
599 StripHits.push_back(mean_strip_position);
600 StripHitsTotalSignal.push_back(total_cluster_signal);
601 StripHitsErrors.push_back(cluster_rms);
602 StripHitsClusterSize.push_back(NStripsInCluster);
607 cluster.
Error = cluster_rms;
610 cluster.SetUniqueID(fUniqueIdL++);
613 cluster.SetUniqueID(fUniqueIdU++);
619 for(Int_t
i = 0;
i < NStripsInCluster; ++
i) {
620 cluster.
Strips.at(
i) += FirstStripNumber;
623 StripClusters.push_back(cluster);
627 if( curcnt < 0 ) curcnt = 0;
639 SmoothStrips.clear();
640 size_t NStrips = AnalyzableStrips.size();
642 for (Int_t iteration = 0; iteration < NIterations; ++iteration)
644 SmoothStrips.clear();
645 for (
size_t istrip = 0; istrip < NStrips; ++istrip)
647 Double_t mean_value = 0.0;
648 for (
size_t iw = istrip-SmoothWindow; iw <= (size_t)istrip+SmoothWindow; ++iw)
650 if (iw >= 0 && iw < NStrips)
652 if (iw == istrip) mean_value += AnalyzableStrips[iw]*Weight;
653 else mean_value += AnalyzableStrips[iw];
656 mean_value /= 2.0*SmoothWindow + Weight;
657 SmoothStrips.push_back(mean_value);
659 AnalyzableStrips = SmoothStrips;
Bool_t AddStripSignal(Int_t strip_num, Double_t signal)
Double_t GetStripHitError(Int_t num)
Double_t ConvertNormalPointToStripY(Double_t x, Double_t y)
Double_t CalculateStripEquationB(Double_t strip_pos)
Double_t ConvertNormalPointToStripX(Double_t x, Double_t y)
void MakeStripHit(StripCluster &cluster, vector< Double_t > &AnalyzableStrips, Int_t &curcnt)
Bool_t SetStripNumberingOrder(StripNumberingDirection strip_direction)
Double_t GetStripHitPos(Int_t num)
Bool_t SetStripMatch(Int_t strip_num, BmnMatch mc_match)
BmnMatch GetStripMatch(Int_t strip_num)
Bool_t SetStripSignal(Int_t strip_num, Double_t signal)
Double_t ConvertPointToStripPosition(Double_t x, Double_t y)
Bool_t SetStripNumberingBorders(Double_t x_left, Double_t y_left, Double_t x_right, Double_t y_right)
Bool_t IsPointInsideDeadZones(Double_t x, Double_t y)
void ResetStripDigitNumberMatches()
Bool_t AddLinkToStripDigitNumberMatch(Int_t strip_num, Double_t weight, Int_t digit_num)
BmnMatch GetStripDigitNumberMatch(Int_t strip_num)
void FindClustersAndStripHits()
Int_t GetStripHitClusterSize(Int_t num)
void SmoothStripSignal(vector< Double_t > &AnalyzableStrips, Int_t NIterations, Int_t SmoothWindow, Double_t Weight)
Bool_t SetStripDigitNumberMatch(Int_t strip_num, BmnMatch digit_num_match)
Double_t GetStripSignal(Int_t strip_num)
Double_t GetStripHitTotalSignal(Int_t num)
void SetLayerSizes(Double_t xsize, Double_t ysize, Double_t xorig=0.0, Double_t yorig=0.0)
void SetPitch(Double_t pitch)
void SetAngleDeg(Double_t deg)
Bool_t AddLinkToStripMatch(Int_t strip_num, Double_t weight, Int_t mc_num)
Bool_t IsPointInsideStripLayer(Double_t x, Double_t y)
Bool_t AddDeadZone(Int_t n_points, Double_t *x_points, Double_t *y_points)
Bool_t SetDeadZone(Int_t n_points, Double_t *xpoints, Double_t *ypoints)
void AddStrip(Int_t strip_num, Double_t strip_signal)
vector< Double_t > Signals