FairRoot/PandaRoot
Public Types | Public Member Functions | Protected Member Functions | Private Attributes | Friends | List of all members
PndMvdMQFileSamplerBursts Class Reference

#include <PndMvdMQFileSamplerBursts.h>

Inheritance diagram for PndMvdMQFileSamplerBursts:

Public Types

enum  { InputFileName = FairMQDevice::Last, Last }
 

Public Member Functions

 PndMvdMQFileSamplerBursts ()
 
virtual ~PndMvdMQFileSamplerBursts ()
 
void AddInputFileName (std::string tempString)
 
void AddInputChannelBranchName (std::pair< std::string, std::string > tempString)
 
void SetMaxIndex (int64_t tempInt)
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Protected Member Functions

virtual void Run ()
 
virtual void InitTask ()
 
virtual void InitBurstBuilder (std::string branchName)
 

Private Attributes

FairRunAna * fRunAna
 
FairFileSource * fSource
 
std::set< std::string > fPorts
 
std::multimap< std::string,
std::string > 
fPortBranchNameMap
 
std::vector< std::pair
< std::string, std::string > > 
fBranchNames
 
std::map< std::string,
std::vector< std::vector
< FairTimeStamp * > > > 
fOutputData
 
std::map< std::string, TObject * > fInputBranches
 
std::map< std::string,
PndBurstVectorBuilderBase * > 
fBurstBuilder
 
std::vector< FairTimeStamp * > fHitVector
 
FairEventHeader * fEventHeader
 
int fNObjects
 
int64_t fMaxIndex
 
std::vector< std::string > fFileNames
 

Friends

class boost::serialization::access
 

Detailed Description

Definition at line 83 of file PndMvdMQFileSamplerBursts.h.

Member Enumeration Documentation

anonymous enum
Enumerator
InputFileName 
Last 

Definition at line 86 of file PndMvdMQFileSamplerBursts.h.

Constructor & Destructor Documentation

PndMvdMQFileSamplerBursts::PndMvdMQFileSamplerBursts ( )

Definition at line 44 of file PndMvdMQFileSamplerBursts.cxx.

45  : FairMQDevice()
46  , fRunAna(NULL)
47  , fSource(NULL)
48  , fOutputData()
49  , fNObjects(0)
50  , fMaxIndex(-1)
51  , fBranchNames()
52  , fFileNames()
53  , fEventHeader(0)
54 {
55 }
std::vector< std::pair< std::string, std::string > > fBranchNames
std::vector< std::string > fFileNames
std::map< std::string, std::vector< std::vector< FairTimeStamp * > > > fOutputData
PndMvdMQFileSamplerBursts::~PndMvdMQFileSamplerBursts ( )
virtual

Definition at line 57 of file PndMvdMQFileSamplerBursts.cxx.

References fBurstBuilder, fRunAna, and fSource.

58 {
59  for (auto itr : fBurstBuilder)
60  delete itr.second;
61  delete fSource;
62  delete fRunAna;
63 }
std::map< std::string, PndBurstVectorBuilderBase * > fBurstBuilder

Member Function Documentation

void PndMvdMQFileSamplerBursts::AddInputChannelBranchName ( std::pair< std::string, std::string >  tempString)
inline

Definition at line 96 of file PndMvdMQFileSamplerBursts.h.

References fBranchNames, fPortBranchNameMap, and fPorts.

Referenced by main().

96  {
97  fPortBranchNameMap.insert(std::pair<std::string, std::string>(tempString.first, tempString.second));
98  fBranchNames.push_back(tempString);
99  fPorts.insert(tempString.first);
100  }
std::vector< std::pair< std::string, std::string > > fBranchNames
std::multimap< std::string, std::string > fPortBranchNameMap
void PndMvdMQFileSamplerBursts::AddInputFileName ( std::string  tempString)
inline

Definition at line 95 of file PndMvdMQFileSamplerBursts.h.

References fFileNames.

Referenced by main().

95 { fFileNames.push_back(tempString);}
std::vector< std::string > fFileNames
void PndMvdMQFileSamplerBursts::InitBurstBuilder ( std::string  branchName)
protectedvirtual

Definition at line 94 of file PndMvdMQFileSamplerBursts.cxx.

References fBurstBuilder.

Referenced by InitTask().

95 {
96  PndBurstVectorBuilderBase* tmpBuilder = 0;
97  if (branchName == "MVDPixelDigis")
99  else if (branchName == "MVDStripDigis")
101  else if (branchName == "STTHit")
102  tmpBuilder = new PndBurstVectorBuilderT<PndSttHit>;
103  else if (branchName == "MVDHitsStrip")
104  tmpBuilder = new PndBurstVectorBuilderT<PndSdsHit>;
105 
106  if (tmpBuilder != 0)
107  fBurstBuilder[branchName] = tmpBuilder;
108 }
std::map< std::string, PndBurstVectorBuilderBase * > fBurstBuilder
void PndMvdMQFileSamplerBursts::InitTask ( )
protectedvirtual

Definition at line 65 of file PndMvdMQFileSamplerBursts.cxx.

