diff --git a/src/THcAerogel.cxx b/src/THcAerogel.cxx index 5dc6ae05dbf785ca6f1c3374fedda1fac4df7495..026613d38e6f030154fde1b3689c054f9e219900 100644 --- a/src/THcAerogel.cxx +++ b/src/THcAerogel.cxx @@ -39,7 +39,8 @@ THcAerogel::THcAerogel( const char* name, const char* description, THaNonTrackingDetector(name,description,apparatus), fPresentP(0), fAdcPosTimeWindowMin(0), fAdcPosTimeWindowMax(0), fAdcNegTimeWindowMin(0), - fAdcNegTimeWindowMax(0), fRegionValue(0), fPosGain(0), fNegGain(0), + fAdcNegTimeWindowMax(0),fPedNegDefault(0),fPedPosDefault(0), + fRegionValue(0), fPosGain(0), fNegGain(0), frPosAdcPedRaw(0), frPosAdcPulseIntRaw(0), frPosAdcPulseAmpRaw(0), frPosAdcPulseTimeRaw(0), frPosAdcPed(0), frPosAdcPulseInt(0), frPosAdcPulseAmp(0), frPosAdcPulseTime(0), frNegAdcPedRaw(0), @@ -59,7 +60,8 @@ THcAerogel::THcAerogel( const char* name, const char* description, THcAerogel::THcAerogel( ) : THaNonTrackingDetector(), fAdcPosTimeWindowMin(0), fAdcPosTimeWindowMax(0), fAdcNegTimeWindowMin(0), - fAdcNegTimeWindowMax(0), fRegionValue(0), fPosGain(0), fNegGain(0), + fAdcNegTimeWindowMax(0), + fPedNegDefault(0),fPedPosDefault(0),fRegionValue(0), fPosGain(0), fNegGain(0), frPosAdcPedRaw(0), frPosAdcPulseIntRaw(0), frPosAdcPulseAmpRaw(0), frPosAdcPulseTimeRaw(0), frPosAdcPed(0), frPosAdcPulseInt(0), frPosAdcPulseAmp(0), frPosAdcPulseTime(0), frNegAdcPedRaw(0), @@ -111,6 +113,8 @@ void THcAerogel::DeleteArrays() delete [] fAdcPosTimeWindowMax; fAdcPosTimeWindowMax = 0; delete [] fAdcNegTimeWindowMin; fAdcNegTimeWindowMin = 0; delete [] fAdcNegTimeWindowMax; fAdcNegTimeWindowMax = 0; + delete [] fPedNegDefault; fPedNegDefault = 0; + delete [] fPedPosDefault; fPedPosDefault = 0; // 6 GeV variables delete fPosTDCHits; fPosTDCHits = NULL; @@ -296,6 +300,8 @@ Int_t THcAerogel::ReadDatabase( const TDatime& date ) fAdcPosTimeWindowMax = new Double_t [fNelem]; fAdcNegTimeWindowMin = new Double_t [fNelem]; fAdcNegTimeWindowMax = new Double_t [fNelem]; + fPedNegDefault = new Int_t [fNelem]; + fPedPosDefault = new Int_t [fNelem]; DBRequest list[]={ {"aero_num_regions", &fNRegions, kInt}, @@ -315,6 +321,8 @@ Int_t THcAerogel::ReadDatabase( const TDatime& date ) {"aero_adcPosTimeWindowMax", fAdcPosTimeWindowMax, kDouble, static_cast<UInt_t>(fNelem), 1}, {"aero_adcNegTimeWindowMin", fAdcNegTimeWindowMin, kDouble, static_cast<UInt_t>(fNelem), 1}, {"aero_adcNegTimeWindowMax", fAdcNegTimeWindowMax, kDouble, static_cast<UInt_t>(fNelem), 1}, + {"aero_PedNegDefault", fPedNegDefault, kInt, static_cast<UInt_t>(fNelem), 1}, + {"aero_PedPosDefault", fPedPosDefault, kInt, static_cast<UInt_t>(fNelem), 1}, {"aero_adc_tdc_offset", &fAdcTdcOffset, kDouble, 0, 1}, {"aero_debug_adc", &fDebugAdc, kInt, 0, 1}, {"aero_six_gev_data", &fSixGevData, kInt, 0, 1}, @@ -331,6 +339,8 @@ Int_t THcAerogel::ReadDatabase( const TDatime& date ) fAdcNegTimeWindowMin[ip] = -1000.; fAdcPosTimeWindowMax[ip] = 1000.; fAdcNegTimeWindowMax[ip] = 1000.; + fPedNegDefault[ip] = 0.; + fPedPosDefault[ip] = 0.; } fSixGevData = 0; // Set 6 GeV data parameter to false unless set in parameter file @@ -646,6 +656,21 @@ Int_t THcAerogel::Decode( const THaEvData& evdata ) if (rawPosAdcHit.GetPulseAmpRaw(thit) > 0) ((THcSignalHit*) fPosAdcErrorFlag->ConstructedAt(nrPosAdcHits))->Set(npmt, 0); if (rawPosAdcHit.GetPulseAmpRaw(thit) <= 0) ((THcSignalHit*) fPosAdcErrorFlag->ConstructedAt(nrPosAdcHits))->Set(npmt, 1); + + if (rawPosAdcHit.GetPulseAmpRaw(thit) <= 0) { + Double_t PeakPedRatio= rawPosAdcHit.GetF250_PeakPedestalRatio(); + Int_t NPedSamples= rawPosAdcHit.GetF250_NPedestalSamples(); + Double_t AdcToC = rawPosAdcHit.GetAdcTopC(); + Double_t AdcToV = rawPosAdcHit.GetAdcTomV(); + if (fPedPosDefault[npmt-1] !=0) { + Double_t tPulseInt = AdcToC*(rawPosAdcHit.GetPulseIntRaw(thit) - fPedPosDefault[npmt-1]*PeakPedRatio); + ((THcSignalHit*) frPosAdcPulseInt->ConstructedAt(nrPosAdcHits))->Set(npmt, tPulseInt); + ((THcSignalHit*) frPosAdcPedRaw->ConstructedAt(nrPosAdcHits))->Set(npmt, fPedPosDefault[npmt-1]); + ((THcSignalHit*) frPosAdcPed->ConstructedAt(nrPosAdcHits))->Set(npmt, float(fPedPosDefault[npmt-1])/float(NPedSamples)*AdcToV); + + } + ((THcSignalHit*) frPosAdcPulseAmp->ConstructedAt(nrPosAdcHits))->Set(npmt, 0.); + } ++nrPosAdcHits; fTotNumAdcHits++; @@ -669,6 +694,21 @@ Int_t THcAerogel::Decode( const THaEvData& evdata ) if (rawNegAdcHit.GetPulseAmpRaw(thit) > 0) ((THcSignalHit*) fNegAdcErrorFlag->ConstructedAt(nrNegAdcHits))->Set(npmt, 0); if (rawNegAdcHit.GetPulseAmpRaw(thit) <= 0) ((THcSignalHit*) fNegAdcErrorFlag->ConstructedAt(nrNegAdcHits))->Set(npmt, 1); + if (rawNegAdcHit.GetPulseAmpRaw(thit) <= 0) { + Double_t PeakPedRatio= rawNegAdcHit.GetF250_PeakPedestalRatio(); + Int_t NPedSamples= rawNegAdcHit.GetF250_NPedestalSamples(); + Double_t AdcToC = rawNegAdcHit.GetAdcTopC(); + Double_t AdcToV = rawNegAdcHit.GetAdcTomV(); + if (fPedNegDefault[npmt-1] !=0) { + Double_t tPulseInt = AdcToC*(rawNegAdcHit.GetPulseIntRaw(thit) - fPedNegDefault[npmt-1]*PeakPedRatio); + ((THcSignalHit*) frNegAdcPulseInt->ConstructedAt(nrNegAdcHits))->Set(npmt, tPulseInt); + ((THcSignalHit*) frNegAdcPedRaw->ConstructedAt(nrNegAdcHits))->Set(npmt, fPedNegDefault[npmt-1]); + ((THcSignalHit*) frNegAdcPed->ConstructedAt(nrNegAdcHits))->Set(npmt, float(fPedNegDefault[npmt-1])/float(NPedSamples)*AdcToV); + + } + ((THcSignalHit*) frNegAdcPulseAmp->ConstructedAt(nrNegAdcHits))->Set(npmt, 0.); + } + ++nrNegAdcHits; fTotNumAdcHits++; fTotNumNegAdcHits++; @@ -690,6 +730,8 @@ Int_t THcAerogel::CoarseProcess( TClonesArray& ) //tracks { Double_t StartTime = 0.0; if( fglHod ) StartTime = fglHod->GetStartTime(); + Double_t OffsetTime = 0.0; + if( fglHod ) OffsetTime = fglHod->GetOffsetTime(); //cout << " starttime = " << StartTime << endl; // Loop over the elements in the TClonesArray for(Int_t ielem = 0; ielem < frPosAdcPulseInt->GetEntries(); ielem++) { @@ -700,18 +742,13 @@ Int_t THcAerogel::CoarseProcess( TClonesArray& ) //tracks Double_t pulseIntRaw = ((THcSignalHit*) frPosAdcPulseIntRaw->ConstructedAt(ielem))->GetData(); Double_t pulseAmp = ((THcSignalHit*) frPosAdcPulseAmp->ConstructedAt(ielem))->GetData(); Double_t pulseTime = ((THcSignalHit*) frPosAdcPulseTime->ConstructedAt(ielem))->GetData(); - Double_t adctdcdiffTime = StartTime-pulseTime; - Bool_t errorFlag = ((THcSignalHit*) fPosAdcErrorFlag->ConstructedAt(ielem))->GetData(); + Double_t adctdcdiffTime = StartTime-pulseTime+OffsetTime; //// Bool_t pulseTimeCut = adctdcdiffTime > fAdcTimeWindowMin && adctdcdiffTime < fAdcTimeWindowMax; Bool_t pulseTimeCut = adctdcdiffTime > fAdcPosTimeWindowMin[npmt] && adctdcdiffTime < fAdcPosTimeWindowMax[npmt]; // By default, the last hit within the timing cut will be considered "good" - if (!errorFlag) - { fGoodPosAdcMult.at(npmt) += 1; - } - - if (!errorFlag && pulseTimeCut) { + if (pulseTimeCut) { fGoodPosAdcPed.at(npmt) = pulsePed; // cout << " out = " << npmt << " " << frPosAdcPulseInt->GetEntries() << " " <<fGoodPosAdcMult.at(npmt); fGoodPosAdcPulseInt.at(npmt) = pulseInt; @@ -738,17 +775,13 @@ Int_t THcAerogel::CoarseProcess( TClonesArray& ) //tracks Double_t pulseIntRaw = ((THcSignalHit*) frNegAdcPulseIntRaw->ConstructedAt(ielem))->GetData(); Double_t pulseAmp = ((THcSignalHit*) frNegAdcPulseAmp->ConstructedAt(ielem))->GetData(); Double_t pulseTime = ((THcSignalHit*) frNegAdcPulseTime->ConstructedAt(ielem))->GetData(); - Double_t adctdcdiffTime = StartTime-pulseTime; - Bool_t errorFlag = ((THcSignalHit*) fNegAdcErrorFlag->ConstructedAt(ielem))->GetData(); + Double_t adctdcdiffTime = StartTime-pulseTime+OffsetTime; //// Bool_t pulseTimeCut = adctdcdiffTime > fAdcTimeWindowMin && adctdcdiffTime < fAdcTimeWindowMax; Bool_t pulseTimeCut = adctdcdiffTime > fAdcNegTimeWindowMin[npmt] && adctdcdiffTime < fAdcNegTimeWindowMax[npmt]; - if (!errorFlag) - { fGoodNegAdcMult.at(npmt) += 1; - } // By default, the last hit within the timing cut will be considered "good" - if (!errorFlag && pulseTimeCut) { + if (pulseTimeCut) { fGoodNegAdcPed.at(npmt) = pulsePed; fGoodNegAdcPulseIntRaw.at(npmt) = pulseIntRaw; fGoodNegAdcPulseAmp.at(npmt) = pulseAmp; diff --git a/src/THcAerogel.h b/src/THcAerogel.h index 1a755523539b6364c39339e8d61d38a37199d4b6..642e60525d50377275f3b7c22aa39c9a7e03fc0c 100644 --- a/src/THcAerogel.h +++ b/src/THcAerogel.h @@ -73,6 +73,8 @@ class THcAerogel : public THaNonTrackingDetector, public THcHitList { Double_t *fAdcPosTimeWindowMax; Double_t *fAdcNegTimeWindowMin; Double_t *fAdcNegTimeWindowMax; + Int_t* fPedNegDefault; + Int_t* fPedPosDefault; Double_t fAdcTdcOffset; Double_t *fRegionValue; diff --git a/src/THcCherenkov.cxx b/src/THcCherenkov.cxx index 363630c6788729bc297caa2a7d093cab00be5ba1..0ccb5649b04ff0896bbb19417e5ca0c41c39a2d2 100644 --- a/src/THcCherenkov.cxx +++ b/src/THcCherenkov.cxx @@ -129,27 +129,20 @@ void THcCherenkov::DeleteArrays() { fGain = NULL; // 6 Gev variables - delete[] fPedSum; - fPedSum = NULL; - delete[] fPedSum2; - fPedSum2 = NULL; - delete[] fPedLimit; - fPedLimit = NULL; - delete[] fPedMean; - fPedMean = NULL; - delete[] fPedCount; - fPedCount = NULL; - delete[] fPed; - fPed = NULL; - delete[] fThresh; - fThresh = NULL; - - delete[] fAdcTimeWindowMin; - fAdcTimeWindowMin = 0; - delete[] fAdcTimeWindowMax; - fAdcTimeWindowMax = 0; - delete[] fRegionValue; - fRegionValue = 0; + + delete [] fPedSum; fPedSum = NULL; + delete [] fPedSum2; fPedSum2 = NULL; + delete [] fPedLimit; fPedLimit = NULL; + delete [] fPedMean; fPedMean = NULL; + delete [] fPedCount; fPedCount = NULL; + delete [] fPed; fPed = NULL; + delete [] fThresh; fThresh = NULL; + + delete [] fPedDefault; fPedDefault = 0; + delete [] fAdcTimeWindowMin; fAdcTimeWindowMin = 0; + delete [] fAdcTimeWindowMax; fAdcTimeWindowMax = 0; + delete [] fRegionValue; fRegionValue = 0; + } //_____________________________________________________________________________ @@ -212,39 +205,48 @@ Int_t THcCherenkov::ReadDatabase(const TDatime& date) { // << GetName() << " with " << fNelem << " PMTs" << endl; // 6 GeV pedestal paramters - fPedLimit = new Int_t[fNelem]; - fGain = new Double_t[fNelem]; - fPedMean = new Double_t[fNelem]; - fAdcTimeWindowMin = new Double_t[fNelem]; - fAdcTimeWindowMax = new Double_t[fNelem]; + + fPedLimit = new Int_t[fNelem]; + fGain = new Double_t[fNelem]; + fPedMean = new Double_t[fNelem]; + fAdcTimeWindowMin = new Double_t[fNelem]; + fAdcTimeWindowMax= new Double_t[fNelem]; + fPedDefault= new Int_t[fNelem]; + // Region parameters fRegionsValueMax = fNRegions * 8; fRegionValue = new Double_t[fRegionsValueMax]; fAdcGoodElem = new Int_t[fNelem]; fAdcPulseAmpTest = new Double_t[fNelem]; - DBRequest list[] = {{"_ped_limit", fPedLimit, kInt, (UInt_t)fNelem, optional}, - {"_adc_to_npe", fGain, kDouble, (UInt_t)fNelem}, - {"_red_chi2_min", &fRedChi2Min, kDouble}, - {"_red_chi2_max", &fRedChi2Max, kDouble}, - {"_beta_min", &fBetaMin, kDouble}, - {"_beta_max", &fBetaMax, kDouble}, - {"_enorm_min", &fENormMin, kDouble}, - {"_enorm_max", &fENormMax, kDouble}, - {"_dp_min", &fDpMin, kDouble}, - {"_dp_max", &fDpMax, kDouble}, - {"_mirror_zpos", &fMirrorZPos, kDouble}, - {"_npe_thresh", &fNpeThresh, kDouble}, - {"_debug_adc", &fDebugAdc, kInt, 0, 1}, - {"_adcTimeWindowMin", fAdcTimeWindowMin, kDouble, (UInt_t)fNelem, 1}, - {"_adcTimeWindowMax", fAdcTimeWindowMax, kDouble, (UInt_t)fNelem, 1}, - {"_adc_tdc_offset", &fAdcTdcOffset, kDouble, 0, 1}, - {"_region", &fRegionValue[0], kDouble, (UInt_t)fRegionsValueMax}, - {"_adcrefcut", &fADC_RefTimeCut, kInt, 0, 1}, - {0}}; - for (Int_t i = 0; i < fNelem; i++) { - fAdcTimeWindowMin[i] = -1000.; - fAdcTimeWindowMax[i] = 1000.; + + DBRequest list[]={ + {"_ped_limit", fPedLimit, kInt, (UInt_t) fNelem, optional}, + {"_adc_to_npe", fGain, kDouble, (UInt_t) fNelem}, + {"_red_chi2_min", &fRedChi2Min, kDouble}, + {"_red_chi2_max", &fRedChi2Max, kDouble}, + {"_beta_min", &fBetaMin, kDouble}, + {"_beta_max", &fBetaMax, kDouble}, + {"_enorm_min", &fENormMin, kDouble}, + {"_enorm_max", &fENormMax, kDouble}, + {"_dp_min", &fDpMin, kDouble}, + {"_dp_max", &fDpMax, kDouble}, + {"_mirror_zpos", &fMirrorZPos, kDouble}, + {"_npe_thresh", &fNpeThresh, kDouble}, + {"_debug_adc", &fDebugAdc, kInt, 0, 1}, + {"_adcTimeWindowMin", fAdcTimeWindowMin, kDouble,(UInt_t) fNelem,1}, + {"_adcTimeWindowMax", fAdcTimeWindowMax, kDouble, (UInt_t) fNelem,1}, + {"_PedDefault", fPedDefault, kInt, (UInt_t) fNelem,1}, + {"_adc_tdc_offset", &fAdcTdcOffset, kDouble, 0, 1}, + {"_region", &fRegionValue[0], kDouble, (UInt_t) fRegionsValueMax}, + {"_adcrefcut", &fADC_RefTimeCut, kInt, 0, 1}, + {0} + }; + for (Int_t i=0;i<fNelem;i++) { + fAdcTimeWindowMin[i]=-1000.; + fAdcTimeWindowMax[i]=1000.; + fPedDefault[i]=0; + } fDebugAdc = 0; // Set ADC debug parameter to false unless set in parameter file fAdcTdcOffset = 0.0; @@ -298,32 +300,36 @@ Int_t THcCherenkov::DefineVariables(EMode mode) { } // end debug statement RVarDef vars[] = { - {"adcCounter", "ADC counter numbers", "frAdcPulseIntRaw.THcSignalHit.GetPaddleNumber()"}, - {"adcErrorFlag", "Error Flag for When FPGA Fails", "fAdcErrorFlag.THcSignalHit.GetData()"}, - {"numGoodAdcHits", "Number of Good ADC Hits Per PMT", - "fNumGoodAdcHits"}, // Cherenkov occupancy - {"totNumGoodAdcHits", "Total Number of Good ADC Hits", - "fTotNumGoodAdcHits"}, // Cherenkov multiplicity - {"numTracksMatched", "Number of Tracks Matched Per Region", "fNumTracksMatched"}, - {"numTracksFired", "Number of Tracks that Fired Per Region", "fNumTracksFired"}, - {"totNumTracksMatched", "Total Number of Tracks Matched Per Region", "fTotNumTracksMatched"}, - {"totNumTracksFired", "Total Number of Tracks that Fired", "fTotNumTracksFired"}, - - {"xAtCer", "Track X at Cherenkov mirror", "fXAtCer"}, - {"yAtCer", "Track Y at Cherenkov mirror", "fYAtCer"}, - - {"npe", "Number of PEs", "fNpe"}, - {"npeSum", "Total Number of PEs", "fNpeSum"}, - - {"goodAdcPed", "Good ADC pedestals", "fGoodAdcPed"}, - {"goodAdcMult", "Good ADC Multiplicity", "fGoodAdcMult"}, - {"goodAdcHitUsed", "Good ADC Hit Used", "fGoodAdcHitUsed"}, - {"goodAdcPulseInt", "Good ADC pulse integrals", "fGoodAdcPulseInt"}, - {"goodAdcPulseIntRaw", "Good ADC raw pulse integrals", "fGoodAdcPulseIntRaw"}, - {"goodAdcPulseAmp", "Good ADC pulse amplitudes", "fGoodAdcPulseAmp"}, - {"goodAdcPulseTime", "Good ADC pulse times", "fGoodAdcPulseTime"}, - {"goodAdcTdcDiffTime", "Good Hodo Start - ADC pulse times", "fGoodAdcTdcDiffTime"}, - {0}}; + + {"adcCounter", "ADC counter numbers", "frAdcPulseIntRaw.THcSignalHit.GetPaddleNumber()"}, + {"adcErrorFlag", "Error Flag for When FPGA Fails", "fAdcErrorFlag.THcSignalHit.GetData()"}, + + {"numGoodAdcHits", "Number of Good ADC Hits Per PMT", "fNumGoodAdcHits"}, // Cherenkov occupancy + {"totNumGoodAdcHits", "Total Number of Good ADC Hits", "fTotNumGoodAdcHits"}, // Cherenkov multiplicity + + {"numTracksMatched", "Number of Tracks Matched Per Region", "fNumTracksMatched"}, + {"numTracksFired", "Number of Tracks that Fired Per Region", "fNumTracksFired"}, + {"totNumTracksMatched", "Total Number of Tracks Matched Per Region", "fTotNumTracksMatched"}, + {"totNumTracksFired", "Total Number of Tracks that Fired", "fTotNumTracksFired"}, + + {"xAtCer", "Track X at Cherenkov mirror", "fXAtCer"}, + {"yAtCer", "Track Y at Cherenkov mirror", "fYAtCer"}, + + {"npe", "Number of PEs", "fNpe"}, + {"npeSum", "Total Number of PEs", "fNpeSum"}, + + {"goodAdcPed", "Good ADC pedestals", "fGoodAdcPed"}, + {"goodAdcMult", "Good ADC Multiplicity", "fGoodAdcMult"}, + {"goodAdcHitUsed", "Good ADC Hit Used", "fGoodAdcHitUsed"}, + {"goodAdcPulseInt", "Good ADC pulse integrals", "fGoodAdcPulseInt"}, + {"goodAdcPulseIntRaw", "Good ADC raw pulse integrals", "fGoodAdcPulseIntRaw"}, + {"goodAdcPulseAmp", "Good ADC pulse amplitudes", "fGoodAdcPulseAmp"}, + {"goodAdcPulseTime", "Good ADC pulse times", "fGoodAdcPulseTime"}, + {"goodAdcTdcDiffTime", "Good Hodo Start - ADC pulse times", "fGoodAdcTdcDiffTime"}, + {"RefTime", "Raw ADC RefTime (chan) ", "fRefTime"}, // Raw reference time + { 0 } + }; + return DefineVarsFromList(vars, mode); } @@ -360,6 +366,7 @@ void THcCherenkov::Clear(Option_t* opt) { fYAtCer = 0.0; fNpeSum = 0.0; + fRefTime=kBig; frAdcPedRaw->Clear(); frAdcPulseIntRaw->Clear(); @@ -406,7 +413,12 @@ Int_t THcCherenkov::Decode(const THaEvData& evdata) { } fNhits = DecodeToHitList(evdata, !present); - if (gHaCuts->Result("Pedestal_event")) { + + //THcHallCSpectrometer *app = dynamic_cast<THcHallCSpectrometer*>(GetApparatus()); + // cout << "Cerenkov Event num = " << evdata.GetEvNum() << " spec = " << app->GetName() << endl; + + if(gHaCuts->Result("Pedestal_event")) { + AccumulatePedestals(fRawHitList); fAnalyzePedestals = 1; // Analyze pedestals first normal events return (0); @@ -421,14 +433,16 @@ Int_t THcCherenkov::Decode(const THaEvData& evdata) { UInt_t nrAdcHits = 0; _waveforms.clear(); - while (ihit < fNhits) { - - THcCherenkovHit* hit = (THcCherenkovHit*)fRawHitList->At(ihit); - Int_t npmt = hit->fCounter; - THcRawAdcHit& rawAdcHit = hit->GetRawAdcHitPos(); - - _waveforms.push_back({rawAdcHit.GetSampleBuffer()}); + while(ihit < fNhits) { + + THcCherenkovHit* hit = (THcCherenkovHit*) fRawHitList->At(ihit); + Int_t npmt = hit->fCounter; + THcRawAdcHit& rawAdcHit = hit->GetRawAdcHitPos(); + if (rawAdcHit.GetNPulses() >0 && rawAdcHit.HasRefTime()) { + fRefTime=rawAdcHit.GetRefTime() ; + } + //if (rawAdcHit.GetNPulses()>0) cout << "Cer npmt = " << " ped = " << rawAdcHit.GetPed() << endl; for (UInt_t thit = 0; thit < rawAdcHit.GetNPulses(); thit++) { @@ -455,6 +469,23 @@ Int_t THcCherenkov::Decode(const THaEvData& evdata) { if (rawAdcHit.GetPulseAmpRaw(thit) <= 0) ((THcSignalHit*)fAdcErrorFlag->ConstructedAt(nrAdcHits))->Set(npmt, 1); + if (rawAdcHit.GetPulseAmpRaw(thit) <= 0) { + Double_t PeakPedRatio= rawAdcHit.GetF250_PeakPedestalRatio(); + Int_t NPedSamples= rawAdcHit.GetF250_NPedestalSamples(); + Double_t AdcToC = rawAdcHit.GetAdcTopC(); + Double_t AdcToV = rawAdcHit.GetAdcTomV(); + if (fPedDefault[npmt-1] !=0) { + Double_t tPulseInt = AdcToC*(rawAdcHit.GetPulseIntRaw(thit) - fPedDefault[npmt-1]*PeakPedRatio); + ((THcSignalHit*) frAdcPulseInt->ConstructedAt(nrAdcHits))->Set(npmt, tPulseInt); + ((THcSignalHit*) frAdcPedRaw->ConstructedAt(nrAdcHits))->Set(npmt, fPedDefault[npmt-1]); + ((THcSignalHit*) frAdcPed->ConstructedAt(nrAdcHits))->Set(npmt, float(fPedDefault[npmt-1])/float(NPedSamples)*AdcToV); + + } + ((THcSignalHit*) frAdcPulseAmp->ConstructedAt(nrAdcHits))->Set(npmt, 0.); + + } + + ++nrAdcHits; fTotNumAdcHits++; fNumAdcHits.at(npmt - 1) = npmt; @@ -471,7 +502,9 @@ Int_t THcCherenkov::ApplyCorrections(void) { return (0); } Int_t THcCherenkov::CoarseProcess(TClonesArray&) { Double_t StartTime = 0.0; if( fglHod ) StartTime = fglHod->GetStartTime(); - for(Int_t ipmt = 0; ipmt < fNelem; ipmt++) { + Double_t OffsetTime = 0.0; + if( fglHod ) OffsetTime = fglHod->GetOffsetTime(); + for(Int_t ipmt = 0; ipmt < fNelem; ipmt++) { fAdcPulseAmpTest[ipmt] = -1000.; fAdcGoodElem[ipmt]=-1; } @@ -480,17 +513,18 @@ Int_t THcCherenkov::CoarseProcess(TClonesArray&) { Int_t npmt = ((THcSignalHit*) frAdcPulseInt->ConstructedAt(ielem))->GetPaddleNumber() - 1; Double_t pulseTime = ((THcSignalHit*) frAdcPulseTime->ConstructedAt(ielem))->GetData(); Double_t pulseAmp = ((THcSignalHit*) frAdcPulseAmp->ConstructedAt(ielem))->GetData(); - Double_t adctdcdiffTime = StartTime-pulseTime; - Bool_t errorFlag = ((THcSignalHit*) fAdcErrorFlag->ConstructedAt(ielem))->GetData(); + Bool_t errorFlag = ((THcSignalHit*) fAdcErrorFlag->ConstructedAt(ielem))->GetData(); + Double_t adctdcdiffTime = StartTime-pulseTime+OffsetTime; Bool_t pulseTimeCut = adctdcdiffTime > fAdcTimeWindowMin[npmt] && adctdcdiffTime < fAdcTimeWindowMax[npmt]; - if (!errorFlag) - { - fGoodAdcMult.at(npmt) += 1; - } - if (!errorFlag && pulseTimeCut && pulseAmp > fAdcPulseAmpTest[npmt]) { - fAdcGoodElem[npmt]=ielem; - fAdcPulseAmpTest[npmt] = pulseAmp; - } + fGoodAdcMult.at(npmt) += 1; + if (!errorFlag) { + if (pulseTimeCut && pulseAmp > fAdcPulseAmpTest[npmt]) { + fAdcGoodElem[npmt]=ielem; + fAdcPulseAmpTest[npmt] = pulseAmp; + } + } else { + if (pulseTimeCut) fAdcGoodElem[npmt]=ielem; + } } // Loop over the npmt for(Int_t npmt = 0; npmt < fNelem; npmt++) { @@ -501,17 +535,18 @@ Int_t THcCherenkov::CoarseProcess(TClonesArray&) { Double_t pulseIntRaw = ((THcSignalHit*) frAdcPulseIntRaw->ConstructedAt(ielem))->GetData(); Double_t pulseAmp = ((THcSignalHit*) frAdcPulseAmp->ConstructedAt(ielem))->GetData(); Double_t pulseTime = ((THcSignalHit*) frAdcPulseTime->ConstructedAt(ielem))->GetData(); - Double_t adctdcdiffTime = StartTime-pulseTime; - // By default, the last hit within the timing cut will be considered "good" + Double_t adctdcdiffTime = StartTime-pulseTime+OffsetTime; fGoodAdcPed.at(npmt) = pulsePed; fGoodAdcHitUsed.at(npmt) = ielem + 1; fGoodAdcPulseInt.at(npmt) = pulseInt; fGoodAdcPulseIntRaw.at(npmt) = pulseIntRaw; fGoodAdcPulseAmp.at(npmt) = pulseAmp; fGoodAdcPulseTime.at(npmt) = pulseTime; - fGoodAdcTdcDiffTime.at(npmt) = adctdcdiffTime; - fNpe.at(npmt) = fGain[npmt] * fGoodAdcPulseInt.at(npmt); + fGoodAdcTdcDiffTime.at(npmt) = adctdcdiffTime; + + fNpe.at(npmt) = fGain[npmt]*pulseInt; + fNpeSum += fNpe.at(npmt); fTotNumGoodAdcHits++; diff --git a/src/THcCherenkov.h b/src/THcCherenkov.h index fc9232901d76a12ff1492fc55ae4ff02d246f3de..446101f10f83b3e11d4eb8ac7814b11b55b45db1 100644 --- a/src/THcCherenkov.h +++ b/src/THcCherenkov.h @@ -69,6 +69,7 @@ public: Int_t fTotNumGoodAdcHits; Int_t fTotNumTracksMatched; Int_t fTotNumTracksFired; + Double_t fRefTime; Double_t fNpeSum; Double_t* fGain; @@ -102,6 +103,7 @@ public: Double_t fNpeThresh; Double_t* fAdcTimeWindowMin; Double_t* fAdcTimeWindowMax; + Int_t* fPedDefault; Double_t fAdcTdcOffset; Double_t* fRegionValue; diff --git a/src/THcCoinTime.cxx b/src/THcCoinTime.cxx index 653e6e2d5b69261e866dbe2dfe694488ab5653ca..84546108ec241ffc2d0c6ff1b7d5325c9995a454 100644 --- a/src/THcCoinTime.cxx +++ b/src/THcCoinTime.cxx @@ -65,6 +65,14 @@ void THcCoinTime::Clear( Option_t* opt ) fROC2_ePosCoinTime=kBig; fROC1_RAW_CoinTime=kBig; fROC2_RAW_CoinTime=kBig; + fTRIG1_ePosCoinTime=kBig; + fTRIG4_ePosCoinTime=kBig; + fTRIG1_ePiCoinTime=kBig; + fTRIG4_ePiCoinTime=kBig; + fTRIG1_eKCoinTime=kBig; + fTRIG4_eKCoinTime=kBig; + fTRIG1_epCoinTime=kBig; + fTRIG4_epCoinTime=kBig; } //_____________________________________________________________________________ @@ -263,6 +271,9 @@ Int_t THcCoinTime::Process( const THaEvData& evdata ) Double_t hms_ypfp = theHMSTrack->GetPhi(); Double_t HMS_FPtime = theHMSTrack->GetFPTime(); + if (SHMS_FPtime==-2000 || HMS_FPtime==-2000) return 1; + if (SHMS_FPtime==-1000 || HMS_FPtime==-1000) return 1; + //Get raw TDC Times for HMS/SHMS (3/4 trigger) pTRIG1_TdcTime_ROC1 = fCoinDet->Get_CT_Trigtime(0); //SHMS pTRIG4_TdcTime_ROC1 = fCoinDet->Get_CT_Trigtime(1); //HMS diff --git a/src/THcDriftChamberPlane.cxx b/src/THcDriftChamberPlane.cxx index 0948adb1b02a33458a33557a41f7969104db3b4c..5c1a36fbbbdb3a6254bb4b4aaf61299f7c1e2f4b 100644 --- a/src/THcDriftChamberPlane.cxx +++ b/src/THcDriftChamberPlane.cxx @@ -298,6 +298,7 @@ Int_t THcDriftChamberPlane::DefineVariables( EMode mode ) {"dist","Drift distancess", "fHits.THcDCHit.GetDist()"}, {"nhit", "Number of hits", "GetNHits()"}, + {"RefTime", "TDC reference time", "fTdcRefTime"}, { 0 } }; @@ -351,7 +352,7 @@ Int_t THcDriftChamberPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) fHits->Clear(); fRawHits->Clear(); - + fTdcRefTime = kBig; Int_t nrawhits = rawhits->GetLast()+1; fNRawhits=0; Int_t ihit = nexthit; @@ -365,6 +366,7 @@ Int_t THcDriftChamberPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) Int_t wireNum = hit->fCounter; THcDCWire* wire = GetWire(wireNum); Bool_t First_Hit_In_Window = kTRUE; + if (hit->GetRawTdcHit().HasRefTime()) fTdcRefTime = hit->GetRawTdcHit().GetRefTime(); for(UInt_t mhit=0; mhit<hit->GetRawTdcHit().GetNHits(); mhit++) { fNRawhits++; /* Sort into early, late and ontime */ @@ -391,6 +393,7 @@ Int_t THcDriftChamberPlane::SubtractStartTime() { Double_t StartTime = 0.0; if( fglHod ) StartTime = fglHod->GetStartTime(); + if (StartTime == -1000) StartTime = 0.0; for(Int_t ihit=0;ihit<GetNHits();ihit++) { THcDCHit *thishit = (THcDCHit*) fHits->At(ihit); Double_t temptime= thishit->GetTime()-StartTime; diff --git a/src/THcDriftChamberPlane.h b/src/THcDriftChamberPlane.h index 0a65b240b7f8e766509f78089eb135ff3f754f39..eaa7b54097a103d71c25e603b409bcc7d1deb94f 100644 --- a/src/THcDriftChamberPlane.h +++ b/src/THcDriftChamberPlane.h @@ -86,6 +86,8 @@ protected: TClonesArray* fHits; TClonesArray* fRawHits; TClonesArray* fWires; + + Double_t fTdcRefTime; Int_t fVersion; Int_t fWireOrder; diff --git a/src/THcHallCSpectrometer.cxx b/src/THcHallCSpectrometer.cxx index 2f84f3d435bb92a1bea5b01b4bbe946fe1fd5538..f6002126192f460292564a42a475375693d56b65 100644 --- a/src/THcHallCSpectrometer.cxx +++ b/src/THcHallCSpectrometer.cxx @@ -142,6 +142,10 @@ Int_t THcHallCSpectrometer::DefineVariables( EMode mode ) fIsSetup = ( mode == kDefine ); RVarDef vars[] = { { "tr.betachisq", "Chi2 of beta", "fTracks.THaTrack.GetBetaChi2()"}, + { "tr.GoodPlane4", "Flag for track hitting hodo plane 4", "fTracks.THaTrack.GetGoodPlane4()"}, + { "tr.GoodPlane3", "Flag for track hitting hodo plane 3", "fTracks.THaTrack.GetGoodPlane3()"}, + { "tr.fptime", "Track hodo focal plane time", "fTracks.THaTrack.GetFPTime()"}, + { "tr.npmt", "Track number of hodo PMTs hit", "fTracks.THaTrack.GetNPMT()"}, { "tr.PruneSelect", "Prune Select ID", "fPruneSelect"}, { "present", "Trigger Type includes this spectrometer", "fPresent"}, { 0 } diff --git a/src/THcHitList.cxx b/src/THcHitList.cxx index 1ae9b0b756e1e9ac058f226c3c7b414dcdcbc587..c06589fc59a34dd39d0a8cdf581912b4ae2c8fb8 100644 --- a/src/THcHitList.cxx +++ b/src/THcHitList.cxx @@ -263,10 +263,14 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarni fRefIndexMaps[i].hashit = kFALSE; Bool_t goodreftime=kFALSE; Int_t reftime = 0; + Int_t prevtime = 0; + Int_t difftime = 0; for(Int_t ihit=0; ihit<nrefhits; ihit++) { reftime = evdata.GetData(Decoder::kPulseTime,fRefIndexMaps[i].crate, fRefIndexMaps[i].slot, fRefIndexMaps[i].channel,ihit); reftime += 64*timeshift; + if (ihit != 0) difftime=reftime-prevtime; + prevtime = reftime; if(reftime >= fADC_RefTimeCut) { goodreftime = kTRUE; break; @@ -274,6 +278,7 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarni } if(goodreftime || (nrefhits>0 && fADC_RefTimeBest)) { fRefIndexMaps[i].reftime = reftime; + fRefIndexMaps[i].refdifftime = difftime; fRefIndexMaps[i].hashit = kTRUE; } } else { // Assume this is a TDC @@ -285,9 +290,13 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarni // then fTDC_RefTimeCut Bool_t goodreftime=kFALSE; Int_t reftime = 0; + Int_t prevtime = 0; + Int_t difftime = 0; for(Int_t ihit=0; ihit<nrefhits; ihit++) { reftime = evdata.GetData(fRefIndexMaps[i].crate,fRefIndexMaps[i].slot, fRefIndexMaps[i].channel,ihit); + if( ihit != 0) difftime=reftime-prevtime; + prevtime=reftime; if(reftime >= fTDC_RefTimeCut) { goodreftime = kTRUE; break; @@ -295,6 +304,7 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarni } if(goodreftime || (nrefhits>0 && fTDC_RefTimeBest)) { fRefIndexMaps[i].reftime = reftime; + fRefIndexMaps[i].refdifftime = difftime; fRefIndexMaps[i].hashit = kTRUE; } } @@ -360,8 +370,12 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarni Int_t nrefhits = evdata.GetNumHits(d->crate,d->slot,d->refchan); Bool_t goodreftime=kFALSE; Int_t reftime=0; + Int_t prevtime=0; + Int_t difftime=0; for(Int_t ihit=0; ihit<nrefhits; ihit++) { reftime = evdata.GetData(d->crate, d->slot, d->refchan, ihit); + if (ihit != 0 ) difftime=reftime-prevtime; + prevtime = reftime; if(reftime >= fTDC_RefTimeCut) { goodreftime = kTRUE; break; @@ -371,6 +385,7 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarni // hits make the RefTimeCut if(goodreftime || (nrefhits>0 && fTDC_RefTimeBest)) { rawhit->SetReference(signal, reftime); + rawhit->SetReferenceDiff(signal, difftime); } else if (!suppresswarnings) { cout << "HitList(event=" << evdata.GetEvNum() << "): refchan " << d->refchan << " missing for (" << d->crate << ", " << d->slot << @@ -381,6 +396,7 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarni if(d->refindex >=0 && d->refindex < fNRefIndex) { if(fRefIndexMaps[d->refindex].hashit) { rawhit->SetReference(signal, fRefIndexMaps[d->refindex].reftime); + rawhit->SetReferenceDiff(signal, fRefIndexMaps[d->refindex].refdifftime); } else { if(!suppresswarnings) { cout << "HitList(event=" << evdata.GetEvNum() << "): refindex " << d->refindex << @@ -451,6 +467,8 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarni d->crate, d->slot, d->refchan); Bool_t goodreftime=kFALSE; Int_t reftime = 0; + Int_t prevtime = 0; + Int_t difftime = 0; timeshift=0; if(fTISlot>0) { // Get the trigger time for this module if(fTrigTimeShiftMap.find(d->slot) @@ -465,6 +483,8 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarni for(Int_t ihit=0; ihit<nrefhits; ihit++) { reftime = evdata.GetData(Decoder::kPulseTime, d->crate, d->slot, d->refchan, ihit); reftime += 64*timeshift; + if (ihit != 0) difftime=reftime-prevtime; + prevtime=reftime; if(reftime >= fADC_RefTimeCut) { goodreftime=kTRUE; break; @@ -474,6 +494,7 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarni // hits make the RefTimeCut if(goodreftime || (nrefhits>0 && fADC_RefTimeBest)) { rawhit->SetReference(signal, reftime); + rawhit->SetReferenceDiff(signal, difftime); } else if (!suppresswarnings) { #ifndef SUPPRESSMISSINGADCREFTIMEMESSAGES cout << "HitList(event=" << evdata.GetEvNum() << "): refchan " << d->refchan << @@ -486,6 +507,7 @@ Int_t THcHitList::DecodeToHitList( const THaEvData& evdata, Bool_t suppresswarni if(d->refindex >=0 && d->refindex < fNRefIndex) { if(fRefIndexMaps[d->refindex].hashit) { rawhit->SetReference(signal, fRefIndexMaps[d->refindex].reftime); + rawhit->SetReferenceDiff(signal, fRefIndexMaps[d->refindex].refdifftime); } else { if(!suppresswarnings) { #ifndef SUPPRESSMISSINGADCREFTIMEMESSAGES diff --git a/src/THcHitList.h b/src/THcHitList.h index 186e861a12736d9ee711627c6f0c2c0cc02e1f00..a8db5bca6af2fcf3db369c39f75e53d0de427b5d 100644 --- a/src/THcHitList.h +++ b/src/THcHitList.h @@ -73,6 +73,7 @@ protected: Int_t slot; Int_t channel; Int_t reftime; + Int_t refdifftime; }; std::vector<RefIndexMap> fRefIndexMaps; // Should this be a sparse list instead in case user diff --git a/src/THcHodoHit.h b/src/THcHodoHit.h index c5b86eff829414c0f243939886b5b12cee38fddd..a450190861f763f885689cac9106f2d900cff971 100644 --- a/src/THcHodoHit.h +++ b/src/THcHodoHit.h @@ -34,6 +34,9 @@ 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; } Double_t GetPosCorrectedTime() const { return fPosCorrectedTime;} @@ -46,8 +49,9 @@ public: Int_t GetPaddleNumber() const { return fPaddleNumber; } Double_t GetPaddleCenter() const { return fPaddleCenter; } - void SetCorrectedTimes(Double_t pos, Double_t neg, Double_t) { + void SetCorrectedTimes(Double_t pos, Double_t neg) { fPosCorrectedTime = pos; fNegCorrectedTime = neg; + fHasCorrectedTimes = kFALSE; } void SetCorrectedTimes(Double_t pos, Double_t neg, Double_t postof, Double_t negtof, @@ -75,6 +79,15 @@ 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; + } protected: static const Double_t kBig; //! @@ -86,6 +99,9 @@ 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; Double_t fPosCorrectedTime; // Pulse height corrected time diff --git a/src/THcHodoscope.cxx b/src/THcHodoscope.cxx index 45bc5d4dcb9b78eafbe87aa21963fb979e949694..86441a263edac2821fad1c2aaa7dc69aed4dc84e 100644 --- a/src/THcHodoscope.cxx +++ b/src/THcHodoscope.cxx @@ -242,9 +242,10 @@ Int_t THcHodoscope::ReadDatabase(const TDatime& date) { fBetaNoTrk = 0.; fBetaNoTrkChiSq = 0.; - fNPaddle = new UInt_t[fNPlanes]; - fFPTime = new Double_t[fNPlanes]; - fPlaneCenter = new Double_t[fNPlanes]; + fNPaddle = new UInt_t [fNPlanes]; + fFPTime = new Double_t [fNPlanes]; + fPlaneCenter = new Double_t[fNPlanes]; + fPlaneSpacing = new Double_t[fNPlanes]; prefix[0] = tolower(GetApparatus()->GetName()[0]); @@ -260,9 +261,13 @@ Int_t THcHodoscope::ReadDatabase(const TDatime& date) { // GN added // reading variables from *hodo.param - fMaxScinPerPlane = fNPaddle[0]; - for (Int_t i = 1; i < fNPlanes; i++) { - fMaxScinPerPlane = (fMaxScinPerPlane > fNPaddle[i]) ? fMaxScinPerPlane : fNPaddle[i]; + + fMaxScinPerPlane=fNPaddle[0]; + fTotHodScin=fNPaddle[0]; + for (Int_t i=1;i<fNPlanes;i++) { + fMaxScinPerPlane=(fMaxScinPerPlane > fNPaddle[i])? fMaxScinPerPlane : fNPaddle[i]; + fTotHodScin+=(fNPaddle[i]); + } // need this for "padded arrays" i.e. 4x16 lists of parameters (GN) fMaxHodoScin = fMaxScinPerPlane * fNPlanes; @@ -316,52 +321,56 @@ Int_t THcHodoscope::ReadDatabase(const TDatime& date) { fAdcTdcOffset[ip] = 0.0; } - DBRequest list[] = { - {"cosmicflag", &fCosmicFlag, kInt, 0, 1}, - {"NumPlanesBetaCalc", &fNumPlanesBetaCalc, kInt, 0, 1}, - {"start_time_center", &fStartTimeCenter, kDouble}, - {"start_time_slop", &fStartTimeSlop, kDouble}, - {"scin_tdc_to_time", &fScinTdcToTime, kDouble}, - {"scin_tdc_min", &fScinTdcMin, kDouble}, - {"scin_tdc_max", &fScinTdcMax, kDouble}, - {"tof_tolerance", &fTofTolerance, kDouble, 0, 1}, - {"pathlength_central", &fPathLengthCentral, kDouble}, - {"hodo_pos_sigma", &fHodoPosSigma[0], kDouble, fMaxHodoScin, 1}, - {"hodo_neg_sigma", &fHodoNegSigma[0], kDouble, fMaxHodoScin, 1}, - {"hodo_pos_ped_limit", &fHodoPosPedLimit[0], kInt, fMaxHodoScin, 1}, - {"hodo_neg_ped_limit", &fHodoNegPedLimit[0], kInt, fMaxHodoScin, 1}, - {"tofusinginvadc", &fTofUsingInvAdc, kInt, 0, 1}, - {"xloscin", &fxLoScin[0], kInt, (UInt_t)fNHodoscopes}, - {"xhiscin", &fxHiScin[0], kInt, (UInt_t)fNHodoscopes}, - {"yloscin", &fyLoScin[0], kInt, (UInt_t)fNHodoscopes}, - {"yhiscin", &fyHiScin[0], kInt, (UInt_t)fNHodoscopes}, - {"track_eff_test_num_scin_planes", &fTrackEffTestNScinPlanes, kInt}, - {"trackeff_scint_ydiff_max", &trackeff_scint_ydiff_max, kDouble, 0, 1}, - {"trackeff_scint_xdiff_max", &trackeff_scint_xdiff_max, kDouble, 0, 1}, - {"cer_npe", &fNCerNPE, kDouble, 0, 1}, - {"normalized_energy_tot", &fNormETot, kDouble, 0, 1}, - {"hodo_slop", fHodoSlop, kDouble, (UInt_t)fNPlanes}, - {"debugprintscinraw", &fdebugprintscinraw, kInt, 0, 1}, - {"hodo_tdc_offset", fTdcOffset, kInt, (UInt_t)fNPlanes, 1}, - {"hodo_adc_tdc_offset", fAdcTdcOffset, kDouble, (UInt_t)fNPlanes, 1}, - {"hodo_PosAdcTimeWindowMin", fHodoPosAdcTimeWindowMin, kDouble, (UInt_t)fMaxHodoScin, 1}, - {"hodo_PosAdcTimeWindowMax", fHodoPosAdcTimeWindowMax, kDouble, (UInt_t)fMaxHodoScin, 1}, - {"hodo_NegAdcTimeWindowMin", fHodoNegAdcTimeWindowMin, kDouble, (UInt_t)fMaxHodoScin, 1}, - {"hodo_NegAdcTimeWindowMax", fHodoNegAdcTimeWindowMax, kDouble, (UInt_t)fMaxHodoScin, 1}, - {"dumptof", &fDumpTOF, kInt, 0, 1}, - {"TOFCalib_shtrk_lo", &fTOFCalib_shtrk_lo, kDouble, 0, 1}, - {"TOFCalib_shtrk_hi", &fTOFCalib_shtrk_hi, kDouble, 0, 1}, - {"TOFCalib_cer_lo", &fTOFCalib_cer_lo, kDouble, 0, 1}, - {"TOFCalib_beta_lo", &fTOFCalib_beta_lo, kDouble, 0, 1}, - {"TOFCalib_beta_hi", &fTOFCalib_beta_hi, kDouble, 0, 1}, - {"dumptof_filename", &fTOFDumpFile, kString, 0, 1}, - {0}}; + + DBRequest list[]={ + {"cosmicflag", &fCosmicFlag, kInt, 0, 1}, + {"NumPlanesBetaCalc", &fNumPlanesBetaCalc, kInt, 0, 1}, + {"start_time_center", &fStartTimeCenter, kDouble}, + {"start_time_slop", &fStartTimeSlop, kDouble}, + {"scin_tdc_to_time", &fScinTdcToTime, kDouble}, + {"scin_tdc_min", &fScinTdcMin, kDouble}, + {"scin_tdc_max", &fScinTdcMax, kDouble}, + {"tof_tolerance", &fTofTolerance, kDouble, 0, 1}, + {"pathlength_central", &fPathLengthCentral, kDouble}, + {"hodo_pos_sigma", &fHodoPosSigma[0], kDouble, fMaxHodoScin, 1}, + {"hodo_neg_sigma", &fHodoNegSigma[0], kDouble, fMaxHodoScin, 1}, + {"hodo_pos_ped_limit", &fHodoPosPedLimit[0], kInt, fMaxHodoScin, 1}, + {"hodo_neg_ped_limit", &fHodoNegPedLimit[0], kInt, fMaxHodoScin, 1}, + {"tofusinginvadc", &fTofUsingInvAdc, kInt, 0, 1}, + {"xloscin", &fxLoScin[0], kInt, (UInt_t) fNHodoscopes}, + {"xhiscin", &fxHiScin[0], kInt, (UInt_t) fNHodoscopes}, + {"yloscin", &fyLoScin[0], kInt, (UInt_t) fNHodoscopes}, + {"yhiscin", &fyHiScin[0], kInt, (UInt_t) fNHodoscopes}, + {"track_eff_test_num_scin_planes", &fTrackEffTestNScinPlanes, kInt}, + {"trackeff_scint_ydiff_max", &trackeff_scint_ydiff_max, kDouble, 0, 1}, + {"trackeff_scint_xdiff_max", &trackeff_scint_xdiff_max, kDouble, 0, 1}, + {"cer_npe", &fNCerNPE, kDouble, 0, 1}, + {"normalized_energy_tot", &fNormETot, kDouble, 0, 1}, + {"hodo_slop", fHodoSlop, kDouble, (UInt_t) fNPlanes}, + {"debugprintscinraw", &fdebugprintscinraw, kInt, 0,1}, + {"hodo_tdc_offset", fTdcOffset, kInt, (UInt_t) fNPlanes, 1}, + {"hodo_adc_tdc_offset", fAdcTdcOffset, kDouble, (UInt_t) fNPlanes, 1}, + {"hodo_PosAdcTimeWindowMin", fHodoPosAdcTimeWindowMin, kDouble, (UInt_t) fMaxHodoScin, 1}, + {"hodo_PosAdcTimeWindowMax", fHodoPosAdcTimeWindowMax, kDouble, (UInt_t) fMaxHodoScin, 1}, + {"hodo_NegAdcTimeWindowMin", fHodoNegAdcTimeWindowMin, kDouble, (UInt_t) fMaxHodoScin, 1}, + {"hodo_NegAdcTimeWindowMax", fHodoNegAdcTimeWindowMax, kDouble, (UInt_t) fMaxHodoScin, 1}, + {"dumptof", &fDumpTOF, kInt, 0, 1}, + {"TOFCalib_shtrk_lo", &fTOFCalib_shtrk_lo, kDouble, 0, 1}, + {"TOFCalib_shtrk_hi", &fTOFCalib_shtrk_hi, kDouble, 0, 1}, + {"TOFCalib_cer_lo", &fTOFCalib_cer_lo, kDouble, 0, 1}, + {"TOFCalib_beta_lo", &fTOFCalib_beta_lo, kDouble, 0, 1}, + {"TOFCalib_beta_hi", &fTOFCalib_beta_hi, kDouble, 0, 1}, + {"dumptof_filename", &fTOFDumpFile, kString, 0, 1}, + {"TrackBetaIncludeSinglePmtHits", &fTrackBetaIncludeSinglePmtHits, kInt, 0, 1}, + {0} + }; // Defaults if not defined in parameter file + fTrackBetaIncludeSinglePmtHits=0; // do not use paddles with only one hit in the TRack Beta calculation set ==1 to include + trackeff_scint_ydiff_max=20.; + trackeff_scint_xdiff_max=20.; + for(UInt_t ip=0;ip<fMaxHodoScin;ip++) { - trackeff_scint_ydiff_max = 20.; - trackeff_scint_xdiff_max = 20.; - for (UInt_t ip = 0; ip < fMaxHodoScin; ip++) { fHodoPosAdcTimeWindowMin[ip] = -1000.; fHodoPosAdcTimeWindowMax[ip] = 1000.; fHodoNegAdcTimeWindowMin[ip] = -1000.; @@ -549,6 +558,28 @@ Int_t THcHodoscope::DefineVariables(EMode mode) { // Register variables in global list RVarDef vars[] = { +<<<<<<< src/THcHodoscope.cxx + // Move these into THcHallCSpectrometer using track fTracks + {"beta", "Beta including track info", "fBeta"}, + {"betanotrack", "Beta from scintillator hits", "fBetaNoTrk"}, + {"betachisqnotrack", "Chi square of beta from scintillator hits", "fBetaNoTrkChiSq"}, + {"fpHitsTime", "Time at focal plane from all hits", "fFPTimeAll"}, + {"starttime", "Hodoscope Start Time", "fStartTime"}, + {"goodstarttime", "Hodoscope Good Start Time (logical flag)", "fGoodStartTime"}, + {"goodscinhit", "Hit in fid area", "fGoodScinHits"}, + {"adctdc_offset"," ","fOffsetTime"}, + {"TimeHist_StartTime_Sigma", "", "fTimeHist_StartTime_Sigma"}, + {"TimeHist_StartTime_Peak", "", "fTimeHist_StartTime_Peak"}, + {"TimeHist_StartTime_NumPeaks", "", "fTimeHist_StartTime_NumPeaks"}, + {"TimeHist_StartTime_Hits", "", "fTimeHist_StartTime_Hits"}, + {"TimeHist_FpTime_Sigma", "", "fTimeHist_FpTime_Sigma"}, + {"TimeHist_FpTime_Peak", "", "fTimeHist_FpTime_Peak"}, + {"TimeHist_FpTime_NumPeaks", "", "fTimeHist_FpTime_NumPeaks"}, + {"TimeHist_FpTime_Hits", "", "fTimeHist_FpTime_Hits"}, + { 0 } + }; + return DefineVarsFromList( vars, mode ); +======= // Move these into THcHallCSpectrometer using track fTracks {"beta", "Beta including track info", "fBeta"}, {"betanotrack", "Beta from scintillator hits", "fBetaNoTrk"}, @@ -563,6 +594,7 @@ Int_t THcHodoscope::DefineVariables(EMode mode) { {0}}; return DefineVarsFromList(vars, mode); +>>>>>>> src/THcHodoscope.cxx // return kOK; } //_____________________________________________________________________________ @@ -705,20 +737,31 @@ void THcHodoscope::Clear(Option_t* opt) { * Called by THcHodoscope::Decode * */ - fTimeHist_Sigma = kBig; - fTimeHist_Peak = kBig; - fTimeHist_Hits = kBig; + + fTimeHist_StartTime_Sigma= kBig; + fTimeHist_StartTime_Peak= kBig; + fTimeHist_StartTime_NumPeaks= 0; + fTimeHist_StartTime_Hits= kBig; + fTimeHist_FpTime_Sigma= kBig; + fTimeHist_FpTime_Peak= kBig; + fTimeHist_FpTime_NumPeaks= 0; + fTimeHist_FpTime_Hits= kBig; + fBeta = 0.0; fBetaNoTrk = 0.0; fBetaNoTrkChiSq = 0.0; - fStartTime = -1000.; - fFPTimeAll = -1000.; - fGoodStartTime = kFALSE; - fGoodScinHits = 0; - if (*opt != 'I') { - for (Int_t ip = 0; ip < fNPlanes; ip++) { + fStartTime = -1000.; + fADCStartTime = -1000.; + fOffsetTime = kBig; + fFPTimeAll= -1000.; + fGoodStartTime = kFALSE; + fGoodScinHits = 0; + + if( *opt != 'I' ) { + for(Int_t ip=0;ip<fNPlanes;ip++) { + fPlanes[ip]->Clear(); fFPTime[ip] = 0.; fPlaneCenter[ip] = 0.; @@ -733,6 +776,10 @@ void THcHodoscope::Clear(Option_t* opt) { fNClust.clear(); fClustSize.clear(); fClustPos.clear(); + fNCluster.clear(); + fClusterSize.clear(); + fClusterXPos.clear(); + fClusterYPos.clear(); fThreeScin.clear(); fGoodScinHitsX.clear(); fGoodFlags.clear(); @@ -760,11 +807,11 @@ Int_t THcHodoscope::Decode(const THaEvData& evdata) { present = *fPresentP; } fNHits = DecodeToHitList(evdata, !present); - + fEventNum = evdata.GetEvNum(); // // GN: print event number so we can cross-check with engine // if (evdata.GetEvNum()>1000) - // cout <<"\nhcana_event " << evdata.GetEvNum()<<endl; + // cout <<"\nhcana_event " << evdata.GetEvNum()<<endl; fCheckEvent = evdata.GetEvNum(); fEventType = evdata.GetEvType(); @@ -789,9 +836,12 @@ Int_t THcHodoscope::Decode(const THaEvData& evdata) { // Let each plane get its hits Int_t nexthit = 0; - fNfptimes = 0; + //THcHallCSpectrometer *app = dynamic_cast<THcHallCSpectrometer*>(GetApparatus()); + // cout << " event number = " << fEventNum << " Evtyp = " << fEventType<< " spec = " << app->GetName() << endl; + fNfptimes=0; Int_t thits = 0; - for (Int_t ip = 0; ip < fNPlanes; ip++) { + for(Int_t ip=0;ip<fNPlanes;ip++) { + fPlaneCenter[ip] = fPlanes[ip]->GetPosCenter(0) + fPlanes[ip]->GetPosOffset(); fPlaneSpacing[ip] = fPlanes[ip]->GetSpacing(); @@ -802,9 +852,12 @@ Int_t THcHodoscope::Decode(const THaEvData& evdata) { nexthit = fPlanes[ip]->ProcessHits(fRawHitList, nexthit); thits += fPlanes[ip]->GetNScinHits(); } - fStartTime = -1000; - if (thits > 0) - EstimateFocalPlaneTime(); + + // + // + fStartTime=-1000; + if (thits>0 ) EstimateFocalPlaneTime(); + if (fdebugprintscinraw == 1) { for (UInt_t ihit = 0; ihit < fNRawHits; ihit++) { @@ -818,6 +871,129 @@ Int_t THcHodoscope::Decode(const THaEvData& evdata) { return fNHits; } +//_____________________________________________________________________________ +Double_t THcHodoscope::DetermineTimePeak(Int_t FillFlag) +{ + Double_t time_peak=-1000; + Int_t NBinsX=hTime->GetNbinsX(); + Int_t hTimeScanRange = 10.; // Integrate over HtimeScanRange + vector<Double_t> hpeakCent; + vector<Double_t> hpeakNum; + vector<Double_t> hpeakRMS; + vector<Double_t> hpeakFlag; + vector<Int_t> hpeakBin; + Double_t MinimumNum=2.; + Double_t test_peakmax=0.; + Bool_t scanning_for_local_peak=kFALSE; + Double_t save_mean=0,save_rms=0,save_num=0; + Int_t save_bin; + Bool_t new_peak=kFALSE; + Bool_t replace_peak=kFALSE; + UInt_t best_peak_index=0; + Int_t best_peak_num=-1; + Double_t best_peak_diff=1000; + Int_t nfound=0; + for (Int_t nb=1;nb<NBinsX-hTimeScanRange;nb++) { + hTime->GetXaxis()->SetRange(nb,nb+hTimeScanRange); + Double_t test_int = hTime->Integral(); + if (scanning_for_local_peak) { + if ( test_int <= test_peakmax) { + Int_t ps=hpeakCent.size(); + replace_peak=kFALSE; + new_peak=kFALSE; + if (ps==0) new_peak=kTRUE; + if (ps!=0 && nb==hpeakBin[ps]+1 && save_mean!=hpeakCent[ps-1]) new_peak=kFALSE; + if (ps!=0 && save_num > hpeakNum[ps-1] && abs(save_mean-hpeakCent[ps-1])<5) replace_peak=kTRUE; + if (ps!=0 && nb!=hpeakBin[ps]+1 && save_num > MinimumNum && abs(save_mean-hpeakCent[ps-1])>=5) new_peak=kTRUE; + if (new_peak) { + hpeakCent.push_back(save_mean); + hpeakRMS.push_back(save_rms); + hpeakNum.push_back(save_num); + hpeakBin.push_back(save_bin); + hpeakFlag.push_back(1); + } + if (replace_peak) { + hpeakCent[ps-1]=save_mean; + hpeakRMS[ps-1]=save_rms; + hpeakNum[ps-1]=save_num; + hpeakBin[ps-1]=save_bin; + hpeakFlag[ps-1]=1; + } + scanning_for_local_peak = kFALSE; + test_peakmax = 0; + best_peak_index=-1; + best_peak_num=5; + nfound=0; + for (UInt_t np=0;np<hpeakNum.size();np++) { + hpeakFlag[np]=-1; + if ( hpeakNum[np] > 5 && (hpeakNum[np]>= best_peak_num || abs(hpeakNum[np] - best_peak_num)<= 4) ) { + if (nfound==0 || (hpeakNum[np]== best_peak_num || abs(hpeakNum[np] - best_peak_num)<= 4) ) { + hpeakFlag[np]=1; + if (nfound==0 ) best_peak_num =hpeakNum[np] ; + if (nfound==0 ) best_peak_index= np; + nfound++; + } else { + for (UInt_t nt=0;nt<np;nt++) {hpeakFlag[nt]=-1;} + nfound=1; + best_peak_num =hpeakNum[np] ; + best_peak_index= np; + } + } + } + if (nfound>1) { + best_peak_diff=1000; + for (UInt_t np=0;np<hpeakNum.size();np++) { + if (hpeakFlag[np]==1 && abs(hpeakCent[np]-fStartTimeCenter)<best_peak_diff) { + best_peak_diff = abs(hpeakCent[np]-fStartTimeCenter); + best_peak_index= np; + } + }} + if (nfound==0) { + best_peak_diff=1000; + for (UInt_t np=0;np<hpeakNum.size();np++) { + if (abs(hpeakCent[np]-fStartTimeCenter)<best_peak_diff) { + best_peak_diff = abs(hpeakCent[np]-fStartTimeCenter); + best_peak_index= np; + } + }} + + } else { + test_peakmax = test_int; + save_mean=hTime->GetMean(); + save_rms=hTime->GetRMS(); + save_num=hTime->Integral(); + save_bin=nb; + } + } else { + if ( test_int > MinimumNum) { + test_peakmax = test_int; + scanning_for_local_peak = kTRUE; + save_mean=hTime->GetMean(); + save_rms=hTime->GetRMS(); + save_num=hTime->Integral(); + save_bin=nb; + } + } + } + // + if (hpeakNum.size() >0 && best_peak_index<hpeakNum.size() ) { + time_peak= hpeakCent[best_peak_index]; + if (FillFlag==1) { + fTimeHist_StartTime_NumPeaks=hpeakNum.size() ; + fTimeHist_StartTime_Peak= time_peak; + fTimeHist_StartTime_Sigma= hpeakRMS[best_peak_index] ; + fTimeHist_StartTime_Hits= hpeakNum[best_peak_index]; + } + if (FillFlag==2) { + fTimeHist_FpTime_NumPeaks=hpeakNum.size() ; + fTimeHist_FpTime_Peak= time_peak; + fTimeHist_FpTime_Sigma= hpeakRMS[best_peak_index] ; + fTimeHist_FpTime_Hits= hpeakNum[best_peak_index]; + } + } + // + return time_peak; +} //_____________________________________________________________________________ void THcHodoscope::EstimateFocalPlaneTime() { @@ -835,93 +1011,160 @@ 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(); + + // + 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()) { - Double_t postime = hit->GetPosTOFCorrectedTime(); - Double_t negtime = hit->GetNegTOFCorrectedTime(); - hTime->Fill(postime); - hTime->Fill(negtime); + for(Int_t i=0;i<nphits;i++) { + THcHodoHit *hit = (THcHodoHit*)hodoHits->At(i); + if(hit->GetHasCorrectedTimes()) { + Double_t postime=hit->GetPosTOFCorrectedTime(); + Double_t negtime=hit->GetNegTOFCorrectedTime(); + hTime->Fill(postime); + hTime->Fill(negtime); + } + } } - } // + Double_t TimePeak=DetermineTimePeak(1); + hTime->Reset(); // - ihit = 0; - Double_t fpTimeSum = 0.0; - fNfptimes = 0; - Int_t Ngood_hits_plane = 0; - Double_t Plane_fptime_sum = 0.0; - Bool_t goodplanetime[fNPlanes]; - Bool_t twogoodtimes[nscinhits]; - Double_t tmin = 0.5 * hTime->GetMaximumBin(); - fTimeHist_Peak = tmin; - fTimeHist_Sigma = hTime->GetRMS(); - fTimeHist_Hits = hTime->Integral(); - _basic_data.fTimeHist_Peak = fTimeHist_Peak; - _basic_data.fTimeHist_Sigma = fTimeHist_Sigma; - _basic_data.fTimeHist_Hits = fTimeHist_Hits; - for (Int_t ip = 0; ip < fNumPlanesBetaCalc; ip++) { - goodplanetime[ip] = kFALSE; - Int_t nphits = fPlanes[ip]->GetNScinHits(); + 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; + Int_t nphits=fPlanes[ip]->GetNScinHits(); + TClonesArray* hodoHits = fPlanes[ip]->GetHits(); Ngood_hits_plane = 0; Plane_fptime_sum = 0.0; for (Int_t i = 0; i < nphits; i++) { THcHodoHit* hit = (THcHodoHit*)hodoHits->At(i); twogoodtimes[ihit] = kFALSE; - if (hit->GetHasCorrectedTimes()) { - Double_t postime = hit->GetPosTOFCorrectedTime(); - Double_t negtime = hit->GetNegTOFCorrectedTime(); - if ((postime > (tmin - fTofTolerance)) && (postime < (tmin + fTofTolerance)) && - (negtime > (tmin - fTofTolerance)) && (negtime < (tmin + fTofTolerance))) { - hit->SetTwoGoodTimes(kTRUE); - twogoodtimes[ihit] = kTRUE; // Both tubes fired - 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); - } + + if(hit->GetHasCorrectedTimes()) { + Double_t postime=hit->GetPosTOFCorrectedTime(); + Double_t negtime=hit->GetNegTOFCorrectedTime(); + Double_t adcpostime=hit->GetPosADCCorrtime(); + Double_t adcnegtime=hit->GetNegADCCorrtime(); + if ((postime>(TimePeak-fTofTolerance)) && (postime<(TimePeak+fTofTolerance)) && + (negtime>(TimePeak-fTofTolerance)) && (negtime<(TimePeak+fTofTolerance)) ) { + hit->SetTwoGoodTimes(kTRUE); + twogoodtimes[ihit] = kTRUE; // Both tubes fired + 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_hits_plane++; - Plane_fptime_sum += fptime; - fpTimeSum += fptime; - fNfptimes++; - goodplanetime[ip] = kTRUE; - } else { - hit->SetTwoGoodTimes(kFALSE); - } + Plane_fptime_sum+=fptime; + fpTimeSum += fptime; + fNfptimes++; + goodplanetime[ip] = kTRUE; + } 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) - fPlanes[ip]->SetFpTime(Plane_fptime_sum / float(Ngood_hits_plane)); + 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); } - - if (fNfptimes > 0) { - fStartTime = fpTimeSum / fNfptimes; - fGoodStartTime = kTRUE; - fFPTimeAll = fStartTime; + } // if TimePeak>0 + // + if(NumPlanesGoodHit>=3) { + fStartTime = fpTimeSum/fNfptimes; + fGoodStartTime=kTRUE; + fFPTimeAll = fStartTime ; + fOffsetTime=0; + if(NumPlanesGoodAdcHit>=3) { + fADCStartTime = adcfpTimeSum/adcNfptimes-fStartTime; + } + fOffsetTime =AdcTdcDiffTimeSum; } else { - fStartTime = fStartTimeCenter; - fGoodStartTime = kFALSE; - fFPTimeAll = fStartTime; + fStartTime = fStartTimeCenter; + fADCStartTime = fStartTimeCenter; + fGoodStartTime=kFALSE; + fFPTimeAll = fStartTime ; + fOffsetTime=AdcTdcDiffTimeSum; + } // // hTime->Reset(); // - if ((goodplanetime[0] || goodplanetime[1]) && (goodplanetime[2] || goodplanetime[3])) { + + if(fGoodStartTime && (goodplanetime[0]||goodplanetime[1]) &&(goodplanetime[2]||goodplanetime[3])) { + Double_t sumW = 0.; Double_t sumT = 0.; @@ -1026,6 +1269,8 @@ void THcHodoscope::EstimateFocalPlaneTime() { fGoodEventTOFCalib = kTRUE; // // + } else { + fBetaNoTrkChiSq = -10.; // Flag if does not try to find beta } } @@ -1080,7 +1325,9 @@ Int_t THcHodoscope::CoarseProcess(TClonesArray& tracks) { Double_t sumFPTime = 0.; // Line 138 fNScinHit.push_back(0); - //! Calculate all corrected hit times and histogram + + +//! Calculate all corrected hit times and histogram //! This uses a copy of code below. Results are save in time_pos,neg //! including the z-pos. correction assuming nominal value of betap //! Code is currently hard-wired to look for a peak in the @@ -1093,12 +1340,14 @@ Int_t THcHodoscope::CoarseProcess(TClonesArray& tracks) { //! Default value in case user hasnt defined something reasonable // Loop over scintillator planes. - // In ENGINE, its loop over good scintillator hits. - hTime->Reset(); - fTOFCalc.clear(); // SAW - Can we - fTOFPInfo.clear(); // SAW - combine these two? - Int_t ihhit = 0; // Hit # overall - + // In ENGINE, its loop over good scintillator hits. (comments from old version) + hTime->Reset(); + fTOFCalc.clear(); // SAW - Can we + fTOFPInfo.clear(); // SAW - combine these two? + Int_t ihhit = 0; // Hit # overall + + + for (Int_t ip = 0; ip < fNumPlanesBetaCalc; ip++) { std::vector<GoodFlags> goodflagstmp2; @@ -1108,146 +1357,159 @@ Int_t THcHodoscope::CoarseProcess(TClonesArray& tracks) { #else fGoodFlags[itrack].push_back(goodflagstmp2); #endif - fNScinHits[ip] = fPlanes[ip]->GetNScinHits(); - TClonesArray* hodoHits = fPlanes[ip]->GetHits(); - - Double_t zPos = fPlanes[ip]->GetZpos(); - Double_t dzPos = fPlanes[ip]->GetDzpos(); - - // first loop over hits with in a single plane - for (Int_t iphit = 0; iphit < fNScinHits[ip]; iphit++) { - // iphit is hit # within a plane - THcHodoHit* hit = (THcHodoHit*)hodoHits->At(iphit); - - fTOFPInfo.push_back(TOFPInfo()); - // Can remove these as we will initialize in the constructor - // fTOFPInfo[ihhit].time_pos = -99.0; - // fTOFPInfo[ihhit].time_neg = -99.0; - // fTOFPInfo[ihhit].keep_pos = kFALSE; - // fTOFPInfo[ihhit].keep_neg = kFALSE; - fTOFPInfo[ihhit].scin_pos_time = 0.0; - fTOFPInfo[ihhit].scin_neg_time = 0.0; - fTOFPInfo[ihhit].hit = hit; - fTOFPInfo[ihhit].planeIndex = ip; - fTOFPInfo[ihhit].hitNumInPlane = iphit; - fTOFPInfo[ihhit].onTrack = kFALSE; - - Int_t paddle = hit->GetPaddleNumber() - 1; - Double_t zposition = zPos + (paddle % 2) * dzPos; - - Double_t xHitCoord = theTrack->GetX() + theTrack->GetTheta() * (zposition); // Line 183 - - Double_t yHitCoord = theTrack->GetY() + theTrack->GetPhi() * (zposition); // Line 184 - - Double_t scinTrnsCoord, scinLongCoord; - if ((ip == 0) || (ip == 2)) { // !x plane. Line 185 - scinTrnsCoord = xHitCoord; - scinLongCoord = yHitCoord; - } else if ((ip == 1) || (ip == 3)) { // !y plane. Line 188 - scinTrnsCoord = yHitCoord; - scinLongCoord = xHitCoord; - } else { - return -1; - } // Line 195 - - fTOFPInfo[ihhit].scinTrnsCoord = scinTrnsCoord; - fTOFPInfo[ihhit].scinLongCoord = scinLongCoord; - - Double_t scinCenter = fPlanes[ip]->GetPosCenter(paddle) + fPlanes[ip]->GetPosOffset(); - - // Index to access the 2d arrays of paddle/scintillator properties - Int_t fPIndex = GetScinIndex(ip, paddle); - Double_t betatrack = theTrack->GetP() / TMath::Sqrt(theTrack->GetP() * theTrack->GetP() + - fPartMass * fPartMass); - - if (TMath::Abs(scinCenter - scinTrnsCoord) < - (fPlanes[ip]->GetSize() * 0.5 + fPlanes[ip]->GetHodoSlop())) { // Line 293 - - fTOFPInfo[ihhit].onTrack = kTRUE; - Double_t zcor = zposition / (29.979 * betatrack) * - TMath::Sqrt(1. + theTrack->GetTheta() * theTrack->GetTheta() + - theTrack->GetPhi() * theTrack->GetPhi()); - fTOFPInfo[ihhit].zcor = zcor; - if (fCosmicFlag) { - Double_t zcor = -zposition / (29.979 * 1.0) * - TMath::Sqrt(1. + theTrack->GetTheta() * theTrack->GetTheta() + - theTrack->GetPhi() * theTrack->GetPhi()); - fTOFPInfo[ihhit].zcor = zcor; - } - Double_t tdc_pos = hit->GetPosTDC(); - if (tdc_pos >= fScinTdcMin && tdc_pos <= fScinTdcMax) { - Double_t adc_pos = hit->GetPosADC(); - Double_t adcamp_pos = hit->GetPosADCpeak(); - Double_t pathp = fPlanes[ip]->GetPosLeft() - scinLongCoord; - fTOFPInfo[ihhit].pathp = pathp; - Double_t timep = tdc_pos * fScinTdcToTime; - if (fTofUsingInvAdc) { - timep -= fHodoPosInvAdcOffset[fPIndex] + pathp / fHodoPosInvAdcLinear[fPIndex] + - fHodoPosInvAdcAdc[fPIndex] / TMath::Sqrt(TMath::Max(20.0 * .020, adc_pos)); - } else { - // Double_t tw_corr_pos = - // fHodoPos_c1[fPIndex]/pow(adcamp_pos/fTdc_Thrs,fHodoPos_c2[fPIndex]) - - // fHodoPos_c1[fPIndex]/pow(200./fTdc_Thrs, fHodoPos_c2[fPIndex]); - Double_t tw_corr_pos = 0.; - pathp = scinLongCoord; - if (adcamp_pos > 0) - tw_corr_pos = 1. / pow(adcamp_pos / fTdc_Thrs, fHodoPos_c2[fPIndex]) - - 1. / pow(200. / fTdc_Thrs, fHodoPos_c2[fPIndex]); - timep += -tw_corr_pos + fHodo_LCoeff[fPIndex] + pathp / fHodoVelFit[fPIndex]; - } - fTOFPInfo[ihhit].scin_pos_time = timep; - timep -= zcor; - fTOFPInfo[ihhit].time_pos = timep; + fNScinHits[ip] = fPlanes[ip]->GetNScinHits(); + TClonesArray* hodoHits = fPlanes[ip]->GetHits(); + + Double_t zPos = fPlanes[ip]->GetZpos(); + Double_t dzPos = fPlanes[ip]->GetDzpos(); + + // first loop over hits with in a single plane + for (Int_t iphit = 0; iphit < fNScinHits[ip]; iphit++ ){ + // iphit is hit # within a plane + THcHodoHit *hit = (THcHodoHit*)hodoHits->At(iphit); + + fTOFPInfo.push_back(TOFPInfo()); + // Can remove these as we will initialize in the constructor + // fTOFPInfo[ihhit].time_pos = -99.0; + // fTOFPInfo[ihhit].time_neg = -99.0; + // fTOFPInfo[ihhit].keep_pos = kFALSE; + // fTOFPInfo[ihhit].keep_neg = kFALSE; + fTOFPInfo[ihhit].scin_pos_time = 0.0; + fTOFPInfo[ihhit].scin_neg_time = 0.0; + fTOFPInfo[ihhit].hit = hit; + fTOFPInfo[ihhit].planeIndex = ip; + fTOFPInfo[ihhit].hitNumInPlane = iphit; + fTOFPInfo[ihhit].onTrack = kFALSE; + + Int_t paddle = hit->GetPaddleNumber()-1; + Double_t zposition = zPos + (paddle%2)*dzPos; + + Double_t xHitCoord = theTrack->GetX() + theTrack->GetTheta() * + ( zposition ); // Line 183 + + Double_t yHitCoord = theTrack->GetY() + theTrack->GetPhi() * + ( zposition ); // Line 184 + + Double_t scinTrnsCoord, scinLongCoord; + if ( ( ip == 0 ) || ( ip == 2 ) ){ // !x plane. Line 185 + scinTrnsCoord = xHitCoord; + scinLongCoord = yHitCoord; + } else if ( ( ip == 1 ) || ( ip == 3 ) ){ // !y plane. Line 188 + scinTrnsCoord = yHitCoord; + scinLongCoord = xHitCoord; + } else { return -1; } // Line 195 + + fTOFPInfo[ihhit].scinTrnsCoord = scinTrnsCoord; + fTOFPInfo[ihhit].scinLongCoord = scinLongCoord; + + Double_t scinCenter = fPlanes[ip]->GetPosCenter(paddle) + fPlanes[ip]->GetPosOffset(); + + // Index to access the 2d arrays of paddle/scintillator properties + Int_t fPIndex = GetScinIndex(ip,paddle); + Double_t betatrack = theTrack->GetP()/TMath::Sqrt(theTrack->GetP()*theTrack->GetP()+fPartMass*fPartMass); + + if ( TMath::Abs( scinCenter - scinTrnsCoord ) < + ( fPlanes[ip]->GetSize() * 0.5 + fPlanes[ip]->GetHodoSlop() ) ){ // Line 293 + + fTOFPInfo[ihhit].onTrack = kTRUE; + Double_t zcor = zposition/(29.979*betatrack)* + TMath::Sqrt(1. + theTrack->GetTheta()*theTrack->GetTheta() + + theTrack->GetPhi()*theTrack->GetPhi()); + fTOFPInfo[ihhit].zcor = zcor; + if (fCosmicFlag) { + Double_t zcor = -zposition/(29.979*1.0)* + TMath::Sqrt(1. + theTrack->GetTheta()*theTrack->GetTheta() + + theTrack->GetPhi()*theTrack->GetPhi()); + fTOFPInfo[ihhit].zcor = zcor; + } + Double_t tdc_pos = hit->GetPosTDC(); + Double_t tdc_neg = hit->GetNegTDC(); + // + if( (tdc_pos >=fScinTdcMin && tdc_pos <= fScinTdcMax) && + (tdc_neg >=fScinTdcMin && tdc_neg <= fScinTdcMax )) { + fTOFPInfo[ihhit].scin_pos_time = hit->GetPosCorrectedTime(); + Double_t timep = hit->GetPosCorrectedTime()-zcor; + fTOFPInfo[ihhit].time_pos = timep; hTime->Fill(timep); - } - Double_t tdc_neg = hit->GetNegTDC(); - if (tdc_neg >= fScinTdcMin && tdc_neg <= fScinTdcMax) { - Double_t adc_neg = hit->GetNegADC(); - Double_t adcamp_neg = hit->GetNegADCpeak(); - Double_t pathn = scinLongCoord - fPlanes[ip]->GetPosRight(); - fTOFPInfo[ihhit].pathn = pathn; - Double_t timen = tdc_neg * fScinTdcToTime; - if (fTofUsingInvAdc) { - timen -= fHodoNegInvAdcOffset[fPIndex] + pathn / fHodoNegInvAdcLinear[fPIndex] + - fHodoNegInvAdcAdc[fPIndex] / TMath::Sqrt(TMath::Max(20.0 * .020, adc_neg)); - } else { - pathn = scinLongCoord; - Double_t tw_corr_neg = 0; - if (adcamp_neg > 0) - tw_corr_neg = 1. / pow(adcamp_neg / fTdc_Thrs, fHodoNeg_c2[fPIndex]) - - 1. / pow(200. / fTdc_Thrs, fHodoNeg_c2[fPIndex]); - timen += -tw_corr_neg - 2 * fHodoCableFit[fPIndex] + fHodo_LCoeff[fPIndex] - - pathn / fHodoVelFit[fPIndex]; - } - fTOFPInfo[ihhit].scin_neg_time = timen; - timen -= zcor; - fTOFPInfo[ihhit].time_neg = timen; + fTOFPInfo[ihhit].scin_neg_time = hit->GetNegCorrectedTime(); + Double_t timen = hit->GetNegCorrectedTime()-zcor; + fTOFPInfo[ihhit].time_neg = timen; hTime->Fill(timen); - } - } // condition for cenetr on a paddle - ihhit++; - } // First loop over hits in a plane <--------- + } else { + // + if (fTrackBetaIncludeSinglePmtHits==1) { + if(tdc_pos >=fScinTdcMin && tdc_pos <= fScinTdcMax ) { + Double_t adc_pos = hit->GetPosADC(); + Double_t adcamp_pos = hit->GetPosADCpeak(); + Double_t pathp = fPlanes[ip]->GetPosLeft() - scinLongCoord; + fTOFPInfo[ihhit].pathp = pathp; + Double_t timep = tdc_pos*fScinTdcToTime; + if(fTofUsingInvAdc) { + timep -= fHodoPosInvAdcOffset[fPIndex] + + pathp/fHodoPosInvAdcLinear[fPIndex] + + fHodoPosInvAdcAdc[fPIndex] + /TMath::Sqrt(TMath::Max(20.0*.020,adc_pos)); + } else { + //Double_t tw_corr_pos = fHodoPos_c1[fPIndex]/pow(adcamp_pos/fTdc_Thrs,fHodoPos_c2[fPIndex]) - fHodoPos_c1[fPIndex]/pow(200./fTdc_Thrs, fHodoPos_c2[fPIndex]); + Double_t tw_corr_pos=0.; + pathp=scinLongCoord; + if (adcamp_pos>0) tw_corr_pos = 1./pow(adcamp_pos/fTdc_Thrs,fHodoPos_c2[fPIndex]) - 1./pow(200./fTdc_Thrs, fHodoPos_c2[fPIndex]); + timep += -tw_corr_pos + fHodo_LCoeff[fPIndex]+ pathp/fHodoVelFit[fPIndex]; + } + fTOFPInfo[ihhit].scin_pos_time = timep; + timep -= zcor; + fTOFPInfo[ihhit].time_pos = timep; - //----------------------------------------------------------------------------------------------- - //------------- First large loop over scintillator hits ends here -------------------- - //----------------------------------------------------------------------------------------------- + hTime->Fill(timep); + } + if(tdc_neg >=fScinTdcMin && tdc_neg <= fScinTdcMax ) { + Double_t adc_neg = hit->GetNegADC(); + Double_t adcamp_neg = hit->GetNegADCpeak(); + Double_t pathn = scinLongCoord - fPlanes[ip]->GetPosRight(); + fTOFPInfo[ihhit].pathn = pathn; + Double_t timen = tdc_neg*fScinTdcToTime; + if(fTofUsingInvAdc) { + timen -= fHodoNegInvAdcOffset[fPIndex] + + pathn/fHodoNegInvAdcLinear[fPIndex] + + fHodoNegInvAdcAdc[fPIndex] + /TMath::Sqrt(TMath::Max(20.0*.020,adc_neg)); + } else { + pathn=scinLongCoord ; + Double_t tw_corr_neg =0 ; + if (adcamp_neg >0) tw_corr_neg= 1./pow(adcamp_neg/fTdc_Thrs,fHodoNeg_c2[fPIndex]) - 1./pow(200./fTdc_Thrs, fHodoNeg_c2[fPIndex]); + timen += -tw_corr_neg- 2*fHodoCableFit[fPIndex] + fHodo_LCoeff[fPIndex]- pathn/fHodoVelFit[fPIndex]; + + } + fTOFPInfo[ihhit].scin_neg_time = timen; + timen -= zcor; + fTOFPInfo[ihhit].time_neg = timen; + hTime->Fill(timen); + } + } // new fTrackBetaIncludeSinglePmtHits + } // matches else + } // condition for cenetr on a paddle + ihhit++; + } // First loop over hits in a plane <--------- + + //----------------------------------------------------------------------------------------------- + //------------- First large loop over scintillator hits ends here -------------------- + //----------------------------------------------------------------------------------------------- } - Int_t nhits = ihhit; + Int_t nhits=ihhit; + + Double_t TimePeak = DetermineTimePeak(2); + if(TimePeak> 0) { + + for(Int_t ih = 0; ih < nhits; ih++) { // loop over all scintillator hits + if ( ( fTOFPInfo[ih].time_pos > (TimePeak-fTofTolerance) ) && ( fTOFPInfo[ih].time_pos < ( TimePeak + fTofTolerance ) ) ) { + fTOFPInfo[ih].keep_pos=kTRUE; + } + if ( ( fTOFPInfo[ih].time_neg > (TimePeak-fTofTolerance) ) && ( fTOFPInfo[ih].time_neg < ( TimePeak + fTofTolerance ) ) ){ + fTOFPInfo[ih].keep_neg=kTRUE; + } + } - if (0.5 * hTime->GetMaximumBin() > 0) { - Double_t tmin = 0.5 * hTime->GetMaximumBin(); - - for (Int_t ih = 0; ih < nhits; ih++) { // loop over all scintillator hits - if ((fTOFPInfo[ih].time_pos > (tmin - fTofTolerance)) && - (fTOFPInfo[ih].time_pos < (tmin + fTofTolerance))) { - fTOFPInfo[ih].keep_pos = kTRUE; - } - if ((fTOFPInfo[ih].time_neg > (tmin - fTofTolerance)) && - (fTOFPInfo[ih].time_neg < (tmin + fTofTolerance))) { - fTOFPInfo[ih].keep_neg = kTRUE; - } - } } //--------------------------------------------------------------------------------------------- @@ -1491,34 +1753,38 @@ Int_t THcHodoscope::CoarseProcess(TClonesArray& tracks) { // // --------------------------------------------------------------------------- - Double_t FPTimeSum = 0.0; - Int_t nFPTimeSum = 0; - for (Int_t ip = 0; ip < fNumPlanesBetaCalc; ip++) { - if (fNPlaneTime[ip] != 0) { - fFPTime[ip] = (fSumPlaneTime[ip] / fNPlaneTime[ip]); - FPTimeSum += fSumPlaneTime[ip]; - nFPTimeSum += fNPlaneTime[ip]; - } else { - fFPTime[ip] = 1000. * (ip + 1); - } + + Double_t FPTimeSum=0.0; + Int_t nFPTimeSum=0; + Int_t nGoodPlanesHit=0; + for (Int_t ip = 0; ip < fNumPlanesBetaCalc; ip++ ){ + if ( fNPlaneTime[ip] != 0 ){ + nGoodPlanesHit++; + fFPTime[ip] = ( fSumPlaneTime[ip] / fNPlaneTime[ip] ); + FPTimeSum += fSumPlaneTime[ip]; + nFPTimeSum += fNPlaneTime[ip]; + } else { + fFPTime[ip] = 1000. * ( ip + 1 ); + } } - Double_t fptime = -1000; - if (nFPTimeSum > 0) - 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) { - dedx = fTOFCalc[ih].dedx; - break; - } + Double_t fptime=-2000; + fptime=fStartTime; + if (nGoodPlanesHit>=3) 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) { + dedx = fTOFCalc[ih].dedx; + break; + } + } theTrack->SetDedx(dedx); theTrack->SetFPTime(fptime); theTrack->SetBeta(beta); theTrack->SetBetaChi2(betaChiSq); theTrack->SetNPMT(nPmtHit[itrack]); - theTrack->SetFPTime(timeAtFP[itrack]); + } // Main loop over tracks ends here. @@ -1527,10 +1793,156 @@ Int_t THcHodoscope::CoarseProcess(TClonesArray& tracks) { // OriginalTrackEffTest(); TrackEffTest(); + // + CalcCluster(); + + return 0; } -void THcHodoscope::TrackEffTest(void) { +// +void THcHodoscope::CalcCluster(void) +{ + // THcHallCSpectrometer *app = dynamic_cast<THcHallCSpectrometer*>(GetApparatus()); + // cout << app->GetName() << endl; + const Int_t MaxNCluster=5; + std::vector<Int_t > iw(MaxNCluster,0); + std::vector<Double_t > dw(MaxNCluster,0); + for(Int_t ip = 0; ip < fNumPlanesBetaCalc; ip++ ) { + fNCluster.push_back(0); + fClusterSize.push_back(iw); + fClusterXPos.push_back(dw); + fClusterYPos.push_back(dw); + } + for (Int_t ip = 0; ip < fNumPlanesBetaCalc; ip++ ){ + Double_t pl_xypos=0; + Double_t pl_calcpos=0; + Double_t pl_zpos=0; + Int_t num_good_pad=0; + Double_t pl_x=0,pl_y=0; + TClonesArray* hodoHits = fPlanes[ip]->GetHits(); + Int_t prev_padnum=-100; + for (Int_t iphit = 0; iphit < fPlanes[ip]->GetNScinHits(); iphit++ ){ + THcHodoHit *hit = (THcHodoHit*)hodoHits->At(iphit); + if ( hit->GetTwoGoodTimes() ) { + Int_t padind = hit->GetPaddleNumber()-1; + Int_t padnum = padind+1; + if (ip==0 || ip==2) pl_x = fPlanes[ip]->GetPosCenter(padind)+ fPlanes[ip]->GetPosOffset(); + if (ip==0 || ip==2) pl_y = ((THcHodoHit*)hodoHits->At(iphit))->GetCalcPosition(); + if (ip==1 || ip==3) pl_y = fPlanes[ip]->GetPosCenter(padind)+ fPlanes[ip]->GetPosOffset(); + if (ip==1 || ip==3) pl_x = ((THcHodoHit*)hodoHits->At(iphit))->GetCalcPosition(); + pl_xypos+=fPlanes[ip]->GetPosCenter(padind)+ fPlanes[ip]->GetPosOffset(); + pl_calcpos=((THcHodoHit*)hodoHits->At(iphit))->GetCalcPosition(); + pl_zpos+=fPlanes[ip]->GetZpos()+ (padind%2)*fPlanes[ip]->GetDzpos(); + num_good_pad++; + if ( fNCluster[ip]>0 && abs(padnum-prev_padnum)==1 && fClusterSize[ip][fNCluster[ip]-1]==1) { + fClusterSize[ip][fNCluster[ip]-1]=fClusterSize[ip][fNCluster[ip]-1]+1; + fClusterXPos[ip][fNCluster[ip]-1]+=pl_x; + fClusterYPos[ip][fNCluster[ip]-1]+=pl_y; + // cout << "Add to cluster pl = " << ip+1 << " hit = " << iphit << " pad = " << padnum << " clus = " << fNCluster[ip] << " cl size = " << fClusterSize[ip][fNCluster[ip]-1] << " Xpos " << pl_x << " Ypos = " << pl_y << " postime = " << hit->GetPosTOFCorrectedTime() << " negtime = " << hit->GetNegTOFCorrectedTime() << endl; + } else { + if (fNCluster[ip]<MaxNCluster) fNCluster[ip]++; + fClusterSize[ip][fNCluster[ip]-1]=1; + fClusterXPos[ip][fNCluster[ip]-1]=pl_x; + fClusterYPos[ip][fNCluster[ip]-1]=pl_y; + // cout << " New clus pl = " << ip+1 << " hit = " << iphit << " pad = " << padnum << " clus = " << fNCluster[ip] << " cl size = " << fClusterSize[ip][fNCluster[ip]-1] << " Xpos = " << pl_x << " Ypos = " << pl_y << " postime = " << hit->GetPosTOFCorrectedTime() << " negtime = " << hit->GetNegTOFCorrectedTime() << endl; + } + prev_padnum=padnum; + } + } + // + for (Int_t ic = 0; ic < fNCluster[ip]; ic++ ){ + fClusterXPos[ip][ic]/=fClusterSize[ip][ic]; + fClusterYPos[ip][ic]/=fClusterSize[ip][ic]; + // cout << " Cluster = " << ic+1 << " Xpos = " << fClusterXPos[ip][ic] << " Ypos = " << fClusterYPos[ip][ic] << endl; + } + // + if (num_good_pad !=0 ) { + pl_xypos=pl_xypos/num_good_pad; + pl_calcpos=pl_calcpos/num_good_pad; + pl_zpos=pl_zpos/num_good_pad; + } else { + pl_xypos = kBig; + pl_calcpos = kBig; + pl_zpos = kBig; + } + // fPlanes[ip]->SetTranversePos(pl_xypos); + //fPlanes[ip]->SetLongPos(pl_calcpos); + } + // + // analyze clusters + Int_t best_cluster[4]={-1,-1,-1,-1}; + Double_t diffx_test; + Double_t diffx; + Double_t diffy_test; + Double_t diffy; + Int_t pl1,pl2; + for (Int_t nch = 0; nch < 2; nch++ ){ + if (nch==0) pl1=0; + if (nch==1) pl1=2; + pl2=pl1+1; + diffx_test=1000; + diffy_test=1000; + if ( fNCluster[pl1]>=1 && fNCluster[pl2]>=1 ) { + for (Int_t ic1 = 0; ic1 < fNCluster[pl1]; ic1++ ){ + for (Int_t ic2 = 0; ic2 < fNCluster[pl2]; ic2++ ){ + diffx= abs(fClusterXPos[pl1][ic1]-fClusterXPos[pl2][ic2]); + diffy= abs(fClusterYPos[pl1][ic1]-fClusterYPos[pl2][ic2]); + if ( (ic1==0 && ic2==0) || (diffx <=diffx_test && diffy <=diffy_test)) { + diffx_test=diffx; + diffy_test=diffy; + best_cluster[pl1]=ic1; + best_cluster[pl2]=ic2; + } + }} + } else { + if (fNCluster[pl1]==1) best_cluster[pl1]=0; + if (fNCluster[pl2]==1) best_cluster[pl2]=0; + } + } + // + Int_t pl_test1[4]={0,1,2,3}; + Int_t pl_test2[4]={2,3,0,1}; + for (Int_t npl = 0; npl < 4; npl++ ){ + pl1=pl_test1[npl]; + pl2=pl_test2[npl]; + if (fNCluster[pl1]>0 && best_cluster[pl1]==-1 && fNCluster[pl2]>0 && best_cluster[pl2]>-1) { + diffx_test=1000; + diffy_test=1000; + for (Int_t ic1 = 0; ic1 < fNCluster[pl1]; ic1++ ){ + diffx= abs(fClusterXPos[pl1][ic1]-fClusterXPos[pl2][best_cluster[pl2]]); + diffy= abs(fClusterYPos[pl1][ic1]-fClusterYPos[pl2][best_cluster[pl2]]); + if ( (diffx <=diffx_test && diffy <=diffy_test)) { + diffx_test=diffx; + diffy_test=diffy; + best_cluster[pl1]=ic1; + } + } + } + } + // + // + + // + for (Int_t npl = 0; npl < 4; npl++ ){ + /* + if (best_cluster[npl]==-1) { + cout << " PLane = " << npl+1 << " no best cluster " << endl; + } else { + cout << " plane = " << npl+1 << " xpos = " << fClusterXPos[npl][best_cluster[npl]] << " ypos = " << fClusterYPos[npl][best_cluster[npl]] << endl; + } + */ + if (best_cluster[npl]!=-1) fPlanes[npl]->SetScinYPos( fClusterYPos[npl][best_cluster[npl]] ); + if (best_cluster[npl]!=-1) fPlanes[npl]->SetScinXPos( fClusterXPos[npl][best_cluster[npl]] ); + } + // +} +// +void THcHodoscope::TrackEffTest(void) +{ + Double_t PadLow[4]; + Double_t PadHigh[4]; + // assume X planes are 0,2 and Y planes are 1,3 std::array<int, 4> PadLow = {fxLoScin[0], fyLoScin[0], fxLoScin[1], fyLoScin[1]}; std::array<int, 4> PadHigh = {fxHiScin[0], fyHiScin[0], fxHiScin[1], fyHiScin[1]}; diff --git a/src/THcHodoscope.h b/src/THcHodoscope.h index 1d30cb95349609d2a6f45d11770a00e08d9d79a7..42aa72a1fb8dfec305a5559f4ee2cc8eee76e201 100644 --- a/src/THcHodoscope.h +++ b/src/THcHodoscope.h @@ -76,11 +76,14 @@ public: virtual Int_t FineProcess( TClonesArray& tracks ); virtual Int_t End(THaRunBase* run=0); + Double_t DetermineTimePeak(Int_t FillFlag); void EstimateFocalPlaneTime(void); void OriginalTrackEffTest(void); void TrackEffTest(void); + void CalcCluster(void); virtual Int_t ApplyCorrections( void ); Double_t GetStartTime() const { return fStartTime; } + Double_t GetOffsetTime() const { return fOffsetTime; } Bool_t IsStartTimeGood() const {return fGoodStartTime;}; Int_t GetNfptimes() const {return fNfptimes;}; Int_t GetScinIndex(Int_t nPlane, Int_t nPaddle); @@ -192,12 +195,19 @@ protected: Bool_t fSHMS; Bool_t fGoodStartTime; Double_t fStartTime; + Double_t fADCStartTime; + Double_t fOffsetTime; Double_t fFPTimeAll; Int_t fNfptimes; Bool_t* fPresentP; - Double_t fTimeHist_Peak; - Double_t fTimeHist_Sigma; - Double_t fTimeHist_Hits; + Double_t fTimeHist_StartTime_NumPeaks; + Double_t fTimeHist_StartTime_Peak; + Double_t fTimeHist_StartTime_Sigma; + Double_t fTimeHist_StartTime_Hits; + Double_t fTimeHist_FpTime_NumPeaks; + Double_t fTimeHist_FpTime_Peak; + Double_t fTimeHist_FpTime_Sigma; + Double_t fTimeHist_FpTime_Hits; Double_t fBeta; @@ -207,7 +217,7 @@ protected: // Potential Hall C parameters. Mostly here for demonstration Int_t fNPlanes; // Number of planes - UInt_t fMaxScinPerPlane,fMaxHodoScin; // max number of scin/plane; product of the first two + UInt_t fMaxScinPerPlane,fMaxHodoScin,fTotHodScin; // max number of scin/plane; product of the first two Double_t fStartTimeCenter, fStartTimeSlop, fScinTdcToTime; Double_t fTofTolerance; Int_t fCosmicFlag; // @@ -216,6 +226,7 @@ protected: Double_t fScinTdcMin, fScinTdcMax; // min and max TDC values char** fPlaneNames; UInt_t* fNPaddle; // Number of paddles per plane + Int_t fTrackBetaIncludeSinglePmtHits; Double_t *fHodoNegAdcTimeWindowMin; Double_t *fHodoNegAdcTimeWindowMax; @@ -265,6 +276,7 @@ protected: Int_t fCheckEvent; Int_t fEventType; + Int_t fEventNum; Int_t fGoodTrack; Double_t fScin2XZpos; @@ -407,6 +419,10 @@ protected: std::vector<Int_t > fNClust; // # scins clusters for the plane std::vector<std::vector<Int_t> > fClustSize; // # scin cluster size std::vector<std::vector<Double_t> > fClustPos; // # scin cluster position + std::vector<Int_t > fNCluster; // # scins clusters for the plane + std::vector<std::vector<Int_t> > fClusterSize; // # scin cluster size + std::vector<std::vector<Double_t> > fClusterXPos; // # scin cluster position + std::vector<std::vector<Double_t> > fClusterYPos; // # scin cluster position std::vector<Int_t > fThreeScin; // # scins three clusters for the plane std::vector<Int_t > fGoodScinHitsX; // # hits in fid x range // Could combine the above into a structure diff --git a/src/THcRawAdcHit.cxx b/src/THcRawAdcHit.cxx index a5a86f4883514ae0009b3d6d94470b5afe79691e..bd8626c23d88978901d1eaa8a960a350a5a78dc0 100644 --- a/src/THcRawAdcHit.cxx +++ b/src/THcRawAdcHit.cxx @@ -258,6 +258,10 @@ void THcRawAdcHit::SetRefTime(Int_t refTime) { fHasRefTime = kTRUE; } +void THcRawAdcHit::SetRefDiffTime(Int_t refDiffTime) { + fRefDiffTime = refDiffTime; +} + void THcRawAdcHit::SetSample(Int_t data) { if (fNSamples >= fMaxNSamples) { // throw std::out_of_range("`THcRawAdcHit::SetSample`: too many samples!"); @@ -481,6 +485,22 @@ Int_t THcRawAdcHit::GetRefTime() const { } } -Bool_t THcRawAdcHit::HasRefTime() const { return fHasRefTime; } + +Int_t THcRawAdcHit::GetRefDiffTime() const { + if (fHasRefTime) { + return fRefDiffTime; + } + else { + TString msg = TString::Format( + "`THcRawAdcHit::GetRefTime`: Reference time not available!" + ); + throw std::runtime_error(msg.Data()); + } +} + +Bool_t THcRawAdcHit::HasRefTime() const { + return fHasRefTime; +} + ClassImp(THcRawAdcHit) diff --git a/src/THcRawAdcHit.h b/src/THcRawAdcHit.h index 49c9c3bb078cf4ee8d803af6647f64a9e31bd9f1..415275122d99c935d5c879b86b4486a4b6f7c725 100644 --- a/src/THcRawAdcHit.h +++ b/src/THcRawAdcHit.h @@ -16,12 +16,14 @@ class THcRawAdcHit : public podd2::HitLogging<TObject> { void SetData(Int_t data); void SetSample(Int_t data); void SetRefTime(Int_t refTime); + void SetRefDiffTime(Int_t refDiffTime); void SetDataTimePedestalPeak( Int_t data, Int_t time, Int_t pedestal, Int_t peak ); Int_t GetRawData(UInt_t iPulse=0) const; Double_t GetF250_PeakPedestalRatio() {return fPeakPedestalRatio;}; + Int_t GetF250_NPedestalSamples() {return fNPedestalSamples;}; Double_t GetAverage(UInt_t iSampleLow, UInt_t iSampleHigh) const; Int_t GetIntegral(UInt_t iSampleLow, UInt_t iSampleHigh) const; @@ -41,6 +43,7 @@ class THcRawAdcHit : public podd2::HitLogging<TObject> { Int_t GetPulseTimeRaw(UInt_t iPulse=0) const; Int_t GetSampleRaw(UInt_t iSample=0) const; Int_t GetRefTime() const; + Int_t GetRefDiffTime() const; Double_t GetPed() const; Double_t GetPulseInt(UInt_t iPulse=0) const; @@ -82,6 +85,7 @@ class THcRawAdcHit : public podd2::HitLogging<TObject> { Int_t fPulseTime[fMaxNPulses]; Int_t fSample[fMaxNSamples]; // the big buffer Int_t fRefTime; + Int_t fRefDiffTime; Bool_t fHasMulti; Bool_t fHasRefTime; diff --git a/src/THcRawDCHit.cxx b/src/THcRawDCHit.cxx index a8e9eff231bb89fc87f18346583de812624f6a06..17b23b1a2d5ea7a11bd5258caf8af4ad6f2f457b 100644 --- a/src/THcRawDCHit.cxx +++ b/src/THcRawDCHit.cxx @@ -59,6 +59,17 @@ void THcRawDCHit::SetReference(Int_t signal, Int_t reference) { } } +void THcRawDCHit::SetReferenceDiff(Int_t signal, Int_t reference) { + if (signal == 0) { + fTdcHit.SetRefDiffTime(reference); + } + else { + throw std::out_of_range( + "`THcRawDCHit::SetReference`: only signal `0` available!" + ); + } +} + Int_t THcRawDCHit::GetData(Int_t signal) { if (signal == 0) { @@ -95,6 +106,17 @@ Int_t THcRawDCHit::GetReference(Int_t signal) { } } +Int_t THcRawDCHit::GetReferenceDiff(Int_t signal) { + if (signal == 0) { + return fTdcHit.GetRefDiffTime(); + } + else { + throw std::out_of_range( + "`THcRawDCHit::GetReference`: only signal `0` available!" + ); + } +} + THcRawHit::ESignalType THcRawDCHit::GetSignalType(Int_t signal) { if (signal == 0) { diff --git a/src/THcRawDCHit.h b/src/THcRawDCHit.h index b1f315f7a8ec5387f7e33cf32686ff46fbe44cb9..363ba2d4a6b0d517ebd36b3362e94821d3f4c114 100644 --- a/src/THcRawDCHit.h +++ b/src/THcRawDCHit.h @@ -18,10 +18,12 @@ class THcRawDCHit : public THcRawHit { virtual void SetData(Int_t signal, Int_t data); virtual void SetReference(Int_t signal, Int_t reference); + virtual void SetReferenceDiff(Int_t signal, Int_t reference); virtual Int_t GetData(Int_t signal); virtual Int_t GetRawData(Int_t signal); virtual Int_t GetReference(Int_t signal); + virtual Int_t GetReferenceDiff(Int_t signal); virtual ESignalType GetSignalType(Int_t signal); virtual Int_t GetNSignals(); diff --git a/src/THcRawHit.h b/src/THcRawHit.h index b997d8555e3ba261f9eb896596d3861732be30a7..74ab5d26c20ebd3995f1a7a9b3bfcbd886df3517 100644 --- a/src/THcRawHit.h +++ b/src/THcRawHit.h @@ -38,9 +38,10 @@ public: virtual ESignalType GetSignalType(Int_t /* signal */) {return kUndefined;} virtual Int_t GetNSignals() { return 1;} - virtual void SetReference(Int_t /* signal */, Int_t /* reference */) {}; - virtual Bool_t HasReference(Int_t /* signal */) {return kFALSE;}; - virtual Int_t GetReference(Int_t /* signal */) {return 0;}; + virtual void SetReference(Int_t signal, Int_t reference) {}; + virtual void SetReferenceDiff(Int_t signal, Int_t reference) {}; + virtual Bool_t HasReference(Int_t signal) {return kFALSE;}; + virtual Int_t GetReference(Int_t signal) {return 0;}; virtual void SetF250Params(Int_t /* NSA */, Int_t /* NSB */, Int_t /* NPED */) {}; diff --git a/src/THcRawHodoHit.cxx b/src/THcRawHodoHit.cxx index 2e7c84ce3145748a1665ea9b350348ed8a2a5719..848f88ddc908e29313a2dc362c279b1ad0c48826 100644 --- a/src/THcRawHodoHit.cxx +++ b/src/THcRawHodoHit.cxx @@ -105,6 +105,18 @@ void THcRawHodoHit::SetReference(Int_t signal, Int_t reference) { } } +void THcRawHodoHit::SetReferenceDiff(Int_t signal, Int_t referenceDiff) { + if (signal < fNAdcSignals) { + fAdcHits[signal].SetRefDiffTime(referenceDiff); + } else if (signal < fNAdcSignals+fNTdcSignals) { + fTdcHits[signal-fNAdcSignals].SetRefDiffTime(referenceDiff); + } else { + throw std::out_of_range( + "`THcRawHodoHit::SetReference`: only signals `2` and `3` available!" + ); + } +} + Int_t THcRawHodoHit::GetData(Int_t signal) { if (0 <= signal && signal < fNAdcSignals) { @@ -147,6 +159,17 @@ Int_t THcRawHodoHit::GetReference(Int_t signal) { } } +Int_t THcRawHodoHit::GetReferenceDiff(Int_t signal) { + if (fNAdcSignals <= signal && signal < fNAdcSignals+fNTdcSignals) { + return fTdcHits[signal-fNAdcSignals].GetRefDiffTime(); + } + else { + throw std::out_of_range( + "`THcRawHodoHit::GetReference`: only signals `2` and `3` available!" + ); + } +} + THcRawHit::ESignalType THcRawHodoHit::GetSignalType(Int_t signal) { if (0 <= signal && signal < fNAdcSignals) { diff --git a/src/THcRawHodoHit.h b/src/THcRawHodoHit.h index dc2528f6e81267b295150d97a95534d34af475b9..025e0ae2c96cc1ce94fa35c6c17972c9a50ab261 100644 --- a/src/THcRawHodoHit.h +++ b/src/THcRawHodoHit.h @@ -25,10 +25,12 @@ class THcRawHodoHit : public THcRawHit { Int_t signal, Int_t data, Int_t time, Int_t pedestal, Int_t peak ); virtual void SetReference(Int_t signal, Int_t reference); + virtual void SetReferenceDiff(Int_t signal, Int_t referenceDiff); virtual Int_t GetData(Int_t signal); virtual Int_t GetRawData(Int_t signal); virtual Int_t GetReference(Int_t signal); + virtual Int_t GetReferenceDiff(Int_t signal); virtual ESignalType GetSignalType(Int_t signal); virtual Int_t GetNSignals(); diff --git a/src/THcRawShowerHit.cxx b/src/THcRawShowerHit.cxx index 1a32508ed78b6546db327c244291e68dd5f67609..043de13b4795d34acdd5b16b4e908cbf7d0a5e05 100644 --- a/src/THcRawShowerHit.cxx +++ b/src/THcRawShowerHit.cxx @@ -92,6 +92,16 @@ void THcRawShowerHit::SetReference(Int_t signal, Int_t reference) { } } +void THcRawShowerHit::SetReferenceDiff(Int_t signal, Int_t reference) { + if (signal < fNAdcSignals) { + fAdcHits[signal].SetRefDiffTime(reference); + } else { + throw std::out_of_range( + "`THcRawHodoHit::SetReference`: only signals `2` and `3` available!" + ); + } +} + Int_t THcRawShowerHit::GetData(Int_t signal) { if (0 <= signal && signal < fNAdcSignals) { diff --git a/src/THcRawShowerHit.h b/src/THcRawShowerHit.h index 9008831e54362303bed9a48474ed0ccbd5a6ac85..c1a4fd871f4f5424dd55af16afbc8ca4f0e97353 100644 --- a/src/THcRawShowerHit.h +++ b/src/THcRawShowerHit.h @@ -22,6 +22,7 @@ class THcRawShowerHit : public THcRawHit { Int_t signal, Int_t data, Int_t time, Int_t pedestal, Int_t peak ); virtual void SetReference(Int_t signal, Int_t reference); + virtual void SetReferenceDiff(Int_t signal, Int_t reference); virtual Int_t GetData(Int_t signal); virtual Int_t GetRawData(Int_t signal); diff --git a/src/THcRawTdcHit.cxx b/src/THcRawTdcHit.cxx index d2ec274f8ca979f901d71c933a54193c13bd882a..38fb647078489d95cdf65f444ff5ce17cbff7bbf 100644 --- a/src/THcRawTdcHit.cxx +++ b/src/THcRawTdcHit.cxx @@ -95,6 +95,7 @@ THcRawTdcHit& THcRawTdcHit::operator=(const THcRawTdcHit& right) { fTime[iHit] = right.fTime[iHit]; } fRefTime = right.fRefTime; + fRefDiffTime = right.fRefDiffTime; fHasRefTime = right.fHasRefTime; fNHits = right.fNHits; } @@ -113,6 +114,7 @@ void THcRawTdcHit::Clear(Option_t* opt) { fTime[iHit] = 0; } fRefTime = 0; + fRefDiffTime = 0; fHasRefTime = kFALSE; fNHits = 0; } @@ -138,6 +140,10 @@ void THcRawTdcHit::SetRefTime(Int_t refTime) { fHasRefTime = kTRUE; } +void THcRawTdcHit::SetRefDiffTime(Int_t refDiffTime) { + fRefDiffTime = refDiffTime; +} + Int_t THcRawTdcHit::GetTimeRaw(UInt_t iHit) const { if (iHit < fNHits) { @@ -177,6 +183,18 @@ Int_t THcRawTdcHit::GetRefTime() const { } } +Int_t THcRawTdcHit::GetRefDiffTime() const { + if (fHasRefTime) { + return fRefDiffTime; + } + else { + TString msg = TString::Format( + "`THcRawTdcHit::GetRefDiffTime`: Reference time not available!" + ); + throw std::runtime_error(msg.Data()); + } +} + Bool_t THcRawTdcHit::HasRefTime() const { return fHasRefTime; diff --git a/src/THcRawTdcHit.h b/src/THcRawTdcHit.h index c930f2772f4fe96e7229e4cc05a2406ba9c8a08c..91e7eba4b5f4bd81522d836d2a88c9e9586c1fb6 100644 --- a/src/THcRawTdcHit.h +++ b/src/THcRawTdcHit.h @@ -14,10 +14,12 @@ class THcRawTdcHit : public TObject { void SetTime(Int_t time); void SetRefTime(Int_t refTime); + void SetRefDiffTime(Int_t refDiffTime); Int_t GetTimeRaw(UInt_t iHit=0) const; Int_t GetTime(UInt_t iHit=0) const; Int_t GetRefTime() const; + Int_t GetRefDiffTime() const; Bool_t HasRefTime() const; @@ -30,6 +32,7 @@ class THcRawTdcHit : public TObject { Int_t fTime[fMaxNHits]; Int_t fRefTime; + Int_t fRefDiffTime; Bool_t fHasRefTime; UInt_t fNHits; diff --git a/src/THcScintillatorPlane.cxx b/src/THcScintillatorPlane.cxx index 1e4578907372a505e9b7f832e44d1e116353ff17..e584f856735d60ba85813ea551f9c162b8eccb47 100644 --- a/src/THcScintillatorPlane.cxx +++ b/src/THcScintillatorPlane.cxx @@ -534,11 +534,21 @@ Int_t THcScintillatorPlane::DefineVariables( EMode mode ) {"DiffDisTrackCorr", "TW Corrected Dist Difference between track and scintillator position (cm)", "fGoodDiffDistTrack"}, {"TrackXPos", "Track X position at plane (cm)", "fTrackXPosition"}, {"TrackYPos", "Track Y position at plane (cm)", "fTrackYPosition"}, + {"ScinXPos", "Scint Average Y position at plane (cm)", "fScinXPos"}, + {"ScinYPos", "Scint Average Xposition at plane (cm)", "fScinYPos"}, {"NumClus", "Number of clusters", "fNumberClusters"}, {"Clus.Pos", "Position of each paddle clusters", "fCluster.THcScintPlaneCluster.GetClusterPosition()"}, {"Clus.Size", "Size of each paddle clusters", "fCluster.THcScintPlaneCluster.GetClusterSize()"}, {"Clus.Flag", "Flag of each paddle clusters", "fCluster.THcScintPlaneCluster.GetClusterFlag()"}, {"Clus.UsedFlag", "USed Flag of each paddle clusters", "fCluster.THcScintPlaneCluster.GetClusterUsedFlag()"}, + {"PosTdcRefTime", "Reference time of Pos TDC", "fPosTdcRefTime"}, + {"NegTdcRefTime", "Reference time of Neg TDC", "fNegTdcRefTime"}, + {"PosAdcRefTime", "Reference time of Pos ADC", "fPosAdcRefTime"}, + {"NegAdcRefTime", "Reference time of Neg aDC", "fNegAdcRefTime"}, + {"PosTdcRefDiffTime", "Reference Diff time of Pos TDC", "fPosTdcRefDiffTime"}, + {"NegTdcRefDiffTime", "Reference Diff time of Neg TDC", "fNegTdcRefDiffTime"}, + {"PosAdcRefDiffTime", "Reference Diff time of Pos ADC", "fPosAdcRefDiffTime"}, + {"NegAdcRefDiffTime", "Reference Diff time of Neg aDC", "fNegAdcRefDiffTime"}, //{"ngoodhits", "Number of paddle hits (passed tof tolerance and used to determine the focal plane time )", "GetNGoodHits() "}, { 0 } }; @@ -643,9 +653,19 @@ void THcScintillatorPlane::Clear( Option_t* ) fpTime = -1.e4; fHitDistance = kBig; + fScinYPos = kBig; + fScinXPos = kBig; fTrackXPosition = kBig; fTrackYPosition = kBig; fNumberClusters=0; + fPosTdcRefTime = kBig; + fPosAdcRefTime = kBig; + fNegTdcRefTime = kBig; + fNegAdcRefTime = kBig; + fPosTdcRefDiffTime = kBig; + fPosAdcRefDiffTime = kBig; + fNegTdcRefDiffTime = kBig; + fNegAdcRefDiffTime = kBig; } //_____________________________________________________________________________ @@ -700,6 +720,14 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) * */ //raw + fPosTdcRefTime = kBig; + fPosAdcRefTime = kBig; + fNegTdcRefTime = kBig; + fNegAdcRefTime = kBig; + fPosTdcRefDiffTime = kBig; + fPosAdcRefDiffTime = kBig; + fNegTdcRefDiffTime = kBig; + fNegAdcRefDiffTime = kBig; Int_t nrPosTDCHits=0; Int_t nrNegTDCHits=0; Int_t nrPosADCHits=0; @@ -774,6 +802,7 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) // might include multiple hits if it uses a multihit tdc. // Use "ihit" as the index over THcRawHodoHit objects. Use // "thit" to index over multiple tdc hits within an "ihit". + Bool_t problem_flag=kFALSE; while(ihit < nrawhits) { THcRawHodoHit* hit = (THcRawHodoHit *) rawhits->At(ihit); if(hit->fPlane > fPlaneNum) { @@ -784,8 +813,17 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) Int_t index=padnum-1; - THcRawTdcHit& rawPosTdcHit = hit->GetRawTdcHitPos(); + if (rawPosTdcHit.GetNHits() >0 && rawPosTdcHit.HasRefTime()) { + if (fPosTdcRefTime == kBig) { + fPosTdcRefTime=rawPosTdcHit.GetRefTime() ; + fPosTdcRefDiffTime=rawPosTdcHit.GetRefDiffTime() ; + } + if (fPosTdcRefTime != rawPosTdcHit.GetRefTime()) { + cout << "THcScintillatorPlane: " << GetName() << " reftime problem at paddle num = " << padnum << " TDC pos hits = " << rawPosTdcHit.GetNHits() << endl; + problem_flag=kTRUE; + } + } for (UInt_t thit=0; thit<rawPosTdcHit.GetNHits(); ++thit) { ((THcSignalHit*) frPosTdcTimeRaw->ConstructedAt(nrPosTdcHits))->Set(padnum, rawPosTdcHit.GetTimeRaw(thit)); ((THcSignalHit*) frPosTdcTime->ConstructedAt(nrPosTdcHits))->Set(padnum, rawPosTdcHit.GetTime(thit)); @@ -794,6 +832,17 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) fTotNumPosTdcHits++; } THcRawTdcHit& rawNegTdcHit = hit->GetRawTdcHitNeg(); + if (rawNegTdcHit.GetNHits() >0 && rawNegTdcHit.HasRefTime()) { + if (fNegTdcRefTime == kBig) { + fNegTdcRefTime=rawNegTdcHit.GetRefTime() ; + fNegTdcRefDiffTime=rawNegTdcHit.GetRefDiffTime() ; + } + if (fNegTdcRefTime != rawNegTdcHit.GetRefTime()) { + cout << "THcScintillatorPlane: " << GetName()<< " Neg TDC reftime problem at paddle num = " << padnum << " TDC neg hits = " << rawNegTdcHit.GetNHits() << endl; + problem_flag=kTRUE; + } + } + // cout << " paddle num = " << padnum << " TDC Neg hits = " << rawNegTdcHit.GetNHits() << endl; for (UInt_t thit=0; thit<rawNegTdcHit.GetNHits(); ++thit) { ((THcSignalHit*) frNegTdcTimeRaw->ConstructedAt(nrNegTdcHits))->Set(padnum, rawNegTdcHit.GetTimeRaw(thit)); ((THcSignalHit*) frNegTdcTime->ConstructedAt(nrNegTdcHits))->Set(padnum, rawNegTdcHit.GetTime(thit)); @@ -802,6 +851,17 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) fTotNumNegTdcHits++; } THcRawAdcHit& rawPosAdcHit = hit->GetRawAdcHitPos(); + if (rawPosAdcHit.GetNPulses() >0 && rawPosAdcHit.HasRefTime()) { + if (fPosAdcRefTime == kBig ) { + fPosAdcRefTime=rawPosAdcHit.GetRefTime() ; + fPosAdcRefDiffTime=rawPosAdcHit.GetRefDiffTime() ; + } + if (fPosAdcRefTime != rawPosAdcHit.GetRefTime()) { + cout << "THcScintillatorPlane: " << GetName()<< " Pos ADC reftime problem at paddle num = " << padnum << " ADC pos hits = " << rawPosAdcHit.GetNPulses() << endl; + problem_flag=kTRUE; + } + } + // cout << " paddle num = " << padnum << " ADC Pos hits = " << rawPosAdcHit.GetNPulses() << endl; for (UInt_t thit=0; thit<rawPosAdcHit.GetNPulses(); ++thit) { ((THcSignalHit*) frPosAdcPedRaw->ConstructedAt(nrPosAdcHits))->Set(padnum, rawPosAdcHit.GetPedRaw()); ((THcSignalHit*) frPosAdcPed->ConstructedAt(nrPosAdcHits))->Set(padnum, rawPosAdcHit.GetPed()); @@ -824,6 +884,17 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) fTotNumPosAdcHits++; } THcRawAdcHit& rawNegAdcHit = hit->GetRawAdcHitNeg(); + if (rawNegAdcHit.GetNPulses()>0 && rawNegAdcHit.HasRefTime()) { + if (fNegAdcRefTime == kBig) { + fNegAdcRefTime=rawNegAdcHit.GetRefTime() ; + fNegAdcRefDiffTime=rawNegAdcHit.GetRefDiffTime() ; + } + if (fNegAdcRefTime != rawNegAdcHit.GetRefTime()) { + cout << "THcScintillatorPlane: " << GetName()<< " Neg ADC reftime problem at paddle num = " << padnum << " TDC pos hits = " << rawNegAdcHit.GetNPulses() << endl; + problem_flag=kTRUE; + } + } + // cout << " paddle num = " << padnum << " ADC Neg hits = " << rawNegAdcHit.GetNPulses() << endl; for (UInt_t thit=0; thit<rawNegAdcHit.GetNPulses(); ++thit) { ((THcSignalHit*) frNegAdcPedRaw->ConstructedAt(nrNegAdcHits))->Set(padnum, rawNegAdcHit.GetPedRaw()); ((THcSignalHit*) frNegAdcPed->ConstructedAt(nrNegAdcHits))->Set(padnum, rawNegAdcHit.GetPed()); @@ -882,7 +953,7 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) if(tdc_pos >= fScinTdcMin && tdc_pos <= fScinTdcMax) { btdcraw_pos = kTRUE; good_ielem_postdc = thit; - break; + break; } } for(UInt_t thit=0; thit<hit->GetRawTdcHitNeg().GetNHits(); thit++) { @@ -890,58 +961,86 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) if(tdc_neg >= fScinTdcMin && tdc_neg <= fScinTdcMax) { btdcraw_neg = kTRUE; good_ielem_negtdc = thit; - break; + break; } } // if(fADCMode == kADCDynamicPedestal) { + Int_t good_ielem_negadc_test2=-1; + Int_t good_ielem_posadc_test2=-1; //Loop Here over all hits per event for neg side of plane if (good_ielem_negtdc != -1) { + Double_t max_adcamp_test=-1000.; + Double_t max_adctdcdiff_test=1000.; for (UInt_t ielem=0;ielem<rawNegAdcHit.GetNPulses();ielem++) { - Double_t pulsePed = rawNegAdcHit.GetPed(); - Double_t pulseInt = rawNegAdcHit.GetPulseInt(ielem); Double_t pulseAmp = rawNegAdcHit.GetPulseAmp(ielem); Double_t pulseTime = rawNegAdcHit.GetPulseTime(ielem)+fAdcTdcOffset; - Bool_t errorflag = 0 ; Double_t TdcAdcTimeDiff = tdc_neg*fScinTdcToTime-pulseTime; - if (rawNegAdcHit.GetPulseAmpRaw(ielem) <= 0) errorflag=1; + if (rawNegAdcHit.GetPulseAmpRaw(ielem) <= 0)pulseAmp= 200.; Bool_t pulseTimeCut =( TdcAdcTimeDiff > fHodoNegAdcTimeWindowMin[index]) && (TdcAdcTimeDiff < fHodoNegAdcTimeWindowMax[index]); - if (!errorflag && pulseTimeCut && adcint_neg == -999) { - adcped_neg = pulsePed; - adcmult_neg = rawNegAdcHit.GetNPulses(); - adchitused_neg = ielem+1; - adcint_neg = pulseInt; - adcamp_neg = pulseAmp; - adctime_neg = pulseTime; - badcraw_neg = kTRUE; + if (pulseTimeCut && pulseAmp>max_adcamp_test) { good_ielem_negadc = ielem; - adctdcdifftime_neg=TdcAdcTimeDiff; + max_adcamp_test=pulseAmp; + } + if (abs(TdcAdcTimeDiff) < max_adctdcdiff_test) { + good_ielem_negadc_test2 = ielem; + max_adctdcdiff_test=abs(TdcAdcTimeDiff); } } } + + // + if ( good_ielem_negadc == -1 && good_ielem_negadc_test2 != -1) good_ielem_negadc=good_ielem_negadc_test2; + if ( good_ielem_negadc == -1 && good_ielem_negadc_test2 == -1 && rawNegAdcHit.GetNPulses()>0) { + good_ielem_negadc=0; + } + // + if (good_ielem_negadc != -1 && good_ielem_negadc<rawNegAdcHit.GetNPulses()) { + adcped_neg = rawNegAdcHit.GetPed(); + adcmult_neg = rawNegAdcHit.GetNPulses(); + adchitused_neg = good_ielem_negadc+1; + adcint_neg = rawNegAdcHit.GetPulseInt(good_ielem_negadc); + adcamp_neg = rawNegAdcHit.GetPulseAmp(good_ielem_negadc); + if (rawNegAdcHit.GetPulseAmpRaw(good_ielem_negadc) <= 0) adcamp_neg= 200.; + adctime_neg = rawNegAdcHit.GetPulseTime(good_ielem_negadc)+fAdcTdcOffset; + badcraw_neg = kTRUE; + adctdcdifftime_neg=tdc_neg*fScinTdcToTime-adctime_neg; + } + // //Loop Here over all hits per event for pos side of plane if (good_ielem_postdc != -1) { + Double_t max_adcamp_test=-1000.; + Double_t max_adctdcdiff_test=1000.; + // for (UInt_t ielem=0;ielem<rawPosAdcHit.GetNPulses();ielem++) { - Double_t pulsePed = rawPosAdcHit.GetPed(); - Double_t pulseInt = rawPosAdcHit.GetPulseInt(ielem); Double_t pulseAmp = rawPosAdcHit.GetPulseAmp(ielem); Double_t pulseTime = rawPosAdcHit.GetPulseTime(ielem)+fAdcTdcOffset; - Bool_t errorflag = 0 ; Double_t TdcAdcTimeDiff = tdc_pos*fScinTdcToTime-pulseTime; - if (rawPosAdcHit.GetPulseAmpRaw(ielem) <= 0) errorflag=1; Bool_t pulseTimeCut =( TdcAdcTimeDiff > fHodoPosAdcTimeWindowMin[index]) && (TdcAdcTimeDiff < fHodoPosAdcTimeWindowMax[index]); - if (!errorflag && pulseTimeCut && adcint_pos == -999) { - adcped_pos = pulsePed; - adcmult_pos = rawPosAdcHit.GetNPulses(); - adchitused_pos = ielem+1; - adcint_pos = pulseInt; - adcamp_pos = pulseAmp; - adctime_pos = pulseTime; - badcraw_pos = kTRUE; + if (rawPosAdcHit.GetPulseAmpRaw(ielem) <= 0)pulseAmp= 200.; + if (pulseTimeCut && pulseAmp>max_adcamp_test) { good_ielem_posadc = ielem; - adctdcdifftime_pos=TdcAdcTimeDiff; + max_adcamp_test=pulseAmp; + } + if (abs(TdcAdcTimeDiff) < max_adctdcdiff_test) { + good_ielem_posadc_test2 = ielem; + max_adctdcdiff_test=abs(TdcAdcTimeDiff); } } + } // + if ( good_ielem_posadc == -1 && good_ielem_posadc_test2 != -1) good_ielem_posadc=good_ielem_posadc_test2; + if ( good_ielem_posadc == -1 && good_ielem_posadc_test2 == -1 && rawPosAdcHit.GetNPulses()>0) good_ielem_posadc=0; + if (good_ielem_posadc != -1 && good_ielem_posadc<rawPosAdcHit.GetNPulses()) { + adcped_pos = rawPosAdcHit.GetPed(); + adcmult_pos = rawPosAdcHit.GetNPulses(); + adchitused_pos = good_ielem_posadc+1; + adcint_pos = rawPosAdcHit.GetPulseInt(good_ielem_posadc); + adcamp_pos = rawPosAdcHit.GetPulseAmp(good_ielem_posadc); + if (rawPosAdcHit.GetPulseAmpRaw(good_ielem_posadc) <= 0) adcamp_pos= 200.; + adctime_pos = rawPosAdcHit.GetPulseTime(good_ielem_posadc)+fAdcTdcOffset; + badcraw_pos = kTRUE; + adctdcdifftime_pos=tdc_pos*fScinTdcToTime-adctime_pos; + // } } else if (fADCMode == kADCSampleIntegral) { adcint_pos = hit->GetRawAdcHitPos().GetSampleIntRaw() - fPosPed[index]; @@ -972,7 +1071,7 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) } // if((btdcraw_pos && badcraw_pos) || (btdcraw_neg && badcraw_neg )) { - if (good_ielem_posadc != -1) { + if (good_ielem_posadc != -1) { //good adc multiplicity fTotNumGoodPosAdcHits++; fTotNumGoodAdcHits++; @@ -1045,9 +1144,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 @@ -1059,6 +1161,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); @@ -1077,6 +1181,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]; @@ -1091,23 +1197,32 @@ 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]); ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetCorrectedTimes(timec_pos,timec_neg, postime, negtime, scin_corrected_time); - ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetPosADCpeak(adcamp_pos); // need for new TWCOrr - ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetNegADCpeak(adcamp_neg); // need for new TWCOrr + ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetPosADCpeak(adcamp_pos); + ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetNegADCpeak(adcamp_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; fGoodNegTdcTimeCorr.at(padnum-1) = timec_neg; fGoodPosTdcTimeTOFCorr.at(padnum-1) = postime; @@ -1138,14 +1253,24 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) 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))->SetCorrectedTimes(timec_pos,timec_neg); ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetNegADCpeak(adc_neg); // needed for new TWCOrr ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetPosADCpeak(adc_pos); // needed for new TWCOrr + if (badcraw_neg) { + ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetNegADCtime(adctime_neg); + } else { + ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetNegADCtime(-999.); + } + if (badcraw_pos) { + ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetPosADCtime(adctime_pos); + } else { + ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetPosADCtime(-999.); + } + ((THcHodoHit*) fHodoHits->At(fNScinHits))->SetCalcPosition(kBig); // fGoodPosTdcTimeCorr.at(padnum-1) = timec_pos; fGoodNegTdcTimeCorr.at(padnum-1) = timec_neg; - fGoodPosTdcTimeTOFCorr.at(padnum-1) = timec_pos; - fGoodNegTdcTimeTOFCorr.at(padnum-1) = timec_neg; + fGoodPosTdcTimeTOFCorr.at(padnum-1) = kBig; + fGoodNegTdcTimeTOFCorr.at(padnum-1) = kBig; } // 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 @@ -1154,7 +1279,10 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) ihit++; // Raw hit counter } // cout << "THcScintillatorPlane: ihit = " << ihit << endl; - + if (problem_flag) { + cout << "THcScintillatorPlane::ProcessHits " << fPlaneNum << " " << nexthit << "/" << nrawhits << endl; +cout << " Ref problem end *******" << endl; + } return(ihit); } diff --git a/src/THcScintillatorPlane.h b/src/THcScintillatorPlane.h index 052ac9512ee1b7706824a5f0eb4562706a57fdbf..265ec190996fbdeb37d8bbd9699a79f38ca90560 100644 --- a/src/THcScintillatorPlane.h +++ b/src/THcScintillatorPlane.h @@ -63,6 +63,8 @@ class THcScintillatorPlane : public THaSubDetector { void SetFpTime(Double_t f) {fFptime=f;}; void SetNGoodHits(Int_t ng) {fNGoodHits=ng;}; void SetHitDistance(Double_t f) {fHitDistance=f;}; // Distance between track and hit paddle + void SetScinYPos(Double_t f) {fScinYPos=f;}; // Scint Average Y position at plane (cm) + void SetScinXPos(Double_t f) {fScinXPos=f;}; // Scint Average X position at plane (cm) void SetTrackXPosition(Double_t f) {fTrackXPosition=f;}; // Distance track X position at plane void SetTrackYPosition(Double_t f) {fTrackYPosition=f;}; // Distance track Y position at plane void SetNumberClusters(Int_t nclus) {fNumberClusters=nclus;}; // number of paddle @@ -181,7 +183,17 @@ class THcScintillatorPlane : public THaSubDetector { vector<Double_t> fGoodDiffDistTrack; Int_t fDebugAdc; + Double_t fPosTdcRefTime; + Double_t fPosAdcRefTime; + Double_t fNegTdcRefTime; + Double_t fNegAdcRefTime; + Double_t fPosTdcRefDiffTime; + Double_t fPosAdcRefDiffTime; + Double_t fNegTdcRefDiffTime; + Double_t fNegAdcRefDiffTime; Double_t fHitDistance; + Double_t fScinXPos; + Double_t fScinYPos; Double_t fTrackXPosition; Double_t fTrackYPosition; Int_t fCosmicFlag; // @@ -272,7 +284,10 @@ class THcScintillatorPlane : public THaSubDetector { Double_t *fNegPed; Double_t *fNegSig; Double_t *fNegThresh; - + // + Int_t fEventType; + Int_t fEventNum; + // Int_t fNScinGoodHits; // number of hits for which both ends of the paddle fired in time! Double_t fpTime; // the original code only has one fpTime per plane! diff --git a/src/THcShower.cxx b/src/THcShower.cxx index b7d6590ed4b4dc9eaba61261f0c8ed1e95a829fd..81b387bc4d990ac1b6b88b5b995c0323c5faac73 100644 --- a/src/THcShower.cxx +++ b/src/THcShower.cxx @@ -36,6 +36,7 @@ THcShower::THcShower( const char* name, const char* description, hcana::ConfigLogging<THaNonTrackingDetector>(name,description,apparatus), fPosAdcTimeWindowMin(0), fNegAdcTimeWindowMin(0), fPosAdcTimeWindowMax(0), fNegAdcTimeWindowMax(0), + fPedPosDefault(0),fPedNegDefault(0), fShPosPedLimit(0), fShNegPedLimit(0), fPosGain(0), fNegGain(0), fClusterList(0), fLayerNames(0), fLayerZPos(0), BlockThick(0), fNBlocks(0), fXPos(0), fYPos(0), fZPos(0), fPlanes(0), fArray(0) @@ -53,6 +54,7 @@ THcShower::THcShower( ) : hcana::ConfigLogging<THaNonTrackingDetector>(), fPosAdcTimeWindowMin(0), fNegAdcTimeWindowMin(0), fPosAdcTimeWindowMax(0), fNegAdcTimeWindowMax(0), + fPedPosDefault(0),fPedNegDefault(0), fShPosPedLimit(0), fShNegPedLimit(0), fPosGain(0), fNegGain(0), fClusterList(0), fLayerNames(0), fLayerZPos(0), BlockThick(0), fNBlocks(0), fXPos(0), fYPos(0), fZPos(0), fPlanes(0), fArray(0) @@ -388,6 +390,8 @@ Int_t THcShower::ReadDatabase( const TDatime& date ) fNegAdcTimeWindowMin = new Double_t [fNTotBlocks]; fPosAdcTimeWindowMax = new Double_t [fNTotBlocks]; fNegAdcTimeWindowMax = new Double_t [fNTotBlocks]; + fPedPosDefault = new Int_t [fNTotBlocks]; + fPedNegDefault = new Int_t [fNTotBlocks]; DBRequest list[]={ {"cal_pos_cal_const", hcal_pos_cal_const, kDouble, fNTotBlocks}, @@ -400,6 +404,8 @@ Int_t THcShower::ReadDatabase( const TDatime& date ) {"cal_neg_AdcTimeWindowMin", fNegAdcTimeWindowMin, kDouble, static_cast<UInt_t>(fNTotBlocks),1}, {"cal_pos_AdcTimeWindowMax", fPosAdcTimeWindowMax, kDouble, static_cast<UInt_t>(fNTotBlocks),1}, {"cal_neg_AdcTimeWindowMax", fNegAdcTimeWindowMax, kDouble, static_cast<UInt_t>(fNTotBlocks),1}, + {"cal_PedNegDefault", fPedNegDefault, kInt, static_cast<UInt_t>(fNTotBlocks),1}, + {"cal_PedPosDefault", fPedNegDefault, kInt, static_cast<UInt_t>(fNTotBlocks),1}, {"cal_min_peds", &fShMinPeds, kInt,0,1}, {0} }; @@ -410,6 +416,8 @@ Int_t THcShower::ReadDatabase( const TDatime& date ) fNegAdcTimeWindowMin[ip] = -1000.; fPosAdcTimeWindowMax[ip] = 1000.; fNegAdcTimeWindowMax[ip] = 1000.; + fPedNegDefault[ip] = 0; + fPedPosDefault[ip] = 0; } gHcParms->LoadParmValues((DBRequest*)&list, prefix); @@ -617,6 +625,8 @@ void THcShower::DeleteArrays() delete [] fNegAdcTimeWindowMin; fNegAdcTimeWindowMin = 0; delete [] fPosAdcTimeWindowMax; fPosAdcTimeWindowMax = 0; delete [] fNegAdcTimeWindowMax; fNegAdcTimeWindowMax = 0; + delete [] fPedNegDefault; fPedNegDefault = 0; + delete [] fPedPosDefault; fPedPosDefault = 0; delete [] fShPosPedLimit; fShPosPedLimit = 0; delete [] fShNegPedLimit; fShNegPedLimit = 0; delete [] fPosGain; fPosGain = 0; diff --git a/src/THcShower.h b/src/THcShower.h index a2aaf7ffab64ede1b97ce40dbb81abe5564a84f5..a5ab4395ca3e48861d5888c2d3178f6762461f6f 100644 --- a/src/THcShower.h +++ b/src/THcShower.h @@ -73,6 +73,17 @@ public: return ( Side == 0 ? fPosGain[nelem] : fNegGain[nelem]); } + Double_t GetPedDefault(Int_t NBlock, Int_t NLayer, Int_t Side) { + if (Side!=0&&Side!=1) { + cout << "*** Wrong Side in GetPedDefault:" << Side << " ***" << endl; + return -1; + } + Int_t nelem = 0; + for (Int_t i=0; i<NLayer; i++) nelem += fNBlocks[i]; + nelem += NBlock; + return ( Side == 0 ? fPedPosDefault[nelem] : fPedNegDefault[nelem] ); + } + Double_t GetWindowMin(Int_t NBlock, Int_t NLayer, Int_t Side) { if (Side!=0&&Side!=1) { cout << "*** Wrong Side in GetWindowMin:" << Side << " ***" << endl; @@ -189,7 +200,9 @@ protected: Double_t* fNegAdcTimeWindowMin; Double_t* fPosAdcTimeWindowMax; Double_t* fNegAdcTimeWindowMax; - Double_t fAdcTdcOffset; + Int_t* fPedPosDefault; + Int_t* fPedNegDefault; + Double_t fAdcTdcOffset; Int_t fAnalyzePedestals; // Flag for pedestal analysis. diff --git a/src/THcShowerArray.cxx b/src/THcShowerArray.cxx index b1817da04863c6fd43c08fc0015ef20ffca363f0..2f1170e26d62bfec508b3dee665c2c470dbe664f 100644 --- a/src/THcShowerArray.cxx +++ b/src/THcShowerArray.cxx @@ -105,6 +105,7 @@ THcShowerArray::~THcShowerArray() delete [] fAdcTimeWindowMin; fAdcTimeWindowMin = 0; delete [] fAdcTimeWindowMax; fAdcTimeWindowMax = 0; + delete [] fPedDefault; fPedDefault = 0; } //_____________________________________________________________________________ @@ -280,6 +281,7 @@ Int_t THcShowerArray::ReadDatabase( const TDatime& date ) fAdcTimeWindowMin = new Double_t [fNelem]; fAdcTimeWindowMax = new Double_t [fNelem]; + fPedDefault = new Int_t [fNelem]; DBRequest list1[]={ {"cal_arr_ped_limit", fPedLimit, kInt, static_cast<UInt_t>(fNelem),1}, @@ -287,12 +289,14 @@ Int_t THcShowerArray::ReadDatabase( const TDatime& date ) {"cal_arr_gain_cor", cal_arr_gain_cor, kDouble, static_cast<UInt_t>(fNelem)}, {"cal_arr_AdcTimeWindowMin", fAdcTimeWindowMin, kDouble, static_cast<UInt_t>(fNelem),1}, {"cal_arr_AdcTimeWindowMax", fAdcTimeWindowMax, kDouble, static_cast<UInt_t>(fNelem),1}, + {"cal_arr_PedDefault", fPedDefault, kInt, static_cast<UInt_t>(fNelem),1}, {0} }; for(Int_t ip=0;ip<fNelem;ip++) { fAdcTimeWindowMin[ip] = -1000.; fAdcTimeWindowMax[ip] = 1000.; + fPedDefault[ip] = 0; } gHcParms->LoadParmValues((DBRequest*)&list1, prefix); @@ -873,6 +877,8 @@ void THcShowerArray::FillADC_DynamicPedestal() { Double_t StartTime = 0.0; if( fglHod ) StartTime = fglHod->GetStartTime(); + Double_t OffsetTime = 0.0; + if( fglHod ) OffsetTime = fglHod->GetOffsetTime(); for (Int_t ielem=0;ielem<frAdcPulseInt->GetEntries();ielem++) { Int_t npad = ((THcSignalHit*) frAdcPulseInt->ConstructedAt(ielem))->GetPaddleNumber() - 1; @@ -881,15 +887,10 @@ void THcShowerArray::FillADC_DynamicPedestal() Double_t pulseInt = ((THcSignalHit*) frAdcPulseInt->ConstructedAt(ielem))->GetData(); Double_t pulseAmp = ((THcSignalHit*) frAdcPulseAmp->ConstructedAt(ielem))->GetData(); Double_t pulseTime = ((THcSignalHit*) frAdcPulseTime->ConstructedAt(ielem))->GetData(); - Double_t adctdcdiffTime = StartTime-pulseTime; - Bool_t errorflag = ((THcSignalHit*) frAdcErrorFlag->ConstructedAt(ielem))->GetData(); + Double_t adctdcdiffTime = StartTime-pulseTime+OffsetTime; Bool_t pulseTimeCut = (adctdcdiffTime > fAdcTimeWindowMin[npad]) && (adctdcdiffTime < fAdcTimeWindowMax[npad]); - - if (!errorflag) - { fGoodAdcMult.at(npad) += 1; - } - if (!errorflag && pulseTimeCut) { + if (pulseTimeCut) { fTotNumAdcHits++; fGoodAdcPulseIntRaw.at(npad) = pulseIntRaw; @@ -982,6 +983,24 @@ Int_t THcShowerArray::ProcessHits(TClonesArray* rawhits, Int_t nexthit) } else { ((THcSignalHit*) frAdcErrorFlag->ConstructedAt(nrAdcHits))->Set(padnum,1); } + + if (rawAdcHit.GetPulseAmpRaw(thit) <= 0) { + Double_t PeakPedRatio= rawAdcHit.GetF250_PeakPedestalRatio(); + Int_t NPedSamples= rawAdcHit.GetF250_NPedestalSamples(); + Double_t AdcToC = rawAdcHit.GetAdcTopC(); + Double_t AdcToV = rawAdcHit.GetAdcTomV(); + if (fPedDefault[padnum-1] !=0) { + Double_t tPulseInt = AdcToC*(rawAdcHit.GetPulseIntRaw(thit) - fPedDefault[padnum-1]*PeakPedRatio); + ((THcSignalHit*) frAdcPulseInt->ConstructedAt(nrAdcHits))->Set(padnum, tPulseInt); + ((THcSignalHit*) frAdcPedRaw->ConstructedAt(nrAdcHits))->Set(padnum, fPedDefault[padnum-1]); + ((THcSignalHit*) frAdcPed->ConstructedAt(nrAdcHits))->Set(padnum, float(fPedDefault[padnum-1])/float(NPedSamples)*AdcToV); + + } + ((THcSignalHit*) frAdcPulseAmp->ConstructedAt(nrAdcHits))->Set(padnum, 0.); + + } + + ++nrAdcHits; } ihit++; diff --git a/src/THcShowerArray.h b/src/THcShowerArray.h index dc8991af37f3456bac0e5667594409c29979effa..8f5dad6d2e679c0a0fb0a5da69a1de5906675fc2 100644 --- a/src/THcShowerArray.h +++ b/src/THcShowerArray.h @@ -150,6 +150,7 @@ protected: static const Int_t kADCSampIntDynPed=3; Double_t *fAdcTimeWindowMin ; Double_t *fAdcTimeWindowMax ; + Int_t *fPedDefault ; Double_t fAdcThreshold ; Double_t fAdcTdcOffset; diff --git a/src/THcShowerPlane.cxx b/src/THcShowerPlane.cxx index d4f723676cf61ec4349034f68f1b84f9015e49ba..7cf0dc2fd8da783fbeb663e66d53608297bb591c 100644 --- a/src/THcShowerPlane.cxx +++ b/src/THcShowerPlane.cxx @@ -612,6 +612,21 @@ Int_t THcShowerPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) } else { ((THcSignalHit*) frPosAdcErrorFlag->ConstructedAt(nrPosAdcHits))->Set(padnum,1); } + if (rawPosAdcHit.GetPulseAmpRaw(thit) <= 0) { + Double_t PeakPedRatio= rawPosAdcHit.GetF250_PeakPedestalRatio(); + Int_t NPedSamples= rawPosAdcHit.GetF250_NPedestalSamples(); + Double_t AdcToC = rawPosAdcHit.GetAdcTopC(); + Double_t AdcToV = rawPosAdcHit.GetAdcTomV(); + Int_t PedDefaultTemp = static_cast<THcShower*>(fParent)->GetPedDefault(padnum-1,fLayerNum-1,0); + if (PedDefaultTemp !=0) { + Double_t tPulseInt = AdcToC*(rawPosAdcHit.GetPulseIntRaw(thit) - PedDefaultTemp*PeakPedRatio); + ((THcSignalHit*) frPosAdcPulseInt->ConstructedAt(nrPosAdcHits))->Set(padnum, tPulseInt); + ((THcSignalHit*) frPosAdcPedRaw->ConstructedAt(nrPosAdcHits))->Set(padnum, PedDefaultTemp); + ((THcSignalHit*) frPosAdcPed->ConstructedAt(nrPosAdcHits))->Set(padnum, float(PedDefaultTemp)/float(NPedSamples)*AdcToV); + + } + ((THcSignalHit*) frPosAdcPulseAmp->ConstructedAt(nrPosAdcHits))->Set(padnum, 0.); + } ++nrPosAdcHits; fTotNumAdcHits++; fTotNumPosAdcHits++; @@ -637,6 +652,21 @@ Int_t THcShowerPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) } else { ((THcSignalHit*) frNegAdcErrorFlag->ConstructedAt(nrNegAdcHits))->Set(padnum,1); } + if (rawNegAdcHit.GetPulseAmpRaw(thit) <= 0) { + Double_t PeakPedRatio= rawNegAdcHit.GetF250_PeakPedestalRatio(); + Int_t NPedSamples= rawNegAdcHit.GetF250_NPedestalSamples(); + Double_t AdcToC = rawNegAdcHit.GetAdcTopC(); + Double_t AdcToV = rawNegAdcHit.GetAdcTomV(); + Int_t PedDefaultTemp = static_cast<THcShower*>(fParent)->GetPedDefault(padnum-1,fLayerNum-1,1); + if (PedDefaultTemp !=0) { + Double_t tPulseInt = AdcToC*(rawNegAdcHit.GetPulseIntRaw(thit) - PedDefaultTemp*PeakPedRatio); + ((THcSignalHit*) frNegAdcPulseInt->ConstructedAt(nrNegAdcHits))->Set(padnum, tPulseInt); + ((THcSignalHit*) frNegAdcPedRaw->ConstructedAt(nrNegAdcHits))->Set(padnum, PedDefaultTemp); + ((THcSignalHit*) frNegAdcPed->ConstructedAt(nrNegAdcHits))->Set(padnum, float(PedDefaultTemp)/float(NPedSamples)*AdcToV); + + } + ((THcSignalHit*) frNegAdcPulseAmp->ConstructedAt(nrNegAdcHits))->Set(padnum, 0.); + } ++nrNegAdcHits; fTotNumAdcHits++; fTotNumNegAdcHits++; @@ -744,6 +774,8 @@ void THcShowerPlane::FillADC_DynamicPedestal() { Double_t StartTime = 0.0; if( fglHod ) StartTime = fglHod->GetStartTime(); + Double_t OffsetTime = 0.0; + if( fglHod ) OffsetTime = fglHod->GetOffsetTime(); for (Int_t ielem=0;ielem<frNegAdcPulseInt->GetEntries();ielem++) { Int_t npad = ((THcSignalHit*) frNegAdcPulseInt->ConstructedAt(ielem))->GetPaddleNumber() - 1; Double_t pulseInt = ((THcSignalHit*) frNegAdcPulseInt->ConstructedAt(ielem))->GetData(); @@ -751,18 +783,11 @@ void THcShowerPlane::FillADC_DynamicPedestal() Double_t pulseAmp = ((THcSignalHit*) frNegAdcPulseAmp->ConstructedAt(ielem))->GetData(); Double_t pulseIntRaw = ((THcSignalHit*) frNegAdcPulseIntRaw->ConstructedAt(ielem))->GetData(); Double_t pulseTime = ((THcSignalHit*) frNegAdcPulseTime->ConstructedAt(ielem))->GetData(); - Double_t adctdcdiffTime = StartTime-pulseTime; + Double_t adctdcdiffTime = StartTime-pulseTime+OffsetTime; Double_t threshold = ((THcSignalHit*) frNegAdcThreshold->ConstructedAt(ielem))->GetData(); - Bool_t errorflag = ((THcSignalHit*) frNegAdcErrorFlag->ConstructedAt(ielem))->GetData(); Bool_t pulseTimeCut = (adctdcdiffTime > static_cast<THcShower*>(fParent)->GetWindowMin(npad,fLayerNum-1,1)) && (adctdcdiffTime < static_cast<THcShower*>(fParent)->GetWindowMax(npad,fLayerNum-1,1) ); - - - - if (!errorflag) - { fGoodNegAdcMult.at(npad) += 1; - } - if (!errorflag && pulseTimeCut) { + if (pulseTimeCut) { fGoodNegAdcPulseIntRaw.at(npad) =pulseIntRaw; if(fGoodNegAdcPulseIntRaw.at(npad) > threshold && fGoodNegAdcPulseInt.at(npad)==0) { @@ -793,18 +818,10 @@ void THcShowerPlane::FillADC_DynamicPedestal() Double_t pulseInt = ((THcSignalHit*) frPosAdcPulseInt->ConstructedAt(ielem))->GetData(); Double_t pulseIntRaw = ((THcSignalHit*) frPosAdcPulseIntRaw->ConstructedAt(ielem))->GetData(); Double_t pulseTime = ((THcSignalHit*) frPosAdcPulseTime->ConstructedAt(ielem))->GetData(); - Double_t adctdcdiffTime = StartTime-pulseTime; - Bool_t errorflag = ((THcSignalHit*) frPosAdcErrorFlag->ConstructedAt(ielem))->GetData(); + Double_t adctdcdiffTime = StartTime-pulseTime+OffsetTime; Bool_t pulseTimeCut = (adctdcdiffTime > static_cast<THcShower*>(fParent)->GetWindowMin(npad,fLayerNum-1,0)) && (adctdcdiffTime < static_cast<THcShower*>(fParent)->GetWindowMax(npad,fLayerNum-1,0) ); - - - - if (!errorflag) - { fGoodPosAdcMult.at(npad) += 1; - } - - if (!errorflag && pulseTimeCut) { + if (pulseTimeCut) { fGoodPosAdcPulseIntRaw.at(npad) = pulseIntRaw; if(fGoodPosAdcPulseIntRaw.at(npad) > threshold && fGoodPosAdcPulseInt.at(npad)==0) { diff --git a/src/THcTrigDet.cxx b/src/THcTrigDet.cxx index 676792f610800628b6b5f3d7396d7b47cdd26c83..234a4a8ebabdb64db083c72cf014397e771262b1 100644 --- a/src/THcTrigDet.cxx +++ b/src/THcTrigDet.cxx @@ -211,7 +211,8 @@ void THcTrigDet::Clear(Option_t* opt) { THaAnalysisObject::Clear(opt); // Reset all data. - for (int i=0; i<fNumAdc; ++i) { + fTdcRefTime = kBig; + for (int i=0; i<fNumAdc; ++i) { fAdcPedRaw[i] = 0; fAdcPulseIntRaw[i] = 0; fAdcPulseAmpRaw[i] = 0; @@ -272,14 +273,21 @@ Int_t THcTrigDet::Decode(const THaEvData& evData) { } else if (hit->fPlane == 2) { THcRawTdcHit rawTdcHit = hit->GetRawTdcHit(); - + if (rawTdcHit.GetNHits() >0 && rawTdcHit.HasRefTime() && fTdcRefTime == kBig) fTdcRefTime=rawTdcHit.GetRefTime() ; UInt_t good_hit=999; + UInt_t closest_hit=999; + Int_t TimeDiff=1000000; for (UInt_t thit=0; thit<rawTdcHit.GetNHits(); ++thit) { Int_t TestTime= rawTdcHit.GetTimeRaw(thit); + if (abs(TestTime-fTdcTimeWindowMin[cnt]) < TimeDiff) { + closest_hit=thit; + TimeDiff=abs(TestTime-fTdcTimeWindowMin[cnt]); + } if (TestTime>=fTdcTimeWindowMin[cnt]&&TestTime<=fTdcTimeWindowMax[cnt]&&good_hit==999) { good_hit=thit; } } + if (good_hit == 999 and closest_hit != 999) good_hit=closest_hit; if (good_hit<rawTdcHit.GetNHits()) { fTdcTimeRaw[cnt] = rawTdcHit.GetTimeRaw(good_hit); fTdcTime[cnt] = rawTdcHit.GetTime(good_hit)*fTdcChanperNS+fTdcOffset; @@ -396,7 +404,16 @@ Int_t THcTrigDet::DefineVariables(THaAnalysisObject::EMode mode) { std::vector<TString> adcPulseIntTitle(fNumAdc), adcPulseIntVar(fNumAdc); std::vector<TString> adcPulseAmpTitle(fNumAdc), adcPulseAmpVar(fNumAdc); std::vector<TString> adcMultiplicityTitle(fNumAdc), adcMultiplicityVar(fNumAdc); - + + TString RefTimeTitle= "TdcRefTime"; + TString RefTimeVar= "fTdcRefTime"; + RVarDef entryRefTime { + RefTimeTitle.Data(), + RefTimeTitle.Data(), + RefTimeVar.Data() + }; + vars.push_back(entryRefTime); + for (int i=0; i<fNumAdc; ++i) { adcPedRawTitle.at(i) = fAdcNames.at(i) + "_adcPedRaw"; adcPedRawVar.at(i) = TString::Format("fAdcPedRaw[%d]", i); diff --git a/src/THcTrigDet.h b/src/THcTrigDet.h index 20b4838cd537a28a25d256182533020490f31904..dfde554b18a7a29a51ec5a67695337bb76954ce0 100644 --- a/src/THcTrigDet.h +++ b/src/THcTrigDet.h @@ -82,6 +82,7 @@ class THcTrigDet : public THaDetector, public THcHitList { Int_t fTdcMultiplicity[fMaxTdcChannels]; Int_t fAdcMultiplicity[fMaxAdcChannels]; + Double_t fTdcRefTime; TString fSpectName; std::vector<Int_t> eventtypes;