R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BUcesbSource.h
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
3 * Copyright (C) 2019-2025 Members of R3B Collaboration *
4 * *
5 * This software is distributed under the terms of the *
6 * GNU General Public Licence (GPL) version 3, *
7 * copied verbatim in the file "LICENSE". *
8 * *
9 * In applying this license GSI does not waive the privileges and immunities *
10 * granted to it by virtue of its status as an Intergovernmental Organization *
11 * or submit itself to any jurisdiction. *
12 ******************************************************************************/
13
14/* R3BUcesbSource.h
15 * R3BROOT
16 *
17 * Author: Bastian Löher <b.loeher@gsi.de>
18 * Date: 29/05/15
19 * */
20
21#pragma once
22
23#include "R3BReader.h"
24
25#include <FairSource.h>
26#include <Rtypes.h>
27#include <TObjArray.h>
28#include <TString.h>
29
30#include <fstream>
31#include <list>
32
33/* External data client interface (ucesb) */
34#include "ext_data_clnt.hh"
35#include "ext_data_struct_info.hh"
36
37/* External data structure
38 * This structure is produced using ucesb in the following way:
39 * ./ucesb --ntuple=RAW,STRUCT_HH,ext_h101.h
40 * */
41struct EXT_STR_h101_t;
43
44class R3BEventHeader;
45
46class R3BUcesbSource : public FairSource
47{
48 public:
49 R3BUcesbSource(const TString&, const TString&, const TString&, EXT_STR_h101*, size_t);
50 virtual ~R3BUcesbSource();
51
52 Source_Type GetSourceType() { return kONLINE; }
53
54 /* Init() will fork a ucesb instance to deliver the unpacked data for
55 * R3BRoot. It makes use of the ext_data_ interface of ucesb.
56 * */
57 virtual Bool_t Init();
58
59 virtual Bool_t SpecifyRunId();
60
61 virtual Bool_t InitUnpackers();
62 virtual void SetParUnpackers();
63 virtual Bool_t ReInitUnpackers();
64 /* A wrapper for ext_data_fetch_event() */
65 Int_t ReadEvent(UInt_t);
66 /* Close the ext_data_ interface */
67 virtual void Close();
68 /* Reset the readers */
69 virtual void Reset();
70 /* The reader interface */
71 void AddReader(R3BReader* a_reader) { fReaders->Add(a_reader); }
72 /* Limit the number of events */
73 void SetMaxEvents(int a_max) { fLastEventNo = a_max; }
74 /* Get readers */
75 const TObjArray* GetReaders() const { return fReaders; }
76
77 virtual void FillEventHeader(FairEventHeader* feh);
78
79 inline void SetInputFileName(TString tstr) { fInputFileName = std::move(tstr); }
80
81 inline void SetFullDataStructureValidation() { fFullDataStructureValidation = true; }
82
83 private:
84 /* File descriptor returned from popen() */
85 FILE* fFd;
86 /* The ucesb interface class */
87 ext_data_clnt fClient;
88 /* The ucesb structure info class */
89 ext_data_struct_info fStructInfo;
90 /* The filename to read */
91 const TString fFileName;
92 /* Ucesb output options */
93 const TString fNtupleOptions;
94 /* The location of the unpacker */
95 const TString fUcesbPath;
96 /* The event counter */
97 unsigned int fNEvent;
98 /* The full event structure */
99 EXT_STR_h101* fEvent;
100 size_t fEventSize;
101 /* Last event requested */
102 int fLastEventNo;
103 /* The array of readers */
104 TObjArray* fReaders;
105 /* R3B header */
106 R3BEventHeader* fEventHeader;
107 Int_t ReadIntFromString(const std::string& wholestr, const std::string& pattern);
108 TString fInputFileName;
109 std::ifstream fInputFile;
110 Int_t fEntryMax;
111 bool fFullDataStructureValidation = false;
112
113 public:
114 // Create dictionary
115 ClassDef(R3BUcesbSource, 1)
116};
struct EXT_STR_h101_t EXT_STR_h101
Int_t ReadEvent(UInt_t)
R3BUcesbSource(const TString &, const TString &, const TString &, EXT_STR_h101 *, size_t)
virtual Bool_t Init()
Source_Type GetSourceType()
virtual Bool_t InitUnpackers()
virtual void SetParUnpackers()
virtual void Reset()
void SetFullDataStructureValidation()
virtual void FillEventHeader(FairEventHeader *feh)
void AddReader(R3BReader *a_reader)
void SetMaxEvents(int a_max)
virtual Bool_t ReInitUnpackers()
const TObjArray * GetReaders() const
virtual ~R3BUcesbSource()
virtual Bool_t SpecifyRunId()
virtual void Close()
void SetInputFileName(TString tstr)