StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFmsTower.cxx
Go to the documentation of this file.
1 // $Id: StFmsTower.cxx,v 1.3 2016/06/07 15:51:44 akio Exp $
2 //
3 // $Log: StFmsTower.cxx,v $
4 // Revision 1.3 2016/06/07 15:51:44 akio
5 // Making code better based on Coverity reports
6 //
7 // Revision 1.2 2015/10/21 15:58:05 akio
8 // Code speed up (~x2) by optimizing minimization fuctions and showershape function
9 // Add option to merge small cells to large, so that it finds cluster at border
10 // Add option to perform 1photon fit when 2photon fit faield
11 // Add option to turn on/off global refit
12 // Moment analysis done without ECUTOFF when no tower in cluster exceed ECUTOFF=0.5GeV
13 //
14 // Revision 1.1 2015/03/10 14:38:54 jeromel
15 // First version of FmsUtil from Yuxi Pan - reviewd 2015/02
16 //
26 #include "StFmsUtil/StFmsTower.h"
27 
28 #include "StEvent/StFmsHit.h"
29 #include "StFmsDbMaker/StFmsDbMaker.h"
30 
31 namespace FMSCluster {
33  : mHit(nullptr), mColumn(-1), mRow(-1), mCluster(-1), mX(0.0), mY(0.0), mE(0.0), mW(0.0) {}
34 
36  : mHit(fmsHit), mColumn(-1), mRow(-1), mCluster(-1), mX(0.0), mY(0.0), mE(0.0), mW(0.0) {}
37 
39 
41  if (!mHit || !database) { // Check for invalid input
42  return false;
43  } // if
44  // Get row and column from the database
45  int det=mHit->detectorId();
46  mRow = database->getRowNumber(det, mHit->channel());
47  mColumn = database->getColumnNumber(det, mHit->channel());
48  mE = mHit->energy();
49  mW = (database->getXWidth(det) + database->getYWidth(det))/2.0;
50  return mRow > -1 && mColumn > -1;
51 }
52 
53 Bool_t StFmsTower::isNeighbor(const StFmsTower& other) const {
54  int det0=mHit->detectorId();
55  int det1=other.hit()->detectorId();
56  //within the same detector
57  if(det0==det1){
58  return abs(mColumn - other.column()) + abs(mRow - other.row()) == 1;
59  }
60  //different detector (large and small)
61  bool ret=false;
62  int rowL,colL,rowS,colS;
63  if(det0<det1){
64  rowL=mRow; rowS=other.row();
65  colL=mColumn; colS=other.column();
66  }else{
67  rowS=mRow; rowL=other.row();
68  colS=mColumn; colL=other.column();
69  }
70  if(rowS>1 && rowS<24 && colS<12){ //inside small cells
71  ret=false;
72  }else if(rowL<9 || rowL>26 || colL>9){ //inside large cells
73  ret=false;
74  }else if((rowS==1 && rowL==9) || (rowS==24 && rowL==26) ){ //large small boundary at top or bottom
75  if((colL-1)/2 == (colS-1)/3){
76  if ((colL-1)%2==0 && (colS-1)%3==2) {ret=false;}
77  else if((colL-1)%2==1 && (colS-1)%3==0) {ret=false;}
78  else {ret=true;}
79  }else{
80  ret=true;
81  }
82  }else if(colL==9 && colS==12){ //large small boundary at side
83  if((rowL-10)/2 == (rowS-1)/3){
84  if ((rowL-10)%2==0 && (rowS-1)%3==2) {ret=false;}
85  else if((rowL-10)%2==1 && (rowS-1)%3==0) {ret=false;}
86  else {ret=true;}
87  }else{
88  ret=true;
89  }
90  }else{
91  ret=true;
92  }
93  //printf("det0=%2d det1=%2d rowL=%2d colL=%2d rowS=%2d colS=%2d ret=%d\n",det0,det1,rowL,colL,rowS,colS,int(ret));
94  return ret;
95 }
96 
97 } // namespace FMSCluster
Bool_t isNeighbor(const StFmsTower &tower) const
Definition: StFmsTower.cxx:53
Double_t mE
local y [cm]
Definition: StFmsTower.h:114
Float_t getXWidth(Int_t detectorId)
get the offset of the detector
const StFmsHit * mHit
Hit information, not owned by StFmsTower.
Definition: StFmsTower.h:108
const StFmsHit * hit() const
Definition: StFmsTower.h:90
Bool_t initialize(StFmsDbMaker *database)
Definition: StFmsTower.cxx:40
Int_t column() const
Definition: StFmsTower.h:92
Declaration of StFmsTower, a simple FMS tower wrapper.
Int_t getRowNumber(Int_t detectorId, Int_t ch)
maximum number of channels
Int_t getColumnNumber(Int_t detectorId, Int_t ch)
get the row number for the channel
Float_t getYWidth(Int_t detectorId)
get the X width of the cell
Double_t mW
Energy.
Definition: StFmsTower.h:115
Int_t row() const
Definition: StFmsTower.h:94
Int_t mRow
&lt; Column number, starts at 1, horizontal (STAR x-coord)
Definition: StFmsTower.h:110