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