3Int_t BmnCSCLayer::fUniqueIdL = 0;
4Int_t BmnCSCLayer::fUniqueIdU = 0;
20 AngleRad = AngleDeg*Pi()/180;
24 if(AngleDeg <= 0.0 && AngleDeg >= -90.0) {
28 if(AngleDeg > 0.0 && AngleDeg <= 90.0) {
33 ClusterFindingThreshold = 0.0;
37 Double_t xsize, Double_t ysize,
38 Double_t xorig, Double_t yorig,
39 Double_t pitch, Double_t adeg) {
43 LayerZoneNumber = zone_number;
44 LayerType = layer_type;
47 XMaxLayer = xorig + xsize;
49 YMaxLayer = yorig + ysize;
53 AngleRad = AngleDeg*Pi()/180;
57 if(AngleDeg <= 0.0 && AngleDeg >= -90.0) {
61 if(AngleDeg > 0.0 && AngleDeg <= 90.0) {
66 ClusterFindingThreshold = 0.0;
78 Strips.resize(NStrips, 0.0);
87 BmnCSCLayer::fUniqueIdL = 0;
88 BmnCSCLayer::fUniqueIdU = 0;
98 Double_t n_strips = (xright_layer - xleft_layer)/Pitch;
100 if( (n_strips - (Int_t)n_strips) < 1E-10 ) {
101 return (Int_t)n_strips;
104 return (Int_t)(n_strips+1);
116 XMaxLayer = xorig + xsize;
118 YMaxLayer = yorig + ysize;
124 if(Abs(deg) <= 90.0) {
129 if(Verbosity) cerr <<
"WARNING: BmnCSCLayer::SetAngleDeg(): the strip angle is incorrect and has been set to zero\n";
132 AngleRad = AngleDeg*Pi()/180;
138 if(x_right < x_left)
return false;
140 XLeftPointOfStripNumbering = x_left;
141 YLeftPointOfStripNumbering = y_left;
142 XRightPointOfStripNumbering = x_right;
143 YRightPointOfStripNumbering = y_right;
153 if(Verbosity) cerr <<
"WARNING: SetStripNumberingBorders: left strip border point is incorrect\n";
157 if(Verbosity) cerr <<
"WARNING: SetStripNumberingBorders: right strip border point is incorrect\n";
161 XLeftPointOfStripNumbering = XMinLayer;
162 XRightPointOfStripNumbering = XMaxLayer;
166 YLeftPointOfStripNumbering = YMaxLayer;
169 YLeftPointOfStripNumbering = YMinLayer;
177 YRightPointOfStripNumbering = YMaxLayer;
180 YRightPointOfStripNumbering = YMinLayer;
192 StripOrder = strip_direction;
201 Bool_t status = dead_zone.
SetDeadZone(n_points, x_points, y_points);
203 DeadZones.push_back(dead_zone);
213 DeadZones.push_back(dead_zone);
222 for(
size_t izone = 0; izone < DeadZones.size(); ++izone) {
223 if(DeadZones[izone].IsInside(x,y))
return true;
230 if( x >= XMinLayer && x <= XMaxLayer &&
231 y >= YMinLayer && y <= YMaxLayer &&
238 if (strip_num >= 0 && strip_num < (Int_t)Strips.size())
240 Strips[strip_num] = signal;
247 if(strip_num >= 0 && strip_num < (Int_t)Strips.size()) {
248 Strips[strip_num] += signal;
255 if(strip_num >= 0 && strip_num < (Int_t)Strips.size()) {
256 return Strips[strip_num];
262 if(strip_num >= 0 && strip_num < (Int_t)StripMatches.size()) {
263 StripMatches[strip_num] = strip_match;
270 if(strip_num >= 0 && strip_num < (Int_t)StripMatches.size()) {
271 StripMatches[strip_num].AddLink(weight, refID);
278 if(strip_num >= 0 && strip_num < (Int_t)StripDigitNumberMatches.size()) {
279 StripDigitNumberMatches[strip_num] = digit_num_match;
286 if(strip_num >= 0 && strip_num < (Int_t)StripDigitNumberMatches.size()) {
287 StripDigitNumberMatches[strip_num].AddLink(weight, digit_num);
294 if(strip_num >= 0 && strip_num < (Int_t)StripMatches.size()) {
295 return StripMatches[strip_num];
301 if(strip_num >= 0 && strip_num < (Int_t)StripDigitNumberMatches.size()) {
302 return StripDigitNumberMatches[strip_num];
310 StripMatches.clear();
311 StripMatches.resize(NStrips,
BmnMatch());
317 StripDigitNumberMatches.clear();
318 StripDigitNumberMatches.resize(NStrips,
BmnMatch());
322 if(num >= 0 && num < (Int_t)StripHits.size()) {
323 return StripHits[num];
329 if(num >= 0 && num < (Int_t)StripHitsTotalSignal.size()) {
330 return StripHitsTotalSignal[num];
336 if(num >= 0 && num < (Int_t)StripHitsErrors.size()) {
337 return StripHitsErrors[num];
343 if(num >= 0 && num < (Int_t)StripHitsClusterSize.size()) {
344 return StripHitsClusterSize[num];
351 StripHitsTotalSignal.clear();
352 StripHitsErrors.clear();
353 StripHitsClusterSize.clear();
354 StripClusters.clear();
358 Double_t XRotationCenter;
359 Double_t YRotationCenter;
362 XRotationCenter = XLeftPointOfStripNumbering;
363 YRotationCenter = YLeftPointOfStripNumbering;
367 XRotationCenter = XRightPointOfStripNumbering;
368 YRotationCenter = YRightPointOfStripNumbering;
371 Double_t StripX = (x - XRotationCenter)*Cos(-AngleRad) + (y - YRotationCenter)*Sin(-AngleRad) + XRotationCenter;
376 Double_t XRotationCenter;
377 Double_t YRotationCenter;
380 XRotationCenter = XLeftPointOfStripNumbering;
381 YRotationCenter = YLeftPointOfStripNumbering;
385 XRotationCenter = XRightPointOfStripNumbering;
386 YRotationCenter = YRightPointOfStripNumbering;
389 Double_t StripY = -(x - XRotationCenter)*Sin(-AngleRad) + (y - YRotationCenter)*Cos(-AngleRad) + YRotationCenter;
413 if(Abs(AngleDeg) != 90.0) {
414 Double_t x_strip_shift = (strip_pos*Pitch)/Cos(Abs(AngleRad));
418 xcoord = XLeftPointOfStripNumbering + x_strip_shift;
419 b = YLeftPointOfStripNumbering - Tan(PiOver2()-AngleRad)*xcoord;
423 xcoord = XRightPointOfStripNumbering-x_strip_shift;
424 b = YRightPointOfStripNumbering - Tan(PiOver2()-AngleRad)*xcoord;
429 Double_t y_strip_shift = strip_pos*Pitch*Sin(AngleRad);
432 b = YLeftPointOfStripNumbering - y_strip_shift;
436 b = YRightPointOfStripNumbering + y_strip_shift;
448 Double_t threshold = ClusterFindingThreshold;
453 Bool_t ascent =
false;
454 Bool_t descent =
false;
457 vector<Double_t> AnalyzableStrips = Strips;
464 for (Int_t is = 0; is < (Int_t)AnalyzableStrips.size(); is++)
466 if(AnalyzableStrips.at(is) <= threshold) {
467 if(descent || ascent) {
498 cluster.
AddStrip(is, AnalyzableStrips.at(is));
503 Int_t lastnum = AnalyzableStrips.size()-1;
510 Double_t mean_strip_position = 0.0;
511 Double_t total_cluster_signal = 0.0;
512 Double_t cluster_rms = 0.0;
518 if(AnalyzableStrips.at(curcnt) >= AnalyzableStrips.at(curcnt-1)) {
520 AnalyzableStrips.at(curcnt-1) *= 0.5;
525 for(Int_t
i = 0;
i < NStripsInCluster; ++
i) {
526 Double_t strip_num = cluster.
Strips.at(
i);
527 Double_t signal = cluster.
Signals.at(
i);
528 total_cluster_signal += signal;
529 mean_strip_position += (strip_num+0.5)*signal;
531 mean_strip_position /= total_cluster_signal;
533 if(mean_strip_position < 0.0) mean_strip_position = 0.0;
534 if(mean_strip_position >= AnalyzableStrips.size()) mean_strip_position = AnalyzableStrips.size() - 0.001;
554 Double_t sumW = total_cluster_signal;
556 Double_t sumWX2 = 0.;
557 if(NStripsInCluster > 1) {
558 for(Int_t
i = 0;
i < NStripsInCluster; ++
i) {
559 Double_t strip_num = cluster.
Strips.at(
i);
560 Double_t signal = cluster.
Signals.at(
i);
561 sumWX += strip_num * signal;
562 sumWX2 += strip_num * strip_num * signal;
564 cluster_rms = (sumWX2 - sumWX * sumWX / sumW) / sumW;
568 cluster_rms = 1.0 /TMath::Sqrt(12.0);
586 StripHits.push_back(mean_strip_position);
587 StripHitsTotalSignal.push_back(total_cluster_signal);
588 StripHitsErrors.push_back(cluster_rms);
589 StripHitsClusterSize.push_back(NStripsInCluster);
594 cluster.
Error = cluster_rms;
597 cluster.SetUniqueID(fUniqueIdL++);
600 cluster.SetUniqueID(fUniqueIdU++);
603 StripClusters.push_back(cluster);
607 if( curcnt < 0 ) curcnt = 0;
619 SmoothStrips.clear();
620 Int_t NStrips = AnalyzableStrips.size();
622 for(Int_t iteration = 0; iteration < NIterations; ++iteration) {
623 SmoothStrips.clear();
624 for(Int_t istrip = 0; istrip < NStrips; ++istrip) {
625 Double_t mean_value = 0.0;
626 for(Int_t iw = istrip-SmoothWindow; iw <= istrip+SmoothWindow; ++iw) {
627 if(iw >= 0 && iw < NStrips) {
628 if(iw == istrip) mean_value += AnalyzableStrips[iw]*Weight;
629 else mean_value += AnalyzableStrips[iw];
632 mean_value /= 2.0*SmoothWindow + Weight;
633 SmoothStrips.push_back(mean_value);
635 AnalyzableStrips = SmoothStrips;
Double_t CalculateStripEquationB(Double_t strip_pos)
Bool_t SetStripMatch(Int_t strip_num, BmnMatch strip_match)
Double_t GetStripHitPos(Int_t num)
void MakeStripHit(StripCluster &cluster, vector< Double_t > &AnalyzableStrips, Int_t &curcnt)
Bool_t SetStripDigitNumberMatch(Int_t strip_num, BmnMatch digit_num_match)
void SetAngleDeg(Double_t deg)
Double_t ConvertNormalPointToStripX(Double_t x, Double_t y)
BmnMatch GetStripDigitNumberMatch(Int_t strip_num)
void SmoothStripSignal(vector< Double_t > &AnalyzableStrips, Int_t NIterations, Int_t SmoothWindow, Double_t Weight)
void SetLayerSizes(Double_t xsize, Double_t ysize, Double_t xorig=0.0, Double_t yorig=0.0)
Bool_t AddStripSignal(Int_t strip_num, Double_t signal)
Double_t GetStripHitError(Int_t num)
Double_t GetStripSignal(Int_t strip_num)
Double_t ConvertPointToStripPosition(Double_t x, Double_t y)
Double_t ConvertNormalPointToStripY(Double_t x, Double_t y)
Bool_t AddDeadZone(Int_t n_points, Double_t *x_points, Double_t *y_points)
Bool_t SetStripNumberingOrder(StripNumberingDirection strip_direction)
Bool_t AddLinkToStripMatch(Int_t strip_num, Double_t weight, Int_t refID)
Int_t GetStripHitClusterSize(Int_t num)
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)
Bool_t IsPointInsideStripLayer(Double_t x, Double_t y)
BmnMatch GetStripMatch(Int_t strip_num)
void SetPitch(Double_t pitch)
Bool_t SetStripSignal(Int_t strip_num, Double_t signal)
void ResetStripDigitNumberMatches()
void FindClustersAndStripHits()
Double_t GetStripHitTotalSignal(Int_t num)
Bool_t AddLinkToStripDigitNumberMatch(Int_t strip_num, Double_t weight, Int_t digit_num)
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