From 08fdc0a34b1d1e0855f785b95e17348b79b837bc Mon Sep 17 00:00:00 2001 From: Gabriel Niculescu <gabriel@jalb.org> Date: Mon, 28 Jan 2013 11:10:10 -0500 Subject: [PATCH] Implementing min/max TDC cuts and pedestal subtraction. --- src/THcScintillatorPlane.cxx | 62 +++++++++++++++++++++++++++++++++++- src/THcScintillatorPlane.h | 1 + 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/src/THcScintillatorPlane.cxx b/src/THcScintillatorPlane.cxx index 774f8d3..ae7b758 100644 --- a/src/THcScintillatorPlane.cxx +++ b/src/THcScintillatorPlane.cxx @@ -168,7 +168,6 @@ Int_t THcScintillatorPlane::ReadDatabase( const TDatime& date ) cout <<"PosOffset = "<<fPosOffset<<endl; cout <<"PosCenter[0] = "<<fPosCenter[0]<<endl; - /* for(Int_t i=0;i<fNPlanes;i++) { fCenter[i] = new Double_t[fNPaddle[i]]; DBRequest list[]={ @@ -250,6 +249,9 @@ Int_t THcScintillatorPlane::Decode( const THaEvData& evdata ) Int_t THcScintillatorPlane::CoarseProcess( TClonesArray& tracks ) { + cout <<"*******************************\n"; + cout <<"NOW IN THcScintilatorPlane::CoarseProcess!!!!\n"; + cout <<"*******************************\n"; // HitCount(); return 0; @@ -318,6 +320,64 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) return(ihit); } +//_____________________________________________________________________________ +Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Double_t mintdc, Double_t maxtdc,Int_t nexthit) +{ + // Extract the data for this plane from hit list + // Assumes that the hit list is sorted by plane, so we stop when the + // plane doesn't agree and return the index for the next hit. + // GN: Select only events that have at least one of their TDC signals in the + // right range. + // NOTE: 01/24/2013: Not quite subtracting pedestals for now! Also subtract the pedestals from the adc signal + + Int_t nPosTDCHits=0; + Int_t nNegTDCHits=0; + Int_t nPosADCHits=0; + Int_t nNegADCHits=0; + fPosTDCHits->Clear(); + fNegTDCHits->Clear(); + fPosADCHits->Clear(); + fNegADCHits->Clear(); + + Int_t nrawhits = rawhits->GetLast()+1; + // cout << "THcScintillatorPlane::ProcessHits " << fPlaneNum << " " << nexthit << "/" << nrawhits << endl; + + Int_t ihit = nexthit; + while(ihit < nrawhits) { + THcHodoscopeHit* hit = (THcHodoscopeHit *) rawhits->At(ihit); + if(hit->fPlane > fPlaneNum) { + break; + } + + // check TDC values + if (((hit->fTDC_pos >= mintdc) && (hit->fTDC_pos <= maxtdc)) || + ((hit->fTDC_neg >= mintdc) && (hit->fTDC_neg <= maxtdc))) { + //TDC positive hit + THcSignalHit *sighit = (THcSignalHit*) fPosTDCHits->ConstructedAt(nPosTDCHits++); + sighit->Set(hit->fCounter, hit->fTDC_pos); + // TDC negative hit + THcSignalHit *sighit2 = (THcSignalHit*) fNegTDCHits->ConstructedAt(nNegTDCHits++); + sighit2->Set(hit->fCounter, hit->fTDC_neg); + // ADC positive hit + if(hit->fADC_pos > 0) { + THcSignalHit *sighit = (THcSignalHit*) fPosADCHits->ConstructedAt(nPosADCHits++); + sighit->Set(hit->fCounter, hit->fADC_pos); + } + // ADC negative hit + if(hit->fADC_neg > 0) { + // cout <<"adc neg hit!!\n"; + THcSignalHit *sighit = (THcSignalHit*) fNegADCHits->ConstructedAt(nNegADCHits++); + sighit->Set(hit->fCounter, hit->fADC_neg); + } + else { + cout <<"skipping BAD tdc event\n"; + } + } + ihit++; + } + return(ihit); +} + //_____________________________________________________________________________ Int_t THcScintillatorPlane::AccumulatePedestals(TClonesArray* rawhits, Int_t nexthit) { diff --git a/src/THcScintillatorPlane.h b/src/THcScintillatorPlane.h index 7cb205c..e1c4650 100644 --- a/src/THcScintillatorPlane.h +++ b/src/THcScintillatorPlane.h @@ -37,6 +37,7 @@ class THcScintillatorPlane : public THaSubDetector { virtual Bool_t IsPid() { return kFALSE; } virtual Int_t ProcessHits(TClonesArray* rawhits, Int_t nexthit); + virtual Int_t ProcessHits(TClonesArray* rawhits, Double_t mintdc, Double_t maxtdc, Int_t nexthit); virtual Int_t AccumulatePedestals(TClonesArray* rawhits, Int_t nexthit); virtual void CalculatePedestals( ); -- GitLab