Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

SharedConeStrategy.cxx

Go to the documentation of this file.
00001 #include "AtlfastAlgs/SharedConeStrategy.h"
00002 #include "AtlfastAlgs/ClusterConeStrategy.h"
00003 #include "AtlfastEvent/Cell.h"
00004 #include "AtlfastEvent/Cluster.h"
00005 
00006 #include "AtlfastUtils/FunctionObjects.h"
00007 
00008 // Gaudi includes
00009 #include "GaudiKernel/DataSvc.h"
00010 #include "StoreGate/DataHandle.h"
00011 #include "GaudiKernel/ISvcLocator.h"
00012 #include "GaudiKernel/MsgStream.h"
00013 
00014 #include <assert.h>
00015 #include <algorithm>
00016 namespace Atlfast{
00017 
00018   SharedConeStrategy::SharedConeStrategy(double rConeBarrel,
00019                                          double rConeForward,
00020                                          double minInitiatorET, 
00021                                          double minClusterET,
00022                                          double barrelForwardEta) : m_rConeBarrel(rConeBarrel),
00023                                                                     m_rConeForward(rConeForward),
00024                                                                     m_minClusterET(minClusterET),
00025                                                                     m_barrelForwardEta(barrelForwardEta)
00026   {
00028      m_coneStrategy = new ClusterConeStrategy( rConeBarrel,   
00029                                                rConeForward,
00030                                                minInitiatorET,
00031                                                minInitiatorET,//crazy!!!!!
00032                                                true);
00033   }
00034 
00035   SharedConeStrategy::~SharedConeStrategy(){delete m_coneStrategy;}
00036 
00037   void SharedConeStrategy::makeClusters(MsgStream& log, 
00038                                         const localCellCollection& storedCells,
00039                                         localCellCollection& unusedCells,
00040                                         ClusterCollection* clusters) const
00041   {
00042     //Firstly Call the bog Standard ClusterConeStrategy
00043     m_coneStrategy->makeClusters(log,  storedCells, unusedCells, clusters);
00044     
00045     //Now recalibrate those clusters
00046     //============================================================
00047     //Partition away all clusters that are more than two R away 
00048     //from other clusters
00049     // JPC: NOT DONE YET!!!!!
00050     //Copy pointers to all associated cells to local vector
00051     
00052     localCellCollection usedCells;
00053     std::map<Cluster*,double> aMap;
00054     ClusterCollection::iterator cluIter = clusters->begin();
00055     for(; cluIter != clusters->end(); ++cluIter) {
00056       aMap[*cluIter] = 0.0;
00057       Cell cell;
00058       IAssociationManager* iam = *cluIter;
00059       localCellCollection smv = iam->ikinematics();
00060       std::copy(smv.begin(), smv.end(),std::back_inserter(usedCells));
00061     }
00062     //Iterate over used cells
00063     localCellCollectionIterator cellIter = usedCells.begin();
00064     for(; cellIter != usedCells.end(); ++cellIter) {
00065       this->CellAssociatedClusterEnergy(
00066                                         cellIter,
00067                                         clusters->begin(),
00068                                         clusters->end(),
00069                                         aMap
00070                                         );
00071     }
00072     
00073     //recalculate cluster energies
00074     cluIter = clusters->begin();
00075     for(; cluIter != clusters->end(); ++cluIter){
00076       if(aMap.find(*cluIter) != aMap.end() && aMap[*cluIter] != 0.0) {
00077         double eT = aMap[*cluIter]/cosh((*cluIter)->eta());
00078         double theta = atan( exp( - (*cluIter)->eta() ) ) * 2.0 ;
00079         double t = eT / sin( theta ) ;
00080         double x = eT * cos( (*cluIter)->phi() ) ;
00081         double y = eT * sin( (*cluIter)->phi() ) ;
00082         double z = t * cos( theta ) ;
00083         (*cluIter)->setMomentum(HepLorentzVector(x,y,z,t));
00084       }
00085     }
00086     //Partition away clusters below eT threshold
00087     ClusterCollection::iterator part = std::partition(clusters->begin(),
00088                                                  clusters->end(),
00089                                                  PartitionCondition::AboveThresholdET( m_minClusterET ));
00090     //retrieve cells from discarded clusters and delete clusters
00091     std::for_each(part,clusters->end(),GetBackCells(unusedCells));
00092     clusters->erase(part,clusters->end());
00093     //sort clusters by eT
00094     sort( clusters->begin(),clusters->end(),SortAttribute::DescendingET());
00095     return;
00096   }
00097 
00098 
00099   void SharedConeStrategy::CellAssociatedClusterEnergy
00100   (
00101    std::vector<const Cell*>::const_iterator cell,
00102    ClusterCollection::iterator cluStart,
00103    ClusterCollection::iterator cluEnd,
00104    std::map<Cluster*,double>& cluMap
00105    ) const{
00106     double tempEnergy = 0.0;
00107     
00108     ClusterCollection::iterator endAssClu = 
00109       partition(cluStart, cluEnd, 
00110                 PartitionCondition::BelowThresholdDeltaR((*cell),m_rConeBarrel)
00111                 );
00112     
00113     //    assert(endAssClu != cluStart);
00114     
00115     //calculate the energy of clusters associated to cells 
00116     
00117     for(ClusterCollection::iterator itr = cluStart;
00118         itr != endAssClu;
00119         ++itr) tempEnergy += ((*itr)->eT()*cosh((*itr)->eta()));
00120     
00121     //calculate the shared energy fractions
00122     for(ClusterCollection::iterator itr = cluStart;itr != endAssClu;++itr){
00123       cluMap[*itr] += 
00124         ((*cell)->eT()*cosh((*cell)->eta())*(*itr)->eT()*cosh((*itr)->eta()))/
00125         tempEnergy;
00126     }
00127     return;
00128   }
00129 
00130   IKinematic* CastAwayConst(const IKinematic* c){return const_cast<IKinematic*>(c);}
00131 
00132   void SharedConeStrategy::GetBackCells::operator()(IAssociationManager* a){
00133     localCellCollection assCells  = a->ikinematics();
00134     //    std::transform(assCells.begin(),
00135     //     assCells.end(),
00136     //     std::back_inserter(m_unusedCells),
00137     //     CastAwayConst
00138     //     );
00139     std::copy(assCells.begin(),
00140               assCells.end(),
00141               std::back_inserter(m_unusedCells),
00142               );
00143     //delete(a); JPC: SHOULD I DELETE THIS?????????
00144     return;
00145   }
00146   
00147 }//end namespace

Generated on Tue Jan 28 09:57:14 2003 for AtlfastAlgs by doxygen1.3-rc1