00001 #include "SimDataFormats/SLHC/interface/L1CaloCluster.h"
00002
00003 #include <stdlib.h>
00004
00005 namespace l1slhc
00006 {
00007
00008 L1CaloCluster::L1CaloCluster( ):mIeta( 0 ),
00009 mIphi( 0 ),
00010 mE( 0 ),
00011 mLeadTowerE( 0 ),
00012 mSecondTowerE( 0 ),
00013 mThirdTowerE( 0 ),
00014 mFourthTowerE( 0 ),
00015 mRing1E( 0 ),
00016 mRing2E( 0 ),
00017 mRing3E( 0 ),
00018 mRing4E( 0 ),
00019 mFg( false ),
00020 mEgamma( false ),
00021 mCentral( false ),
00022 mIsoeg( false ),
00023 mLeadtowertau( false ),
00024 mIsotau( false ),
00025 mEgammavalue( 0 ),
00026 mInnereta( 0 ),
00027 mInnerphi( 0 ),
00028 mIsoclusterseg( 0 ),
00029 mIsoclusterstau( 0 ),
00030 mP4( math::PtEtaPhiMLorentzVector( 0.001, 0, 0, 0. ) )
00031 {
00032 }
00033
00034 L1CaloCluster::L1CaloCluster( const int &iEta, const int &iPhi ):mIeta( iEta ),
00035 mIphi( iPhi ),
00036 mE( 0 ),
00037 mLeadTowerE( 0 ),
00038 mSecondTowerE( 0 ),
00039 mThirdTowerE( 0 ),
00040 mFourthTowerE( 0 ),
00041 mRing1E( 0 ),
00042 mRing2E( 0 ),
00043 mRing3E( 0 ),
00044 mRing4E( 0 ),
00045 mFg( false ),
00046 mEgamma( false ),
00047 mCentral( false ),
00048 mIsoeg( false ),
00049 mLeadtowertau( false ),
00050 mIsotau( false ),
00051 mEgammavalue( 0 ),
00052 mInnereta( 0 ),
00053 mInnerphi( 0 ),
00054 mIsoclusterseg( 0 ),
00055 mIsoclusterstau( 0 ),
00056 mP4( math::PtEtaPhiMLorentzVector( 0.001, 0, 0, 0. ) )
00057 {
00058 }
00059
00060
00061
00062 L1CaloCluster::~L1CaloCluster( )
00063 {
00064 }
00065
00066
00067 const int &L1CaloCluster::iEta( ) const
00068 {
00069 return mIeta;
00070 }
00071
00072 const int &L1CaloCluster::iPhi( ) const
00073 {
00074 return mIphi;
00075 }
00076
00077 const int &L1CaloCluster::innerEta( ) const
00078 {
00079 return mInnereta;
00080 }
00081
00082 const int &L1CaloCluster::innerPhi( ) const
00083 {
00084 return mInnerphi;
00085 }
00086
00087
00088 const int &L1CaloCluster::E( ) const
00089 {
00090 return mE;
00091 }
00092
00093
00094 const int &L1CaloCluster::LeadTowerE( ) const
00095 {
00096 return mLeadTowerE;
00097 }
00098
00099 const int &L1CaloCluster::SecondTowerE( ) const
00100 {
00101 return mSecondTowerE;
00102 }
00103
00104 const int &L1CaloCluster::ThirdTowerE( ) const
00105 {
00106 return mThirdTowerE;
00107 }
00108
00109 const int &L1CaloCluster::FourthTowerE( ) const
00110 {
00111 return mFourthTowerE;
00112 }
00113
00114
00115 const int &L1CaloCluster::Ring1E( ) const
00116 {
00117 return mRing1E;
00118 }
00119
00120
00121 const int &L1CaloCluster::Ring2E( ) const
00122 {
00123 return mRing2E;
00124 }
00125
00126 const int &L1CaloCluster::Ring3E( ) const
00127 {
00128 return mRing3E;
00129 }
00130
00131 const int &L1CaloCluster::Ring4E( ) const
00132 {
00133 return mRing4E;
00134 }
00135
00136 const bool & L1CaloCluster::fg( ) const
00137 {
00138 return mFg;
00139 }
00140
00141 const bool & L1CaloCluster::eGamma( ) const
00142 {
00143 return mEgamma;
00144 }
00145
00146 const bool & L1CaloCluster::hasLeadTower( ) const
00147 {
00148 return mLeadtowertau;
00149 }
00150
00151
00152 const int &L1CaloCluster::eGammaValue( ) const
00153 {
00154 return mEgammavalue;
00155 }
00156
00157 const bool & L1CaloCluster::isoEG( ) const
00158 {
00159 return mIsoeg;
00160 }
00161
00162 const bool & L1CaloCluster::isoTau( ) const
00163 {
00164 return mIsotau;
00165 }
00166
00167 const bool & L1CaloCluster::isCentral( ) const
00168 {
00169 return mCentral;
00170 }
00171
00172 const int &L1CaloCluster::isoClustersEG( ) const
00173 {
00174 return mIsoclusterseg;
00175 }
00176
00177 const int &L1CaloCluster::isoClustersTau( ) const
00178 {
00179 return mIsoclusterstau;
00180 }
00181
00182 const int &L1CaloCluster::isoEnergyEG( ) const
00183 {
00184 return mIsoenergyeg;
00185 }
00186
00187 const int &L1CaloCluster::isoEnergyTau( ) const
00188 {
00189 return mIsoenergytau;
00190 }
00191
00192 bool L1CaloCluster::isEGamma( ) const
00193 {
00194 return ( !fg( ) && eGamma( ) && isCentral( ) );
00195 }
00196
00197 bool L1CaloCluster::isIsoEGamma( ) const
00198 {
00199 return ( !fg( ) && eGamma( ) && isoEG( ) && isCentral( ) );
00200 }
00201
00202 bool L1CaloCluster::isIsoTau( ) const
00203 {
00204 return hasLeadTower( ) && isoTau( ) && isCentral( );
00205 }
00206
00207 bool L1CaloCluster::isTau( ) const
00208 {
00209 return hasLeadTower( ) && isCentral( );
00210 }
00211
00212
00213 void L1CaloCluster::setE( const int &E )
00214 {
00215 mE = E;
00216 }
00217
00218
00219 void L1CaloCluster::setLeadTowerE( const int &E )
00220 {
00221 mLeadTowerE = E;
00222 }
00223
00224 void L1CaloCluster::setSecondTowerE( const int &E )
00225 {
00226 mSecondTowerE = E;
00227 }
00228
00229 void L1CaloCluster::setThirdTowerE( const int &E )
00230 {
00231 mThirdTowerE = E;
00232 }
00233
00234 void L1CaloCluster::setFourthTowerE( const int &E )
00235 {
00236 mFourthTowerE = E;
00237 }
00238
00239
00240 void L1CaloCluster::setRing1E( const int &Ring1E )
00241 {
00242 mRing1E = Ring1E;
00243 }
00244
00245
00246 void L1CaloCluster::setRing2E( const int &Ring2E )
00247 {
00248 mRing2E = Ring2E;
00249 }
00250
00251 void L1CaloCluster::setRing3E( const int &Ring3E )
00252 {
00253 mRing3E = Ring3E;
00254 }
00255
00256 void L1CaloCluster::setRing4E( const int &Ring4E )
00257 {
00258 mRing4E = Ring4E;
00259 }
00260
00261 void L1CaloCluster::setConstituents( const L1CaloTowerRefVector & cons )
00262 {
00263 mConstituents = cons;
00264 }
00265
00266 const L1CaloTowerRefVector & L1CaloCluster::getConstituents( ) const
00267 {
00268 return mConstituents;
00269 }
00270
00271
00272 void L1CaloCluster::setFg( const bool & fg )
00273 {
00274 mFg = fg;
00275 }
00276
00277
00278 void L1CaloCluster::setEGamma( const bool & eg )
00279 {
00280 mEgamma = eg;
00281 }
00282
00283 void L1CaloCluster::setLeadTower( const bool & eg )
00284 {
00285 mLeadtowertau = eg;
00286 }
00287
00288
00289 void L1CaloCluster::setEGammaValue( const int &eg )
00290 {
00291 mEgammavalue = eg;
00292 }
00293
00294 void L1CaloCluster::setIsoEG( const bool & eg )
00295 {
00296 mIsoeg = eg;
00297 }
00298
00299 void L1CaloCluster::setIsoTau( const bool & eg )
00300 {
00301 mIsotau = eg;
00302 }
00303
00304 void L1CaloCluster::setIsoClusters( const int &eg, const int &tau )
00305 {
00306 mIsoclusterseg = eg;
00307 mIsoclusterstau = tau;
00308 }
00309
00310 void L1CaloCluster::setIsoEnergy( const int &eg, const int &tau )
00311 {
00312 mIsoenergyeg = eg;
00313 mIsoenergytau = tau;
00314 }
00315
00316
00317 void L1CaloCluster::setCentral( const bool & eg )
00318 {
00319 mCentral = eg;
00320 }
00321
00322 void L1CaloCluster::setPosBits( const int &eta, const int &phi )
00323 {
00324 mInnereta = eta;
00325 mInnerphi = phi;
00326
00327 }
00328
00329 void L1CaloCluster::setLorentzVector( const math::PtEtaPhiMLorentzVector & v )
00330 {
00331 mP4 = v;
00332 }
00333
00334
00335 void L1CaloCluster::addConstituent( const L1CaloTowerRef & tower )
00336 {
00337 mE += tower->E( );
00338 mE += tower->H( );
00339 mConstituents.push_back( tower );
00340 }
00341
00342 int L1CaloCluster::hasConstituent( const int &eta, const int &phi )
00343 {
00344 for ( unsigned int i = 0; i < mConstituents.size( ); ++i )
00345 {
00346 L1CaloTowerRef tower = mConstituents.at( i );
00347 if ( tower->iEta( ) == mIeta + eta && tower->iPhi( ) == mIphi + phi )
00348 {
00349 return i;
00350 }
00351 }
00352 return -1;
00353 }
00354
00355
00356 L1CaloTowerRef L1CaloCluster::getConstituent( const int &pos )
00357 {
00358 return mConstituents.at( pos );
00359 }
00360
00361
00362
00363 void L1CaloCluster::removeConstituent( const int &eta, const int &phi )
00364 {
00365
00366 int pos = hasConstituent( eta, phi );
00367
00368 if ( pos != -1 )
00369 {
00370 mE = mE - mConstituents.at( pos )->E( );
00371 mE = mE - mConstituents.at( pos )->H( );
00372 mConstituents.erase( mConstituents.begin( ) + pos );
00373 }
00374 }
00375
00376
00377
00378 const math::PtEtaPhiMLorentzVector & L1CaloCluster::p4( ) const
00379 {
00380 return mP4;
00381 }
00382
00383 }
00384
00385
00386 namespace std
00387 {
00388 bool operator<( const l1slhc::L1CaloCluster & aLeft, const l1slhc::L1CaloCluster & aRight )
00389 {
00390 if ( aLeft.E( ) == aRight.E( ) )
00391 {
00392
00393 return ( abs( aLeft.iEta( ) ) > abs( aRight.iEta( ) ) );
00394 }
00395 else
00396 {
00397 return ( aLeft.E( ) < aRight.E( ) );
00398 }
00399 }
00400 }
00401
00402
00403
00404 std::ostream & operator<<( std::ostream & aStream, const l1slhc::L1CaloCluster & aL1CaloCluster )
00405 {
00406 aStream << "L1CaloCluster"
00407 << " iEta=" << aL1CaloCluster.iEta( )
00408 << " iPhi=" << aL1CaloCluster.iPhi( )
00409 << " E=" << aL1CaloCluster.E( )
00410 << " eta=" << aL1CaloCluster.p4( ).eta( )
00411 << " phi=" << aL1CaloCluster.p4( ).phi( )
00412 << " pt=" << aL1CaloCluster.p4( ).pt( )
00413 << " egamma=" << aL1CaloCluster.eGammaValue( )
00414 << " central=" << aL1CaloCluster.isCentral( )
00415 << " fg=" << aL1CaloCluster.fg( )
00416 << "\n with constituents:\n";
00417 for ( l1slhc::L1CaloTowerRefVector::const_iterator i = aL1CaloCluster.getConstituents( ).begin( ); i != aL1CaloCluster.getConstituents( ).end( ); ++i )
00418 aStream << " iEta=" << ( **i ).iEta( )
00419 << " iPhi=" << ( **i ).iPhi( )
00420 << " ET=" << ( **i ).E( )
00421 << "\n";
00422 return aStream;
00423 }