PandaRoot
PndProcessTask Class Referenceabstract

Task based version of a PndProcessHandler. More...

#include <PndProcessTask.h>

Inheritance diagram for PndProcessTask:
PndPersistencyTask PndProcessHandler BSEmcClusteringTask BSEmcDigitizerTask BSEmcMCDepositProducerTask BSEmcPlotTask TestPndProcessTask

Public Member Functions

 PndProcessTask (const std::string &t_detectorName)
 
virtual ~PndProcessTask ()
 
virtual InitStatus Init () final
 Initialise this task. This must be called AFTER SetParContainers(), otherwise we will try to pass the parameters to the PndProcesses, while the parameter were not fetched yet. More...
 
virtual void Exec (Option_t *t_opt=nullptr)
 Prepare Task for processing of PndProcess (e.g. reset data arrays), process the PndProcesses and do cleanup during the PostProcessing. More...
 
virtual void Finish ()
 End the task, call TearDown for all PndProcesses. More...
 
- Public Member Functions inherited from PndPersistencyTask
 PndPersistencyTask ()
 
 PndPersistencyTask (const char *name, Int_t iVerbose=1)
 
virtual ~PndPersistencyTask ()
 
void SetPersistency (Bool_t val=kTRUE)
 
Bool_t GetPersistency ()
 
- Public Member Functions inherited from PndProcessHandler
 PndProcessHandler (const std::string &t_detectorname="")
 
virtual ~PndProcessHandler ()
 
void AddProcess (PndProcess *)
 Add a PndProcess of appropriate type to the list of PndProcesses to be managed. More...
 
void SetupProcesses ()
 Call for each PndProcess the SetupParameter. More...
 
const std::vector< PndProcess * > & GetProcesses ()
 
PndParameterRegisterGetParameterRegister ()
 
const PndParameterRegisterGetParameterRegister () const
 
const std::string & GetDetectorName () const
 
virtual void GetRequiredDataContainerInfo ()
 
virtual void PassDataContainersToProcesses ()
 

Protected Member Functions

void SetParContainers () final
 Fetch the FairRuntimeDb and populate the PndParameterRegister with all requested parameter. Has to be called before Init() More...
 
virtual void PreProcessing (Option_t *)
 Do some task preparation before PndProcesses are run once per event. More...
 
virtual void PostProcessing (Option_t *)
 Do some task post clean up after PndProcesses are run once per event. More...
 
virtual void SetupDataArrays ()=0
 Define which data containers need to be fetched from the FairRootManager, pass the data container addresses into a simple struct to distribute the addresses to the PndProcesses so they can read and write the data to them. Needs to be implemented in the derived PndProcessTask, such as the BSEmcClusteringTask. More...
 
template<class T >
Bool_t DispatchRequest (const PndContainerRegister::PndContainerType_t &t_container, PndContainerRegister *t_register, const TString &t_defaultName)
 
TClonesArray * GetInputArray (const TString &t_branchname, const TString &t_classtype)
 
TClonesArray * GetOutputArray (const TString &t_branchname, const TString &t_classtype, const TString &t_foldername, Bool_t t_persistenxy)
 
template<class T >
Bool_t HandledRequest (const PndContainerRegister::PndContainerType_t &t_container, PndContainerRegister *t_register, const TString &t_defaultName)
 
- Protected Member Functions inherited from PndProcessHandler
virtual void SetupProcess (PndProcess *t_process)
 

Additional Inherited Members

- Protected Attributes inherited from PndProcessHandler
std::vector< PndProcess * > fProcesses {}
 
std::unique_ptr< PndParameterRegisterfParameterRegister {new PndParameterRegister}
 
std::unique_ptr< PndContainerRegisterfContainerRegister {new PndContainerRegister}
 
std::string fDetectorName {""}
 

Detailed Description

Task based version of a PndProcessHandler.

Author
Ben Salisbury salis.nosp@m.bury.nosp@m.@hisk.nosp@m.p.un.nosp@m.i-bon.nosp@m.n.de, HISKP Bonn
Date
2021-02
Template Parameters
DataStruct

Definition at line 42 of file PndProcessTask.h.

Constructor & Destructor Documentation

◆ PndProcessTask()

PndProcessTask::PndProcessTask ( const std::string &  t_detectorName)

◆ ~PndProcessTask()

virtual PndProcessTask::~PndProcessTask ( )
virtual

Member Function Documentation

◆ DispatchRequest()

