PandaRoot
PndMvdMQFileSamplerBursts.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
13 /********************************************************************************
14  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
15  * *
16  * This software is distributed under the terms of the *
17  * GNU Lesser General Public Licence version 3 (LGPL) version 3, *
18  * copied verbatim in the file "LICENSE" *
19  ********************************************************************************/
27 #ifndef PndMvdMQFileSamplerBursts_H_
28 #define PndMvdMQFileSamplerBursts_H_
29 
30 #include <string>
31 
32 #include "FairFileSource.h"
33 #include "FairRunAna.h"
34 #include "FairTimeStamp.h"
35 
36 #include "FairMQDevice.h"
37 
38 #include "PndBurstVectorBuilder.h"
39 
40 #include "TClonesArray.h"
41 
42 struct BurstHeader {
43  unsigned int fRunID;
44  unsigned int fBurstID;
45  std::string fBranchName;
46 
47  template <class Archive>
48  void serialize(Archive &ar, const unsigned int version)
49  {
50  ar &fRunID;
51  ar &fBurstID;
52  ar &fBranchName;
53  }
54 
55 #ifndef __CINT__ // for BOOST serialization
57 #endif // for BOOST serialization
58 };
59 
60 struct BurstData {
61  BurstData() : fHeader(), fData(){};
62  virtual ~BurstData()
63  {
64  for (auto itr : fData) {
65  for (auto dataItr : itr) {
66  delete (dataItr);
67  }
68  itr.clear();
69  }
70  fData.clear();
71  };
73  std::vector<std::vector<FairTimeStamp *>> fData;
74 
75  virtual void Reset() {}
76 
77  template <class Archive>
78  void serialize(Archive &ar, const unsigned int version)
79  {
80  ar &fHeader;
81  ar &fData;
82  }
83 
84 #ifndef __CINT__ // for BOOST serialization
85  friend class boost::serialization::access;
86 #endif
87 };
88 
89 class PndMvdMQFileSamplerBursts : public FairMQDevice {
90  public:
91  enum { InputFileName = FairMQDevice::Last, Last };
92 
94  virtual ~PndMvdMQFileSamplerBursts();
95 
96  void AddInputFileName(std::string tempString) { fFileNames.push_back(tempString); }
97  void AddInputChannelBranchName(std::pair<std::string, std::string> tempString)
98  {
99  fPortBranchNameMap.insert(std::pair<std::string, std::string>(tempString.first, tempString.second));
100  fBranchNames.push_back(tempString);
101  fPorts.insert(tempString.first);
102  }
103 
104  void SetMaxIndex(int64_t tempInt) { fMaxIndex = tempInt; }
105 
106  template <class Archive>
107  void serialize(Archive &ar, const unsigned int version)
108  {
109  ar &fHitVector;
110  }
111 
112 #ifndef __CINT__ // for BOOST serialization
113  friend class boost::serialization::access;
114 #endif
115 
116  protected:
117  virtual void Run();
118  virtual void InitTask();
119 
120  virtual void InitBurstBuilder(std::string branchName);
121 
122  private:
123  FairRunAna *fRunAna;
124  FairFileSource *fSource;
125  std::set<std::string> fPorts; //< set of output ports
126  std::multimap<std::string, std::string> fPortBranchNameMap;
127  std::vector<std::pair<std::string, std::string>> fBranchNames; //< vector of output ports and branch names. One port can have multiple branches send to it
128  std::map<std::string, std::vector<std::vector<FairTimeStamp *>>> fOutputData; //< map of branch and data object to be send
129  std::map<std::string, TObject *> fInputBranches; //< branch name and TClonesArray in root tree
130  std::map<std::string, PndBurstVectorBuilderBase *> fBurstBuilder; //< branch name and associated burst builder
131  std::vector<FairTimeStamp *> fHitVector;
132  FairEventHeader *fEventHeader;
133 
134  int fNObjects;
135  int64_t fMaxIndex;
136 
137  std::vector<std::string> fFileNames;
138 };
139 
140 #endif /* PndMvdMQFileSamplerBursts_H_ */
void serialize(Archive &ar, const unsigned int version)
virtual void Reset()
void serialize(Archive &ar, const unsigned int version)
std::vector< std::vector< FairTimeStamp * > > fData
void AddInputFileName(std::string tempString)
void AddInputChannelBranchName(std::pair< std::string, std::string > tempString)
void serialize(Archive &ar, const unsigned int version)
friend class boost::serialization::access