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

#include <PndMvdMQFileSampler.h>

Inheritance diagram for PndMvdMQFileSampler:

Public Types

enum  { InputFileName = FairMQDevice::Last, Last }
 
enum  { InputFileName = FairMQDevice::Last, Last }
 

Public Member Functions

 PndMvdMQFileSampler ()
 
virtual ~PndMvdMQFileSampler ()
 
void AddInputFileName (std::string tempString)
 
void AddInputChannelBranchName (std::pair< std::string, std::string > tempString)
 
void SetMaxIndex (int64_t tempInt)
 
 PndMvdMQFileSampler ()
 
virtual ~PndMvdMQFileSampler ()
 
void AddInputFileName (std::string tempString)
 
void AddInputBranchName (std::string tempString)
 
void SetMaxIndex (int64_t tempInt)
 

Protected Member Functions

virtual void Run ()
 
virtual void InitTask ()
 
virtual void Run ()
 
virtual void InitTask ()
 

Private Attributes

FairRunAna * fRunAna
 
FairFileSource * fSource
 
std::multimap< std::string,
TObject * > 
fInputObjects
 
std::map< std::string, TObject * > fInputBranches
 
TObject * fEventHeaderPointer
 
std::set< std::string > fPorts
 
int fNObjects
 
int64_t fMaxIndex
 
std::vector< std::pair
< std::string, std::string > > 
fBranchNames
 
std::vector< std::string > fFileNames
 
TObject * fInputObjects [100]
 
std::vector< std::string > fBranchNames
 

Detailed Description

FairMQEx9Sampler.h

Since
2016-03-08
Author
R. Karabowicz

Definition at line 27 of file MvdMQ/src/devices/PndMvdMQFileSampler.h.

Member Enumeration Documentation

anonymous enum
anonymous enum
Enumerator
InputFileName 
Last 

Definition at line 30 of file MvdMQ/src/devices/PndMvdMQFileSampler.h.

Constructor & Destructor Documentation

PndMvdMQFileSampler::PndMvdMQFileSampler ( )

Definition at line 28 of file MvdMQ/src/devices/PndMvdMQFileSampler.cxx.

29  : FairMQDevice()
30  , fRunAna(NULL)
31  , fSource(NULL)
32  , fInputObjects()
33  , fNObjects(0)
34  , fMaxIndex(-1)
35  , fBranchNames()
36  , fFileNames()
37 {
38 }
std::vector< std::string > fFileNames
std::multimap< std::string, TObject * > fInputObjects
std::vector< std::pair< std::string, std::string > > fBranchNames
PndMvdMQFileSampler::~PndMvdMQFileSampler ( )
virtual

Definition at line 108 of file MvdMQ/src/devices/PndMvdMQFileSampler.cxx.

109 {
110 }
PndMvdMQFileSampler::PndMvdMQFileSampler ( )
virtual PndMvdMQFileSampler::~PndMvdMQFileSampler ( )
virtual

Member Function Documentation

void PndMvdMQFileSampler::AddInputBranchName ( std::string  tempString)
inline

Definition at line 40 of file MvdOfflineTBAnalysis_Topix4/MQ/PndMvdMQFileSampler.h.

References fBranchNames.

Referenced by main().

40 { fBranchNames.push_back(tempString); }
std::vector< std::pair< std::string, std::string > > fBranchNames
void PndMvdMQFileSampler::AddInputChannelBranchName ( std::pair< std::string, std::string >  tempString)
inline

Definition at line 40 of file MvdMQ/src/devices/PndMvdMQFileSampler.h.

References fBranchNames, and fPorts.

Referenced by main().

40  {
41  fBranchNames.push_back(tempString);
42  fPorts.insert(tempString.first);
43  }
std::vector< std::pair< std::string, std::string > > fBranchNames
void PndMvdMQFileSampler::AddInputFileName ( std::string  tempString)
inline

Definition at line 39 of file MvdMQ/src/devices/PndMvdMQFileSampler.h.

References fFileNames.

Referenced by main().

39 { fFileNames .push_back(tempString);}
std::vector< std::string > fFileNames
void PndMvdMQFileSampler::AddInputFileName ( std::string  tempString)
inline

Definition at line 39 of file MvdOfflineTBAnalysis_Topix4/MQ/PndMvdMQFileSampler.h.

References fFileNames.

39 { fFileNames .push_back(tempString); }
std::vector< std::string > fFileNames
virtual void PndMvdMQFileSampler::InitTask ( )
protectedvirtual
void PndMvdMQFileSampler::InitTask ( )
protectedvirtual

Definition at line 40 of file MvdMQ/src/devices/PndMvdMQFileSampler.cxx.

References fBranchNames, fFileNames, fInputBranches, fInputObjects, fMaxIndex, fNObjects, fRunAna, and fSource.

