StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StSimpleCluster.cxx
1 
9 //#include <iostream>
10 #include "StSimpleCluster.h"
11 
12 StSimpleCluster_t& StSimpleCluster_t::operator+=( const StSimpleCluster_t& other ){
13 // std::cout << "Merging" << std::endl;
14 // std::cout << "\t" << *this << std::endl;
15 // std::cout << "\t" << other << std::endl;
16 // std::cout << "Old seeds " << mSeedIdx << ' ' << other.mSeedIdx << " old sizes " << mMember.GetSize() << ' ' << other.mMember.GetSize() << std::endl;
17 
18  if( other.mE > mE ){
19  mID = other.mID;
20  mSeedIdx = other.mSeedIdx + mMember.GetSize();
21  };
22  mMeanX = other.mE*other.mMeanX + mE*mMeanX;
23  mMeanY = other.mE*other.mMeanY + mE*mMeanY;
24 
25  mE += other.mE;
26  if( mE ){
27  mMeanX /= mE;
28  mMeanY /= mE;
29  };
30  Int_t oldSize = mMember.GetSize();
31  Int_t newSize = oldSize + other.mMember.GetSize();
32  mMember.Set( newSize );
33  for( Int_t i = oldSize, j = 0; i < newSize; ++i, ++j )
34  mMember[i] = other.mMember[j];
35 
36  oldSize = mWeight.GetSize();
37  newSize = oldSize + other.mWeight.GetSize();
38  mWeight.Set( newSize );
39  for( Int_t i = oldSize, j = 0; i < newSize; ++i, ++j )
40  mWeight[i] = other.mWeight[j];
41 
42 // std::cout << "Merged: " << *this << std::endl;
43 
44  return *this;
45 };
46 
47 std::ostream &operator<<( std::ostream &out, const StSimpleCluster_t &clus ){
48  out << "clus " << clus.mID << ", E = " << clus.mE << ", nMember = " << clus.mMember.GetSize() << ", " << clus.mWeight.GetSize();
49  out << ", seed at " << clus.mSeedIdx << ", with idx " << clus.getSeedMember() << " X = " << clus.mMeanX;
50  return out;
51 };
52 
53 ClassImp(StSimpleCluster_t);
54 
55 /*
56  * $Id: StSimpleCluster.cxx,v 1.1 2012/11/26 19:05:56 sgliske Exp $
57  * $Log: StSimpleCluster.cxx,v $
58  * Revision 1.1 2012/11/26 19:05:56 sgliske
59  * moved from offline/users/sgliske/StRoot/StEEmcPool/StEEmcHitMaker to StRoot/StEEmcPool/StEEmcHitMaker
60  *
61  *
62  */