1 #include "StEEmcGenericClusterMaker.h"
7 #include "StEEmcPool/StEEmcA2EMaker/StEEmcA2EMaker.h"
10 #include "StEmcDetector.h"
11 #include "StEmcCollection.h"
13 #include "StMessMgr.h"
15 #include "StMuDSTMaker/COMMON/StMuTrack.h"
16 #include "StMuDSTMaker/COMMON/StMuDst.h"
17 #include "StMuDSTMaker/COMMON/StMuDstMaker.h"
19 #include "StEEmcUtil/EEmcGeom/EEmcGeomDefs.h"
33 mESmdGeom=EEmcSmdGeom::instance();
34 mESmdMap =EEmcSmdMap::instance();
50 std::vector< StEEmcClusterVec_t > layers;
51 for ( Int_t i = 0; i < 4; i++ ) layers.push_back(t);
52 for ( Int_t i = 0; i < 12; i++ ) mTowerClusters.push_back(layers);
54 StEEmcSmdClusterVec_t s;
55 std::vector< StEEmcSmdClusterVec_t > planes;
58 for ( Int_t i = 0; i < 12; i++ ) mSmdClusters.push_back(planes);
68 mClusterTrackSeparation[0] = 0.05;
69 mClusterTrackSeparation[1] = 0.075;
70 mClusterTrackSeparation[2] = 0.075;
71 mClusterTrackSeparation[3] = 0.075;
72 mClusterTrackSeparation[4] = 3.0;
73 mClusterTrackSeparation[5] = 3.0;
80 Int_t StEEmcGenericClusterMaker::Init()
86 if (!mEEanalysis) mEEanalysis=(
StEEmcA2EMaker*)GetMaker(
"EEmcAdc2Energy");
89 return StMaker::Init();
128 void StEEmcGenericClusterMaker::makeHistograms()
134 void StEEmcGenericClusterMaker::makeClusterMap()
139 for ( UInt_t sec=0;sec<12;sec++ )
143 StEEmcClusterVec_t &Tclusters = mTowerClusters[sec][0];
144 StEEmcClusterVec_t &Pclusters = mTowerClusters[sec][1];
145 StEEmcClusterVec_t &Qclusters = mTowerClusters[sec][2];
146 StEEmcClusterVec_t &Rclusters = mTowerClusters[sec][3];
147 StEEmcSmdClusterVec_t &Uclusters = mSmdClusters[sec][0];
148 StEEmcSmdClusterVec_t &Vclusters = mSmdClusters[sec][1];
151 for ( UInt_t t=0;t<Tclusters.size(); t++ )
155 EEmatch *mymatch = &mClusterMap[c.key()];
157 for ( UInt_t p=0;p<Pclusters.size();p++ )
158 if (
match(c,Pclusters[p]) ) mymatch->pre1.push_back(Pclusters[p]);
159 for ( UInt_t q=0;q<Qclusters.size();q++ )
160 if (
match(c,Qclusters[q]) ) mymatch->pre2.push_back(Qclusters[q]);
161 for ( UInt_t r=0;r<Rclusters.size();r++ )
162 if (
match(c,Rclusters[r]) ) mymatch->post.push_back(Rclusters[r]);
163 for ( UInt_t u=0;u<Uclusters.size();u++ )
164 if (
match(c,Uclusters[u]) ) mymatch->smdu.push_back(Uclusters[u]);
165 for ( UInt_t v=0;v<Vclusters.size();v++ )
166 if (
match(c,Vclusters[v]) ) mymatch->smdv.push_back(Vclusters[v]);
169 for ( UInt_t p=0;p<Pclusters.size();p++ )
170 if (
match(c,Pclusters[p]) ) c.addMatch( Pclusters[p].key(), 1 );
171 for ( UInt_t q=0;q<Qclusters.size();q++ )
172 if (
match(c,Qclusters[q]) ) c.addMatch( Qclusters[q].key(), 2 );
173 for ( UInt_t r=0;r<Rclusters.size();r++ )
174 if (
match(c,Rclusters[r]) ) c.addMatch( Rclusters[r].key(), 3 );
175 for ( UInt_t u=0;u<Uclusters.size();u++ )
176 if (
match(c,Uclusters[u]) ) c.addMatch( Uclusters[u].key(), 4 );
177 for ( UInt_t v=0;v<Vclusters.size();v++ )
178 if (
match(c,Vclusters[v]) ) c.addMatch( Vclusters[v].key(), 5 );
184 for ( UInt_t i=0;i<Tclusters.size();i++ )
187 std::cout <<
"sec=" << sec <<
" i=" << i <<
" ------------------------------------" << std::endl;
191 EEmatch m=mClusterMap[k];
192 for ( UInt_t j=0;j<m.pre1.size();j++ )
194 for ( UInt_t j=0;j<m.pre2.size();j++ )
196 for ( UInt_t j=0;j<m.post.size();j++ )
198 for ( UInt_t j=0;j<m.smdu.size();j++ )
199 m.smdu[j].printLine();
200 for ( UInt_t j=0;j<m.smdv.size();j++ )
201 m.smdv[j].printLine();
208 for ( UInt_t i=0;i<Tclusters.size();i++ )
210 std::cout <<
"sec=" << sec <<
" i=" << i <<
" ------------------------------------" << std::endl;
214 std::cout <<
"pre1 matches: ";
215 for ( Int_t j=0;j<c.numberOfMatchingClusters(1);j++ )
216 std::cout << c.getMatch(j,1) <<
" ";
217 std::cout << std::endl;
219 std::cout <<
"pre2 matches: ";
220 for ( Int_t j=0;j<c.numberOfMatchingClusters(2);j++ )
221 std::cout << c.getMatch(j,2) <<
" ";
222 std::cout << std::endl;
225 std::cout <<
"post matches: ";
226 for ( Int_t j=0;j<c.numberOfMatchingClusters(3);j++ )
227 std::cout << c.getMatch(j,3) <<
" ";
228 std::cout << std::endl;
246 LOG_DEBUG <<
GetName() <<
" -I- entering makeTrackMap()" << endm;
251 LOG_DEBUG <<
GetName() <<
" -I- mudst maker not in chain?" << endm;
260 Int_t nprimary = (Int_t)mudst->numberOfPrimaryTracks();
262 LOG_DEBUG<<
" checking nprimary="<<nprimary<<
" tracks"<<endm;
264 for ( Int_t iprimary = 0; iprimary < nprimary; iprimary++ )
270 for ( Int_t sec=0;sec<12;sec++ )
274 for ( Int_t layer = 0; layer < 4; layer++ )
280 if (
match(mycluster, track) )
282 LOG_DEBUG <<
GetName() <<
" -I- matched cluster to track in layer=" << layer << endm;
286 mClusterTrackMap[ mycluster.key() ].push_back( track );
301 Int_t nglobal = (Int_t)mudst->numberOfGlobalTracks();
302 for ( Int_t iglobal = 0; iglobal < nglobal; iglobal++ )
305 if (!track)
continue;
308 if (! (track->
flag()==901) )
continue;
311 for ( Int_t sec=0;sec<12;sec++ )
315 for ( Int_t layer = 0; layer < 4; layer++ )
321 if ( matchBackgroundTrack(mycluster, track) )
323 LOG_DEBUG <<
GetName() <<
" -I- matched cluster to background track in layer=" << layer << endm;
327 mBackgroundTrackMap[ mycluster.key() ].push_back( track );
358 StEmcDetector *detector=stevent->emcCollection()->detector(kEndcapEmcTowerId);
367 detector=stevent->emcCollection()->detector(kEndcapEmcPreShowerId);
376 StDetectorId ids[]={ kEndcapSmdUStripId, kEndcapSmdVStripId };
379 for ( Int_t iplane=0; iplane<2; iplane++ )
382 detector=stevent->emcCollection()->detector(ids[iplane]);
400 for ( Int_t sector=0; sector<12; sector++ ) {
401 for ( Int_t layer=0; layer<4; layer++ )
402 mTowerClusters[sector][layer].clear();
403 for ( Int_t plane=0; plane<2; plane++ )
404 mSmdClusters[sector][plane].clear();
406 for ( Int_t i=0;i<6;i++ ) mNumberOfClusters[i]=0;
410 mClusterTrackMap.clear();
411 mBackgroundTrackMap.clear();
426 assert( c.
towers().size() );
432 mTowerClusters[sector][layer].push_back(c);
434 assert( mTowerClusters[sector][layer].back().towers().size() );
438 match.tower.push_back(c);
439 mClusterMap[ key ] =
match;
442 std::vector< StMuTrack* > v, u;
443 mClusterTrackMap[ key ] = v;
444 mBackgroundTrackMap[ key ] = u;
460 if ( seed.
sector() != c2.sector() )
return false;
466 Int_t plane = c2.plane();
467 Float_t mean = c2.mean();
468 Int_t mid = (max[plane]+min[plane])/2;
469 Float_t del = mean - mid;
471 return TMath::Abs(del)<mSmdMatchRange;
477 Bool_t myMatch =
false;
478 if ( ( c1.energy() > 0.8 * c2.energy() &&
479 c1.energy() < 1.2 * c2.energy() ) ||
480 ( c2.energy() > 0.8 * c1.energy() &&
481 c2.energy() < 1.2 * c1.energy() ) ) myMatch =
true;
483 if ( !myMatch )
return false;
485 for ( Int_t sec=0;sec<12;sec++ )
486 for ( UInt_t i=0; i < mTowerClusters[sec][0].size(); i++ )
490 if (
match ( c, c1 ) &&
match( c, c2 ) )
return true;
502 const Float_t match_at_z[]={
511 TVector3 r(0.,0.,-1.);
514 TVector3 position = cluster.
position();
515 Float_t dphi = fmod( position.Phi() - r.Phi(), TMath::TwoPi() );
516 Float_t deta = position.Eta() - r.Eta();
517 Float_t dr=TMath::Sqrt(deta*deta+dphi*dphi);
519 if ( dr < mClusterTrackSeparation[layer] )
return true;
529 const double kMinDipAngle = 1.0e-13;
530 double dipAng = helix.dipAngle();
531 double z0 = helix.
origin().z();
532 if(dipAng<kMinDipAngle)
534 double s = ( z - z0 ) / sin(dipAng) ;
536 r.SetXYZ(hit.x(),hit.y(),hit.z());
541 Bool_t StEEmcGenericClusterMaker::matchBackgroundTrack(
const StEEmcCluster &cluster,
const StMuTrack *track )
const
555 Double_t z1 = p1.z();
556 Double_t z2 = p2.z();
558 if ( z2 <= z1 )
return false;
560 const Float_t match_at_z[]={
567 Double_t zmatch = match_at_z[ layer ];
573 Double_t scale = zmatch - z1;
579 TVector3 r(myposition.x(),myposition.y(),myposition.z());
580 TVector3 position = cluster.
position();
582 Float_t dphi = fmod( position.Phi() - r.Phi(), TMath::TwoPi() );
583 Float_t deta = position.Eta() - r.Eta();
584 Float_t dr=TMath::Sqrt(deta*deta+dphi*dphi);
586 if ( dr < mClusterTrackSeparation[layer] )
return true;
597 return (plane==0)? (Int_t)matches.smdu.size() : (Int_t)matches.smdv.size();
603 return (plane==0)? matches.smdu[index] : matches.smdv[index];
609 return (plane==0)? matches.smdu[index] : matches.smdv[index];
StEEmcTower & tower(Int_t t)
Get the specified tower within the cluster.
static TObjArray * globalTracks()
returns pointer to the global tracks list
EEmc ADC –> energy maker.
Bool_t isNeighbor(const StEEmcTower &t) const
Int_t numberOfClusters() const
returns the total number of clusters summed over all layers
StEEmcGenericClusterMaker(const Char_t *name, const StEEmcA2EMaker *a2e=NULL)
void layer(Int_t l)
Sets the layer, [0-4]=[TPQR].
virtual void Clear(Option_t *opts="")
User defined functions.
TVector3 position() const
virtual void Clear(Option_t *option="")
User defined functions.
Bool_t extrapolateToZ(const StPhysicalHelixD &helix, const double z, TVector3 &r) const
extrapolates helix to position z (borrowed from StEEmcPool/TTM)
void add(const StEEmcCluster &cluster)
Add a tower (pre/postshower) cluster to the list of clusters.
Bool_t match(const StEEmcCluster &c1, const StEEmcCluster &c2) const
Int_t numberOfMatchingSmdClusters(const StEEmcCluster &cluster, Int_t plane) const
StEEmcTowerVec_t & towers()
Get the vector of towers in this cluster.
void print() const
Prints cluster data.
Int_t etabin() const
Returns the etabin of this tower, pre- or postshower element.
EEmatch & clusterMatch(const StEEmcCluster &c)
Int_t subsector() const
Returns subsector of this tower, pre- or postshower element.
short flag() const
Returns flag, (see StEvent manual for type information)
Base class for representing tower, preshower and postshower elements.
StEEmcSmdCluster & matchingSmdCluster(const StEEmcCluster &cluster, Int_t plane, Int_t index)
static TObjArray * primaryTracks()
returns pointer to a list of tracks belonging to the selected primary vertex
Int_t sector() const
Returns sector of this tower, pre- or postshower element.
const StThreeVector< double > & origin() const
-sign(q*B);
virtual const char * GetName() const
special overload
A base class for representing clusters of EEMC smd strips.
A base class for describing clusters of EEMC towers.
StEEmcCluster & cluster(Int_t sector, Int_t layer, Int_t index)