22 #include "StEEmcFgtCorrelatorA.h"
24 #include "StEEmcRawMapMaker.h"
25 #include "StThreeVectorF.hh"
27 #include "StRoot/StEEmcUtil/EEmcGeom/EEmcGeomDefs.h"
28 #include "StRoot/StEEmcPool/StEEmcPointMap/StEEmcPointMap.h"
29 #include "StRoot/StEvent/StEvent.h"
30 #include "StRoot/StEvent/StPrimaryVertex.h"
31 #include "StRoot/StMuDSTMaker/COMMON/StMuDst.h"
32 #include "StRoot/StMuDSTMaker/COMMON/StMuEvent.h"
33 #include "StRoot/StFgtUtil/geometry/StFgtGeom.h"
37 #define CLUSTER_WIDTH 4
38 #define CLUSTER_SIZE 9
39 #define FAIL_FLAG -1234
42 StEEmcFgtCorrelatorA::StEEmcFgtCorrelatorA(
const Char_t* name,
const Char_t* rawMapMkrName ) :
43 StMaker( name ), mInputType(1), mInputName(
"MuDst"), mEEmcRawMapMkr(0),
44 mMipMin(5), mMipMax(50), mSigThres(3) {
47 assert( mEEmcRawMapMkr );
48 assert( CLUSTER_SIZE == CLUSTER_WIDTH*2+1 );
49 assert( FAIL_FLAG < 0 );
53 StEEmcFgtCorrelatorA::~StEEmcFgtCorrelatorA(){ };
56 Int_t StEEmcFgtCorrelatorA::Init(){
61 Int_t ierr = loadVertex();
63 const StEEmcRawMap& eemcMap = mEEmcRawMapMkr->getMap( 4 );
65 std::vector< Int_t > seedIdxVec;
66 std::vector< Float_t > mipClusPosVec[12];
67 std::vector< TVector3 > mipPosVec;
69 StEEmcRawMap::const_iterator mapIter;
70 if( !eemcMap.empty() ){
73 for( mapIter = eemcMap.begin(); mapIter != eemcMap.end(); ++mapIter ){
74 Int_t idx = mapIter->first;
77 Float_t resp = data.rawAdc - data.ped;
78 if( data.fail || data.stat )
80 if( resp && data.pedSigma )
81 resp /= data.pedSigma;
83 if( resp < mMipMax && resp > mMipMin )
84 seedIdxVec.push_back( idx );
89 LOG_INFO <<
"zzz " << GetEventNumber() <<
" found " << seedIdxVec.size() <<
" MIP seeds out of " << eemcMap.size() <<
" strips" << endm;
93 Int_t nFailBothAdj = 0, nFailFail = 0, nFailSideHigh = 0, nFailNonIso = 0;
95 if( !seedIdxVec.empty() ){
96 std::vector< Int_t >::const_iterator seedIter;
98 Float_t clusterShape[CLUSTER_SIZE];
100 for( seedIter = seedIdxVec.begin(); seedIter != seedIdxVec.end(); ++seedIter ){
103 for( Float_t *p = clusterShape; p != &clusterShape[CLUSTER_SIZE]; ++p )
107 Int_t first = ((*seedIter)/kEEmcNumStrips)*kEEmcNumStrips;
108 Int_t last = first + kEEmcNumStrips;
111 Int_t offset = *seedIter - CLUSTER_WIDTH;
112 Int_t low = std::max( first, *seedIter - CLUSTER_WIDTH );
113 Int_t high = std::min( last, *seedIter + CLUSTER_WIDTH + 1 );
116 for( Int_t i = offset; i<offset+CLUSTER_SIZE; ++i ){
117 if( i >= low && i < high ){
118 mapIter = eemcMap.find( i );
120 if( mapIter != eemcMap.end() ){
123 Float_t resp = data.rawAdc - data.ped;
124 if( resp && data.pedSigma )
125 resp /= data.pedSigma;
126 if( data.fail || data.stat )
129 clusterShape[i-offset] = resp;
134 #ifdef DEBUG_CLUS_SHAPE
135 LOG_INFO <<
"zzz cluster shape: ";
136 for( Int_t i=0; i<CLUSTER_SIZE; ++i )
137 LOG_INFO << clusterShape[i] <<
' ';
144 Bool_t pass = (( clusterShape[CLUSTER_WIDTH-1] > mSigThres ) ^ ( clusterShape[CLUSTER_WIDTH+1] > mSigThres ));
152 if( pass && (clusterShape[CLUSTER_WIDTH+1] == FAIL_FLAG || clusterShape[CLUSTER_WIDTH-1] == FAIL_FLAG) ){
156 if( pass && ( clusterShape[CLUSTER_WIDTH+1] > clusterShape[CLUSTER_WIDTH] || clusterShape[CLUSTER_WIDTH-1] > clusterShape[CLUSTER_WIDTH] ) ){
161 Bool_t passOlder = pass;
163 for( Int_t i = 0; i<CLUSTER_WIDTH-1 && pass; ++i )
164 if( clusterShape[i] > mSigThres )
166 for( Int_t i = CLUSTER_WIDTH+2; i<CLUSTER_SIZE && pass; ++i )
167 if( clusterShape[i] > mSigThres )
170 if( passOlder && !pass )
175 Float_t posA = *seedIter;
176 Float_t wA = clusterShape[CLUSTER_WIDTH];
177 Float_t posB = (( clusterShape[CLUSTER_WIDTH+1] > clusterShape[CLUSTER_WIDTH-1] ) ? *seedIter+1 : *seedIter-1 );
178 Float_t wB = std::max( clusterShape[CLUSTER_WIDTH+1], clusterShape[CLUSTER_WIDTH-1] );
181 Int_t sec = (*seedIter)/kEEmcNumStrips/2;
182 mipClusPosVec[sec].push_back(( posA*wA + posB*wB ) / ( wA + wB ));
188 LOG_INFO <<
"zzz FOUND " << nMipClus <<
" possible MIP clusters, "
189 <<
"failed " << nFailBothAdj <<
' ' << nFailFail <<
' ' << nFailSideHigh <<
' ' << nFailNonIso << endm;
193 std::vector< Float_t >::iterator mipClusPosIter;
196 for( Int_t sec = 6; sec<kEEmcNumSectors; ++sec ){
198 LOG_INFO <<
"zzz \t sector " << sec <<
" has " << mipClusPosVec[sec].size() <<
" MIP clusters " << endm;
200 for( UInt_t j = 0; j<mipClusPosVec[sec].size(); ++j ){
201 Float_t idx = mipClusPosVec[sec][j];
203 Int_t strip = idx2 % kEEmcNumStrips;
204 Bool_t isV = (idx2 / kEEmcNumStrips)%2;
205 Int_t sec = (idx2 / kEEmcNumStrips)/2;
207 LOG_INFO <<
"zzz \t\t " << idx <<
' ' << sec <<
' ' << (isV ?
'v' :
'u') <<
' ' << strip <<
' ' << strip+idx-idx2 << endm;
211 if( mipClusPosVec[sec].size() == 2 ){
212 Float_t idx1 = mipClusPosVec[sec][0];
213 Float_t idx2 = mipClusPosVec[sec][1];
214 Bool_t isV1 = ((Int_t)idx1/kEEmcNumStrips)%2;
215 Bool_t isV2 = ((Int_t)idx2/kEEmcNumStrips)%2;
218 Float_t idxU = ( isV1 ? idx2 : idx1 );
219 Float_t idxV = ( isV1 ? idx1 : idx2 );
220 Float_t x = 0, y = 0;
222 StEEmcPointMap_t::instance().convertStripUVtoXY( sec, idxU, idxV, x, y );
223 mipPosVec.push_back( TVector3( x, y, kEEmcZSMD ) );
230 if( !mipPosVec.empty() ){
231 LOG_INFO <<
"zzz EVENT " << GetEventNumber() <<
" FOUND " << mipPosVec.size() <<
" MIP points" << endm;
235 if( !mipPosVec.empty() ){
237 LOG_INFO <<
"zzz -> vertex " << mVertex.X() <<
' ' << mVertex.Y() <<
' ' << mVertex.Z() << endm;
240 for( UInt_t j = 0; j < mipPosVec.size(); ++j ){
241 TVector3& smdPt = mipPosVec[j];
242 TVector3 delta = smdPt - mVertex;
245 LOG_INFO <<
"zzz -> ESMD point " << smdPt.X() <<
' ' << smdPt.Y() <<
' ' << smdPt.Z() << endm;
247 for( Int_t disc = 0; disc<kFgtNumDiscs; ++disc ){
248 Float_t z = StFgtGeom::getDiscZ( disc );
249 Float_t alpha = ( z - mVertex.Z() ) / ( smdPt.Z() - mVertex.Z() );
250 TVector3 pos = alpha*delta + mVertex;
253 LOG_INFO <<
"zzz ----> disc " << disc+1 <<
" line passes through " << pos.X() <<
' ' << pos.Y() <<
' ' << pos.Z() << endm;
266 Int_t StEEmcFgtCorrelatorA::setInput(
const Char_t *name, Int_t type ){
269 if( type == 0 || type == 1){
273 LOG_ERROR <<
"Invalid input type" << endm;
279 Int_t StEEmcFgtCorrelatorA::loadVertex(){
284 const StMuDst* muDst = (
const StMuDst*)GetInputDS( mInputName.data() );
291 if( v.z() > -300 && v.z() < 300 ){
293 mVertex.SetXYZ( v.x(), v.y(), v.z() );
298 const StEvent *
event = (
const StEvent*)GetInputDS( mInputName.data() );
305 if( v.z() > -300 && v.z() < 300 ){
307 mVertex.SetXYZ( v.x(), v.y(), v.z() );
virtual void Clear(Option_t *opt="")
User defined functions.
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)