12 #include <boost/filesystem.hpp> 16 #include <ROOT/RVec.hxx> 20 #include <Math/GenVector/LorentzVector.h> 21 #include <Math/GenVector/PtEtaPhiM4D.h> 22 #include <Math/Vector4Dfwd.h> 39 TFile *
Open(std::string file,
bool inTIMBER =
true,
const char *option =
"READ");
49 TH1 *
LoadHist(std::string filename, std::string histname,
bool inTIMBER =
true);
68 RVec<float>
HadamardProduct(RVec<float> v1, RVec<RVec<float>> v2,
int v2subindex);
87 RVec<float>
MultiHadamardProduct(RVec<float> v1, RVec<RVec<RVec<float>>> Multiv2,
int v2subindex);
95 float DeltaPhi(
float phi1,
float phi2);
103 float DeltaR(ROOT::Math::PtEtaPhiMVector v1, ROOT::Math::PtEtaPhiMVector v2);
111 template<
class T1,
class T2>
113 ROOT::Math::PtEtaPhiMVector v1(in1.pt, in1.eta, in1.phi, in1.mass);
114 ROOT::Math::PtEtaPhiMVector v2(in2.pt, in2.eta, in2.phi, in2.mass);
115 float deta = v1.Eta()-v2.Eta();
116 float dphi =
DeltaPhi(v1.Phi(),v2.Phi());
117 return sqrt(deta*deta+dphi*dphi);
128 ROOT::Math::PtEtaPhiMVector
TLvector(
float pt,
float eta,
float phi,
float m);
138 RVec<ROOT::Math::PtEtaPhiMVector> TLvector(RVec<float> pt,RVec<float> eta,RVec<float> phi,RVec<float> m);
146 ROOT::Math::PtEtaPhiMVector TLvector(T obj) {
147 ROOT::Math::PtEtaPhiMVector v (obj.pt, obj.eta, obj.phi, obj.mass);
157 RVec<ROOT::Math::PtEtaPhiMVector> TLvector(std::vector<T> objs) {
158 RVec<ROOT::Math::PtEtaPhiMVector> vs;
159 vs.reserve(objs.size());
160 for (
size_t i = 0; i < objs.size(); i++) {
161 vs.emplace_back(objs[i].pt, objs[i].eta, objs[i].phi, objs[i].mass);
176 float TransverseMass(
float MET_pt,
float obj_pt,
float MET_phi,
float obj_phi);
186 double InvariantMass(RVec<ROOT::Math::PtEtaPhiMVector> vects);
196 return RVec<RVec<T>> (0);
199 for (
int i = 0; i < v[0].size(); i++) {
201 for (
int j = 0; j < v.size(); j++) {
202 inner.push_back(v[j][i]);
204 out.push_back(inner);
222 template <
typename IntType>
223 std::vector<IntType> Range(IntType start, IntType stop, IntType step) {
224 if (step == IntType(0)) {
225 throw std::invalid_argument(
"step for range must be non-zero");
228 std::vector<IntType> result;
230 while ((step > 0) ? (i < stop) : (i > stop)) {
247 template <
typename IntType>
248 std::vector<IntType> Range(IntType start, IntType stop) {
249 return Range(start, stop, IntType(1));
260 template <
typename IntType>
261 std::vector<IntType> Range(IntType stop) {
262 return Range(IntType(0), stop, IntType(1));
274 std::vector<std::string> Split(
const std::string& str,
char delim =
' ');
286 int InList(T obj, std::vector<T> list) {
288 auto pos = std::find(std::begin(list), std::end(list), obj);
289 if (pos != std::end(list)){
290 out = pos - std::begin(list);
303 bool InString(std::string sub, std::string main);
313 void Extend(std::vector<T> base, std::vector<T> extension) {
314 for (
int i = 0; i < extension.size(); i++) {
315 base.push_back(extension.at(i));
326 bool IsDir(
char* dirname);
332 void Execute(std::string cmd);
343 std::string ReadTarFile(std::string tarname, std::string internalFile);
350 const boost::filesystem::path _path;
351 std::vector<std::string> _filesSaved;
372 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:72
RVec< float > HadamardProduct(RVec< float > v1, RVec< float > v2)
Hadamard product of two vectors (v3[i] = v1[i]*v2[i])
Definition: common.cc:21
TH1 * LoadHist(std::string filename, std::string histname, bool inTIMBER=true)
Generically open a histogram from a file into memory (closing the file in the process).
Definition: common.cc:13
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:95
RVec< RVec< T > > Transpose(RVec< RVec< T >> v)
Transpose a vector so that output[j][i] = input[i][j].
Definition: common.h:194
TFile * Open(std::string file, bool inTIMBER=true, const char *option="READ")
Open a ROOT file inside the TIMBER path. Thsi function essentially just does the char + string format...
Definition: common.cc:5
RVec< float > MultiHadamardProduct(RVec< float > v1, RVec< RVec< float >> Multiv2)
Hadamard product of a base vector and a list of N more vectors (vout[i] = v1[i]*v2[i]*v3[i]...).
Definition: common.cc:39
float DeltaPhi(float phi1, float phi2)
Calculate the difference in .
Definition: common.cc:65
C++ class. Creates a temporary directory that is destroyed on delete.
Definition: common.h:348
ROOT::Math::PtEtaPhiMVector TLvector(float pt, float eta, float phi, float m)
Create a ROOT::Math::PtEtaPhiMVector.
Definition: common.cc:78
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:91