Project
Loading...
Searching...
No Matches
Utils.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#ifndef ALICEO2_TPC_UTILS_H_
13#define ALICEO2_TPC_UTILS_H_
14
19
20#include <string>
21#include <vector>
22#include <string_view>
23
24#include "TPCBase/CalDet.h"
25
26class TObjArray;
27class TCanvas;
28class TH1;
29class TChain;
30
31namespace o2::tpc
32{
33
41
42namespace utils
43{
44
45const std::vector<std::string> tokenize(const std::string_view input, const std::string_view pattern);
46TH1* getBinInfoXY(int& binx, int& biny, float& bincx, float& bincy);
47void addFECInfo();
48void saveCanvases(TObjArray& arr, std::string_view outDir, std::string_view types = "png,pdf", std::string_view rootFileName = "", std::string nameAdd = "");
49void saveCanvases(std::vector<TCanvas*>& canvases, std::string_view outDir, std::string_view types = "png,pdf", std::string_view rootFileName = "", std::string nameAdd = "");
50void saveCanvas(TCanvas& c, std::string_view outDir, std::string_view types, std::string nameAdd = "");
51std::vector<CalPad*> readCalPads(const std::string_view fileName, const std::vector<std::string>& calPadNames);
52std::vector<CalPad*> readCalPads(const std::string_view fileName, const std::string_view calPadNames);
53
61void mergeCalPads(std::string_view outputFileName, std::string_view inputFileNames, std::string_view calPadNames, bool average = false);
62
71TChain* buildChain(std::string_view command, std::string_view treeName, std::string_view treeTitle = "", bool checkSubDir = false);
72
73template <typename Iterator>
74std::string elementsToString(Iterator begin, Iterator end, const std::string separator = ", ")
75{
76 return std::accumulate(std::next(begin), end, std::to_string(*begin),
77 [&separator](auto s, auto f) { return std::move(s) + separator + std::to_string(f); });
78}
79
80template <typename T>
81std::string elementsToString(const T& val, const std::string separator = ", ")
82{
83 return elementsToString(val.begin(), val.end(), separator);
84}
85
86} // namespace utils
87} // namespace o2::tpc
88
89#endif
uint32_t c
Definition RawData.h:2
GLuint GLuint end
Definition glcorearb.h:469
GLsizei GLenum GLenum * types
Definition glcorearb.h:2516
GLdouble f
Definition glcorearb.h:310
GLuint GLfloat * val
Definition glcorearb.h:1582
const std::vector< std::string > tokenize(const std::string_view input, const std::string_view pattern)
Definition Utils.cxx:40
std::vector< CalPad * > readCalPads(const std::string_view fileName, const std::vector< std::string > &calPadNames)
Definition Utils.cxx:190
TH1 * getBinInfoXY(int &binx, int &biny, float &bincx, float &bincy)
Definition Utils.cxx:50
std::string elementsToString(Iterator begin, Iterator end, const std::string separator=", ")
Definition Utils.h:74
void addFECInfo()
Definition Utils.cxx:78
void mergeCalPads(std::string_view outputFileName, std::string_view inputFileNames, std::string_view calPadNames, bool average=false)
Definition Utils.cxx:226
void saveCanvases(TObjArray &arr, std::string_view outDir, std::string_view types="png,pdf", std::string_view rootFileName="", std::string nameAdd="")
Definition Utils.cxx:136
TChain * buildChain(std::string_view command, std::string_view treeName, std::string_view treeTitle="", bool checkSubDir=false)
Definition Utils.cxx:278
void saveCanvas(TCanvas &c, std::string_view outDir, std::string_view types, std::string nameAdd="")
Definition Utils.cxx:179
Global TPC definitions and constants.
Definition SimTraits.h:167
Enum< T >::Iterator begin(Enum< T >)
Definition Defs.h:173
std::string to_string(gsl::span< T, Size > span)
Definition common.h:52
Common utility functions.
std::array< uint16_t, 5 > pattern