21 #include <FairMQLogger.h>
22 #include <TClonesArray.h>
26 #include <TObjString.h>
35 , fInputChannelName(
"data-in")
49 , fOutputObjects(new TObject*[1000])
55 fFileName = fConfig->GetValue<std::string>(
"file-name");
56 fClassNames = fConfig->GetValue<std::vector<std::string>>(
"class-name");
57 fBranchNames = fConfig->GetValue<std::vector<std::string>>(
"branch-name");
58 fInputChannelName = fConfig->GetValue<std::string>(
"in-channel");
59 fAckChannelName = fConfig->GetValue<std::string>(
"ack-channel");
61 LOG(info) <<
"SHOULD CREATE THE FILE AND TREE";
62 fFileOption =
"RECREATE";
65 fOutFile = TFile::Open(fFileName.c_str(), fFileOption.c_str());
67 fTree =
new TTree(fTreeName.c_str(),
"/cbmout");
69 fFolder =
new TFolder(
"cbmout",
"Main Output Folder");
70 TFolder* foldEventHeader = fFolder->AddFolder(
"EvtHeader",
"EvtHeader");
71 TFolder* foldPixel = fFolder->AddFolder(
"Pixel",
"Pixel");
75 for (fNObjects = 0; fNObjects < fBranchNames.size(); fNObjects++) {
76 if (fClassNames[fNObjects].find(
"TClonesArray(") == 0) {
77 fClassNames[fNObjects] = fClassNames[fNObjects].substr(13, fClassNames[fNObjects].length() - 12 - 2);
78 fOutputObjects[fNObjects] =
new TClonesArray(fClassNames[fNObjects].c_str());
79 fTree->Branch(fBranchNames[fNObjects].c_str(),
"TClonesArray", &fOutputObjects[fNObjects]);
80 foldPixel->Add(fOutputObjects[fNObjects]);
81 branchNameList.AddLast(
new TObjString(fBranchNames[fNObjects].c_str()));
82 }
else if (fClassNames[fNObjects].find(
"FairEventHeader") == 0) {
84 fTree->Branch(fBranchNames[fNObjects].c_str(),
"FairEventHeader", &fOutputObjects[fNObjects]);
85 foldEventHeader->Add(fOutputObjects[fNObjects]);
86 branchNameList.AddLast(
new TObjString(fBranchNames[fNObjects].c_str()));
88 LOG(error) <<
"!!! Unknown output object \"" << fClassNames[fNObjects] <<
"\" !!!";
93 branchNameList.Write(
"BranchList", TObject::kSingleKey);
94 branchNameList.Delete();
101 if (parts.Size() == 0)
107 if (parts.Size() % nPPE >= 1)
108 LOG(info) <<
"received " << parts.Size() <<
" parts, will ignore last part!!!";
110 for (
int ievent = 0; ievent < parts.Size() / nPPE; ievent++) {
117 for (
unsigned int ibr = 0; ibr < fBranchNames.size(); ibr++) {
118 if (
"EventHeader." == fBranchNames[ibr]) {
126 int hitArraySize = parts.At(nPPE * ievent + 1)->GetSize();
129 for (
unsigned int ibr = 0; ibr < fBranchNames.size(); ibr++) {
130 if (
"PixelHits" == fBranchNames[ibr]) {
131 ((TClonesArray*)fOutputObjects[ibr])->Clear();
132 for (
int ihit = 0; ihit < nofHits; ihit++) {
133 TVector3 pos(payloadH[ihit].posX, payloadH[ihit].posY, payloadH[ihit].posZ);
134 TVector3 posErr(payloadH[ihit].dposX, payloadH[ihit].dposY, payloadH[ihit].dposZ);
135 new ((*((TClonesArray*)fOutputObjects[ibr]))[ihit])
136 PixelHit(payloadH[ihit].fDetectorID, -1, pos, posErr);
145 if (fAckChannelName !=
"") {
146 FairMQMessagePtr msg(NewMessage());
147 Send(msg, fAckChannelName);
160 if (fOutFile->IsOpen()) {
bool StoreData(FairMQParts &, int)
virtual ~FairMQPixelFileSinkBin()