diff --git a/src/THcDC.cxx b/src/THcDC.cxx index 7f0cba2805e8cf4774c1d518b59960960ad89c54..feccef1f2913b3da8e928ddc9fcde5cb857339f8 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 a4260bae6b70398c32e0559965c36754ebf143d9..69eeb8659e1c67b91e4e2d7adb83a125094a98e0 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 e2f75c951d9c77ab9fe79417931525e0be9fdb35..b23c7af112eeb1bc8fc5851a17c1a9d9fcf2213e 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 44d82bad27997b051b37761b3b775a66cf433890..8aa6ca2e9ec4f4587eefa992695679ef0efd61d4 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 5701277c0f2ed214d4d5fd32210de0d6cab62cb9..810156ffa5674b70972996dd0805db6c8b98558b 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