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