00001 #include "StEmcUtil/projection/StEmcPosition.h"
00002 #include "StEmcUtil/geometry/StEmcGeom.h"
00003
00004 #include "StGammaEventMaker.h"
00005 #include "StGammaEvent.h"
00006 #include "StGammaRawMaker.h"
00007 #include "StBarrelEmcCluster.h"
00008
00009 #include "StBarrelEmcClusterMaker.h"
00010
00011 using namespace std;
00012
00013 ClassImp(StBarrelEmcClusterMaker);
00014
00016
00018 StBarrelEmcClusterMaker::StBarrelEmcClusterMaker(const char *name): StMaker(name)
00019 {
00020 mHighTowerThreshold = 3.6;
00021 mClusterThreshold = 5.1;
00022 }
00023
00025
00027 int StBarrelEmcClusterMaker::Init()
00028 {
00029
00030
00031 mGammaEventMaker = dynamic_cast<StGammaEventMaker*>(GetMakerInheritsFrom("StGammaEventMaker"));
00032 assert(mGammaEventMaker);
00033
00034
00035 mGammaRawMaker = dynamic_cast<StGammaRawMaker*>(GetMakerInheritsFrom("StGammaRawMaker"));
00036 assert(mGammaRawMaker);
00037
00038 return StMaker::Init();
00039
00040 }
00041
00043
00045 void StBarrelEmcClusterMaker::Clear(Option_t* option)
00046 {
00047
00048 mVertex.SetXYZ(0,0,0);
00049
00050 for(unsigned i = 0; i < mClusters.size(); ++i)
00051 {
00052 delete mClusters[i];
00053 mClusters[i] = 0;
00054 }
00055
00056 mClusters.clear();
00057
00058 StMaker::Clear(option);
00059
00060 }
00061
00063
00065 int StBarrelEmcClusterMaker::Make()
00066 {
00067
00068
00069 if (mGammaEventMaker->event()) mVertex = mGammaEventMaker->event()->vertex();
00070
00071
00072 for(int id = 1; id <= 4800; ++id)
00073 {
00074
00075 if(StGammaTower* tower = mGammaRawMaker->tower(id, kBEmcTower))
00076 {
00077
00078
00079
00080 if (tower->energy > mHighTowerThreshold)
00081 {
00082
00083 StBarrelEmcCluster* cluster = makeCluster(tower);
00084
00085
00086
00087
00088 if(cluster && cluster->energy() > mClusterThreshold)
00089 {
00090 mClusters.push_back(cluster);
00091 }
00092
00093 }
00094
00095 }
00096
00097 }
00098
00099
00100 LOG_DEBUG << "Make() - Number of BEMC clusters: " << mClusters.size() << endm;
00101
00102 for(unsigned int i = 0; i < mClusters.size(); ++i)
00103 {
00104 LOG_DEBUG << "---------- BEMC CLUSTER #" << i << " ----------" << endm;
00105 LOG_DEBUG << *mClusters[i] << endm;
00106 }
00107
00108 return kStOk;
00109 }
00110
00112
00113
00114
00115
00116
00117
00118
00119
00121 StBarrelEmcCluster* StBarrelEmcClusterMaker::makeCluster(StGammaTower* tower) const
00122 {
00123
00124
00125
00126 StEmcPosition emcPosition;
00127
00128
00129 int id = tower->id;
00130 float energy = tower->energy;
00131
00132
00133 TVector3 position;
00134 getTowerPosition(id, position);
00135 position *= energy;
00136
00137
00138 StBarrelEmcCluster* cluster = new StBarrelEmcCluster;
00139 cluster->setSeed(tower);
00140
00141
00142 for (int deta = -1; deta <= 1; ++deta)
00143 {
00144
00145
00146 for (int dphi = -1; dphi <= 1; ++dphi)
00147 {
00148
00149
00150 if(deta == 0 && dphi == 0) continue;
00151
00152
00153 int neighborId = emcPosition.getNextTowerId(id, deta, dphi);
00154
00155
00156 if(StGammaTower* neighbor = mGammaRawMaker->tower(neighborId, kBEmcTower))
00157 {
00158
00159
00160
00161
00162
00163 if (tower->energy > neighbor->energy)
00164 {
00165
00166 cluster->setTower(deta, dphi, neighbor);
00167 TVector3 neighborPosition;
00168 getTowerPosition(neighborId, neighborPosition);
00169 position += neighborPosition * neighbor->energy;
00170 energy += neighbor->energy;
00171 }
00172 else
00173 {
00174 delete cluster;
00175 return 0;
00176 }
00177
00178 }
00179
00180 }
00181
00182 }
00183
00184
00185 position *= 1.0 / energy;
00186
00187
00188 cluster->setEnergy(energy);
00189 cluster->setPosition(position);
00190
00191
00192 TVector3 momentum = position - mVertex;
00193 momentum.SetMag(energy);
00194 cluster->setMomentum(momentum);
00195
00196 return cluster;
00197
00198 }
00199
00201
00202
00204 void StBarrelEmcClusterMaker::getTowerPosition(int id, TVector3& position) const
00205 {
00206 float x, y, z;
00207 StEmcGeom::instance("bemc")->getXYZ(id, x, y, z);
00208 position.SetXYZ(x, y, z);
00209 }