From 9f98b2c0d693dfac34989fb7f039ff49e156f90e Mon Sep 17 00:00:00 2001 From: hallc-online <hallconline@gmail.com> Date: Fri, 27 Apr 2018 18:23:07 -0400 Subject: [PATCH] Modify THcDC, THcDriftChamber, THcSpacePoint THcSpacePoint 1) added fSetStubFlag which is intialized to kFALSE in constructor and set to kTRUE when SetStub is called. 2) added method GetSetStubFlag which returns fSetStubFlag. THcDriftchamber 1) In ProcessHits increased fHits reserve to 40 2) In FindSpacePoints use fSpacePoints->Delete(); 3) In LeftRight ,only SetStub if the Stub is fit. THcDC 1) In LinkStubs a) only link stubs if number of total spacepoints <10 b) only link stubs if both spacepoints have SetStubFlag true THcDCHit.h 1) In constructor initalize fLR to 0 THcDCTrack.cxx 1) AddSpacePoint check if fnSP < 10 --- src/THcDC.cxx | 15 ++++++++++----- src/THcDCHit.h | 2 +- src/THcDCTrack.cxx | 2 ++ src/THcDriftChamber.cxx | 26 ++++++++++++-------------- src/THcSpacePoint.h | 5 ++++- 5 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/THcDC.cxx b/src/THcDC.cxx index 7f0cba2..feccef1 100644 --- a/src/THcDC.cxx +++ b/src/THcDC.cxx @@ -593,7 +593,7 @@ Int_t THcDC::CoarseTrack( TClonesArray& tracks ) fChambers[i]->CorrectHitTimes(); fChambers[i]->LeftRight(); } - if (fdebugflagpr) PrintSpacePoints(); + if (fdebugflagstubs) PrintSpacePoints(); if (fdebugflagstubs) PrintStubs(); // Now link the stubs between chambers LinkStubs(); @@ -691,7 +691,7 @@ void THcDC::PrintSpacePoints() printf("%5d %8.5f %8.5f %5d %5d ",isp+1,sp->GetX(),sp->GetY(),sp->GetNHits(),sp->GetCombos()) ; for (Int_t ii=0;ii<sp->GetNHits();ii++) { THcDCHit* hittemp = (THcDCHit*)(sp->GetHit(ii)); - printf("%3d %3d",hittemp->GetPlaneNum(),hittemp->GetWireNum()); + printf("%3d %3d %3d",hittemp->GetPlaneNum(),hittemp->GetWireNum(),hittemp->GetLR()); } printf("\n"); } @@ -734,7 +734,11 @@ void THcDC::LinkStubs() fNSp=0; fSp.clear(); fSp.reserve(10); + fNDCTracks=0; // Number of Focal Plane tracks found + fDCTracks->Delete(); // Make a vector of pointers to the SpacePoints + if (fChambers[0]->GetNSpacePoints()+fChambers[1]->GetNSpacePoints()>10) return; + for(UInt_t ich=0;ich<fNChambers;ich++) { Int_t nchamber=fChambers[ich]->GetChamberNum(); TClonesArray* spacepointarray = fChambers[ich]->GetSpacePointsP(); @@ -743,10 +747,9 @@ void THcDC::LinkStubs() fSp[fNSp]->fNChamber = nchamber; fSp[fNSp]->fNChamber_spnum = isp; fNSp++; + if (fNSp>10) break; } } - fNDCTracks=0; // Number of Focal Plane tracks found - fDCTracks->Clear("C"); Double_t stubminx = 999999; Double_t stubminy = 999999; Double_t stubminxp = 999999; @@ -772,7 +775,7 @@ void THcDC::LinkStubs() Int_t newtrack=1; for(Int_t isp2=isp1+1;isp2<fNSp;isp2++) { THcSpacePoint* sp2=fSp[isp2]; - if(sp1->fNChamber!=sp2->fNChamber) { + if(sp1->fNChamber!=sp2->fNChamber&&sp1->GetSetStubFlag()&&sp2->GetSetStubFlag()) { Double_t *spstub1=sp1->GetStubP(); Double_t *spstub2=sp2->GetStubP(); Double_t dposx = spstub1[0] - spstub2[0]; @@ -893,8 +896,10 @@ void THcDC::LinkStubs() for(Int_t isp=0;isp<fNSp;isp++) { if(fNDCTracks<MAXTRACKS) { // Need some constructed t thingy + if (fSp[isp]->GetSetStubFlag()) { THcDCTrack *newDCTrack = new( (*fDCTracks)[fNDCTracks++]) THcDCTrack(fNPlanes); newDCTrack->AddSpacePoint(fSp[isp]); + } } else { if (fdebuglinkstubs) cout << "EPIC FAIL 3: Too many tracks found in THcDC::LinkStubs" << endl; fNDCTracks=0; diff --git a/src/THcDCHit.h b/src/THcDCHit.h index a4260ba..69eeb86 100644 --- a/src/THcDCHit.h +++ b/src/THcDCHit.h @@ -19,7 +19,7 @@ public: THcDCHit( THcDCWire* wire=NULL, Int_t rawnorefcorrtime=0, Int_t rawtime=0, Double_t time=0.0, THcDriftChamberPlane* wp=0) : fWire(wire), fRawNoRefCorrTime(rawnorefcorrtime), fRawTime(rawtime), fTime(time), fWirePlane(wp), - fDist(0.0), ftrDist(kBig) { + fDist(0.0), fLR(0), ftrDist(kBig) { if (wire) ConvertTimeToDist(); fCorrected = 0; } diff --git a/src/THcDCTrack.cxx b/src/THcDCTrack.cxx index e2f75c9..b23c7af 100644 --- a/src/THcDCTrack.cxx +++ b/src/THcDCTrack.cxx @@ -31,12 +31,14 @@ void THcDCTrack::AddSpacePoint( THcSpacePoint* sp ) { // Add to list of space points in this track // Need a check for maximum spacepoints of 10 + if (fnSP <10) { fSp[fnSP++] = sp; // Copy all the hits from the space point into the track // Will need to also copy the corrected distance and lr information for(Int_t ihit=0;ihit<sp->GetNHits();ihit++) { AddHit(sp->GetHit(ihit),sp->GetHitDist(ihit),sp->GetHitLR(ihit)); } + } } void THcDCTrack::Clear( const Option_t* ) diff --git a/src/THcDriftChamber.cxx b/src/THcDriftChamber.cxx index 44d82ba..8aa6ca2 100644 --- a/src/THcDriftChamber.cxx +++ b/src/THcDriftChamber.cxx @@ -250,7 +250,7 @@ void THcDriftChamber::ProcessHits( void) // Make a list of hits for whole chamber fNhits = 0; fHits.clear(); - fHits.reserve(10); + fHits.reserve(40); for(Int_t ip=0;ip<fNPlanes;ip++) { TClonesArray* hitsarray = fPlanes[ip]->GetHits(); @@ -317,7 +317,8 @@ Int_t THcDriftChamber::FindSpacePoints( void ) that do not have nhits > min_hits and ncombos> min_combos ( exception for easyspacepoint) */ - fSpacePoints->Clear(); + // fSpacePoints->Clear(); + fSpacePoints->Delete(); Int_t plane_hitind=0; Int_t planep_hitind=0; @@ -352,7 +353,6 @@ Int_t THcDriftChamber::FindSpacePoints( void ) if(!fEasySpacePoint) { // It's not easy FindHardSpacePoints(); } - // We have our space points for this chamber if(fNSpacePoints > 0) { if(fHMSStyleChambers) { @@ -536,6 +536,7 @@ Int_t THcDriftChamber::FindHardSpacePoints() Double_t xt = (combos[icombo].pair1->x + combos[icombo].pair2->x)/2.0; Double_t yt = (combos[icombo].pair1->y + combos[icombo].pair2->y)/2.0; // Loop over space points + if(fNSpacePoints > 0) { Int_t add_flag=1; for(Int_t ispace=0;ispace<fNSpacePoints;ispace++) { @@ -842,12 +843,10 @@ void THcDriftChamber::ChooseSingleHit() { // Look at all hits in a space point. If two hits are in the same plane, // reject the one with the longer drift time. - for(Int_t isp=0;isp<fNSpacePoints;isp++) { THcSpacePoint* sp = (THcSpacePoint*)(*fSpacePoints)[isp]; Int_t startnum = sp->GetNHits(); Int_t goodhit[startnum]; - for(Int_t ihit=0;ihit<startnum;ihit++) { goodhit[ihit] = 1; } @@ -866,15 +865,12 @@ void THcDriftChamber::ChooseSingleHit() } else { goodhit[ihit2] = 0; } - // if (fhdebugflagpr) cout << " Rejecting hit " << ihit1 << " " << tdrift1 << " " << ihit2 << " " << tdrift2 << endl; } } } // Gather the remaining hits Int_t finalnum = 0; for(Int_t ihit=0;ihit<startnum;ihit++) { - //THcDCHit* hit = sp->GetHit(ihit); - // if (fhdebugflagpr) cout << " good hit = "<< ihit << " " << goodhit[ihit] << " time = " << hit->GetTime() << endl; if(goodhit[ihit] > 0) { // Keep this hit if (ihit > finalnum) { // Move hit sp->ReplaceHit(finalnum++, sp->GetHit(ihit)); @@ -899,13 +895,11 @@ void THcDriftChamber::SelectSpacePoints() for(Int_t isp=0;isp<fNSpacePoints;isp++) { // Include fEasySpacePoint because ncombos not filled in THcSpacePoint* sp = (THcSpacePoint*)(*fSpacePoints)[isp]; - // if (fhdebugflagpr) cout << " looping sp points " << sp->GetCombos() << " " << fMinCombos << " " << fEasySpacePoint << " " << sp->GetNHits() << " " << fMinHits << endl; if(sp->GetCombos() >= fMinCombos || fEasySpacePoint) { if(sp->GetNHits() >= fMinHits) { if(isp > sp_count) { // (*fSpacePoints)[sp_count] = (*fSpacePoints)[isp]; THcSpacePoint* sp1 = (THcSpacePoint*)(*fSpacePoints)[sp_count]; - //if (fhdebugflagpr) cout << " select space pt = " << isp << endl; sp1->Clear(); Double_t xt,yt; xt=sp->GetX(); @@ -921,7 +915,6 @@ void THcDriftChamber::SelectSpacePoints() } } } - // if(sp_count < fNSpacePoints) if (fhdebugflagpr) cout << "Reduced from " << fNSpacePoints << " to " << sp_count << " space points" << endl; fNSpacePoints = sp_count; //for(Int_t isp=0;isp<fNSpacePoints;isp++) { // THcSpacePoint* sp = (THcSpacePoint*)(*fSpacePoints)[isp]; @@ -1087,8 +1080,9 @@ void THcDriftChamber::LeftRight() THcSpacePoint* sp = (THcSpacePoint*)(*fSpacePoints)[isp]; Int_t nhits = sp->GetNHits(); UInt_t bitpat = 0; // Bit pattern of which planes are hit - Double_t minchi2 = 1.0e10; - Double_t tmp_minchi2=1.0e10; + Double_t maxchi2= 1.0e10; + Double_t minchi2 = maxchi2; + Double_t tmp_minchi2=maxchi2; Double_t minxp = 0.25; Int_t hasy1 = -1; Int_t hasy2 = -1; @@ -1253,7 +1247,10 @@ void THcDriftChamber::LeftRight() } } // End loop of pm combinations - if(minchi2 > 9.9e9) { // No track passed angle cut + if (minchi2 == maxchi2 && tmp_minchi2 == maxchi2) { + + }else{ + if(minchi2 == maxchi2 ) { // No track passed angle cut minchi2 = tmp_minchi2; for(Int_t ihit=0;ihit<nhits;ihit++) { plusminusbest[ihit] = tmp_plusminus[ihit]; @@ -1290,6 +1287,7 @@ void THcDriftChamber::LeftRight() - spstub[1]*stub[3]*fSinBeta[pindex]; sp->SetStub(stub); //if (fhdebugflagpr) cout << " Left/Right space pt " << isp+1 << " " << stub[0]<< " " << stub[1] << " " << stub[2]<< " " << stub[3] << endl; + } } // Option to print stubs } diff --git a/src/THcSpacePoint.h b/src/THcSpacePoint.h index 5701277..810156f 100644 --- a/src/THcSpacePoint.h +++ b/src/THcSpacePoint.h @@ -15,7 +15,7 @@ class THcSpacePoint : public TObject { public: THcSpacePoint(Int_t nhits=0, Int_t ncombos=0) : - fNHits(nhits), fNCombos(ncombos) { + fNHits(nhits), fNCombos(ncombos),fSetStubFlag(kFALSE) { fHits.clear(); } virtual ~THcSpacePoint() {} @@ -42,6 +42,7 @@ public: void SetNHits(Int_t nhits) {fNHits = nhits;}; Double_t GetX() {return fX;}; Double_t GetY() {return fY;}; + Bool_t GetSetStubFlag() {return fSetStubFlag;}; THcDCHit* GetHit(Int_t ihit) {return fHits[ihit].dchit;}; // std::vector<THcDCHit*>* GetHitVectorP() {return &fHits;}; //std::vector<Hit>* GetHitStuffVectorP() {return &fHits;}; @@ -60,6 +61,7 @@ public: for(Int_t i=0;i<4;i++) { fStub[i] = stub[i]; } + fSetStubFlag=kTRUE; }; Double_t GetHitDist(Int_t ihit) { return fHits[ihit].distCorr; }; Int_t GetHitLR(Int_t ihit) { return fHits[ihit].lr; }; @@ -87,6 +89,7 @@ protected: std::vector<Hit> fHits; //std::vector<THcDCHit*> fHits; Double_t fStub[4]; + Bool_t fSetStubFlag; // Should we also have a pointer back to the chamber object ClassDef(THcSpacePoint,0); // Space Point/stub track in a single drift chamber -- GitLab