diff --git a/Makefile b/Makefile index 056ecb8a81ec4b010b726ca16cb9a9f1455ddc28..ac3647998063bc9d1866370e1276b319842fd3e3 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ SRC = src/THcInterface.cxx src/THcParmList.cxx src/THcAnalyzer.cxx \ src/THcRawHit.cxx src/THcHitList.cxx \ src/THcSignalHit.cxx \ src/THcHodoscope.cxx src/THcScintillatorPlane.cxx \ - src/THcRawHodoHit.cxx \ + src/THcRawHodoHit.cxx src/THcHodoHit.cxx \ src/THcDC.cxx src/THcDriftChamberPlane.cxx \ src/THcDriftChamber.cxx \ src/THcRawDCHit.cxx src/THcDCHit.cxx \ diff --git a/SConscript.py b/SConscript.py index c94403f73cc3e27e558c339440e87490a6e615d6..3d54796dd8fae33ffa8c8457f1ed6d3f2584446b 100644 --- a/SConscript.py +++ b/SConscript.py @@ -13,7 +13,8 @@ roothcobj = pbaseenv.subst('$HC_SRC')+'/HallCDict.so' hcheaders = Split(""" src/THcInterface.h src/THcParmList.h src/THcAnalyzer.h src/THcHallCSpectrometer.h src/THcDetectorMap.h src/THcRawHit.h src/THcHitList.h src/THcSignalHit.h src/THcHodoscope.h - src/THcScintillatorPlane.h src/THcRawHodoHit.h src/THcDC.h src/THcDriftChamberPlane.h + src/THcScintillatorPlane.h src/THcRawHodoHit.h src/THcHodoHit.h + src/THcDC.h src/THcDriftChamberPlane.h src/THcDriftChamber.h src/THcRawDCHit.h src/THcDCHit.h src/THcDCWire.h src/THcSpacePoint.h src/THcDCLookupTTDConv.h src/THcDCTimeToDistConv.h src/THcShower.h src/THcShowerPlane.h src/THcRawShowerHit.h src/THcAerogel.h src/THcAerogelHit.h src/THcCherenkov.h src/THcCherenkovHit.h diff --git a/src/HallC_LinkDef.h b/src/HallC_LinkDef.h index 21d28e17b25e596ea426faef945995c729aa6c5f..d4218837c36fddc27fa6e89b5ebf3a249fb23f21 100644 --- a/src/HallC_LinkDef.h +++ b/src/HallC_LinkDef.h @@ -30,6 +30,7 @@ #pragma link C++ class THcHodoscope+; #pragma link C++ class THcScintillatorPlane+; #pragma link C++ class THcRawHodoHit+; +#pragma link C++ class THcHodoHit+; #pragma link C++ class THcDC+; #pragma link C++ class THcDriftChamber+; #pragma link C++ class THcDriftChamberPlane+; diff --git a/src/THcHodoHit.cxx b/src/THcHodoHit.cxx new file mode 100644 index 0000000000000000000000000000000000000000..bd3aa24285144d44740c20856471861836ffe9c0 --- /dev/null +++ b/src/THcHodoHit.cxx @@ -0,0 +1,37 @@ +/////////////////////////////////////////////////////////////////////////////// +// // +// THcHodoHit // +// // +// Class representing a single hit for the Hodoscopes // +// // +/////////////////////////////////////////////////////////////////////////////// + +#include "THcHodoHit.h" + +#include <iostream> + +using std::cout; +using std::endl; + +ClassImp(THcHodoHit) + +THcHodoHit::THcHodoHit( THcRawHodoHit *hit=NULL, Double_t posPed=0.0, + Double_t negPed=0.0, THcScintillatorPlane* sp=NULL) +{ + if(hit) { + fPosTDC = hit->fTDC_pos; + fNegTDC = hit->fTDC_neg; + fPosADC_Ped = hit->fADC_pos - posPed; + fNegADC_Ped = hit->fADC_neg - negPed; + fPaddleNumber = hit->fCounter; + } else { + fPosTDC = -1; + fNegTDC = -1; + fPosADC_Ped = -1000.0; + fNegADC_Ped = -1000.0; + fPaddleNumber = -1; + } + fPlane = sp; +} + +//////////////////////////////////////////////////////////////////////////////// diff --git a/src/THcHodoHit.h b/src/THcHodoHit.h new file mode 100644 index 0000000000000000000000000000000000000000..03c538c8603dc38f84782db963bd6ded36788346 --- /dev/null +++ b/src/THcHodoHit.h @@ -0,0 +1,54 @@ +#ifndef ROOT_THcHodoHit +#define ROOT_THcHodoHit + +/////////////////////////////////////////////////////////////////////////////// +// // +// THcHodoHit // +// // +/////////////////////////////////////////////////////////////////////////////// + +#include "TObject.h" +#include "THcScintillatorPlane.h" +//#include "THcDriftChamber.h" +#include "THcRawHodoHit.h" +#include <cstdio> + +class THcHodoHit : public TObject { + +public: + THcHodoHit( THcRawHodoHit* hit, Double_t posPed, + Double_t negPed, THcScintillatorPlane* sp); + + virtual ~THcHodoHit() {} + + Bool_t IsSortable () const { return kFALSE; } + + // Get and Set Functions + Double_t GetPosADC() const { return fPosADC_Ped; } + Double_t GetNegADC() const { return fNegADC_Ped; } + Int_t GetPosTDC() const { return fPosTDC; } + Int_t GetNegTDC() const { return fNegTDC; } + Int_t GetPaddleNumber() const { return fPaddleNumber; } + +protected: + static const Double_t kBig; //! + + Int_t fPaddleNumber; + Int_t fPosTDC; + Int_t fNegTDC; + Double_t fPosADC_Ped; // Pedestal subtracted ADC + Double_t fNegADC_Ped; // Pedestal subtracted ADC + + THcScintillatorPlane* fPlane; // Pointer to parent scintillator plane + + +private: + THcHodoHit( const THcHodoHit& ); + THcHodoHit& operator=( const THcHodoHit& ); + + ClassDef(THcHodoHit,0) // Drift Chamber Hit +}; + +//////////////////////////////////////////////////////////////////////////////// + +#endif diff --git a/src/THcHodoscope.cxx b/src/THcHodoscope.cxx index b99270228ccfc5f1174334e2b4553c5c5ce458de..bb0e341cd940bb63d83e9eee129d233dccfd3028 100644 --- a/src/THcHodoscope.cxx +++ b/src/THcHodoscope.cxx @@ -15,6 +15,7 @@ /////////////////////////////////////////////////////////////////////////////// #include "THcSignalHit.h" +#include "THcHodoHit.h" #include "THcShower.h" #include "THcCherenkov.h" #include "THcHallCSpectrometer.h" @@ -805,10 +806,7 @@ Int_t THcHodoscope::FineProcess( TClonesArray& tracks ) for(Int_t ip = 0; ip < fNPlanes; ip++ ) { fNScinHits[ip] = fPlanes[ip]->GetNScinHits(); - TClonesArray* scinPosADC = fPlanes[ip]->GetPosADC(); - TClonesArray* scinNegADC = fPlanes[ip]->GetNegADC(); - TClonesArray* scinPosTDC = fPlanes[ip]->GetPosTDC(); - TClonesArray* scinNegTDC = fPlanes[ip]->GetNegTDC(); + TClonesArray* hodoHits = fPlanes[ip]->GetHits(); // first loop over hits with in a single plane fTOFPInfo.clear(); @@ -824,7 +822,7 @@ Int_t THcHodoscope::FineProcess( TClonesArray& tracks ) fTOFPInfo[iphit].scin_pos_time = 0.0; fTOFPInfo[iphit].scin_neg_time = 0.0; - Int_t paddle = ((THcSignalHit*)scinPosTDC->At(iphit))->GetPaddleNumber()-1; + Int_t paddle = ((THcHodoHit*)hodoHits->At(iphit))->GetPaddleNumber()-1; Double_t xHitCoord = theTrack->GetX() + theTrack->GetTheta() * ( fPlanes[ip]->GetZpos() + @@ -855,57 +853,44 @@ Int_t THcHodoscope::FineProcess( TClonesArray& tracks ) if ( TMath::Abs( scinCenter - scinTrnsCoord ) < ( fPlanes[ip]->GetSize() * 0.5 + fPlanes[ip]->GetHodoSlop() ) ){ // Line 293 - if ( ( ((THcSignalHit*)scinPosTDC->At(iphit))->GetData() > fScinTdcMin ) && - ( ((THcSignalHit*)scinPosTDC->At(iphit))->GetData() < fScinTdcMax ) ) { // Line 199 + Double_t adcPhp = ((THcHodoHit*)hodoHits->At(iphit))->GetPosADC(); + Double_t pathp = fPlanes[ip]->GetPosLeft() - scinLongCoord; + Double_t timep = ((THcHodoHit*)hodoHits->At(iphit))->GetPosTDC() * fScinTdcToTime; + timep = timep - fHodoPosPhcCoeff[fPIndex] * + TMath::Sqrt( TMath::Max( 0., ( ( adcPhp / fHodoPosMinPh[fPIndex] ) - 1 ) ) ); + timep = timep - ( pathp / fHodoVelLight[fPIndex] ) - ( fPlanes[ip]->GetZpos() + + ( paddle % 2 ) * fPlanes[ip]->GetDzpos() ) / ( 29.979 * betaP ) * + TMath::Sqrt( 1. + theTrack->GetTheta() * theTrack->GetTheta() + + theTrack->GetPhi() * theTrack->GetPhi() ); + timep = timep - fHodoPosTimeOffset[fPIndex]; + fTOFPInfo[iphit].time_pos = timep; - Double_t adcPh = ((THcSignalHit*)scinPosADC->At(iphit))->GetData(); - fTOFPInfo[iphit].adcPh = adcPh; - Double_t path = fPlanes[ip]->GetPosLeft() - scinLongCoord; - fTOFPInfo[iphit].path = path; - Double_t time = ((THcSignalHit*)scinPosTDC->At(iphit))->GetData() * fScinTdcToTime; - time = time - fHodoPosPhcCoeff[fPIndex] * - TMath::Sqrt( TMath::Max( 0., ( ( adcPh / fHodoPosMinPh[fPIndex] ) - 1 ) ) ); - time = time - ( path / fHodoVelLight[fPIndex] ) - ( fPlanes[ip]->GetZpos() + - ( paddle % 2 ) * fPlanes[ip]->GetDzpos() ) / ( 29.979 * betaP ) * - TMath::Sqrt( 1. + theTrack->GetTheta() * theTrack->GetTheta() + - theTrack->GetPhi() * theTrack->GetPhi() ); - fTOFPInfo[iphit].time = time; - fTOFPInfo[iphit].time_pos = time - fHodoPosTimeOffset[fPIndex]; - - for ( Int_t k = 0; k < 200; k++ ){ // Line 211 - Double_t tmin = 0.5 * ( k + 1 ) ; - if ( ( fTOFPInfo[iphit].time_pos > tmin ) && ( fTOFPInfo[iphit].time_pos < ( tmin + fTofTolerance ) ) ) - timehist[k] ++; - } - } // TDC pos hit condition - + for ( Int_t k = 0; k < 200; k++ ){ // Line 211 + Double_t tmin = 0.5 * ( k + 1 ) ; + if ( ( timep > tmin ) && ( timep < ( tmin + fTofTolerance ) ) ) + timehist[k] ++; + } - if ( ( ((THcSignalHit*)scinNegTDC->At(iphit))->GetData() > fScinTdcMin ) && - ( ((THcSignalHit*)scinNegTDC->At(iphit))->GetData() < fScinTdcMax ) ) { // Line 218 - - Double_t adcPh = ((THcSignalHit*)scinNegADC->At(iphit))->GetData(); - fTOFPInfo[iphit].adcPh = adcPh; - Double_t path = scinLongCoord - fPlanes[ip]->GetPosRight(); - fTOFPInfo[iphit].path = path; - Double_t time = ((THcSignalHit*)scinNegTDC->At(iphit))->GetData() * fScinTdcToTime; - time =time - fHodoNegPhcCoeff[fPIndex] * - TMath::Sqrt( TMath::Max( 0., ( ( adcPh / fHodoNegMinPh[fPIndex] ) - 1 ) ) ); - time = time - ( path / fHodoVelLight[fPIndex] ) - ( fPlanes[ip]->GetZpos() + - ( paddle % 2 ) * fPlanes[ip]->GetDzpos() ) / ( 29.979 * betaP ) * - TMath::Sqrt( 1. + theTrack->GetTheta() * theTrack->GetTheta() + - theTrack->GetPhi() * theTrack->GetPhi() ); - fTOFPInfo[iphit].time = time; - fTOFPInfo[iphit].time_neg = time - fHodoNegTimeOffset[fPIndex]; + Double_t adcPhn = ((THcHodoHit*)hodoHits->At(iphit))->GetNegADC(); + Double_t pathn = scinLongCoord - fPlanes[ip]->GetPosRight(); + Double_t timen = ((THcHodoHit*)hodoHits->At(iphit))->GetNegTDC() * fScinTdcToTime; + timen =timen - fHodoNegPhcCoeff[fPIndex] * + TMath::Sqrt( TMath::Max( 0., ( ( adcPhn / fHodoNegMinPh[fPIndex] ) - 1 ) ) ); + timen = timen - ( pathn / fHodoVelLight[fPIndex] ) - ( fPlanes[ip]->GetZpos() + + ( paddle % 2 ) * fPlanes[ip]->GetDzpos() ) / ( 29.979 * betaP ) * + TMath::Sqrt( 1. + theTrack->GetTheta() * theTrack->GetTheta() + + theTrack->GetPhi() * theTrack->GetPhi() ); + timen = timen - fHodoNegTimeOffset[fPIndex]; + fTOFPInfo[iphit].time_neg = timen; - for ( Int_t k = 0; k < 200; k++ ){ // Line 230 - Double_t tmin = 0.5 * ( k + 1 ); - if ( ( fTOFPInfo[iphit].time_neg > tmin ) && ( fTOFPInfo[iphit].time_neg < ( tmin + fTofTolerance ) ) ) - timehist[k] ++; - } - } // TDC neg hit condition + for ( Int_t k = 0; k < 200; k++ ){ // Line 230 + Double_t tmin = 0.5 * ( k + 1 ); + if ( ( timen > tmin ) && ( timen < ( tmin + fTofTolerance ) ) ) + timehist[k] ++; + } } // condition for cenetr on a paddle } // First loop over hits in a plane <--------- - + //----------------------------------------------------------------------------------------------- //------------- First large loop over scintillator hits in a plane ends here -------------------- //----------------------------------------------------------------------------------------------- @@ -921,16 +906,15 @@ Int_t THcHodoscope::FineProcess( TClonesArray& tracks ) } - Double_t tmin = 0.5 * jmax; - for(Int_t iphit = 0; iphit < fNScinHits[ip]; iphit++) { // Loop over sinc. hits. in plane - if ( ( fTOFPInfo[iphit].time_pos > tmin ) && ( fTOFPInfo[iphit].time_pos < ( tmin + fTofTolerance ) ) ) { - fTOFPInfo[iphit].keep_pos=kTRUE; - } - if ( ( fTOFPInfo[iphit].time_neg > tmin ) && ( fTOFPInfo[iphit].time_neg < ( tmin + fTofTolerance ) ) ){ - fTOFPInfo[iphit].keep_neg=kTRUE; - } - } - + Double_t tmin = 0.5 * jmax; + for(Int_t iphit = 0; iphit < fNScinHits[ip]; iphit++) { // Loop over sinc. hits. in plane + if ( ( fTOFPInfo[iphit].time_pos > tmin ) && ( fTOFPInfo[iphit].time_pos < ( tmin + fTofTolerance ) ) ) { + fTOFPInfo[iphit].keep_pos=kTRUE; + } + if ( ( fTOFPInfo[iphit].time_neg > tmin ) && ( fTOFPInfo[iphit].time_neg < ( tmin + fTofTolerance ) ) ){ + fTOFPInfo[iphit].keep_neg=kTRUE; + } + } //--------------------------------------------------------------------------------------------- // ---------------------- Scond loop over scint. hits in a plane ------------------------------ @@ -950,7 +934,7 @@ Int_t THcHodoscope::FineProcess( TClonesArray& tracks ) // fRawIndex ++; // Is fRawIndex ever different from ihhit Int_t rawindex = ihhit; - Int_t paddle = ((THcSignalHit*)scinPosTDC->At(iphit))->GetPaddleNumber()-1; + Int_t paddle = ((THcHodoHit*)hodoHits->At(iphit))->GetPaddleNumber()-1; fTOFCalc[ihhit].hit_paddle = paddle; fTOFCalc[rawindex].good_raw_pad = paddle; @@ -978,50 +962,38 @@ Int_t THcHodoscope::FineProcess( TClonesArray& tracks ) ( fPlanes[ip]->GetSize() * 0.5 + fPlanes[ip]->GetHodoSlop() ) ){ // Line 293 } else{ - // * * Check for good TDC - if ( ( ((THcSignalHit*)scinPosTDC->At(iphit))->GetData() > fScinTdcMin ) && - ( ((THcSignalHit*)scinPosTDC->At(iphit))->GetData() < fScinTdcMax ) && - ( fTOFPInfo[iphit].keep_pos ) ) { // 301 + if ( fTOFPInfo[iphit].keep_pos ) { // 301 // ** Calculate time for each tube with a good tdc. 'pos' side first. fTOFCalc[ihhit].good_tdc_pos = kTRUE; - Double_t adcPh = ((THcSignalHit*)scinPosADC->At(iphit))->GetData(); - fTOFPInfo[iphit].adcPh = adcPh; + Double_t adcPh = ((THcHodoHit*)hodoHits->At(iphit))->GetPosADC(); Double_t path = fPlanes[ip]->GetPosLeft() - scinLongCoord; - fTOFPInfo[iphit].path = path; // * Convert TDC value to time, do pulse height correction, correction for // * propogation of light thru scintillator, and offset. - Double_t time = ((THcSignalHit*)scinPosTDC->At(iphit))->GetData() * fScinTdcToTime; + Double_t time = ((THcHodoHit*)hodoHits->At(iphit))->GetPosTDC() * fScinTdcToTime; time = time - ( fHodoPosPhcCoeff[fPIndex] * TMath::Sqrt( TMath::Max( 0. , ( ( adcPh / fHodoPosMinPh[fPIndex] ) - 1 ) ) ) ); time = time - ( path / fHodoVelLight[fPIndex] ); - fTOFPInfo[iphit].time = time; fTOFPInfo[iphit].scin_pos_time = time - fHodoPosTimeOffset[fPIndex]; } // check for good pos TDC condition - // ** Repeat for pmts on 'negative' side - if ( ( ((THcSignalHit*)scinNegTDC->At(iphit))->GetData() > fScinTdcMin ) && - ( ((THcSignalHit*)scinNegTDC->At(iphit))->GetData() < fScinTdcMax ) && - ( fTOFPInfo[iphit].keep_neg ) ) { // + if ( fTOFPInfo[iphit].keep_neg ) { // // ** Calculate time for each tube with a good tdc. 'pos' side first. fTOFCalc[ihhit].good_tdc_neg = kTRUE; // fNtof ++; - Double_t adcPh = ((THcSignalHit*)scinNegADC->At(iphit))->GetData(); - fTOFPInfo[iphit].adcPh = adcPh; + Double_t adcPh = ((THcHodoHit*)hodoHits->At(iphit))->GetNegADC(); // Double_t path = fPlanes[ip]->GetPosRight() - scinLongCoord; Double_t path = scinLongCoord - fPlanes[ip]->GetPosRight(); - fTOFPInfo[iphit].path = path; // * Convert TDC value to time, do pulse height correction, correction for // * propogation of light thru scintillator, and offset. - Double_t time = ((THcSignalHit*)scinNegTDC->At(iphit))->GetData() * fScinTdcToTime; + Double_t time = ((THcHodoHit*)hodoHits->At(iphit))->GetNegTDC() * fScinTdcToTime; time = time - ( fHodoNegPhcCoeff[fPIndex] * TMath::Sqrt( TMath::Max( 0. , ( ( adcPh / fHodoNegMinPh[fPIndex] ) - 1 ) ) ) ); time = time - ( path / fHodoVelLight[fPIndex] ); - fTOFPInfo[iphit].time = time; fTOFPInfo[iphit].scin_neg_time = time - fHodoNegTimeOffset[fPIndex]; } // check for good neg TDC condition @@ -1080,18 +1052,18 @@ Int_t THcHodoscope::FineProcess( TClonesArray& tracks ) if ( fTOFCalc[ihhit].good_tdc_pos ){ if ( fTOFCalc[ihhit].good_tdc_neg ){ fdEdX[itrack][fNScinHit[itrack]-1]= - TMath::Sqrt( TMath::Max( 0., ((THcSignalHit*)scinPosADC->At(iphit))->GetData() * - ((THcSignalHit*)scinNegADC->At(iphit))->GetData() ) ); + TMath::Sqrt( TMath::Max( 0., ((THcHodoHit*)hodoHits->At(iphit))->GetPosADC() * + ((THcHodoHit*)hodoHits->At(iphit))->GetNegADC() ) ); } else{ fdEdX[itrack][fNScinHit[itrack]-1]= - TMath::Max( 0., ((THcSignalHit*)scinPosADC->At(iphit))->GetData() ); + TMath::Max( 0., ((THcHodoHit*)hodoHits->At(iphit))->GetPosADC() ); } } else{ if ( fTOFCalc[ihhit].good_tdc_neg ){ fdEdX[itrack][fNScinHit[itrack]-1]= - TMath::Max( 0., ((THcSignalHit*)scinNegADC->At(iphit))->GetData() ); + TMath::Max( 0., ((THcHodoHit*)hodoHits->At(iphit))->GetNegADC() ); } else{ fdEdX[itrack][fNScinHit[itrack]-1]=0.0; @@ -1280,17 +1252,15 @@ Int_t THcHodoscope::FineProcess( TClonesArray& tracks ) if (!fPlanes[ip]) return -1; - TClonesArray* scinPosTDC = fPlanes[ip]->GetPosTDC(); - TClonesArray* scinNegTDC = fPlanes[ip]->GetNegTDC(); + TClonesArray* hodoHits = fPlanes[ip]->GetHits(); + // TClonesArray* scinPosTDC = fPlanes[ip]->GetPosTDC(); + // TClonesArray* scinNegTDC = fPlanes[ip]->GetNegTDC(); fNScinHits[ip] = fPlanes[ip]->GetNScinHits(); for (Int_t iphit = 0; iphit < fNScinHits[ip]; iphit++ ){ - Int_t paddlePos = ((THcSignalHit*)scinPosTDC->At(iphit))->GetPaddleNumber()-1; - Int_t paddleNeg = ((THcSignalHit*)scinNegTDC->At(iphit))->GetPaddleNumber()-1; - if ( paddlePos != paddleNeg ) - return -1; + Int_t paddle = ((THcHodoHit*)hodoHits->At(iphit))->GetPaddleNumber()-1; - fScinHitPaddle[ip][paddlePos] = 1; + fScinHitPaddle[ip][paddle] = 1; } } diff --git a/src/THcHodoscope.h b/src/THcHodoscope.h index 4617fa1efe5acff843a8a415a62a1bd3d12658f5..a72b32e01d5742285f080ab6ed16b4be4349a43b 100644 --- a/src/THcHodoscope.h +++ b/src/THcHodoscope.h @@ -229,9 +229,9 @@ protected: Double_t time_neg; Bool_t keep_pos; Bool_t keep_neg; - Double_t adcPh; - Double_t path; - Double_t time; + // Double_t adcPh; + // Double_t path; + // Double_t time; Double_t scin_pos_time; Double_t scin_neg_time; TOFPInfo () : time_pos(-99.0), time_neg(-99.0), keep_pos(kFALSE), diff --git a/src/THcRawHodoHit.h b/src/THcRawHodoHit.h index b4d3702c5bd7b9b0844628796afcbd180369dea6..7e5614b4865fc4bb8478dc013f46e695c37d81a6 100644 --- a/src/THcRawHodoHit.h +++ b/src/THcRawHodoHit.h @@ -8,6 +8,7 @@ class THcRawHodoHit : public THcRawHit { public: friend class THcScintillatorPlane; friend class THcHodoscope; + friend class THcHodoHit; THcRawHodoHit(Int_t plane=0, Int_t counter=0) : THcRawHit(plane, counter), fADC_pos(-1), fADC_neg(-1), diff --git a/src/THcScintillatorPlane.cxx b/src/THcScintillatorPlane.cxx index 64aa1dd21ec0ed14d11b246ecc9ed1131365dbc4..9556cbed4e1b02d653d08085ea2fc2cbb2ae5353 100644 --- a/src/THcScintillatorPlane.cxx +++ b/src/THcScintillatorPlane.cxx @@ -9,6 +9,7 @@ #include "THcScintillatorPlane.h" #include "TClonesArray.h" #include "THcSignalHit.h" +#include "THcHodoHit.h" #include "THcGlobals.h" #include "THcParmList.h" #include "THcHitList.h" @@ -32,10 +33,7 @@ THcScintillatorPlane::THcScintillatorPlane( const char* name, : THaSubDetector(name,description,parent) { // Normal constructor with name and description - fPosTDCHits = new TClonesArray("THcSignalHit",16); - fNegTDCHits = new TClonesArray("THcSignalHit",16); - fPosADCHits = new TClonesArray("THcSignalHit",16); - fNegADCHits = new TClonesArray("THcSignalHit",16); + fHodoHits = new TClonesArray("THcHodoHit",16); frPosTDCHits = new TClonesArray("THcSignalHit",16); frNegTDCHits = new TClonesArray("THcSignalHit",16); frPosADCHits = new TClonesArray("THcSignalHit",16); @@ -57,10 +55,7 @@ THcScintillatorPlane::THcScintillatorPlane( const char* name, THcScintillatorPlane::~THcScintillatorPlane() { // Destructor - delete fPosTDCHits; - delete fNegTDCHits; - delete fPosADCHits; - delete fNegADCHits; + delete fHodoHits; delete frPosTDCHits; delete frNegTDCHits; delete frPosADCHits; @@ -248,10 +243,7 @@ void THcScintillatorPlane::Clear( Option_t* ) { //cout << " Calling THcScintillatorPlane::Clear " << GetName() << endl; // Clears the hit lists - fPosTDCHits->Clear(); - fNegTDCHits->Clear(); - fPosADCHits->Clear(); - fNegADCHits->Clear(); + fHodoHits->Clear(); frPosTDCHits->Clear(); frNegTDCHits->Clear(); frPosADCHits->Clear(); @@ -307,15 +299,8 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) frPosADCHits->Clear(); frNegADCHits->Clear(); //stripped - Int_t nPosTDCHits=0; - Int_t nNegTDCHits=0; - Int_t nPosADCHits=0; - Int_t nNegADCHits=0; fNScinHits=0; - fPosTDCHits->Clear(); - fNegTDCHits->Clear(); - fPosADCHits->Clear(); - fNegADCHits->Clear(); + fHodoHits->Clear(); Int_t nrawhits = rawhits->GetLast()+1; // cout << "THcScintillatorPlane::ProcessHits " << fPlaneNum << " " << nexthit << "/" << nrawhits << endl; Int_t ihit = nexthit; @@ -342,19 +327,8 @@ Int_t THcScintillatorPlane::ProcessHits(TClonesArray* rawhits, Int_t nexthit) if (((hit->fTDC_pos >= fScinTdcMin) && (hit->fTDC_pos <= fScinTdcMax)) || ((hit->fTDC_neg >= fScinTdcMin) && (hit->fTDC_neg <= fScinTdcMax))) { - //TDC positive hit - THcSignalHit *sighit = (THcSignalHit*) fPosTDCHits->ConstructedAt(nPosTDCHits++); - sighit->Set(padnum, hit->fTDC_pos); - // TDC negative hit - THcSignalHit *sighit2 = (THcSignalHit*) fNegTDCHits->ConstructedAt(nNegTDCHits++); - sighit2->Set(padnum, hit->fTDC_neg); - // ADC positive hit - THcSignalHit *sighit3 = (THcSignalHit*) fPosADCHits->ConstructedAt(nPosADCHits++); - sighit3->Set(padnum, hit->fADC_pos-fPosPed[index]); - // ADC negative hit - THcSignalHit *sighit4 = (THcSignalHit*) fNegADCHits->ConstructedAt(nNegADCHits++); - sighit4->Set(padnum, hit->fADC_neg-fNegPed[index]); - fNScinHits++; + // If TDC values are all good, transfer the raw hit to the HodoHit list + new( (*fHodoHits)[fNScinHits++]) THcHodoHit(hit, fPosPed[index], fNegPed[index], this); } else { } @@ -406,47 +380,42 @@ Int_t THcScintillatorPlane::PulseHeightCorrection() fpTime=-1e5; for (Int_t i=0;i<fNScinHits;i++) { - if ((((THcSignalHit*) fPosTDCHits->At(i))->GetData()>=fScinTdcMin) && - (((THcSignalHit*) fPosTDCHits->At(i))->GetData()<=fScinTdcMax) && - (((THcSignalHit*) fNegTDCHits->At(i))->GetData()>=fScinTdcMin) && - (((THcSignalHit*) fNegTDCHits->At(i))->GetData()<=fScinTdcMax)) { - pos_ph[i]=((THcSignalHit*) fPosADCHits->At(i))->GetData(); - postime[i]=((THcSignalHit*) fPosTDCHits->At(i))->GetData()*fScinTdcToTime; - Int_t jpos=((THcSignalHit*)fPosTDCHits->At(i))->GetPaddleNumber()-1; - postime[i]=postime[i]-fHodoPosPhcCoeff[jpos]* - TMath::Sqrt(TMath::Max(0.,(pos_ph[i]/fHodoPosMinPh[jpos]-1))); - postime[i]=postime[i]-fHodoPosTimeOffset[jpos]; - - neg_ph[i]=((THcSignalHit*) fNegADCHits->At(i))->GetData(); - negtime[i]=((THcSignalHit*) fNegTDCHits->At(i))->GetData()*fScinTdcToTime; - Int_t jneg=((THcSignalHit*)fNegTDCHits->At(i))->GetPaddleNumber()-1; - assert(jpos==jneg); - negtime[i]=negtime[i]-fHodoNegPhcCoeff[jneg]* - TMath::Sqrt(TMath::Max(0.,(neg_ph[i]/fHodoNegMinPh[jneg]-1))); - negtime[i]=negtime[i]-fHodoNegTimeOffset[jneg]; - - // Find hit position. If postime larger, then hit was nearer negative side. - dist_from_center=0.5*(negtime[i]-postime[i])*fHodoVelLight[jpos]; - scint_center=0.5*(fPosLeft+fPosRight); - hit_position=scint_center+dist_from_center; - hit_position=TMath::Min(hit_position,fPosLeft); - hit_position=TMath::Max(hit_position,fPosRight); - postime[i]=postime[i]-(fPosLeft-hit_position)/fHodoVelLight[jpos]; - negtime[i]=negtime[i]-(hit_position-fPosRight)/fHodoVelLight[jpos]; - - time_pos[i]=postime[i]-(fZpos+(jpos%2)*fDzpos)/(29.979*fBetaNominal); - time_neg[i]=negtime[i]-(fZpos+(jpos%2)*fDzpos)/(29.979*fBetaNominal); - // nfound++; - for (Int_t k=0;k<200;k++) { - Double_t tmin=0.5*(k+1); - if ((time_pos[i]> tmin) && (time_pos[i] < tmin+fTofTolerance)) { - timehist[k]++; - } - if ((time_neg[i]> tmin) && (time_neg[i] < tmin+fTofTolerance)) { - timehist[k]++; - } - } + // Perhaps these calculations should be done in the THcHodoHit class so + // that they don't get repeated + Int_t index=((THcHodoHit*)fHodoHits->At(i))->GetPaddleNumber()-1; + + pos_ph[i]=((THcHodoHit*) fHodoHits->At(i))->GetPosADC(); + postime[i]=((THcHodoHit*) fHodoHits->At(i))->GetPosTDC()*fScinTdcToTime; + postime[i]=postime[i]-fHodoPosPhcCoeff[index]* + TMath::Sqrt(TMath::Max(0.,(pos_ph[i]/fHodoPosMinPh[index]-1))); + postime[i]=postime[i]-fHodoPosTimeOffset[index]; + + neg_ph[i]=((THcHodoHit*) fHodoHits->At(i))->GetNegADC(); + negtime[i]=((THcHodoHit*) fHodoHits->At(i))->GetNegTDC()*fScinTdcToTime; + negtime[i]=negtime[i]-fHodoNegPhcCoeff[index]* + TMath::Sqrt(TMath::Max(0.,(neg_ph[i]/fHodoNegMinPh[index]-1))); + negtime[i]=negtime[i]-fHodoNegTimeOffset[index]; + + // Find hit position. If postime larger, then hit was nearer negative side. + dist_from_center=0.5*(negtime[i]-postime[i])*fHodoVelLight[index]; + scint_center=0.5*(fPosLeft+fPosRight); + hit_position=scint_center+dist_from_center; + hit_position=TMath::Min(hit_position,fPosLeft); + hit_position=TMath::Max(hit_position,fPosRight); + postime[i]=postime[i]-(fPosLeft-hit_position)/fHodoVelLight[index]; + negtime[i]=negtime[i]-(hit_position-fPosRight)/fHodoVelLight[index]; + + time_pos[i]=postime[i]-(fZpos+(index%2)*fDzpos)/(29.979*fBetaNominal); + time_neg[i]=negtime[i]-(fZpos+(index%2)*fDzpos)/(29.979*fBetaNominal); // nfound++; + for (Int_t k=0;k<200;k++) { + Double_t tmin=0.5*(k+1); + if ((time_pos[i]> tmin) && (time_pos[i] < tmin+fTofTolerance)) { + timehist[k]++; + } + if ((time_neg[i]> tmin) && (time_neg[i] < tmin+fTofTolerance)) { + timehist[k]++; + } } } // Find the bin with most hits @@ -463,45 +432,40 @@ Int_t THcScintillatorPlane::PulseHeightCorrection() // Resume regular tof code, now using time filer(?) from above // Check for TWO good TDC hits for (Int_t i=0;i<fNScinHits;i++) { - if ((((THcSignalHit*) fPosTDCHits->At(i))->GetData()>=fScinTdcMin) && - (((THcSignalHit*) fPosTDCHits->At(i))->GetData()<=fScinTdcMax) && - (((THcSignalHit*) fNegTDCHits->At(i))->GetData()>=fScinTdcMin) && - (((THcSignalHit*) fNegTDCHits->At(i))->GetData()<=fScinTdcMax)) { - Double_t tmin = 0.5*jmax; - if ((time_pos[i]>tmin) && (time_pos[i]<tmin+fTofTolerance) && - (time_neg[i]>tmin) && (time_neg[i]<tmin+fTofTolerance)) - two_good_times[i]=kTRUE; - } + Double_t tmin = 0.5*jmax; + if ((time_pos[i]>tmin) && (time_pos[i]<tmin+fTofTolerance) && + (time_neg[i]>tmin) && (time_neg[i]<tmin+fTofTolerance)) + two_good_times[i]=kTRUE; } // end of loop that finds tube setting time for (Int_t i=0;i<fNScinHits;i++) { if (two_good_times[i]) { // both tubes fired // correct time for everything except veloc. correction in order // to find hit location from difference in TDC. - pos_ph[i]=((THcSignalHit*) fPosADCHits->At(i))->GetData(); - postime[i]=((THcSignalHit*) fPosTDCHits->At(i))->GetData()*fScinTdcToTime; - Int_t jpos=((THcSignalHit*)fPosTDCHits->At(i))->GetPaddleNumber()-1; - postime[i]=postime[i]-fHodoPosPhcCoeff[jpos]* - TMath::Sqrt(TMath::Max(0.,(pos_ph[i]/fHodoPosMinPh[jpos]-1))); - postime[i]=postime[i]-fHodoPosTimeOffset[jpos]; - // - neg_ph[i]=((THcSignalHit*) fNegADCHits->At(i))->GetData(); - negtime[i]=((THcSignalHit*) fNegTDCHits->At(i))->GetData()*fScinTdcToTime; - Int_t jneg=((THcSignalHit*)fNegTDCHits->At(i))->GetPaddleNumber()-1; - assert(jpos==jneg); - negtime[i]=negtime[i]-fHodoNegPhcCoeff[jneg]* - TMath::Sqrt(TMath::Max(0.,(neg_ph[i]/fHodoNegMinPh[jneg]-1))); - negtime[i]=negtime[i]-fHodoNegTimeOffset[jneg]; + // We are repeating some stuff here. Should save it all in the hit + // class so it doesn't have to be recalculated. (Avoid mistakes too) + Int_t index=((THcHodoHit*)fHodoHits->At(i))->GetPaddleNumber()-1; + pos_ph[i]=((THcHodoHit*) fHodoHits->At(i))->GetPosADC(); + postime[i]=((THcHodoHit*) fHodoHits->At(i))->GetPosTDC()*fScinTdcToTime; + postime[i]=postime[i]-fHodoPosPhcCoeff[index]* + TMath::Sqrt(TMath::Max(0.,(pos_ph[i]/fHodoPosMinPh[index]-1))); + postime[i]=postime[i]-fHodoPosTimeOffset[index]; + + neg_ph[i]=((THcHodoHit*) fHodoHits->At(i))->GetNegADC(); + negtime[i]=((THcHodoHit*) fHodoHits->At(i))->GetNegTDC()*fScinTdcToTime; + negtime[i]=negtime[i]-fHodoNegPhcCoeff[index]* + TMath::Sqrt(TMath::Max(0.,(neg_ph[i]/fHodoNegMinPh[index]-1))); + negtime[i]=negtime[i]-fHodoNegTimeOffset[index]; + // find hit position. If postime larger, then hit was nearer negative side - dist_from_center=0.5*(negtime[i]-postime[i])*fHodoVelLight[jpos]; + dist_from_center=0.5*(negtime[i]-postime[i])*fHodoVelLight[index]; scint_center=0.5*(fPosLeft+fPosRight); hit_position=scint_center+dist_from_center; hit_position=TMath::Min(hit_position,fPosLeft); hit_position=TMath::Max(hit_position,fPosRight); - postime[i]=postime[i]-(fPosLeft-hit_position)/fHodoVelLight[jpos]; - negtime[i]=negtime[i]-(hit_position-fPosRight)/fHodoVelLight[jpos]; + postime[i]=postime[i]-(fPosLeft-hit_position)/fHodoVelLight[index]; + negtime[i]=negtime[i]-(hit_position-fPosRight)/fHodoVelLight[index]; scin_corrected_time[i]=0.5*(postime[i]+negtime[i]); - } - else { // only one tube fired + } 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! } @@ -511,7 +475,7 @@ Int_t THcScintillatorPlane::PulseHeightCorrection() fNScinGoodHits=0; for (Int_t i=0;i<fNScinHits;i++) { - Int_t j=((THcSignalHit*)fNegTDCHits->At(i))->GetPaddleNumber()-1; + Int_t j=((THcHodoHit*)fHodoHits->At(i))->GetPaddleNumber()-1; if (two_good_times[i]) { // both tubes fired fpTimes[fNScinGoodHits]=scin_corrected_time[i]-(fZpos+(j%2)*fDzpos)/(29.979*fBetaNominal); fScinTime[fNScinGoodHits]=scin_corrected_time[i]; diff --git a/src/THcScintillatorPlane.h b/src/THcScintillatorPlane.h index f619a2bedaf1a957d4dd46c41a7a5c1f35774df7..70db898e98f961e21acf368c94cee6b5e70e17bd 100644 --- a/src/THcScintillatorPlane.h +++ b/src/THcScintillatorPlane.h @@ -61,10 +61,7 @@ class THcScintillatorPlane : public THaSubDetector { TClonesArray* fParentHitList; - TClonesArray* GetPosADC() { return fPosADCHits;}; // Ahmed - TClonesArray* GetNegADC() { return fNegADCHits;}; // Ahmed - TClonesArray* GetPosTDC() { return fPosTDCHits;}; // Ahmed - TClonesArray* GetNegTDC() { return fNegTDCHits;}; // Ahmed + TClonesArray* GetHits() { return fHodoHits;}; protected: @@ -72,10 +69,7 @@ class THcScintillatorPlane : public THaSubDetector { TClonesArray* frNegTDCHits; TClonesArray* frPosADCHits; TClonesArray* frNegADCHits; - TClonesArray* fPosTDCHits; - TClonesArray* fNegTDCHits; - TClonesArray* fPosADCHits; - TClonesArray* fNegADCHits; + TClonesArray* fHodoHits; Int_t fPlaneNum; /* Which plane am I 1-4 */ UInt_t fTotPlanes; /* so we can read variables that are not indexed by plane id */