StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMuFmsCollection.cxx
1 /***************************************************************************
2  *
3  * $Id: StMuFmsCollection.cxx,v 1.6 2017/08/14 16:22:36 smirnovd Exp $
4  *
5  * Author: Jingguo Ma, Dec 2009
6  ***************************************************************************
7  *
8  * Description: FMS data interface to StMuFmsHit, StMuFmsCluster and StMuFmsPoint
9  *
10  ***************************************************************************
11  *
12  * $Log: StMuFmsCollection.cxx,v $
13  * Revision 1.6 2017/08/14 16:22:36 smirnovd
14  * Recover FMS hits using StTriggerData
15  *
16  * commit 6d7358f4c86a15edd0671326580d291a9843aec9
17  * Date: Tue Aug 8 23:42:41 2017 -0400
18  *
19  * StMuFmsUtil: Recover FMS hits using StTriggerData
20  *
21  * commit 556d07cb8fd87cb62e4ac674226423671c94917d
22  * Date: Tue Aug 8 23:42:34 2017 -0400
23  *
24  * StMuFmsUtil: Added func to fill StMuFmsCollection with FMS hits from StTriggerData in StMuEvent
25  *
26  * commit c355529c1ee401849b2b81d74df8d452886593d1
27  * Date: Tue Aug 8 23:42:19 2017 -0400
28  *
29  * [Cosmetic] Changes in whitespace
30  *
31  * commit 67fdc1b348bebbfbfb137b726ee9c455a7d8be37
32  * Date: Mon Jun 5 12:00:24 2017 -0400
33  *
34  * StMuFmsCollection::addHit() Return pointer to just added default FMS hit object
35  *
36  * Revision 1.5 2015/11/06 17:47:16 jdb
37  * Added StMuFmsInfo.{h,cxx} as a new branch for storing event-by-event FMS paramters
38  *
39  * Revision 1.4 2015/10/23 19:22:49 jdb
40  * akio added mFmsReconstructionFlag and related getters and setters. pushed version number of StMuFmsCollection. Corresponding changes for reconstruction flag in StMuFmsUtil.cxx
41  *
42  * Revision 1.3 2015/08/28 18:36:04 jdb
43  * Added Akios FMS codes
44  *
45  * Revision 1.2 2012/11/26 23:14:33 fisyak
46  * Replace GetEntries() by GetEntriesFast(), fix print outs
47  *
48  * Revision 1.1 2010/01/25 03:57:39 tone421
49  * Added FMS and Roman pot arrays
50  *
51  **************************************************************************/
52 #include "StMuDSTMaker/COMMON/StMuFmsCollection.h"
53 #include "StMuDSTMaker/COMMON/StMuFmsCluster.h"
54 #include "StMuDSTMaker/COMMON/StMuFmsHit.h"
55 #include "StMuDSTMaker/COMMON/StMuFmsPoint.h"
56  #include "StMuDSTMaker/COMMON/StMuFmsInfo.h"
57 
58 static const char rcsid[] = "$Id: StMuFmsCollection.cxx,v 1.6 2017/08/14 16:22:36 smirnovd Exp $";
59 
60 ClassImp(StMuFmsCollection)
61 
62 StMuFmsCollection::StMuFmsCollection() { mHits = 0; mClusters = 0; mPoints = 0; mInfo=0;}
63 
64 StMuFmsCollection::~StMuFmsCollection() {
65  if (mHits) {
66  delete mHits;
67  } // if
68  if (mClusters) {
69  delete mClusters;
70  } // if
71  if (mPoints) {
72  delete mPoints;
73  } // if
74  if (mInfo) {
75  delete mInfo;
76  } // if
77  mHits = mClusters = mPoints = mInfo = NULL;
78 }
79 
80 void StMuFmsCollection::init() {
81  mHits = new TClonesArray("StMuFmsHit", 0);
82  mClusters = new TClonesArray("StMuFmsCluster", 0);
83  mPoints = new TClonesArray("StMuFmsPoint", 0);
84  mInfo = new TClonesArray("StMuFmsInfo", 0);
85 }
86 
87 StMuFmsHit* StMuFmsCollection::addHit(){
88  if(!mHits) init();
89  int counter = mHits->GetEntriesFast();
90  StMuFmsHit* newFmsHit = new ((*mHits)[counter]) StMuFmsHit();
91  return newFmsHit;
92 }
93 
94 void StMuFmsCollection::addCluster() {
95  if (!mClusters) init();
96  int counter = mClusters->GetEntriesFast();
97  new ((*mClusters)[counter]) StMuFmsCluster;
98 }
99 
100 StMuFmsPoint* StMuFmsCollection::addPoint() {
101  if (!mPoints) init();
102  int counter = mPoints->GetEntriesFast();
103  return new ((*mPoints)[counter]) StMuFmsPoint;
104 }
105 
106 void StMuFmsCollection::addInfo() {
107  if (!mInfo) init();
108  int counter = mInfo->GetEntriesFast();
109  new ((*mInfo)[counter]) StMuFmsInfo;
110  return;
111 }
112 
113 unsigned int StMuFmsCollection::numberOfHits() const{
114  if(!mHits) return 0;
115  return mHits->GetEntriesFast();
116 }
117 
118 unsigned int StMuFmsCollection::numberOfClusters() const {
119  if (!mClusters) return 0;
120  return mClusters->GetEntriesFast();
121 }
122 
123 unsigned int StMuFmsCollection::numberOfPoints() const {
124  if (!mPoints) return 0;
125  return mPoints->GetEntriesFast();
126 }
127 
128 StMuFmsHit* StMuFmsCollection::getHit(int hitId){
129  if(!mHits) return NULL;
130  return (StMuFmsHit*) mHits->At(hitId);
131 }
132 
133 StMuFmsCluster* StMuFmsCollection::getCluster(int index) {
134  if (!mClusters) return NULL;
135  return static_cast<StMuFmsCluster*>(mClusters->At(index));
136 }
137 
138 StMuFmsPoint* StMuFmsCollection::getPoint(int index) {
139  if (!mPoints) return NULL;
140  return static_cast<StMuFmsPoint*>(mPoints->At(index));
141 }
142 
143 StMuFmsInfo* StMuFmsCollection::getInfo() {
144  if (!mInfo) return NULL;
145  return static_cast<StMuFmsInfo*>(mInfo->At(0));
146 }
147 
148 
149 Int_t StMuFmsCollection::fmsReconstructionFlag() {
150  return getInfo()->fmsReconstructionFlag();
151 }
152 void StMuFmsCollection::setFmsReconstructionFlag(Int_t v){
153  getInfo()->setFmsReconstructionFlag(v);
154 }