37 #include "StFmsPoint.h"
38 #include "St_base/StMessMgr.h"
41 static const char rcsid[] =
"$Id: StFmsPoint.cxx,v 2.8 2017/11/20 20:01:49 smirnovd Exp $";
43 StFmsPoint::StFmsPoint()
44 : mDetectorId(0), mEnergy(-1.0), mX(-99.0), mY(-99.0),
45 mId(-1), mParentClusterId(-1), mNParentClusterPhotons(-1), mCluster(0)
50 StFmsPoint::~StFmsPoint() { }
52 int StFmsPoint::fpsNCandidate(
int layer) {
53 if (layer>=1 && layer<=kFpsNLayer) {
54 return mFpsNCandidate[layer-1];
59 float StFmsPoint::fpsMip(
int layer,
int candidate) {
60 if(layer<1 || layer>kFpsNLayer)
return -1;
61 if(candidate>=0 && candidate<kFpsNCandidate)
return mFpsMip[layer-1][candidate];
62 if(candidate>=kFpsNCandidate && candidate<=kFpsNCandidate+2){
64 for(
int i=0; i<candidate-kFpsNCandidate+2; i++){
65 if(i==0 && mFpsMip[layer-1][i]==-9.0)
return -9.0;
66 if(mFpsMip[layer-1][i]>0.0) sum+=mFpsMip[layer-1][i];
73 int StFmsPoint::fpsSlatId(
int layer,
int candidate) {
74 if (layer>=1 && layer<=kFpsNLayer && candidate>=0 && candidate<mFpsNCandidate[layer-1]){
75 return mFpsSlatId[layer-1][candidate];
80 float StFmsPoint::fpsDistance(
int layer,
int candidate) {
81 if (layer>=1 && layer<=kFpsNLayer && candidate>=0 && candidate<mFpsNCandidate[layer-1]){
82 return mFpsDistance[layer-1][candidate];
87 void StFmsPoint::setFps(
int layer,
float mip,
int slatid,
float d) {
88 if (layer>=1 && layer<=kFpsNLayer){
89 int n=mFpsNCandidate[layer-1];
90 if (n>=kFpsNCandidate) {
91 LOG_WARN << Form(
"StFmsPoint::setFps() too many FPS slats associcated with a point in layer=%d (slatid=%d distance=%6.2f mip=%6.2f) n=%d/%d"
92 ,layer,slatid,d,mip,n,kFpsNCandidate) <<endm;
95 mFpsMip[layer-1][n] = mip;
96 mFpsSlatId[layer-1][n] = slatid;
97 mFpsDistance[layer-1][n] = d;
98 mFpsNCandidate[layer-1]++;
100 orderFpsCandidates(layer);
103 void StFmsPoint::resetFps() {
105 for(
int l=0; l<kFpsNLayer; l++){
107 for(
int c=0; c<kFpsNCandidate; c++){
108 mFpsMip[l][c] = -2.0;
109 mFpsSlatId[l][c] = -1;
110 mFpsDistance[l][c] = 999.0;
115 void StFmsPoint::orderFpsCandidates(
int layer) {
116 int l1=0, l2=kFpsNLayer;
117 if(layer>0) {l1=layer-1; l2=layer;}
118 for(
int l=l1; l<l2; l++){
119 int n=mFpsNCandidate[l];
121 int index[kFpsNCandidate];
122 TMath::Sort(n,mFpsDistance[l],index,
false);
123 for(
int i=0; i<n-1; i++) {
126 float mip = mFpsMip[l][i];
127 int slatid = mFpsSlatId[l][i];
128 float d = mFpsDistance[l][i];
129 mFpsMip[l][i] = mFpsMip[l][j];
130 mFpsSlatId[l][i] = mFpsSlatId[l][j];
131 mFpsDistance[l][i] = mFpsDistance[l][j];
133 mFpsSlatId[l][j] = slatid;
134 mFpsDistance[l][j] = d;
135 for(
int k=i+i; k<n; k++){
147 void StFmsPoint::print(
int opt) {
148 cout << Form(
"StFmsPoint: Id=%4d Det=%2d ParentId=%3d loc=%6.1f %6.1f xyz=%6.1f %6.1f %6.1f E=%7.2f ET=%6.2f FPS=",
149 id(), detectorId(), parentClusterId(),
150 x(), y(), XYZ().x(), XYZ().y(), XYZ().z(), energy(), fourMomentum().perp());
151 for(
int i=1; i<=kFpsNLayer; i++) {
153 float mip=fpsMip(i,0);
154 if(mip<0.0) {cout <<
"?";}
155 else if(mip>9.0) {cout <<
"9";}
156 else {cout << Form(
"%1d",
int(mip+0.5));}
158 cout << Form(
" PID=%2d(%s) ",fpsPid(),pidName(fpsPid()));
159 for(
int l=1; l<=kFpsNLayer; l++){
160 for(
int j=0; j<fpsNCandidate(l); j++){
161 int slatid=fpsSlatId(l,j);
162 int mip=int(fpsMip(l,j)+0.5);
163 int slat=slatid%21+1;
164 int layer=(slatid/21)%3+1;
165 int quad=(slatid/21/3)+1;
166 cout << Form(
" Q%1dL%1dS%02d=%2d ",quad,layer,slat,mip);