GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
TUnpackedEvent.cxx
Go to the documentation of this file.
1#include "TUnpackedEvent.h"
2
3#include "TClass.h"
4#include "TDetector.h"
5#include "TChannel.h"
7
9
11
13{
14 for(const auto& frag : fFragments) {
15 TChannel* channel = TChannel::GetChannel(frag->GetAddress(), true);
16 if(channel == nullptr) {
17 // add to diagnostics, one time printing of error message is already taken care of by TChannel::GetChannel
18 TSortingDiagnostics::Get()->MissingChannel(frag->GetAddress());
19 continue;
20 }
21
22 TClass* detClass = channel->GetClassType();
23 if(detClass == nullptr) {
25 continue;
26 }
27
28 GetDetector(detClass, true)->AddFragment(frag, channel);
29 }
30
31 BuildHits();
33}
34
35void TUnpackedEvent::AddRawData(const std::shared_ptr<const TFragment>& frag)
36{
37 fFragments.push_back(frag);
38}
39
41{
42 fFragments.clear();
43}
44
46{
47 for(const auto& det : fDetectors) {
48 det->BuildHits();
49 }
50}
51
52std::shared_ptr<TDetector> TUnpackedEvent::GetDetector(TClass* cls, bool make_if_not_found)
53{
54 for(auto det : fDetectors) {
55 if(det->IsA() == cls) {
56 return det;
57 }
58 }
59
60 if(make_if_not_found) {
61 std::shared_ptr<TDetector> output(static_cast<TDetector*>(cls->New()));
62 fDetectors.push_back(output);
63 return output;
64 }
65 return nullptr;
66}
67
68#if __GNUC__ > 5
69std::ostringstream TUnpackedEvent::Print()
70{
71 std::ostringstream str;
72 str << fDetectors.size() << " detector types:" << std::endl;
73 for(const auto& det : fDetectors) {
74 str << "detector type " << det->ClassName() << std::endl;
75 for(int i = 0; i < det->GetMultiplicity(); ++i) {
76 auto hit = det->GetHit(i);
77 str << hit << " " << hex(hit->GetAddress(), 4) << " " << std::setw(16) << hit->GetTimeStamp() << " " << std::setw(16) << static_cast<int>(hit->Charge()) << " " << std::setw(16) << hit->GetEnergy() << std::endl;
78 }
79 }
80 return str;
81}
82#endif
std::string hex(T val, int width=-1)
Definition Globals.h:129
static TChannel * GetChannel(unsigned int temp_address, bool warn=false)
Definition TChannel.cxx:459
TClass * GetClassType() const
static TSortingDiagnostics * Get(bool verbose=false)
Definition TSingleton.h:33
void MissingChannel(const UInt_t &address)
void AddDetectorClass(TChannel *)
std::vector< std::shared_ptr< TDetector > > fDetectors
std::shared_ptr< T > GetDetector(bool make_if_not_found=false)
void AddRawData(const std::shared_ptr< const TFragment > &frag)
std::vector< std::shared_ptr< const TFragment > > fFragments