Skip to content

Commit 2180b56

Browse files
rbxkarabowi
authored andcommitted
Serialization example: add temporary processing on sender side
1 parent 676d34b commit 2180b56

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

examples/MQ/serialization/sampler.cxx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// this example
1010
#include "ExHeader.h"
1111
#include "MyDigi.h"
12+
#include "MyHit.h" // temporary for the data check (see below)
1213

1314
// FairRoot
1415
#include "BoostSerializer.h"
@@ -19,6 +20,7 @@
1920
// ROOT
2021
#include <Rtypes.h>
2122
#include <TFile.h>
23+
#include <TMath.h> // temporary for the data check (see below)
2224
#include <TTree.h>
2325

2426
// std
@@ -64,6 +66,9 @@ struct Sampler : fair::mq::Device
6466
ExHeader header;
6567
header.eventNumber = idx;
6668

69+
// temporarily apply data processing steps to check that they work before & after serialization
70+
volatile TClonesArray hits = FindHits(*fInput);
71+
6772
auto msgHeader(NewMessage());
6873
BoostSerializer<ExHeader>().Serialize(*msgHeader, header);
6974

@@ -92,6 +97,25 @@ struct Sampler : fair::mq::Device
9297
}
9398

9499
private:
100+
// temporary method to check data before transfer
101+
TClonesArray FindHits(const TClonesArray& digis)
102+
{
103+
TClonesArray hits("MyHit");
104+
const TVector3 dpos(1 / TMath::Sqrt(12), 1 / TMath::Sqrt(12), 1 / TMath::Sqrt(12));
105+
const Int_t fDetID = 0;
106+
const Int_t fMCIndex = 0;
107+
108+
for (int i = 0; i < digis.GetEntriesFast(); i++) {
109+
auto digi = static_cast<MyDigi const*>(digis.At(i));
110+
const TVector3 pos(digi->GetX() + 0.5, digi->GetY() + 0.5, digi->GetZ() + 0.5);
111+
auto hit = new ((hits)[i]) MyHit(fDetID, fMCIndex, pos, dpos);
112+
hit->SetTimeStamp(digi->GetTimeStamp());
113+
hit->SetTimeStampError(digi->GetTimeStampError());
114+
}
115+
116+
return hits;
117+
}
118+
95119
TClonesArray* fInput;
96120
TTree* fTree;
97121
std::string fFileName;

0 commit comments

Comments
 (0)