From 69c8b5a3f6fea5bb803ce59f3308f4fae55c3cfd Mon Sep 17 00:00:00 2001 From: "Stephen A. Wood" <saw@jlab.org> Date: Thu, 19 Dec 2013 15:21:35 -0500 Subject: [PATCH] Do fSpacePointCriterion comparison correctly. Fix from Mark Jones with additional cleanup for saw's misunderstanding of space point criterion --- src/THcDC.cxx | 8 ++++---- src/THcDC.h | 4 ++-- src/THcDriftChamber.cxx | 18 ++++++++---------- src/THcDriftChamber.h | 2 +- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/THcDC.cxx b/src/THcDC.cxx index 3d573a4..be89cfc 100644 --- a/src/THcDC.cxx +++ b/src/THcDC.cxx @@ -45,7 +45,7 @@ THcDC::THcDC( fMinHits = NULL; fMaxHits = NULL; fMinCombos = NULL; - fSpace_Point_Criterion2 = NULL; + fSpace_Point_Criterion = NULL; fTdcWinMin = NULL; fTdcWinMax = NULL; @@ -251,7 +251,7 @@ Int_t THcDC::ReadDatabase( const TDatime& date ) delete [] fMinHits; fMinHits = new Int_t [fNChambers]; delete [] fMaxHits; fMaxHits = new Int_t [fNChambers]; delete [] fMinCombos; fMinCombos = new Int_t [fNChambers]; - delete [] fSpace_Point_Criterion2; fSpace_Point_Criterion2 = new Double_t [fNChambers]; + delete [] fSpace_Point_Criterion; fSpace_Point_Criterion = new Double_t [fNChambers]; delete [] fTdcWinMin; fTdcWinMin = new Int_t [fNPlanes]; delete [] fTdcWinMax; fTdcWinMax = new Int_t [fNPlanes]; @@ -279,7 +279,7 @@ Int_t THcDC::ReadDatabase( const TDatime& date ) {"min_hit", fMinHits, kInt, fNChambers}, {"max_pr_hits", fMaxHits, kInt, fNChambers}, {"min_combos", fMinCombos, kInt, fNChambers}, - {"space_point_criterion", fSpace_Point_Criterion2, kDouble, fNChambers}, + {"space_point_criterion", fSpace_Point_Criterion, kDouble, fNChambers}, {"dc_tdc_min_win", fTdcWinMin, kInt, fNPlanes}, {"dc_tdc_max_win", fTdcWinMax, kInt, fNPlanes}, @@ -380,7 +380,7 @@ void THcDC::DeleteArrays() delete [] fMinHits; fMinHits = NULL; delete [] fMaxHits; fMaxHits = NULL; delete [] fMinCombos; fMinCombos = NULL; - delete [] fSpace_Point_Criterion2; fSpace_Point_Criterion2 = NULL; + delete [] fSpace_Point_Criterion; fSpace_Point_Criterion = NULL; delete [] fTdcWinMin; fTdcWinMin = NULL; delete [] fTdcWinMax; fTdcWinMax = NULL; diff --git a/src/THcDC.h b/src/THcDC.h index 396847c..68ea807 100644 --- a/src/THcDC.h +++ b/src/THcDC.h @@ -55,7 +55,7 @@ public: Int_t GetMinHits(Int_t chamber) const { return fMinHits[chamber-1];} Int_t GetMaxHits(Int_t chamber) const { return fMaxHits[chamber-1];} Int_t GetMinCombos(Int_t chamber) const { return fMinCombos[chamber-1];} - Double_t GetSpacePointCriterion(Int_t chamber) const { return fSpace_Point_Criterion2[chamber-1];} + Double_t GetSpacePointCriterion(Int_t chamber) const { return fSpace_Point_Criterion[chamber-1];} Double_t GetCentralTime(Int_t plane) const { return fCentralTime[plane-1];} Int_t GetDriftTimeSign(Int_t plane) const { return fDriftTimeSign[plane-1];} @@ -120,7 +120,7 @@ protected: Int_t* fMinHits; Int_t* fMaxHits; Int_t* fMinCombos; - Double_t* fSpace_Point_Criterion2; + Double_t* fSpace_Point_Criterion; // Each of these will be dimensioned with the number of planes // A THcDCPlane class object will need to access the value for diff --git a/src/THcDriftChamber.cxx b/src/THcDriftChamber.cxx index 21fd41c..69f0c75 100644 --- a/src/THcDriftChamber.cxx +++ b/src/THcDriftChamber.cxx @@ -155,8 +155,8 @@ Int_t THcDriftChamber::ReadDatabase( const TDatime& date ) fFixPropagationCorrection = fParent->GetFixPropagationCorrectionFlag(); fSpacePointCriterion = fParent->GetSpacePointCriterion(fChamberNum); - - fSpacePointCriterion2 = fSpacePointCriterion*fSpacePointCriterion; + fMaxDist = TMath::Sqrt(fSpacePointCriterion/2.0); // For easy space points + if (fhdebugflagpr) cout << " cham = " << fChamberNum << " Set yplane num " << YPlaneNum << " "<< YPlanePNum << endl; // Generate the HAA3INV matrix for all the acceptable combinations // of hit planes. Try to make it as generic as possible @@ -367,13 +367,12 @@ Int_t THcDriftChamber::FindEasySpacePoint_HMS(Int_t yplane_hitind,Int_t yplanep_ x_pos[ihit] = 0.0; } } - Double_t max_dist = TMath::Sqrt(fSpacePointCriterion/2.); xt = (num_xhits>0?xt/num_xhits:0.0); easy_space_point = 1; // Assume we have an easy space point // Rule it out if x points don't cluster well enough for(Int_t ihit=0;ihit<fNhits;ihit++) { if(ihit!=yplane_hitind && ihit!=yplanep_hitind) { // select x-like hit - if(TMath::Abs(xt-x_pos[ihit]) >= max_dist) + if(TMath::Abs(xt-x_pos[ihit]) >= fMaxDist) { easy_space_point=0; break;} } } @@ -414,13 +413,12 @@ Int_t THcDriftChamber::FindEasySpacePoint_SOS(Int_t xplane_hitind,Int_t xplanep_ y_pos[ihit] = 0.0; } } - Double_t max_dist = TMath::Sqrt(fSpacePointCriterion/2.); yt = (num_yhits>0?yt/num_yhits:0.0); easy_space_point = 1; // Assume we have an easy space point // Rule it out if x points don't cluster well enough for(Int_t ihit=0;ihit<fNhits;ihit++) { if(ihit!=xplane_hitind && ihit!=xplanep_hitind) { // select y-like hit - if(TMath::Abs(yt-y_pos[ihit]) >= max_dist) + if(TMath::Abs(yt-y_pos[ihit]) >= fMaxDist) { easy_space_point=0; break;} } } @@ -483,7 +481,7 @@ Int_t THcDriftChamber::FindHardSpacePoints() if(ncombos < 10*MAX_NUMBER_PAIRS) { Double_t dist2 = pow(pairs[ipair1].x - pairs[ipair2].x,2) + pow(pairs[ipair1].y - pairs[ipair2].y,2); - if(dist2 <= fSpacePointCriterion2) { + if(dist2 <= fSpacePointCriterion) { combos[ncombos].pair1 = &pairs[ipair1]; combos[ncombos].pair2 = &pairs[ipair2]; ncombos++; @@ -510,11 +508,11 @@ Int_t THcDriftChamber::FindHardSpacePoints() if(sp->GetNHits() > 0) { Double_t sqdist_test = pow(xt - sp->GetX(),2) + pow(yt - sp->GetY(),2); // I (who is I) want to be careful if sqdist_test is bvetween 1 and - // 3 fSpacePointCriterion2. Let me ignore not add a new point the - if(sqdist_test < 3*fSpacePointCriterion2) { + // 3 fSpacePointCriterion. Let me ignore not add a new point the + if(sqdist_test < 3*fSpacePointCriterion) { add_flag = 0; // do not add a new space point } - if(sqdist_test < fSpacePointCriterion2) { + if(sqdist_test < fSpacePointCriterion) { // This is a real match // Add the new hits to the existing space point Int_t iflag[4]; diff --git a/src/THcDriftChamber.h b/src/THcDriftChamber.h index d49dfeb..b77fca4 100644 --- a/src/THcDriftChamber.h +++ b/src/THcDriftChamber.h @@ -95,7 +95,7 @@ protected: Double_t fXCenter; Double_t fYCenter; Double_t fSpacePointCriterion; - Double_t fSpacePointCriterion2; + Double_t fMaxDist; // Max dist used in EasySpacePoint methods Double_t* fSinBeta; Double_t* fCosBeta; Double_t* fTanBeta; -- GitLab