11 #include "StRoot/StEEmcPool/./EEmcTreeContainers/EEmcEnergy.h"
12 #include "StRoot/StEEmcPool/StEEmcPointMaker/eeTowerFunction.h"
13 #include "StEEmcUtil/EEmcGeom/EEmcGeomSimple.h"
14 #include "StRoot/StEEmcPool/StEEmcGeoId/StEEmcGeoId.h"
16 #include "StEEmcEnergyApportionerIU.h"
17 #include "StSimpleCluster.h"
18 #include "StEEmcHit.h"
19 #include "StESMDClustersPerSector.h"
28 const StSimpleClusterVec_t& towerClusterVec,
29 const StESMDClustersVec_t &smdClusterVec,
30 StEEmcHitVec_t& hitVec ){
31 if( !hitVec.empty() ){
38 std::vector< sparseVec_t > wPerTowerPerHit( hitVec.size() );
41 std::vector< Int_t > neighborIndices;
44 sparseVec_t denominator;
45 sparseVec_t::iterator denomIter, weightIter;
48 StEEmcHitVec_t::iterator hitIter = hitVec.begin();
52 static Int_t kEEmcNumPhiBins = kEEmcNumSubSectors * kEEmcNumSectors;
54 for( hitIter = hitVec.begin(); hitIter != hitVec.end(); ++hitIter, ++hitIdx ){
58 sparseVec_t& thisMap = wPerTowerPerHit[ hitIdx ];
61 neighborIndices.clear();
64 Int_t towIdx = hitIter->getTowerIdx();
67 StEEmcGeoId_t::decodeTow( towIdx, phiBin, etaBin );
70 Int_t phiBinLeft = (phiBin ? phiBin-1 : kEEmcNumPhiBins-1);
71 Int_t phiBinRight = (phiBin+1 < kEEmcNumPhiBins ? phiBin+1 : 0);
73 neighborIndices.push_back( StEEmcGeoId_t::encodeTow( phiBinLeft, etaBin ) );
74 neighborIndices.push_back( StEEmcGeoId_t::encodeTow( phiBin, etaBin ) );
75 neighborIndices.push_back( StEEmcGeoId_t::encodeTow( phiBinRight, etaBin ) );
77 if( etaBin < kEEmcNumEtas -1 ){
79 neighborIndices.push_back( StEEmcGeoId_t::encodeTow( phiBinLeft, etaBin + 1 ) );
80 neighborIndices.push_back( StEEmcGeoId_t::encodeTow( phiBin, etaBin + 1 ) );
81 neighborIndices.push_back( StEEmcGeoId_t::encodeTow( phiBinRight, etaBin + 1 ) );
86 neighborIndices.push_back( StEEmcGeoId_t::encodeTow( phiBinLeft, etaBin - 1 ) );
87 neighborIndices.push_back( StEEmcGeoId_t::encodeTow( phiBin, etaBin - 1 ) );
88 neighborIndices.push_back( StEEmcGeoId_t::encodeTow( phiBinRight, etaBin - 1 ) );
93 for( UInt_t i=0; i<neighborIndices.size(); ++i ){
94 Int_t& thisTowIdx = neighborIndices[i];
95 Float_t contribution = (this->*
weightFunc)( *hitIter, thisTowIdx );
97 thisMap[ thisTowIdx ] = contribution;
99 denomIter = denominator.find( thisTowIdx );
100 if( denomIter == denominator.end() ){
101 denominator[ thisTowIdx ] = contribution;
103 denominator[ thisTowIdx ] += contribution;
109 std::vector< Short_t > usedTowerIndices;
110 std::vector< Float_t > usedTowerWeights;
119 for( hitIter = hitVec.begin(); hitIter != hitVec.end(); ++hitIter, ++hitIdx ){
122 sparseVec_t& weightVec = wPerTowerPerHit[ hitIdx ];
125 usedTowerIndices.clear();
126 usedTowerWeights.clear();
128 Float_t hitEnergy = 0;
129 for( weightIter = weightVec.begin(); weightIter != weightVec.end(); ++weightIter ){
131 EEmcElement_t element = eemcEnergyPtr->eTow.getByIdx( weightIter->first );
136 if( !mCheckTowerBits || !element.fail ){
137 weightIter->second /= denominator[ weightIter->first ];
138 Float_t energy = element.energy;
139 energy *= weightIter->second;
143 usedTowerIndices.push_back( weightIter->first );
144 usedTowerWeights.push_back( weightIter->second );
150 hitIter->setEnergy( hitEnergy );
151 hitIter->setUsedTowers( usedTowerIndices, usedTowerWeights );
153 if( hitEnergy <= 0 ){
154 hitIter->setIsValid(0);
163 for( hitIter = hitVec.begin(); hitIter != hitVec.end() && hitIter->isValid(); ++hitIter ){ };
166 hitVec.erase( hitIter );
180 Short_t phiBin = 0, etaBin = 0;
181 StEEmcGeoId_t::decodeTow( thisTowIdx, phiBin, etaBin );
182 Double_t xTower[2] = { (Double_t) phiBin, (Double_t) etaBin };
185 Int_t towIdx = hit.getTowerIdx();
186 Short_t etaHitTower, phiHitTower;
187 StEEmcGeoId_t::decodeTow( towIdx, phiHitTower, etaHitTower );
194 if ( !mEEmcGeomSimple.
getTower( hit.getPosition(), sec, sub, eta, dphi, deta ) )
206 Double_t funcVal = eeTowerFunction( xTower, xHit );
214 funcVal *= ( hit.getEnergyU()*hit.getWeightU() + hit.getEnergyV()*hit.getWeightV() );
220 return ( hit.getEnergyU()*hit.getWeightU() + hit.getEnergyV()*hit.getWeightV() );
223 void StEEmcEnergyApportionerIU_t::setWeightFunction( WeightFunction_t funcType ){
228 case SMD_SUM_AND_LEAKAGE:
Float_t(StEEmcEnergyApportionerIU_t::* weightFunc)(const StEEmcHit_t &hit, Int_t thisTowerIdx)
pointer to which function to use for weights
bool getTower(const TVector3 &r, int &sec, int &sub, int &etabin, Float_t &dphi, Float_t &deta) const
Float_t smdSumAndLeakageWeightFunc(const StEEmcHit_t &hit, Int_t thisTowerIdx)
Use sum of SMD energies times leakage function (spline), i.e. the eeTowerFunction.
Float_t smdSumWeightFunc(const StEEmcHit_t &hit, Int_t thisTowerIdx)
Use just sum of SMD energies.
virtual Int_t find(EEmcEnergy_t *eemcEnergyPtr, const StSimpleClusterVec_t &towerClusterVec, const StESMDClustersVec_t &smdClusterVec, StEEmcHitVec_t &hitVec)
apportion the energy