|
| 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 | + |
| 12 | +/// @file ClusterReaderSpec.h |
| 13 | +/// @brief Reads the TRK or FT3 clusters the cluster writer stored, one stream per layer |
| 14 | + |
| 15 | +#ifndef O2_TRK_CLUSTERREADER |
| 16 | +#define O2_TRK_CLUSTERREADER |
| 17 | + |
| 18 | +#include <memory> |
| 19 | +#include <string> |
| 20 | +#include <vector> |
| 21 | + |
| 22 | +#include "TFile.h" |
| 23 | +#include "TTree.h" |
| 24 | +#include "DataFormatsTRKFT3/Cluster.h" |
| 25 | +#include "DataFormatsTRKFT3/ROFRecord.h" |
| 26 | +#include "SimulationDataFormat/MCCompLabel.h" |
| 27 | +#include "SimulationDataFormat/MCTruthContainer.h" |
| 28 | +#include "Framework/DataProcessorSpec.h" |
| 29 | +#include "Framework/Task.h" |
| 30 | +#include "TRKBase/AlmiraParam.h" |
| 31 | + |
| 32 | +namespace o2::trk |
| 33 | +{ |
| 34 | + |
| 35 | +template <int DetID> |
| 36 | +class ClusterReader : public framework::Task |
| 37 | +{ |
| 38 | + public: |
| 39 | + explicit ClusterReader(bool useMC); |
| 40 | + void init(framework::InitContext& ic) final; |
| 41 | + void run(framework::ProcessingContext& pc) final; |
| 42 | + |
| 43 | + static constexpr int NLayers = DetID == o2::detectors::DetID::TRK ? static_cast<int>(o2::trk::AlmiraParam::kNLayers) : o2::trk::constants::MLOTDisks::nLayers; |
| 44 | + |
| 45 | + private: |
| 46 | + void connectTree(const std::string& filename); |
| 47 | + template <typename Ptr> |
| 48 | + void setBranchAddress(const std::string& base, int layer, Ptr& address); |
| 49 | + |
| 50 | + std::vector<std::vector<o2::trkft3::Cluster<DetID>>*> mClusters; |
| 51 | + std::vector<std::vector<unsigned char>*> mPatterns; |
| 52 | + std::vector<std::vector<o2::trkft3::ROFRecord>*> mROFs; |
| 53 | + std::vector<o2::dataformats::MCTruthContainer<o2::MCCompLabel>*> mLabels; |
| 54 | + |
| 55 | + std::unique_ptr<TFile> mFile; |
| 56 | + std::unique_ptr<TTree> mTree; |
| 57 | + bool mUseMC = true; |
| 58 | +}; |
| 59 | + |
| 60 | +using TRKClusterReader = ClusterReader<o2::detectors::DetID::TRK>; |
| 61 | +using FT3ClusterReader = ClusterReader<o2::detectors::DetID::FT3>; |
| 62 | + |
| 63 | +/// The reader of \a defname, by default the cluster writer's file. |
| 64 | +framework::DataProcessorSpec getTRKClusterReaderSpec(bool useMC = true, std::string defname = "o2clus_trk.root"); |
| 65 | +framework::DataProcessorSpec getFT3ClusterReaderSpec(bool useMC = true, std::string defname = "o2clus_ft3.root"); |
| 66 | + |
| 67 | +} // namespace o2::trk |
| 68 | + |
| 69 | +#endif |
0 commit comments