ATLAS Offline Software
MomentumFilter.h
Go to the documentation of this file.
1 
3 /*
4  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 // MomentumFilter.h
8 // Header file for class MomentumFilter
9 // Author: S.Binet<binet@cern.ch>
11 #ifndef ANALYSISUTILS_MOMENTUMFILTER_H
12 #define ANALYSISUTILS_MOMENTUMFILTER_H
13 
20 #include <typeinfo>
21 
23 #include "GaudiKernel/MsgStream.h"
24 
25 #include "AnalysisUtils/IFilter.h"
28 
29 template <typename T>
30 class MomentumFilter : virtual public IFilter<T>
31 {
32 
34  // Public methods:
36  public:
37 
41 
45 
46  // Constructor with parameters:
47 
50  virtual ~MomentumFilter();
51 
55 
57  // Const methods:
59 
69  virtual bool isAccepted( const T * element ) const;
70 
73  double pxMin() const;
74 
77  double pxMax() const;
78 
81  double pyMin() const;
82 
85  double pyMax() const;
86 
89  double pzMin() const;
90 
93  double pzMax() const;
94 
97  double eneMin() const;
98 
101  double eneMax() const;
102 
105  double etaMin() const;
106 
109  double etaMax() const;
110 
113  double phiMin() const;
114 
117  double phiMax() const;
118 
121  double massMin() const;
122 
125  double massMax() const;
126 
129  double ptMin() const;
130 
133  double ptMax() const;
134 
138  double atlasPhi( const double phi ) const;
139 
141  // Non-const methods:
143 
148  void setFilter( const IFilterCuts * filter );
149 
152  void setPxMin( const double pxMin );
153 
156  void setPxMax( const double pxMax );
157 
160  void setPyMin( const double pyMin );
161 
164  void setPyMax( const double pyMax );
165 
168  void setPzMin( const double pzMin );
169 
172  void setPzMax( const double pzMax );
173 
176  void setEneMin( const double eneMin );
177 
180  void setEneMax( const double eneMax );
181 
184  void setEtaMin( const double etaMin );
185 
188  void setEtaMax( const double etaMax );
189 
192  void setPhiMin( const double phiMin );
193 
196  void setPhiMax( const double phiMax );
197 
200  void setMassMin( const double massMin );
201 
204  void setMassMax( const double massMax );
205 
208  void setPtMin( const double ptMin );
209 
212  void setPtMax( const double ptMax );
213 
216  void setRange( const std::string& name,
217  const double min, const double max );
218 
220  // Protected method:
222  protected:
223 
225  // Protected data:
227  protected:
228 
232 
236 
240 
244 
248 
252 
256 
260 
261  private :
262 
263 };
264 
265 // I/O operators
267 //MsgStream& operator<<( MsgStream & msg, const MomentumFilter &obj );
268 
270 // Inline methods:
272 
273 template<typename T>
275  IFilterCuts(),
276  IFilter<T>(),
277  m_pxRange(),
278  m_pyRange(),
279  m_pzRange(),
280  m_eneRange(),
281  m_etaRange(),
282  m_phiRange(),
283  m_massRange(),
284  m_ptRange()
285 {}
286 
287 template<typename T>
289  IFilterCuts(rhs),
290  IFilter<T>( rhs ),
291  m_pxRange( rhs.m_pxRange ),
292  m_pyRange( rhs.m_pyRange ),
293  m_pzRange( rhs.m_pzRange ),
294  m_eneRange(rhs.m_eneRange ),
295  m_etaRange(rhs.m_etaRange ),
296  m_phiRange(rhs.m_phiRange ),
297  m_massRange(rhs.m_massRange ),
298  m_ptRange( rhs.m_ptRange )
299 {}
300 
301 template<typename T>
303 
304 template<typename T>
305 inline
307 {
308  if ( this != &rhs ) {
311  m_pxRange = rhs.m_pxRange;
312  m_pyRange = rhs.m_pyRange;
313  m_pzRange = rhs.m_pzRange;
314  m_eneRange = rhs.m_eneRange;
315  m_etaRange = rhs.m_etaRange;
316  m_phiRange = rhs.m_phiRange;
317  m_massRange = rhs.m_massRange;
318  m_ptRange = rhs.m_ptRange;
319  }
320  return *this;
321 }
322 
324 // Const methods:
326 
327 template<typename T>
328 bool MomentumFilter<T>::isAccepted( const T * element ) const
329 {
330  bool isAccepted = true;
331 
332  if ( m_pxRange.isActive() ) {
333  isAccepted = isAccepted && m_pxRange.isInRange ( element->px() );
334  }
335  if ( m_pyRange.isActive() ) {
336  isAccepted = isAccepted && m_pyRange.isInRange ( element->py() );
337  }
338  if ( m_pzRange.isActive() ) {
339  isAccepted = isAccepted && m_pzRange.isInRange ( element->pz() );
340  }
341  if ( m_eneRange.isActive() ) {
342  isAccepted = isAccepted && m_eneRange.isInRange ( element->e() );
343  }
344  if ( m_etaRange.isActive() ) {
345  isAccepted = isAccepted && m_etaRange.isInRange ( element->eta() );
346  }
347  if ( m_phiRange.isActive() ) {
348  isAccepted = isAccepted && m_phiRange.isInRange( element->phi() );
349  }
350  if ( m_massRange.isActive() ) {
351  isAccepted = isAccepted && m_massRange.isInRange( element->m() );
352  }
353  if ( m_ptRange.isActive() ) {
354  isAccepted = isAccepted && m_ptRange.isInRange ( element->pt() );
355  }
356 
357  return isAccepted;
358 }
359 
360 template<typename T>
361 inline double MomentumFilter<T>::pxMin() const
362 {
363  return m_pxRange.lower();
364 }
365 
366 template<typename T>
367 inline double MomentumFilter<T>::pxMax() const
368 {
369  return m_pxRange.upper();
370 }
371 
372 template<typename T>
373 inline double MomentumFilter<T>::pyMin() const
374 {
375  return m_pyRange.lower();
376 }
377 
378 template<typename T>
379 inline double MomentumFilter<T>::pyMax() const
380 {
381  return m_pyRange.upper();
382 }
383 
384 template<typename T>
385 inline double MomentumFilter<T>::pzMin() const
386 {
387  return m_pzRange.lower();
388 }
389 
390 template<typename T>
391 inline double MomentumFilter<T>::pzMax() const
392 {
393  return m_pzRange.upper();
394 }
395 
396 template<typename T>
397 inline double MomentumFilter<T>::eneMin() const
398 {
399  return m_eneRange.lower();
400 }
401 
402 template<typename T>
403 inline double MomentumFilter<T>::eneMax() const
404 {
405  return m_eneRange.upper();
406 }
407 
408 template<typename T>
409 inline double MomentumFilter<T>::etaMin() const
410 {
411  return m_etaRange.lower();
412 }
413 
414 template<typename T>
415 inline double MomentumFilter<T>::etaMax() const
416 {
417  return m_etaRange.upper();
418 }
419 
420 template<typename T>
421 inline double MomentumFilter<T>::phiMin() const
422 {
423  return m_phiRange.lower();
424 }
425 
426 template<typename T>
427 inline double MomentumFilter<T>::phiMax() const
428 {
429  return m_phiRange.upper();
430 }
431 
432 template<typename T>
433 inline double MomentumFilter<T>::massMin() const
434 {
435  return m_massRange.lower();
436 }
437 
438 template<typename T>
439 inline double MomentumFilter<T>::massMax() const
440 {
441  return m_massRange.upper();
442 }
443 
444 template<typename T>
445 inline double MomentumFilter<T>::ptMin() const
446 {
447  return m_ptRange.lower();
448 }
449 
450 template<typename T>
451 inline double MomentumFilter<T>::ptMax() const
452 {
453  return m_ptRange.upper();
454 }
455 
456 template<typename T>
457 inline double MomentumFilter<T>::atlasPhi( const double phi ) const
458 {
459  return m_phiRange.atlasPhi( phi );
460 }
461 
463 // Non-const methods:
465 template<typename T>
467 {
468  if ( filter ) {
469  try {
470  const MomentumFilter<T> * momFilter =
471  dynamic_cast<const MomentumFilter<T> *>(filter);
472 
473  if ( momFilter ) {
474  operator=(*momFilter);
475  } else {
476  MsgStream log( Athena::getMessageSvc(), "MomentumFilter" );
477  log << MSG::ERROR
478  << "Can't dynamic_cast " << typeid(filter).name()
479  << " to a MomentumFilter"
480  << endmsg;
481  }
482  } catch (...) {
483  MsgStream log( Athena::getMessageSvc(), "MomentumFilter" );
484  log << MSG::ERROR
485  << "Can't dynamic_cast " << filter << " to a MomentumFilter"
486  << endmsg;
487  }
488  } //> filter is a valid pointer
489 }
490 
491 template<typename T>
492 inline void MomentumFilter<T>::setPxMin( const double pxMin )
493 {
494  m_pxRange.setMin(pxMin);
495 }
496 
497 template<typename T>
498 inline void MomentumFilter<T>::setPxMax( const double pxMax )
499 {
500  m_pxRange.setMax(pxMax);
501 }
502 
503 template<typename T>
504 inline void MomentumFilter<T>::setPyMin( const double pyMin )
505 {
506  m_pyRange.setMin(pyMin);
507 }
508 
509 template<typename T>
510 inline void MomentumFilter<T>::setPyMax( const double pyMax )
511 {
512  m_pyRange.setMax(pyMax);
513 }
514 
515 template<typename T>
516 inline void MomentumFilter<T>::setPzMin( const double pzMin )
517 {
518  m_pzRange.setMin(pzMin);
519 }
520 
521 template<typename T>
522 inline void MomentumFilter<T>::setPzMax( const double pzMax )
523 {
524  m_pzRange.setMax(pzMax);
525 }
526 
527 template<typename T>
528 inline void MomentumFilter<T>::setEneMin( const double eneMin )
529 {
530  m_eneRange.setMin(eneMin);
531 }
532 
533 template<typename T>
534 inline void MomentumFilter<T>::setEneMax( const double eneMax )
535 {
536  m_eneRange.setMax(eneMax);
537 }
538 
539 template<typename T>
540 inline void MomentumFilter<T>::setEtaMin( const double etaMin )
541 {
542  m_etaRange.setMin(etaMin);
543 }
544 
545 template<typename T>
546 inline void MomentumFilter<T>::setEtaMax( const double etaMax )
547 {
548  m_etaRange.setMax(etaMax);
549 }
550 
551 template<typename T>
552 inline void MomentumFilter<T>::setPhiMin( const double phiMin )
553 {
555  m_phiRange.setMin(phiMin);
556 }
557 
558 template<typename T>
559 inline void MomentumFilter<T>::setPhiMax( const double phiMax )
560 {
562  m_phiRange.setMax(phiMax);
563 }
564 
565 template<typename T>
566 inline void MomentumFilter<T>::setMassMin( const double massMin )
567 {
568  m_massRange.setMin(massMin);
569 }
570 
571 template<typename T>
572 inline void MomentumFilter<T>::setMassMax( const double massMax )
573 {
574  m_massRange.setMax(massMax);
575 }
576 
577 template<typename T>
578 inline void MomentumFilter<T>::setPtMin( const double ptMin )
579 {
580  m_ptRange.setMin(ptMin);
581 }
582 
583 template<typename T>
584 inline void MomentumFilter<T>::setPtMax( const double ptMax )
585 {
586  m_ptRange.setMax(ptMax);
587 }
588 
589 template<typename T>
590 void MomentumFilter<T>::setRange( const std::string& name,
591  const double min, const double max )
592 {
593  if ( name == "px" ) { m_pxRange .setRange( min, max );
594  } else if ( name == "py" ) { m_pyRange .setRange( min, max );
595  } else if ( name == "pz" ) { m_pzRange .setRange( min, max );
596  } else if ( name == "ene" ) { m_eneRange .setRange( min, max );
597  } else if ( name == "eta" ) { m_etaRange .setRange( min, max );
598  } else if ( name == "phi" ) { m_phiRange .setRange( min, max );
599  } else if ( name == "mass" ) { m_massRange .setRange( min, max );
600  } else if ( name == "pt" ) { m_ptRange .setRange( min, max );
601  } else {
602  const std::string error = "Range of name <"+name+"> is UNKNOWN !!";
603  throw std::invalid_argument(error);
604  }
605 
606  return;
607 }
608 
609 #endif //> ANALYSISUTILS_MOMENTUMFILTER_H
MomentumFilter::MomentumFilter
MomentumFilter()
Default constructor:
Definition: MomentumFilter.h:274
MomentumFilter::m_pyRange
FilterRange m_pyRange
The range in py required by the filter.
Definition: MomentumFilter.h:235
MomentumFilter::massMax
double massMax() const
Returns the maximum mass required by the filter.
Definition: MomentumFilter.h:439
MomentumFilter::setMassMax
void setMassMax(const double massMax)
Sets the maximum mass required by the filter.
Definition: MomentumFilter.h:572
max
#define max(a, b)
Definition: cfImp.cxx:41
MomentumFilter::pxMax
double pxMax() const
Returns the maximum px required by the filter.
Definition: MomentumFilter.h:367
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
getMessageSvc.h
singleton-like access to IMessageSvc via open function and helper
MomentumFilter::setPhiMin
void setPhiMin(const double phiMin)
Sets the minimum phi required by the filter.
Definition: MomentumFilter.h:552
MomentumFilter::setPxMax
void setPxMax(const double pxMax)
Sets the maximum px required by the filter.
Definition: MomentumFilter.h:498
MomentumFilter::operator=
MomentumFilter< T > & operator=(const MomentumFilter< T > &rhs)
Assignment operator:
Definition: MomentumFilter.h:306
MomentumFilter::ptMax
double ptMax() const
Returns the maximum pt required by the filter.
Definition: MomentumFilter.h:451
MomentumFilter::m_massRange
FilterRange m_massRange
The range in mass required by the filter.
Definition: MomentumFilter.h:255
MomentumFilter::etaMin
double etaMin() const
Returns the minimum eta required by the filter.
Definition: MomentumFilter.h:409
MomentumFilter::setEtaMin
void setEtaMin(const double etaMin)
Sets the minimum eta required by the filter.
Definition: MomentumFilter.h:540
FilterRange
FilterRange implements the range (ie: [min, max]) the filters will use to take their filtering decisi...
Definition: FilterRange.h:35
MomentumFilter::pyMax
double pyMax() const
Returns the maximum py required by the filter.
Definition: MomentumFilter.h:379
IFilter
IFilter is the main interface to the filters.
Definition: IFilter.h:31
xAOD::etaMax
etaMax
Definition: HIEventShape_v2.cxx:46
PhiFilterRange
PhiFilterRange implements the range (ie: [min, max]) the filters will use to take their filtering dec...
Definition: PhiFilterRange.h:30
MomentumFilter::phiMin
double phiMin() const
Returns the minimum phi required by the filter.
Definition: MomentumFilter.h:421
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
IFilter::operator=
IFilter< T > & operator=(const IFilter< T > &rhs)
Assignment operator:
Definition: IFilter.h:91
MomentumFilter::setPyMax
void setPyMax(const double pyMax)
Sets the maximum py required by the filter.
Definition: MomentumFilter.h:510
covarianceTool.filter
filter
Definition: covarianceTool.py:514
MomentumFilter
MomentumFilter can filter objects upon their four-momentum properties.
Definition: MomentumFilter.h:31
MomentumFilter::setPhiMax
void setPhiMax(const double phiMax)
Sets the maximum phi required by the filter.
Definition: MomentumFilter.h:559
MomentumFilter::setEneMax
void setEneMax(const double eneMax)
Sets the maximum energy required by the filter.
Definition: MomentumFilter.h:534
MomentumFilter::setEneMin
void setEneMin(const double eneMin)
Sets the minimum energy required by the filter.
Definition: MomentumFilter.h:528
MomentumFilter::atlasPhi
double atlasPhi(const double phi) const
Convert a phi angle in the ATLAS conventional range -PI->PI inspired from FourMom package (could also...
Definition: MomentumFilter.h:457
FilterRange.h
MomentumFilter::m_phiRange
PhiFilterRange m_phiRange
The range in phi required by the filter.
Definition: MomentumFilter.h:251
MomentumFilter::m_ptRange
FilterRange m_ptRange
The range in pt required by the filter.
Definition: MomentumFilter.h:259
InDetSecVtxTruthMatchUtils::isAccepted
bool isAccepted(int matchInfo)
Definition: InDetSecVtxTruthMatchTool.h:73
MomentumFilter::setPtMin
void setPtMin(const double ptMin)
Sets the minimum pt required by the filter.
Definition: MomentumFilter.h:578
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
MomentumFilter::m_pxRange
FilterRange m_pxRange
The range in px required by the filter.
Definition: MomentumFilter.h:231
MomentumFilter::pzMin
double pzMin() const
Returns the minimum pz required by the filter.
Definition: MomentumFilter.h:385
MomentumFilter::setPyMin
void setPyMin(const double pyMin)
Sets the minimum py required by the filter.
Definition: MomentumFilter.h:504
MomentumFilter::setFilter
void setFilter(const IFilterCuts *filter)
Copies the IFilterCuts properties of the given object to the current IFilterCuts object (ie: it copie...
Definition: MomentumFilter.h:466
MomentumFilter::m_pzRange
FilterRange m_pzRange
The range in pz required by the filter.
Definition: MomentumFilter.h:239
MomentumFilter::isAccepted
virtual bool isAccepted(const T *element) const
Main filter method.
Definition: MomentumFilter.h:328
MomentumFilter::setPxMin
void setPxMin(const double pxMin)
Sets the minimum px required by the filter.
Definition: MomentumFilter.h:492
min
#define min(a, b)
Definition: cfImp.cxx:40
MomentumFilter::eneMax
double eneMax() const
Returns the maximum energy required by the filter.
Definition: MomentumFilter.h:403
private
#define private
Definition: DetDescrConditionsDict_dict_fixes.cxx:13
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
PhiFilterRange.h
MomentumFilter::setPzMax
void setPzMax(const double pzMax)
Sets the maximum pz required by the filter.
Definition: MomentumFilter.h:522
MomentumFilter::phiMax
double phiMax() const
Returns the maximum phi required by the filter.
Definition: MomentumFilter.h:427
MomentumFilter::massMin
double massMin() const
Returns the minimum mass required by the filter.
Definition: MomentumFilter.h:433
LArCellBinning.etaMin
etaMin
Definition: LArCellBinning.py:84
MomentumFilter::m_etaRange
FilterRange m_etaRange
The range in eta required by the filter.
Definition: MomentumFilter.h:247
MomentumFilter::etaMax
double etaMax() const
Returns the maximum eta required by the filter.
Definition: MomentumFilter.h:415
MomentumFilter::setRange
void setRange(const std::string &name, const double min, const double max)
Set range for a given momentum component (by name)
Definition: MomentumFilter.h:590
PhysDESDM_SmpCaloId.ptMin
ptMin
Definition: PhysDESDM_SmpCaloId.py:90
MomentumFilter::m_eneRange
FilterRange m_eneRange
The range in energy required by the filter.
Definition: MomentumFilter.h:243
MomentumFilter::setPtMax
void setPtMax(const double ptMax)
Sets the maximum pt required by the filter.
Definition: MomentumFilter.h:584
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
MomentumFilter::ptMin
double ptMin() const
Returns the minimum pt required by the filter.
Definition: MomentumFilter.h:445
IFilterCuts::operator=
IFilterCuts & operator=(const IFilterCuts &rhs)
Assignment operator:
Definition: IFilterCuts.h:78
MomentumFilter::~MomentumFilter
virtual ~MomentumFilter()
Destructor:
Definition: MomentumFilter.h:302
MomentumFilter::setEtaMax
void setEtaMax(const double etaMax)
Sets the maximum eta required by the filter.
Definition: MomentumFilter.h:546
IFilterCuts
IFilterCuts is a class which is used internally by the filters to copy their cut properties one to ...
Definition: IFilterCuts.h:21
MomentumFilter::pzMax
double pzMax() const
Returns the maximum pz required by the filter.
Definition: MomentumFilter.h:391
IFilter.h
MomentumFilter::setPzMin
void setPzMin(const double pzMin)
Sets the minimum pz required by the filter.
Definition: MomentumFilter.h:516
MomentumFilter::setMassMin
void setMassMin(const double massMin)
Sets the minimum mass required by the filter.
Definition: MomentumFilter.h:566
error
Definition: IImpactPoint3dEstimator.h:70
MomentumFilter::pxMin
double pxMin() const
Returns the minimum px required by the filter.
Definition: MomentumFilter.h:361
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
MomentumFilter::pyMin
double pyMin() const
Returns the minimum py required by the filter.
Definition: MomentumFilter.h:373
MomentumFilter::eneMin
double eneMin() const
Returns the minimum energy required by the filter.
Definition: MomentumFilter.h:397