StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEEmcIUSmdCluster.cxx
1 
17 #include "StEEmcIUSmdCluster.h"
18 #include <TMath.h>
19 
20 #include "StEvent/StEmcCluster.h"
21 
22 ClassImp(StEEmcIUSmdCluster);
23 
24 // ----------------------------------------------------------------------------
25 StEEmcIUSmdCluster::StEEmcIUSmdCluster()
26 {
27  mEnergy=0.;
28  mSumXW=0.;
29  mSumX2W=0.;
30  mEmcCluster = 0;
31 }
32 
34 {
35  // std::cout << "smd cluster plane=" << plane() << std::endl;
36  std::cout << "key=" << key() << std::endl;
37  std::cout << "energy=" << energy() << std::endl;
38  std::cout << "mean=" << mean() << std::endl;
39 }
40 
41 StEEmcIUSmdCluster::StEEmcIUSmdCluster( const StEEmcIUSmdCluster &c )
42 {
43 
44  mStrips=c.mStrips;
46  mEnergy=c.mEnergy;
47  mSumXW=c.mSumXW;
48  mSumX2W=c.mSumX2W;
49  mMean=c.mMean;
50  mSigma=c.mSigma;
51  mSize=c.mSize;
52  mKey=c.mKey;
55  mPlane=c.mPlane;
56  mSector=c.mSector;
57 }
58 // ----------------------------------------------------------------------------
59 void StEEmcIUSmdCluster::add( StEEmcStrip strip, Float_t weight )
60 {
61 
62  if ( mStrips.size() == 0 )
63  {
64  mPlane=strip.plane();
65  mSector=strip.sector();
66  }
67 
68  mWeights.push_back(weight);
69  mStrips.push_back(strip);
70 
71  Float_t energy = strip.energy() * weight;
72 
73  mEnergy += energy;
74  mSumXW += ( strip.index() + 0.5 ) * energy;
75  mSumX2W += ( strip.index() + 0.5 ) * ( strip.index() + 0.5 ) * energy;
76 
77  mMean = mSumXW / mEnergy;
79  mSigma = TMath::Sqrt(mSigma);
80 
81  mSize=(Int_t)mStrips.size();
82 
83 }
84 
85 // ----------------------------------------------------------------------------
87 {
88 
89  if ( mEmcCluster ) return mEmcCluster;
90 
92  Int_t iuv=( mStrips[0].plane()==1 ); // 0=U, 1=V
93 
94  if ( iuv==0 ) {
95  mEmcCluster->setEta( mean() );
96  mEmcCluster->setSigmaEta( sigma() );
97  mEmcCluster->setPhi( -1. );
98  mEmcCluster->setSigmaPhi( -1. );
99  }
100  else {
101  mEmcCluster->setEta( -1. );
102  mEmcCluster->setSigmaEta( -1. );
103  mEmcCluster->setPhi( mean() );
104  mEmcCluster->setSigmaPhi( sigma() );
105  }
106  mEmcCluster->setEnergy( energy() );
107 
108  for ( Int_t i=0; i<numberOfStrips(); i++ ) {
109  StEmcRawHit *hit=mStrips[i].stemc();
110  assert(hit);
111  mEmcCluster->addHit( hit );
112  }
113 
114  return mEmcCluster;
115 
116 }
117 
118 // ----------------------------------------------------------------------------
119 Float_t StEEmcIUSmdCluster::energy(Int_t nmax, Option_t *opts)
120 {
121 
122  Float_t mymean;
123  if ( TString(opts).Contains("seed") )
124  {
125  mymean=mStrips[0].index()+0.5;
126  }
127  else
128  {
129  mymean=mean();
130  }
131  Int_t min=(Int_t)(mymean-(Float_t)nmax);
132  Int_t max=(Int_t)(mymean+(Float_t)nmax);
133 
134  Float_t esum=0.;
135 
136  for ( UInt_t i=0;i<mStrips.size();i++ )
137  {
138  StEEmcStrip &s=mStrips[i];
139  if ( s.index() >= min && s.index() <= max ) esum+=s.energy();
140  }
141 
142  return esum;
143 
144 }
145 
146 Float_t StEEmcIUSmdCluster::sigma(Int_t nmax, Option_t *opts)
147 {
148 
149  Float_t mymean;
150  if ( TString(opts).Contains("seed") )
151  {
152  mymean=mStrips[0].index()+0.5;
153  }
154  else
155  {
156  mymean=mean();
157  }
158  Int_t min=(Int_t)(mymean-(Float_t)nmax);
159  Int_t max=(Int_t)(mymean+(Float_t)nmax);
160 
161  std::cout << "mymean=" << mymean << std::endl;
162  std::cout << "min =" << min << std::endl;
163  std::cout << "max =" << max << std::endl;
164 
165  Float_t esum=0.;
166  Float_t xsum=0.;
167  Float_t x2sum=0.;
168 
169  for ( UInt_t i=0;i<mStrips.size();i++ )
170  {
171  StEEmcStrip &s=mStrips[i];
172  std::cout << i << " " << s.index() << std::endl;
173  if ( s.index() >= min && s.index() <= max ) {
174  esum+=s.energy();
175  xsum+=(s.index()+0.5)*s.energy();
176  x2sum+=(s.index()+0.5)*(s.index()+0.5)*s.energy();
177  }
178  }
179  Float_t sig=0.;
180  if ( esum>0. )
181  {
182  sig=TMath::Sqrt( x2sum/esum - (xsum/esum)*(xsum/esum) );
183  }
184 
185 
186  return sig;
187 
188 }
Float_t mEnergy
Energy of this SMD cluster.
Int_t key()
Return a unique key assigned by the cluster maker.
Int_t mSize
Kludge so that root will store number of smd strips.
std::vector< Float_t > mWeights
Vector of strip weights.
Int_t numberOfStrips()
Returns the number of SMD strips in the cluster.
Float_t mSumXW
Running sums to calculate mean, sigma of cluster.
Float_t mMean
Mean and sigma computed after each strip is added.
void index(Int_t i)
Sets the index for this SMD strip, 0..287.
Definition: StEEmcStrip.cxx:32
StEEmcTowerVec_t mMatchedTowers
Vector of hit towers above this SMD cluster.
Float_t mean()
Return the mean strip number of this cluster.
Float_t mSumX2W
Running sums to calculate mean, sigma of cluster.
Float_t sigma()
Return the sigma – TMath::Sqrt(variance) – of the cluster.
Int_t mKey
Unique key.
A base class for representing clusters of EEMC smd strips.
StEmcCluster * mEmcCluster
POinter to EMC cluster.
void plane(Int_t p)
Sets the plane for this SMD strip, 0=U, 1=V.
Definition: StEEmcStrip.h:19
void sector(Int_t s)
Sets the sector for this SMD strip.
Definition: StEEmcStrip.h:17
void energy(Float_t e)
Set the energy (adc-ped+0.5)/gain for this element.
Definition: StEEmcElement.h:21
StEEmcStripVec_t mStrips
Vector of strips belonging to this SMD cluster.
Base class for describing an endcap SMD strip.
Definition: StEEmcStrip.h:8
Float_t energy()
Return the energy of this cluster.
StEmcCluster * stemc()
void add(StEEmcStrip strip, Float_t weight=1.0)