ATLAS Offline Software
Namespaces | Classes | Functions
DiTauMassTools Namespace Reference

Namespaces

 HistInfo
 
 MaxHistStrategy
 
 MMCCalibrationSet
 
 MMCFitMethod
 
 TauTypes
 

Classes

class  MissingMassCalculator
 
class  MissingMassInput
 
class  MissingMassOutput
 
class  MissingMassProb
 
class  MissingMassTool
 

Functions

template<typename T >
void ignore (T &&)
 
template<typename VectorType1 , typename VectorType2 >
double Angle (const VectorType1 &vec1, const VectorType2 &vec2)
 
template<typename VectorType >
double mT (const VectorType &vec, const XYVector &met_vec)
 
bool updateDouble (const double in, double &out)
 
void fastSinCos (const double &phi, double &sinPhi, double &cosPhi)
 
double fixPhiRange (const double &phi)
 
double MaxDelPhi (int tau_type, double Pvis, double dRmax_tau)
 
int getLFVMode (const xAOD::IParticle *p1, const xAOD::IParticle *p2, int mmcType1, int mmcType2)
 
int mmcType (const xAOD::IParticle *part)
 
void readInParams (TDirectory *dir, MMCCalibrationSet::e aset, std::vector< TF1 * > &lep_numass, std::vector< TF1 * > &lep_angle, std::vector< TF1 * > &lep_ratio, std::vector< TF1 * > &had_angle, std::vector< TF1 * > &had_ratio)
 

Function Documentation

◆ Angle()

template<typename VectorType1 , typename VectorType2 >
double DiTauMassTools::Angle ( const VectorType1 &  vec1,
const VectorType2 &  vec2 
)

Definition at line 61 of file PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h.

61  {
62  // Calculate the dot product and magnitudes (similar to but faster than ::Angle())
63  double dotProduct = vec1.Px() * vec2.Px() + vec1.Py() * vec2.Py() + vec1.Pz() * vec2.Pz();
64  double magnitude1 = vec1.P();
65  double magnitude2 = vec2.P();
66 
67  // Calculate and return the angle
68  return acos(dotProduct / (magnitude1 * magnitude2));
69 }

◆ fastSinCos()

void DiTauMassTools::fastSinCos ( const double &  phi,
double &  sinPhi,
double &  cosPhi 
)

Definition at line 42 of file PhysicsAnalysis/TauID/DiTauMassTools/Root/HelperFunctions.cxx.

43 {
44  const double fastB=4/TMath::Pi();
45  const double fastC=-4/(TMath::Pi()*TMath::Pi());
46  const double fastP=9./40.;
47  const double fastQ=31./40.;
48  // use normal sin cos if switch off
49 #ifdef NOFASTSINCOS
50  sinPhi=sin(phiInput);
51  cosPhi=cos(phiInput);
52 #else
53 
54 
55  double phi = fixPhiRange(phiInput);
56 
57  // http://devmaster.net/forums/topic/4648-fast-and-accurate-sinecosine/
58  // accurate to 1 per mille
59 
60  // even faster
61  // const double y=fastB*phi+fastC*phi*std::abs(phi);
62  // sinPhi=fastP*(y*std::abs(y)-y)+y;
63  const double y=phi*(fastB+fastC*std::abs(phi));
64  sinPhi=y*(fastP*std::abs(y)+fastQ);
65 
66 
67  //note that one could use cos(phi)=sin(phi+pi/2), however then one would not have c^2+s^2=1 (would get it only within 1 per mille)
68  // the choice here is to keep c^2+s^2=1 so everything is as one would compute c and s from a slightly (1 per mille) different angle
69  cosPhi=sqrt(1-std::pow(sinPhi,2));
70  if (std::abs(phi)>TMath::PiOver2()) cosPhi=-cosPhi;
71 #endif
72 }

◆ fixPhiRange()

double DiTauMassTools::fixPhiRange ( const double &  phi)

