diff --git a/src/THcHodoscope.cxx b/src/THcHodoscope.cxx index 7a5fcb8aab4cc89b6456cc8c07c0134b2d435f97..98ad1fe38f05c28c654f5dce2075fe0f9ca1c231 100644 --- a/src/THcHodoscope.cxx +++ b/src/THcHodoscope.cxx @@ -282,8 +282,8 @@ Int_t THcHodoscope::ReadDatabase( const TDatime& date ) fMaxHodoScin=fMaxScinPerPlane*fNPlanes; if (fDebug>=1) cout <<"fMaxScinPerPlane = "<<fMaxScinPerPlane<<" fMaxHodoScin = "<<fMaxHodoScin<<endl; - fHodoVelLight=new Double_t [fMaxHodoScin]; - fHodoPosSigma=new Double_t [fMaxHodoScin]; + fHodoVelLight=new Double_t [fMaxHodoScin]; + fHodoPosSigma=new Double_t [fMaxHodoScin]; fHodoNegSigma=new Double_t [fMaxHodoScin]; fHodoPosMinPh=new Double_t [fMaxHodoScin]; fHodoNegMinPh=new Double_t [fMaxHodoScin]; @@ -306,6 +306,10 @@ Int_t THcHodoscope::ReadDatabase( const TDatime& date ) fyLoScin = new Int_t [fNHodoscopes]; fyHiScin = new Int_t [fNHodoscopes]; fHodoSlop = new Double_t [fNPlanes]; + fTdcOffset = new Int_t [fNPlanes]; + for(Int_t ip=0;ip<fNPlanes;ip++) { // Set a large default window + fTdcOffset[ip] = 0 ; + } DBRequest list[]={ {"start_time_center", &fStartTimeCenter, kDouble}, @@ -315,15 +319,8 @@ Int_t THcHodoscope::ReadDatabase( const TDatime& date ) {"scin_tdc_max", &fScinTdcMax, kDouble}, {"tof_tolerance", &fTofTolerance, kDouble, 0, 1}, {"pathlength_central", &fPathLengthCentral, kDouble}, - {"hodo_vel_light", &fHodoVelLight[0], kDouble, fMaxHodoScin}, {"hodo_pos_sigma", &fHodoPosSigma[0], kDouble, fMaxHodoScin}, {"hodo_neg_sigma", &fHodoNegSigma[0], kDouble, fMaxHodoScin}, - {"hodo_pos_minph", &fHodoPosMinPh[0], kDouble, fMaxHodoScin}, - {"hodo_neg_minph", &fHodoNegMinPh[0], kDouble, fMaxHodoScin}, - {"hodo_pos_phc_coeff", &fHodoPosPhcCoeff[0], kDouble, fMaxHodoScin}, - {"hodo_neg_phc_coeff", &fHodoNegPhcCoeff[0], kDouble, fMaxHodoScin}, - {"hodo_pos_time_offset", &fHodoPosTimeOffset[0], kDouble, fMaxHodoScin}, - {"hodo_neg_time_offset", &fHodoNegTimeOffset[0], kDouble, fMaxHodoScin}, {"hodo_pos_ped_limit", &fHodoPosPedLimit[0], kInt, fMaxHodoScin}, {"hodo_neg_ped_limit", &fHodoNegPedLimit[0], kInt, fMaxHodoScin}, {"tofusinginvadc", &fTofUsingInvAdc, kInt, 0, 1}, @@ -353,10 +350,6 @@ Int_t THcHodoscope::ReadDatabase( const TDatime& date ) fNormETot = 0.7; // Gets added to each reference time corrected raw TDC value // to make sure valid range is all positive. - fTdcOffset = new Int_t [fNPlanes]; - for(Int_t ip=0;ip<fNPlanes;ip++) { // Set a large default window - fTdcOffset[ip] = 0; - } gHcParms->LoadParmValues((DBRequest*)&list,prefix); @@ -390,6 +383,7 @@ Int_t THcHodoscope::ReadDatabase( const TDatime& date ) if (fTofUsingInvAdc) { DBRequest list2[]={ + {"hodo_vel_light", &fHodoVelLight[0], kDouble, fMaxHodoScin}, {"hodo_pos_invadc_offset",&fHodoPosInvAdcOffset[0],kDouble,fMaxHodoScin}, {"hodo_neg_invadc_offset",&fHodoNegInvAdcOffset[0],kDouble,fMaxHodoScin}, {"hodo_pos_invadc_linear",&fHodoPosInvAdcLinear[0],kDouble,fMaxHodoScin}, @@ -400,6 +394,19 @@ Int_t THcHodoscope::ReadDatabase( const TDatime& date ) }; gHcParms->LoadParmValues((DBRequest*)&list2,prefix); }; + if (!fTofUsingInvAdc) { + DBRequest list3[]={ + {"hodo_vel_light", &fHodoVelLight[0], kDouble, fMaxHodoScin}, + {"hodo_pos_minph", &fHodoPosMinPh[0], kDouble, fMaxHodoScin}, + {"hodo_neg_minph", &fHodoNegMinPh[0], kDouble, fMaxHodoScin}, + {"hodo_pos_phc_coeff", &fHodoPosPhcCoeff[0], kDouble, fMaxHodoScin}, + {"hodo_neg_phc_coeff", &fHodoNegPhcCoeff[0], kDouble, fMaxHodoScin}, + {"hodo_pos_time_offset", &fHodoPosTimeOffset[0], kDouble, fMaxHodoScin}, + {"hodo_neg_time_offset", &fHodoNegTimeOffset[0], kDouble, fMaxHodoScin}, + {0} + }; + gHcParms->LoadParmValues((DBRequest*)&list3,prefix); + }; if (fDebug >=1) { cout <<"******* Testing Hodoscope Parameter Reading ***\n"; cout<<"StarTimeCenter = "<<fStartTimeCenter<<endl; @@ -452,9 +459,9 @@ Int_t THcHodoscope::DefineVariables( EMode mode ) {"betap", "betaP", "fBetaP"}, {"betanotrack", "Beta from scintillator hits", "fBetaNoTrk"}, {"betachisqnotrack", "Chi square of beta from scintillator hits", "fBetaNoTrkChiSq"}, - {"fpHitsTime", "Time at focal plane from all hits", "fFPTime"}, + {"fpHitsTime", "Time at focal plane from all hits", "fFPTimeAll"}, {"starttime", "Hodoscope Start Time", "fStartTime"}, - {"goodstarttime", "Hodoscope Good Start Time", "fGoodStartTime"}, + {"goodstarttime", "Hodoscope Good Start Time (logical flag)", "fGoodStartTime"}, {"goodscinhit", "Hit in fid area", "fGoodScinHits"}, // {"goodscinhitx", "Hit in fid x range", "fGoodScinHitsX"}, {"scinshould", "Total scin Hits in fid area", "fScinShould"}, @@ -537,6 +544,7 @@ void THcHodoscope::ClearEvent() fBetaNoTrk = 0.0; fBetaNoTrkChiSq = 0.0; fStartTime = 0.0; + fFPTimeAll= -1000.; fGoodStartTime = kFALSE; fGoodScinHits = 0; fScinShould = 0; @@ -646,7 +654,6 @@ void THcHodoscope::EstimateFocalPlaneTime( void ) */ Int_t timehist[200]; - for (Int_t i=0;i<200;i++) { timehist[i] = 0; } @@ -738,7 +745,6 @@ void THcHodoscope::EstimateFocalPlaneTime( void ) fStartTime = fStartTimeCenter; fGoodStartTime=kFALSE; } - if((goodplanetime[0]||goodplanetime[1]) &&(goodplanetime[2]||goodplanetime[3])) { @@ -1304,7 +1310,7 @@ Int_t THcHodoscope::FineProcess( TClonesArray& tracks ) } } Double_t fptime = FPTimeSum/nFPTimeSum; - + fFPTimeAll = fptime; Double_t dedx=0.0; for(UInt_t ih=0;ih<fTOFCalc.size();ih++) { if(fTOFCalc[ih].good_scin_time) { diff --git a/src/THcHodoscope.h b/src/THcHodoscope.h index 207c04b84cda7a0cc288b9f92e1116dff5912a05..19b38652446c71f4c68814e7032200383cc3b4b7 100644 --- a/src/THcHodoscope.h +++ b/src/THcHodoscope.h @@ -128,6 +128,7 @@ protected: // Per-event data Bool_t fGoodStartTime; Double_t fStartTime; + Double_t fFPTimeAll; Int_t fNfptimes; Double_t fBetaP; diff --git a/src/THcScintillatorPlane.cxx b/src/THcScintillatorPlane.cxx index cf4f87dd7eb9bc19a619b580698902b146150594..fb9a24dc50688b1e12e44e4e56230cf893fc8d9e 100644 --- a/src/THcScintillatorPlane.cxx +++ b/src/THcScintillatorPlane.cxx @@ -348,7 +348,17 @@ Int_t THcScintillatorPlane::DefineVariables( EMode mode ) {"negAdcPulseAmp", "List of negative ADC pulse amplitudes.", "frNegAdcPulseAmp.THcSignalHit.GetData()"}, {"fptime", "Time at focal plane", "GetFpTime()"}, + {"nhits", "Number of paddle hits (passed TDC Min and Max cuts for either end)", "GetNScinHits() "}, + {"GoodPaddle", "List of Paddle Numbers (passed TDC Min and Max cuts for either end)", "fHodoHits.THcHodoHit.GetPaddleNumber()"}, + {"GoodNegTdcChan", "List of negative TDC values (passed TDC Min and Max cuts for either end)", "fHodoHits.THcHodoHit.GetNegTDC()"}, + {"GoodNegTdcTimeCorr", "List of negative corrected TDC values (corrected for PMT offset and ADC)", "fHodoHits.THcHodoHit.GetNegCorrectedTime()"}, + {"GoodNegTdcTimeTOFCorr", "List of negative corrected TDC values (corrected for TOF)", "fHodoHits.THcHodoHit.GetNegTOFCorrectedTime()"}, + {"GoodNegAdcPulseInt", "List of negative ADC values (passed TDC Min and Max cuts for either end)", "fHodoHits.THcHodoHit.GetNegADC()"}, + {"GoodPosTdcChan", "List of positive TDC values (passed TDC Min and Max cuts for either end)", "fHodoHits.THcHodoHit.GetPosTDC()"}, + {"GoodPosTdcTimeCorr", "List of positive corrected TDC values (corrected for PMT offset and ADC)", "fHodoHits.THcHodoHit.GetPosCorrectedTime()"}, + {"GoodPosTdcTimeTOFCorr", "List of positive corrected TDC values (corrected for TOF)", "fHodoHits.THcHodoHit.GetPosTOFCorrectedTime()"}, + {"GoodPosAdcPulseInt", "List of positive ADC values (passed TDC Min and Max cuts for either end)", "fHodoHits.THcHodoHit.GetPosADC()"}, {"ngoodhits", "Number of paddle hits (passed tof tolerance and used to determine the focal plane time )", "GetNGoodHits() "}, { 0 } }; @@ -595,8 +605,8 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) Bool_t btdcraw_pos=kFALSE; Bool_t btdcraw_neg=kFALSE; - Int_t tdc_pos=-99; - Int_t tdc_neg=-99; + Int_t tdc_pos=-999; + Int_t tdc_neg=-999; // Find first in range hit from multihit tdc for(UInt_t thit=0; thit<hit->GetRawTdcHitPos().GetNHits(); thit++) { tdc_pos = hit->GetRawTdcHitPos().GetTime(thit)+fTdcOffset; @@ -613,6 +623,7 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) } } // Proceed if there is a valid TDC on either end of the bar + // cout << ihit << " " << hit->fCounter << " " << fNScinHits<< " " << tdc_neg << " " << btdcraw_neg << " " << tdc_pos << " " << btdcraw_pos << " " <<endl; if(btdcraw_pos || btdcraw_neg) { @@ -665,9 +676,39 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) postime = postime-(fZpos+(index%2)*fDzpos)/(29.979*fBetaNominal); negtime = negtime-(fZpos+(index%2)*fDzpos)/(29.979*fBetaNominal); } + // cout << fNScinHits<< " " << timec_pos << " " << timec_neg << endl; ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetCorrectedTimes(timec_pos,timec_neg, postime, negtime, scin_corrected_time); + } else { + Double_t timec_pos,timec_neg; + timec_pos=tdc_pos; + timec_neg=tdc_neg; + if(btdcraw_pos) { + if(fTofUsingInvAdc) { + timec_pos = tdc_pos*fScinTdcToTime + - fHodoPosInvAdcOffset[index] + - fHodoPosInvAdcAdc[index]/TMath::Sqrt(TMath::Max(20.0,adc_pos)); + } else { // Old style + timec_pos = tdc_pos*fScinTdcToTime - fHodoPosPhcCoeff[index]* + TMath::Sqrt(TMath::Max(0.0,adc_pos/fHodoPosMinPh[index]-1.0)) + - fHodoPosTimeOffset[index]; + } + } + if(btdcraw_neg) { + if(fTofUsingInvAdc) { + timec_neg = tdc_neg*fScinTdcToTime + - fHodoNegInvAdcOffset[index] + - fHodoNegInvAdcAdc[index]/TMath::Sqrt(TMath::Max(20.0,adc_neg)); + } else { // Old style + timec_neg = tdc_neg*fScinTdcToTime - fHodoNegPhcCoeff[index]* + TMath::Sqrt(TMath::Max(0.0,adc_neg/fHodoNegMinPh[index]-1.0)) + - fHodoNegTimeOffset[index]; + } + } + ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetCorrectedTimes(timec_pos,timec_neg, + timec_pos,timec_neg, + 0.0); } fNScinHits++; // One or more good time counter }