diff --git a/src/THcHallCSpectrometer.cxx b/src/THcHallCSpectrometer.cxx index 0bb6c069571c7a82a16a44de119f1ddee4e0d2aa..793277b63177fcdcf6d1d2f58df99b1bd9518540 100644 --- a/src/THcHallCSpectrometer.cxx +++ b/src/THcHallCSpectrometer.cxx @@ -457,16 +457,13 @@ Int_t THcHallCSpectrometer::TrackCalc() if ( fSelUsingScin == 1 ){ if( fNtracks > 0 ) { - Double_t ft; //, fShowerEnergy; Int_t itrack; //, fGoodTimeIndex = -1; - Int_t fRawIndex, fGoodRawPad; fGoodTrack = -1; chi2Min = 10000000000.0; Double_t y2Dmin = 100.; Double_t x2Dmin = 100.; - fRawIndex = -1; for ( itrack = 0; itrack < fNtracks; itrack++ ){ Double_t chi2PerDeg; @@ -490,24 +487,23 @@ Int_t THcHallCSpectrometer::TrackCalc() y2Hits[j] = -1; } + Int_t rawindex = 0; for (Int_t ip = 0; ip < fNPlanes; ip++ ){ for (UInt_t ihit = 0; ihit < fHodo->GetNScinHits(ip); ihit++ ){ - fRawIndex ++; - cout << itrack << " " << fRawIndex << endl; - // fGoodRawPad = fHodo->GetGoodRawPad(fRawIndex)-1; - fGoodRawPad = fHodo->GetGoodRawPad(fRawIndex); - cout << itrack << " " << fRawIndex << " " << fGoodRawPad << endl; + // goodRawPad = fHodo->GetGoodRawPad(rawindex)-1; + // Kind of a fragile way to get the paddle number + Int_t goodRawPad = fHodo->GetGoodRawPad(rawindex); if ( ip == 2 ){ - x2Hits[fGoodRawPad] = 0; + x2Hits[goodRawPad] = 0; } if ( ip == 3 ){ - y2Hits[fGoodRawPad] = 0; + y2Hits[goodRawPad] = 0; } - + rawindex ++; } // loop over hits of a plane } // loop over planes @@ -520,19 +516,29 @@ Int_t THcHallCSpectrometer::TrackCalc() if ( fNtracks > 1 ){ // Plane 4 Double_t zap = 0.; - ft = 0; + Int_t ft = 0; + // What is this doing? There must be a simpler way. + // Why stop at ft==6? Something identifying the paddle + // with hits that is closest to where the track passes? for (UInt_t i = 0; i < fHodo->GetNPaddles(3); i++ ){ if ( y2Hits[i] == 0 ) { y2D[itrack] = TMath::Abs((Int_t)hitCnt4-(Int_t)i-1); ft ++; - +#if 0 if ( ft == 1 ) zap = y2D[itrack]; if ( ( ft == 2 ) && ( y2D[itrack] < zap ) ) zap = y2D[itrack]; if ( ( ft == 3 ) && ( y2D[itrack] < zap ) ) zap = y2D[itrack]; if ( ( ft == 4 ) && ( y2D[itrack] < zap ) ) zap = y2D[itrack]; if ( ( ft == 5 ) && ( y2D[itrack] < zap ) ) zap = y2D[itrack]; if ( ( ft == 6 ) && ( y2D[itrack] < zap ) ) zap = y2D[itrack]; +#else + if (ft==1) { + zap = y2D[itrack]; + } else if (ft>=2 && ft<=6) { + if(y2D[itrack] < zap) zap = y2D[itrack]; + } +#endif } // condition for fHodScinHit[4][i] } // loop over 10 @@ -551,18 +557,26 @@ Int_t THcHallCSpectrometer::TrackCalc() if ( fNtracks > 1 ){ // Plane 3 (2X) Double_t zap = 0.; - ft = 0; + Int_t ft = 0; for (UInt_t i = 0; i < fHodo->GetNPaddles(2); i++ ){ if ( x2Hits[i] == 0 ) { x2D[itrack] = TMath::Abs((Int_t)hitCnt3-(Int_t)i-1); ft ++; +#if 0 if ( ft == 1 ) zap = x2D[itrack]; if ( ( ft == 2 ) && ( x2D[itrack] < zap ) ) zap = x2D[itrack]; if ( ( ft == 3 ) && ( x2D[itrack] < zap ) ) zap = x2D[itrack]; if ( ( ft == 4 ) && ( x2D[itrack] < zap ) ) zap = x2D[itrack]; if ( ( ft == 5 ) && ( x2D[itrack] < zap ) ) zap = x2D[itrack]; if ( ( ft == 6 ) && ( x2D[itrack] < zap ) ) zap = x2D[itrack]; +#else + if (ft==1) { + zap = x2D[itrack]; + } else if (ft>=2 && ft<=6) { + if(x2D[itrack] < zap) zap = x2D[itrack]; + } +#endif } // condition for fHodScinHit[4][i] } // loop over 16 diff --git a/src/THcHodoscope.cxx b/src/THcHodoscope.cxx index c98b230bb3f0d89641eef67c5a214a697999b18e..0b8bfe87dcc28eb5c0aecc4229309ef146b8b6d9 100644 --- a/src/THcHodoscope.cxx +++ b/src/THcHodoscope.cxx @@ -1106,6 +1106,9 @@ Int_t THcHodoscope::FineProcess( TClonesArray& tracks ) // ** See if there are any good time measurements in the plane. if ( fTOFCalc[ihhit].good_scin_time ){ fGoodPlaneTime[ip] = kTRUE; + fTOFCalc[ihhit].dedx = fdEdX[itrack][fNScinHit[itrack]-1]; + } else { + fTOFCalc[ihhit].dedx = 0.0; } // Can this be done after looping over hits and planes? @@ -1232,10 +1235,15 @@ Int_t THcHodoscope::FineProcess( TClonesArray& tracks ) } } Double_t fptime = FPTimeSum/nFPTimeSum; - - // This can't be right. Plus if there are no hits, then - // it is undefined. + Double_t dedx=0.0; + for(UInt_t ih=0;ih<fTOFCalc.size();ih++) { + if(fTOFCalc[ih].good_scin_time) { + dedx = fTOFCalc[ih].dedx; + break; + } + } + theTrack->SetDedx(dedx); theTrack->SetFPTime(fptime); theTrack->SetBeta(beta); theTrack->SetBetaChi2( betaChiSq ); diff --git a/src/THcHodoscope.h b/src/THcHodoscope.h index 03de4a3a4d01d1e085775d25d7b059f01e87b3b1..02e0a1e89f355d660fbfe91f726f299e2a0026c8 100644 --- a/src/THcHodoscope.h +++ b/src/THcHodoscope.h @@ -245,6 +245,7 @@ protected: Bool_t good_tdc_neg; Double_t scin_time; Double_t scin_sigma; + Double_t dedx; TOFCalc() : good_scin_time(kFALSE), good_tdc_pos(kFALSE), good_tdc_neg(kFALSE) {} };