Definition at line 21 of file PhysicsAnalysis/TauID/DiTauMassTools/Root/HelperFunctions.cxx.

22 {
23  double phiOut=phi;
24 
25  if (phiOut>0){
26  while (phiOut>TMath::Pi()) {
27  phiOut-=TMath::TwoPi();
28  }
29  }
30 
31  else{
32  while (phiOut<-TMath::Pi()) {
33  phiOut+=TMath::TwoPi();
34  }
35  }
36  return phiOut;
37 }

◆ getLFVMode()

int DiTauMassTools::getLFVMode ( const xAOD::IParticle p1,
const xAOD::IParticle p2,
int  mmcType1,
int  mmcType2 
)

Definition at line 83 of file PhysicsAnalysis/TauID/DiTauMassTools/Root/HelperFunctions.cxx.

83  {
84 
85  // Check if particles pointers are null
86  if(p1 == nullptr || p2 == nullptr) {
87  Info("DiTauMassTools", "MissingMassTool::getLFVMode() got a nullptr - returning -1");
88  return -1;
89  }
90 
91  // In case we're in LFV calibration, pass the LFV mode to the tool
92  if (mmcType1 == -1) mmcType1 = mmcType(p1);
93  if (mmcType1 < 0) return -1;//return CP::CorrectionCode::Error;
94 
95  if (mmcType2 == -1) mmcType2 = mmcType(p2);
96  if (mmcType2 < 0) return -1;//return CP::CorrectionCode::Error;
97 
98  // we don't use mmcType as it's 0 for both leptons
99  const xAOD::IParticle *p;
100  if(mmcType1 == 8 && mmcType2 == 8) {
101  // both leptonic; find whichever has the highest pT
102  if(p1->pt() > p2->pt() ) {
103  p = p1;
104  } else {
105  p = p2;
106  }
107 
108  } else {
109  // one of them is a lepton, find it
110  if(mmcType1 == 8) {
111  p = p1;
112  } else if(mmcType2 == 8) {
113  p = p2;
114  } else {
115  // if you're here, you've passed 2 taus to the LFV mode.
116  Warning("DiTauMassTools", "Trying to set LFV mode for 2 taus!");
117  return -1;//return CP::CorrectionCode::Error;
118  }
119  }
120 
121  if(!p) return -1;//return CP::CorrectionCode::Error;
122 
123  int LFVMode = -1;
124  if(p->type() == xAOD::Type::Muon) {
125  // mu+tau mode
126  Info("DiTauMassTools", "Setting MMC to mu+tau mode");
127  //m_MMC->SetLFVmode(1);
128  LFVMode = 1;
129  } else {
130  // e+tau mode
131  Info("DiTauMassTools", "Setting MMC to e+tau mode");
132  //m_MMC->SetLFVmode(0);
133  LFVMode = 0;
134  }
135 
136  return LFVMode;
137  //return CP::CorrectionCode::Ok;
138 }

◆ ignore()

template<typename T >
void DiTauMassTools::ignore ( T &&  )

◆ MaxDelPhi()

double DiTauMassTools::MaxDelPhi ( int  tau_type,
double  Pvis,
double  dRmax_tau 
)

Definition at line 15 of file PhysicsAnalysis/TauID/DiTauMassTools/Root/HelperFunctions.cxx.

16 {
17  return dRmax_tau+0*Pvis*tau_type; // hack to avoid warning
18 }

◆ mmcType()

int DiTauMassTools::mmcType ( const xAOD::IParticle part)

Definition at line 140 of file PhysicsAnalysis/TauID/DiTauMassTools/Root/HelperFunctions.cxx.

