13 #include "StRoot/St_base/StMessMgr.h"
16 #include "StEEmcStripClusterFinderTSIU.h"
17 #include "StRoot/StEEmcPool/./EEmcTreeContainers/EEmcEnergy.h"
19 StEEmcStripClusterFinderTSIU_t::StEEmcStripClusterFinderTSIU_t() :
21 mNumStripsPerSide( 2 ),
22 mMinStripsPerCluster( 4 ),
23 mSeedAbsThres( 0.001 ),
24 mSeedRelThres( 0.05 ),
25 mMinEnergyPerCluster( 0.010 )
33 StEEmcStripClusterFinderTSIU_t::~StEEmcStripClusterFinderTSIU_t(){
43 assert( mNumStripsPerSide > 0 );
44 assert( mNumStripsPerSide < 0.3*kEEmcNumStrips );
45 assert( mMinEnergyPerCluster > 0 );
48 if( (UInt_t)(stripArray.nStrips) < mMinStripsPerCluster )
52 for( Double_t *p1 = mStripEnergyArray, *p2 = mSmoothedEnergyArray; p1 != &mStripEnergyArray[kEEmcNumStrips]; ++p1, ++p2 )
56 UInt_t smallestIdx = kEEmcNumStrips;
57 UInt_t largestIdx = 0;
59 Bool_t existsStripOverThres = 0;
62 for(
const EEmcElement_t *strip = stripArray.strip; strip != &stripArray.strip[288]; ++strip, ++stripIdx ){
63 if( !strip->fail && strip->energy ){
64 if( smallestIdx > stripIdx )
65 smallestIdx = stripIdx;
66 if( largestIdx < stripIdx )
67 largestIdx = stripIdx;
69 mStripEnergyArray[ stripIdx ] = strip->energy;
70 mSmoothedEnergyArray[ stripIdx ] = strip->energy;
72 if( strip->energy > mSeedAbsThres )
73 existsStripOverThres = 1;
77 if( smallestIdx < largestIdx && existsStripOverThres ){
83 if( largestIdx < kEEmcNumStrips-1 )
87 if( smallestIdx < mNumStripsPerSide )
88 smallestIdx = mNumStripsPerSide;
89 if( largestIdx > kEEmcNumStrips-mNumStripsPerSide-1 )
90 largestIdx = kEEmcNumStrips-mNumStripsPerSide-1;
93 TH1::SmoothArray( kEEmcNumStrips, mSmoothedEnergyArray, mNumSmoothIters );
96 Double_t thres = mSeedAbsThres;
98 Double_t maxEnergy = *std::max_element( mSmoothedEnergyArray, mSmoothedEnergyArray+kEEmcNumStrips );
99 Double_t newThres = mSeedRelThres*maxEnergy;
100 if( newThres > thres )
106 UInt_t seedPos = smallestIdx;
107 for( Double_t *ePtr = &mSmoothedEnergyArray[smallestIdx]; ePtr != &mSmoothedEnergyArray[largestIdx]; ++ePtr, ++seedPos ){
108 if( *ePtr > thres && *(ePtr-1) < *ePtr && *(ePtr+1) < *ePtr ){
112 Double_t clusE = *ePtr;
113 Double_t clusPos = seedPos*clusE;
115 UInt_t numStrips = 1;
120 Int_t idx = seedPos - mNumStripsPerSide;
121 for( Double_t *ePtr2 = ePtr-mNumStripsPerSide; ePtr2 < ePtr && passes; ++ePtr2, ++idx ){
122 passes = ( *ePtr2 < *(ePtr2+1) );
124 clusPos += *ePtr2 * idx;
126 if( mStripEnergyArray[idx] )
132 for( Double_t *ePtr2 = ePtr+1; ePtr2 < ePtr+mNumStripsPerSide+1 && passes; ++ePtr2, ++idx ){
133 passes = ( *ePtr2 < *(ePtr2-1) );
135 clusPos += *ePtr2 * idx;
137 if( mStripEnergyArray[idx] )
141 if( passes && clusE > mMinEnergyPerCluster && numStrips >= mMinStripsPerCluster ){
148 clus.setMeanX( clusPos/clusE );
150 clus.setEnergy( clusE );
151 clus.setSeedIdx( 0 );
154 TArrayS& memArr = clus.getMemberArray();
155 TArrayF& wArr = clus.getWeightArray();
157 memArr.Set( numStrips );
158 wArr.Set( numStrips );
167 for( UInt_t idx = seedPos - mNumStripsPerSide, i=1; idx <= seedPos + mNumStripsPerSide; ++idx ){
168 if( mStripEnergyArray[idx] && idx != seedPos ){
virtual Int_t find(const ESmdLayer_t &stripArray, StSimpleClusterVec_t &cluster)
find some clusters