55 #include "StFgtRobustPedMaker.h"
56 #include "StRoot/StEvent/StFgtCollection.h"
57 #include "StRoot/StEvent/StFgtStrip.h"
58 #include "StRoot/StEvent/StEvent.h"
59 #include "StRoot/StFgtDbMaker/StFgtDbMaker.h"
60 #include "StRoot/StFgtUtil/geometry/StFgtGeom.h"
61 #include "StRoot/StFgtPool/StFgtCosmicTestStandGeom/StFgtCosmicTestStandGeom.h"
62 #include "StRoot/StFgtUtil/StFgtConsts.h"
64 #define ONE_OVER_TWICE_SQRT_LOG_TWO 0.6005612
67 StFgtRobustPedMaker::StFgtRobustPedMaker(
const Char_t* name ) :
68 StFgtPedMaker( name ), mNumBins(100) , mMaxAdc(1250), mNumSmooth(10), mInternalEventNum(0) {
71 mHistVec.assign( mDataVec.size(), (TH1F*)0 );
82 eventPtr = (
StEvent*)GetInputDS(
"StEvent");
85 LOG_ERROR <<
"Error getting pointer to StEvent from '" << ClassName() <<
"'" << endm;
92 fgtCollectionPtr=eventPtr->fgtCollection();
95 if( !fgtCollectionPtr) {
96 LOG_ERROR <<
"Error getting pointer to StFgtCollection from '" << ClassName() <<
"'" << endm;
101 std::stringstream ss;
102 for( UInt_t discIdx=0; discIdx<fgtCollectionPtr->getNumDiscs(); ++discIdx ){
104 if( stripCollectionPtr ){
105 StSPtrVecFgtStrip& stripVec = stripCollectionPtr->getStripVec();
106 StSPtrVecFgtStripIterator stripIter;
108 for( stripIter = stripVec.begin(); stripIter != stripVec.end(); ++stripIter ){
109 for( Int_t timeBin = 0; timeBin < kFgtNumTimeBins; ++timeBin ){
110 Bool_t pass = ((mTimeBinMask==0 || ( (1<<timeBin) & mTimeBinMask)) && timeBin >= 0 && timeBin < kFgtNumTimeBins);
112 Short_t adc = (*stripIter)->getAdc( timeBin );
117 if(mTimeBinMask==0) t=0;
119 Int_t rdo, arm, apv, channel;
120 (*stripIter)->getElecCoords( rdo, arm, apv, channel );
121 Int_t elecId = StFgtGeom::getElectIdFromElecCoord( rdo, arm, apv, channel );
123 Int_t code = kFgtNumTimeBins * elecId + t;
125 TH1F* hist = mHistVec[ code ];
129 ss <<
"hStripADC_" << code;
130 hist =
new TH1F( ss.str().data(),
"", mNumBins, 0, mMaxAdc );
131 mHistVec[ code ] = hist;
134 hist->Fill(
float(adc) );
151 cout <<
"StFgtRobustPedMaker::Finish()" << endl;
153 std::vector< TH1F* >::iterator mHistVecIter;
157 for( mHistVecIter = mHistVec.begin(); mHistVecIter != mHistVec.end(); ++mHistVecIter ){
159 TH1F *hist = *mHistVecIter;
163 if( mNumSmooth ) hist->Smooth( mNumSmooth );
166 Int_t maxLoc = hist->GetMaximumBin();
167 Float_t halfMax = 0.5*hist->GetBinContent( maxLoc );
168 Float_t pedValue = hist->GetBinCenter( maxLoc );
169 Float_t mean = hist->GetMean();
173 for( binIdxR = maxLoc + 1; binIdxR <= hist->GetNbinsX() && hist->GetBinContent( binIdxR ) > halfMax; ++binIdxR );
174 Float_t HWHMR = ( hist->GetBinCenter( binIdxR ) - pedValue );
178 for( binIdxL = maxLoc - 1; binIdxL > 0 && hist->GetBinContent( binIdxL ) > halfMax; --binIdxL );
179 Float_t HWHML = ( pedValue - hist->GetBinCenter( binIdxL ) );
182 Float_t sigma = ( HWHML + HWHMR ) * ONE_OVER_TWICE_SQRT_LOG_TWO;
183 Float_t rms = hist->GetRMS();
184 Float_t sig3 = 3.0*rms;
185 if(sig3<100) sig3=100;
188 hist->GetXaxis()->SetRangeUser(mean-sig3, mean+sig3);
191 Float_t mean2 = hist->GetMean();
192 Float_t rms2 = hist->GetRMS();
195 Float_t fracClose = hist->Integral(hist->FindBin(mean2-rms2), hist->FindBin(mean2+rms2)) / hist->GetEntries();
201 Int_t code = std::distance( mHistVec.begin(), mHistVecIter );
203 data.n = hist->GetEntries();
206 data.fracClose = fracClose;