diff --git a/src/THcHodoHit.h b/src/THcHodoHit.h index 1f836ab4e7adbb6121cfd877bd56b6d3d538c0cb..a450190861f763f885689cac9106f2d900cff971 100644 --- a/src/THcHodoHit.h +++ b/src/THcHodoHit.h @@ -34,6 +34,8 @@ public: Double_t GetNegADCpeak() const { return fNegADC_Peak; } Double_t GetPosADCtime() const { return fPosADC_Time; } Double_t GetNegADCtime() const { return fNegADC_Time; } + Double_t GetPosADCCorrtime() const { return fPosADC_CorrTime; } + Double_t GetNegADCCorrtime() const { return fNegADC_CorrTime; } Double_t GetCalcPosition() const { return fCalcPosition; } Int_t GetPosTDC() const { return fPosTDC; } Int_t GetNegTDC() const { return fNegTDC; } @@ -76,6 +78,12 @@ public: } void SetNegADCtime( Double_t ptime) { fNegADC_Time =ptime; + } + void SetPosADCCorrtime( Double_t ptime) { + fPosADC_CorrTime =ptime; + } + void SetNegADCCorrtime( Double_t ptime) { + fNegADC_CorrTime =ptime; } void SetCalcPosition( Double_t calcpos) { fCalcPosition =calcpos; @@ -91,6 +99,8 @@ protected: Double_t fNegADC_Peak; // ADC peak amplitude Double_t fPosADC_Time; // ADC time Double_t fNegADC_Time; // ADC time + Double_t fPosADC_CorrTime; // ADC time + Double_t fNegADC_CorrTime; // ADC time Double_t fCalcPosition; // Position along paddle calculated by time diff Int_t fPaddleNumber; diff --git a/src/THcHodoscope.cxx b/src/THcHodoscope.cxx index 2fd9f998dbf41fee62d99c3ad55ea990463cb07b..e8e25795dbe45e075ba2836ce716f314db20ab3e 100644 --- a/src/THcHodoscope.cxx +++ b/src/THcHodoscope.cxx @@ -676,6 +676,7 @@ void THcHodoscope::Clear( Option_t* opt ) fBetaNoTrk = 0.0; fBetaNoTrkChiSq = 0.0; fStartTime = -1000.; + fADCStartTime = -1000.; fOffsetTime = kBig; fFPTimeAll= -1000.; fGoodStartTime = kFALSE; @@ -755,7 +756,7 @@ Int_t THcHodoscope::Decode( const THaEvData& evdata ) // Let each plane get its hits Int_t nexthit = 0; - THcHallCSpectrometer *app = dynamic_cast<THcHallCSpectrometer*>(GetApparatus()); + //THcHallCSpectrometer *app = dynamic_cast<THcHallCSpectrometer*>(GetApparatus()); // cout << " event number = " << fEventNum << " Evtyp = " << fEventType<< " spec = " << app->GetName() << endl; fNfptimes=0; Int_t thits = 0; @@ -771,33 +772,6 @@ Int_t THcHodoscope::Decode( const THaEvData& evdata ) thits+=fPlanes[ip]->GetNScinHits(); } // - if (thits>0 ) { - Double_t ave_AdcTdcDiffTime=0; - Double_t num_AdcTdcDiffTime=0; - for(Int_t ip=0;ip<fNPlanes;ip++) { - Int_t nphits=fPlanes[ip]->GetNScinHits(); - TClonesArray* hodoHits = fPlanes[ip]->GetHits(); - for(Int_t i=0;i<nphits;i++) { - THcHodoHit *hit = (THcHodoHit*)hodoHits->At(i); - if(hit->GetHasCorrectedTimes()) { - Double_t posADCtime=hit->GetPosADCtime(); - Double_t negADCtime=hit->GetNegADCtime(); - Double_t posTDCtime=hit->GetPosTDC()*fScinTdcToTime; - Double_t negTDCtime=hit->GetNegTDC()*fScinTdcToTime; - if (posADCtime>0 && posTDCtime>0) { - ave_AdcTdcDiffTime+=posTDCtime-posADCtime; - num_AdcTdcDiffTime++; - } - if (negADCtime>0 && negTDCtime>0) { - ave_AdcTdcDiffTime+=negTDCtime-negADCtime; - num_AdcTdcDiffTime++; - } - } - } - } - if (num_AdcTdcDiffTime>0) ave_AdcTdcDiffTime = ave_AdcTdcDiffTime/num_AdcTdcDiffTime; - if (num_AdcTdcDiffTime>0) fOffsetTime = ave_AdcTdcDiffTime; - } // fStartTime=-1000; if (thits>0 ) EstimateFocalPlaneTime(); @@ -955,6 +929,7 @@ void THcHodoscope::EstimateFocalPlaneTime() Int_t nscinhits=0; // Total # hits with at least one good tdc hTime->Reset(); // + // for(Int_t ip=0;ip<fNPlanes;ip++) { Int_t nphits=fPlanes[ip]->GetNScinHits(); nscinhits += nphits; @@ -966,20 +941,51 @@ void THcHodoscope::EstimateFocalPlaneTime() Double_t negtime=hit->GetNegTOFCorrectedTime(); hTime->Fill(postime); hTime->Fill(negtime); + } } } - } // Double_t TimePeak=DetermineTimePeak(1); + hTime->Reset(); + // + Double_t AdcTdcDiffTimeSum=0; + Double_t NAdcTdcDiffTimeSum=0; + // + for(Int_t ip=0;ip<fNPlanes;ip++) { + Int_t nphits=fPlanes[ip]->GetNScinHits(); + nscinhits += nphits; + TClonesArray* hodoHits = fPlanes[ip]->GetHits(); + for(Int_t i=0;i<nphits;i++) { + THcHodoHit *hit = (THcHodoHit*)hodoHits->At(i); + if(hit->GetHasCorrectedTimes()) { + NAdcTdcDiffTimeSum++; + AdcTdcDiffTimeSum+=(hit->GetPosADCtime()-hit->GetPosTDC()*fScinTdcToTime); + NAdcTdcDiffTimeSum++; + AdcTdcDiffTimeSum+=(hit->GetNegADCtime()-hit->GetNegTDC()*fScinTdcToTime); + Double_t postime=hit->GetPosADCCorrtime(); + Double_t negtime=hit->GetNegADCCorrtime(); + hTime->Fill(postime); + hTime->Fill(negtime); + } + } + } + if (NAdcTdcDiffTimeSum>0) AdcTdcDiffTimeSum=AdcTdcDiffTimeSum/NAdcTdcDiffTimeSum; + // + Double_t AdcTimePeak=DetermineTimePeak(3); // ihit = 0; Double_t fpTimeSum = 0.0; + Double_t adcfpTimeSum = 0.0; + Double_t adcNfptimes=0; fNfptimes=0; Int_t Ngood_hits_plane=0; + Int_t Ngood_adchits_plane=0; Double_t Plane_fptime_sum=0.0; + Double_t Plane_adcfptime_sum=0.0; Bool_t goodplanetime[fNPlanes]; Bool_t twogoodtimes[nscinhits]; Int_t NumPlanesGoodHit=0; + Int_t NumPlanesGoodAdcHit=0; if (TimePeak>0) { for(Int_t ip=0;ip<fNumPlanesBetaCalc;ip++) { goodplanetime[ip] = kFALSE; @@ -993,6 +999,8 @@ void THcHodoscope::EstimateFocalPlaneTime() if(hit->GetHasCorrectedTimes()) { Double_t postime=hit->GetPosTOFCorrectedTime(); Double_t negtime=hit->GetNegTOFCorrectedTime(); + Double_t adcpostime=hit->GetPosADCtime(); + Double_t adcnegtime=hit->GetNegADCtime(); if ((postime>(TimePeak-fTofTolerance)) && (postime<(TimePeak+fTofTolerance)) && (negtime>(TimePeak-fTofTolerance)) && (negtime<(TimePeak+fTofTolerance)) ) { hit->SetTwoGoodTimes(kTRUE); @@ -1016,10 +1024,31 @@ void THcHodoscope::EstimateFocalPlaneTime() } else { hit->SetTwoGoodTimes(kFALSE); } + // + if ((adcpostime>(AdcTimePeak-fTofTolerance)) && (adcpostime<(AdcTimePeak+fTofTolerance)) && + (adcnegtime>(AdcTimePeak-fTofTolerance)) && (adcnegtime<(AdcTimePeak+fTofTolerance)) ) { + Int_t index=hit->GetPaddleNumber()-1; // + Double_t fptime; + if(fCosmicFlag==1) { + fptime = hit->GetScinCorrectedTime() + + (fPlanes[ip]->GetZpos()+(index%2)*fPlanes[ip]->GetDzpos()) + / (29.979 * fBetaNominal); + }else{ + fptime = hit->GetScinCorrectedTime() + - (fPlanes[ip]->GetZpos()+(index%2)*fPlanes[ip]->GetDzpos()) + / (29.979 * fBetaNominal); + } + Ngood_adchits_plane++; + Plane_adcfptime_sum+=fptime; + adcfpTimeSum += fptime; + adcNfptimes++; + } + // } ihit++; } if (Ngood_hits_plane>0) NumPlanesGoodHit++; + if (Ngood_adchits_plane>0) NumPlanesGoodAdcHit++; if (Ngood_hits_plane>0) fPlanes[ip]->SetFpTime(Plane_fptime_sum/float(Ngood_hits_plane)); fPlanes[ip]->SetNGoodHits(Ngood_hits_plane); } @@ -1029,10 +1058,17 @@ void THcHodoscope::EstimateFocalPlaneTime() fStartTime = fpTimeSum/fNfptimes; fGoodStartTime=kTRUE; fFPTimeAll = fStartTime ; + fOffsetTime=0; + if(NumPlanesGoodAdcHit>=3) { + fADCStartTime = adcfpTimeSum/adcNfptimes-fStartTime; + } + fOffsetTime =AdcTdcDiffTimeSum; } else { fStartTime = fStartTimeCenter; + fADCStartTime = fStartTimeCenter; fGoodStartTime=kFALSE; fFPTimeAll = fStartTime ; + fOffsetTime=AdcTdcDiffTimeSum; } // // diff --git a/src/THcHodoscope.h b/src/THcHodoscope.h index 3ca760ac2714d08e105bf409826fa5ce3c18c989..789e1930dbf5c02bb2ab6dd8afa080c0e6252604 100644 --- a/src/THcHodoscope.h +++ b/src/THcHodoscope.h @@ -158,6 +158,7 @@ protected: Bool_t fSHMS; Bool_t fGoodStartTime; Double_t fStartTime; + Double_t fADCStartTime; Double_t fOffsetTime; Double_t fFPTimeAll; Int_t fNfptimes; diff --git a/src/THcScintillatorPlane.cxx b/src/THcScintillatorPlane.cxx index 10ab6ec5f5982fd645b7ca4520473766078c0d79..fb80467b1b26145bf9c92807261d488664f398c4 100644 --- a/src/THcScintillatorPlane.cxx +++ b/src/THcScintillatorPlane.cxx @@ -1119,9 +1119,12 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) } + // Do corrections if valid TDC on both ends of bar if( (btdcraw_pos && btdcraw_neg) && (badcraw_pos && badcraw_neg) ) { // Do the pulse height correction to the time. (Position dependent corrections later) + Double_t adc_timec_pos= adctime_pos; + Double_t adc_timec_neg= adctime_neg; Double_t timec_pos, timec_neg; if(fTofUsingInvAdc) { timec_pos = tdc_pos*fScinTdcToTime @@ -1133,6 +1136,8 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) } else { // FADC style timec_pos = tdc_pos*fScinTdcToTime -tw_corr_pos + fHodo_LCoeff[index]; timec_neg = tdc_neg*fScinTdcToTime -tw_corr_neg- 2*fHodoCableFit[index] + fHodo_LCoeff[index]; + adc_timec_pos = adc_timec_pos -tw_corr_pos + fHodo_LCoeff[index]; + adc_timec_neg = adc_timec_neg -tw_corr_neg- 2*fHodoCableFit[index] + fHodo_LCoeff[index]; } Double_t TWCorrDiff = fGoodNegTdcTimeWalkCorr.at(padnum-1) - 2*fHodoCableFit[index] - fGoodPosTdcTimeWalkCorr.at(padnum-1); @@ -1151,6 +1156,8 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) hit_position=TMath::Min(hit_position,fPosLeft); hit_position=TMath::Max(hit_position,fPosRight); Double_t scin_corrected_time, postime, negtime; + Double_t adc_postime=adc_timec_pos; + Double_t adc_negtime=adc_timec_neg; if(fTofUsingInvAdc) { timec_pos -= (fPosLeft-hit_position)/ fHodoPosInvAdcLinear[index]; @@ -1165,15 +1172,20 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) negtime = timec_neg - (fZpos+(index%2)*fDzpos)/(29.979*fBetaNominal); } } else { - scin_corrected_time = 0.5*(timec_neg+timec_pos); // add constants for each paddle, 25ns, 25 + zpos, . . . //remove propagation time + scin_corrected_time = 0.5*(timec_neg+timec_pos); timec_pos= scin_corrected_time; - timec_neg= scin_corrected_time; + timec_neg= scin_corrected_time; + Double_t adc_time_corrected = 0.5*(adc_timec_pos+adc_timec_neg); if (fCosmicFlag) { postime = timec_pos + (fZpos+(index%2)*fDzpos)/(29.979*fBetaNominal); negtime = timec_neg + (fZpos+(index%2)*fDzpos)/(29.979*fBetaNominal); + adc_postime = adc_time_corrected + (fZpos+(index%2)*fDzpos)/(29.979*fBetaNominal); + adc_negtime = adc_time_corrected + (fZpos+(index%2)*fDzpos)/(29.979*fBetaNominal); } else { postime = timec_pos - (fZpos+(index%2)*fDzpos)/(29.979*fBetaNominal); negtime = timec_neg - (fZpos+(index%2)*fDzpos)/(29.979*fBetaNominal); + adc_postime = adc_time_corrected - (fZpos+(index%2)*fDzpos)/(29.979*fBetaNominal); + adc_negtime = adc_time_corrected - (fZpos+(index%2)*fDzpos)/(29.979*fBetaNominal); } } ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetPaddleCenter(fPosCenter[index]); @@ -1182,8 +1194,8 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) scin_corrected_time); ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetPosADCpeak(adcamp_pos); ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetNegADCpeak(adcamp_neg); - ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetPosADCtime(adctime_pos); - ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetNegADCtime(adctime_neg); + ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetPosADCCorrtime(adc_postime); + ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetNegADCCorrtime(adc_negtime); ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetCalcPosition(fHitDistCorr); // fGoodPosTdcTimeCorr.at(padnum-1) = timec_pos;