template<class T >
Bool_t PndProcessTask::DispatchRequest ( const PndContainerRegister::PndContainerType_t t_container,
PndContainerRegister t_register,
const TString &  t_defaultName 
)
inlineprotected

Definition at line 93 of file PndProcessTask.h.

References PndContainerRegister::PndContainerType_t::fClassType, and PndProcessHandler::fDetectorName.

94  {
95  if (t_container.fClassType == T().ClassName()) {
96  if (!HandledRequest<T>(t_container, t_register, t_defaultName)) {
97  LOG(error) << "PndProcessTask::DispatchRequest(): " << this->fDetectorName << " - No " << t_container.fClassType << " branch found. Aborting.";
98  throw std::exception(); // Exception is catched in PndProcessTask::Init(), which will return kERROR InitStatus
99  }
100  return true;
101  }
102  return false;
103  }
std::string fDetectorName

◆ Exec()

virtual void PndProcessTask::Exec ( Option_t *  t_opt = nullptr)
virtual

Prepare Task for processing of PndProcess (e.g. reset data arrays), process the PndProcesses and do cleanup during the PostProcessing.

Reimplemented in TestPndProcessTask.

◆ Finish()

virtual void PndProcessTask::Finish ( )
virtual

End the task, call TearDown for all PndProcesses.

◆ GetInputArray()

TClonesArray* PndProcessTask::GetInputArray ( const TString &  t_branchname,
const TString &  t_classtype 
)
inlineprotected

Definition at line 105 of file PndProcessTask.h.

Referenced by HandledRequest().

106  {
107  TClonesArray *tca{nullptr};
108  FairRootManager *ioman = FairRootManager::Instance();
109  if (ioman == nullptr) {
110  throw std::runtime_error("FairRootManager::Instance() returned nullptr");
111  } else {
112  tca = dynamic_cast<TClonesArray *>(ioman->GetObject(t_branchname));
113  if (tca == nullptr) {
114  LOG(error) << "PndTCAConstContainer<" << t_classtype << ">::Init(" << t_branchname << "): No " << t_classtype << " array with name " << t_branchname << " found!";
115  return tca;
116  }
117  }
118  return tca;
119  }

◆ GetOutputArray()

TClonesArray* PndProcessTask::GetOutputArray ( const TString &  t_branchname,
const TString &  t_classtype,
const TString &  t_foldername,
Bool_t  t_persistenxy 
)
inlineprotected

Definition at line 121 of file PndProcessTask.h.

Referenced by HandledRequest().

122  {
123  TClonesArray *tca{nullptr};
124  FairRootManager *ioman = FairRootManager::Instance();
125  if (ioman == nullptr) {
126  throw std::runtime_error("FairRootManager::Instance() returned nullptr");
127  } else {
128  if (ioman->CheckBranch(t_branchname) == 0) {
129  LOG(debug) << "Attempting to register " << t_branchname << " as a container for " << t_classtype << " in folder " << t_foldername;
130  tca = ioman->Register(t_branchname, t_classtype, t_foldername, t_persistenxy);
131  } else {
132  tca = dynamic_cast<TClonesArray *>(ioman->GetObject(t_branchname));
133  if (tca == nullptr) {
134  LOG(error) << "PndTCAMutableContainer<" << t_classtype << ">::Init(" << t_branchname << "): No " << t_classtype << " array with name " << t_branchname
135  << " already exists but could not be fetched!";
136 
137  return tca;
138  }
139  LOG(debug) << "Found a branch already called " << t_branchname << ". Using this for container for " << t_classtype << " in folder " << t_foldername;
140  }
141  }
142  return tca;
143  }

◆ HandledRequest()

template<class T >
Bool_t PndProcessTask::HandledRequest ( const PndContainerRegister::PndContainerType_t t_container,
PndContainerRegister t_register,
const TString &  t_defaultName 
)
inlineprotected

Definition at line 146 of file PndProcessTask.h.

References PndContainerRegister::PndContainerType_t::fBranchname, PndContainerRegister::PndContainerType_t::fClassType, PndProcessHandler::fDetectorName, PndContainerRegister::PndContainerType_t::fIsOutput, PndContainerRegister::PndContainerType_t::fIsPersistent, GetInputArray(), GetOutputArray(), PndContainerRegister::IsBranchSet(), PndContainerRegister::PndContainerType_t::RequestsSpecificBranch(), PndContainerBaseI::SetBranchName(), PndContainerRegister::SetInput(), PndContainerRegister::SetOutput(), PndMutableContainerI< T >::SetPersistency(), PndTCAConstContainer< T >::SetTCA(), PndTCAMutableContainer< T >::SetTCA(), and status.

