StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFmsCollection.cxx
1 /***************************************************************************
2  *
3  * $Id: StFmsCollection.cxx,v 2.9 2019/06/25 15:56:33 ullrich Exp $
4  *
5  * Author: Jingguo Ma, Dec 2009
6  ***************************************************************************
7  *
8  * Description:
9  *
10  ***************************************************************************
11  *
12  * $Log: StFmsCollection.cxx,v $
13  * Revision 2.9 2019/06/25 15:56:33 ullrich
14  * FMS shower shape scaling in StFmsCollection (Akio)
15  *
16  * Revision 2.8 2015/11/05 19:01:15 ullrich
17  * Improve print-out.
18  *
19  * Revision 2.7 2015/10/21 14:53:59 ullrich
20  * Added new member and methods.
21  *
22  * Revision 2.6 2015/09/14 16:59:53 ullrich
23  * Added StFmsPointPair collection.
24  *
25  * Revision 2.5 2015/09/01 21:01:47 ullrich
26  * Minor changes to format of print statments and \nchange to naming of data member.
27  *
28  * Revision 2.4 2015/09/01 18:29:01 ullrich
29  * Changes due to adding StFpsSlat and interconnection between slats and points.
30  *
31  * Revision 2.3 2015/08/26 16:51:59 ullrich
32  * Added print out fct and operator.
33  *
34  * Revision 2.2 2015/02/14 18:57:24 ullrich
35  * Big upgrade after adding StFmPoint and StFmsCluster.
36  *
37  * Revision 2.1 2010/01/08 22:42:30 ullrich
38  * Initial Revision.
39  *
40  **************************************************************************/
41 #include "StEvent/StFmsCollection.h"
42 
43 #include "StEvent/StFmsHit.h"
44 #include "StEvent/StFmsCluster.h"
45 #include "StEvent/StFmsPoint.h"
46 #include "StEvent/StFpsSlat.h"
47 #include "StEvent/StFmsPointPair.h"
48 #include "StarClassLibrary/StParticleTypes.hh"
49 
50 static const char rcsid[] = "$Id: StFmsCollection.cxx,v 2.9 2019/06/25 15:56:33 ullrich Exp $";
51 
52 StFmsCollection::StFmsCollection() :
53  mFmsReconstructionFlag(0), mFpsSlatFilled(false), mFpsAssociationFilled(false), mFmsPointPairFilled(false) {
54 }
55 
56 StFmsCollection::~StFmsCollection() {
57  for(unsigned int i=0; i<mPointPairs.size(); i++) {delete (mPointPairs[i]);}
58  mPointPairs.clear();
59 }
60 
61 unsigned int StFmsCollection::numberOfHits() const {
62  return mHits.size();
63 }
64 
65 unsigned int StFmsCollection::numberOfClusters() const {
66  return mClusters.size();
67 }
68 
69 unsigned int StFmsCollection::numberOfPoints() const {
70  return mPoints.size();
71 }
72 
73 void StFmsCollection::addHit(StFmsHit* hit) {
74  mHits.push_back(hit);
75 }
76 
77 void StFmsCollection::addCluster(StFmsCluster* cluster) {
78  mClusters.push_back(cluster);
79 }
80 
81 void StFmsCollection::addPoint(StFmsPoint* point) {
82  mPoints.push_back(point);
83 }
84 
85 StSPtrVecFmsHit& StFmsCollection::hits() {
86  return mHits;
87 }
88 
89 const StSPtrVecFmsHit& StFmsCollection::hits() const {
90  return mHits;
91 }
92 
93 StSPtrVecFmsCluster& StFmsCollection::clusters() {
94  return mClusters;
95 }
96 
97 const StSPtrVecFmsCluster& StFmsCollection::clusters() const {
98  return mClusters;
99 }
100 
101 StSPtrVecFmsPoint& StFmsCollection::points() {
102  return mPoints;
103 }
104 
105 const StSPtrVecFmsPoint& StFmsCollection::points() const {
106  return mPoints;
107 }
108 
109 StSPtrVecFpsSlat& StFmsCollection::fpsSlats() {
110  if(!mFpsAssociationFilled) fillFpsAssociation();
111  return mFpsSlats;
112 }
113 
114 StFpsSlat* StFmsCollection::fps(int slatid){
115  if(!mFpsAssociationFilled) fillFpsAssociation();
116  return mFpsSlats[slatid];
117 }
118 
119 void StFmsCollection::fillFpsSlat(){
120  mFpsSlats.Clear();
121  for(unsigned int i=0; i<kFpsMaxSlat; i++) {
122  mFpsSlats.push_back(new StFpsSlat(i,0.0));
123  }
124  for(unsigned int i=0; i<numberOfHits(); i++) {
125  if(mHits[i]->detectorId()==kFpsDetId){
126  int slatid=int(mHits[i]->channel());
127  if (slatid>=0 && slatid<kFpsMaxSlat){
128  mFpsSlats[slatid]->setMip(mHits[i]->energy());
129  }
130  }
131  }
132  mFpsSlatFilled=true;
133 }
134 
135 void StFmsCollection::fillFpsAssociation(){
136  if (!mFpsSlatFilled) fillFpsSlat();
137  for(unsigned int i=0; i<numberOfPoints(); i++) {
138  for(int l=1; l<=kFpsNLayer; l++) {
139  for(int c=0; c<kFpsNCandidate; c++) {
140  int slatid=mPoints[i]->fpsSlatId(l,c);
141  if (slatid>=0){
142  mFpsSlats[slatid]->addPoint(mPoints[i],c);
143  }
144  }
145  }
146  }
147  mFpsAssociationFilled=true;
148 }
149 
150 void StFmsCollection::fillFmsPointPair(){
151  int np=numberOfPoints();
152  if(np<=1) return;
153  sortPointsByEnergy(); //first sort points by energy
154  for(int i=0; i<np-1; i++){
155  if(mPoints[i]->energy()<1.0) break; //don't make pair with E<1GeV points
156  for(int j=i+1; j<np; j++){
157  if(mPoints[j]->energy()<1.0) break; //don't make pair with E<1GeV points
158  mPointPairs.push_back(new StFmsPointPair(mPoints[i],mPoints[j]));
159  }
160  }
161 
162  mPointPairsEnergySorted = mPointPairs;
163  std::sort(mPointPairsEnergySorted.begin(), mPointPairsEnergySorted.end(), [](StFmsPointPair* a, StFmsPointPair* b) {
164  return b->energy() < a->energy();
165  });
166 
167  mPointPairsETSorted = mPointPairs;
168  std::sort(mPointPairsETSorted.begin(), mPointPairsETSorted.end(), [](StFmsPointPair* a, StFmsPointPair* b) {
169  return b->pT() < a->pT();
170  });
171 
172  mPointPairsPi0MassSorted = mPointPairs;
173  std::sort(mPointPairsPi0MassSorted.begin(), mPointPairsPi0MassSorted.end(), [](StFmsPointPair* a, StFmsPointPair* b) {
174  return fabs(b->mass() - StPionZero::instance()->mass()) > fabs(a->mass() - StPionZero::instance()->mass());
175  });
176 
177  mFmsPointPairFilled=true;
178 }
179 
180 unsigned int StFmsCollection::numberOfPointPairs() {
181  if(!mFmsPointPairFilled) fillFmsPointPair();
182  return mPointPairs.size();
183 }
184 
185 vector<StFmsPointPair*>& StFmsCollection::pointPairs() {
186  if(!mFmsPointPairFilled) fillFmsPointPair();
187  return mPointPairs;
188 }
189 
190 vector<StFmsPointPair*>& StFmsCollection::pointPairsEnergySorted() {
191  if(!mFmsPointPairFilled) fillFmsPointPair();
192  return mPointPairsEnergySorted;
193 }
194 
195 vector<StFmsPointPair*>& StFmsCollection::pointPairsETSorted() {
196  if(!mFmsPointPairFilled) fillFmsPointPair();
197  return mPointPairsETSorted;
198 }
199 
200 vector<StFmsPointPair*>& StFmsCollection::pointPairsPi0MassSorted() {
201  if(!mFmsPointPairFilled) fillFmsPointPair();
202  return mPointPairsPi0MassSorted;
203 }
204 
205 void StFmsCollection::sortPointsByEnergy() {
206  std::sort(mPoints.begin(), mPoints.end(), [](StFmsPoint* a, StFmsPoint* b) {
207  return b->energy() < a->energy();
208  });
209 }
210 
211 void StFmsCollection::sortPointsByET() {
212  std::sort(mPoints.begin(), mPoints.end(), [](StFmsPoint* a, StFmsPoint* b) {
213  return b->fourMomentum().perp() < a->fourMomentum().perp();
214  });
215 }
216 
217 void StFmsCollection::print(int option) {
218  cout << Form("Flag=%x MergeSmallToLarge=%1d GlobalRefit=%1d Try1PhotonFit=%1d NewClusterCateg=%1d ScaleShowerShape=%1d Scale L/S=%f/%f\n",
219  mFmsReconstructionFlag,isMergeSmallToLarge(),isGlobalRefit(),isTry1PhotonFit(),
220  isNewClusterCategorization(),isScaleShowerShape(),scaleShowerShapeLarge(),scaleShowerShapeSmall());
221  cout << Form("NHit=%3d NCluster=%3d NPoint=%3d\n",numberOfHits(),numberOfClusters(),numberOfPoints());
222  if(option>=5) for(unsigned int i=0; i<numberOfHits(); i++) {hits()[i]->print();}
223  if(option>=4) for(unsigned int i=0; i<numberOfClusters(); i++) {clusters()[i]->print();}
224  if(option>=3) for(unsigned int i=0; i<mFpsSlats.size(); i++) {fpsSlats()[i]->print(1);}
225  if(option>=2) for(unsigned int i=0; i<numberOfPoints(); i++) {points()[i]->print();}
226  if(option>=1) for(unsigned int i=0; i<numberOfPointPairs(); i++) {pointPairs()[i]->print();}
227 }
228