10Int_t BmnSiliconLayer::fUniqueIdL = 0;
11Int_t BmnSiliconLayer::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 BmnSiliconLayer::fUniqueIdL = 0;
102 BmnSiliconLayer::fUniqueIdU = 0;
112 Double_t n_strips = (xright_layer - xleft_layer)/Pitch;
114 if( (n_strips - (Int_t)n_strips) < 1E-10 ) {
115 return (Int_t)n_strips;
118 return (Int_t)(n_strips+1);
130 XMaxLayer = xorig + xsize;
132 YMaxLayer = yorig + ysize;
138 if(Abs(deg) <= 90.0) {
143 if(Verbosity) cerr <<
"WARNING: BmnSiliconLayer::SetAngleDeg(): the strip angle is incorrect and has been set to zero\n";
146 AngleRad = AngleDeg*Pi()/180;
152 if(x_right < x_left)
return false;
154 XLeftPointOfStripNumbering = x_left;
155 YLeftPointOfStripNumbering = y_left;
156 XRightPointOfStripNumbering = x_right;
157 YRightPointOfStripNumbering = y_right;
167 if(Verbosity) cerr <<
"WARNING: SetStripNumberingBorders: left strip border point is incorrect\n";
171 if(Verbosity) cerr <<
"WARNING: SetStripNumberingBorders: right strip border point is incorrect\n";
175 XLeftPointOfStripNumbering = XMinLayer;
176 XRightPointOfStripNumbering = XMaxLayer;
180 YLeftPointOfStripNumbering = YMaxLayer;
183 YLeftPointOfStripNumbering = YMinLayer;
191 YRightPointOfStripNumbering = YMaxLayer;
194 YRightPointOfStripNumbering = YMinLayer;
206 StripOrder = strip_direction;
215 Bool_t status = dead_zone.
SetDeadZone(n_points, x_points, y_points);
217 DeadZones.push_back(dead_zone);
227 DeadZones.push_back(dead_zone);
236 for (
size_t izone = 0; izone < DeadZones.size(); ++izone)
237 if(DeadZones[izone].IsInside(x,y))
return true;
243 if( x >= XMinLayer && x <= XMaxLayer &&
244 y >= YMinLayer && y <= YMaxLayer &&
251 if (strip_num >= FirstStripNumber && strip_num < ((Int_t)Strips.size()+FirstStripNumber) ) {
252 Strips[strip_num-FirstStripNumber] = signal;
259 if (strip_num >= FirstStripNumber && strip_num < ((Int_t)Strips.size()+FirstStripNumber)) {
260 Strips[strip_num-FirstStripNumber] += signal;
267 if ( strip_num >= FirstStripNumber && strip_num < ((Int_t)Strips.size()+FirstStripNumber) )
268 return Strips[strip_num-FirstStripNumber];
273 if ( strip_num >= FirstStripNumber && strip_num < ((Int_t)StripMatches.size()+FirstStripNumber) ) {
274 StripMatches[strip_num-FirstStripNumber] = mc_match;
281 if (strip_num >= FirstStripNumber && strip_num < ((Int_t)StripMatches.size()+FirstStripNumber)) {
282 StripMatches[strip_num-FirstStripNumber].AddLink(weight, mc_num);
289 if (strip_num >= FirstStripNumber && strip_num < ((Int_t)StripDigitNumberMatches.size()+FirstStripNumber)) {
290 StripDigitNumberMatches[strip_num-FirstStripNumber] = digit_num_match;
297 if (strip_num >= FirstStripNumber && strip_num < ((Int_t)StripDigitNumberMatches.size()+FirstStripNumber)) {
298 StripDigitNumberMatches[strip_num-FirstStripNumber].AddLink(weight, digit_num);
305 if (strip_num >= FirstStripNumber && strip_num < ((Int_t)StripMatches.size()+FirstStripNumber))
306 return StripMatches[strip_num-FirstStripNumber];
311 if (strip_num >= FirstStripNumber && strip_num < ((Int_t)StripDigitNumberMatches.size()+FirstStripNumber))
312 return StripDigitNumberMatches[strip_num-FirstStripNumber];
319 StripMatches.clear();
320 StripMatches.resize(NStrips,
BmnMatch());
326 StripDigitNumberMatches.clear();
327 StripDigitNumberMatches.resize(NStrips,
BmnMatch());
331 if (num >= 0 && num < (Int_t)StripHits.size())
332 return StripHits[num];
338 if (num >= 0 && num < (Int_t)StripHitsTotalSignal.size())
339 return StripHitsTotalSignal[num];
345 if (num >= 0 && num < (Int_t)StripHitsErrors.size())
346 return StripHitsErrors[num];
352 if (num >= 0 && num < (Int_t)StripHitsClusterSize.size())
353 return StripHitsClusterSize[num];
360 StripHitsTotalSignal.clear();
361 StripHitsErrors.clear();
362 StripHitsClusterSize.clear();
363 StripClusters.clear();
367 Double_t XRotationCenter;
368 Double_t YRotationCenter;
371 XRotationCenter = XLeftPointOfStripNumbering;
372 YRotationCenter = YLeftPointOfStripNumbering;
376 XRotationCenter = XRightPointOfStripNumbering;
377 YRotationCenter = YRightPointOfStripNumbering;
380 Double_t StripX = (x - XRotationCenter)*Cos(-AngleRad) + (y - YRotationCenter)*Sin(-AngleRad) + XRotationCenter;
385 Double_t XRotationCenter;
386 Double_t YRotationCenter;
389 XRotationCenter = XLeftPointOfStripNumbering;
390 YRotationCenter = YLeftPointOfStripNumbering;
394 XRotationCenter = XRightPointOfStripNumbering;
395 YRotationCenter = YRightPointOfStripNumbering;
398 Double_t StripY = -(x - XRotationCenter)*Sin(-AngleRad) + (y - YRotationCenter)*Cos(-AngleRad) + YRotationCenter;
422 if(Abs(AngleDeg) != 90.0) {
423 Double_t x_strip_shift = ((strip_pos-FirstStripNumber)*Pitch)/Cos(Abs(AngleRad));
427 xcoord = XLeftPointOfStripNumbering + x_strip_shift;
428 b = YLeftPointOfStripNumbering - Tan(PiOver2()-AngleRad)*xcoord;
432 xcoord = XRightPointOfStripNumbering-x_strip_shift;
433 b = YRightPointOfStripNumbering - Tan(PiOver2()-AngleRad)*xcoord;
438 Double_t y_strip_shift = (strip_pos-FirstStripNumber)*Pitch*Sin(AngleRad);
441 b = YLeftPointOfStripNumbering - y_strip_shift;
445 b = YRightPointOfStripNumbering + y_strip_shift;
457 Double_t threshold = ClusterFindingThreshold;
462 Bool_t ascent =
false;
463 Bool_t descent =
false;
466 vector<Double_t> AnalyzableStrips = Strips;
473 for (Int_t is = 0; is < (Int_t)AnalyzableStrips.size(); is++)
475 if(AnalyzableStrips.at(is) <= threshold) {
476 if(descent || ascent) {
507 cluster.
AddStrip(is, AnalyzableStrips.at(is));
512 Int_t lastnum = AnalyzableStrips.size()-1;
519 Double_t mean_strip_position = 0.0;
520 Double_t total_cluster_signal = 0.0;
521 Double_t cluster_rms = 0.0;
527 if(AnalyzableStrips.at(curcnt) >= AnalyzableStrips.at(curcnt-1)) {
529 AnalyzableStrips.at(curcnt-1) *= 0.5;
534 for(Int_t
i = 0;
i < NStripsInCluster; ++
i) {
535 Double_t strip_num = cluster.
Strips.at(
i) + FirstStripNumber;
536 Double_t signal = cluster.
Signals.at(
i);
537 total_cluster_signal += signal;
538 mean_strip_position += (strip_num+0.5)*signal;
540 mean_strip_position /= total_cluster_signal;
542 if(mean_strip_position < FirstStripNumber) mean_strip_position = FirstStripNumber;
543 if(mean_strip_position >= AnalyzableStrips.size()+FirstStripNumber) mean_strip_position = AnalyzableStrips.size() - 0.001;
563 Double_t sumW = total_cluster_signal;
565 Double_t sumWX2 = 0.;
566 if(NStripsInCluster > 1) {
567 for(Int_t
i = 0;
i < NStripsInCluster; ++
i) {
568 Double_t strip_num = cluster.
Strips.at(
i) + FirstStripNumber;
569 Double_t signal = cluster.
Signals.at(
i);
570 sumWX += strip_num * signal;
571 sumWX2 += strip_num * strip_num * signal;
573 cluster_rms = (sumWX2 - sumWX * sumWX / sumW) / sumW;
577 cluster_rms = 1.0 /TMath::Sqrt(12.0);
582 StripHits.push_back(mean_strip_position);
583 StripHitsTotalSignal.push_back(total_cluster_signal);
584 StripHitsErrors.push_back(cluster_rms);
585 StripHitsClusterSize.push_back(NStripsInCluster);
590 cluster.
Error = cluster_rms;
593 cluster.SetUniqueID(fUniqueIdL++);
596 cluster.SetUniqueID(fUniqueIdU++);
602 for(Int_t
i = 0;
i < NStripsInCluster; ++
i) {
603 cluster.
Strips.at(
i) += FirstStripNumber;
606 StripClusters.push_back(cluster);
610 if( curcnt < 0 ) curcnt = 0;
622 SmoothStrips.clear();
623 Int_t NStrips = AnalyzableStrips.size();
625 for(Int_t iteration = 0; iteration < NIterations; ++iteration) {
626 SmoothStrips.clear();
627 for(Int_t istrip = 0; istrip < NStrips; ++istrip) {
628 Double_t mean_value = 0.0;
629 for(Int_t iw = istrip-SmoothWindow; iw <= istrip+SmoothWindow; ++iw) {
630 if(iw >= 0 && iw < NStrips) {
631 if(iw == istrip) mean_value += AnalyzableStrips[iw]*Weight;
632 else mean_value += AnalyzableStrips[iw];
635 mean_value /= 2.0*SmoothWindow + Weight;
636 SmoothStrips.push_back(mean_value);
638 AnalyzableStrips = SmoothStrips;
Bool_t AddDeadZone(Int_t n_points, Double_t *x_points, Double_t *y_points)
Double_t CalculateStripEquationB(Double_t strip_pos)
Bool_t IsPointInsideStripLayer(Double_t x, Double_t y)
Double_t GetStripSignal(Int_t strip_num)
Bool_t SetStripDigitNumberMatch(Int_t strip_num, BmnMatch digit_num_match)
void MakeStripHit(StripCluster &cluster, vector< Double_t > &AnalyzableStrips, Int_t &curcnt)
BmnMatch GetStripMatch(Int_t strip_num)
Bool_t SetStripMatch(Int_t strip_num, BmnMatch mc_match)
void SmoothStripSignal(vector< Double_t > &AnalyzableStrips, Int_t NIterations, Int_t SmoothWindow, Double_t Weight)
Bool_t AddStripSignal(Int_t strip_num, Double_t signal)
Bool_t SetStripSignal(Int_t strip_num, Double_t signal)
void SetAngleDeg(Double_t deg)
Bool_t IsPointInsideDeadZones(Double_t x, Double_t y)
Bool_t AddLinkToStripMatch(Int_t strip_num, Double_t weight, Int_t mc_num)
void ResetStripDigitNumberMatches()
Bool_t SetStripNumberingBorders(Double_t x_left, Double_t y_left, Double_t x_right, Double_t y_right)
BmnMatch GetStripDigitNumberMatch(Int_t strip_num)
Double_t GetStripHitPos(Int_t num)
Bool_t SetStripNumberingOrder(StripNumberingDirection strip_direction)
Double_t ConvertNormalPointToStripY(Double_t x, Double_t y)
Double_t GetStripHitError(Int_t num)
Int_t GetStripHitClusterSize(Int_t num)
void SetPitch(Double_t pitch)
Bool_t AddLinkToStripDigitNumberMatch(Int_t strip_num, Double_t weight, Int_t digit_num)
void SetLayerSizes(Double_t xsize, Double_t ysize, Double_t xorig=0.0, Double_t yorig=0.0)
Double_t ConvertNormalPointToStripX(Double_t x, Double_t y)
void FindClustersAndStripHits()
Double_t ConvertPointToStripPosition(Double_t x, Double_t y)
Double_t GetStripHitTotalSignal(Int_t num)
virtual ~BmnSiliconLayer()
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