ATLAS Offline Software
Loading...
Searching...
No Matches
MissingMassCalculator.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5/*
6------ MissingMassCalculator
7------ Author: Aliaksandr Pranko (appranko@lbl.gov)
8------ Code developers: David Rousseau (rousseau@lal.in2p3.fr), Dimitris Varouchas (Dimitris.Varouchas@cern.ch)
9MissingMassCalculator is designed to reconstruct mass in
10events where two particles decay into states with missing ET.
11*/
12#ifndef MissingMassCalculator_h
13#define MissingMassCalculator_h
14
15
16
17#if !defined (__CINT__) || defined (__MAKECINT__)
18
19#include <TRandom2.h>
20#include <TH1.h>
21#include <TGraph.h>
22#include <TF1.h>
23#include <TMath.h>
24#include <Math/Vector4D.h>
25#include <Math/Vector2D.h>
26#include <vector>
27#include <TObject.h>
28#include <TDirectory.h>
29#include "TMatrixD.h"
30
31#include <memory>
32#include <string>
33
38
40
41#endif
42
43
44namespace DiTauMassTools{
45 using ROOT::Math::PtEtaPhiMVector;
46
48
49 public:
50
51 private:
52
53 //---------------- structures
54 struct DitauStuff {
55 double Mditau_best{}; // best fitted M(ditau)
56 double Sign_best{}; // best significance of M(ditau) fit
57 PtEtaPhiMVector nutau1; // fitted 4-vec for neutrino from tau-1
58 PtEtaPhiMVector nutau2; // fitted 4-vec for neutrino from tau-2
59 PtEtaPhiMVector vistau1; // fitted 4-vec for visible tau-1
60 PtEtaPhiMVector vistau2; // fitted 4-vec for visible tau-2
61 double RMSoverMPV{};
62 };
63
64 TRandom2 m_randomGen;
65
67
68 bool m_fUseEfficiencyRecovery{}; // switch to turn ON/OFF re-fit in order to recover efficiency
69 bool m_fUseFloatStopping{}; // switch to turn ON/OFF floating stopping criterion
73
77 int m_rmsStop{};
78 double m_meanbinStop{};
79
80 // these are temporary vectors. Declared globally to avoid construction/destruction
81 std::vector<PtEtaPhiMVector> m_nuvecsol1;
82 std::vector<PtEtaPhiMVector> m_nuvecsol2;
83
84 std::vector<PtEtaPhiMVector> m_tauvecsol1;
85 std::vector<PtEtaPhiMVector> m_tauvecsol2;
86 std::vector<double> m_tauvecprob1;
87 std::vector<double> m_tauvecprob2;
88
89 std::vector<PtEtaPhiMVector> m_nuvec1_tmp;
90 std::vector<PtEtaPhiMVector> m_nuvec2_tmp;
91
92 PtEtaPhiMVector m_tautau_tmp;
93
95
98 double m_nsigma_METscan_lfv_lh{}, m_beamEnergy{}; // number of sigmas for MET-scan
99
101
102 double m_prob_tmp{};
103
105 double m_mtautauSum{};
106
108 int m_seed{};
109 // data member for the spaceWalker approach
110
111 int m_iter0{};
117 int m_nosol1{};
118 int m_nosol2{};
120 bool m_switch1{};
121 bool m_switch2{};
122
124
130
134
138
139 double m_mTau{},m_mTau2{};
141 double m_eTau1{}, m_eTau2{};
142 double m_eTau10{}, m_eTau20{};
151
157 std::vector<double> m_probFinalSolOldVec;
158 std::vector<double> m_mtautauFinalSolOldVec;
159 std::vector<PtEtaPhiMVector> m_nu1FinalSolOldVec;
160 std::vector<PtEtaPhiMVector> m_nu2FinalSolOldVec;
161
162 int m_nsol{};
163 std::vector<double> m_probFinalSolVec;
164 std::vector<double> m_mtautauFinalSolVec;
165 std::vector<PtEtaPhiMVector> m_nu1FinalSolVec;
166 std::vector<PtEtaPhiMVector> m_nu2FinalSolVec;
167
168
171 double m_walkWeight{};
173
175
176 PtEtaPhiMVector m_tauVec1,m_tauVec2;
182 double m_tauVec1E{};
183 double m_tauVec2E{};
184 double m_m2Nu1{};
185 double m_m2Nu2{};
186 double m_ET2v1{};
187 double m_ET2v2{};
188 double m_E2v1{};
189 double m_E2v2{};
190 double m_Ev2{};
191 double m_Ev1{};
192 double m_Mvis{},m_Meff{};
193
194 //--- define histograms for histogram method
195 //--- upper limits need to be revisied in the future!!! It may be not enough for some analyses
196 std::shared_ptr<TH1F> m_fMfit_all;
197 std::shared_ptr<TH1F> m_fMEtP_all;
198 std::shared_ptr<TH1F> m_fMEtL_all;
199 std::shared_ptr<TH1F> m_fMnu1_all;
200 std::shared_ptr<TH1F> m_fMnu2_all;
201 std::shared_ptr<TH1F> m_fPhi1_all;
202 std::shared_ptr<TH1F> m_fPhi2_all;
203 std::shared_ptr<TGraph> m_fMfit_allGraph;
204 std::shared_ptr<TH1F> m_fMfit_allNoWeight;
205
206 std::shared_ptr<TH1F> m_fPXfit1;
207 std::shared_ptr<TH1F> m_fPYfit1;
208 std::shared_ptr<TH1F> m_fPZfit1;
209 std::shared_ptr<TH1F> m_fPXfit2;
210 std::shared_ptr<TH1F> m_fPYfit2;
211 std::shared_ptr<TH1F> m_fPZfit2;
212
213 // these histograms are used for the floating stopping criterion
214 std::shared_ptr<TH1F> m_fMmass_split1;
215 std::shared_ptr<TH1F> m_fMEtP_split1;
216 std::shared_ptr<TH1F> m_fMEtL_split1;
217 std::shared_ptr<TH1F> m_fMnu1_split1;
218 std::shared_ptr<TH1F> m_fMnu2_split1;
219 std::shared_ptr<TH1F> m_fPhi1_split1;
220 std::shared_ptr<TH1F> m_fPhi2_split1;
221 std::shared_ptr<TH1F> m_fMmass_split2;
222 std::shared_ptr<TH1F> m_fMEtP_split2;
223 std::shared_ptr<TH1F> m_fMEtL_split2;
224 std::shared_ptr<TH1F> m_fMnu1_split2;
225 std::shared_ptr<TH1F> m_fMnu2_split2;
226 std::shared_ptr<TH1F> m_fPhi1_split2;
227 std::shared_ptr<TH1F> m_fPhi2_split2;
228
230
231 TH1F* m_fPhi1{};
232 TH1F* m_fPhi2{};
233 TH1F* m_fMnu1{};
234 TH1F* m_fMnu2{};
235 TH1F* m_fMetx{};
236 TH1F* m_fMety{};
237 TH1F* m_fTheta3D{};
238 TH1F* m_fTauProb{};
239
240 // for intermediate calc
241 PtEtaPhiMVector m_TLVdummy;
242
243 //---------------- protected variables
244 DitauStuff m_fDitauStuffFit; // results based on fit method
245 DitauStuff m_fDitauStuffHisto; // results based on histo method
246
247 int m_niter_fit1{}; // number of iterations for dR-dPhi scan
248 int m_niter_fit2{}; // number of iterations for MET-scan
249 int m_niter_fit3{}; // number of iterations for Mnu-scan
250 int m_NiterRandom{}; // number of random iterations (for lh, multiply or divide by 10 for ll and hh)
253 int m_RndmSeedAltering{}; // reset seed (not necessary by default)
254
255 double m_dRmax_tau{}; // maximum dR(nu-visTau)
256
257 double m_MnuScanRange{}; // range of M(nunu) scan; M(nunu) range can be affected by selection cuts
258
259
260 //---------------- protected functions
261 void ClearDitauStuff(DitauStuff &fStuff);
262 void DoOutputInfo();
263 void PrintOtherInput();
264 void PrintResults();
265
266 inline int NuPsolutionV3(const double & mNu1, const double & mNu2, const double & phi1, const double & phi2,
267 int & nsol1, int & nsol2);
268
269 inline int NuPsolutionLFV(const XYVector & met_vec, const PtEtaPhiMVector & tau,
270 const double & m_nu, std::vector<PtEtaPhiMVector> &nu_vec);
271
272
273 protected:
274 inline int CheckSolutions(PtEtaPhiMVector nu_vec, PtEtaPhiMVector vis_vec, int decayType);
275 inline int TailCleanUp(const PtEtaPhiMVector & vis1, const PtEtaPhiMVector & nu1,
276 const PtEtaPhiMVector & vis2, const PtEtaPhiMVector & nu2,
277 const double & mmc_mass, const double & vis_mass, const double & eff_mass, const double & dphiTT);
278
279
280 inline int refineSolutions ( const double & M_nu1, const double & M_nu2,
281 const int nsol1, const int nsol2,
282 const double & Mvis, const double & Meff);
283
284
285
286 inline void handleSolutions();
287
288 inline double MassScale(int method, double mass, const int & tau_type1, const int & tau_type2);
289
290
291 // factor out parameter space walking and probablity computing
292 inline int DitauMassCalculatorV9walk();
293
294
295 // Calculates mass of lep+tau system in LFV X->lep+tau decays
296 // It is based on DitauMassCalculatorV9, not optimized for speed yet, simple phase-space scan
297 inline int DitauMassCalculatorV9lfv(bool refit);
298
299
300
301 // only compute probability
302 inline int probCalculatorV9fast(
303 const double & phi1, const double & phi2,
304 const double & M_nu1, const double & M_nu2);
305
306 // initialize the walker
307 inline void SpaceWalkerInit();
308
309 //walk the walker
310 inline bool SpaceWalkerWalk();
311
312 inline bool precomputeCache();
313
314
315 inline bool checkMEtInRange () ;
316 inline bool checkAllParamInRange () ;
317
318 //----------------------------------------------
319 //
320 // ------------ Public methods ---------------
321 //
322 //______________________________________________
323
324public:
325
327
328 MissingMassCalculator(MMCCalibrationSet::e aset, std::string paramFilePath) ;
329
332
336
337 int RunMissingMassCalculator( const xAOD::IParticle* part1, const xAOD::IParticle* part2, const xAOD::MissingET* met, const int& njets );
338
339 bool MassCollinear(const xAOD::IParticle *p0, const xAOD::IParticle *p1,
340 const xAOD::MissingET *met, // met
341 const bool kMMCsynchronize, // mmc sychronization
342 double &mass, double &xp1, double &xp2);
343
344
345 //-------- Set Input Parameters
346 void FinalizeSettings(const xAOD::IParticle* part1, const xAOD::IParticle* part2, const xAOD::MissingET* met, const int& njets );
347 void SetNiterFit1(const int val) { m_niter_fit1=val; } // number of iterations per loop in dPhi loop
348 void SetNiterFit2(const int val) { m_niter_fit2=val; } // number of iterations per loop in MET loop
349 void SetNiterFit3(const int val) { m_niter_fit3=val; } // number of iterations per loop in Mnu loop
350 void SetNiterRandom(const int val) { m_NiterRandom=val; } // number of random iterations
351 void SetNsucStop(const int val) { m_NsucStop=val; } // Arrest criteria for Nsuccesses
352 void SetRMSStop(const int val) { m_RMSStop=val;}
353 void SetMeanbinStop(const double val) {m_meanbinStop=val;}
354 void SetRndmSeedAltering(const int val) { m_RndmSeedAltering=val; } // number of iterations per loop in Mnu loop
355 void SetEventNumber(const int eventNumber) { m_eventNumber = eventNumber; }
356
357 void SetMnuScanRange(const double val) { m_MnuScanRange=val; }
358
359 void SetProposalTryMEt(const double val) {m_proposalTryMEt=val; }
360 void SetProposalTryPhi(const double val) {m_ProposalTryPhi=val;}
361 void SetProposalTryMnu(const double val) {m_ProposalTryMnu=val;}
362
365
366 int GetNiterFit1() const { return m_niter_fit1; } // number of iterations per loop in dPhi loop
367 int GetNiterFit2() const { return m_niter_fit2; } // number of iterations per loop in MET loop
368 int GetNiterFit3() const { return m_niter_fit3; } // number of iterations per loop in Mnu loop
369 int GetNiterRandom() const { return m_niterRandomLocal; } // number of random iterations
370
371 int GetNsucStop() const { return m_NsucStop; } // Arrest criteria for NSuc
372 int GetRMSStop() const { return m_RMSStop; }
373 double GetMeanbinStop() const { return m_meanbinStop;}
374 int GetRndmSeedAltering() const { return m_RndmSeedAltering; } // number of iterations per loop in Mnu loop
375
379 int GetMarkovNAccept() const { return m_markovNAccept; }
381 double GetProposalTryMEt() const {return m_proposalTryMEt;}
382 double GetProposalTryPhi() const {return m_ProposalTryPhi;}
383 double GetProposalTryMnu() const {return m_ProposalTryMnu;}
384
385 void SetNsigmaMETscan_ll(const double val) { m_nsigma_METscan_ll=val; } // number of sigma's for MET-scan in ll events
386 void SetNsigmaMETscan_lh(const double val) { m_nsigma_METscan_lh=val; } // number of sigma's for MET-scan in lh events
387 void SetNsigmaMETscan_hh(const double val) { m_nsigma_METscan_hh=val; } // number of sigma's for MET-scan in hh events
388 void SetNsigmaMETscan(const double val) { m_nsigma_METscan=val; } // number of sigma's for MET-scan
389
390 void SetUseFloatStopping(const bool val); // switch for floating stopping criterion
393 void SetFloatStoppingComp(const double val) { m_fUseFloatStoppingComp = val;}
394 void SetBeamEnergy(const double val) { m_beamEnergy=val; }
395 void SetLFVLeplepRefit(const bool val) { m_lfvLeplepRefit=val; }
396 void SaveLlhHisto(const bool val);
397
398 double GetmMaxError() const {return m_PrintmMaxError;}
399 double GetmMeanError() const { return m_PrintmMeanError;}
401
402 int GetNNoSol() const {return m_markovNRejectNoSol;}
404 int GetNSol() const {return m_markovNAccept;}
405
406
407 //-------- Get results;
408 Double_t maxFitting(Double_t *x, Double_t *par);
409
410 // compute maximum from histo
411 double maxFromHist(TH1F *theHist, std::vector<double> & histInfo, const MaxHistStrategy::e maxHistStrategy=MaxHistStrategy::FIT,const int winHalfWidth=2,bool debug=false);
412 double maxFromHist(const std::shared_ptr<TH1F>& theHist, std::vector<double> & histInfo, const MaxHistStrategy::e maxHistStrategy=MaxHistStrategy::FIT,const int winHalfWidth=2,bool debug=false) {
413 return maxFromHist(theHist.get(), histInfo, maxHistStrategy, winHalfWidth, debug);
414 }
415
416 XYVector metvec_tmp;
417 inline double dTheta3DLimit(const int & tau_type, const int & limit_code,const double & P_tau);
418
419};
420} // namespace DiTauMassTools
421
422#endif
const bool debug
#define x
int TailCleanUp(const PtEtaPhiMVector &vis1, const PtEtaPhiMVector &nu1, const PtEtaPhiMVector &vis2, const PtEtaPhiMVector &nu2, const double &mmc_mass, const double &vis_mass, const double &eff_mass, const double &dphiTT)
double maxFromHist(TH1F *theHist, std::vector< double > &histInfo, const MaxHistStrategy::e maxHistStrategy=MaxHistStrategy::FIT, const int winHalfWidth=2, bool debug=false)
bool MassCollinear(const xAOD::IParticle *p0, const xAOD::IParticle *p1, const xAOD::MissingET *met, const bool kMMCsynchronize, double &mass, double &xp1, double &xp2)
int probCalculatorV9fast(const double &phi1, const double &phi2, const double &M_nu1, const double &M_nu2)
void FinalizeSettings(const xAOD::IParticle *part1, const xAOD::IParticle *part2, const xAOD::MissingET *met, const int &njets)
std::vector< PtEtaPhiMVector > m_nu2FinalSolOldVec
int refineSolutions(const double &M_nu1, const double &M_nu2, const int nsol1, const int nsol2, const double &Mvis, const double &Meff)
MissingMassCalculator(MMCCalibrationSet::e aset, std::string paramFilePath)
MissingMassCalculator & operator=(const MissingMassCalculator &)=delete
int CheckSolutions(PtEtaPhiMVector nu_vec, PtEtaPhiMVector vis_vec, int decayType)
std::vector< PtEtaPhiMVector > m_nu1FinalSolOldVec
std::vector< PtEtaPhiMVector > m_tauvecsol1
std::vector< PtEtaPhiMVector > m_nuvec1_tmp
std::vector< PtEtaPhiMVector > m_nuvecsol1
std::vector< PtEtaPhiMVector > m_nuvec2_tmp
std::vector< PtEtaPhiMVector > m_nuvecsol2
std::vector< PtEtaPhiMVector > m_nu2FinalSolVec
Double_t maxFitting(Double_t *x, Double_t *par)
int NuPsolutionV3(const double &mNu1, const double &mNu2, const double &phi1, const double &phi2, int &nsol1, int &nsol2)
double MassScale(int method, double mass, const int &tau_type1, const int &tau_type2)
double dTheta3DLimit(const int &tau_type, const int &limit_code, const double &P_tau)
int NuPsolutionLFV(const XYVector &met_vec, const PtEtaPhiMVector &tau, const double &m_nu, std::vector< PtEtaPhiMVector > &nu_vec)
std::vector< PtEtaPhiMVector > m_tauvecsol2
std::vector< PtEtaPhiMVector > m_nu1FinalSolVec
MissingMassCalculator(const MissingMassCalculator &)=delete
int RunMissingMassCalculator(const xAOD::IParticle *part1, const xAOD::IParticle *part2, const xAOD::MissingET *met, const int &njets)
double maxFromHist(const std::shared_ptr< TH1F > &theHist, std::vector< double > &histInfo, const MaxHistStrategy::e maxHistStrategy=MaxHistStrategy::FIT, const int winHalfWidth=2, bool debug=false)
Class providing the definition of the 4-vector interface.
Definition part1.py:1
Definition part2.py:1
MissingET_v1 MissingET
Version control by type defintion.