References fBranchNames, fEventHeader, fFileNames, fInputBranches, fMaxIndex, fNObjects, fRunAna, fSource, and InitBurstBuilder().

66 {
67  fRunAna = new FairRunAna();
68  if ( fFileNames.size() > 0 ) {
69  fSource = new FairFileSource(fFileNames.at(0).c_str());
70  for ( unsigned int ifile = 1 ; ifile < fFileNames.size() ; ifile++ )
71  fSource->AddFile(fFileNames.at(ifile));
72  }
73  fSource->Init();
74  LOG(INFO) << "Going to request " << fBranchNames.size() << " branches:";
75 
76  fSource->ActivateObject((TObject**)&fEventHeader, "EventHeader.");
77 
78  for ( unsigned int ibrn = 0 ; ibrn < fBranchNames.size() ; ibrn++ ) {
79 
80  LOG(INFO) << " requesting branch \"" << fBranchNames[ibrn].second << "\"";
81  std::string branchName = fBranchNames[ibrn].second;
82  int branchStat = fSource->ActivateObject((TObject**)&fInputBranches[branchName], branchName.c_str()); // should check the status...
83  LOG(INFO) << "BranchStat: " << branchStat;
84  InitBurstBuilder(branchName);
85  LOG(INFO) << "Activated object \"" << fInputBranches[branchName] << "\" with name \"" << fBranchNames[ibrn].second << " for channel " << fBranchNames[ibrn].first <<"/ (" << branchStat << ")";
86  fNObjects++;
87  }
88 
89  if ( fMaxIndex < 0 )
90  fMaxIndex = fSource->CheckMaxEventNo();
91  LOG(INFO) << "Input source has " << fMaxIndex << " events.";
92 }
std::vector< std::pair< std::string, std::string > > fBranchNames
virtual void InitBurstBuilder(std::string branchName)
std::vector< std::string > fFileNames
std::map< std::string, TObject * > fInputBranches
void PndMvdMQFileSamplerBursts::Run ( )
protectedvirtual

Definition at line 126 of file PndMvdMQFileSamplerBursts.cxx.

References BurstHeader::fBranchName, fBurstBuilder, BurstHeader::fBurstID, BurstData::fData, fEventHeader, BurstData::fHeader, fInputBranches, fMaxIndex, fOutputData, fPortBranchNameMap, fPorts, free_string(), BurstHeader::fRunID, fSource, and if().

126  {
127  int eventCounter = 0;
128 
129  // Check if we are still in the RUNNING state.
130 // boost::this_thread::sleep(boost::posix_time::milliseconds(100000));
131  while (CheckCurrentState(RUNNING)) {
132  if (eventCounter != fMaxIndex){
133 
134  Int_t readEventReturn = fSource->ReadEvent(eventCounter);
135 
136  if (readEventReturn != 0)
137  break;
138 
139 // if (fEventHeader != 0)
140 // LOG(INFO) << "EventHeader: " << fEventHeader->GetRunId() << " " << fEventHeader->GetEventTime() << std::endl;
141 
142  for (auto branchItr : fInputBranches){
143  if (branchItr.first.find(".") == std::string::npos){
144  std::vector<std::vector< FairTimeStamp* > > data;
145  TClonesArray* tmpArray = (TClonesArray*)branchItr.second;
146 
147  if (fBurstBuilder.count(branchItr.first) > 0){
148  fOutputData[branchItr.first] = fBurstBuilder[branchItr.first]->ProcessData(tmpArray);
149  // LOG(INFO) << branchItr.first << " has " << fOutputData[branchItr.first].size() << " bursts! ";
150  }
151  }
152  }
153  } else {
154  LOG(INFO) << "FinishRun";
155  for (auto branchItr : fInputBranches){
156  if (branchItr.first.find(".") == std::string::npos){
157  if (fBurstBuilder.count(branchItr.first) > 0){
158  fOutputData[branchItr.first] = fBurstBuilder[branchItr.first]->GetLastData();
159  // LOG(INFO) << branchItr.first << " has " << fOutputData[branchItr.first].size() << " last bursts! ";
160  // for (auto dataItr : fOutputData[branchItr.first]){
161  // LOG(INFO) << branchItr.first << " has data: " << dataItr.size();
162  // }
163  }
164  }
165  }
166  }
167 
168  for (auto portIt = fPorts.begin(); portIt != fPorts.end(); portIt++){
169  for (auto branchIt = fPortBranchNameMap.lower_bound(*portIt); branchIt != fPortBranchNameMap.upper_bound(*portIt); ++branchIt){
170 // LOG(INFO) << branchIt->second << " burstSize " << fOutputData[branchIt->second].size();
171  for (auto dataIt = fOutputData[branchIt->second].begin(); dataIt != fOutputData[branchIt->second].end(); ++dataIt){
172 // LOG(INFO) << branchIt->second << " dataSize " << dataIt->size();
173  if (dataIt->size() > 0){
174  BurstData bData;// = new BurstData;
175  std::vector<std::vector<FairTimeStamp*> > dataVector;
176  dataVector.push_back(*dataIt);
177  bData.fData = dataVector;
178  bData.fHeader.fBranchName = branchIt->second;
179  bData.fHeader.fRunID = fEventHeader->GetRunId();
180  bData.fHeader.fBurstID = fBurstBuilder[branchIt->second]->GetBurstId(dataVector[0][0]);
181  std::ostringstream obuffer;
182  boost::archive::binary_oarchive OutputArchive(obuffer);
183  OutputArchive << bData;
184  std::string* strMsg = new std::string(obuffer.str());
185  unique_ptr<FairMQMessage> msg(NewMessage(const_cast<char*>(strMsg->c_str()), strMsg->length(), free_string, strMsg));
186  LOG(INFO) << "Send message: " << bData.fHeader.fBranchName << " " << bData.fHeader.fBurstID << " size: " << msg->GetSize();
187  //LOG(INFO) << obuffer.str();
188  Send(msg, *portIt);
189  }
190  }
191  }
192  }
193  if (eventCounter != fMaxIndex){
194  eventCounter++;
195  }
196  else
197  break;
198  }
199  LOG(INFO) << "Going out of RUNNING state.";
200 }
std::map< std::string, PndBurstVectorBuilderBase * > fBurstBuilder
void free_string(void *data, void *hint)
std::vector< std::vector< FairTimeStamp * > > fData
std::multimap< std::string, std::string > fPortBranchNameMap
std::map< std::string, std::vector< std::vector< FairTimeStamp * > > > fOutputData
if(fWindowIsBox)
std::map< std::string, TObject * > fInputBranches
template<class Archive >
void PndMvdMQFileSamplerBursts::serialize ( Archive &  ar,
const unsigned int  version 
)
inline

