HackAnalysis  2
DV.hpp
1 
2 
3 #ifndef DV_h
4 #define DV_h
5 #include "include/BaseAnalysis.h"
6 #include "include/isolation.h"
7 #include "include/HEPData.h"
8 
9 using namespace std;
10 
11 #ifndef MAdouble64
12 #define MAdouble64 double
13 #endif
14 
15 //bool found_ee;
16 //bool found_emu;
17 //bool found_mumu;
18 const static bool USE_REWEIGHT=false;
19 static std::uniform_real_distribution<double> rd(0.0,1.0);
20 
21 inline bool mycomp(const HEP::Particle* p1, const HEP::Particle* p2)
22  {
23  return (p1->pT() > p2->pT()); // to sort with highest pt first
24  };
25 
27  {
28  private:
29  HEP::P4 position;
30 
31  public:
32  std::vector <const HEP::Particle *> particles;
33 
34  bool single_photon_trigger = false;
35  bool di_photon_trigger = false;
36  bool muon_trigger = false;
37  double weight_multiplier;
38 
39 
40  void sort_reverse_pt()
41  {
42  std::sort(particles.begin(),particles.end(),mycomp);
43  }
44 
45  HEP::P4 get_momentum () {
46  HEP::P4 p_tot (0.,0.,0.,0.);
47  for (int i=0; i<particles.size(); i++)
48  p_tot += particles[i]->mom();
49  return p_tot;
50  }
51 
52  double get_invariant_mass () {
53  return get_momentum().m();
54  };
55 
56  double get_pt () {
57  return get_momentum().pT();
58  };
59 
60  HEP::P4 get_position () const { return position; };
61 
62  void set_particle (const HEP::Particle * part) {
63  if (particles.size() > 0)
64  particles.clear();
65  add_particle(part);
66  }
67  void add_particle (const HEP::Particle * part) {
68  particles.push_back(part);
69  }
70 
71  double d_xy () {
72  //double dxy = sqrt(get_position().px2() + get_position().py2());
73  double dxy=position.pT();
74  return dxy;
75  }
76 
77  int Nelectrons () {
78  int Nelectrons = 0;
79  for (int i=0; i<particles.size(); i++) {
80  //if(dynamic_cast<const RecLeptonFormat *>(particles[i]) != 0)
81  if(abs(particles[i]->pid()) == 11) Nelectrons++;
82  }
83  return Nelectrons;
84  }
85 
86  int N_leptons () {
87  int Nleptons = 0;
88  for (int i=0; i<particles.size(); i++) {
89  //if(dynamic_cast<const RecLeptonFormat *>(particles[i]) != 0)
90  if(PDG::isLepton(particles[i]->pid())) Nleptons++;
91  }
92  return Nleptons;
93  }
94 
95  dv_candidate (const HEP::Particle * part) {
96  particles.push_back(part);
97  //int tpid=part->pid();
98  position = part->prod_vertex();
99  //if(PDG::isLepton(tpid) || (tpid==22)) position = part->prod_vertex();
100 
101 
102  // if (dynamic_cast<const RecLeptonFormat *>(part) != 0) {
103  // position = dynamic_cast<const RecLeptonFormat *>(part)->ProductionVertex();
104  // }
105  // else if (dynamic_cast<const RecPhotonFormat *>(part) != 0) {
106  // position = dynamic_cast<const RecPhotonFormat *>(part)->ProductionVertex();
107  // }
108  }
109 
110  dv_candidate()
111  {
112  weight_multiplier=1.0;
113  position=HEP::P4();
114  particles.clear();
115  }
116 
117 
118 };
119 
120 
121 
122 void update_vertex_types(vector<dv_candidate> & dv_candidates, bool & found_ee, bool & found_emu, bool & found_mumu);
123 
124 MAdouble64 DVRecoEfficiencyZPrime100GeVToEE (MAdouble64 r_xy, MAdouble64 pT) ;
125 
126 MAdouble64 DVRecoEfficiencyZPrime100GeVToEMU (MAdouble64 r_xy, MAdouble64 pT);
127 
128 MAdouble64 DVRecoEfficiencyZPrime100GeVToEMU (MAdouble64 r_xy, MAdouble64 pT);
129 
130 MAdouble64 DVRecoEfficiencyZPrime100GeVToMUMU (MAdouble64 r_xy, MAdouble64 pT);
131 
132 MAdouble64 DVRecoEfficiencyZPrime250GeVToEE (MAdouble64 r_xy, MAdouble64 pT);
133 
134 MAdouble64 DVRecoEfficiencyZPrime250GeVToEMU (MAdouble64 r_xy, MAdouble64 pT);
135 
136 MAdouble64 DVRecoEfficiencyZPrime250GeVToMUMU (MAdouble64 r_xy, MAdouble64 pT);
137 
138 MAdouble64 DVRecoEfficiencyZPrime500GeVToEE (MAdouble64 r_xy, MAdouble64 pT);
139 
140 MAdouble64 DVRecoEfficiencyZPrime500GeVToEMU (MAdouble64 r_xy, MAdouble64 pT);
141 
142 MAdouble64 DVRecoEfficiencyZPrime500GeVToMUMU (MAdouble64 r_xy, MAdouble64 pT) ;
143 
144 MAdouble64 DVRecoEfficiencyZPrime750GeVToEE (MAdouble64 r_xy, MAdouble64 pT);
145 
146 MAdouble64 DVRecoEfficiencyZPrime750GeVToEMU (MAdouble64 r_xy, MAdouble64 pT);
147 
148 MAdouble64 DVRecoEfficiencyZPrime750GeVToMUMU (MAdouble64 r_xy, MAdouble64 pT);
149 MAdouble64 DVRecoEfficiencyZPrime1000GeVToEE (MAdouble64 r_xy, MAdouble64 pT);
150 MAdouble64 DVRecoEfficiencyZPrime1000GeVToEMU (MAdouble64 r_xy, MAdouble64 pT);
151 
152 MAdouble64 DVRecoEfficiencyZPrime1000GeVToMUMU (MAdouble64 r_xy, MAdouble64 pT);
153 
154 MAdouble64 DVRecoEfficiencyRPVEE (MAdouble64 r_xy, MAdouble64 mDV, MAdouble64 pT) ;
155 
156 MAdouble64 DVRecoEfficiencyRPVEMU (MAdouble64 r_xy, MAdouble64 mDV, MAdouble64 pT);
157 MAdouble64 DVRecoEfficiencyRPVMUMU (MAdouble64 r_xy, MAdouble64 mDV, MAdouble64 pT);
158 
159 bool vertexMatch (const HEP::P4& v1, const HEP::P4& v2);
160 
161 bool fullMatch(const HEP::Particle &p1, const HEP::Particle &p2);
162 
163 double drCos (HEP::P4 v1,HEP::P4 v2);
164 
165 template<typename T1> bool crVeto1(vector<T1> &v1, const double &drmin)
166 {
167  // Determining with objects should be removed
168  for (int j=0;j<v1.size();j++)
169  for (int i=j+1;i<v1.size();i++)
170  // if (v1[i]->dr(v1[j]) < drmin)
171  if (drCos(v1[i]->mom(),v1[j]->mom()) < drmin)
172  return true;
173  return false;
174 }
175 
176 template<typename T1, typename T2> bool crVeto2(vector<T1> &v1, vector<T2> &v2, const double &drmin)
177 {
178  // Determining with objects should be removed
179  for (int j=0;j<v1.size();j++)
180  for (int i=0;i<v2.size();i++)
181  // if (v2[i]->dr(v1[j]) < drmin)
182  if (drCos(v2[i]->mom(),v1[j]->mom()) < drmin)
183  return true;
184  return false;
185 }
186 
187 bool cosmicRayVeto(vector<HEP::Particle*> &finalStateElectrons, vector<HEP::Particle*> &finalStateMuons);
188 
189 
190 double materialVetoWeight(HEP::P4 &vertex);
191 
192 double disabledPixelModulesVetoWeight(HEP::P4 &vertex);
193 
194 void apply_d_xy_criterion (vector<dv_candidate> &DV_candidates, double d_xy_min);
195 
196 void apply_fiducial_volume_criterion (vector<dv_candidate> &DV_candidates, double radius, double half_length);
197 
198 double apply_dis_pixel_mod_veto (vector<dv_candidate> &DV_candidates, std::mt19937 &engine);
199 
200 double apply_material_veto (vector<dv_candidate> &DV_candidates, std::mt19937 &engine);
201 
202 void require_leptons (vector<dv_candidate> &DV_candidates, int N_min) ;
203 
204 void require_invariant_mass (vector<dv_candidate> &DV_candidates, int m_min);
205 
206 void require_opposite_charge (vector<dv_candidate> &DV_candidates);
207 
208 void apply_trigger_matching (vector<dv_candidate> &DV_candidates);
209 
210 void apply_preselection_matching (vector<dv_candidate> &DV_candidates) ;
211 bool is_loose_photon (const HEP::Particle *photon, const HEP::Event* event);
212 #endif
Simple event class, separating particles into classes.
Definition: heputil.h:227
A 4-momentum class for vectors.
Definition: Vectors.h:45
double pT() const
Get the transverse momentum (same as rho)
Definition: Vectors.h:453
double m() const
Get m.
Definition: Vectors.h:414
void clear()
Set the components to zero.
Definition: Vectors.h:82
Definition: Particle.h:24
double pT() const
Get the squared transverse momentum.
Definition: Particle.h:165
Definition: DV.hpp:27