用脚轻松学O2
cmake
${PROJECT_NAME}是一个宏
In-Place Build
In-place builds generate all temporary build files in the same directory structure as the source code. This means that all Makefiles and object files are interspersed with your normal code. To create an in-place build target run the cmake command in your root directory.
Out-of-Source Build
Out-of-source builds allow you to create a single build folder that can be anywhere on your file system. All temporary build and object files are located in this directory keeping your source tree clean. To create an out-of-source build run the cmake command in the build folder and point it to the directory with your root CMakeLists.txt file. Using out-of-source builds if you want to recreate your cmake environment from scratch, you only need to delete your build directory and then rerun cmake.
总结,其实这两都一样,你给cmake后面接上路径就行
set(SOURCES src/Hello.cpp src/main.cpp ) add_executable(${PROJECT_NAME} ${SOURCES})
用GLOB也行
这个target要改成project name
大致意思:先定义一些libraries,这些包含一些CPP,然后呢把这个library的声明关联给这个library,然后生成可执行文件并把libraries链接给这个文件
像之前的代码就是:直接把所有文件变成可执行文件,然后再把headers链接给他
c++
总结:省内存
这个命令的后面几个可以找到,但是为什么前面是analysistutorial-mm?,未找到
data format
数据为AOD格式,但是存储的是root格式
The result of the asynchronous reconstruction is the Analysis Object Data (AOD) format, which is a set of tables which are stored to file (by default AO2D.root) as ROOT trees.
总结:SQL的链接
总结,不知道有啥用
对于表中的每个索引,都有一种方法可以获取相应的对象。例如,在表 aod::Tracks 中有一个索引 collisionId。因此,如果您有一个名为 track 的对象 aod::Track,则可以通过调用 track.collision() 直接访问此轨道的碰撞。您还可以在执行此操作之前检查您感兴趣的轨道是否发生碰撞,方法是使用模板函数 .has_smthg(),在此示例中使用 track.has_collision(),它返回一个布尔值。对象 track.collision() 的类型是 o2::aod::Collision。这适用于每个表中的每个索引,因此调用例如 collision.bc() 会为您提供您正在处理的碰撞的 bc。然后您可以调用例如 collision.bc().globalBC()。
总结:有用,但是现在暂时不明白
总结:这是用一个缩写表示类型
task基础
总结:要用一种特殊格式写分析任务
类似于接口?
license还要写,好专业。。
上面这个图中的东西等效于cfgc(ConfigContext)
histograms
总结:这是创建一个histo,下面的histo注册可以方便地管理一批histo,但是我看不懂他再扯什么
这个语法是root的
看起来,histo的registry这里一开始是空的,后面需要再init里面add一些histo,如下
上图为定义图的坐标的
总结:上面那个是一次性获得所有track的,下面是一个一个获得,下面的方法可以使用并行
总结,当需要分析特定碰撞的时候使用这个
定义一个config
这样的好处是可以在json里面修改这个变量
下面的代码写露了init
分区/过滤
总结:按照数据大小分区数据
总结:过滤数据,注意:process里面的类型不一样了
总结:含有config的filter
链接两个表
仅两个表的大小相同才可以链接
注意filter里面的类型为Tracks,一定要记得process里面要写Filtered
需要一个cache来帮助slice,还需要传入collision的globalIndex(问题,如果我process无需collision的话该如何分片)
(猜想:若没有指定collision的需求,那么可以直接用for去读取leftTracks,若有指定collision的需求则需要去用slice)
分片加过滤的操作是一个逻辑and
join,这里把Tracks和TracksExtras join一起了,但是我不知道他具体指的是啥
筛选,注意需要一个头文件
运行时还要加一点东西
附录
// 简单的代码(没join)
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.
///
/// \brief This task is an empty skeleton that fills a simple eta histogram.
/// it is meant to be a blank page for further developments.
/// \author everyone
#include "Framework/runDataProcessing.h"
#include "Framework/AnalysisTask.h"
using namespace o2;
using namespace o2::framework;
struct myExampleTask {
// Histogram registry: an object to hold your histograms
HistogramRegistry histos{"histos", {}, OutputObjHandlingPolicy::AnalysisObject};
Configurable<int> nBinsEta{"nBinsEta", 30, "N bins in eta histo"};
Configurable<int> nBinsPt{"nBinsPt", 100, "N bins in pT histo"};
Configurable<double> axisEtaStart{"axisEtaStart", -1.5, "axisEtaStart"};
Configurable<double> axisEtaEnd{"axisEtaEnd", +1.5, "axisEtaend"};
Configurable<double> axisPtStart{"axisPtStart", 0.0, "axisEtaStart"};
Configurable<double> axisPtEnd{"axisPtEnd", +10.0, "axisEtaend"};
void init(InitContext const&)
{
// define axes you want to use
const AxisSpec axisEta{nBinsEta, axisEtaStart, axisEtaEnd, "#eta"};
const AxisSpec myaxisPt{nBinsPt, axisPtStart, axisPtEnd, "P_{t}"};
// create histograms
histos.add("etaHistogram", "etaHistogram", kTH1F, {axisEta});
histos.add("ptHistogram", "ptHistogram", kTH1F, {myaxisPt});
}
void process(aod::TracksIU const& tracks)
{
for (auto& track : tracks) {
histos.fill(HIST("etaHistogram"), track.eta());
histos.fill(HIST("ptHistogram"), track.pt());
}
}
};
WorkflowSpec defineDataProcessing(ConfigContext const& cfgc)
{
return WorkflowSpec{
adaptAnalysisTask<myExampleTask>(cfgc)};
}