|
| 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 | +#include "StatusMapReaderSpec.h" |
| 13 | + |
| 14 | +#include <memory> |
| 15 | +#include <string> |
| 16 | + |
| 17 | +#include "Framework/ConfigParamRegistry.h" |
| 18 | +#include "Framework/ConfigParamSpec.h" |
| 19 | +#include "Framework/ControlService.h" |
| 20 | +#include "Framework/InitContext.h" |
| 21 | +#include "Framework/Lifetime.h" |
| 22 | +#include "Framework/OutputSpec.h" |
| 23 | +#include "Framework/ProcessingContext.h" |
| 24 | +#include "Framework/Task.h" |
| 25 | + |
| 26 | +#include "DPLUtils/RootTreeReader.h" |
| 27 | +#include "CommonUtils/StringUtils.h" |
| 28 | +#include "MCHStatus/StatusMap.h" |
| 29 | + |
| 30 | +using namespace o2::framework; |
| 31 | + |
| 32 | +namespace o2::mch |
| 33 | +{ |
| 34 | + |
| 35 | +struct StatusMapReader { |
| 36 | + std::unique_ptr<RootTreeReader> mTreeReader; |
| 37 | + |
| 38 | + void init(InitContext& ic) |
| 39 | + { |
| 40 | + auto fileName = o2::utils::Str::concat_string(o2::utils::Str::rectifyDirectory(ic.options().get<std::string>("input-dir")), ic.options().get<std::string>("infile")); |
| 41 | + mTreeReader = std::make_unique<RootTreeReader>( |
| 42 | + "o2sim", |
| 43 | + fileName.c_str(), |
| 44 | + -1, |
| 45 | + RootTreeReader::PublishingMode::Single, |
| 46 | + RootTreeReader::BranchDefinition<StatusMap>{Output{"MCH", "STATUSMAP", 0}, "statusmaps"}); |
| 47 | + } |
| 48 | + |
| 49 | + void run(ProcessingContext& pc) |
| 50 | + { |
| 51 | + if (mTreeReader->next()) { |
| 52 | + (*mTreeReader)(pc); |
| 53 | + } else { |
| 54 | + pc.services().get<ControlService>().endOfStream(); |
| 55 | + } |
| 56 | + } |
| 57 | +}; |
| 58 | + |
| 59 | +DataProcessorSpec getStatusMapReaderSpec(const char* specName) |
| 60 | +{ |
| 61 | + return DataProcessorSpec{ |
| 62 | + specName, |
| 63 | + Inputs{}, |
| 64 | + Outputs{OutputSpec{{"statusmaps"}, "MCH", "STATUSMAP", 0, Lifetime::Timeframe}}, |
| 65 | + adaptFromTask<StatusMapReader>(), |
| 66 | + Options{{"infile", VariantType::String, "mchstatusmaps.root", {"name of the input status map file"}}, |
| 67 | + {"input-dir", VariantType::String, "none", {"Input directory"}}}}; |
| 68 | +} |
| 69 | + |
| 70 | +} // namespace o2::mch |
0 commit comments