diff --git a/examples/PARAM/general.param b/examples/PARAM/general.param index f6d2f37fee455def56a4335216aebf7bce92d22d..5383e6c1028e2cd9b610b1f215cabc03f070d692 100644 --- a/examples/PARAM/general.param +++ b/examples/PARAM/general.param @@ -23,7 +23,7 @@ raddeg=3.14159265/180 #include "PARAM/sdc.pos" #include "PARAM/shodo.pos" #include "PARAM/scal.pos" -#include "PARAM/hhodo.param_v1" +#include "PARAM/hhodo.param" #include "PARAM/haero.param" #include "PARAM/hdc.param" #include "PARAM/hdriftmap.param" diff --git a/examples/PARAM/hhodo.param b/examples/PARAM/hhodo.param index 18f69a68eeb01c4f6131aaa4a19f3a7e3e2ca3fd..3305be2f5536ec3158177e87775c8af4f10a9f79 100644 --- a/examples/PARAM/hhodo.param +++ b/examples/PARAM/hhodo.param @@ -11,7 +11,7 @@ ; new variable for picking good hits for tof fitting ; this should not be set tight until you are ready to fit ; tof and you figured out good values - htof_tolerance = 3.0 + htof_tolerance = 30.0 ; ; hms_tof_params ; hnum_scin_counters, hhodo_zpos, hhodo_center_coord, hhodo_width @@ -284,3 +284,5 @@ hhodo_neg_invadc_adc= 0.00, 0.00, 33.27, 0.00 78.19, 0.00, 51.72, 0.00 75.03, 0.00, 49.34, 0.00 0.00, 0.00, 53.40, 0.00 + +htofusinginvadc=0 diff --git a/examples/PARAM/hhodo.param_v1 b/examples/PARAM/hhodo.param_v1 index 80d5863c326cdae4b861d16f0ede3cf4e54fb923..b4e2672c96551dcd608453c98e9759b6a8e3a1f8 100644 --- a/examples/PARAM/hhodo.param_v1 +++ b/examples/PARAM/hhodo.param_v1 @@ -181,7 +181,7 @@ hhodo_neg_ped_limit = 1000,1000,1000,1000,1000,1000,1000,1000 ; use htofusinginvadc=1 if want invadc_offset ; invadc_linear, and invadc_adc to be used -htofusinginvadc=1 +htofusinginvadc=0 hhodo_pos_invadc_offset = 0.00, 0.00, -7.49, 0.00 0.00, -3.93, -1.33, 6.35 diff --git a/examples/PARAM/shodo.param b/examples/PARAM/shodo.param index 681cfd9d0fb334e090eb1eff3236bb4a8ad05e89..56e7cd0a7b4ae73226fc528865660de085efe8d8 100644 --- a/examples/PARAM/shodo.param +++ b/examples/PARAM/shodo.param @@ -190,3 +190,4 @@ shodo_neg_time_offset = -4.3414, -4.2570, 5.1140, -22.1772 1000,1000,1000,1000,1000,1000,1000,1000 1000,1000,1000,1000,1000,1000,1000,1000 +stofusinginvadc=0 diff --git a/src/THcHodoscope.cxx b/src/THcHodoscope.cxx index bc5a6d8b8dccbaffde7f4732cf0de85734734615..185e09710c2de8ad50cebe9bdf28207db8e21bac 100644 --- a/src/THcHodoscope.cxx +++ b/src/THcHodoscope.cxx @@ -1001,11 +1001,18 @@ Int_t THcHodoscope::FineProcess( TClonesArray& tracks ) Double_t adc_pos = hit->GetPosADC(); Double_t pathp = fPlanes[ip]->GetPosLeft() - scinLongCoord; fTOFPInfo[ihhit].pathp = pathp; - Double_t timep = tdc_pos*fScinTdcToTime - - fHodoPosInvAdcOffset[fPIndex] - - pathp/fHodoPosInvAdcLinear[fPIndex] - - fHodoPosInvAdcAdc[fPIndex] - /TMath::Sqrt(TMath::Max(20.0,adc_pos)); + Double_t timep = tdc_pos*fScinTdcToTime; + if(fTofUsingInvAdc) { + timep -= fHodoPosInvAdcOffset[fPIndex] + + pathp/fHodoPosInvAdcLinear[fPIndex] + + fHodoPosInvAdcAdc[fPIndex] + /TMath::Sqrt(TMath::Max(20.0,adc_pos)); + } else { + timep -= fHodoPosPhcCoeff[fPIndex]* + TMath::Sqrt(TMath::Max(0.0,adc_pos/fHodoPosMinPh[fPIndex]-1.0)) + + pathp/fHodoVelLight[fPIndex] + + fHodoPosTimeOffset[fPIndex]; + } fTOFPInfo[ihhit].scin_pos_time = timep; timep -= zcor; fTOFPInfo[ihhit].time_pos = timep; @@ -1022,11 +1029,18 @@ Int_t THcHodoscope::FineProcess( TClonesArray& tracks ) Double_t adc_neg = hit->GetNegADC(); Double_t pathn = scinLongCoord - fPlanes[ip]->GetPosRight(); fTOFPInfo[ihhit].pathn = pathn; - Double_t timen = tdc_neg*fScinTdcToTime - - fHodoNegInvAdcOffset[fPIndex] - - pathn/fHodoNegInvAdcLinear[fPIndex] - - fHodoNegInvAdcAdc[fPIndex] - /TMath::Sqrt(TMath::Max(20.0,adc_neg)); + Double_t timen = tdc_neg*fScinTdcToTime; + if(fTofUsingInvAdc) { + timen -= fHodoNegInvAdcOffset[fPIndex] + + pathn/fHodoNegInvAdcLinear[fPIndex] + + fHodoNegInvAdcAdc[fPIndex] + /TMath::Sqrt(TMath::Max(20.0,adc_neg)); + } else { + timen -= fHodoNegPhcCoeff[fPIndex]* + TMath::Sqrt(TMath::Max(0.0,adc_neg/fHodoNegMinPh[fPIndex]-1.0)) + + pathn/fHodoVelLight[fPIndex] + + fHodoNegTimeOffset[fPIndex]; + } fTOFPInfo[ihhit].scin_neg_time = timen; timen -= zcor; fTOFPInfo[ihhit].time_neg = timen; diff --git a/src/THcScintillatorPlane.cxx b/src/THcScintillatorPlane.cxx index 4d3270d44f8c16e70e830c409c8e295c8f97c853..ee48bb80abff2e36fdb2f4b5fe844afcbd290c6d 100644 --- a/src/THcScintillatorPlane.cxx +++ b/src/THcScintillatorPlane.cxx @@ -66,12 +66,12 @@ THcScintillatorPlane::~THcScintillatorPlane() delete [] fScinZpos; delete [] fPosCenter; - // delete [] fHodoPosMinPh; fHodoPosMinPh = NULL; - // delete [] fHodoNegMinPh; fHodoNegMinPh = NULL; - // delete [] fHodoPosPhcCoeff; fHodoPosPhcCoeff = NULL; - // delete [] fHodoNegPhcCoeff; fHodoNegPhcCoeff = NULL; - // delete [] fHodoPosTimeOffset; fHodoPosTimeOffset = NULL; - // delete [] fHodoNegTimeOffset; fHodoNegTimeOffset = NULL; + delete [] fHodoPosMinPh; fHodoPosMinPh = NULL; + delete [] fHodoNegMinPh; fHodoNegMinPh = NULL; + delete [] fHodoPosPhcCoeff; fHodoPosPhcCoeff = NULL; + delete [] fHodoNegPhcCoeff; fHodoNegPhcCoeff = NULL; + delete [] fHodoPosTimeOffset; fHodoPosTimeOffset = NULL; + delete [] fHodoNegTimeOffset; fHodoNegTimeOffset = NULL; delete [] fHodoPosInvAdcOffset; fHodoPosInvAdcOffset = NULL; delete [] fHodoNegInvAdcOffset; fHodoNegInvAdcOffset = NULL; delete [] fHodoPosInvAdcLinear; fHodoPosInvAdcLinear = NULL; @@ -154,8 +154,11 @@ Int_t THcScintillatorPlane::ReadDatabase( const TDatime& date ) {Form("scin_%s_%s",GetName(),tmpright), &fPosRight,kDouble}, {Form("scin_%s_offset",GetName()), &fPosOffset, kDouble}, {Form("scin_%s_center",GetName()), fPosCenter,kDouble,fNelem}, + {"tofusinginvadc", &fTofUsingInvAdc, kInt, 0, 1}, {0} }; + + fTofUsingInvAdc = 1; gHcParms->LoadParmValues((DBRequest*)&list,prefix); // fetch the parameter from the temporary list @@ -171,12 +174,12 @@ Int_t THcScintillatorPlane::ReadDatabase( const TDatime& date ) fStartTimeCenter=((THcHodoscope *)GetParent())->GetStartTimeCenter(); fStartTimeSlop=((THcHodoscope *)GetParent())->GetStartTimeSlop(); // Parameters for this plane - // fHodoPosMinPh = new Double_t[fNelem]; - // fHodoNegMinPh = new Double_t[fNelem]; - // fHodoPosPhcCoeff = new Double_t[fNelem]; - // fHodoNegPhcCoeff = new Double_t[fNelem]; - // fHodoPosTimeOffset = new Double_t[fNelem]; - // fHodoNegTimeOffset = new Double_t[fNelem]; + fHodoPosMinPh = new Double_t[fNelem]; + fHodoNegMinPh = new Double_t[fNelem]; + fHodoPosPhcCoeff = new Double_t[fNelem]; + fHodoNegPhcCoeff = new Double_t[fNelem]; + fHodoPosTimeOffset = new Double_t[fNelem]; + fHodoNegTimeOffset = new Double_t[fNelem]; fHodoVelLight = new Double_t[fNelem]; fHodoPosInvAdcOffset = new Double_t[fNelem]; fHodoNegInvAdcOffset = new Double_t[fNelem]; @@ -187,12 +190,12 @@ Int_t THcScintillatorPlane::ReadDatabase( const TDatime& date ) fHodoSigma = new Double_t[fNelem]; for(Int_t j=0;j<(Int_t) fNelem;j++) { Int_t index=((THcHodoscope *)GetParent())->GetScinIndex(fPlaneNum-1,j); - // fHodoPosMinPh[j] = ((THcHodoscope *)GetParent())->GetHodoPosMinPh(index); - // fHodoNegMinPh[j] = ((THcHodoscope *)GetParent())->GetHodoNegMinPh(index); - // fHodoPosPhcCoeff[j] = ((THcHodoscope *)GetParent())->GetHodoPosPhcCoeff(index); - // fHodoNegPhcCoeff[j] = ((THcHodoscope *)GetParent())->GetHodoNegPhcCoeff(index); - // fHodoPosTimeOffset[j] = ((THcHodoscope *)GetParent())->GetHodoPosTimeOffset(index); - // fHodoNegTimeOffset[j] = ((THcHodoscope *)GetParent())->GetHodoNegTimeOffset(index); + fHodoPosMinPh[j] = ((THcHodoscope *)GetParent())->GetHodoPosMinPh(index); + fHodoNegMinPh[j] = ((THcHodoscope *)GetParent())->GetHodoNegMinPh(index); + fHodoPosPhcCoeff[j] = ((THcHodoscope *)GetParent())->GetHodoPosPhcCoeff(index); + fHodoNegPhcCoeff[j] = ((THcHodoscope *)GetParent())->GetHodoNegPhcCoeff(index); + fHodoPosTimeOffset[j] = ((THcHodoscope *)GetParent())->GetHodoPosTimeOffset(index); + fHodoNegTimeOffset[j] = ((THcHodoscope *)GetParent())->GetHodoNegTimeOffset(index); fHodoPosInvAdcOffset[j] = ((THcHodoscope *)GetParent())->GetHodoPosInvAdcOffset(index); fHodoNegInvAdcOffset[j] = ((THcHodoscope *)GetParent())->GetHodoNegInvAdcOffset(index); fHodoPosInvAdcLinear[j] = ((THcHodoscope *)GetParent())->GetHodoPosInvAdcLinear(index); @@ -402,12 +405,22 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) if(btdcraw_pos && btdcraw_neg) { // Do the pulse height correction to the time. (Position dependent corrections later) - Double_t timec_pos = tdc_pos*fScinTdcToTime - - fHodoPosInvAdcOffset[index] - - fHodoPosInvAdcAdc[index]/TMath::Sqrt(TMath::Max(20.0,adc_pos)); - Double_t timec_neg = tdc_neg*fScinTdcToTime - - fHodoNegInvAdcOffset[index] - - fHodoNegInvAdcAdc[index]/TMath::Sqrt(TMath::Max(20.0,adc_neg)); + Double_t timec_pos, timec_neg; + if(fTofUsingInvAdc) { + timec_pos = tdc_pos*fScinTdcToTime + - fHodoPosInvAdcOffset[index] + - fHodoPosInvAdcAdc[index]/TMath::Sqrt(TMath::Max(20.0,adc_pos)); + timec_neg = tdc_neg*fScinTdcToTime + - fHodoNegInvAdcOffset[index] + - fHodoNegInvAdcAdc[index]/TMath::Sqrt(TMath::Max(20.0,adc_neg)); + } else { // Old style + timec_pos = tdc_pos*fScinTdcToTime - fHodoPosPhcCoeff[index]* + TMath::Sqrt(TMath::Max(0.0,adc_pos/fHodoPosMinPh[index]-1.0)) + - fHodoPosTimeOffset[index]; + timec_neg = tdc_neg*fScinTdcToTime - fHodoNegPhcCoeff[index]* + TMath::Sqrt(TMath::Max(0.0,adc_neg/fHodoNegMinPh[index]-1.0)) + - fHodoNegTimeOffset[index]; + } // Find hit position using ADCs // If postime larger, then hit was nearer negative side. // Some incarnations use fixed velocity of 15 cm/nsec @@ -418,14 +431,22 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) hit_position=TMath::Min(hit_position,fPosLeft); hit_position=TMath::Max(hit_position,fPosRight); // Position depenent time corrections - timec_pos -= (fPosLeft-hit_position)/ - fHodoPosInvAdcLinear[index]; - timec_neg -= (hit_position-fPosRight)/ - fHodoNegInvAdcLinear[index]; - Double_t scin_corrected_time = 0.5*(timec_pos+timec_neg); - Double_t postime = timec_pos - (fZpos+(index%2)*fDzpos)/(29.979*fBetaNominal); - Double_t negtime = timec_neg - (fZpos+(index%2)*fDzpos)/(29.979*fBetaNominal); - + Double_t scin_corrected_time, postime, negtime; + if(fTofUsingInvAdc) { + timec_pos -= (fPosLeft-hit_position)/ + fHodoPosInvAdcLinear[index]; + timec_neg -= (hit_position-fPosRight)/ + fHodoNegInvAdcLinear[index]; + scin_corrected_time = 0.5*(timec_pos+timec_neg); + postime = timec_pos - (fZpos+(index%2)*fDzpos)/(29.979*fBetaNominal); + negtime = timec_neg - (fZpos+(index%2)*fDzpos)/(29.979*fBetaNominal); + } else { + postime=timec_pos-(fPosLeft-hit_position)/fHodoVelLight[index]; + negtime=timec_neg-(hit_position-fPosRight)/fHodoVelLight[index]; + scin_corrected_time = 0.5*(postime+negtime); + postime = postime-(fZpos+(index%2)*fDzpos)/(29.979*fBetaNominal); + negtime = negtime-(fZpos+(index%2)*fDzpos)/(29.979*fBetaNominal); + } ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetCorrectedTimes(timec_pos,timec_neg, postime, negtime, scin_corrected_time); diff --git a/src/THcScintillatorPlane.h b/src/THcScintillatorPlane.h index c83fa437ee61e4c80523ece3a05fe45cf264caa2..270db3104789aed25c96da5882001d9ae7e6b5e9 100644 --- a/src/THcScintillatorPlane.h +++ b/src/THcScintillatorPlane.h @@ -94,12 +94,13 @@ class THcScintillatorPlane : public THaSubDetector { Double_t fScinTdcToTime; Double_t fTofTolerance; Double_t fBetaNominal; - // Double_t *fHodoPosMinPh; // Minimum pulse height per paddle for this plane - // Double_t *fHodoNegMinPh; // Minimum pulse height per paddle for this plane - // Double_t *fHodoPosPhcCoeff; // Pulse height to time coefficient per paddle for this plane - // Double_t *fHodoNegPhcCoeff; // Pulse height to time coefficient per paddlefor this plane - // Double_t *fHodoPosTimeOffset; - // Double_t *fHodoNegTimeOffset; + Double_t *fHodoPosMinPh; // Minimum pulse height per paddle for this plane + Double_t *fHodoNegMinPh; // Minimum pulse height per paddle for this plane + Double_t *fHodoPosPhcCoeff; // Pulse height to time coefficient per paddle for this plane + Double_t *fHodoNegPhcCoeff; // Pulse height to time coefficient per paddlefor this plane + Double_t *fHodoPosTimeOffset; + Double_t *fHodoNegTimeOffset; + Int_t fTofUsingInvAdc; Double_t *fHodoVelLight; Double_t *fHodoPosInvAdcOffset; Double_t *fHodoNegInvAdcOffset;