GRUTinizer
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TUnpackedEvent.h
Go to the documentation of this file.
1 #ifndef _TUNPACKEDEVENT_H_
2 #define _TUNPACKEDEVENT_H_
3 
4 #ifndef __CINT__
5 #include <type_traits>
6 #endif
7 
8 #include "TClass.h"
9 
10 #include "TDetector.h"
11 #include "TGRUTTypes.h"
12 #include "TRawEvent.h"
13 
15 public:
18 
19  template<typename T>
20  T* GetDetector(bool make_if_not_found = false);
21 
22  std::vector<TDetector*>& GetDetectors() { return detectors; }
23  void AddDetector(TDetector* det) { detectors.push_back(det); }
24  void AddRawData(const TRawEvent& event, kDetectorSystems detector);
25 
26  void Build();
27 
28 private:
29  std::vector<TDetector*> detectors;
30 };
31 
32 #ifndef __CINT__
33 template<typename T>
34 T* TUnpackedEvent::GetDetector(bool make_if_not_found) {
36  "T must be a subclass of TDetector");
37  for(auto det : detectors) {
38  T* output = dynamic_cast<T*>(det);
39  if(output){
40  return output;
41  }
42  }
43 
44  if(make_if_not_found) {
45  T* output = new T;
46  detectors.push_back(output);
47  return output;
48  } else {
49  return NULL;
50  }
51 }
52 #endif
53 
54 #endif /* _TUNPACKEDEVENT_H_ */