R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BWhiterabbitNeulandReader.cxx
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#include <FairRootManager.h>
15
16#include "R3BEventHeader.h"
17#include "R3BLogger.h"
18#include "R3BWRData.h"
20
21#include <TClonesArray.h>
22
23extern "C"
24{
25#include "ext_data_client.h"
26#include "ext_h101_wrneuland.h"
27}
28
30 size_t offset,
31 UInt_t whiterabbit_id)
32 : R3BReader("R3BWhiterabbitNeulandReader")
33 , fNEvent(0)
34 , fData(data)
35 , fOffset(offset)
36 , fOnline(kFALSE)
37 , fWhiterabbitId(whiterabbit_id)
38 , fEventHeader(nullptr)
39 , fArray(new TClonesArray("R3BWRData"))
40{
41}
42
44{
45 if (fArray)
46 {
47 delete fArray;
48 }
49}
50
51Bool_t R3BWhiterabbitNeulandReader::Init(ext_data_struct_info* a_struct_info)
52{
53 Int_t ok;
54 R3BLOG(info, "");
55 EXT_STR_h101_WRNEULAND_ITEMS_INFO(ok, *a_struct_info, fOffset, EXT_STR_h101_WRNEULAND, 0);
56 if (!ok)
57 {
58 R3BLOG(error, "R3BWhiterabbitNeulandReader::Failed to setup structure information.");
59 return kFALSE;
60 }
61
62 // Look for the R3BEventHeader
63 FairRootManager* frm = FairRootManager::Instance();
64 fEventHeader = dynamic_cast<R3BEventHeader*>(frm->GetObject("EventHeader."));
65 if (!fEventHeader)
66 {
67 R3BLOG(warn, "EventHeader. not found");
68 fEventHeader = dynamic_cast<R3BEventHeader*>(frm->GetObject("R3BEventHeader"));
69 }
70 else
71 R3BLOG(info, "EventHeader. found");
72
73 // Register output array in tree
74 FairRootManager::Instance()->Register("WRNeulandData", "WRNeuland", fArray, !fOnline);
75
76 fData->NN_WR_ID = 0;
77
78 return kTRUE;
79}
80
82{
83 if (!fData->NN_WR_ID)
84 {
85 return kTRUE;
86 }
87
88 if (fWhiterabbitId != fData->NN_WR_ID)
89 {
90 char strMessage[1000];
91 snprintf(strMessage,
92 sizeof strMessage,
93 "Event %lu: Whiterabbit ID mismatch: expected 0x%x, got 0x%x.\n",
94 fEventHeader->GetEventno(),
95 fWhiterabbitId,
96 fData->NN_WR_ID);
97 R3BLOG(error, strMessage);
98 }
99
100 if (fEventHeader != nullptr)
101 {
102 uint64_t timestamp = ((uint64_t)fData->NN_WR_T4 << 48) | ((uint64_t)fData->NN_WR_T3 << 32) |
103 ((uint64_t)fData->NN_WR_T2 << 16) | (uint64_t)fData->NN_WR_T1;
104 // fEventHeader->SetTimeStamp(timestamp);
105 fNEvent = fEventHeader->GetEventno();
106 new ((*fArray)[fArray->GetEntriesFast()]) R3BWRData(timestamp);
107 }
108 else
109 {
110 fNEvent++;
111 }
112
113 fData->NN_WR_ID = 0;
114 return kTRUE;
115}
116
118{
119 // Reset the output array
120 fArray->Clear();
121 fNEvent = 0;
122}
123
#define R3BLOG(severity, x)
Definition R3BLogger.h:35
ClassImp(R3BWhiterabbitNeulandReader)
R3BReader(TString const &)
Definition R3BReader.cxx:16
A reader of NEULAND white rabbit data with UCESB.
virtual Bool_t Init(ext_data_struct_info *) override
R3BWhiterabbitNeulandReader(EXT_STR_h101_WRNEULAND *, size_t, UInt_t)
#define EXT_STR_h101_WRNEULAND_ITEMS_INFO(ok, si, offset, struct_t, printerr)
struct EXT_STR_h101_WRNEULAND_t EXT_STR_h101_WRNEULAND