Project
Loading...
Searching...
No Matches
o2AnalysisTaskExample.cxx
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.
14
15#include <TFile.h>
16#include <TH1F.h>
17
18using namespace o2;
19using namespace o2::framework;
20
21// This is a stateful task, where we send the state downstream.
22struct ATask {
24
25 // explicit ATask(int state)
26 // : mSomeState{state} {}
27
28 void init(InitContext& ic)
29 {
30 }
31
33 {
34 }
35
36 void process(aod::Tracks const& tracks)
37 {
38 auto hPhi = new TH1F("phi", "Phi", 100, 0, 2 * M_PI);
39 auto hEta = new TH1F("eta", "Eta", 100, 0, 2 * M_PI);
40 for (auto& track : tracks) {
41 auto phi = asin(track.snp()) + track.alpha() + M_PI;
42 auto eta = log(tan(0.25 * M_PI - 0.5 * atan(track.tgl())));
43 hPhi->Fill(phi);
44 hEta->Fill(eta);
45 }
46 TFile f("result1.root", "RECREATE");
47 hPhi->SetName("Phi");
48 hPhi->Write();
49 hEta->SetName("Eta");
50 hEta->Write();
51 }
52};
53
55{
56 return WorkflowSpec{
57 adaptAnalysisTask<ATask>(cfgc, TaskName{"mySimpleTrackAnalysis"})};
58}
GLdouble f
Definition glcorearb.h:310
Defining PrimaryVertex explicitly as messageable.
Definition TFIDInfo.h:20
std::vector< DataProcessorSpec > WorkflowSpec
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...
WorkflowSpec defineDataProcessing(ConfigContext const &cfgc)
This function hooks up the the workflow specifications into the DPL driver.
void run(ProcessingContext &pc)
void process(aod::Tracks const &tracks)
Service< TimingInfo > info
void init(InitContext &ic)
Struct to differentiate task names from possible task string arguments.