CbmRoot
Loading...
Searching...
No Matches
CbmStsHitProducerIdealWrapper.cxx
Go to the documentation of this file.
1/* Copyright (C) 2006-2021 GSI Helmholtzzentrum fuer Schwerionenforschung, Darmstadt
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Volker Friese, Florian Uhlig [committer] */
4
5// -------------------------------------------------------------------------
6// ----- CbmStsHitProducerIdealWrapper source file -----
7// ----- Created 10/01/06 by V. Friese -----
8// -------------------------------------------------------------------------
10
11#include "CbmStsHit.h"
12#include "CbmTrdParSetGas.h"
13
14#include "FairParGenericSet.h"
15#include "FairRootManager.h"
16#include "FairRun.h"
17#include "FairRuntimeDb.h"
18#include <Logger.h>
19
20#include "TClonesArray.h"
21
22#include <iostream>
23
24using std::cout;
25using std::endl;
26
27// ----- Default constructor -------------------------------------------
28CbmStsHitProducerIdealWrapper::CbmStsHitProducerIdealWrapper() : FairTask("Ideal STS Hit Producer Task") {}
29// -------------------------------------------------------------------------
30
31
32// ----- Destructor ----------------------------------------------------
34// -------------------------------------------------------------------------
35
36// ----- Public method Init --------------------------------------------
38{
39
40 // Get RootManager
41 FairRootManager* ioman = FairRootManager::Instance();
42 if (!ioman) {
43 cout << "-E- CbmStsHitProducerIdealWrapper::Init: "
44 << "RootManager not instantised!" << endl;
45 return kFATAL;
46 }
47
48 // Get input array
49 fPointArray = (TClonesArray*) ioman->GetObject("StsPoint");
50 if (!fPointArray) {
51 cout << "-W- CbmStsHitProducerIdealWrapper::Init: "
52 << "No STSPoint array!" << endl;
53 return kERROR;
54 }
55
56 // Create and register output array
57 fHitArray = new TClonesArray("CbmStsHit");
58 ioman->Register("StsHit", "STS", fHitArray, IsOutputBranchPersistent("StsHit"));
59
60
61 fAlgo->Init();
63
64 cout << "-I- CbmStsHitProducerIdealWrapper: Intialisation successfull" << endl;
65 return kSUCCESS;
66}
67// -------------------------------------------------------------------------
68
70{
71 LOG(info) << "Setting parameter containers for " << GetName();
72
73 TList* fParCList = fAlgo->GetParList();
74
75 for (Int_t iparC = 0; iparC < fParCList->GetEntries(); ++iparC) {
76 FairParGenericSet* tempObj = (FairParGenericSet*) (fParCList->At(iparC));
77 fParCList->Remove(tempObj);
78
79 std::string sParamName {tempObj->GetName()};
80 FairParGenericSet* newObj =
81 dynamic_cast<FairParGenericSet*>(FairRun::Instance()->GetRuntimeDb()->getContainer(sParamName.data()));
82
83 if (nullptr == newObj) {
84 LOG(error) << "Failed to obtain parameter container " << sParamName << ", for parameter index " << iparC;
85 return;
86 } // if( nullptr == newObj )
87
88 fParCList->AddAt(newObj, iparC);
89 // delete tempObj;
90 } // for( Int_t iparC = 0; iparC < fParCList->GetEntries(); ++iparC )
91}
92
93std::vector<CbmStsPoint> CbmStsHitProducerIdealWrapper::Convert(TClonesArray* arr)
94{
95
96 std::vector<CbmStsPoint> vec;
97 Int_t entries = arr->GetEntriesFast();
98 if (entries > 0) {
99 CbmStsPoint* point = static_cast<CbmStsPoint*>(arr->At(0));
100 LOG(info) << "Entries in TCA for data type " << point->GetName() << ": " << entries;
101 }
102 for (int i = 0; i < entries; ++i) {
103 CbmStsPoint* point = static_cast<CbmStsPoint*>(arr->At(i));
104 vec.emplace_back(*point);
105 }
106 return vec;
107}
108
109
110// ----- Public method Exec --------------------------------------------
112{
113
114 // Reset output array
115 if (!fHitArray) Fatal("Exec", "No StsHit array");
116
117 // fHitArray->Clear();
118 fHitArray->Delete();
119
120 // ConvertToVector
121 std::vector<CbmStsPoint> points = Convert(fPointArray);
122
123 // Pass the vector to the algorithm
124 // Get the vector with the newly created data objects from the algorithm
125 std::vector<CbmStsHit> hits = fAlgo->ProcessInputData(points);
126
127 // Fill the content of vector into TCA
128 int iPoint = 0;
129 for (const auto& hit : hits) {
130 new ((*fHitArray)[iPoint]) CbmStsHit(hit);
131 iPoint++;
132 }
133
134 // Event summary
135 cout << "-I- CbmStsHitProducerIdealWrapper: " << points.size() << " StsPoints, " << hits.size() << " Hits created."
136 << endl;
137}
138// -------------------------------------------------------------------------
139
TClonesArray * points
ClassImp(CbmConverterManager)
Data class for a reconstructed hit in the STS.
static vector< vector< QAHit > > hits
virtual std::vector< CbmStsHit > ProcessInputData(const std::vector< CbmStsPoint > &)
std::vector< CbmStsPoint > Convert(TClonesArray *arr)
virtual void SetParContainers()
Inherited from FairTask.
data class for a reconstructed 3-d hit in the STS
Definition CbmStsHit.h:35