FairRoot/PandaRoot
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PndWriteoutBuffer Class Referenceabstract

A container class to store digi data during events. More...

#include <PndWriteoutBuffer.h>

Inheritance diagram for PndWriteoutBuffer:

Public Member Functions

 PndWriteoutBuffer ()
 
 PndWriteoutBuffer (TString branchName, TString className, TString folderName, Bool_t persistance)
 
virtual ~PndWriteoutBuffer ()
 
virtual void WriteOutData (double time)
 
virtual void WriteOutAllData ()
 
virtual void SaveDataToTree (Bool_t val=kTRUE)
 If SaveDataToTree is set the data is stored at the end of the buffering into the given TClonesArray. More...
 
virtual void ActivateBuffering (Bool_t val=kTRUE)
 fActivateBuffering has to be set to kTRUE to use the buffering. Otherwise the data is directly stored in the given TClonesArray. More...
 
virtual std::vector
< FairTimeStamp * > 
GetRemoveOldData (double time)
 
virtual std::vector
< FairTimeStamp * > 
GetAllData ()
 
virtual void FillNewData (FairTimeStamp *data, double activeTime)
 
virtual Int_t GetNData ()
 
virtual void AddNewDataToTClonesArray (FairTimeStamp *data)=0
 store the data from the FairTimeStamp pointer in a TClonesArray (you have to cast it to your type of data) More...
 
virtual void DeleteOldData ()
 
virtual double FindTimeForData (FairTimeStamp *data)=0
 if the same data object (like a pad or a pixel) is already present in the buffer, the time of this object has to be returned otherwise -1 More...
 
virtual void FillDataMap (FairTimeStamp *data, double activeTime)=0
 add a new element in the search buffer More...
 
virtual void EraseDataFromDataMap (FairTimeStamp *data)=0
 delete the element from the search buffer (see PndSdsDigiPixelWriteoutBuffer) More...
 
virtual void SetVerbose (Int_t val)
 

Protected Member Functions

virtual std::vector< std::pair
< double, FairTimeStamp * > > 
Modify (std::pair< double, FairTimeStamp * > oldData, std::pair< double, FairTimeStamp * > newData)
 
 ClassDef (PndWriteoutBuffer, 1)
 

Protected Attributes

std::multimap< double,
FairTimeStamp * > 
fDeadTime_map
 
TString fBranchName
 
TString fClassName
 
Bool_t fTreeSave
 
Bool_t fActivateBuffering
 
Int_t fVerbose
 

Detailed Description

A container class to store digi data during events.

Author
Tobias Stockmanns The PndWriteoutBuffer class provides a container which handles the storage of data between events. The data has to be given with an active time, the absolute time the data is active in the detector and can influence the output of the data. FillNewData is used to put new data into the container. WriteOutData with a given actual time stores the data which has an active time older than the given time in the corresponding TClonesArray of the FairRootManager. At the end of the task WriteOutAllData has to be called to store the data which is still in the buffer. If one adds data via FillNewData into the buffer which is already present in the buffer, Modify is called. The standard behavior of Modify is that the new data is ignored to simulate pile-up. If a different behavior is wanted one has to overwrite Modify in a derived class.

The data which should be stored in the buffer has to be derived from FairTimeStamp. It needs an operator< and a method equal if the same detector element is hit.

To use this buffer one has to derive his own buffer class from FairWriteoutBuffer and overwrite the pure virtual functions.

Definition at line 36 of file PndWriteoutBuffer.h.

Constructor & Destructor Documentation

PndWriteoutBuffer::PndWriteoutBuffer ( )
inline

Definition at line 38 of file PndWriteoutBuffer.h.

PndWriteoutBuffer::PndWriteoutBuffer ( TString  branchName,
TString  className,
TString  folderName,
Bool_t  persistance 
)

Definition at line 15 of file PndWriteoutBuffer.cxx.

References fBranchName, fClassName, and fTreeSave.