141 {
142  if(part == nullptr) {
143  // idea for fix: pass logger object to this function or whole algorithm that inherited from athena as pointer
144  Info("DiTauMassTools", "MissingMassTool::mmcType() got a nullptr - returning -1");
145  return -1;
146  }
147 
148  xAOD::Type::ObjectType partType=part->type();
149  int aType=-1;
150  if (partType==xAOD::Type::Electron || partType==xAOD::Type::Muon)
151  {
152  aType=8; // PanTau_DecayMode for leptonic taus
153  }
154  else if (partType==xAOD::Type::Tau)
155  {
156  const xAOD::TauJet * aTauJet=dynamic_cast<const xAOD::TauJet*>(part);
157  if (aTauJet==0)
158  {
159  Warning("DiTauMassTools", "MissingMassTool::mmcType() dynamic_cast of TauJet failed");
160  aType=-2;
161  }
162  else
163  {
164  aTauJet->panTauDetail(xAOD::TauJetParameters::PanTau_DecayMode, aType); // 0: 1p0n, 1: 1p1n, 2: 1pXn, 3: 3p0n, 4: 3pXn, 5: Other (2p, 4p, 5p), 6: not set (0p, >=6p), 7: error, 8: leptonic
165  }
166  }
167  else
168  {
169  Warning("DiTauMassTools", "MissingMassTool::mmcType() unrecognised particle type! Only Electron, Muon, TauJet allowed. If no mistake, please call MissingMassTool::calculate() directly.");
170  aType=-1;
171  }
172 
173  return aType;
174 }

◆ mT()

template<typename VectorType >
double DiTauMassTools::mT ( const VectorType &  vec,
const XYVector &  met_vec 
)

Definition at line 72 of file PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h.

72  {
73  double mt=0.0;
74  double dphi=std::abs(Phi_mpi_pi(vec.Phi()-met_vec.Phi()));
75  double cphi=1.0-cos(dphi);
76  if(cphi>0.0) mt=sqrt(2.0*vec.Pt()*met_vec.R()*cphi);
77  return mt;
78 }

◆ readInParams()

void DiTauMassTools::readInParams ( TDirectory *  dir,
MMCCalibrationSet::e  aset,
std::vector< TF1 * > &  lep_numass,
std::vector< TF1 * > &  lep_angle,
std::vector< TF1 * > &  lep_ratio,
std::vector< TF1 * > &  had_angle,
std::vector< TF1 * > &  had_ratio 
)

Definition at line 177 of file PhysicsAnalysis/TauID/DiTauMassTools/Root/HelperFunctions.cxx.

177  {
178  std::string paramcode;
179  if (aset == MMCCalibrationSet::MMC2019) paramcode = "MMC2019MC16";
180  else {
181  Info("DiTauMassTools", "The specified calibration version does not support root file parametrisations");
182  return;
183  }
184  TIter next(dir->GetListOfKeys());
185  TKey* key;
186  while ((key = (TKey*)next())) {
187  TClass *cl = gROOT->GetClass(key->GetClassName());
188  // if there is another subdirectory, go into that dir
189  if (cl->InheritsFrom("TDirectory")) {
190  dir->cd(key->GetName());
191  TDirectory *subdir = gDirectory;
192  readInParams(subdir, aset, lep_numass, lep_angle, lep_ratio, had_angle, had_ratio);
193  dir->cd();
194  }
195  else if (cl->InheritsFrom("TF1") || cl->InheritsFrom("TGraph")) {
196  // get parametrisations and sort them into their corresponding vectors
197  std::string total_path = dir->GetPath();
198  if (total_path.find(paramcode) == std::string::npos) continue;
199  TF1* func = (TF1*)dir->Get( (const char*) key->GetName() );
200  TF1* f = new TF1(*func);
201  if (total_path.find("lep") != std::string::npos)
202  {
203  if (total_path.find("Angle") != std::string::npos){
204  lep_angle.push_back(f);
205  }
206  else if (total_path.find("Ratio") != std::string::npos)
207  {
208  lep_ratio.push_back(f);
209  }
210  else if (total_path.find("Mass") != std::string::npos)
211  {
212  lep_numass.push_back(f);
213  }
214  else
215  {
216  Warning("DiTauMassTools", "Undefined leptonic PDF term in input file.");
217  }
218  }
219  else if (total_path.find("had") != std::string::npos)
220  {
221  if (total_path.find("Angle") != std::string::npos){
222  had_angle.push_back(f);
223  }
224  else if (total_path.find("Ratio") != std::string::npos)
225  {
226  had_ratio.push_back(f);
227  }
228  else
229  {
230  Warning("DiTauMassTools", "Undefined hadronic PDF term in input file.");
231  }
232  }
233  else
234  {
235  Warning("DiTauMassTools", "Undefined decay channel in input file.");
236  }
237  }
238  else {
239  Warning("DiTauMassTools", "Class in input file not recognized.");
240  }
241  }
242 }