Definition at line 105 of file PndMvdMQFileSamplerBursts.h.

References fHitVector.

106  {
107  ar & fHitVector;
108  }
std::vector< FairTimeStamp * > fHitVector
void PndMvdMQFileSamplerBursts::SetMaxIndex ( int64_t  tempInt)
inline

Definition at line 102 of file PndMvdMQFileSamplerBursts.h.

References fMaxIndex.

Referenced by main().

Friends And Related Function Documentation

friend class boost::serialization::access
friend

Definition at line 111 of file PndMvdMQFileSamplerBursts.h.

Member Data Documentation

std::vector<std::pair<std::string, std::string> > PndMvdMQFileSamplerBursts::fBranchNames
private

Definition at line 125 of file PndMvdMQFileSamplerBursts.h.

Referenced by AddInputChannelBranchName(), and InitTask().

std::map<std::string, PndBurstVectorBuilderBase*> PndMvdMQFileSamplerBursts::fBurstBuilder
private

Definition at line 128 of file PndMvdMQFileSamplerBursts.h.

Referenced by InitBurstBuilder(), Run(), and ~PndMvdMQFileSamplerBursts().

FairEventHeader* PndMvdMQFileSamplerBursts::fEventHeader
private

Definition at line 130 of file PndMvdMQFileSamplerBursts.h.

Referenced by InitTask(), and Run().

std::vector<std::string> PndMvdMQFileSamplerBursts::fFileNames
private

Definition at line 136 of file PndMvdMQFileSamplerBursts.h.

Referenced by AddInputFileName(), and InitTask().

std::vector<FairTimeStamp*> PndMvdMQFileSamplerBursts::fHitVector
private

Definition at line 129 of file PndMvdMQFileSamplerBursts.h.

Referenced by serialize().

std::map<std::string, TObject* > PndMvdMQFileSamplerBursts::fInputBranches
private

Definition at line 127 of file PndMvdMQFileSamplerBursts.h.

Referenced by InitTask(), and Run().

int64_t PndMvdMQFileSamplerBursts::fMaxIndex
private

Definition at line 134 of file PndMvdMQFileSamplerBursts.h.

Referenced by InitTask(), Run(), and SetMaxIndex().

int PndMvdMQFileSamplerBursts::fNObjects
private

Definition at line 133 of file PndMvdMQFileSamplerBursts.h.

Referenced by InitTask().

std::map<std::string, std::vector< std::vector<FairTimeStamp*> > > PndMvdMQFileSamplerBursts::fOutputData
private

Definition at line 126 of file PndMvdMQFileSamplerBursts.h.

Referenced by Run().

std::multimap<std::string, std::string> PndMvdMQFileSamplerBursts::fPortBranchNameMap
private

Definition at line 124 of file PndMvdMQFileSamplerBursts.h.

Referenced by AddInputChannelBranchName(), and Run().

std::set<std::string> PndMvdMQFileSamplerBursts::fPorts
private

Definition at line 123 of file PndMvdMQFileSamplerBursts.h.

Referenced by AddInputChannelBranchName(), and Run().

FairRunAna* PndMvdMQFileSamplerBursts::fRunAna
private

Definition at line 121 of file PndMvdMQFileSamplerBursts.h.

Referenced by InitTask(), and ~PndMvdMQFileSamplerBursts().

FairFileSource* PndMvdMQFileSamplerBursts::fSource
private

Definition at line 122 of file PndMvdMQFileSamplerBursts.h.

Referenced by InitTask(), Run(), and ~PndMvdMQFileSamplerBursts().


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