15  :
16  fBranchName(branchName), fClassName(className), fActivateBuffering(kTRUE), fVerbose(3)
17 {
18  FairRootManager::Instance()->Register(branchName, className, folderName, persistance);
19  if (fBranchName == "" || fClassName == "")
20  fTreeSave = false;
21  else
22  fTreeSave = true;
23 }
virtual PndWriteoutBuffer::~PndWriteoutBuffer ( )
inlinevirtual

Definition at line 40 of file PndWriteoutBuffer.h.

40 {};

Member Function Documentation

virtual void PndWriteoutBuffer::ActivateBuffering ( Bool_t  val = kTRUE)
inlinevirtual

fActivateBuffering has to be set to kTRUE to use the buffering. Otherwise the data is directly stored in the given TClonesArray.

Definition at line 46 of file PndWriteoutBuffer.h.

References fActivateBuffering, and val.

virtual void PndWriteoutBuffer::AddNewDataToTClonesArray ( FairTimeStamp *  data)
pure virtual

store the data from the FairTimeStamp pointer in a TClonesArray (you have to cast it to your type of data)

Referenced by FillNewData(), and WriteOutData().

PndWriteoutBuffer::ClassDef ( PndWriteoutBuffer  ,
 
)
protected
virtual void PndWriteoutBuffer::DeleteOldData ( )
inlinevirtual

Definition at line 54 of file PndWriteoutBuffer.h.

References fBranchName.

54  {
55  TClonesArray* myArray = FairRootManager::Instance()->GetTClonesArray(fBranchName);
56  myArray->Delete();
57  }
virtual void PndWriteoutBuffer::EraseDataFromDataMap ( FairTimeStamp *  data)
pure virtual

delete the element from the search buffer (see PndSdsDigiPixelWriteoutBuffer)

Referenced by FillNewData(), and GetRemoveOldData().

virtual void PndWriteoutBuffer::FillDataMap ( FairTimeStamp *  data,
double  activeTime 
)
pure virtual

add a new element in the search buffer

Referenced by FillNewData().

void PndWriteoutBuffer::FillNewData ( FairTimeStamp *  data,
double  activeTime 
)
virtual

Definition at line 79 of file PndWriteoutBuffer.cxx.

References AddNewDataToTClonesArray(), EraseDataFromDataMap(), fActivateBuffering, fDeadTime_map, FillDataMap(), FindTimeForData(), fVerbose, i, and Modify().

