ATLAS Offline Software
xAODChargedTracksWeightFilter.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef GENERATORFILTERS_XAODCHARGEDTRACKSWEIGHTFILTER_H
6 #define GENERATORFILTERS_XAODCHARGEDTRACKSWEIGHTFILTER_H
7 
9 #include "GaudiKernel/ServiceHandle.h"
11 
12 #include "xAODTruth/TruthEvent.h"
14 
15 namespace CLHEP {
16  class HepRandomEngine;
17 }
18 
21 public:
22 
23  xAODChargedTracksWeightFilter(const std::string& name, ISvcLocator* pSvcLocator);
27 
28  struct Spline {
30 
31  struct Point {
33  Point(double _x, double _y, double _slope) :
34  x(_x), y(_y), slope(_slope) {};
35 
36  double x;
37  double y;
38  double slope;
39  };
40 
42  std::vector<Point> points;
43 
44  StatusCode initialize( std::vector<double> & x, std::vector<double> & y);
45 
47  double get_minimum(double min, double max) const;
48 
50  double value(int nch) const;
51  };
52 
53 private:
54 
55  CLHEP::HepRandomEngine* getRandomEngine(const std::string& streamName,
56  const EventContext& ctx) const;
57 
59  double get_nch_weight(int nch) const;
60 
62  StatusCode event_weight(double & event_weight) const;
63 
65  void weight_event(double weight);
66 
68  ServiceHandle<IAthRNGSvc> m_rndmSvc{this, "RndmSvc", "AthRNGSvc"};
69 
70  // Minimum pT for a track to count
71  double m_Ptmin;
72 
73  // Maximum |pseudorapidity| for a track to count
74  double m_EtaRange;
75 
76  // Minimum number of tracks
77  int m_nchmin;
78 
79  // Maximum number of tracks
80  int m_nchmax;
81 
83 
85  std::vector<double> m_weight_fun_x;
86  std::vector<double> m_weight_fun_y;
87 
88  double m_min_weight = 0;
89 
91  double m_nevents_selected = 0;
93  double m_nevents_accepted = 0;
94 };
95 
96 #endif
xAODChargedTracksWeightFilter::Spline::initialize
StatusCode initialize(std::vector< double > &x, std::vector< double > &y)
Definition: xAODChargedTracksWeightFilter.cxx:261
max
#define max(a, b)
Definition: cfImp.cxx:41
xAODChargedTracksWeightFilter::m_min_weight
double m_min_weight
Definition: xAODChargedTracksWeightFilter.h:88
xAODChargedTracksWeightFilter::event_weight
StatusCode event_weight(double &event_weight) const
read the event weight
Definition: xAODChargedTracksWeightFilter.cxx:290
xAODChargedTracksWeightFilter::m_nchmin
int m_nchmin
Definition: xAODChargedTracksWeightFilter.h:77
xAODChargedTracksWeightFilter::m_weight_fun_x
std::vector< double > m_weight_fun_x
Spline points.
Definition: xAODChargedTracksWeightFilter.h:85
xAODChargedTracksWeightFilter::Spline::value
double value(int nch) const
get value for certain x
Definition: xAODChargedTracksWeightFilter.cxx:217
xAODChargedTracksWeightFilter::xAODChargedTracksWeightFilter
xAODChargedTracksWeightFilter(const std::string &name, ISvcLocator *pSvcLocator)
Definition: xAODChargedTracksWeightFilter.cxx:13
GenFilter.h
xAODChargedTracksWeightFilter::m_nevents_selected
double m_nevents_selected
Number of events passing selection (weighted, orig weight)
Definition: xAODChargedTracksWeightFilter.h:91
xAODChargedTracksWeightFilter::Spline::points
std::vector< Point > points
n-1 spline points filled at initialization
Definition: xAODChargedTracksWeightFilter.h:42
xAODChargedTracksWeightFilter::m_spline
Spline m_spline
Definition: xAODChargedTracksWeightFilter.h:82
xAODChargedTracksWeightFilter::m_nevents_accepted
double m_nevents_accepted
Number of events passing weight-filtering (weighted, origin weight)
Definition: xAODChargedTracksWeightFilter.h:93
xAODChargedTracksWeightFilter::Spline::Point::x
double x
Definition: xAODChargedTracksWeightFilter.h:34
xAODChargedTracksWeightFilter::Spline::Point
Linear spline representation of a function used to calculate weights.
Definition: xAODChargedTracksWeightFilter.h:31
x
#define x
xAODChargedTracksWeightFilter
Filter events based on presence of charged tracks.
Definition: xAODChargedTracksWeightFilter.h:20
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:200
xAODChargedTracksWeightFilter::m_Ptmin
double m_Ptmin
Definition: xAODChargedTracksWeightFilter.h:71
xAODChargedTracksWeightFilter::filterEvent
StatusCode filterEvent()
Definition: xAODChargedTracksWeightFilter.cxx:73
xAODChargedTracksWeightFilter::get_nch_weight
double get_nch_weight(int nch) const
get weight to filter and weight events
Definition: xAODChargedTracksWeightFilter.cxx:174
GenFilter
Base class for event generator filtering modules.
Definition: GenFilter.h:30
xAODChargedTracksWeightFilter::m_weight_fun_y
std::vector< double > m_weight_fun_y
Definition: xAODChargedTracksWeightFilter.h:86
xAODChargedTracksWeightFilter::filterInitialize
StatusCode filterInitialize()
Definition: xAODChargedTracksWeightFilter.cxx:24
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAODChargedTracksWeightFilter::weight_event
void weight_event(double weight)
modify the event weight by weight
Definition: xAODChargedTracksWeightFilter.cxx:185
CLHEP
STD'S.
Definition: IAtRndmGenSvc.h:19
xAODChargedTracksWeightFilter::m_nchmax
int m_nchmax
Definition: xAODChargedTracksWeightFilter.h:80
min
#define min(a, b)
Definition: cfImp.cxx:40
xAODChargedTracksWeightFilter::m_EtaRange
double m_EtaRange
Definition: xAODChargedTracksWeightFilter.h:74
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
xAODChargedTracksWeightFilter::Spline::get_minimum
double get_minimum(double min, double max) const
get minimum over certain range (requires initialization to extrapolate)
Definition: xAODChargedTracksWeightFilter.cxx:238
xAODChargedTracksWeightFilter::Spline
Definition: xAODChargedTracksWeightFilter.h:28
xAODChargedTracksWeightFilter::m_rndmSvc
ServiceHandle< IAthRNGSvc > m_rndmSvc
Rndm generator service.
Definition: xAODChargedTracksWeightFilter.h:68
xAODChargedTracksWeightFilter::Spline::Point::Point
Point(double _x, double _y, double _slope)
Single point and slope to next point.
Definition: xAODChargedTracksWeightFilter.h:33
AthenaPoolExample_Copy.streamName
string streamName
Definition: AthenaPoolExample_Copy.py:39
y
#define y
xAODChargedTracksWeightFilter::filterFinalize
StatusCode filterFinalize()
Definition: xAODChargedTracksWeightFilter.cxx:54
xAODChargedTracksWeightFilter::getRandomEngine
CLHEP::HepRandomEngine * getRandomEngine(const std::string &streamName, const EventContext &ctx) const
Definition: xAODChargedTracksWeightFilter.cxx:63
xAODChargedTracksWeightFilter::Spline::Point::y
double y
Definition: xAODChargedTracksWeightFilter.h:37
TruthEventContainer.h
TruthEvent.h
xAODChargedTracksWeightFilter::Spline::Point::slope
double slope
Definition: xAODChargedTracksWeightFilter.h:38
IAthRNGSvc.h
ServiceHandle< IAthRNGSvc >