FairRoot/PandaRoot
PndBranchBurstBuilder_timeCut_STB.cxx
Go to the documentation of this file.
1 /*
2  * PndBranchBurstBuilder_timeCut_STB.cxx
3  *
4  * Created on: July 13, 2017
5  * Author: Steinschaden
6  *
7  */
8 
9 #include "TClonesArray.h"
10 //#include "TROOT.h"
11 //#include "TString.h"
12 //#include "TVector3.h"
13 //#include "TMath.h"
14 
15 // framework includes
16 #include "FairRootManager.h"
17 #include "FairTimeStamp.h"
18 
20 
21 
22 
23 
26 {
27  fOutputPrefix= "Burst_STB";
28  fTimePeriod = 2000.0; // in nano seconds
29  fBurstNum = 0;
30  fWriteOut = false;
31 
32 }
33 
35 {
36 }
37 
38 
39 // ----- Public method Init --------------------------------------------
41 {
42 
43  InitStatus status = PndBranchBurstBuilder::Init();
44 
45  for (size_t i =0; i < fInBranchNames.size();i++){
46  fTempArrays.push_back(new TClonesArray(fInArrays[i]->GetClass()->GetName()));
47  }
48 
49  return status;
50 }
51 
52 
53 TClonesArray* PndBranchBurstBuilder_timeCut_STB::GetBurstData(size_t branchNum)
54 {
55 
56  TClonesArray* emptyArray = new TClonesArray(fInArrays[branchNum]->GetClass()->GetName());
57  double timeStamp;
58 
59  if (branchNum==0) { //only the "master branch" is controling the writeout to ensure synchron writeouts
60  fWriteOut = false;
61  if (fInArrays[branchNum]->GetEntriesFast()>0) {
62  fWriteOut = true; //set potential writeout
63  for (int i = 0; i< fInArrays[branchNum]->GetEntriesFast(); i++){ // loop over all timestamps of the event
64  timeStamp = ((FairTimeStamp*)fInArrays[branchNum]->At(i))->GetTimeStamp(); // access the timestamps
65  if (timeStamp < fBurstNum*fTimePeriod+fTimePeriod){ // if at least one timestamp is within the Range
66  fWriteOut = false; // deactivate the WriteOut
67  break; // save computing time and break the loop
68  }
69  }
70  }
71  if (fWriteOut == true) fBurstNum++; // increase the Burst number for the next Burst
72 
73  } // masterBranch end
74 
75  if (fWriteOut == true){
76  emptyArray->AbsorbObjects(fTempArrays[branchNum]); // prepare writeOut and "clear" the temporary buffer arrays
77  }
78  fTempArrays[branchNum]->AbsorbObjects(fInArrays[branchNum]); //absorb data into buffer
79 
80  return emptyArray; // writeout empty or Data array.
81 }
82 
83 
85 {
86  // write out the data collected for a maybe last and uncomplete Burst
87 
88  for (size_t i =0; i < fInBranchNames.size();i++){
89  fOutArrays[i]->Delete(); // make sure data written out from old events are deleted
90  fOutArrays[i]->AbsorbObjects(fTempArrays[i]);
91  }
92  FairRootManager::Instance()->SetLastFill();
93 
94 }
95 
96 
97 
99 
std::vector< TString > fInBranchNames
std::vector< TClonesArray * > fOutArrays
Int_t i
Definition: run_full.C:25
virtual TClonesArray * GetBurstData(size_t branchNum)
cout<< "POINTs for new FwEndCap == "<< tsim-> GetEntriesFast()
std::vector< TClonesArray * > fInArrays
ClassImp(PndAnaContFact)
virtual InitStatus Init()
cout<<"the Event No is "<< i<< endl;{{if(hit_array->GetEntriesFast()!=mc_array->GetEntriesFast()) continue;PndSdsHit *hit=(PndSdsHit *) hit_array-> At(j)
Definition: anaLmdCluster.C:71
int status[10]
Definition: f_Init.h:28