80 {
81  if (fActivateBuffering){
82  typedef std::multimap<double, FairTimeStamp*>::iterator DTMapIter;
83  typedef std::map<FairTimeStamp, double>::iterator DataMapIter;
84 
85  double timeOfOldData = FindTimeForData(data);
86  if(timeOfOldData > -1){ //if an older active data object is already present
87  if (fVerbose > 1) std::cout << " OldData found! " << std::endl;
88  if (fVerbose > 1) std::cout << "New Data: " << activeTime << " : " << data << std::endl;
89  double currentdeadtime = timeOfOldData;
90  FairTimeStamp* oldData;
91  for (DTMapIter it = fDeadTime_map.lower_bound(currentdeadtime); it != fDeadTime_map.upper_bound(currentdeadtime); it++){
92  oldData = it->second;
93  if (fVerbose > 1) std::cout << "Check Data: " << it->first << " : " << oldData << std::endl;
94  if (oldData->equal(data)){
95  if (fVerbose > 1) std::cout << " oldData == data " << std::endl;
96  if (fVerbose > 1) std::cout << it->first << " : " << it->second << std::endl;
97  fDeadTime_map.erase(it);
98  EraseDataFromDataMap(oldData);
99  break;
100  }
101  }
102  std::vector<std::pair<double, FairTimeStamp*> > modifiedData = Modify(std::pair<double, FairTimeStamp*>(currentdeadtime, oldData), std::pair<double, FairTimeStamp*>(-1, data));
103  for (int i = 0; i < modifiedData.size(); i++){
104  FillNewData(modifiedData[i].second, modifiedData[i].first);
105  if (fVerbose > 1) std::cout << i << " :Modified Data: " << modifiedData[i].first << " : " << modifiedData[i].second << std::endl;
106  }
107  }
108  else{
109  if (fVerbose > 1){
110  std::cout << "-I- PndWriteoutBuffer::FillNewData Data Inserted: " << activeTime << " : ";
111  data->Print();
112  std::cout << std::endl;
113  }
114  fDeadTime_map.insert(std::pair<double, FairTimeStamp*>(activeTime, data));
115  FillDataMap(data, activeTime);
116  }
117  }
118  else{
120  }
121 }
virtual void FillDataMap(FairTimeStamp *data, double activeTime)=0
add a new element in the search buffer
std::multimap< double, FairTimeStamp * > fDeadTime_map
Int_t i
Definition: run_full.C:25
virtual std::vector< std::pair< double, FairTimeStamp * > > Modify(std::pair< double, FairTimeStamp * > oldData, std::pair< double, FairTimeStamp * > newData)
virtual void EraseDataFromDataMap(FairTimeStamp *data)=0
delete the element from the search buffer (see PndSdsDigiPixelWriteoutBuffer)
virtual void FillNewData(FairTimeStamp *data, double activeTime)
virtual void AddNewDataToTClonesArray(FairTimeStamp *data)=0
store the data from the FairTimeStamp pointer in a TClonesArray (you have to cast it to your type of ...
virtual double FindTimeForData(FairTimeStamp *data)=0
if the same data object (like a pad or a pixel) is already present in the buffer, the time of this ob...
virtual double PndWriteoutBuffer::FindTimeForData ( FairTimeStamp *  data)
pure virtual

if the same data object (like a pad or a pixel) is already present in the buffer, the time of this object has to be returned otherwise -1

Referenced by FillNewData().

std::vector< FairTimeStamp * > PndWriteoutBuffer::GetAllData ( )
virtual

Definition at line 72 of file PndWriteoutBuffer.cxx.

References fDeadTime_map, and GetRemoveOldData().

73 {
74  return GetRemoveOldData(fDeadTime_map.rbegin()->first + 1);
75 }
std::multimap< double, FairTimeStamp * > fDeadTime_map
virtual std::vector< FairTimeStamp * > GetRemoveOldData(double time)
virtual Int_t PndWriteoutBuffer::GetNData ( )
inlinevirtual

Definition at line 51 of file PndWriteoutBuffer.h.

References fDeadTime_map.

51 {return fDeadTime_map.size();}
std::multimap< double, FairTimeStamp * > fDeadTime_map
std::vector< FairTimeStamp * > PndWriteoutBuffer::GetRemoveOldData ( double  time)
virtual

Definition at line 59 of file PndWriteoutBuffer.cxx.

References EraseDataFromDataMap(), fDeadTime_map, and fVerbose.

Referenced by GetAllData(), and WriteOutData().

60 {
61  typedef std::multimap<double, FairTimeStamp*>::iterator DTMapIter;
62  std::vector<FairTimeStamp*> result;
63  for(DTMapIter it = fDeadTime_map.begin(); it != fDeadTime_map.lower_bound(time); it++){
64  if (fVerbose > 1) std::cout << "-I- GetRemoveOldData: DeadTime: " << it->first << " Data: " << it->second << std::endl;
65  result.push_back(it->second);
66  EraseDataFromDataMap(it->second);
67  }
68  fDeadTime_map.erase(fDeadTime_map.begin(), fDeadTime_map.lower_bound(time));
69  return result;
70 }
std::multimap< double, FairTimeStamp * > fDeadTime_map
virtual void EraseDataFromDataMap(FairTimeStamp *data)=0
delete the element from the search buffer (see PndSdsDigiPixelWriteoutBuffer)
virtual std::vector<std::pair<double, FairTimeStamp*> > PndWriteoutBuffer::Modify ( std::pair< double, FairTimeStamp * >  oldData,
std::pair< double, FairTimeStamp * >  newData 
)
inlineprotectedvirtual

Modify defines the behavior of the buffer if data should be stored which is already in the buffer. Parameters are the old data with the active time, the new data with an active time. Modify returns than a vector with the new data which should be stored.

Definition at line 68 of file PndWriteoutBuffer.h.

Referenced by FillNewData().

68  {
69  std::vector<std::pair<double, FairTimeStamp*> > result;
70  result.push_back(oldData);
71  return result;
72  }
virtual void PndWriteoutBuffer::SaveDataToTree ( Bool_t  val = kTRUE)
inlinevirtual

If SaveDataToTree is set the data is stored at the end of the buffering into the given TClonesArray.

Definition at line 45 of file PndWriteoutBuffer.h.

References fTreeSave, and val.

virtual void PndWriteoutBuffer::SetVerbose ( Int_t  val)
inlinevirtual

Definition at line 63 of file PndWriteoutBuffer.h.

References fVerbose, and val.

63 {fVerbose = val;}
Double_t val[nBoxes][nFEBox]
Definition: createCalib.C:11
void PndWriteoutBuffer::WriteOutAllData ( )
virtual

Definition at line 52 of file PndWriteoutBuffer.cxx.

References fDeadTime_map, and WriteOutData().

53 {
54  if (fDeadTime_map.size() > 0){
55  WriteOutData(fDeadTime_map.rbegin()->first + 1);
56  }
57 }
std::multimap< double, FairTimeStamp * > fDeadTime_map
virtual void WriteOutData(double time)
void PndWriteoutBuffer::WriteOutData ( double  time)
virtual

Definition at line 25 of file PndWriteoutBuffer.cxx.

References AddNewDataToTClonesArray(), fActivateBuffering, fBranchName, fTreeSave, fVerbose, GetRemoveOldData(), and i.

Referenced by WriteOutAllData().

26 {
27  FairRootManager* ioman = FairRootManager::Instance();
28  std::vector<FairTimeStamp*> data;
29  if (fActivateBuffering){
30  if (fVerbose > 0) std::cout << "-I- PndWriteoutBuffer::WriteOutData for time: " << time << std::endl;
31  data = GetRemoveOldData(time);
32  if (fTreeSave && data.size() > 0){
33  TClonesArray* myArray = ioman->GetTClonesArray(fBranchName);
34  if (!myArray)
35  std::cout << "-E- PndWriteoutBuffer::WriteOutData " << fBranchName << " array is not available!" << std::endl;
36  if (fVerbose > 0) std::cout << "-I- PndWriteoutBuffer::WriteOutData size: " << data.size() << std::endl;
37  for (int i = 0; i < data.size(); i++){
39  if (fVerbose > 1){
40  std::cout << i << " : ";
41  data[i]->Print();
42  std::cout << std::endl;
43  }
44  }
45  }
46  }
47  else{
48  ioman->GetTClonesArray(fBranchName);
49  }
50 }
virtual std::vector< FairTimeStamp * > GetRemoveOldData(double time)
Int_t i
Definition: run_full.C:25
virtual void AddNewDataToTClonesArray(FairTimeStamp *data)=0
store the data from the FairTimeStamp pointer in a TClonesArray (you have to cast it to your type of ...

Member Data Documentation

Bool_t PndWriteoutBuffer::fActivateBuffering
protected

Definition at line 79 of file PndWriteoutBuffer.h.

Referenced by ActivateBuffering(), FillNewData(), and WriteOutData().

TString PndWriteoutBuffer::fBranchName
protected

Definition at line 76 of file PndWriteoutBuffer.h.

Referenced by DeleteOldData(), PndWriteoutBuffer(), and WriteOutData().

TString PndWriteoutBuffer::fClassName
protected

Definition at line 77 of file PndWriteoutBuffer.h.

Referenced by PndWriteoutBuffer().

std::multimap<double, FairTimeStamp*> PndWriteoutBuffer::fDeadTime_map
protected
Bool_t PndWriteoutBuffer::fTreeSave
protected

Definition at line 78 of file PndWriteoutBuffer.h.

Referenced by PndWriteoutBuffer(), SaveDataToTree(), and WriteOutData().

Int_t PndWriteoutBuffer::fVerbose
protected

Definition at line 80 of file PndWriteoutBuffer.h.

Referenced by FillNewData(), GetRemoveOldData(), SetVerbose(), and WriteOutData().


The documentation for this class was generated from the following files: