Project
Loading...
Searching...
No Matches
CompressedAnalysisTask.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
16
17#ifndef O2_TOF_COMPRESSEDANALYSISTASK
18#define O2_TOF_COMPRESSEDANALYSISTASK
19
20#include "Framework/Task.h"
22
23#include "TROOT.h"
24#include "TSystem.h"
25#include "TGlobal.h"
26#include "TFunction.h"
27#include <string>
28#include <iostream>
29
30using namespace o2::framework;
31
32namespace o2
33{
34namespace tof
35{
36
38{
39 public:
41 ~CompressedAnalysisTask() override = default;
42 void init(InitContext& ic) final;
43 void run(ProcessingContext& pc) final;
44
45 private:
46 CompressedAnalysis* mAnalysis = nullptr;
47 bool mStatus = false;
48
49 template <typename T>
50 T GetFromMacro(const std::string& file, const std::string& funcname, const std::string& type, const std::string& unique)
51 {
52
54 auto func = funcname;
55 if (func.empty()) {
56 auto size = file.size();
57 auto firstindex = file.find_last_of("/") + 1;
58 auto lastindex = file.find_last_of(".");
59 func = file.substr(firstindex < size ? firstindex : 0,
60 lastindex < size ? lastindex - firstindex : size - firstindex) +
61 "()";
62 }
63 auto gfunc = func.substr(0, func.find_first_of('('));
64
66 if (!gROOT->GetGlobalFunction(gfunc.c_str())) {
67 if (gROOT->LoadMacro(file.c_str()) != 0) {
68 std::cout << "Cannot find " << file << std::endl;
69 return nullptr;
70 }
71 if (!gROOT->GetGlobalFunction(gfunc.c_str())) {
72 std::cout << "Global function '" << gfunc << "' not defined" << std::endl;
73 return nullptr;
74 }
75 }
76
78 if (strcmp(gROOT->GetGlobalFunction(gfunc.c_str())->GetReturnTypeName(), type.c_str())) {
79 std::cout << "Global function '" << gfunc << "' does not return a '" << type << "' type" << std::endl;
80 return nullptr;
81 }
82
84 gROOT->ProcessLine(Form("%s __%s__ = %s;", type.c_str(), unique.c_str(), func.c_str()));
85 auto ptr = (T*)gROOT->GetGlobal(Form("__%s__", unique.c_str()))->GetAddress();
86
88 return *ptr;
89 }
90};
91
92} // namespace tof
93} // namespace o2
94
95#endif /* O2_TOF_COMPRESSEDANALYSISTASK */
TBranch * ptr
void run(ProcessingContext &pc) final
~CompressedAnalysisTask() override=default
GLenum func
Definition glcorearb.h:778
GLsizeiptr size
Definition glcorearb.h:659
GLint GLint GLsizei GLint GLenum GLenum type
Definition glcorearb.h:275
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...