FairRoot/PandaRoot
Public Member Functions | Protected Member Functions | Private Attributes | Friends | List of all members
PndMQFileSink Class Reference

#include <PndMQFileSink.h>

Inheritance diagram for PndMQFileSink:

Public Member Functions

 PndMQFileSink ()
 
virtual ~PndMQFileSink ()
 
virtual void InitOutputFile (TString defaultId="100")
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Protected Member Functions

virtual void Run ()
 

Private Attributes

TFile * fOutFile
 
TTree * fTree
 
TClonesArray * fOutput
 
vector< PndSdsDigiTopix4fHitVector
 
bool fHasBoostSerialization
 

Friends

class boost::serialization::access
 

Detailed Description

Definition at line 53 of file PndMQFileSink.h.

Constructor & Destructor Documentation

PndMQFileSink::PndMQFileSink ( )
inline

Definition at line 56 of file PndMQFileSink.h.

57  : fOutFile(NULL)
58  , fTree(NULL)
59  , fOutput(NULL)
60  , fHitVector()
61  , fHasBoostSerialization(false)
62  {
63  gSystem->ResetSignal(kSigInterrupt);
64  gSystem->ResetSignal(kSigTermination);
65 
66  // Check if boost serialization is available if it is chosen
67  using namespace baseMQ::tools::resolve;
68  // coverity[pointless_expression]: suppress coverity warnings on apparant if(const).
69  if (is_same<boost::archive::binary_iarchive, boost::archive::binary_iarchive>::value || is_same<boost::archive::binary_iarchive, boost::archive::text_iarchive>::value)
70  {
71  if (has_BoostSerialization<PndSdsDigiTopix4, void(boost::archive::binary_iarchive&, const unsigned int)>::value == 1)
72  {
74  }
75  }
76  }
Data class to store the digi output of a pixel module.
bool fHasBoostSerialization
TFile * fOutFile
vector< PndSdsDigiTopix4 > fHitVector
TClonesArray * fOutput
virtual PndMQFileSink::~PndMQFileSink ( )
inlinevirtual

Definition at line 78 of file PndMQFileSink.h.

References fOutFile.

79  {
80  fTree->Write();
81  fOutFile->Close();
82  if (fHitVector.size() > 0)
83  {
84  fHitVector.clear();
85  }
86  }
TFile * fOutFile
vector< PndSdsDigiTopix4 > fHitVector

Member Function Documentation

virtual void PndMQFileSink::InitOutputFile ( TString  defaultId = "100")
inlinevirtual

Definition at line 88 of file PndMQFileSink.h.

References fOutFile.

Referenced by main().

89  {
90  fOutput = new TClonesArray("PndSdsDigiTopix4");
91 
92  fOutFile = new TFile("Filesink1.root", "recreate");
93  fTree = new TTree("MQOut", "Test output");
94  fTree->Branch("Output", "TClonesArray", &fOutput, 64000, 99);
95  }
TFile * fOutFile
TClonesArray * fOutput
void PndMQFileSink::Run ( )
protectedvirtual

Definition at line 11 of file PndMQFileSink.cxx.

References fHasBoostSerialization, fHitVector, fOutput, fTree, and i.

12 {
14  {
15  int receivedMsgs = 0;
16 
17  // store the channel references to avoid traversing the map on every loop iteration
18  FairMQChannel& dataInChannel = fChannels.at("data-in").at(0);
19 
20  while (CheckCurrentState(RUNNING))
21  {
22  FairMQMessage* msg = fTransportFactory->CreateMessage();
23 
24  if (dataInChannel.Receive(msg) > 0)
25  {
26  receivedMsgs++;
27  string msgStr(static_cast<char*>(msg->GetData()), msg->GetSize());
28  istringstream ibuffer(msgStr);
29  boost::archive::binary_iarchive InputArchive(ibuffer);
30  LOG(INFO) << "Received Message: " << receivedMsgs;
31  try
32  {
33  InputArchive >> fHitVector;
34  }
35  catch (boost::archive::archive_exception& e)
36  {
37  LOG(ERROR) << e.what();
38  }
39 
40  int numInput = fHitVector.size();
41  fOutput->Delete();
42 
43  for (Int_t i = 0; i < numInput; ++i)
44  {
45  new ((*fOutput)[i]) PndSdsDigiTopix4(fHitVector.at(i));
46  // LOG(INFO) << "Data: " << i << " " << fHitVector.at(i).GetTimeStamp();
47  }
48 
49  if (fOutput->IsEmpty())
50  {
51  LOG(ERROR) << "PndMQFileSink::Run(): No Output array!";
52  }
53 
54  fTree->Fill();
55  }
56 
57  delete msg;
58 
59  if (fHitVector.size() > 0)
60  {
61  fHitVector.clear();
62  }
63  }
64 
65  LOG(INFO) << "I've received " << receivedMsgs << " messages!";
66  }
67  else
68  {
69  LOG(ERROR) << " Boost Serialization not ok";
70  }
71 }
Int_t i
Definition: run_full.C:25
Data class to store the digi output of a pixel module.
bool fHasBoostSerialization
vector< PndSdsDigiTopix4 > fHitVector
TClonesArray * fOutput
template<class Archive >
void PndMQFileSink::serialize ( Archive &  ar,
const unsigned int  version 
)
inline

Definition at line 98 of file PndMQFileSink.h.

99  {
100  ar& fHitVector;
101  }
vector< PndSdsDigiTopix4 > fHitVector

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 112 of file PndMQFileSink.h.

Member Data Documentation

bool PndMQFileSink::fHasBoostSerialization
private

Definition at line 114 of file PndMQFileSink.h.

Referenced by Run().

vector<PndSdsDigiTopix4> PndMQFileSink::fHitVector
private

Definition at line 113 of file PndMQFileSink.h.

Referenced by Run().

TFile* PndMQFileSink::fOutFile
private

Definition at line 107 of file PndMQFileSink.h.

TClonesArray* PndMQFileSink::fOutput
private

Definition at line 109 of file PndMQFileSink.h.

Referenced by Run().

TTree* PndMQFileSink::fTree
private

Definition at line 108 of file PndMQFileSink.h.

Referenced by Run().


The documentation for this class was generated from the following files: