1 #include "StEvent/StFcsCluster.h"
2 #include "StMuDSTMaker/COMMON/StMuFcsCluster.h"
3 #include "StMuDSTMaker/COMMON/StMuFcsHit.h"
4 #include "StMuDSTMaker/COMMON/StMuFcsPoint.h"
5 #include "StMuDSTMaker/COMMON/StMuFcsUtil.h"
6 #include "StMuDSTMaker/COMMON/StMuFcsInfo.h"
7 #include "StMuDSTMaker/COMMON/StMuFcsCollection.h"
8 #include "StMuDSTMaker/COMMON/StMuDst.h"
9 #include "StMuDSTMaker/COMMON/StMuEvent.h"
10 #include "StEvent/StEvent.h"
11 #include "St_base/StMessMgr.h"
12 #include "StEvent/StEventTypes.h"
13 #include "StEvent/StTriggerData.h"
18 #include "TCollection.h"
19 #include "TRefArray.h"
27 StMuFcsUtil::~StMuFcsUtil()
33 LOG_DEBUG <<
"StMuFcsUtil::getMuFcs" << endm;
34 if(!fcscol)
return NULL;
36 fillMuFcs(muFcs,fcscol);
42 if(!muFcs)
return NULL;
54 fillMuFcsHits(muFcs, fcscol);
55 fillMuFcsPoints(muFcs, fcscol);
56 fillMuFcsClusters(muFcs, fcscol);
57 fillMuFcsInfo(muFcs, fcscol);
61 rebuildRelationships( fcscol, muFcs );
68 fillFcsHits(fcscol, muFcs);
74 for (
unsigned int idet = 0; idet < kFcsNDet+1; idet++ ){
75 const StSPtrVecFcsHit& vecHit = fcscol->hits(idet);
76 for(
unsigned int i=0; i<fcscol->numberOfHits(idet); i++){
81 unsigned int l = vecHit[i]->nTimeBin();
82 if ( vecHit[i]->zs() ) l *= 2;
83 unsigned short data[ l ];
84 for (
unsigned int j = 0; j < l; j++ ){
85 data[ j ] = vecHit[i]->data( j );
89 vecHit[i]->zs(), vecHit[i]->detectorId(), vecHit[i]->
id(),
90 vecHit[i]->ns(), vecHit[i]->ehp(), vecHit[i]->dep(), vecHit[i]->channel(),
95 muFcsHit->setAdcSum ( vecHit[i]->adcSum() );
96 muFcsHit->setFitPeak ( vecHit[i]->fitPeak() );
97 muFcsHit->setFitSigma( vecHit[i]->fitSigma());
98 muFcsHit->setFitChi2 ( vecHit[i]->fitChi2() );
99 muFcsHit->setNPeak ( vecHit[i]->nPeak() );
100 muFcsHit->setEnergy ( vecHit[i]->energy() );
103 mMapHits[ fcscol->hits(idet)[i] ] = muFcsHit;
113 for (
unsigned int idet = 0; idet < kFcsNDet+1; idet++){
114 for(
unsigned int i=0; i<fcscol->numberOfHits(idet); i++){
116 if ( mMapHits.count( fcscol->hits(idet)[i] ) > 0 ) {
118 if (
nullptr == fcscol->hits(idet)[i]->cluster() )
continue;
119 if ( mMapClusters.count( fcscol->hits(idet)[i]->cluster() ) == 0
120 || mMapClusters[ fcscol->hits(idet)[i]->cluster() ] == nullptr )
123 StMuFcsCluster* muCluster = mMapClusters[ fcscol->hits(idet)[i]->cluster() ];
124 muHit->setCluster( muCluster );
127 LOG_ERROR <<
"Cannot find StMuFcsHit for StFcsHit=" << fcscol->hits(idet)[i] << endm;
133 for (
unsigned int idet = 0; idet < kFcsNDet; idet++){
134 const StSPtrVecFcsCluster &vecClu = fcscol->clusters(idet);
135 for(
unsigned int i=0; i<vecClu.size(); i++){
137 assert( mMapClusters.count( vecClu[i] ) > 0 );
140 StPtrVecFcsHit& vecHits = vecClu[i]->hits();
141 StPtrVecFcsCluster& vecNeighbors = vecClu[i]->neighbor();
142 StPtrVecFcsPoint& vecPoints = vecClu[i]->points();
144 for (
unsigned int j = 0; j < vecHits.size(); j++ ){
145 if ( vecHits[j] && mMapHits.count( vecHits[j] ) > 0 && mMapHits[vecHits[j]] != nullptr ) {
147 clu->hits()->Add( muHit );
149 LOG_ERROR <<
"Cannot find StMuFcsHit for StFcsHit=" << vecHits[j] << endm;
153 for (
unsigned int j = 0; j < vecNeighbors.size(); j++ ){
154 if ( vecNeighbors[j] && mMapClusters.count( vecNeighbors[j] ) > 0 && mMapClusters[vecNeighbors[j]] !=
nullptr) {
156 clu->addNeighbor( muCluster );
158 LOG_ERROR <<
"Cannot find StMuFcsCluster for StFcsCluster=" << vecNeighbors[j] << endm;
162 for (
unsigned int j = 0; j < vecPoints.size(); j++ ){
163 if ( vecPoints[j] && mMapPoints.count( vecPoints[j] ) > 0 && mMapPoints[vecPoints[j]] != nullptr ) {
165 clu->addPoint( muPoint );
167 LOG_ERROR <<
"Cannot find StMuFcsPoint for StFcsPoint=" << vecPoints[j] << endm;
191 for (
unsigned int idet = 0; idet < kFcsNDet; idet++ ){
192 for (
unsigned i(0); i < fcscol->numberOfClusters(idet); ++i) {
193 const StFcsCluster* cluster = fcscol->clusters(idet)[i];
196 muCluster->setId( cluster->id() );
197 muCluster->setDetectorId( cluster->detectorId() );
198 muCluster->setCategory( cluster->category() );
199 muCluster->setNTowers( cluster->nTowers() );
200 muCluster->setEnergy( cluster->energy() );
201 muCluster->setX( cluster->x() );
202 muCluster->setY( cluster->y() );
203 muCluster->setSigmaMin( cluster->sigmaMin() );
204 muCluster->setSigmaMax( cluster->sigmaMax() );
205 muCluster->setTheta( cluster->theta() );
206 muCluster->setChi2Ndf1Photon( cluster->chi2Ndf1Photon() );
207 muCluster->setChi2Ndf2Photon( cluster->chi2Ndf2Photon() );
209 lv.SetPxPyPzE( cluster->fourMomentum().px(), cluster->fourMomentum().py(), cluster->fourMomentum().pz(), cluster->fourMomentum().e() );
210 muCluster->setFourMomentum( lv );
212 mMapClusters[ cluster ] = muCluster;
220 for (
unsigned int idet = 0; idet < kFcsNDet; idet++ ){
221 for (
unsigned i(0); i < fcscol->numberOfPoints(idet); ++i) {
222 const StFcsPoint* point = fcscol->points(idet)[i];
224 if (point && muPoint) {
225 muPoint->setDetectorId( point->detectorId() );
226 muPoint->setEnergy( point->energy() );
227 muPoint->setX( point->x() );
228 muPoint->setY( point->y() );
229 muPoint->setNParentClusterPhotons( point->nParentClusterPhotons() );
230 muPoint->setXYZ( TVector3(point->xyz().x(), point->xyz().y(), point->xyz().z()) );
232 lv.SetPxPyPzE( point->fourMomentum().px(), point->fourMomentum().py(), point->fourMomentum().pz(), point->fourMomentum().e() );
233 muPoint->setFourMomentum( lv );
235 mMapPoints[ point ] = muPoint;
244 muFcs->setFcsReconstructionFlag(fcscol->fcsReconstructionFlag());
249 size_t clusterCount = 0;
250 size_t pointCount = 0;
251 for (
unsigned int idet = 0; idet < kFcsNDet + 1; idet++ ){
254 muFcs->getInfo()->setHitIndex( idet, hitCount );
255 hitCount += fcscol->numberOfHits(idet);
257 if ( idet == kFcsNDet )
259 muFcs->getInfo()->setClusterIndex( idet, clusterCount );
260 clusterCount += fcscol->numberOfClusters(idet);
262 muFcs->getInfo()->setPointIndex( idet, pointCount );
263 pointCount += fcscol->numberOfPoints(idet);
268 muFcs->getInfo()->setHitIndex( kFcsNDet + 1, hitCount );
269 muFcs->getInfo()->setClusterIndex( kFcsNDet, clusterCount );
270 muFcs->getInfo()->setPointIndex( kFcsNDet, pointCount );
277 TIter next(muFcs->getHitArray());
279 while ((muHit = static_cast<StMuFcsHit*>(next()))) {
280 unsigned int idet =
static_cast<unsigned int>(muHit->detectorId());
284 unsigned int l = muHit->nTimeBin();
285 if ( muHit->zs() ) l *= 2;
287 muHit->zs(), muHit->detectorId(), muHit->id(),
288 muHit->ns(), muHit->ehp(), muHit->dep(), muHit->channel(),
292 hit->setAdcSum ( muHit->adcSum() );
293 hit->setFitPeak ( muHit->fitPeak() );
294 hit->setFitSigma( muHit->fitSigma());
295 hit->setFitChi2 ( muHit->fitChi2() );
296 hit->setNPeak ( muHit->nPeak() );
297 hit->setEnergy ( muHit->energy() );