◆ updateDouble()

bool DiTauMassTools::updateDouble ( const double  in,
double &  out 
)

Definition at line 75 of file PhysicsAnalysis/TauID/DiTauMassTools/Root/HelperFunctions.cxx.

76 {
77  if (out==in) return true;
78  out=in;
79  return false;
80 }
LArG4FSStartPointFilter.part
part
Definition: LArG4FSStartPointFilter.py:21
xAOD::TauJetParameters::PanTau_DecayMode
@ PanTau_DecayMode
Definition: TauDefs.h:360
D3PDMakerTestInstan::vec2
std::vector< D3PDTest::MyVec2 > vec2
Definition: D3PDMakerTestDict.h:14
xAOD::Electron
Electron_v1 Electron
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:67
ObjectType
ObjectType
Definition: BaseObject.h:11
conifer::pow
constexpr int pow(int x)
Definition: conifer.h:20
TRTCalib_cfilter.p1
p1
Definition: TRTCalib_cfilter.py:130
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
xAOD::TauJet_v3::panTauDetail
bool panTauDetail(TauJetParameters::PanTauDetails panTauDetail, int &value) const
Get and set values of pantau details variables via enum.
Definition: TauJet_v3.cxx:367
vec
std::vector< size_t > vec
Definition: CombinationsGeneratorTest.cxx:12
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:41
ZDCMsg::Info
@ Info
Definition: ZDCMsg.h:20
Phi_mpi_pi
__HOSTDEV__ double Phi_mpi_pi(double)
Definition: GeoRegion.cxx:7
TRTCalib_cfilter.p2
p2
Definition: TRTCalib_cfilter.py:131
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
fillPileUpNoiseLumi.next
next
Definition: fillPileUpNoiseLumi.py:52
ParseInputs.gDirectory
gDirectory
Definition: Final2012/ParseInputs.py:133
DiTauMassTools::readInParams
void readInParams(TDirectory *dir, MMCCalibrationSet::e aset, std::vector< TF1 * > &lep_numass, std::vector< TF1 * > &lep_angle, std::vector< TF1 * > &lep_ratio, std::vector< TF1 * > &had_angle, std::vector< TF1 * > &had_ratio)
Definition: PhysicsAnalysis/TauID/DiTauMassTools/Root/HelperFunctions.cxx:177
xAOD::TauJet_v3
Class describing a tau jet.
Definition: TauJet_v3.h:41
DiTauMassTools::MMCCalibrationSet::MMC2019
@ MMC2019
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:40
hist_file_dump.f
f
Definition: hist_file_dump.py:135
DiTauMassTools::mmcType
int mmcType(const xAOD::IParticle *part)
Definition: PhysicsAnalysis/TauID/DiTauMassTools/Root/HelperFunctions.cxx:140
beamspotman.dir
string dir
Definition: beamspotman.py:623
DiTauMassTools::fixPhiRange
double fixPhiRange(const double &phi)
Definition: PhysicsAnalysis/TauID/DiTauMassTools/Root/HelperFunctions.cxx:21
Muon
struct TBPatternUnitContext Muon
y
#define y
xAODType::Tau
@ Tau
The object is a tau (jet)
Definition: ObjectType.h:49
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
python.LumiCalcRecover.subdir
subdir
Definition: LumiCalcRecover.py:25
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:26
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37