00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "AtlfastAlgs/ClusterConeStrategy.h"
00011
00012 #include "AtlfastEvent/IKinematic.h"
00013 #include "AtlfastEvent/Cluster.h"
00014
00015 #include "AtlfastUtils/FunctionObjects.h"
00016
00017 #include <cmath>
00018 #include <algorithm>
00019 #include <vector>
00020
00021
00022 #include "GaudiKernel/MsgStream.h"
00023
00024
00025 #include "CLHEP/Vector/LorentzVector.h"
00026
00027
00028 namespace Atlfast {
00029 using std::sort;
00030 using std::partition;
00031
00032 void
00033 ClusterConeStrategy::makeClusters(
00034 MsgStream& log,
00035 const localCellCollection& storedCells,
00036 localCellCollection& unusedCells,
00037 ClusterCollection* clusters) const {
00038 log << MSG::DEBUG << storedCells.size() << "cells to start with"<<endreq;
00039
00040
00041
00042
00043
00044
00045 localCellCollection availableCells(storedCells.begin(),
00046 storedCells.end() );
00047 localCellIterator firstAvailableCell = availableCells.begin() ;
00048 localCellIterator lastAvailableCell = availableCells.end() ;
00049
00050
00051 localCellCollection availableInitiators( storedCells.begin(),
00052 storedCells.end() ) ;
00053 localCellIterator firstAvailableInitiator = availableInitiators.begin() ;
00054 localCellIterator lastAvailableInitiator = availableInitiators.end() ;
00055
00056
00057 lastAvailableInitiator
00058 = partition( firstAvailableInitiator,
00059 lastAvailableInitiator,
00060 PartitionCondition::AboveThresholdET( m_minInitiatorET )
00061 );
00062
00063
00064
00065 sort( firstAvailableInitiator,
00066 lastAvailableInitiator,
00067 SortAttribute::DescendingET()
00068 );
00069
00070
00071
00072
00073 while( firstAvailableInitiator != lastAvailableInitiator ) {
00074
00075
00076
00077
00078
00079
00080 double rCone = this->rCone( ) ;
00081
00082 localCellIterator endCellInCone = partition
00083 (
00084 firstAvailableCell,
00085 lastAvailableCell,
00086 PartitionCondition::BelowThresholdDeltaR( *firstAvailableInitiator,
00087 rCone )
00088 );
00089
00090
00091
00092 PreCluster preclus( firstAvailableCell, endCellInCone, m_masslessJets);
00093
00094
00095 if( preclus.eT() > m_minClusterET ){
00096
00097 HepLorentzVector temp=preclus;
00098 Cluster* newclus =
00099 new Cluster( temp, firstAvailableCell, endCellInCone ) ;
00100
00101
00102 clusters->push_back( newclus ) ;
00103
00104
00105
00106
00107 localCellIterator cell= firstAvailableCell;
00108 for(; cell != endCellInCone; ++cell ){
00109 lastAvailableInitiator =
00110 std::remove( firstAvailableInitiator,
00111 lastAvailableInitiator, *cell );
00112 }
00113
00114
00115 firstAvailableCell = endCellInCone ;
00116
00117 }else{
00118
00119
00120
00121
00122
00123 ++firstAvailableInitiator ;
00124 }
00125
00126 }
00127
00128 localCellIterator cellIter = firstAvailableCell;
00129 for(; cellIter!=lastAvailableCell; ++cellIter){
00130
00131 unusedCells.push_back( (*cellIter)->clone() );
00132 }
00133 return;
00134 }
00135
00136
00137
00138
00139
00140
00141
00142 double ClusterConeStrategy::rCone() const {
00143
00144
00145 return m_rConeBarrel ;
00146 }
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156 ClusterConeStrategy::PreCluster::PreCluster(
00157 localCellIterator start,
00158 localCellIterator end,
00159 bool masslessJets) :
00160 m_eT_total(0),
00161 m_eta_weighted(0),
00162 m_masslessJets(masslessJets),
00163 m_momentum_sum( 0, 0, 0, 0 ){
00164
00165 for( localCellIterator cell = start; cell != end; ++cell ){
00166
00167
00168 m_eT_total += (*cell)->eT() ;
00169 m_eta_weighted += (*cell)->eta() * (*cell)->eT() ;
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181 m_momentum_sum += (*cell)->momentum() ;
00182
00183 }
00184 }
00185
00186
00187
00188 double ClusterConeStrategy::PreCluster::eT() { return m_eT_total ; }
00189
00190 double ClusterConeStrategy::PreCluster::eta() {
00191
00192 if( m_eT_total > 0 ) return m_eta_weighted / m_eT_total ;
00193 else return 0. ;
00194 }
00195
00196 double ClusterConeStrategy::PreCluster::phi() {
00197
00198 return m_momentum_sum.phi() ;
00199 }
00200
00201
00202
00203 ClusterConeStrategy::PreCluster::operator HepLorentzVector () {
00204
00205
00206
00207
00208
00209
00210 double theta = atan( exp( - this->eta() ) ) * 2.0 ;
00211
00212 double x=0.,y=0.,z=0.,t=0. ;
00213
00214 if( (0. < theta) && ( theta < M_PI ) )
00215 {
00216 if(m_masslessJets){
00217 t = this->eT() / sin( theta ) ;
00218 x = this->eT() * cos( this->phi() ) ;
00219 y = this->eT() * sin( this->phi() ) ;
00220 z = t * cos( theta ) ;
00221 }else{
00222 t = m_momentum_sum.e();
00223 x = m_momentum_sum.px();
00224 y = m_momentum_sum.py();
00225 z = m_momentum_sum.pz();
00226 }
00227 }
00228
00229 return HepLorentzVector( x, y, z, t ) ;
00230 }
00231 }
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242