StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMuFwdTrackUtil.cxx
1 #include "StMuFwdTrackUtil.h"
2 #include "StMuFwdTrackCollection.h"
3 
4 #include "StEvent/StFcsCluster.h"
5 #include "StMuDSTMaker/COMMON/StMuFcsCluster.h"
6 #include "StMuDSTMaker/COMMON/StMuFcsHit.h"
7 #include "StMuDSTMaker/COMMON/StMuFcsPoint.h"
8 #include "StMuDSTMaker/COMMON/StMuFcsUtil.h"
9 #include "StMuDSTMaker/COMMON/StMuFcsInfo.h"
10 #include "StMuDSTMaker/COMMON/StMuFcsCollection.h"
11 
12 
13 #include "StEvent/StFwdTrackCollection.h"
14 #include "StEvent/StFwdTrack.h"
15 #include "St_base/StMessMgr.h"
16 
17 #include "StMuFwdTrack.h"
18 #include "StMuFwdTrackCollection.h"
19 
20 StMuFwdTrackCollection* StMuFwdTrackUtil::getMuFwdTrack(StFwdTrackCollection* evc){
21 
22  if ( evc == nullptr ){
23  LOG_WARN << "NULL StFwdTrackCollection, cannot fill MuDST" << endm;
24  }
25 
27  return muc;
28 }
29 
30 StFwdTrackCollection* StMuFwdTrackUtil::getFwdTrack(StMuFwdTrackCollection*){
31  return new StFwdTrackCollection();
32 }
33 
34 void StMuFwdTrackUtil::fillMuFwdTrack(StMuFwdTrackCollection* muc,StFwdTrackCollection* evc, StMuFcsUtil *fcsu){
35 
36  if ( evc == nullptr ){
37  LOG_WARN << "NULL StFwdTrackCollection, cannot fill FwdTracks in MuDST" << endm;
38  return;
39  }
40 
41  if ( muc == nullptr ){
42  LOG_WARN << "NULL StMuFwdTrackCollection, cannot fill FwdTracks in MuDST" << endm;
43  return;
44  }
45 
46  if ( fcsu == nullptr ){
47  LOG_WARN << "NULL StMuFcsUtil, cannot fill FwdTracks in MuDST" << endm;
48  return;
49  }
50 
51  auto fcsClusterMapEvToMu = fcsu->getClusterMap();
52 
53  const StSPtrVecFwdTrack& evTracks = evc->tracks();
54  LOG_INFO << "Adding " << evc->numberOfTracks() << " StMuFwdTracks to MuDSt" << endm;
55  for ( size_t i = 0; i < evc->numberOfTracks(); i++ ){
56  StFwdTrack * evTrack = evTracks[i];
57  StMuFwdTrack * muFwdTrack = muc->addFwdTrack();
58  muFwdTrack->set( evTrack );
59 
60  // Fix ECAL, HCAL associations
61  const StPtrVecFcsCluster& ecalClus = evTrack->ecalClusters();
62  const StPtrVecFcsCluster& hcalClus = evTrack->hcalClusters();
63 
64  for (auto eClu : ecalClus ){
65 
66  if ( fcsClusterMapEvToMu.count( eClu ) == 0){
67  LOG_WARN << "Cannot find ECAL Cluster in map" << endm;
68  continue;
69  }
70  StMuFcsCluster * muClu = fcsClusterMapEvToMu[ eClu ];
71  muFwdTrack->addEcalCluster( muClu );
72  }
73 
74  for (auto hClu : hcalClus ){
75 
76  if ( fcsClusterMapEvToMu.count( hClu ) == 0){
77  LOG_WARN << "Cannot find HCAL Cluster in map" << endm;
78  continue;
79  }
80  StMuFcsCluster * muClu = fcsClusterMapEvToMu[ hClu ];
81  muFwdTrack->addHcalCluster( muClu );
82  }
83  }
84 
85  return;
86 }