41 {
42  fRunAna = new FairRunAna();
43  if ( fFileNames.size() > 0 ) {
44  fSource = new FairFileSource(fFileNames.at(0).c_str());
45  for ( unsigned int ifile = 1 ; ifile < fFileNames.size() ; ifile++ )
46  fSource->AddFile(fFileNames.at(ifile));
47  }
48  fSource->Init();
49  LOG(INFO) << "Going to request " << fBranchNames.size() << " branches:";
50  for ( unsigned int ibrn = 0 ; ibrn < fBranchNames.size() ; ibrn++ ) {
51  LOG(INFO) << " requesting branch \"" << fBranchNames[ibrn].second << "\"";
52  int branchStat = fSource->ActivateObject((TObject**)&fInputBranches[fBranchNames[ibrn].second],fBranchNames[ibrn].second.c_str()); // should check the status...
53  LOG(INFO) << "BranchStat: " << branchStat;
54  if ( fInputBranches[fBranchNames[ibrn].second] ) {
55  fInputObjects.insert(std::pair<std::string, TObject*>(fBranchNames[ibrn].first, fInputBranches[fBranchNames[ibrn].second]));
56  LOG(INFO) << "Activated object \"" << fInputBranches[fBranchNames[ibrn].second] << "\" with name \"" << fBranchNames[ibrn].second << " for channel " << fBranchNames[ibrn].first <<"/ (" << branchStat << ")";
57  fNObjects++;
58  }
59  }
60  if ( fMaxIndex < 0 )
61  fMaxIndex = fSource->CheckMaxEventNo();
62  LOG(INFO) << "Input source has " << fMaxIndex << " events.";
63 }
std::vector< std::string > fFileNames
std::multimap< std::string, TObject * > fInputObjects
std::vector< std::pair< std::string, std::string > > fBranchNames
std::map< std::string, TObject * > fInputBranches
virtual void PndMvdMQFileSampler::Run ( )
protectedvirtual
void PndMvdMQFileSampler::Run ( )
protectedvirtual

Definition at line 71 of file MvdMQ/src/devices/PndMvdMQFileSampler.cxx.

References fInputObjects, fMaxIndex, fPorts, free_tmessage2(), and fSource.

71  {
72  int eventCounter = 0;
73 
74  // Check if we are still in the RUNNING state.
75  while (CheckCurrentState(RUNNING)) {
76  if (eventCounter == fMaxIndex)
77  break;
78 
79  Int_t readEventReturn = fSource->ReadEvent(eventCounter);
80 
81  if (readEventReturn != 0)
82  break;
83 
84  int messageIter = 0;
85  for (std::set<std::string>::iterator portIt = fPorts.begin(); portIt != fPorts.end(); portIt++){
86  FairMQParts parts;
87  TMessage* message[1000];
88  for (std::multimap<std::string, TObject*>::iterator dataIt = fInputObjects.lower_bound(*portIt); dataIt != fInputObjects.upper_bound(*portIt); ++dataIt){
89  TNamed* data = (TNamed*)(dataIt->second);
90  LOG(INFO) << *portIt << " : " << dataIt->second << " " << dataIt->second->ClassName() << " " << dataIt->second->GetName();
91  if ( strcmp(dataIt->second->ClassName(),"FairEventHeader") == 0 )
92  LOG(INFO) << "RunNumber: " << ((FairEventHeader*)dataIt->second)->GetRunId();
93  message[messageIter] = new TMessage(kMESS_OBJECT);
94  message[messageIter]->WriteObject(dataIt->second);
95  parts.AddPart(NewMessage(message[messageIter]->Buffer(), message[messageIter]->BufferSize(), free_tmessage2, message[messageIter]));
96  messageIter++;
97  }
98  LOG(INFO) << "Send!";
99  Send(parts, *portIt);
100  }
101 
102  eventCounter++;
103  }
104 
105  LOG(INFO) << "Going out of RUNNING state.";
106 }
void free_tmessage2(void *, void *hint)
std::multimap< std::string, TObject * > fInputObjects
void PndMvdMQFileSampler::SetMaxIndex ( int64_t  tempInt)
inline
void PndMvdMQFileSampler::SetMaxIndex ( int64_t  tempInt)
inline

Definition at line 45 of file MvdMQ/src/devices/PndMvdMQFileSampler.h.

References fMaxIndex.

Referenced by main().

Member Data Documentation

std::vector<std::string> PndMvdMQFileSampler::fBranchNames
private
std::vector<std::pair<std::string, std::string> > PndMvdMQFileSampler::fBranchNames
private
TObject* PndMvdMQFileSampler::fEventHeaderPointer
private

Definition at line 56 of file MvdMQ/src/devices/PndMvdMQFileSampler.h.

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

Definition at line 61 of file MvdMQ/src/devices/PndMvdMQFileSampler.h.

Referenced by AddInputFileName(), and InitTask().

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

Definition at line 55 of file MvdMQ/src/devices/PndMvdMQFileSampler.h.

Referenced by InitTask().

TObject* PndMvdMQFileSampler::fInputObjects[100]
private
std::multimap<std::string, TObject*> PndMvdMQFileSampler::fInputObjects
private

Definition at line 54 of file MvdMQ/src/devices/PndMvdMQFileSampler.h.

Referenced by InitTask(), and Run().

int64_t PndMvdMQFileSampler::fMaxIndex
private

Definition at line 59 of file MvdMQ/src/devices/PndMvdMQFileSampler.h.

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

int PndMvdMQFileSampler::fNObjects
private

Definition at line 58 of file MvdMQ/src/devices/PndMvdMQFileSampler.h.

Referenced by InitTask().

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

Definition at line 57 of file MvdMQ/src/devices/PndMvdMQFileSampler.h.

Referenced by AddInputChannelBranchName(), and Run().

FairRunAna * PndMvdMQFileSampler::fRunAna
private

Definition at line 52 of file MvdMQ/src/devices/PndMvdMQFileSampler.h.

Referenced by InitTask().

FairFileSource * PndMvdMQFileSampler::fSource
private

Definition at line 53 of file MvdMQ/src/devices/PndMvdMQFileSampler.h.

Referenced by InitTask(), and Run().


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