Newer
Older
} else {
Double_t timec_pos,timec_neg;
timec_pos=tdc_pos;
timec_neg=tdc_neg;
if(btdcraw_pos) {
if(fTofUsingInvAdc) {
timec_pos = tdc_pos*fScinTdcToTime
- fHodoPosInvAdcOffset[index]
- fHodoPosInvAdcAdc[index]/TMath::Sqrt(TMath::Max(20.0,adc_pos));
} else { // Old style
timec_pos = tdc_pos*fScinTdcToTime - fHodoPosPhcCoeff[index]*
TMath::Sqrt(TMath::Max(0.0,adc_pos/fHodoPosMinPh[index]-1.0))
- fHodoPosTimeOffset[index];
}
if(btdcraw_neg) {
if(fTofUsingInvAdc) {
timec_neg = tdc_neg*fScinTdcToTime
- fHodoNegInvAdcOffset[index]
- fHodoNegInvAdcAdc[index]/TMath::Sqrt(TMath::Max(20.0,adc_neg));
} else { // Old style
timec_neg = tdc_neg*fScinTdcToTime - fHodoNegPhcCoeff[index]*
TMath::Sqrt(TMath::Max(0.0,adc_neg/fHodoNegMinPh[index]-1.0))
- fHodoNegTimeOffset[index];
}
((THcHodoHit*) fHodoHits->At(fNScinHits))->SetPaddleCenter(fPosCenter[index]);
((THcHodoHit*) fHodoHits->At(fNScinHits))->SetCorrectedTimes(timec_pos,timec_neg,
timec_pos,timec_neg,
0.0);
//Define GoodTdcTimeCorr and GoodTdcTimeTOFCorr (a second time, since when only 1pmt fires, we cannot get TOFCorr)
fGoodPosTdcTimeCorr.at(padnum-1) = timec_pos;
fGoodNegTdcTimeCorr.at(padnum-1) = timec_neg;
fGoodPosTdcTimeTOFCorr.at(padnum-1) = timec_pos;
fGoodNegTdcTimeTOFCorr.at(padnum-1) = timec_neg;
}
fNScinHits++; // One or more good time counter
// fTotNumGoodNegTdcHits++;
// fTotNumGoodTdcHits++;
//Good TDC- Occupancy
// fNumGoodNegTdcHits.at(npad) = npad + 1;
// fTotNumGoodPosTdcHits++;
// fTotNumGoodTdcHits++;
//Good TDC+ Occupancy
// fNumGoodPosTdcHits.at(npad) = npad + 1;
ihit++; // Raw hit counter
return(ihit);
}
//_____________________________________________________________________________
Int_t THcScintillatorPlane::AccumulatePedestals(TClonesArray* rawhits, Int_t nexthit)
{
/*! \brief Extract the data for this plane from raw hit list THcRawHodoHit, accumulating into arrays for calculating pedestals.
Int_t nrawhits = rawhits->GetLast()+1;
// cout << "THcScintillatorPlane::AcculatePedestals " << fPlaneNum << " " << nexthit << "/" << nrawhits << endl;
Int_t ihit = nexthit;
while(ihit < nrawhits) {
THcRawHodoHit* hit = (THcRawHodoHit *) rawhits->At(ihit);
if(hit->fPlane > fPlaneNum) {
break;
}
Int_t element = hit->fCounter - 1; // Should check if in range
Int_t adcpos = hit->GetRawAdcHitPos().GetPulseIntRaw();
Int_t adcneg = hit->GetRawAdcHitNeg().GetPulseIntRaw();
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
if(adcpos <= fPosPedLimit[element]) {
fPosPedSum[element] += adcpos;
fPosPedSum2[element] += adcpos*adcpos;
fPosPedCount[element]++;
if(fPosPedCount[element] == fMinPeds/5) {
fPosPedLimit[element] = 100 + fPosPedSum[element]/fPosPedCount[element];
}
}
if(adcneg <= fNegPedLimit[element]) {
fNegPedSum[element] += adcneg;
fNegPedSum2[element] += adcneg*adcneg;
fNegPedCount[element]++;
if(fNegPedCount[element] == fMinPeds/5) {
fNegPedLimit[element] = 100 + fNegPedSum[element]/fNegPedCount[element];
}
}
ihit++;
}
fNPedestalEvents++;
return(ihit);
}
//_____________________________________________________________________________
void THcScintillatorPlane::CalculatePedestals( )
{
/*! \brief Calculate pedestals from arrays made in THcScintillatorPlane::AccumulatePedestals
*
* - Calculate pedestals from arrays made in THcScintillatorPlane::AccumulatePedestals
* - In old fortran ENGINE code, a comparison was made between calculated pedestals and the pedestals read in by the FASTBUS modules for zero supression. This is not implemented.
*/
for(UInt_t i=0; i<fNelem;i++) {
// Positive tubes
fPosPed[i] = ((Double_t) fPosPedSum[i]) / TMath::Max(1, fPosPedCount[i]);
fPosThresh[i] = fPosPed[i] + 15;
// Negative tubes
fNegPed[i] = ((Double_t) fNegPedSum[i]) / TMath::Max(1, fNegPedCount[i]);
fNegThresh[i] = fNegPed[i] + 15;
// cout <<"Pedestals "<< i+1 << " " << fPosPed[i] << " " << fNegPed[i] << endl;
}
//_____________________________________________________________________________
void THcScintillatorPlane::InitializePedestals( )
{
/*! \brief called by THcScintillatorPlane::ReadDatabase
*
* - Initialize variables used in THcScintillatorPlane::AccumulatePedestals and THcScintillatorPlane::CalculatePedestals
* - Minimum number of pedestal events needed for calculation, fMinPeds, hadrcoded to 500
*/
fNPedestalEvents = 0;
fMinPeds = 500; // In engine, this is set in parameter file
fPosPedSum = new Int_t [fNelem];
fPosPedSum2 = new Int_t [fNelem];
fPosPedLimit = new Int_t [fNelem];
fPosPedCount = new Int_t [fNelem];
fNegPedSum = new Int_t [fNelem];
fNegPedSum2 = new Int_t [fNelem];
fNegPedLimit = new Int_t [fNelem];
fNegPedCount = new Int_t [fNelem];
fPosPed = new Double_t [fNelem];
fNegPed = new Double_t [fNelem];
fPosThresh = new Double_t [fNelem];
fNegThresh = new Double_t [fNelem];
for(UInt_t i=0;i<fNelem;i++) {
fPosPedSum[i] = 0;
fPosPedSum2[i] = 0;
fPosPedLimit[i] = 1000; // In engine, this are set in parameter file
fPosPedCount[i] = 0;
fNegPedSum[i] = 0;
fNegPedSum2[i] = 0;
fNegPedLimit[i] = 1000; // In engine, this are set in parameter file
fNegPedCount[i] = 0;
}
}
Gabriel Niculescu
committed
//____________________________________________________________________________
ClassImp(THcScintillatorPlane)
////////////////////////////////////////////////////////////////////////////////