diff --git a/src/THcScintillatorPlane.cxx b/src/THcScintillatorPlane.cxx index 63c039283209932cf0af9c35eae0fa96d2fbb258..15fa4bb8bb64386cdd1019ed7192a3da3665c8ba 100644 --- a/src/THcScintillatorPlane.cxx +++ b/src/THcScintillatorPlane.cxx @@ -974,7 +974,7 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) //CALCULATE TIME-WALK CORRECTIONS HERE!!!! //Define GoodTdcUnCorrTime - if(btdcraw_pos) { + if(btdcraw_pos&&badcraw_pos) { fGoodPosTdcTimeUnCorr.at(padnum-1) = tdc_pos*fScinTdcToTime; //tw_corr_pos = fHodoPos_c1[padnum-1]/pow(adcamp_pos/fTdc_Thrs,fHodoPos_c2[padnum-1]) - fHodoPos_c1[padnum-1]/pow(200./fTdc_Thrs, fHodoPos_c2[padnum-1]); @@ -982,7 +982,7 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) fGoodPosTdcTimeWalkCorr.at(padnum-1) = tdc_pos*fScinTdcToTime -tw_corr_pos; } - if(btdcraw_neg) { + if(btdcraw_neg&&badcraw_neg) { fGoodNegTdcTimeUnCorr.at(padnum-1) = tdc_neg*fScinTdcToTime; //tw_corr_neg = fHodoNeg_c1[padnum-1]/pow(adcamp_neg/fTdc_Thrs,fHodoNeg_c2[padnum-1]) - fHodoNeg_c1[padnum-1]/pow(200./fTdc_Thrs, fHodoNeg_c2[padnum-1]); @@ -994,7 +994,7 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) } // Do corrections if valid TDC on both ends of bar - if(btdcraw_pos && btdcraw_neg) { + if(btdcraw_pos && btdcraw_neg && badcraw_pos && badcraw_neg) { // Do the pulse height correction to the time. (Position dependent corrections later) Double_t timec_pos, timec_neg; if(fTofUsingInvAdc) { @@ -1013,32 +1013,11 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) Double_t fHitDistCorr = 0.5*TWCorrDiff*fHodoVelFit[index]; - /*Debug*/ - //cout << "*****************" << endl; - //cout << "fPlNum: " << fPlaneNum << endl; - //cout << "*****************" << endl; - //cout << "Paddle index: " << index << endl; - //cout << "pos_sigma: " << fHodoSigma[index] << endl; - //cout << "fZPos: " << fZpos << endl; - //cout << "fDzPos: " << fDzpos << endl; - //cout << "Zcorr = fZpos+(index%2)*fDzpos = " << fZpos+(index%2)*fDzpos << endl; - - //cout << Form("****fHodo_LCoeff[%d]", index) << fHodo_LCoeff[index] << endl; - //cout << Form("****fHodoCableFit[%d]", index) << fHodoCableFit[index] << endl; - //cout << Form("****fHodoVelFit[%d]", index) << fHodoVelFit[index] << endl; - //cout << Form("****c1_Pos/Neg[%d]", index) << fHodoPos_c1[index] << " / " << fHodoNeg_c1[index] << endl; - //cout << Form("****c2_Pos/Neg[%d]", index) << fHodoPos_c2[index] << " / " << fHodoNeg_c2[index] << endl; - //cout << "TW Corr val. +/-: " << tw_corr_pos << " / " << tw_corr_neg << endl; - //cout << "TW UnCorr +/-: " << fGoodPosTdcTimeUnCorr.at(padnum-1) << " / " << fGoodNegTdcTimeUnCorr.at(padnum-1) << endl; - //cout << "TW Corr +/-: " << fGoodPosTdcTimeWalkCorr.at(padnum-1) << " / " << fGoodNegTdcTimeWalkCorr.at(padnum-1) << endl; fGoodDiffDistTrack.at(index) = fHitDistCorr; - // Find hit position using ADCs - // If postime larger, then hit was nearer negative side. Double_t vellight=fHodoVelLight[index]; //read from hodo_cuts.param, where it is set fixed to 15.0 - //Double_t vellight=fHodoVelFit[index]; //use scin prop vel. values from hodo_calibVp_run#.param file Double_t dist_from_center=0.5*(timec_neg-timec_pos)*vellight; Double_t scint_center=0.5*(fPosLeft+fPosRight); @@ -1085,7 +1064,7 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) Double_t timec_pos,timec_neg; timec_pos=tdc_pos; timec_neg=tdc_neg; - if(btdcraw_pos) { + if(btdcraw_pos&& badcraw_pos) { if(fTofUsingInvAdc) { timec_pos = tdc_pos*fScinTdcToTime - fHodoPosInvAdcOffset[index] @@ -1094,7 +1073,7 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) timec_pos = tdc_pos*fScinTdcToTime -tw_corr_pos + fHodo_LCoeff[index]; } } - if(btdcraw_neg) { + if(btdcraw_neg && badcraw_neg) { if(fTofUsingInvAdc) { timec_neg = tdc_neg*fScinTdcToTime - fHodoNegInvAdcOffset[index] @@ -1103,16 +1082,20 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) timec_neg = tdc_neg*fScinTdcToTime -tw_corr_neg- 2*fHodoCableFit[index] + fHodo_LCoeff[index]; } } + Double_t adc_neg=0.,adc_pos=0.; + if (badcraw_neg) adc_neg=adcamp_neg; + if (badcraw_pos) adc_pos=adcamp_pos; ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetPaddleCenter(fPosCenter[index]); ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetCorrectedTimes(timec_pos,timec_neg, timec_pos,timec_neg,0.0); - ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetNegADCpeak(adcamp_neg); // needed for new TWCOrr - ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetPosADCpeak(adcamp_pos); // needed for new TWCOrr + ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetNegADCpeak(adc_neg); // needed for new TWCOrr + ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetPosADCpeak(adc_pos); // needed for new TWCOrr fGoodPosTdcTimeCorr.at(padnum-1) = timec_pos; fGoodNegTdcTimeCorr.at(padnum-1) = timec_neg; fGoodPosTdcTimeTOFCorr.at(padnum-1) = timec_pos; fGoodNegTdcTimeTOFCorr.at(padnum-1) = timec_neg; } + // if ( ((THcHodoHit*) fHodoHits->At(fNScinHits))->GetPosTOFCorrectedTime() != ((THcHodoHit*) fHodoHits->At(fNScinHits))->GetPosTOFCorrectedTime()) cout << " ihit = " << ihit << " scinhit = " << fNScinHits << " plane = " << fPlaneNum << " padnum = " << padnum << " " << tdc_pos<< " "<< tdc_neg<< " " << ((THcHodoHit*) fHodoHits->At(fNScinHits))->GetPosTOFCorrectedTime() << endl; fNScinHits++; // One or more good time counter // }