diff --git a/src/THcHodoHit.h b/src/THcHodoHit.h index 03c538c8603dc38f84782db963bd6ded36788346..be94afc2617375b995eb47125ed071b3bf1fb3b9 100644 --- a/src/THcHodoHit.h +++ b/src/THcHodoHit.h @@ -28,8 +28,14 @@ public: Double_t GetNegADC() const { return fNegADC_Ped; } Int_t GetPosTDC() const { return fPosTDC; } Int_t GetNegTDC() const { return fNegTDC; } + Double_t GetPosCorrectedTime() const { return fPosCorrectedTime;} + Double_t GetNegCorrectedTime() const { return fNegCorrectedTime;} Int_t GetPaddleNumber() const { return fPaddleNumber; } + void SetCorrectedTimes(Double_t pos, Double_t neg) { + fPosCorrectedTime = pos; fNegCorrectedTime = neg; + } + protected: static const Double_t kBig; //! @@ -38,6 +44,8 @@ protected: Int_t fNegTDC; Double_t fPosADC_Ped; // Pedestal subtracted ADC Double_t fNegADC_Ped; // Pedestal subtracted ADC + Double_t fPosCorrectedTime; // Pulse height corrected time + Double_t fNegCorrectedTime; // Pulse height corrected time THcScintillatorPlane* fPlane; // Pointer to parent scintillator plane diff --git a/src/THcHodoscope.cxx b/src/THcHodoscope.cxx index bb0e341cd940bb63d83e9eee129d233dccfd3028..b3b2f6144adf55150f529990c071c77f7df65bf9 100644 --- a/src/THcHodoscope.cxx +++ b/src/THcHodoscope.cxx @@ -690,7 +690,7 @@ Int_t THcHodoscope::Decode( const THaEvData& evdata ) // as per the Engine h_strip_scin.f nexthit = fPlanes[ip]->ProcessHits(fRawHitList,nexthit); if (fPlanes[ip]->GetNScinHits()>0) { - fPlanes[ip]->PulseHeightCorrection(); + fPlanes[ip]->EstimateFocalPlaneTimes(); // GN: allow for more than one fptime per plane!! for (Int_t i=0;i<fPlanes[ip]->GetNScinGoodHits();i++) { if (TMath::Abs(fPlanes[ip]->GetFpTime(i)-fStartTimeCenter)<=fStartTimeSlop) { @@ -853,16 +853,12 @@ Int_t THcHodoscope::FineProcess( TClonesArray& tracks ) if ( TMath::Abs( scinCenter - scinTrnsCoord ) < ( fPlanes[ip]->GetSize() * 0.5 + fPlanes[ip]->GetHodoSlop() ) ){ // Line 293 - Double_t adcPhp = ((THcHodoHit*)hodoHits->At(iphit))->GetPosADC(); Double_t pathp = fPlanes[ip]->GetPosLeft() - scinLongCoord; - Double_t timep = ((THcHodoHit*)hodoHits->At(iphit))->GetPosTDC() * fScinTdcToTime; - timep = timep - fHodoPosPhcCoeff[fPIndex] * - TMath::Sqrt( TMath::Max( 0., ( ( adcPhp / fHodoPosMinPh[fPIndex] ) - 1 ) ) ); + Double_t timep = ((THcHodoHit*)hodoHits->At(iphit))->GetPosCorrectedTime(); timep = timep - ( pathp / fHodoVelLight[fPIndex] ) - ( fPlanes[ip]->GetZpos() + ( paddle % 2 ) * fPlanes[ip]->GetDzpos() ) / ( 29.979 * betaP ) * TMath::Sqrt( 1. + theTrack->GetTheta() * theTrack->GetTheta() + theTrack->GetPhi() * theTrack->GetPhi() ); - timep = timep - fHodoPosTimeOffset[fPIndex]; fTOFPInfo[iphit].time_pos = timep; for ( Int_t k = 0; k < 200; k++ ){ // Line 211 @@ -871,16 +867,12 @@ Int_t THcHodoscope::FineProcess( TClonesArray& tracks ) timehist[k] ++; } - Double_t adcPhn = ((THcHodoHit*)hodoHits->At(iphit))->GetNegADC(); Double_t pathn = scinLongCoord - fPlanes[ip]->GetPosRight(); - Double_t timen = ((THcHodoHit*)hodoHits->At(iphit))->GetNegTDC() * fScinTdcToTime; - timen =timen - fHodoNegPhcCoeff[fPIndex] * - TMath::Sqrt( TMath::Max( 0., ( ( adcPhn / fHodoNegMinPh[fPIndex] ) - 1 ) ) ); + Double_t timen = ((THcHodoHit*)hodoHits->At(iphit))->GetNegCorrectedTime(); timen = timen - ( pathn / fHodoVelLight[fPIndex] ) - ( fPlanes[ip]->GetZpos() + ( paddle % 2 ) * fPlanes[ip]->GetDzpos() ) / ( 29.979 * betaP ) * TMath::Sqrt( 1. + theTrack->GetTheta() * theTrack->GetTheta() + theTrack->GetPhi() * theTrack->GetPhi() ); - timen = timen - fHodoNegTimeOffset[fPIndex]; fTOFPInfo[iphit].time_neg = timen; for ( Int_t k = 0; k < 200; k++ ){ // Line 230 @@ -966,16 +958,13 @@ Int_t THcHodoscope::FineProcess( TClonesArray& tracks ) // ** Calculate time for each tube with a good tdc. 'pos' side first. fTOFCalc[ihhit].good_tdc_pos = kTRUE; - Double_t adcPh = ((THcHodoHit*)hodoHits->At(iphit))->GetPosADC(); Double_t path = fPlanes[ip]->GetPosLeft() - scinLongCoord; // * Convert TDC value to time, do pulse height correction, correction for // * propogation of light thru scintillator, and offset. - Double_t time = ((THcHodoHit*)hodoHits->At(iphit))->GetPosTDC() * fScinTdcToTime; - time = time - ( fHodoPosPhcCoeff[fPIndex] * TMath::Sqrt( TMath::Max( 0. , - ( ( adcPh / fHodoPosMinPh[fPIndex] ) - 1 ) ) ) ); + Double_t time = ((THcHodoHit*)hodoHits->At(iphit))->GetPosCorrectedTime(); time = time - ( path / fHodoVelLight[fPIndex] ); - fTOFPInfo[iphit].scin_pos_time = time - fHodoPosTimeOffset[fPIndex]; + fTOFPInfo[iphit].scin_pos_time = time; } // check for good pos TDC condition @@ -984,17 +973,13 @@ Int_t THcHodoscope::FineProcess( TClonesArray& tracks ) // ** Calculate time for each tube with a good tdc. 'pos' side first. fTOFCalc[ihhit].good_tdc_neg = kTRUE; // fNtof ++; - Double_t adcPh = ((THcHodoHit*)hodoHits->At(iphit))->GetNegADC(); - // Double_t path = fPlanes[ip]->GetPosRight() - scinLongCoord; Double_t path = scinLongCoord - fPlanes[ip]->GetPosRight(); // * Convert TDC value to time, do pulse height correction, correction for // * propogation of light thru scintillator, and offset. - Double_t time = ((THcHodoHit*)hodoHits->At(iphit))->GetNegTDC() * fScinTdcToTime; - time = time - ( fHodoNegPhcCoeff[fPIndex] * - TMath::Sqrt( TMath::Max( 0. , ( ( adcPh / fHodoNegMinPh[fPIndex] ) - 1 ) ) ) ); + Double_t time = ((THcHodoHit*)hodoHits->At(iphit))->GetNegCorrectedTime(); time = time - ( path / fHodoVelLight[fPIndex] ); - fTOFPInfo[iphit].scin_neg_time = time - fHodoNegTimeOffset[fPIndex]; + fTOFPInfo[iphit].scin_neg_time = time; } // check for good neg TDC condition diff --git a/src/THcScintillatorPlane.cxx b/src/THcScintillatorPlane.cxx index 9556cbed4e1b02d653d08085ea2fc2cbb2ae5353..891f1f374253ef3ae845e4683b801b61b9dfc731 100644 --- a/src/THcScintillatorPlane.cxx +++ b/src/THcScintillatorPlane.cxx @@ -328,7 +328,17 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) ((hit->fTDC_neg >= fScinTdcMin) && (hit->fTDC_neg <= fScinTdcMax))) { // If TDC values are all good, transfer the raw hit to the HodoHit list - new( (*fHodoHits)[fNScinHits++]) THcHodoHit(hit, fPosPed[index], fNegPed[index], this); + new( (*fHodoHits)[fNScinHits]) THcHodoHit(hit, fPosPed[index], fNegPed[index], this); + + // Do the pulse height correction to the time. (Position dependent corrections later) + Double_t timec_pos = hit->fTDC_pos*fScinTdcToTime - fHodoPosPhcCoeff[index]* + TMath::Sqrt(TMath::Max(0.0,(hit->fADC_pos/fHodoPosMinPh[index]-1))) + - fHodoPosTimeOffset[index]; + Double_t timec_neg = hit->fTDC_neg*fScinTdcToTime - fHodoNegPhcCoeff[index]* + TMath::Sqrt(TMath::Max(0.0,(hit->fADC_neg/fHodoNegMinPh[index]-1))) + - fHodoNegTimeOffset[index]; + ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetCorrectedTimes(timec_pos,timec_neg); + fNScinHits++; } else { } @@ -341,7 +351,7 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) } //________________________________________________________________________________ -Int_t THcScintillatorPlane::PulseHeightCorrection() +Int_t THcScintillatorPlane::EstimateFocalPlaneTimes() { // Perform pulse height correction of the TDC values as in the original h_trans_scin // see original comments below @@ -356,7 +366,7 @@ Int_t THcScintillatorPlane::PulseHeightCorrection() ! reference particle, need to make sure this is big enough ! to accomodate difference in TOF for other particles ! Default value in case user hasn't defined something reasonable */ - Double_t pos_ph[53],neg_ph[53],postime[53],negtime[53],scin_corrected_time[53]; // the 53 should go in a param file (was hmax_scin_hits originally) + Double_t scin_corrected_time[53]; // the 53 should go in a param file (was hmax_scin_hits originally) // Bool_t keep_pos[53],keep_neg[53]; // are these all really needed? Bool_t two_good_times[53]; Double_t dist_from_center,scint_center,hit_position,time_pos[100],time_neg[100]; @@ -372,41 +382,26 @@ Int_t THcScintillatorPlane::PulseHeightCorrection() for (Int_t i=0;i<200;i++) { timehist[i]=0; } - for (Int_t i=0;i<fMaxHits;i++) { - // keep_pos[i]=kFALSE; - // keep_neg[i]=kFALSE; - two_good_times[i]=kFALSE; - } fpTime=-1e5; for (Int_t i=0;i<fNScinHits;i++) { - // Perhaps these calculations should be done in the THcHodoHit class so - // that they don't get repeated Int_t index=((THcHodoHit*)fHodoHits->At(i))->GetPaddleNumber()-1; - pos_ph[i]=((THcHodoHit*) fHodoHits->At(i))->GetPosADC(); - postime[i]=((THcHodoHit*) fHodoHits->At(i))->GetPosTDC()*fScinTdcToTime; - postime[i]=postime[i]-fHodoPosPhcCoeff[index]* - TMath::Sqrt(TMath::Max(0.,(pos_ph[i]/fHodoPosMinPh[index]-1))); - postime[i]=postime[i]-fHodoPosTimeOffset[index]; - - neg_ph[i]=((THcHodoHit*) fHodoHits->At(i))->GetNegADC(); - negtime[i]=((THcHodoHit*) fHodoHits->At(i))->GetNegTDC()*fScinTdcToTime; - negtime[i]=negtime[i]-fHodoNegPhcCoeff[index]* - TMath::Sqrt(TMath::Max(0.,(neg_ph[i]/fHodoNegMinPh[index]-1))); - negtime[i]=negtime[i]-fHodoNegTimeOffset[index]; + Double_t postime=((THcHodoHit*) fHodoHits->At(i))->GetPosCorrectedTime(); + Double_t negtime=((THcHodoHit*) fHodoHits->At(i))->GetNegCorrectedTime(); // Find hit position. If postime larger, then hit was nearer negative side. - dist_from_center=0.5*(negtime[i]-postime[i])*fHodoVelLight[index]; + dist_from_center=0.5*(negtime-postime)*fHodoVelLight[index]; scint_center=0.5*(fPosLeft+fPosRight); hit_position=scint_center+dist_from_center; hit_position=TMath::Min(hit_position,fPosLeft); hit_position=TMath::Max(hit_position,fPosRight); - postime[i]=postime[i]-(fPosLeft-hit_position)/fHodoVelLight[index]; - negtime[i]=negtime[i]-(hit_position-fPosRight)/fHodoVelLight[index]; + postime=postime-(fPosLeft-hit_position)/fHodoVelLight[index]; + negtime=negtime-(hit_position-fPosRight)/fHodoVelLight[index]; + scin_corrected_time[i]=0.5*(postime+negtime); - time_pos[i]=postime[i]-(fZpos+(index%2)*fDzpos)/(29.979*fBetaNominal); - time_neg[i]=negtime[i]-(fZpos+(index%2)*fDzpos)/(29.979*fBetaNominal); + time_pos[i]=postime-(fZpos+(index%2)*fDzpos)/(29.979*fBetaNominal); + time_neg[i]=negtime-(fZpos+(index%2)*fDzpos)/(29.979*fBetaNominal); // nfound++; for (Int_t k=0;k<200;k++) { Double_t tmin=0.5*(k+1); @@ -434,42 +429,14 @@ Int_t THcScintillatorPlane::PulseHeightCorrection() for (Int_t i=0;i<fNScinHits;i++) { Double_t tmin = 0.5*jmax; if ((time_pos[i]>tmin) && (time_pos[i]<tmin+fTofTolerance) && - (time_neg[i]>tmin) && (time_neg[i]<tmin+fTofTolerance)) + (time_neg[i]>tmin) && (time_neg[i]<tmin+fTofTolerance)) { two_good_times[i]=kTRUE; - } // end of loop that finds tube setting time - for (Int_t i=0;i<fNScinHits;i++) { - if (two_good_times[i]) { // both tubes fired - // correct time for everything except veloc. correction in order - // to find hit location from difference in TDC. - // We are repeating some stuff here. Should save it all in the hit - // class so it doesn't have to be recalculated. (Avoid mistakes too) - Int_t index=((THcHodoHit*)fHodoHits->At(i))->GetPaddleNumber()-1; - pos_ph[i]=((THcHodoHit*) fHodoHits->At(i))->GetPosADC(); - postime[i]=((THcHodoHit*) fHodoHits->At(i))->GetPosTDC()*fScinTdcToTime; - postime[i]=postime[i]-fHodoPosPhcCoeff[index]* - TMath::Sqrt(TMath::Max(0.,(pos_ph[i]/fHodoPosMinPh[index]-1))); - postime[i]=postime[i]-fHodoPosTimeOffset[index]; - - neg_ph[i]=((THcHodoHit*) fHodoHits->At(i))->GetNegADC(); - negtime[i]=((THcHodoHit*) fHodoHits->At(i))->GetNegTDC()*fScinTdcToTime; - negtime[i]=negtime[i]-fHodoNegPhcCoeff[index]* - TMath::Sqrt(TMath::Max(0.,(neg_ph[i]/fHodoNegMinPh[index]-1))); - negtime[i]=negtime[i]-fHodoNegTimeOffset[index]; - - // find hit position. If postime larger, then hit was nearer negative side - dist_from_center=0.5*(negtime[i]-postime[i])*fHodoVelLight[index]; - scint_center=0.5*(fPosLeft+fPosRight); - hit_position=scint_center+dist_from_center; - hit_position=TMath::Min(hit_position,fPosLeft); - hit_position=TMath::Max(hit_position,fPosRight); - postime[i]=postime[i]-(fPosLeft-hit_position)/fHodoVelLight[index]; - negtime[i]=negtime[i]-(hit_position-fPosRight)/fHodoVelLight[index]; - scin_corrected_time[i]=0.5*(postime[i]+negtime[i]); - } else { // only one tube fired + } else { + two_good_times[i]=kFALSE; scin_corrected_time[i]=0.0; // not a very good "flag" but there is the logical two_good_hits... - // no fpTimes for U! } - } + } // end of loop that finds tube setting time + //start time calculation. assume xp=yp=0 radians. project all //time values to focal plane. use average for start time. @@ -488,7 +455,7 @@ Int_t THcScintillatorPlane::PulseHeightCorrection() } CalcFpTime(); return 0; -} + } //_____________________________________________________________________________ Int_t THcScintillatorPlane::AccumulatePedestals(TClonesArray* rawhits, Int_t nexthit) { diff --git a/src/THcScintillatorPlane.h b/src/THcScintillatorPlane.h index 70db898e98f961e21acf368c94cee6b5e70e17bd..0e45a5034e31700b5fb12f57dcfdef87c328c716 100644 --- a/src/THcScintillatorPlane.h +++ b/src/THcScintillatorPlane.h @@ -35,7 +35,7 @@ class THcScintillatorPlane : public THaSubDetector { virtual Bool_t IsPid() { return kFALSE; } virtual Int_t ProcessHits(TClonesArray* rawhits, Int_t nexthit); - virtual Int_t PulseHeightCorrection(); + virtual Int_t EstimateFocalPlaneTimes(); virtual Int_t AccumulatePedestals(TClonesArray* rawhits, Int_t nexthit); virtual void CalculatePedestals( ); @@ -102,7 +102,7 @@ class THcScintillatorPlane : public THaSubDetector { Double_t *fHodoVelLight; Double_t *fHodoSigma; - Double_t fTolerance; /* need this for PulseHeightCorrection */ + Double_t fTolerance; /* need this for Focal Plane Time estimation */ /* Pedestal Quantities */ Int_t fNPedestalEvents; /* Number of pedestal events */ Int_t fMinPeds; /* Only analyze/update if num events > */