147  {
148 
149  TString branchname = (t_container.RequestsSpecificBranch()) ? t_container.fBranchname : t_defaultName;
150  LOG(debug) << "PndProcessTask::HandledRequest " << t_container.fBranchname << "(" << branchname << ") for " << t_container.fClassType;
151 
152  if (t_register->IsBranchSet(branchname)) {
153  return true;
154  }
155  Bool_t status = kFALSE;
156  if (t_container.fIsOutput) {
157 
159  output->SetPersistency(t_container.fIsPersistent);
160  output->SetTCA(GetOutputArray(branchname, t_container.fClassType, "Emc" + fDetectorName, t_container.fIsPersistent));
161  output->SetBranchName(branchname);
162 
163  t_register->SetOutput(branchname, output);
164  LOG(debug) << "PndProcessTask::HandledRequest " << t_container.fBranchname << "(" << branchname << ") for " << t_container.fClassType << " as output container.";
165  status = kTRUE;
166  } else {
168  input->SetTCA(GetInputArray(branchname, t_container.fClassType));
169  input->SetBranchName(branchname);
170 
171  t_register->SetInput(branchname, input);
172  LOG(debug) << "PndProcessTask::HandledRequest " << t_container.fBranchname << "(" << branchname << ") for " << t_container.fClassType << " as input container.";
173  status = kTRUE;
174  }
175  return status;
176  }
void SetTCA(TClonesArray *t_tca)
Set the TClonesArray address.
void SetInput(const TString &t_branchname, PndContainerI< T > *t_ptr)
void SetOutput(const TString &t_branchname, PndContainerI< T > *t_ptr)
void SetTCA(TClonesArray *t_tca)
Set the TClonesArray address.
void SetPersistency(Bool_t t_persistency)
Set the Persistency of the data.
PndTCAMutableContainer implementation of PndMutableContainerI<T> for FairRootManager and TClonesArray...
void SetBranchName(const TString &t_branchname)
Set the Branch Name.
TClonesArray * GetOutputArray(const TString &t_branchname, const TString &t_classtype, const TString &t_foldername, Bool_t t_persistenxy)
PndTCAConstContainer implementation of PndConstContainerI<T> for FairRootManager and TClonesArray...
TClonesArray * GetInputArray(const TString &t_branchname, const TString &t_classtype)
std::string fDetectorName
Bool_t IsBranchSet(const TString &t_branchname) const
int status[10]
Definition: f_Init.h:48

◆ Init()

virtual InitStatus PndProcessTask::Init ( )
finalvirtual

Initialise this task. This must be called AFTER SetParContainers(), otherwise we will try to pass the parameters to the PndProcesses, while the parameter were not fetched yet.

Returns
InitStatus

◆ PostProcessing()

virtual void PndProcessTask::PostProcessing ( Option_t *  )
protectedvirtual

Do some task post clean up after PndProcesses are run once per event.

Reimplemented in BSEmcClusteringTask, BSEmcPlotTask, BSEmcDigitizerTask, and BSEmcMCDepositProducerTask.

Referenced by TestPndProcessTask::Exec().

◆ PreProcessing()

virtual void PndProcessTask::PreProcessing ( Option_t *  )
protectedvirtual

Do some task preparation before PndProcesses are run once per event.

Reimplemented in BSEmcClusteringTask, BSEmcPlotTask, BSEmcDigitizerTask, and BSEmcMCDepositProducerTask.

Referenced by TestPndProcessTask::Exec().

◆ SetParContainers()

void PndProcessTask::SetParContainers ( )
finalprotected

Fetch the FairRuntimeDb and populate the PndParameterRegister with all requested parameter. Has to be called before Init()

◆ SetupDataArrays()

virtual void PndProcessTask::SetupDataArrays ( )
protectedpure virtual

Define which data containers need to be fetched from the FairRootManager, pass the data container addresses into a simple struct to distribute the addresses to the PndProcesses so they can read and write the data to them. Needs to be implemented in the derived PndProcessTask, such as the BSEmcClusteringTask.

Implemented in BSEmcClusteringTask, BSEmcPlotTask, BSEmcDigitizerTask, and BSEmcMCDepositProducerTask.


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