00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef ___Atlfast_functionobjects__
00036 #define ___Atlfast_functionobjects__
00037
00038 #include "AtlfastCode/IKinematic.h"
00039 #include <cmath>
00040 #include <cstdlib>
00041 #include "AtlfastCode/Phi.h"
00042
00043
00044
00045
00046
00047
00048
00049 namespace CellSortCondition {
00050
00051
00056 class AscendingPhi {
00057 public:
00058 bool operator()
00059 ( const Atlfast::ICellWrapper* a, const Atlfast::ICellWrapper* b ) const {
00060 return( a->phi() < b->phi() ) ; }
00061
00062 bool operator()
00063 ( const Atlfast::ICellWrapper& a, const Atlfast::ICellWrapper& b ) const
00064 { return this->operator() ( &a, &b ) ; }
00065 };
00070 class DescendingPhi {
00071 public:
00072 bool operator()
00073 ( const Atlfast::ICellWrapper* a, const Atlfast::ICellWrapper* b ) const
00074 { return( a->phi() > b->phi() ) ; }
00075 bool operator()
00076 ( const Atlfast::ICellWrapper& a, const Atlfast::ICellWrapper& b ) const
00077 { return( a.phi() > b.phi() ) ; }
00078 };
00079
00080
00081
00086 class AscendingEta {
00087 public:
00088 bool operator()
00089 ( const Atlfast::ICellWrapper* a, const Atlfast::ICellWrapper* b ) const
00090 { return( a->eta() < b->eta() ) ; }
00091 bool operator()
00092 ( const Atlfast::ICellWrapper& a, const Atlfast::ICellWrapper& b ) const
00093 { return( a.eta() < b.eta() ) ; }
00094 };
00099 class DescendingEta {
00100 public:
00101 bool operator()
00102 ( const Atlfast::ICellWrapper* a, const Atlfast::ICellWrapper* b ) const
00103 { return( a->eta() > b->eta() ) ; }
00104 bool operator()
00105 ( const Atlfast::ICellWrapper& a, const Atlfast::ICellWrapper& b ) const
00106 { return( a.eta() > b.eta() ) ; }
00107 };
00108
00109
00110
00111
00116 class AscendingPT {
00117 public:
00118 bool operator()
00119 ( const Atlfast::ICellWrapper* a, const Atlfast::ICellWrapper* b ) const
00120 { return( a->pT() < b->pT() ) ; }
00121 bool operator()
00122 ( const Atlfast::ICellWrapper& a, const Atlfast::ICellWrapper& b ) const
00123 { return( a.pT() < b.pT() ) ; }
00124 };
00129 class DescendingPT {
00130 public:
00131 bool operator()
00132 ( const Atlfast::ICellWrapper* a, const Atlfast::ICellWrapper* b ) const
00133 { return( a->pT() > b->pT() ) ; }
00134 bool operator()
00135 ( const Atlfast::ICellWrapper& a, const Atlfast::ICellWrapper& b ) const
00136 { return( a.pT() > b.pT() ) ; }
00137 };
00138
00143 class DeltaPhi {
00144
00145 private:
00146 Atlfast::ICellWrapper* ref ;
00147
00148 public:
00149
00150
00151 DeltaPhi( Atlfast::ICellWrapper* reference ) : ref(reference) {}
00152 DeltaPhi( Atlfast::ICellWrapper& reference ) : ref(&reference) {}
00153
00154
00155 bool operator()
00156 ( const Atlfast::ICellWrapper* a, const Atlfast::ICellWrapper* b ) const
00157 {
00158 Phi a_dPhi( a->phi() - ref->phi() ) ;
00159 Phi b_dPhi( b->phi() - ref->phi() ) ;
00160
00161 return ( abs(a_dPhi) < abs(b_dPhi) ) ;
00162 }
00163
00164
00165 bool operator()
00166 ( const Atlfast::ICellWrapper& a, const Atlfast::ICellWrapper& b ) const
00167 { return this->operator() ( &a, &b ) ; }
00168
00169 };
00170
00171
00176 class DeltaEta {
00177
00178 private:
00179 Atlfast::ICellWrapper* ref ;
00180
00181 public:
00182
00183
00184 DeltaEta( Atlfast::ICellWrapper* reference ) : ref(reference) {}
00185 DeltaEta( Atlfast::ICellWrapper& reference ) : ref(&reference) {}
00186
00187
00188 bool operator()
00189 ( const Atlfast::ICellWrapper* a, const Atlfast::ICellWrapper* b ) const {
00190 return(
00191 abs(a->eta() - ref->eta())
00192 <
00193 abs(b->eta() - ref->eta())
00194 );
00195 }
00196
00197
00198 bool operator()
00199 ( const Atlfast::ICellWrapper& a, const Atlfast::ICellWrapper& b ) const
00200 { return this->operator() ( &a, &b ) ; }
00201
00202 };
00203
00204
00205
00210 class DeltaR {
00211
00212 private:
00213 Atlfast::ICellWrapper* ref ;
00214
00215 public:
00216
00217
00218 DeltaR( Atlfast::ICellWrapper* reference ) : ref(reference) {}
00219 DeltaR( Atlfast::ICellWrapper& reference ) : ref(&reference) {}
00220
00221
00222 bool operator()
00223 ( const Atlfast::ICellWrapper* a, const Atlfast::ICellWrapper* b ) const {
00224
00225 Phi a_dPhi( a->phi() - ref->phi() ) ;
00226 Phi b_dPhi( b->phi() - ref->phi() ) ;
00227
00228 double dista =
00229 sqrt(
00230 (a_dPhi*a_dPhi) +
00231 (a->eta() - ref->eta())*(a->eta() - ref->eta())
00232 );
00233
00234 double distb =
00235 sqrt(
00236 (b_dPhi*b_dPhi) +
00237 (b->eta() - ref->eta())*(b->eta() - ref->eta())
00238 );
00239
00240 return ( dista < distb ) ;
00241 }
00242
00243
00244
00245 bool operator()
00246 ( const Atlfast::ICellWrapper& a, const Atlfast::ICellWrapper& b ) const
00247 { return this->operator() ( &a, &b ) ; }
00248
00249 };
00250
00251
00252
00253 }
00254
00255
00256
00257
00258
00259
00260
00261 namespace CellPartitionCondition {
00262
00263
00264
00265
00270 class AboveThresholdPT {
00271
00272 public:
00273
00274 AboveThresholdPT( double boundary ) : m_boundary(boundary) {}
00275
00276 bool operator() ( const Atlfast::ICellWrapper* a ) const
00277 { return (m_boundary < a->pT()) ; }
00278 bool operator() ( const Atlfast::ICellWrapper& a ) const
00279 { return (m_boundary < a.pT()) ; }
00280
00281 private:
00282 double m_boundary ;
00283
00284 };
00289 class BelowThresholdpT {
00290
00291 public:
00292
00293 BelowThresholdpT( double boundary ) : m_boundary(boundary) {}
00294
00295 bool operator() ( const Atlfast::ICellWrapper* a ) const
00296 { return (m_boundary > a->pT()) ; }
00297 bool operator() ( const Atlfast::ICellWrapper& a ) const
00298 { return (m_boundary > a.pT()) ; }
00299
00300 private:
00301 double m_boundary ;
00302
00303 };
00304
00305
00306
00311 class BelowThresholdDeltaR {
00312
00313 public:
00319 BelowThresholdDeltaR( Atlfast::ICellWrapper* ref, double boundary )
00320 : m_boundary(boundary), m_ref(ref) {}
00326 BelowThresholdDeltaR( Atlfast::ICellWrapper& ref, double boundary )
00327 : m_boundary(boundary), m_ref(&ref) {}
00329 bool operator() ( const Atlfast::ICellWrapper* a ) const
00330 {
00331 Phi dphi( a->phi() - m_ref->phi() ) ;
00332
00333 double dist =
00334 sqrt(
00335 (dphi*dphi) +
00336 (a->eta() - m_ref->eta())*(a->eta() - m_ref->eta())
00337 );
00338
00339 return (dist < m_boundary) ;
00340
00341 }
00342
00343 bool operator()
00344 ( const Atlfast::ICellWrapper& a ) const
00345 { return this->operator()( &a ) ; }
00346
00347 private:
00348 double m_boundary ;
00349 Atlfast::ICellWrapper* m_ref ;
00350
00351 };
00352
00353
00354
00359 class BelowThresholdDeltaPT {
00360
00361 public:
00367 BelowThresholdDeltaPT( Atlfast::ICellWrapper* ref, double boundary )
00368 : m_boundary(boundary), m_ref(ref) {}
00369
00374 BelowThresholdDeltaPT( Atlfast::ICellWrapper& ref, double boundary )
00375 : m_boundary(boundary), m_ref(&ref) {}
00377 bool operator() ( const Atlfast::ICellWrapper* a ) const
00378 {
00379 return ( abs( a->pT() - m_ref->pT() ) < m_boundary) ;
00380 }
00382 bool operator()
00383 ( const Atlfast::ICellWrapper& a ) const
00384 { return this->operator()( &a ) ; }
00386 bool operator()
00387 ( const Atlfast::ICellWrapper** a ) const
00388 { return this->operator()( *a ) ; }
00389
00390 private:
00392 double m_boundary ;
00394 Atlfast::ICellWrapper* m_ref ;
00395
00396 };
00397
00398
00399
00405 class CellValidation {
00406
00407 public:
00412 CellValidation( Atlfast::ICellWrapper* ref,
00413 double maxEtaDiff,
00414 double maxPhiDiff,
00415 double maxPtDiff ) :
00416 m_ref(ref),
00417 m_maxEtaDiff(maxEtaDiff),
00418 m_maxPhiDiff(maxPhiDiff),
00419 m_maxPtDiff(maxPtDiff) {}
00420
00425 CellValidation( Atlfast::ICellWrapper& ref,
00426 double maxEtaDiff,
00427 double maxPhiDiff,
00428 double maxPtDiff ) :
00429 m_ref(&ref),
00430 m_maxEtaDiff(maxEtaDiff),
00431 m_maxPhiDiff(maxPhiDiff),
00432 m_maxPtDiff(maxPtDiff) {}
00434 bool operator() ( const Atlfast::ICellWrapper* a ) const
00435 {
00436 double delphi = abs( (Phi(a->phi()) - Phi(m_ref->phi())) );
00437 double deleta = abs( ( a->eta() - m_ref->eta()) );
00438 double delpt = abs( a->pT() - m_ref->pT() );
00439
00440 return (
00441 delphi< m_maxPhiDiff &&
00442 deleta< m_maxEtaDiff &&
00443 delpt < m_maxPtDiff
00444 );
00445 }
00447 bool operator()
00448 ( const Atlfast::ICellWrapper& a ) const
00449 { return this->operator()( &a ) ; }
00451 bool operator()
00452 ( const Atlfast::ICellWrapper** a ) const
00453 { return this->operator()( *a ) ; }
00454
00455 private:
00457 Atlfast::ICellWrapper* m_ref ;
00459 double m_maxEtaDiff;
00461 double m_maxPhiDiff;
00463 double m_maxPtDiff;
00464 };
00465
00471 class MatchParticle {
00472
00473 public:
00479 MatchParticle( Atlfast::ICellWrapper* ref,
00480 double maxEtaDiff,
00481 double maxPhiDiff,
00482 double maxPtDiff ) :
00483 m_ref(ref),
00484 m_maxEtaDiff(maxEtaDiff),
00485 m_maxPhiDiff(maxPhiDiff),
00486 m_maxPtDiff(maxPtDiff) {}
00487
00493 MatchParticle( Atlfast::ICellWrapper& ref,
00494 double maxEtaDiff,
00495 double maxPhiDiff,
00496 double maxPtDiff ) :
00497 m_ref(&ref),
00498 m_maxEtaDiff(maxEtaDiff),
00499 m_maxPhiDiff(maxPhiDiff),
00500 m_maxPtDiff(maxPtDiff) {}
00502 bool operator() ( const Atlfast::ICellWrapper* a ) const
00503 {
00504 std::vector<const HepMC::GenParticle*> p=a->particles();
00505 std::vector<const HepMC::GenParticle*>::const_iterator ip=p.begin();
00506 for(;ip!=p.end();++ip){
00507
00508 double delphi = abs( Phi((*ip)->momentum().phi()) - Phi( m_ref->phi() ) );
00509 double deleta = abs( (*ip)->momentum().pseudoRapidity() - m_ref->eta() );
00510 double delpt = abs( (*ip)->momentum().perp() - m_ref->pT() );
00511 if(
00512 delphi< m_maxPhiDiff &&
00513 deleta< m_maxEtaDiff &&
00514 delpt < m_maxPtDiff
00515 ) return true;
00516 }
00517 return false;
00518 }
00520 bool operator()
00521 ( const Atlfast::ICellWrapper& a ) const
00522 { return this->operator()( &a ) ; }
00524 bool operator()
00525 ( const Atlfast::ICellWrapper** a ) const
00526 { return this->operator()( *a ) ; }
00527
00528 private:
00530 Atlfast::ICellWrapper* m_ref ;
00532 double m_maxEtaDiff;
00534 double m_maxPhiDiff;
00536 double m_maxPtDiff;
00537 };
00538
00543 class AddModPt{
00544 public:
00545 double operator()( double a,
00546 Atlfast::ICellWrapper* b){
00547 double result = (a + abs( b->pT() ) );
00548 return result;
00549 }
00550
00551 };
00552 }
00553
00554
00555
00556
00557 #endif
00558
00559
00560
00561
00562