Project
Loading...
Searching...
No Matches
ClustererTask.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.
11
14
16#include "MathUtils/Cartesian.h"
17#include "MathUtils/Utils.h"
20
21#include <fairlogger/Logger.h> // for LOG
22#include "FairRootManager.h" // for FairRootManager
23
25
26using namespace o2::tof;
27
28//_____________________________________________________________________
29ClustererTask::ClustererTask(Bool_t useMCTruth) : FairTask("TOFClustererTask")
30{
31 if (useMCTruth) {
33 }
34}
35
36//_____________________________________________________________________
38{
39 if (mClustersArray) {
40 mClustersArray->clear();
41 delete mClustersArray;
42 }
43 if (mClsLabels) {
44 mClsLabels->clear();
45 delete mClsLabels;
46 }
47}
48//_____________________________________________________________________
52{
53 FairRootManager* mgr = FairRootManager::Instance();
54 if (!mgr) {
55 LOG(error) << "Could not instantiate FairRootManager. Exiting ...";
56 return kERROR;
57 }
58
59 const gsl::span<const o2::tof::Digit>* arr = mgr->InitObjectAs<const gsl::span<const o2::tof::Digit>*>("TOFDigit");
60 if (!arr) {
61 LOG(error) << "TOF digits not registered in the FairRootManager. Exiting ...";
62 return kERROR;
63 }
64 mReader.setDigitArray(arr);
65
66 if (mClsLabels) { // here we take the array of labels used for the digits
67 mDigitMCTruth =
68 mgr->InitObjectAs<const dataformats::MCTruthContainer<MCCompLabel>*>("TOFDigitMCTruth");
69 if (!mDigitMCTruth) {
70 LOG(error) << "TOF MC Truth not registered in the FairRootManager. Exiting ...";
71 return kERROR;
72 }
73 }
74
75 // Register output container
76 mgr->RegisterAny("TOFCluster", mClustersArray, kTRUE);
77
78 // Register new MC Truth container --> here we will now associate to the clusters all labels that belonged to all digits that formed that cluster
79 if (mClsLabels) {
80 mgr->RegisterAny("TOFClusterMCTruth", mClsLabels, kTRUE);
81 }
82
83 mClusterer.setMCTruthContainer(mClsLabels);
84
85 return kSUCCESS;
86}
87
88//_____________________________________________________________________
89void ClustererTask::Exec(Option_t* option)
90{
91 if (mClustersArray) {
92 mClustersArray->clear();
93 }
94 if (mClsLabels) {
95 mClsLabels->clear();
96 }
97 LOG(debug) << "Running clusterization on new event";
98
99 mClusterer.process(mReader, *mClustersArray, mDigitMCTruth);
100}
General auxilliary methods.
Definition of a container to keep Monte Carlo truth external to simulation objects.
Definition of the TOF cluster finder task.
ClassImp(o2::tof::ClustererTask)
std::ostringstream debug
A container to hold and manage MC truth information/labels.
void Exec(Option_t *option) override
ClustererTask(Bool_t useMCTruth=kTRUE)
InitStatus Init() override
Init function Inititializes the clusterer and connects input and output container.
void process(DataReader &r, std::vector< Cluster > &clusters, MCLabelContainer const *digitMCTruth)
Definition Clusterer.cxx:25
void setMCTruthContainer(o2::dataformats::MCTruthContainer< o2::MCCompLabel > *truth)
Definition Clusterer.h:50
void setDigitArray(const gsl::span< const o2::tof::Digit > *a)
Definition DataReader.h:63
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"