GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TFragment.cxx
Go to the documentation of this file.
1#include "TFragment.h"
2#include "TChannel.h"
3#include "TROOT.h"
4#include <iostream>
5#include <sstream>
6
7#include <TClass.h>
8
10
12{
13 /// Default constructor
14 Clear();
15}
16
17void TFragment::Clear(Option_t* opt)
18{
19 /// Clears all fields of the TFragment
21
22 fDaqTimeStamp = 0;
23 fDaqId = 0;
24 fFragmentId = 0;
27 fChannelId = 0;
29
30 fDeadTime = 0;
31 fModuleType = 0;
32 fDetectorType = 0;
34
35 fTriggerId.clear();
36
37 fPPG = nullptr;
38 fEntryNumber = 0;
39 fZc = 0;
40 fCcShort = 0;
41 fCcLong = 0;
43}
44
45TObject* TFragment::Clone(const char*) const
46{
47 auto* result = new TFragment;
48 *result = *this;
49 result->ClearTransients();
50 return result;
51}
52
53double TFragment::GetTZero() const
54{
55 TChannel* chan = GetChannel();
56 if(chan == nullptr) {
57 return 0.000;
58 }
59 return chan->GetTZero(GetEnergy());
60}
61
63{ // return a 4G cfd in terms of 1/256 ns since the trigger
64 return static_cast<Int_t>(GetCfd()) & 0x001fffff;
65}
66
68{
69
70 if(fPPG == nullptr) {
71 fPPG = TPPG::Get(); // static_cast<TPPG*>(gROOT->FindObject("TPPG"));
72 }
73 if(fPPG == nullptr) {
74 return 0;
75 }
77}
78
80{
81 if(fPPG == nullptr) {
82 fPPG = TPPG::Get(); // static_cast<TPPG*>(gROOT->FindObject("TPPG"));
83 }
84 if(fPPG == nullptr) {
85 return 0;
86 }
88}
89
91{
92 if(fPPG == nullptr) {
93 fPPG = static_cast<TPPG*>(gROOT->FindObject("TPPG"));
94 }
95 return fPPG;
96}
97
98void TFragment::Print(Option_t*) const
99{
100 /// Prints out all fields of the TFragment
101 Print(std::cout);
102}
103
104void TFragment::Print(std::ostream& out) const
105{
106 /// Print fragment to stream out in a thread-safe way
107 std::ostringstream str;
108 str << "DaqTimeStamp: " << ctime(&fDaqTimeStamp) << std::endl
109 << "DaqId: " << fDaqId << std::endl
110 << "\tTriggerId[" << fTriggerId.size() << "]";
111 for(auto triggerId : fTriggerId) {
112 str << " 0x" << std::hex << triggerId << std::dec;
113 }
114 str << std::endl
115 << "FragmentId: " << fFragmentId << std::endl
116 << "TriggerBit: 0x" << std::hex << fTriggerBitPattern << std::dec << std::endl
117 << "NetworkPacketNumber: " << fNetworkPacketNumber << std::endl
118 << "Channel Address: 0x" << std::hex << GetAddress() << std::dec << std::endl;
119 TChannel* channel = GetChannel();
120 if(channel != nullptr) {
121 str << "Channel: " << channel->GetNumber() << "\t Name: " << channel->GetName() << std::endl;
122 }
123 str << "Charge: 0x" << std::hex << static_cast<Int_t>(GetCharge()) << std::dec << std::endl
124 << "Cfd: 0x" << std::hex << static_cast<Int_t>(GetCfd()) << std::dec << std::endl
125 << "ZC: 0x" << std::hex << fZc << std::dec << std::endl
126 << "TimeStamp: " << GetTimeStamp() << std::endl
127 << (HasWave() ? "Has a wave form stored" : "Doesn't have a wave form stored") << std::endl;
128 out << str.str();
129}
130
131bool TFragment::IsDetector(const char* prefix, Option_t* opt) const
132{
133 // Checks to see if the current fragment constains the same "prefix", for example "GRG"
134 // The option determines whether the channel should be:
135 // - C : The core of a segmented detector
136 // - S : The segments of a segmented detector
137 // - A : Low gain output of a detector
138 // - B : High gain output of a detectora
139 // If C or S are not given, default to C
140 // If A or B are not given, default to A
141 // Note that multiple options add to the output, so "CAB" would return the core with both high and low gain
142 // One should eventually add N,P,T options as well.
143 std::string pre = prefix;
144 TString option = opt;
145 std::string channame = GetName();
146 if(channame.length() < 9) {
147 return false;
148 }
149
150 option.ToUpper();
151 // Could also do everything below with TMnemonic. This limits the amount of string processing that needs to be done
152 // Because it returns false after every potential failure while the mnemonic class sets all of the strings, and then
153 // checks
154 // for conditions.
155 if(channame.compare(0, pre.length(), pre) == 0) { // channame.BeginsWith(pre)){
156 if(option.Length() < 1) { // no option.
157 return true;
158 }
159 if(channame.length() > 8) {
160 if(option.Contains("B") && (std::toupper(channame[9]) == std::toupper('B'))) {
161 return true;
162 }
163 if(option.Contains("A") && (std::toupper(channame[9]) == std::toupper('A'))) {
164 return true;
165 }
166 }
167 if(option.Contains("C") && (channame.compare(7, 2, "00") == 0)) {
168 return true;
169 }
170 if(option.Contains("S") && (channame.compare(7, 2, "00") != 0)) {
171 return true;
172 }
173 } else {
174 return false;
175 }
176
177 return false;
178}
179
181{
182 int slave = (GetAddress() & 0x00f00000) >> 20;
183 int port = (GetAddress() & 0x00000f00) >> 8;
184 int channel = (GetAddress() & 0x000000ff);
185
186 if(slave != 0x1 && slave != 0x2) {
187 return -1;
188 }
189 if(channel == 0x1f) {
190 return (slave - 1) * 16 + (port - 1) * 2 + 1;
191 }
192 if(channel == 0x3f) {
193 return (slave - 1) * 16 + (port - 1) * 2 + 2;
194 }
195 return -1;
196}
int GetNumber() const
Definition TChannel.h:169
double GetTZero(double tempd) const
Definition TChannel.h:294
virtual Float_t GetCharge() const
!
virtual UInt_t GetAddress() const
!
virtual Long64_t GetTimeStampNs(Option_t *opt="") const
virtual Long64_t GetTimeStamp(Option_t *="") const
virtual double GetEnergy(Option_t *opt="") const
const char * GetName() const override
!
TChannel * GetChannel() const
!
void Clear(Option_t *opt="") override
!
virtual Float_t GetCfd() const
!
virtual bool HasWave() const
!
UShort_t fDeadTime
Added to combine Grif Fragment ////.
Definition TFragment.h:125
Int_t fDaqId
Daq ID.
Definition TFragment.h:116
TObject * Clone(const char *name="") const override
Definition TFragment.cxx:45
UInt_t fChannelId
Threshold crossing counter for a channel.
Definition TFragment.h:120
bool IsDetector(const char *prefix, Option_t *opt="CA") const
ULong64_t GetTimeInCycle()
Definition TFragment.cxx:67
Long64_t fEntryNumber
! Entry number in fragment tree
Definition TFragment.h:135
double GetTZero() const
Definition TFragment.cxx:53
void Print(Option_t *opt="") const override
Definition TFragment.cxx:98
time_t fDaqTimeStamp
Timestamp of the Daq event.
Definition TFragment.h:115
std::vector< Long_t > fTriggerId
PrimaryFilterID in Griffin DAQ.
Definition TFragment.h:130
Int_t fTriggerBitPattern
PrimaryFilterPattern in Griffin DAQ.
Definition TFragment.h:118
UShort_t fNumberOfWords
! Number of non-waveform words in fragment, only used for check while parsing the fragment
Definition TFragment.h:139
Int_t fCcShort
! Short integration over waveform peak from 4G (saved in separate branch)
Definition TFragment.h:137
Int_t fNetworkPacketNumber
Network packet number.
Definition TFragment.h:119
Short_t fNumberOfPileups
Number of piled up hits 1-3.
Definition TFragment.h:128
UShort_t fModuleType
Data Type (GRIF-16, 4G, etc.)
Definition TFragment.h:126
Int_t Get4GCfd() const
Definition TFragment.cxx:62
Int_t fZc
! Zero-crossing value from 4G (saved in separate branch)
Definition TFragment.h:136
Int_t GetSharcMesyBoard() const
UInt_t fAcceptedChannelId
Accepted threshold crossing counter for a channel.
Definition TFragment.h:121
ULong64_t GetCycleNumber()
Definition TFragment.cxx:79
void Clear(Option_t *opt="") override
Definition TFragment.cxx:17
UShort_t fDetectorType
Detector Type (PACES,HPGe, etc.)
Definition TFragment.h:127
Int_t fFragmentId
Channel Trigger ID ??? not needed anymore ???
Definition TFragment.h:117
Int_t fCcLong
! Long integration over waveform tail from 4G (saved in separate branch)
Definition TFragment.h:138
TPPG * fPPG
! Programmable pattern generator value
Definition TFragment.h:133
TPPG * GetPPG()
Definition TFragment.cxx:90
static Long64_t fNumberOfFragments
Definition TFragment.h:141
Definition TPPG.h:132
ULong64_t GetCycleNumber(ULong64_t real_time)
Definition TPPG.cxx:621
ULong64_t GetTimeInCycle(ULong64_t real_time)
Definition TPPG.cxx:613
static TPPG * Get(bool verbose=false)
Definition TSingleton.h:33