FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FairTestDetectorDigiWriteoutBuffer.cxx
Go to the documentation of this file.
1 /********************************************************************************
2  * Copyright (C) 2014 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 /*
9  * FairTestDetectorDigiWriteoutBuffer.cxx
10  *
11  * Created on: May 10, 2011
12  * Author: stockman
13  */
14 
16 
17 #include "FairLogger.h" // for logging
18 #include "FairRootManager.h" // for FairRootManager
19 #include "FairTestDetectorDigi.h" // for FairTestDetectorDigi, etc
20 
21 #include <TClonesArray.h> // for TClonesArray
22 #include <utility> // for pair
23 
25 
28  , fData_map()
29 {
30  // TODO Auto-generated constructor stub
31 }
32 
34  TString folderName,
35  Bool_t persistance)
36  : FairWriteoutBuffer(branchName, "FairTestDetectorDigi", folderName, persistance)
37  , fData_map()
38 {}
39 
41 {
42  // TODO Auto-generated destructor stub
43 }
44 
46 {
48  TClonesArray* myArray = ioman->GetTClonesArray(fBranchName);
49  if (fVerbose > 1) {
50  LOG(info) << "Data Inserted: " << static_cast<FairTestDetectorDigi*>(data)->ToString();
51  }
52  new ((*myArray)[myArray->GetEntries()]) FairTestDetectorDigi(*static_cast<FairTestDetectorDigi*>((data)));
53 }
54 
56 {
57  std::map<FairTestDetectorDigi, double>::iterator it;
58  FairTestDetectorDigi myData = *static_cast<FairTestDetectorDigi*>(data);
59  it = fData_map.find(myData);
60  if (it == fData_map.end()) {
61  return -1;
62  } else {
63  return it->second;
64  }
65 }
66 
68 {
69  FairTestDetectorDigi myData = *static_cast<FairTestDetectorDigi*>(data);
70  fData_map[myData] = activeTime;
71 }
72 
74 {
75  FairTestDetectorDigi myData = *static_cast<FairTestDetectorDigi*>(data);
76  if (fData_map.find(myData) != fData_map.end()) {
77  fData_map.erase(fData_map.find(myData));
78  }
79 }
virtual double FindTimeForData(FairTimeStamp *data)
static FairRootManager * Instance()
ClassImp(FairEventBuilder)
TClonesArray * GetTClonesArray(TString branchName)
virtual void FillDataMap(FairTimeStamp *data, double activeTime)
add a new element in the search buffer
std::map< FairTestDetectorDigi, double > fData_map
virtual void EraseDataFromDataMap(FairTimeStamp *data)
delete the element from the search buffer (see PndSdsDigiPixelWriteoutBuffer)
A container class to store digi data during events.