PandaRoot
PndMQFileSinkBursts.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 PndMQFileSinkBursts_H_
28 #define PndMQFileSinkBursts_H_
29 
30 #include <iostream>
31 
32 #include "Rtypes.h"
33 #include "TFile.h"
34 #include "TTree.h"
35 #include "TClonesArray.h"
36 #include "TVector3.h"
37 #include "TString.h"
38 #include "TSystem.h"
39 #include "TList.h"
40 #include "TObjString.h"
41 
42 #include "FairMQDevice.h"
43 #include "FairMQLogger.h"
44 #include "FairParGenericSet.h"
45 #include "FairGeoParSet.h"
46 
48 #include "PndSdsPixelDigiPar.h"
49 #include "PndSdsTotDigiPar.h"
50 #include "PndSensorNamePar.h"
51 
52 #include "PndSdsHit.h"
53 
54 #include "baseMQtools.h"
55 
56 #include "TMessage.h"
57 
58 #ifndef __CINT__
59 #include <boost/thread.hpp>
60 #include <boost/bind.hpp>
61 #include <boost/serialization/access.hpp>
62 #include <boost/archive/text_iarchive.hpp>
63 #include <boost/archive/binary_iarchive.hpp>
64 #include <boost/serialization/vector.hpp>
65 #include <boost/serialization/unique_ptr.hpp>
66 #endif //__CINT__
67 
68 class TVector3;
69 class TFile;
70 class TTree;
71 class TClonesArray;
72 
73 using namespace std;
74 
75 class PndMQFileSinkBursts : public FairMQDevice {
76  public:
77  PndMQFileSinkBursts(std::string outputFileName = "FilesSinkBursts.root")
78  : fOutFile(nullptr), fTree(nullptr), fOutput(nullptr), fHitVector(), fHasBoostSerialization(false), fOutputFileName(outputFileName), fBranchNameList(0), fCurrentRunId(0)
79  {
80  gSystem->ResetSignal(kSigInterrupt);
81  gSystem->ResetSignal(kSigTermination);
82 
83  // Check if boost serialization is available if it is chosen
84  using namespace baseMQ::tools::resolve;
85  // coverity[pointless_expression]: suppress coverity warnings on apparant if(const).
86  if (is_same<boost::archive::binary_iarchive, boost::archive::binary_iarchive>::value || is_same<boost::archive::binary_iarchive, boost::archive::text_iarchive>::value) {
87  if (has_BoostSerialization<FairTimeStamp, void(boost::archive::binary_iarchive &, const unsigned int)>::value == 1) {
88  fHasBoostSerialization = true;
89  }
90  }
91 
92  fGeoPar = new FairGeoParSet("FairGeoParSet");
93  fParCList = new TList();
94  fParCList->Add(fGeoPar);
95 
96  fDigiPar = new PndSdsPixelDigiPar("MVDPixelDigiPar");
97  fParCList->Add(fDigiPar);
98 
99  fTotPar = new PndSdsTotDigiPar("MVDPixelTotDigiPar");
100  fParCList->Add(fTotPar);
101 
102  fSensorPar = new PndSensorNamePar("PndSensorNamePar");
103  fParCList->Add(fSensorPar);
104  }
105 
107  {
108  // fBranchNameList->Write("BranchList", TObject::kSingleKey);
109  // fTree->Write();
110  // fOutFile->Close();
111  if (fHitVector.size() > 0) {
112  fHitVector.clear();
113  }
114  }
115 
116  virtual void SetFileName(std::string fileName) { fOutputFileName = fileName; }
117 
118  virtual void InitOutputFile(TString defaultId = "100")
119  {
120  // fOutput = new TClonesArray("PndSdsHit");
121  //
122  // std::stringstream ss;
123  // // ss << "/Volumes/RAMDisk/";
124  // ss << fOutputFileName.c_str();
125  //
126  //
127  // fOutFile = new TFile(ss.str().c_str(), "recreate");
128  // fTree = new TTree("pndsim", "Test output");
129  // fTree->Branch("Output", "TClonesArray", &fOutput, 64000, 99);
130  // fBranchNameList = new TList();
131  // fBranchNameList->AddLast(new TObjString("Output"));
132  }
133 
134  void UpdateParameters();
135  FairParGenericSet *UpdateParameter(FairParGenericSet *thisPar);
136  static void CustomCleanup(void *data, void *hint);
137 
138  template <class Archive>
139  void serialize(Archive &ar, const unsigned int version)
140  {
141  ar &fHitVector;
142  ar &fBurstData;
143  }
144 
145  protected:
146  virtual void Run();
147 
148  private:
149  TFile *fOutFile;
150  TTree *fTree;
151  TClonesArray *fOutput;
152  TList *fBranchNameList;
153  std::string fOutputFileName;
154  BurstData fBurstData;
155  int fCurrentRunId;
156  int fNewRunId;
157  TList *fParCList;
158  FairGeoParSet *fGeoPar;
159  PndSdsPixelDigiPar *fDigiPar;
160  PndSdsTotDigiPar *fTotPar;
161  PndSensorNamePar *fSensorPar;
162 
163 #ifndef __CINT__ // for BOOST serialization
164  friend class boost::serialization::access;
165  vector<FairTimeStamp *> fHitVector;
166  bool fHasBoostSerialization;
167 #endif // for BOOST serialization
168 
170  // PndMQFileSinkBursts(const PndMQFileSinkBursts&);
171  // PndMQFileSinkBursts operator=(const PndMQFileSinkBursts&);
172 };
173 
174 #endif /* PndMQFileSinkBursts_H_ */
PndMQFileSinkBursts(std::string outputFileName="FilesSinkBursts.root")
STL namespace.
Charge Digitization Parameter Class for SDS.
void serialize(Archive &ar, const unsigned int version)
virtual void InitOutputFile(TString defaultId="100")
virtual void SetFileName(std::string fileName)
Unique match between SensorID and path in TGeoManager.
Digitization Parameter Class for SDS-Pixel part.