REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestEvent.h
1/*************************************************************************
2 * This file is part of the REST software framework. *
3 * *
4 * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) *
5 * For more information see http://gifna.unizar.es/trex *
6 * *
7 * REST is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * REST is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have a copy of the GNU General Public License along with *
18 * REST in $REST_PATH/LICENSE. *
19 * If not, see http://www.gnu.org/licenses/. *
20 * For the list of contributors see $REST_PATH/CREDITS. *
21 *************************************************************************/
22
23#ifndef RestCore_TRestEvent
24#define RestCore_TRestEvent
25
26#include <TBufferFile.h>
27#include <TPad.h>
28#include <TString.h>
29#include <TTimeStamp.h>
30
31#include <iostream>
32
33#include "TRestTools.h"
34
35class TRestRun;
36
38class TRestEvent : public TObject {
39 protected:
40 Int_t fRunOrigin;
42 Int_t fEventID;
44 TString fSubEventTag;
45 TTimeStamp fEventTime;
46 Bool_t fOk;
47
48 TRestRun* fRun = nullptr;
49
50 TPad* fPad;
51
52 void RestartPad(Int_t nElements);
53
54 public:
55 // Setters
56 inline void SetRunOrigin(Int_t run_origin) { fRunOrigin = run_origin; }
57 inline void SetSubRunOrigin(Int_t sub_run_origin) { fSubRunOrigin = sub_run_origin; }
58
59 inline void SetID(Int_t id) { fEventID = id; }
60 inline void SetSubID(Int_t id) { fSubEventID = id; }
61 inline void SetSubEventTag(const TString& tag) { fSubEventTag = tag; }
62
63 void SetTime(Double_t time);
64 void SetTime(Double_t seconds, Double_t nanoseconds);
65 inline void SetTimeStamp(const TTimeStamp& time) { fEventTime = time; }
66
67 inline void SetState(Bool_t state) { fOk = state; }
68 inline void SetOK(Bool_t state) { fOk = state; }
69
70 void SetEventInfo(TRestEvent* eve);
71
72 // Getters
73 inline Int_t GetID() const { return fEventID; }
74 inline Int_t GetSubID() const { return fSubEventID; }
75 inline TString GetSubEventTag() const { return fSubEventTag; }
76
77 inline Int_t GetRunOrigin() const { return fRunOrigin; }
78 inline Int_t GetSubRunOrigin() const { return fSubRunOrigin; }
79
80 inline Double_t GetTime() const { return fEventTime.AsDouble(); }
81 inline TTimeStamp GetTimeStamp() const { return fEventTime; }
82
83 inline Bool_t isOk() const { return fOk; }
84
85 virtual void Initialize() = 0;
86 virtual void InitializeWithMetadata(TRestRun* run);
87
95 virtual void InitializeReferences(TRestRun* run);
96
97 virtual void PrintEvent() const;
98
103 virtual TPad* DrawEvent(const TString& option = "") {
104 UNUSED(option);
105 return new TPad();
106 }
107
108 virtual void CloneTo(TRestEvent* target);
109
110 // Constructor
111 TRestEvent();
112 // Destructor
113 virtual ~TRestEvent();
114
115 ClassDef(TRestEvent, 1);
116};
117#endif
A base class for any REST event.
Definition: TRestEvent.h:38
void SetTime(Double_t time)
Definition: TRestEvent.cxx:85
virtual void InitializeReferences(TRestRun *run)
Initialize dynamical references when loading the event from a root file.
Definition: TRestEvent.cxx:175
virtual void CloneTo(TRestEvent *target)
Clone the content of this TRestEvent object to another.
Definition: TRestEvent.cxx:98
virtual TPad * DrawEvent(const TString &option="")
Draw the event.
Definition: TRestEvent.h:103
virtual ~TRestEvent()
Definition: TRestEvent.cxx:66
void SetEventInfo(TRestEvent *eve)
Definition: TRestEvent.cxx:137
virtual void PrintEvent() const
Definition: TRestEvent.cxx:187
Int_t fRunOrigin
Run ID number of the event.
Definition: TRestEvent.h:40
TString fSubEventTag
A short length label to identify the sub-Event.
Definition: TRestEvent.h:44
TTimeStamp fEventTime
Absolute event time.
Definition: TRestEvent.h:45
Bool_t fOk
Flag to be used by processes to define an event status. fOk=true is the default.
Definition: TRestEvent.h:46
virtual void Initialize()=0
Definition: TRestEvent.cxx:73
Int_t fEventID
Event identification number.
Definition: TRestEvent.h:42
Int_t fSubEventID
Sub-Event identification number.
Definition: TRestEvent.h:43
Int_t fSubRunOrigin
Sub-run ID number of the event.
Definition: TRestEvent.h:41
Data provider and manager in REST.
Definition: TRestRun.h:18