diff --git a/src/THcScintillatorPlane.cxx b/src/THcScintillatorPlane.cxx index d80406d008a77c6a70d3d3945435fc44ba7c5812..38033103faf6282a290bc04b300eea391a3faa2b 100644 --- a/src/THcScintillatorPlane.cxx +++ b/src/THcScintillatorPlane.cxx @@ -248,16 +248,17 @@ Int_t THcScintillatorPlane::ReadDatabase( const TDatime& date ) // Retrieve parameters we need from parent class // Common for all planes - fHodoSlop= ((THcHodoscope*) GetParent())->GetHodoSlop(fPlaneNum-1); - fTdcOffset= ((THcHodoscope*) GetParent())->GetTdcOffset(fPlaneNum-1); - fAdcTdcOffset= ((THcHodoscope*) GetParent())->GetAdcTdcOffset(fPlaneNum-1); - fScinTdcMin=((THcHodoscope *)GetParent())->GetTdcMin(); - fScinTdcMax=((THcHodoscope *)GetParent())->GetTdcMax(); - fScinTdcToTime=((THcHodoscope *)GetParent())->GetTdcToTime(); - fTofTolerance=((THcHodoscope *)GetParent())->GetTofTolerance(); - fBetaNominal=((THcHodoscope *)GetParent())->GetBetaNominal(); - fStartTimeCenter=((THcHodoscope *)GetParent())->GetStartTimeCenter(); - fStartTimeSlop=((THcHodoscope *)GetParent())->GetStartTimeSlop(); + THcHodoscope* parent = (THcHodoscope*)GetParent(); + fHodoSlop= parent->GetHodoSlop(fPlaneNum-1); + fTdcOffset= parent->GetTdcOffset(fPlaneNum-1); + fAdcTdcOffset= parent->GetAdcTdcOffset(fPlaneNum-1); + fScinTdcMin=parent->GetTdcMin(); + fScinTdcMax=parent->GetTdcMax(); + fScinTdcToTime=parent->GetTdcToTime(); + fTofTolerance=parent->GetTofTolerance(); + fBetaNominal=parent->GetBetaNominal(); + fStartTimeCenter=parent->GetStartTimeCenter(); + fStartTimeSlop=parent->GetStartTimeSlop(); // Parameters for this plane fHodoPosMinPh = new Double_t[fNelem]; fHodoNegMinPh = new Double_t[fNelem]; @@ -288,35 +289,35 @@ Int_t THcScintillatorPlane::ReadDatabase( const TDatime& date ) fHodoNeg_c2=new Double_t [fNelem]; for(Int_t j=0;j<(Int_t) fNelem;j++) { - Int_t index=((THcHodoscope *)GetParent())->GetScinIndex(fPlaneNum-1,j); - fHodoPosAdcTimeWindowMin[j] = ((THcHodoscope*) GetParent())->GetHodoPosAdcTimeWindowMin(index); - fHodoPosAdcTimeWindowMax[j] = ((THcHodoscope*) GetParent())->GetHodoPosAdcTimeWindowMax(index); - fHodoNegAdcTimeWindowMin[j] = ((THcHodoscope*) GetParent())->GetHodoNegAdcTimeWindowMin(index); - fHodoNegAdcTimeWindowMax[j] = ((THcHodoscope*) GetParent())->GetHodoNegAdcTimeWindowMax(index); - fHodoPosMinPh[j] = ((THcHodoscope *)GetParent())->GetHodoPosMinPh(index); - fHodoNegMinPh[j] = ((THcHodoscope *)GetParent())->GetHodoNegMinPh(index); - fHodoPosPhcCoeff[j] = ((THcHodoscope *)GetParent())->GetHodoPosPhcCoeff(index); - fHodoNegPhcCoeff[j] = ((THcHodoscope *)GetParent())->GetHodoNegPhcCoeff(index); - fHodoPosTimeOffset[j] = ((THcHodoscope *)GetParent())->GetHodoPosTimeOffset(index); - fHodoNegTimeOffset[j] = ((THcHodoscope *)GetParent())->GetHodoNegTimeOffset(index); - fHodoPosInvAdcOffset[j] = ((THcHodoscope *)GetParent())->GetHodoPosInvAdcOffset(index); - fHodoNegInvAdcOffset[j] = ((THcHodoscope *)GetParent())->GetHodoNegInvAdcOffset(index); - fHodoPosInvAdcLinear[j] = ((THcHodoscope *)GetParent())->GetHodoPosInvAdcLinear(index); - fHodoNegInvAdcLinear[j] = ((THcHodoscope *)GetParent())->GetHodoNegInvAdcLinear(index); - fHodoPosInvAdcAdc[j] = ((THcHodoscope *)GetParent())->GetHodoPosInvAdcAdc(index); - fHodoNegInvAdcAdc[j] = ((THcHodoscope *)GetParent())->GetHodoNegInvAdcAdc(index); - fHodoVelLight[j] = ((THcHodoscope *)GetParent())->GetHodoVelLight(index); + Int_t index=parent->GetScinIndex(fPlaneNum-1,j); + fHodoPosAdcTimeWindowMin[j] = parent->GetHodoPosAdcTimeWindowMin(index); + fHodoPosAdcTimeWindowMax[j] = parent->GetHodoPosAdcTimeWindowMax(index); + fHodoNegAdcTimeWindowMin[j] = parent->GetHodoNegAdcTimeWindowMin(index); + fHodoNegAdcTimeWindowMax[j] = parent->GetHodoNegAdcTimeWindowMax(index); + fHodoPosMinPh[j] = parent->GetHodoPosMinPh(index); + fHodoNegMinPh[j] = parent->GetHodoNegMinPh(index); + fHodoPosPhcCoeff[j] = parent->GetHodoPosPhcCoeff(index); + fHodoNegPhcCoeff[j] = parent->GetHodoNegPhcCoeff(index); + fHodoPosTimeOffset[j] = parent->GetHodoPosTimeOffset(index); + fHodoNegTimeOffset[j] = parent->GetHodoNegTimeOffset(index); + fHodoPosInvAdcOffset[j] = parent->GetHodoPosInvAdcOffset(index); + fHodoNegInvAdcOffset[j] = parent->GetHodoNegInvAdcOffset(index); + fHodoPosInvAdcLinear[j] = parent->GetHodoPosInvAdcLinear(index); + fHodoNegInvAdcLinear[j] = parent->GetHodoNegInvAdcLinear(index); + fHodoPosInvAdcAdc[j] = parent->GetHodoPosInvAdcAdc(index); + fHodoNegInvAdcAdc[j] = parent->GetHodoNegInvAdcAdc(index); + fHodoVelLight[j] = parent->GetHodoVelLight(index); //Get Time-Walk correction param - fHodoVelFit[j] = ((THcHodoscope *)GetParent())->GetHodoVelFit(index); - fHodoCableFit[j] = ((THcHodoscope *)GetParent())->GetHodoCableFit(index); - fHodo_LCoeff[j] = ((THcHodoscope *)GetParent())->GetHodoLCoeff(index); - fHodoPos_c1[j] = ((THcHodoscope *)GetParent())->GetHodoPos_c1(index); - fHodoNeg_c1[j] = ((THcHodoscope *)GetParent())->GetHodoNeg_c1(index); - fHodoPos_c2[j] = ((THcHodoscope *)GetParent())->GetHodoPos_c2(index); - fHodoNeg_c2[j] = ((THcHodoscope *)GetParent())->GetHodoNeg_c2(index); + fHodoVelFit[j] = parent->GetHodoVelFit(index); + fHodoCableFit[j] = parent->GetHodoCableFit(index); + fHodo_LCoeff[j] = parent->GetHodoLCoeff(index); + fHodoPos_c1[j] = parent->GetHodoPos_c1(index); + fHodoNeg_c1[j] = parent->GetHodoNeg_c1(index); + fHodoPos_c2[j] = parent->GetHodoPos_c2(index); + fHodoNeg_c2[j] = parent->GetHodoNeg_c2(index); - Double_t possigma = ((THcHodoscope *)GetParent())->GetHodoPosSigma(index); - Double_t negsigma = ((THcHodoscope *)GetParent())->GetHodoNegSigma(index); + Double_t possigma = parent->GetHodoPosSigma(index); + Double_t negsigma = parent->GetHodoNegSigma(index); fHodoSigma[j] = TMath::Sqrt(possigma*possigma+negsigma*negsigma)/2.0; @@ -324,7 +325,7 @@ Int_t THcScintillatorPlane::ReadDatabase( const TDatime& date ) } - fTdc_Thrs = ((THcHodoscope *)GetParent())->GetTDCThrs(); + fTdc_Thrs = parent->GetTDCThrs(); // cout <<" plane num = "<<fPlaneNum<<endl; // cout <<" nelem = "<<fNelem<<endl; // cout <<" zpos = "<<fZpos<<endl; diff --git a/src/THcShowerArray.cxx b/src/THcShowerArray.cxx index dc246b2c1dbd7dc38a895097dd8fdbcb57845cbf..6a30172f1c1cbac292d59a38e18164ef8bdf9aeb 100644 --- a/src/THcShowerArray.cxx +++ b/src/THcShowerArray.cxx @@ -198,10 +198,9 @@ Int_t THcShowerArray::ReadDatabase( const TDatime& date ) // Debug output. - THcShower* fParent; - fParent = (THcShower*) GetParent(); + fParent = GetParent(); - if (fParent->fdbg_init_cal) { + if (static_cast<THcShower*>(fParent)->fdbg_init_cal) { cout << "---------------------------------------------------------------\n"; cout << "Debug output from THcShowerArray::ReadDatabase for " << GetParent()->GetPrefix() << ":" << endl; @@ -289,7 +288,7 @@ Int_t THcShowerArray::ReadDatabase( const TDatime& date ) gHcParms->LoadParmValues((DBRequest*)&list1, prefix); // Debug output. - if (fParent->fdbg_init_cal) { + if (static_cast<THcShower*>(fParent)->fdbg_init_cal) { cout << " fPedLimit:" << endl; Int_t el=0; @@ -330,7 +329,7 @@ Int_t THcShowerArray::ReadDatabase( const TDatime& date ) } // Debug output. - if (fParent->fdbg_init_cal) { + if (static_cast<THcShower*>(fParent)->fdbg_init_cal) { cout << " fGain:" << endl; Int_t el=0; @@ -344,7 +343,7 @@ Int_t THcShowerArray::ReadDatabase( const TDatime& date ) } - fMinPeds = fParent->GetMinPeds(); + fMinPeds = static_cast<THcShower*>(fParent)->GetMinPeds(); InitializePedestals(); @@ -386,7 +385,7 @@ Int_t THcShowerArray::ReadDatabase( const TDatime& date ) // Debug output. - if (fParent->fdbg_init_cal) { + if (static_cast<THcShower*>(fParent)->fdbg_init_cal) { cout << " fMinPeds = " << fMinPeds << endl; @@ -407,9 +406,9 @@ Int_t THcShowerArray::DefineVariables( EMode mode ) // Register counters for efficiency calculations in gHcParms so that the // variables can be used in end of run reports. - gHcParms->Define(Form("%sstat_trksum_array", GetParent()->GetPrefix()), + gHcParms->Define(Form("%sstat_trksum_array", fParent->GetPrefix()), "Number of tracks in calo. array", fTotStatNumTrk); - gHcParms->Define(Form("%sstat_hitsum_array", GetParent()->GetPrefix()), + gHcParms->Define(Form("%sstat_hitsum_array", fParent->GetPrefix()), "Number of hits in calo. array", fTotStatNumHit); // Register variables in global list @@ -543,9 +542,7 @@ Int_t THcShowerArray::CoarseProcess( TClonesArray& tracks ) } //Debug output, print out hits before clustering. - THcShower* fParent = (THcShower*) GetParent(); - - if (fParent->fdbg_clusters_cal) { + if (static_cast<THcShower*>(fParent)->fdbg_clusters_cal) { cout << "---------------------------------------------------------------\n"; cout << "Debug output from THcShowerArray::CoarseProcess for " << GetName() << endl; @@ -569,7 +566,7 @@ Int_t THcShowerArray::CoarseProcess( TClonesArray& tracks ) // Cluster hits and fill list of clusters. - fParent->ClusterHits(HitSet, fClusterList); + static_cast<THcShower*>(fParent)->ClusterHits(HitSet, fClusterList); fNclust = (*fClusterList).size(); //number of clusters @@ -588,7 +585,7 @@ Int_t THcShowerArray::CoarseProcess( TClonesArray& tracks ) //Debug output, print out clustered hits. - if (fParent->fdbg_clusters_cal) { + if (static_cast<THcShower*>(fParent)->fdbg_clusters_cal) { cout << " Clustered hits. Number of clusters: " << fNclust << endl; @@ -637,9 +634,7 @@ Int_t THcShowerArray::MatchCluster(THaTrack* Track, fOrigin = GetOrigin(); - THcShower* fParent = (THcShower*) GetParent(); - - fParent->CalcTrackIntercept(Track, pathl, XTrFront, YTrFront); + static_cast<THcShower*>(fParent)->CalcTrackIntercept(Track, pathl, XTrFront, YTrFront); // Transform coordiantes to the spectrometer's coordinate system. @@ -650,7 +645,7 @@ Int_t THcShowerArray::MatchCluster(THaTrack* Track, // Re-evaluate Fid. Volume Flag if fid. volume test is requested - if (fParent->fvTest) { + if (static_cast<THcShower*>(fParent)->fvTest) { TVector3 Origin = fOrigin; //save fOrigin @@ -662,15 +657,15 @@ Int_t THcShowerArray::MatchCluster(THaTrack* Track, Double_t XTrBack = kBig; Double_t YTrBack = kBig; - fParent->CalcTrackIntercept(Track, pathl, XTrBack, YTrBack); + static_cast<THcShower*>(fParent)->CalcTrackIntercept(Track, pathl, XTrBack, YTrBack); XTrBack += GetOrigin().X(); // from local coord. system YTrBack += GetOrigin().Y(); // to the spectrometer system - inFidVol = (XTrFront <= fParent->fvXmax) && (XTrFront >= fParent->fvXmin) && - (YTrFront <= fParent->fvYmax) && (YTrFront >= fParent->fvYmin) && - (XTrBack <= fParent->fvXmax) && (XTrBack >= fParent->fvXmin) && - (YTrBack <= fParent->fvYmax) && (YTrBack >= fParent->fvYmin); + inFidVol = (XTrFront <= static_cast<THcShower*>(fParent)->fvXmax) && (XTrFront >= static_cast<THcShower*>(fParent)->fvXmin) && + (YTrFront <= static_cast<THcShower*>(fParent)->fvYmax) && (YTrFront >= static_cast<THcShower*>(fParent)->fvYmin) && + (XTrBack <= static_cast<THcShower*>(fParent)->fvXmax) && (XTrBack >= static_cast<THcShower*>(fParent)->fvXmin) && + (YTrBack <= static_cast<THcShower*>(fParent)->fvYmax) && (YTrBack >= static_cast<THcShower*>(fParent)->fvYmin); fOrigin = Origin; //restore fOrigin } @@ -692,13 +687,13 @@ Int_t THcShowerArray::MatchCluster(THaTrack* Track, Double_t dx = TMath::Abs( clX(cluster) - XTrFront ); Double_t dy = TMath::Abs( clY(cluster) - YTrFront ); Double_t distance = TMath::Sqrt(dx*dx+dy*dy); //cluster-track dist. - if (fParent->fdbg_tracks_cal) { - cout << " match clust = " << i << " clX = " << clX(cluster)<< " clY = " << clY(cluster) << " distacne = " << distance << " test = " << (0.5*(fXStep + fYStep) + fParent->fSlop) << endl; + if (static_cast<THcShower*>(fParent)->fdbg_tracks_cal) { + cout << " match clust = " << i << " clX = " << clX(cluster)<< " clY = " << clY(cluster) << " distacne = " << distance << " test = " << (0.5*(fXStep + fYStep) + static_cast<THcShower*>(fParent)->fSlop) << endl; } //Choice of threshold on distance is not unuque. Use the simplest for now. - if (distance <= (0.5*(fXStep + fYStep) + fParent->fSlop)) { + if (distance <= (0.5*(fXStep + fYStep) + static_cast<THcShower*>(fParent)->fSlop)) { fNtracks++; if (distance < Delta) { mclust = i; @@ -713,7 +708,7 @@ Int_t THcShowerArray::MatchCluster(THaTrack* Track, //Debug output. - if (fParent->fdbg_tracks_cal) { + if (static_cast<THcShower*>(fParent)->fdbg_tracks_cal) { cout << "---------------------------------------------------------------\n"; cout << "Debug output from THcShowerArray::MatchCluster for " << GetName() << endl; @@ -729,7 +724,7 @@ Int_t THcShowerArray::MatchCluster(THaTrack* Track, << " Y = " << YTrFront << " Pathl = " << pathl << endl; - if (fParent->fvTest) + if (static_cast<THcShower*>(fParent)->fvTest) cout << " Fiducial volume test: inFidVol = " << inFidVol << endl; cout << " Matched cluster #" << mclust << ", Delta = " << Delta << endl; @@ -768,9 +763,7 @@ Float_t THcShowerArray::GetShEnergy(THaTrack* Track) { //Debug output. - THcShower* fParent = (THcShower*) GetParent(); - - if (fParent->fdbg_tracks_cal) { + if (static_cast<THcShower*>(fParent)->fdbg_tracks_cal) { cout << "---------------------------------------------------------------\n"; cout << "Debug output from THcShowerArray::GetShEnergy for " << GetName() << endl; @@ -797,9 +790,7 @@ Int_t THcShowerArray::FineProcess( TClonesArray& tracks ) //_____________________________________________________________________________ Int_t THcShowerArray::CoarseProcessHits() { - THcShower* fParent; - fParent = (THcShower*) GetParent(); - Int_t ADCMode=fParent->GetADCMode(); + Int_t ADCMode=static_cast<THcShower*>(fParent)->GetADCMode(); if(ADCMode == kADCDynamicPedestal) { FillADC_DynamicPedestal(); } else if (ADCMode == kADCSampleIntegral) { @@ -810,11 +801,11 @@ Int_t THcShowerArray::CoarseProcessHits() FillADC_Standard(); } // - if (fParent->fdbg_decoded_cal) { + if (static_cast<THcShower*>(fParent)->fdbg_decoded_cal) { cout << "---------------------------------------------------------------\n"; cout << "Debug output from THcShowerArray::ProcessHits for " - << fParent->GetPrefix() << ":" << endl; + << static_cast<THcShower*>(fParent)->GetPrefix() << ":" << endl; cout << " Sparsified hits for shower array, plane #" << fLayerNum << ", " << GetName() << ":" << endl; @@ -1084,11 +1075,11 @@ Int_t THcShowerArray::AccumulatePedestals(TClonesArray* rawhits, Int_t nexthit) // Debug output. - if ( ((THcShower*) GetParent())->fdbg_raw_cal ) { + if ( static_cast<THcShower*>(fParent)->fdbg_raw_cal ) { cout << "---------------------------------------------------------------\n"; cout << "Debug output from THcShowerArray::AcculatePedestals for " - << GetParent()->GetPrefix() << ":" << endl; + << fParent->GetPrefix() << ":" << endl; cout << "Processed hit list for plane " << GetName() << ":\n"; @@ -1140,11 +1131,11 @@ void THcShowerArray::CalculatePedestals( ) // Debug output. - if ( ((THcShower*) GetParent())->fdbg_raw_cal ) { + if ( static_cast<THcShower*>(fParent)->fdbg_raw_cal ) { cout << "---------------------------------------------------------------\n"; cout << "Debug output from THcShowerArray::CalculatePedestals for " - << GetParent()->GetPrefix() << ":" << endl; + << fParent->GetPrefix() << ":" << endl; cout << " ADC pedestals and thresholds for calorimeter plane " << GetName() << endl; @@ -1184,27 +1175,19 @@ void THcShowerArray::InitializePedestals( ) // Fiducial volume limits. Double_t THcShowerArray::fvXmin() { - THcShower* fParent; - fParent = (THcShower*) GetParent(); - return fXPos[0][0] - fXStep/2 + fParent->fvDelta; + return fXPos[0][0] - fXStep/2 + static_cast<THcShower*>(fParent)->fvDelta; } Double_t THcShowerArray::fvYmax() { - THcShower* fParent; - fParent = (THcShower*) GetParent(); - return fYPos[0][0] + fYStep/2 - fParent->fvDelta; + return fYPos[0][0] + fYStep/2 - static_cast<THcShower*>(fParent)->fvDelta; } Double_t THcShowerArray::fvXmax() { - THcShower* fParent; - fParent = (THcShower*) GetParent(); - return fXPos[fNRows-1][fNColumns-1] + fXStep/2 - fParent->fvDelta; + return fXPos[fNRows-1][fNColumns-1] + fXStep/2 - static_cast<THcShower*>(fParent)->fvDelta; } Double_t THcShowerArray::fvYmin() { - THcShower* fParent; - fParent = (THcShower*) GetParent(); - return fYPos[fNRows-1][fNColumns-1] - fYStep/2 + fParent->fvDelta; + return fYPos[fNRows-1][fNColumns-1] - fYStep/2 + static_cast<THcShower*>(fParent)->fvDelta; } Double_t THcShowerArray::clMaxEnergyBlock(THcShowerCluster* cluster) { Double_t max_energy=-1.; @@ -1236,7 +1219,7 @@ Int_t THcShowerArray::AccumulateStat(TClonesArray& tracks ) THcHallCSpectrometer *app=dynamic_cast<THcHallCSpectrometer*>(GetApparatus()); THaDetector* detc; - if (GetParent()->GetPrefix()[0] == 'P') + if (fParent->GetPrefix()[0] == 'P') detc = app->GetDetector("hgcer"); else detc = app->GetDetector("cer"); @@ -1258,8 +1241,7 @@ Int_t THcShowerArray::AccumulateStat(TClonesArray& tracks ) // local system. fOrigin = GetOrigin(); - THcShower* fParent = (THcShower*) GetParent(); - fParent->CalcTrackIntercept(BestTrack, pathl, XTrk, YTrk); + static_cast<THcShower*>(fParent)->CalcTrackIntercept(BestTrack, pathl, XTrk, YTrk); // Transform coordiantes to the spectrometer's coordinate system. XTrk += GetOrigin().X(); @@ -1285,7 +1267,7 @@ Int_t THcShowerArray::AccumulateStat(TClonesArray& tracks ) } - if ( ((THcShower*) GetParent())->fdbg_tracks_cal ) { + if (static_cast<THcShower*>(fParent)->fdbg_tracks_cal ) { cout << "---------------------------------------------------------------\n"; cout << "THcShowerArray::AccumulateStat:" << endl; cout << " Chi2/NDF = " <<BestTrack->GetChi2()/BestTrack->GetNDoF() <<endl; diff --git a/src/THcShowerArray.h b/src/THcShowerArray.h index 1f055138ebaf5f58c2623e5de6468e4795d4e17e..5344658ab26424bf639ee65ee38584fb53a80c80 100644 --- a/src/THcShowerArray.h +++ b/src/THcShowerArray.h @@ -210,7 +210,10 @@ protected: virtual Int_t ReadDatabase( const TDatime& date ); virtual Int_t DefineVariables( EMode mode = kDefine ); - THcHodoscope* fglHod; // Hodoscope to get start time + THcHodoscope* fglHod; // Hodoscope to get start time + + THaDetectorBase* fParent; + ClassDef(THcShowerArray,0); // Fly;s Eye calorimeter array }; diff --git a/src/THcShowerPlane.cxx b/src/THcShowerPlane.cxx index a709e27302875d7d17b00e2d732aafd55a3f74bf..f82ae9b7016458440cf8ad96d4b95e184d71384a 100644 --- a/src/THcShowerPlane.cxx +++ b/src/THcShowerPlane.cxx @@ -481,7 +481,7 @@ void THcShowerPlane::Clear( Option_t* ) if ( static_cast<THcShower*>(GetParent())->fdbg_decoded_cal ) { cout << "---------------------------------------------------------------\n"; cout << "Debug output from THcShowerPlane::Clear for " - << fParent->GetPrefix() << ":" << endl; + << GetParent()->GetPrefix() << ":" << endl; cout << " Cleared ADC hits for plane " << GetName() << endl; cout << "---------------------------------------------------------------\n";