xAODWriterAlg.h 2.4 KB
Newer Older
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
// Dear emacs, this is -*- c++ -*-
//
// Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
//
#ifndef STANDALONEANALYSISALGORITHMS_XAODWRITERALG_H
#define STANDALONEANALYSISALGORITHMS_XAODWRITERALG_H

// System include(s):
#include <string>
#include <vector>
#include <typeinfo>

// Core include(s):
#include "AnaAlgorithm/AnaAlgorithm.h"
#include "SystematicsHandles/SysListHandle.h"
#include "xAODRootAccess/TEvent.h"

namespace CP {

   /// Algorithm writing an xAOD output file
   ///
   /// This algorithm is meant to be used to write mini-xAOD output files from
   /// analysis jobs. Similar to how such a file could be written using an
   /// Athena job.
   ///
   /// @author Attila Krasznahorkay <Attila.Krasznahorkay@cern.ch>
   ///
   class xAODWriterAlg final : public EL::AnaAlgorithm {

   public:
      /// Algorithm constructor
      xAODWriterAlg( const std::string& name, ISvcLocator* svcLoc );

      /// @name Function(s) inherited from @c EL::AnaAlgorithm
      /// @{

      /// Function initialising the algorithm
      StatusCode initialize() override;

      /// Function executing the algorithm
      StatusCode execute() override;

      /// Function finalising the algorithm
      StatusCode finalize() override;

      /// @}

   private:
      /// Function setting up the algorithm while processing the first event
      StatusCode setup();

      /// @name Algorithm properties
      /// @{

      /// Name of the output stream to write to
      std::string m_outputStreamName;
      /// Item list to write to the output file
      std::vector< std::string > m_itemList;

      /// (Starter) Basket size for the created branches
      int m_basketSize;
      /// Split level for the created branches
      int m_splitLevel;

      /// @}

      /// Helper struct
      struct Item {
         /// Name of the written object
         std::string name;
         /// Type of the written object
         const std::type_info* type;
      }; // struct Item

      /// Object to write the output file with
      xAOD::TEvent m_event;

      /// Internal flag
      bool m_itemListInitialized = false;
      /// Item list being written after the first event
      std::vector< Item > m_writtenItemList;

      /// The systematic list to consider during execution
      SysListHandle m_systematicsList{ this };

   }; // class xAODWriterAlg

} // namespace CP

#endif // STANDALONEANALYSISALGORITHMS_XAODWRITERALG_H