-
Notifications
You must be signed in to change notification settings - Fork 494
Expand file tree
/
Copy pathClustererTask.cxx
More file actions
131 lines (108 loc) · 4.63 KB
/
ClustererTask.cxx
File metadata and controls
131 lines (108 loc) · 4.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// 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.
/// \file ClustererTask.cxx
/// \brief Implementation of the TPC Clusterer Task
#include "TPCReconstruction/ClustererTask.h"
#include <fairlogger/Logger.h> // for LOG
#include "FairRootManager.h" // for FairRootManager
ClassImp(o2::tpc::ClustererTask);
using namespace o2::tpc;
using namespace o2::dataformats;
//_____________________________________________________________________
ClustererTask::ClustererTask(int sectorid)
: FairTask("TPCClustererTask"),
mClusterSector(sectorid),
mHwClusterer(),
mDigitsArray(),
mDigitMCTruthArray(),
mHwClustersArray(),
mHwClustersMCTruthArray()
{
}
//_____________________________________________________________________
/// \brief Init function
/// Inititializes the clusterer and connects input and output container
InitStatus ClustererTask::Init()
{
LOG(debug) << "Enter Initializer of ClustererTask";
FairRootManager* mgr = FairRootManager::Instance();
if (!mgr) {
LOG(error) << "Could not instantiate FairRootManager. Exiting ...";
return kERROR;
}
if (mClusterSector < 0 || mClusterSector >= Sector::MAXSECTOR) {
LOG(error) << "Sector ID " << mClusterSector << " is not supported. Exiting ...";
return kERROR;
}
// Register input container
std::stringstream sectornamestr;
sectornamestr << "TPCDigit" << mClusterSector;
LOG(info) << "FETCHING DIGITS FOR SECTOR " << mClusterSector << "\n";
mDigitsArray = std::unique_ptr<const std::vector<Digit>>(
mgr->InitObjectAs<const std::vector<Digit>*>(sectornamestr.str().c_str()));
if (!mDigitsArray) {
LOG(error) << "TPC points not registered in the FairRootManager. Exiting ...";
return kERROR;
}
std::stringstream mcsectornamestr;
mcsectornamestr << "TPCDigitMCTruth" << mClusterSector;
mDigitMCTruthArray = std::unique_ptr<const ConstMCLabelContainerView>(
mgr->InitObjectAs<const ConstMCLabelContainerView*>(mcsectornamestr.str().c_str()));
if (!mDigitMCTruthArray) {
LOG(error) << "TPC MC Truth not registered in the FairRootManager. Exiting ...";
return kERROR;
}
// Register output container
mHwClustersArray = std::make_unique<std::vector<OutputType>>();
// a trick to register the unique pointer with FairRootManager
static auto clusterArrayTmpPtr = mHwClustersArray.get();
mgr->RegisterAny(Form("TPCClusterHW%i", mClusterSector), clusterArrayTmpPtr, kTRUE);
// Register MC Truth output container
mHwClustersMCTruthArray = std::make_unique<MCLabelContainer>();
// a trick to register the unique pointer with FairRootManager
static auto clusterMcTruthTmpPtr = mHwClustersMCTruthArray.get();
mgr->RegisterAny(Form("TPCClusterHWMCTruth%i", mClusterSector), clusterMcTruthTmpPtr, kTRUE);
// create clusterer and pass output pointer
mHwClusterer = std::make_unique<HwClusterer>(mHwClustersArray.get(), mClusterSector, mHwClustersMCTruthArray.get());
mHwClusterer->setContinuousReadout(mIsContinuousReadout);
// TODO: implement noise/pedestal objects
// mHwClusterer->setNoiseObject(...);
// mHwClusterer->setPedestalObject(...);
return kSUCCESS;
}
//_____________________________________________________________________
void ClustererTask::Exec(Option_t* option)
{
LOG(debug) << "Running clusterization on event " << mEventCount << " with " << mDigitsArray->size() << " digits.";
if (mHwClustersArray) {
mHwClustersArray->clear();
}
if (mHwClustersMCTruthArray) {
mHwClustersMCTruthArray->clear();
}
mHwClusterer->process(gsl::span<o2::tpc::Digit const>(mDigitsArray->data(), mDigitsArray->size()), *mDigitMCTruthArray.get());
LOG(debug) << "Hw clusterer delivered " << mHwClustersArray->size() << " cluster container";
++mEventCount;
}
//_____________________________________________________________________
void ClustererTask::FinishTask()
{
LOG(debug) << "Finish clusterization";
if (mHwClustersArray) {
mHwClustersArray->clear();
}
if (mHwClustersMCTruthArray) {
mHwClustersMCTruthArray->clear();
}
mHwClusterer->finishProcess(*mDigitsArray.get(), *mDigitMCTruthArray.get());
LOG(debug) << "Hw clusterer delivered " << mHwClustersArray->size() << " cluster container";
++mEventCount;
}