FairRoot/PandaRoot
PndBranchBurstBuilder_eventBased.cxx
Go to the documentation of this file.
1 /*
2  * PndEventCombinerTask_eb.cxx
3  *
4  * Created on: July 13, 2017
5  * Author: Steinschaden
6  *
7  */
8 
10 #include "TClonesArray.h"
11 
12 // framework includes
13 #include "FairRootManager.h"
14 
15 
16 
19 {
20  fNEvents = 3;
21  fOutputPrefix= "Burst_eb";
22 
23 }
24 
26 {
27 }
28 
29 
30 // ----- Public method Init --------------------------------------------
32 {
33 
34  InitStatus status = PndBranchBurstBuilder::Init();
35 
36  for (size_t i =0; i < fInBranchNames.size();i++){
37  fTempArrays.push_back(new TClonesArray(fInArrays[i]->GetClass()->GetName()));
38  }
39 
40  return status;
41 }
42 
43 
44 TClonesArray* PndBranchBurstBuilder_eventBased::GetBurstData(size_t branchNum)
45 {
46 
47 
48  FairRootManager* ioman = FairRootManager::Instance();
49  //generate empty dummy array to retrun when not enough data is collected for a burst
50  TClonesArray* emptyArray = new TClonesArray(fInArrays[branchNum]->GetClass()->GetName());
51 
52  fTempArrays[branchNum]->AbsorbObjects(fInArrays[branchNum]); //fill the temp array with the data of the new events
53  if(ioman->GetEntryNr() % fNEvents == fNEvents - 1) { //if enough data is collected :
54  return fTempArrays[branchNum]; // the absorbtion of the returned TClonesArray will reset the TempArray
55  }
56 
57  return emptyArray;
58 }
59 
61 {
62  // write out the data collected for a maybe last and uncomplete Burst
63 
64  for (size_t i =0; i < fInBranchNames.size();i++){
65  fOutArrays[i]->Delete(); // make sure data written out from old events are deleted
66  fOutArrays[i]->AbsorbObjects(fTempArrays[i]);
67  }
68  FairRootManager::Instance()->SetLastFill();
69 
70 }
71 
72 
73 
75 
std::vector< TString > fInBranchNames
std::vector< TClonesArray * > fOutArrays
Int_t i
Definition: run_full.C:25
std::vector< TClonesArray * > fInArrays
ClassImp(PndBranchBurstBuilder_eventBased)
virtual TClonesArray * GetBurstData(size_t branchNum)
virtual InitStatus Init()
int status[10]
Definition: f_Init.h:28