diff --git a/src/THcHodoscope.cxx b/src/THcHodoscope.cxx index 3d335ad2eb080d09377a87b5ef3162c471ddf074..2117d689870031f18a9a207eb57d3b65ce66017e 100644 --- a/src/THcHodoscope.cxx +++ b/src/THcHodoscope.cxx @@ -563,6 +563,9 @@ Int_t THcHodoscope::Decode( const THaEvData& evdata ) // Get the Hall C style hitlist (fRawHitList) for this event Int_t nhits = DecodeToHitList(evdata); + // + // GN: print event number so we can cross-check with engine + // if (evdata.GetEvNum()>1000) cout <<"hcana event no = "<<evdata.GetEvNum()<<endl; if(gHaCuts->Result("Pedestal_event")) { Int_t nexthit = 0; @@ -581,9 +584,9 @@ Int_t THcHodoscope::Decode( const THaEvData& evdata ) // Let each plane get its hits Int_t nexthit = 0; - Int_t nfptimes=0; fStartTime=0; + fNfptimes=0; for(Int_t ip=0;ip<fNPlanes;ip++) { // nexthit = fPlanes[ip]->ProcessHits(fRawHitList, nexthit); // GN: select only events that have reasonable TDC values to start with @@ -591,14 +594,19 @@ Int_t THcHodoscope::Decode( const THaEvData& evdata ) nexthit = fPlanes[ip]->ProcessHits(fRawHitList,nexthit); if (fPlanes[ip]->GetNScinHits()>0) { fPlanes[ip]->PulseHeightCorrection(); - if (TMath::Abs(fPlanes[ip]->GetFpTime()-fStartTimeCenter)<=fStartTimeSlop) { - fStartTime=fStartTime+fPlanes[ip]->GetFpTime(); - nfptimes++; + // GN: allow for more than one fptime per plane!! + for (Int_t i=0;i<fPlanes[ip]->GetNScinGoodHits();i++) { + if (TMath::Abs(fPlanes[ip]->GetFpTime(i)-fStartTimeCenter)<=fStartTimeSlop) { + fStartTime=fStartTime+fPlanes[ip]->GetFpTime(i); + // GN write stuff out so I can compare with engine + /// cout<<"hcana event= "<<evdata.GetEvNum()<<" fNfptimes= "<<fNfptimes<<" fptime= "<<fPlanes[ip]->GetFpTime(i)<<endl; + fNfptimes++; + } } } } - if (nfptimes>0) { - fStartTime=fStartTime/nfptimes; + if (fNfptimes>0) { + fStartTime=fStartTime/fNfptimes; fGoodStartTime=kTRUE; } else { fGoodStartTime=kFALSE; @@ -606,6 +614,18 @@ Int_t THcHodoscope::Decode( const THaEvData& evdata ) } fStartTime=32.; // mkj force to constant +/// fStartTime=32.; // mkj force to constant +/// if (fGoodStartTime) cout <<"hcana event= "<<evdata.GetEvNum()<<" fNfptimes= "<<fNfptimes<<" fStartTime= "<<fStartTime<<endl<<endl; + // fRawHitList is TClones array of THcHodoscopeHit objects +#if 0 + for(Int_t ihit = 0; ihit < fNRawHits ; ihit++) { + THcHodoscopeHit* hit = (THcHodoscopeHit *) fRawHitList->At(ihit); + cout << ihit << " : " << hit->fPlane << ":" << hit->fCounter << " : " + << hit->fADC_pos << " " << hit->fADC_neg << " " << hit->fTDC_pos + << " " << hit->fTDC_neg << endl; + } + cout << endl; +#endif /// fStartTime = 500; // Drift Chamber will need this return nhits; diff --git a/src/THcHodoscope.h b/src/THcHodoscope.h index 2c90d460172b2d0f00090210ff900c64502c9fe5..f4332c1268de615988d17525d558adf344075e79 100644 --- a/src/THcHodoscope.h +++ b/src/THcHodoscope.h @@ -32,6 +32,7 @@ public: virtual Int_t ApplyCorrections( void ); Double_t GetStartTime() const { return fStartTime; } Bool_t IsStartTimeGood() const {return fGoodStartTime;}; + Int_t GetNfptimes() const {return fNfptimes;}; Int_t GetScinIndex(Int_t nPlane, Int_t nPaddle); Int_t GetScinIndex(Int_t nSide, Int_t nPlane, Int_t nPaddle); Double_t GetPathLengthCentral(); @@ -47,6 +48,12 @@ public: Double_t GetHodoPosTimeOffset(Int_t iii) const {return fHodoPosTimeOffset[iii];} Double_t GetHodoNegTimeOffset(Int_t iii) const {return fHodoNegTimeOffset[iii];} Double_t GetHodoVelLight(Int_t iii) const {return fHodoVelLight[iii];} + Double_t GetStartTimeCenter() const {return fStartTimeCenter;} + Double_t GetStartTimeSlop() const {return fStartTimeSlop;} + Double_t GetBetaNotrk() const {return fBetaNotrk;} + Double_t GetBeta() const {return fBeta;} + Double_t GetHodoPosSigma(Int_t iii) const {return fHodoPosSigma[iii];} + Double_t GetHodoNegSigma(Int_t iii) const {return fHodoNegSigma[iii];} const TClonesArray* GetTrackHits() const { return fTrackProj; } @@ -61,8 +68,11 @@ protected: // Per-event data Bool_t fGoodStartTime; - Double_t fStartTime; - + Double_t fStartTime; + Int_t fNfptimes; + + Double_t fBetaNotrk; + Double_t fBeta; // Per-event data // Potential Hall C parameters. Mostly here for demonstration diff --git a/src/THcScintillatorPlane.cxx b/src/THcScintillatorPlane.cxx index 4033ee71d35aed6137b4cd912bee6a2ecbcd34ee..7e1a30de3ffb6aa7eb268d97869d4bd9a3f3592b 100644 --- a/src/THcScintillatorPlane.cxx +++ b/src/THcScintillatorPlane.cxx @@ -46,6 +46,10 @@ THcScintillatorPlane::THcScintillatorPlane( const char* name, // fMaxHits=53; fpTime = -1.e5; + fpTimes = new Double_t [fMaxHits]; + fScinTime = new Double_t [fMaxHits]; + fScinSigma = new Double_t [fMaxHits]; + fScinZpos = new Double_t [fMaxHits]; } //______________________________________________________________________________ THcScintillatorPlane::THcScintillatorPlane( const char* name, @@ -70,7 +74,10 @@ THcScintillatorPlane::THcScintillatorPlane( const char* name, // fMaxHits=53; fpTime = -1.e5; - + fpTimes = new Double_t [fMaxHits]; + fScinTime = new Double_t [fMaxHits]; + fScinSigma = new Double_t [fMaxHits]; + fScinZpos = new Double_t [fMaxHits]; } //______________________________________________________________________________ @@ -85,6 +92,10 @@ THcScintillatorPlane::~THcScintillatorPlane() delete frNegTDCHits; delete frPosADCHits; delete frNegADCHits; + delete fpTimes; + delete fScinTime; + delete fScinSigma; + delete fScinZpos; } //______________________________________________________________________________ @@ -492,14 +503,29 @@ Int_t THcScintillatorPlane::PulseHeightCorrection() postime[i]=postime[i]-(fPosLeft-hit_position)/((THcHodoscope *)GetParent())->GetHodoVelLight(index); negtime[i]=negtime[i]-(hit_position-fPosRight)/((THcHodoscope *)GetParent())->GetHodoVelLight(index); scin_corrected_time[i]=0.5*(postime[i]+negtime[i]); - fpTime=scin_corrected_time[i]-(fZpos+(j%2)*fDzpos)/(29.979*hbeta_pcent); } else { // only one tube fired scin_corrected_time[i]=0.0; // not a very good "flag" but there is the logical two_good_hits... + // no fpTimes for U! + } + } + //start time calculation. assume xp=yp=0 radians. project all + //time values to focal plane. use average for start time. + + fNScinGoodHits=0; + for (i=0;i<fNScinHits;i++) { + j=((THcSignalHit*)fNegTDCHits->At(i))->GetPaddleNumber()-1; + index=((THcHodoscope *)GetParent())->GetScinIndex(fPlaneNum-1,j); + if (two_good_times[i]) { // both tubes fired + fpTimes[fNScinGoodHits]=scin_corrected_time[i]-(fZpos+(j%2)*fDzpos)/(29.979*hbeta_pcent); + fScinTime[fNScinGoodHits]=scin_corrected_time[i]; + fScinSigma[fNScinGoodHits]=TMath::Sqrt(((THcHodoscope *)GetParent())->GetHodoPosSigma(index)*((THcHodoscope *)GetParent())->GetHodoPosSigma(index)+((THcHodoscope *)GetParent())->GetHodoNegSigma(index)*((THcHodoscope *)GetParent())->GetHodoNegSigma(index)); // not ideal by any stretch!!! + fScinZpos[fNScinGoodHits]=fZpos+(j%2)*fDzpos; // see comment above + // h_rfptime(hscin_plane_num(ihit))=fptime + fNScinGoodHits++; // increment the number of good hits } } - // Start time calculation, assume xp=yp=0 radians. project all - // time values to focal plane. use average for start time. + CalcFpTime(); return 0; } //_____________________________________________________________________________ @@ -600,7 +626,8 @@ void THcScintillatorPlane::InitializePedestals( ) Int_t THcScintillatorPlane::GetNelem() { return fNelem; -}//____________________________________________________________________________ +} +//____________________________________________________________________________ Int_t THcScintillatorPlane::GetNScinHits() { return fNScinHits; @@ -647,6 +674,24 @@ Double_t THcScintillatorPlane::GetPosCenter(Int_t PaddleNo) { return fPosCenter[PaddleNo]; } //____________________________________________________________________________ +Double_t THcScintillatorPlane::CalcFpTime() +{ + Double_t tmp=0; + Int_t i,counter=0; + for (i=0;i<fNScinHits;i++) { + if (TMath::Abs(fpTimes[i]-((THcHodoscope *)GetParent())->GetStartTimeCenter())<=((THcHodoscope *)GetParent())->GetStartTimeSlop()) { + tmp+=fpTimes[i]; + counter++; + } + } + if (counter>0) { + fpTime=tmp/counter; + } else { + fpTime=((THcHodoscope *)GetParent())->GetStartTimeCenter(); + } + return fpTime; +} +//____________________________________________________________________________ ClassImp(THcScintillatorPlane) //////////////////////////////////////////////////////////////////////////////// diff --git a/src/THcScintillatorPlane.h b/src/THcScintillatorPlane.h index 9b5f33e5cc5a40300b3c93bfc7e7755d2ccb1bc1..520a25007d1fae9c4b85f158cf24cb668df852fd 100644 --- a/src/THcScintillatorPlane.h +++ b/src/THcScintillatorPlane.h @@ -53,7 +53,13 @@ class THcScintillatorPlane : public THaSubDetector { Double_t GetPosRight(); Double_t GetPosOffset(); Double_t GetPosCenter(Int_t PaddleNo); // here we're counting from zero! - Double_t GetFpTime() { return fpTime;}; + Double_t CalcFpTime(); + Double_t GetFpTime() {return fpTime;}; + Double_t GetFpTime(Int_t index) { return fpTimes[index];}; + Double_t GetScinTime(Int_t index) { return fScinTime[index];}; + Double_t GetScinSigma(Int_t index) { return fScinSigma[index];}; + Double_t GetScinZpos(Int_t index) { return fScinZpos[index];}; + Int_t GetNScinGoodHits() const {return fNScinGoodHits;}; TClonesArray* fParentHitList; @@ -106,8 +112,12 @@ class THcScintillatorPlane : public THaSubDetector { Double_t *fNegThresh; // - Double_t fpTime; // the original code only has one fpTime per plane! - + 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! + Double_t *fpTimes; // ... but also allows for more than one hit per plane + Double_t *fScinTime; // array of scintillator times (only filled for goodhits) + Double_t *fScinSigma; // errors for the above + Double_t *fScinZpos; // zpositions for the above virtual Int_t ReadDatabase( const TDatime& date ); virtual Int_t DefineVariables( EMode mode = kDefine );