Project
Loading...
Searching...
No Matches
DigitReader.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
17#include <fairlogger/Logger.h> // for LOG
18
19using namespace o2::emcal;
20using o2::emcal::Cell;
22
23//______________________________________________________________________________
24template <class InputType>
25void DigitReader<InputType>::openInput(const std::string fileName)
26{
27 clear();
28 if (!(mInputTree = o2::utils::RootChain::load("o2sim", fileName))) {
29 LOG(fatal) << "Failed to load cells/digits tree from " << fileName;
30 }
31
32 if constexpr (std::is_same<InputType, Digit>::value) {
33 mInputTree->SetBranchAddress("EMCALDigit", &mInputArray);
34 if (!mInputArray) {
35 LOG(fatal) << "Failed to find EMCALDigit branch in the " << mInputTree->GetName()
36 << " from file " << fileName;
37 }
38 mInputTree->SetBranchAddress("EMCALDigitTRGR", &mTriggerArray);
39 if (!mTriggerArray) {
40 LOG(fatal) << "Failed to find TriggerRecords branch in the " << mInputTree->GetName()
41 << " from file " << fileName;
42 }
43 } else if constexpr (std::is_same<InputType, Cell>::value) {
44 mInputTree->SetBranchAddress("EMCALCell", &mInputArray);
45 if (!mInputArray) {
46 LOG(fatal) << "Failed to find EMCALCell branch in the " << mInputTree->GetName()
47 << " from file " << fileName;
48 }
49 mInputTree->SetBranchAddress("EMCALCellTRGR", &mTriggerArray);
50 if (!mTriggerArray) {
51 LOG(fatal) << "Failed to find TriggerRecords branch in the " << mInputTree->GetName()
52 << " from file " << fileName;
53 }
54 }
55}
56
57//______________________________________________________________________________
58template <class InputType>
60{
61 // Load next entry from the self-managed input
62
63 if (mCurrentEntry >= mInputTree->GetEntriesFast()) {
64 return false;
65 }
66
67 mInputTree->GetEntry(mCurrentEntry);
68 mCurrentEntry++;
69 return true;
70}
71
72//______________________________________________________________________________
73template <class InputType>
75{
76 // clear data structures
77 mInputTree.reset(); // here we reset the unique ptr, not the tree!
78}
79
Definition of EMCAL cell/digit reader.
EMCAL compressed cell information.
Definition Cell.h:59
DigitReader class for EMCAL. Loads cells/digits and feeds them to clusterizer.
Definition DigitReader.h:33
void openInput(const std::string fileName)
EMCAL digit implementation.
Definition Digit.h:34
static std::unique_ptr< TChain > load(const std::string trName, const std::string inpFile)
Definition RootChain.cxx:21
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
vec clear()