23 #include <FairMQLogger.h>
24 #include <FairMQMessage.h>
26 #include <TClonesArray.h>
32 : fGeneratorChannelName(
"primariesChannel")
34 , fRunConditional(true)
35 , fPrimaryGenerator(nullptr)
36 , fMCEventHeader(nullptr)
47 fAckChannelName = fConfig->GetValue<std::string>(
"ack-channel");
51 fPrimaryGenerator->
SetEvent(fMCEventHeader);
52 fPrimaryGenerator->
Init();
62 if (fAckChannelName !=
"") {
71 return GenerateAndSendData();
76 return GenerateAndSendData();
79 bool FairMQPrimaryGeneratorDevice::GenerateAndSendData()
81 if (fChunkPointer == 0) {
87 if (fEventCounter > fNofEvents)
97 0, fEventCounter, 1, 0);
99 if (fChunkSize != 0) {
100 meh->
SetNofChunks((UInt_t)(prims->GetEntries() / fChunkSize));
102 meh->
SetNPrim(fChunkPointer + fChunkSize);
103 if (fChunkPointer + fChunkSize > prims->GetEntries())
104 meh->
SetNPrim(prims->GetEntries() - fChunkPointer);
107 FairMQMessagePtr messEH(NewMessage());
108 Serialize<RootSerializer>(*messEH, meh);
109 parts.AddPart(std::move(messEH));
111 FairMQMessagePtr mess(NewMessage());
112 Serialize<RootSerializer>(*mess, prims);
113 parts.AddPart(std::move(mess));
116 if (Send(parts, fGeneratorChannelName) > 0) {}
118 int numberofparticles = (int)prims->GetEntries();
120 if (fChunkSize != 0) {
122 fChunkPointer += fChunkSize;
123 if (fChunkPointer >= numberofparticles) {
133 if (fAckChannelName !=
"") {
140 if (fAckChannelName !=
"") {
141 Long64_t numAcks = 0;
143 FairMQMessagePtr ack(NewMessage());
144 if (Receive(ack, fAckChannelName) >= 0) {
145 LOG(info) <<
"RECEIVED ACK!";
148 }
while (numAcks < fNofEvents);
150 LOG(info) <<
"Acknowledged " << numAcks <<
" messages.";
bool Reply(FairMQMessagePtr &, int)
TClonesArray * GetListOfParticles()
virtual ~FairMQPrimaryGeneratorDevice()
virtual Bool_t GenerateEvent(FairGenericStack *pStack)
void SetEvent(FairMCEventHeader *event)
virtual bool ConditionalRun()
virtual void SendPrimaries()
FairMQPrimaryGeneratorDevice()