JHUGen MELA  v2.4.1
Matrix element calculations as used in JHUGen. MELA is an important tool that was used for the Higgs boson discovery and for precise measurements of its structure and interactions. Please see the website https://spin.pha.jhu.edu/ and papers cited there for more details, and kindly cite those papers when using this code.
TUtilHelpers.hh
Go to the documentation of this file.
1 #ifndef TUTILHELPERS
2 #define TUTILHELPERS
3 
4 #include <string>
5 #include <vector>
6 #include <iterator>
7 #include <algorithm>
8 #include <utility>
9 #include "MELAParticle.h"
10 #include "MELACandidate.h"
12 #include "TVar.hh"
13 #include "TNumericUtil.hh"
14 
15 namespace TUtilHelpers{
16 
17  template<typename T> void copyVector(std::vector<T> const& input, std::vector<T>& target);
18  template<typename T, typename U=T> bool checkElementExists(T const& element, std::vector<U> const& elementlist);
19  template<typename T> bool hasCommonElements(std::vector<T> const& v1, std::vector<T> const& v2);
20 
21  void ExpandEnvironmentVariables(std::string& str);
22 }
23 
24 template<typename T> void TUtilHelpers::copyVector(std::vector<T> const& input, std::vector<T>& target){
25  std::copy(input.cbegin(), input.cend(), std::back_inserter(target));
26 }
27 template void TUtilHelpers::copyVector<MELAParticle*>(std::vector<MELAParticle*> const& input, std::vector<MELAParticle*>& target);
28 template void TUtilHelpers::copyVector<MELACandidate*>(std::vector<MELACandidate*> const& input, std::vector<MELACandidate*>& target);
29 template void TUtilHelpers::copyVector<MELAThreeBodyDecayCandidate*>(std::vector<MELAThreeBodyDecayCandidate*> const& input, std::vector<MELAThreeBodyDecayCandidate*>& target);
30 template void TUtilHelpers::copyVector<SimpleParticle_t>(SimpleParticleCollection_t const& input, SimpleParticleCollection_t& target);
31 template void TUtilHelpers::copyVector<bool>(std::vector<bool> const& input, std::vector<bool>& target);
32 template void TUtilHelpers::copyVector<short>(std::vector<short> const& input, std::vector<short>& target);
33 template void TUtilHelpers::copyVector<unsigned int>(std::vector<unsigned int> const& input, std::vector<unsigned int>& target);
34 template void TUtilHelpers::copyVector<int>(std::vector<int> const& input, std::vector<int>& target);
35 template void TUtilHelpers::copyVector<unsigned long>(std::vector<unsigned long> const& input, std::vector<unsigned long>& target);
36 template void TUtilHelpers::copyVector<long>(std::vector<long> const& input, std::vector<long>& target);
37 template void TUtilHelpers::copyVector<long long>(std::vector<long long> const& input, std::vector<long long>& target);
38 template void TUtilHelpers::copyVector<float>(std::vector<float> const& input, std::vector<float>& target);
39 template void TUtilHelpers::copyVector<double>(std::vector<double> const& input, std::vector<double>& target);
40 template void TUtilHelpers::copyVector<TNumericUtil::intQuad_t>(std::vector<TNumericUtil::intQuad_t> const& input, std::vector<TNumericUtil::intQuad_t>& target);
41 
42 template<typename T, typename U> bool TUtilHelpers::checkElementExists(T const& element, std::vector<U> const& elementlist){
43  for (U const& el:elementlist){ if (el==element) return true; }
44  return false;
45 }
46 template bool TUtilHelpers::checkElementExists<MELAParticle const*>(MELAParticle const* const& element, std::vector<MELAParticle const*> const& elementlist);
47 template bool TUtilHelpers::checkElementExists<MELAParticle const*, MELAParticle*>(MELAParticle const* const& element, std::vector<MELAParticle*> const& elementlist);
48 template bool TUtilHelpers::checkElementExists<MELACandidate const*>(MELACandidate const* const& element, std::vector<MELACandidate const*> const& elementlist);
49 template bool TUtilHelpers::checkElementExists<MELACandidate const*, MELACandidate*>(MELACandidate const* const& element, std::vector<MELACandidate*> const& elementlist);
50 template bool TUtilHelpers::checkElementExists<MELAThreeBodyDecayCandidate const*>(MELAThreeBodyDecayCandidate const* const& element, std::vector<MELAThreeBodyDecayCandidate const*> const& elementlist);
51 template bool TUtilHelpers::checkElementExists<MELAThreeBodyDecayCandidate const*, MELAThreeBodyDecayCandidate*>(MELAThreeBodyDecayCandidate const* const& element, std::vector<MELAThreeBodyDecayCandidate*> const& elementlist);
52 template bool TUtilHelpers::checkElementExists<bool>(bool const& element, std::vector<bool> const& elementlist);
53 template bool TUtilHelpers::checkElementExists<short>(short const& element, std::vector<short> const& elementlist);
54 template bool TUtilHelpers::checkElementExists<unsigned int>(unsigned int const& element, std::vector<unsigned int> const& elementlist);
55 template bool TUtilHelpers::checkElementExists<int>(int const& element, std::vector<int> const& elementlist);
56 template bool TUtilHelpers::checkElementExists<unsigned long>(unsigned long const& element, std::vector<unsigned long> const& elementlist);
57 template bool TUtilHelpers::checkElementExists<long>(long const& element, std::vector<long> const& elementlist);
58 template bool TUtilHelpers::checkElementExists<long long>(long long const& element, std::vector<long long> const& elementlist);
59 template bool TUtilHelpers::checkElementExists<float>(float const& element, std::vector<float> const& elementlist);
60 template bool TUtilHelpers::checkElementExists<double>(double const& element, std::vector<double> const& elementlist);
61 template bool TUtilHelpers::checkElementExists<TNumericUtil::intQuad_t>(TNumericUtil::intQuad_t const& element, std::vector<TNumericUtil::intQuad_t> const& elementlist);
62 
63 template<typename T> bool TUtilHelpers::hasCommonElements(std::vector<T> const& v1, std::vector<T> const& v2){
64  for (T const& el1:v1){
65  for (T const& el2:v2){
66  if (el1==el2) return true;
67  }
68  }
69  return false;
70 }
71 
72 #endif
73 
TUtilHelpers::checkElementExists
bool checkElementExists(T const &element, std::vector< U > const &elementlist)
Definition: TUtilHelpers.hh:42
TNumericUtil.hh
MELAThreeBodyDecayCandidate.h
TUtilHelpers
Definition: TUtilHelpers.hh:15
MELAParticle
Definition: MELAParticle.h:13
TUtilHelpers::copyVector
void copyVector(std::vector< T > const &input, std::vector< T > &target)
Definition: TUtilHelpers.hh:24
TUtilHelpers::ExpandEnvironmentVariables
void ExpandEnvironmentVariables(std::string &str)
Definition: TUtilHelpers.cc:6
MELAParticle.h
MELACandidate.h
TVar.hh
TNumericUtil::quadruplet
Definition: TNumericUtil.hh:27
MELACandidate
Definition: MELACandidate.h:7
TUtilHelpers::hasCommonElements
bool hasCommonElements(std::vector< T > const &v1, std::vector< T > const &v2)
Definition: TUtilHelpers.hh:63
MELAThreeBodyDecayCandidate
Definition: MELAThreeBodyDecayCandidate.h:7
SimpleParticleCollection_t
std::vector< SimpleParticle_t > SimpleParticleCollection_t
Definition: TVar.hh:25