12 #include <boost/filesystem.hpp> 16 #include <ROOT/RVec.hxx> 18 #include <Math/GenVector/LorentzVector.h> 19 #include <Math/GenVector/PtEtaPhiM4D.h> 20 #include <Math/Vector4Dfwd.h> 46 RVec<float>
HadamardProduct(RVec<float> v1, RVec<RVec<float>> v2,
int v2subindex);
57 RVec<float>
MultiHadamardProduct(RVec<float> v1, RVec<RVec<RVec<float>>> Multiv2,
int v2subindex);
65 float DeltaPhi(
float phi1,
float phi2);
73 float DeltaR(ROOT::Math::PtEtaPhiMVector v1, ROOT::Math::PtEtaPhiMVector v2);
81 template<
class T1,
class T2>
83 ROOT::Math::PtEtaPhiMVector v1(in1.pt, in1.eta, in1.phi, in1.mass);
84 ROOT::Math::PtEtaPhiMVector v2(in2.pt, in2.eta, in2.phi, in2.mass);
85 float deta = v1.Eta()-v2.Eta();
86 float dphi =
DeltaPhi(v1.Phi(),v2.Phi());
87 return sqrt(deta*deta+dphi*dphi);
98 ROOT::Math::PtEtaPhiMVector
TLvector(
float pt,
float eta,
float phi,
float m);
108 RVec<ROOT::Math::PtEtaPhiMVector> TLvector(RVec<float> pt,RVec<float> eta,RVec<float> phi,RVec<float> m);
116 ROOT::Math::PtEtaPhiMVector TLvector(T obj) {
117 ROOT::Math::PtEtaPhiMVector v (obj.pt, obj.eta, obj.phi, obj.mass);
127 RVec<ROOT::Math::PtEtaPhiMVector> TLvector(std::vector<T> objs) {
128 RVec<ROOT::Math::PtEtaPhiMVector> vs;
129 vs.reserve(objs.size());
130 for (
size_t i = 0; i < objs.size(); i++) {
131 vs.emplace_back(objs[i].pt, objs[i].eta, objs[i].phi, objs[i].mass);
146 float TransverseMass(
float MET_pt,
float obj_pt,
float MET_phi,
float obj_phi);
156 double InvariantMass(RVec<ROOT::Math::PtEtaPhiMVector> vects);
166 return RVec<RVec<T>> (0);
169 for (
int i = 0; i < v[0].size(); i++) {
171 for (
int j = 0; j < v.size(); j++) {
172 inner.push_back(v[j][i]);
174 out.push_back(inner);
192 template <
typename IntType>
193 std::vector<IntType> Range(IntType start, IntType stop, IntType step) {
194 if (step == IntType(0)) {
195 throw std::invalid_argument(
"step for range must be non-zero");
198 std::vector<IntType> result;
200 while ((step > 0) ? (i < stop) : (i > stop)) {
217 template <
typename IntType>
218 std::vector<IntType> Range(IntType start, IntType stop) {
219 return Range(start, stop, IntType(1));
230 template <
typename IntType>
231 std::vector<IntType> Range(IntType stop) {
232 return Range(IntType(0), stop, IntType(1));
244 std::vector<std::string> Split(
const std::string& str,
char delim =
' ');
256 bool InList(T obj, std::vector<T> list) {
258 auto pos = std::find(std::begin(list), std::end(list), obj);
259 if (pos != std::end(list)){
261 }
else {out =
false;}
273 bool InString(std::string sub, std::string main);
283 void Extend(std::vector<T> base, std::vector<T> extension) {
284 for (
int i = 0; i < extension.size(); i++) {
285 base.push_back(extension.at(i));
296 bool IsDir(
char* dirname);
302 void Execute(std::string cmd);
313 std::string ReadTarFile(std::string tarname, std::string internalFile);
320 const boost::filesystem::path _path;
321 std::vector<std::string> _filesSaved;
342 std::string Write(std::string filename, std::string in);
C++ namespace for common physics functions.
float DeltaR(ROOT::Math::PtEtaPhiMVector v1, ROOT::Math::PtEtaPhiMVector v2)
Calculate between two vectors.
Definition: common.cc:43
RVec< float > HadamardProduct(RVec< float > v1, RVec< float > v2)
Hadamard product of two vectors (v3[i] = v1[i]*v2[i])
Definition: common.cc:5
double InvariantMass(RVec< ROOT::Math::PtEtaPhiMVector > vects)
Calculates the invariant mass of a vector of Lorentz vectors (ROOT::Math::PtEtaPhiMVector). Note that this is an alternative to ROOT::VecOps::InvariantMasses() which does not need the intermediate Lorentz vector.
Definition: common.cc:66
RVec< RVec< T > > Transpose(RVec< RVec< T >> v)
Transpose a vector so that output[j][i] = input[i][j].
Definition: common.h:164
float DeltaPhi(float phi1, float phi2)
Calculate the difference in .
Definition: common.cc:36
C++ class. Creates a temporary directory that is destroyed on delete.
Definition: common.h:318
RVec< float > MultiHadamardProduct(RVec< float > v1, RVec< RVec< RVec< float >>> Multiv2, int v2subindex)
Hadamard product of a base vector and a list of N more vectors (vout[i] = v1[i]*v2[i][v2subindex]*v3[...
Definition: common.cc:23
ROOT::Math::PtEtaPhiMVector TLvector(float pt, float eta, float phi, float m)
Create a ROOT::Math::PtEtaPhiMVector.
Definition: common.cc:49
float TransverseMass(float MET_pt, float obj_pt, float MET_phi, float obj_phi)
Calculate the transverse mass from MET and and an object's and .
Definition: common.cc:62