From 9a8a8d2d753832b41294451bb106a3c1e4186b97 Mon Sep 17 00:00:00 2001 From: "Stephen A. Wood" <saw@jlab.org> Date: Fri, 2 Sep 2016 14:03:33 -0400 Subject: [PATCH] In hodoscope, ability to use multihit tdcs with reference times --- src/THcHodoHit.cxx | 8 ++-- src/THcHodoscope.cxx | 15 +++++++- src/THcHodoscope.h | 13 +++++-- src/THcRawDCHit.h | 2 +- src/THcRawHodoHit.cxx | 75 ++++++++++++++++++++++++++++++------ src/THcRawHodoHit.h | 45 ++++++++++++++-------- src/THcScintillatorPlane.cxx | 33 ++++++++-------- 7 files changed, 137 insertions(+), 54 deletions(-) diff --git a/src/THcHodoHit.cxx b/src/THcHodoHit.cxx index 9c6d82a..eab26b0 100644 --- a/src/THcHodoHit.cxx +++ b/src/THcHodoHit.cxx @@ -17,10 +17,10 @@ THcHodoHit::THcHodoHit( THcRawHodoHit *hit, Double_t posPed, Double_t negPed, THcScintillatorPlane* sp) { if(hit) { - fPosTDC = hit->fTDC_pos; - fNegTDC = hit->fTDC_neg; - fPosADC_Ped = hit->fADC_pos - posPed; - fNegADC_Ped = hit->fADC_neg - negPed; + fPosTDC = hit->GetTDCPos(); + fNegTDC = hit->GetTDCNeg(); + fPosADC_Ped = hit->GetADCPos() - posPed; + fNegADC_Ped = hit->GetADCNeg() - negPed; fPaddleNumber = hit->fCounter; } else { fPosTDC = -1; diff --git a/src/THcHodoscope.cxx b/src/THcHodoscope.cxx index 76da20a..9405baf 100644 --- a/src/THcHodoscope.cxx +++ b/src/THcHodoscope.cxx @@ -309,6 +309,8 @@ Int_t THcHodoscope::ReadDatabase( const TDatime& date ) fyLoScin = new Int_t [fNHodoscopes]; fyHiScin = new Int_t [fNHodoscopes]; fHodoSlop = new Double_t [fNPlanes]; + fTdcWinMin = new Int_t [fNPlanes]; + fTdcWinMax = new Int_t [fNPlanes]; DBRequest list[]={ {"start_time_center", &fStartTimeCenter, kDouble}, @@ -339,13 +341,22 @@ Int_t THcHodoscope::ReadDatabase( const TDatime& date ) {"normalized_energy_tot", &fNormETot, kDouble, 0, 1}, {"hodo_slop", fHodoSlop, kDouble, (UInt_t) fNPlanes}, {"debugprintscinraw", &fdebugprintscinraw, kInt, 0,1}, + {"hodo_tdc_min_win", fTdcWinMin, kInt, (UInt_t) fNPlanes, 1}, + {"hodo_tdc_max_win", fTdcWinMax, kInt, (UInt_t) fNPlanes, 1}, {0} }; + + // Defaults if not defined in parameter file + fdebugprintscinraw=0; - fTofUsingInvAdc = 0; // Default if not defined - fTofTolerance = 3.0; // Default if not defined + fTofUsingInvAdc = 0; + fTofTolerance = 3.0; fNCerNPE = 2.0; fNormETot = 0.7; + for(Int_t ip=0;ip<fNPlanes;ip++) { // Set a large default window + fTdcWinMin[ip] = -65000; + fTdcWinMax[ip] = 65000; + } gHcParms->LoadParmValues((DBRequest*)&list,prefix); diff --git a/src/THcHodoscope.h b/src/THcHodoscope.h index 42d4599..f85ea8a 100644 --- a/src/THcHodoscope.h +++ b/src/THcHodoscope.h @@ -78,10 +78,13 @@ public: Int_t GetNPlanes() { return fNPlanes;} THcScintillatorPlane* GetPlane(Int_t ip) { return fPlanes[ip];} - UInt_t GetNPaddles(Int_t iii) { return fNPaddle[iii];} - Double_t GetHodoSlop(Int_t iii) { return fHodoSlop[iii];} - Double_t GetPlaneCenter(Int_t iii) { return fPlaneCenter[iii];} - Double_t GetPlaneSpacing(Int_t iii) { return fPlaneSpacing[iii];} + UInt_t GetNPaddles(Int_t ip) { return fNPaddle[ip];} + Double_t GetHodoSlop(Int_t ip) { return fHodoSlop[ip];} + Double_t GetPlaneCenter(Int_t ip) { return fPlaneCenter[ip];} + Double_t GetPlaneSpacing(Int_t ip) { return fPlaneSpacing[ip];} + Int_t GetTdcWinMin(Int_t ip) const { return fTdcWinMin[ip];} + Int_t GetTdcWinMax(Int_t ip) const { return fTdcWinMax[ip];} + // Double_t GetBeta() const {return fBeta[];} @@ -184,6 +187,8 @@ protected: Double_t fNormETot; Double_t fNCerNPE; Double_t* fHodoSlop; + Int_t* fTdcWinMin; + Int_t* fTdcWinMax; Int_t fdebugprintscinraw; Int_t fTestSum; Int_t fTrackEffTestNScinPlanes; diff --git a/src/THcRawDCHit.h b/src/THcRawDCHit.h index 577dedc..7a55667 100644 --- a/src/THcRawDCHit.h +++ b/src/THcRawDCHit.h @@ -17,7 +17,7 @@ public: THcRawDCHit& operator=( const THcRawDCHit& ); virtual ~THcRawDCHit() {} - virtual void Clear( Option_t* opt="" ) { fNHits=0; } + virtual void Clear( Option_t* opt="" ) { fNHits=0; fHasRef=kFALSE; } void SetData(Int_t signal, Int_t data); void SetReference(Int_t signal, Int_t reference); diff --git a/src/THcRawHodoHit.cxx b/src/THcRawHodoHit.cxx index 3d6bc71..3608098 100644 --- a/src/THcRawHodoHit.cxx +++ b/src/THcRawHodoHit.cxx @@ -1,7 +1,7 @@ /** \class THcRawHodoHit \ingroup DetSupport -Raw Aerogel Hit Info +Raw Hodoscope Hit Info Class representing a single raw hit for a hodoscope paddle @@ -19,32 +19,82 @@ Class representing a single raw hit for a hodoscope paddle using namespace std; - void THcRawHodoHit::SetData(Int_t signal, Int_t data) { if(signal==0) { - fADC_pos = data; + fADC_pos[fNRawHits[0]++] = data; } else if (signal==1) { - fADC_neg = data; + fADC_neg[fNRawHits[1]++] = data; } else if(signal==2) { - fTDC_pos = data; + fTDC_pos[fNRawHits[2]++] = data; } else if (signal==3) { - fTDC_neg = data; + fTDC_neg[fNRawHits[3]++] = data; } } Int_t THcRawHodoHit::GetData(Int_t signal) { + return(GetData(signal,0)); +} +Int_t THcRawHodoHit::GetData(Int_t signal, UInt_t ihit) { + Int_t value; + if(ihit>= fNRawHits[signal]) { + return(-1); + } if(signal==0) { - return(fADC_pos); + value = fADC_pos[ihit]; } else if (signal==1) { - return(fADC_neg); - } else if(signal==2) { - return(fTDC_pos); + value = fADC_neg[ihit]; + } else if (signal==2) { + value = fTDC_pos[ihit]; + } else if (signal==3) { + value = fTDC_neg[ihit]; + } else { + return(-1); // Actually should throw an exception + } + // We are return -1 as a error, but reference subtracted + // time can be negative. + if(fHasRef[signal]) { + value -= fReferenceTime[signal]; + } + return(value); +} + +Int_t THcRawHodoHit::GetRawData(Int_t signal) { + return(GetRawData(signal,0)); +} + +// Return a requested raw hit +Int_t THcRawHodoHit::GetRawData(Int_t signal, UInt_t ihit) { + if(ihit>= fNRawHits[signal]) { + return(-1); + } + if(signal==0) { + return(fADC_pos[ihit]); + } else if (signal==1) { + return(fADC_neg[ihit]); + } else if (signal==2) { + return(fTDC_pos[ihit]); } else if (signal==3) { - return(fTDC_neg); + return(fTDC_neg[ihit]); + } else { + return(-1); // Actually should throw an exception + } +} + +// Set the reference time +void THcRawHodoHit::SetReference(Int_t signal, Int_t reference) { + fReferenceTime[signal] = reference; + fHasRef[signal] = kTRUE; +} +Int_t THcRawHodoHit::GetReference(Int_t signal) { + if(fHasRef[signal]) { + return(fReferenceTime[signal]); + } else { + return(0); } - return(-1); // Actually should throw exception } + // Do we use this? +#if 0 //_____________________________________________________________________________ THcRawHodoHit& THcRawHodoHit::operator=( const THcRawHodoHit& rhs ) { @@ -61,6 +111,7 @@ THcRawHodoHit& THcRawHodoHit::operator=( const THcRawHodoHit& rhs ) } return *this; } +#endif ////////////////////////////////////////////////////////////////////////// diff --git a/src/THcRawHodoHit.h b/src/THcRawHodoHit.h index 1299bdf..42f961c 100644 --- a/src/THcRawHodoHit.h +++ b/src/THcRawHodoHit.h @@ -3,6 +3,8 @@ #include "THcRawHit.h" +#define MAXHITS 16 + class THcRawHodoHit : public THcRawHit { public: @@ -10,31 +12,44 @@ class THcRawHodoHit : public THcRawHit { friend class THcHodoscope; friend class THcHodoHit; - THcRawHodoHit(Int_t plane=0, Int_t counter=0) : THcRawHit(plane, counter), - fADC_pos(-1), fADC_neg(-1), - fTDC_pos(-1), fTDC_neg(-1) { + THcRawHodoHit(Int_t plane=0, Int_t counter=0) : THcRawHit(plane, counter) { + for(Int_t i=0;i<4;i++) { + fHasRef[i] = kFALSE; + fNRawHits[i] = 0; + } } THcRawHodoHit& operator=( const THcRawHodoHit& ); virtual ~THcRawHodoHit() {} - virtual void Clear( Option_t* opt="" ) - { fADC_pos = -1; fADC_neg = -1; fTDC_pos = -1; fTDC_neg = -1; } - + virtual void Clear( Option_t* opt="" ) { + for(Int_t i=0;i<4;i++) { + fHasRef[i] = kFALSE; + fNRawHits[i] = 0; + } + } void SetData(Int_t signal, Int_t data); + void SetReference(Int_t signal, Int_t reference); Int_t GetData(Int_t signal); - + Int_t GetData(Int_t signal, UInt_t ihit); + Int_t GetRawData(Int_t signal); + Int_t GetRawData(Int_t signal, UInt_t ihit); + Int_t GetReference(Int_t signal); + // virtual Bool_t IsSortable () const {return kTRUE; } // virtual Int_t Compare(const TObject* obj) const; - Int_t GetADCPos() {return fADC_pos;} - Int_t GetADCNeg() {return fADC_neg;} - Int_t GetTDCPos() {return fTDC_pos;} - Int_t GetTDCNeg() {return fTDC_neg;} + Int_t GetADCPos() {return GetData(0, 0);} + Int_t GetADCNeg() {return GetData(1, 0);} + Int_t GetTDCPos() {return GetData(2, 0);} + Int_t GetTDCNeg() {return GetData(3, 0);} protected: - Int_t fADC_pos; - Int_t fADC_neg; - Int_t fTDC_pos; - Int_t fTDC_neg; + Int_t fADC_pos[MAXHITS]; + Int_t fADC_neg[MAXHITS]; + Int_t fTDC_pos[MAXHITS]; + Int_t fTDC_neg[MAXHITS]; + Int_t fReferenceTime[4]; + Bool_t fHasRef[4]; + UInt_t fNRawHits[4]; private: diff --git a/src/THcScintillatorPlane.cxx b/src/THcScintillatorPlane.cxx index 3b78341..019551d 100644 --- a/src/THcScintillatorPlane.cxx +++ b/src/THcScintillatorPlane.cxx @@ -329,29 +329,30 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) Int_t padnum=hit->fCounter; Int_t index=padnum-1; - if (hit->fTDC_pos > 0) - ((THcSignalHit*) frPosTDCHits->ConstructedAt(nrPosTDCHits++))->Set(padnum, hit->fTDC_pos); - if (hit->fTDC_neg > 0) - ((THcSignalHit*) frNegTDCHits->ConstructedAt(nrNegTDCHits++))->Set(padnum, hit->fTDC_neg); - if ((hit->fADC_pos-fPosPed[index]) >= 50) - ((THcSignalHit*) frPosADCHits->ConstructedAt(nrPosADCHits++))->Set(padnum, hit->fADC_pos-fPosPed[index]); - if ((hit->fADC_neg-fNegPed[index]) >= 50) - ((THcSignalHit*) frNegADCHits->ConstructedAt(nrNegADCHits++))->Set(padnum, hit->fADC_neg-fNegPed[index]); + // Need to be finding first hit in TDC range, not the first hit overall + if (hit->fNRawHits[2] > 0) + ((THcSignalHit*) frPosTDCHits->ConstructedAt(nrPosTDCHits++))->Set(padnum, hit->GetTDCPos()); + if (hit->fNRawHits[3] > 0) + ((THcSignalHit*) frNegTDCHits->ConstructedAt(nrNegTDCHits++))->Set(padnum, hit->GetTDCNeg()); + if ((hit->GetADCPos()-fPosPed[index]) >= 50) + ((THcSignalHit*) frPosADCHits->ConstructedAt(nrPosADCHits++))->Set(padnum, hit->GetADCPos()-fPosPed[index]); + if ((hit->GetADCNeg()-fNegPed[index]) >= 50) + ((THcSignalHit*) frNegADCHits->ConstructedAt(nrNegADCHits++))->Set(padnum, hit->GetADCNeg()-fNegPed[index]); // check TDC values - if (((hit->fTDC_pos >= fScinTdcMin) && (hit->fTDC_pos <= fScinTdcMax)) || - ((hit->fTDC_neg >= fScinTdcMin) && (hit->fTDC_neg <= fScinTdcMax))) { + if (((hit->GetTDCPos() >= fScinTdcMin) && (hit->GetTDCPos() <= fScinTdcMax)) || + ((hit->GetTDCNeg() >= fScinTdcMin) && (hit->GetTDCNeg() <= fScinTdcMax))) { // If TDC values are all good, transfer the raw hit to the HodoHit list new( (*fHodoHits)[fNScinHits]) THcHodoHit(hit, fPosPed[index], fNegPed[index], this); // Do the pulse height correction to the time. (Position dependent corrections later) - Double_t timec_pos = hit->fTDC_pos*fScinTdcToTime - fHodoPosPhcCoeff[index]* + Double_t timec_pos = hit->GetTDCPos()*fScinTdcToTime - fHodoPosPhcCoeff[index]* TMath::Sqrt(TMath::Max(0.0, - (hit->fADC_pos-fPosPed[index])/fHodoPosMinPh[index]-1.0)) + (hit->GetADCPos()-fPosPed[index])/fHodoPosMinPh[index]-1.0)) - fHodoPosTimeOffset[index]; - Double_t timec_neg = hit->fTDC_neg*fScinTdcToTime - fHodoNegPhcCoeff[index]* + Double_t timec_neg = hit->GetTDCNeg()*fScinTdcToTime - fHodoNegPhcCoeff[index]* TMath::Sqrt(TMath::Max(0.0, - (hit->fADC_neg-fNegPed[index])/fHodoNegMinPh[index]-1.0)) + (hit->GetADCNeg()-fNegPed[index])/fHodoNegMinPh[index]-1.0)) - fHodoNegTimeOffset[index]; // Find hit position using ADCs @@ -399,8 +400,8 @@ Int_t THcScintillatorPlane::AccumulatePedestals(TClonesArray* rawhits, Int_t nex break; } Int_t element = hit->fCounter - 1; // Should check if in range - Int_t adcpos = hit->fADC_pos; - Int_t adcneg = hit->fADC_neg; + Int_t adcpos = hit->GetADCPos(); + Int_t adcneg = hit->GetADCNeg(); if(adcpos <= fPosPedLimit[element]) { fPosPedSum[element] += adcpos; -- GitLab