FileReader.h 3.13 KB
Newer Older
 Simon Spannagel committed Aug 23, 2019 1 2 3 4 5 6 7 8 9 10 11 12 /** * @file * @brief Definition of ROOT data file reader module * @copyright Copyright (c) 2017-2019 CERN and the Corryvreckan authors. * This software is distributed under the terms of the MIT License, copied verbatim in the file "LICENSE.md". * 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. */ #include #include #include  Daniel Hynds committed Jan 29, 2016 13   Simon Spannagel committed Oct 26, 2018 14 15 #include #include  Simon Spannagel committed Aug 23, 2019 16   Simon Spannagel committed Apr 16, 2018 17 #include "core/module/Module.hpp"  Daniel Hynds committed Jan 29, 2016 18   19 namespace corryvreckan {  Simon Spannagel committed Aug 23, 2019 20 21 22  /** * @ingroup Modules * @brief Module to read data stored in ROOT file back to the Corryvreckan clipboard  Simon Spannagel committed Aug 27, 2019 23  * @remarks The implementation of this module is based on the ROOTObjectReader module of the Allpix Squared project  Simon Spannagel committed Aug 23, 2019 24 25 26  * * Reads the tree of objects in the data format of the \ref FileWriter module. Copies all stored objects that are * supported back to the clipboard.  Simon Spannagel committed Jan 23, 2018 27  */  Simon Spannagel committed Apr 16, 2018 28  class FileReader : public Module {  Simon Spannagel committed Oct 09, 2017 29  public:  Simon Spannagel committed Aug 23, 2019 30  using ObjectCreatorMap =  Simon Spannagel committed Aug 24, 2019 31 32  std::map, std::string detector, std::shared_ptr clipboard)>>;  Simon Spannagel committed Aug 23, 2019 33 34 35 36 37 38  /** * @brief Constructor for this global module * @param config Configuration object for this module as retrieved from the steering file * @param detectors List of detectors to perform task on */  Simon Spannagel committed Oct 26, 2018 39  FileReader(Configuration config, std::vector> detectors);  Simon Spannagel committed Aug 23, 2019 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  /** * @brief Destructor deletes the internal objects read from ROOT Tree */ ~FileReader() override; /** * @brief Open the ROOT file containing the stored output data */ void initialise() override; /** * @brief Move the objects stored for the current event to the clipboard */ StatusCode run(std::shared_ptr clipboard) override; /** * @brief Output summary and close the ROOT file */ void finalise() override; private: /** * @brief Internal object storing objects and information to construct a message from tree */ struct object_info { std::vector* objects; std::string detector; }; // Object names to include or exclude from reading std::set include_; std::set exclude_; // File containing the objects std::unique_ptr input_file_; // Object trees in the file std::vector trees_;  Simon Spannagel committed Aug 24, 2019 78  TTree* event_tree_{nullptr};  Simon Spannagel committed Aug 24, 2019 79  Event* event_{};  Simon Spannagel committed Aug 23, 2019 80 81 82 83 84 85 86 87 88 89 90 91  // List of objects and detector information converted from the trees std::list object_info_array_; // Statistics for total amount of objects stored unsigned long read_cnt_{}; // Counter for number of events read: int event_num_{}; // Internal map to construct an object from it's type index ObjectCreatorMap object_creator_map_;  Simon Spannagel committed Oct 09, 2017 92  };  Simon Spannagel committed Aug 23, 2019 93 } // namespace allpix