CbmRoot
CbmStsHitProducerTaskIdeal.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- CbmStsHitProducerTaskIdeal 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 "FairRootManager.h"
11 #include "FairRunAna.h"
12 #include "FairRuntimeDb.h"
13 
14 #include "CbmStsHit.h"
16 #include "CbmStsPoint.h"
17 
18 #include "CbmTrdParSetGas.h"
19 
20 using std::cout;
21 using std::endl;
22 
23 
24 // ----- Default constructor -------------------------------------------
26  : FairTask("Ideal STS Hit Producer Task")
27  , fPointArray(NULL)
28  , fHitArray(NULL)
29  , fTrdGasPar(NULL) {}
30 // -------------------------------------------------------------------------
31 
32 
33 // ----- Destructor ----------------------------------------------------
35 // -------------------------------------------------------------------------
36 
38  fTrdGasPar = static_cast<CbmTrdParSetGas*>(
39  FairRunAna::Instance()->GetRuntimeDb()->getContainer("CbmTrdParSetGas"));
40 }
41 
42 // ----- Public method Init --------------------------------------------
44 
45  // Get RootManager
46  FairRootManager* ioman = FairRootManager::Instance();
47  if (!ioman) {
48  cout << "-E- CbmStsHitProducerTaskIdeal::Init: "
49  << "RootManager not instantised!" << endl;
50  return kFATAL;
51  }
52 
53  // Get input array
54  fPointArray = (TClonesArray*) ioman->GetObject("StsPoint");
55  if (!fPointArray) {
56  cout << "-W- CbmStsHitProducerTaskIdeal::Init: "
57  << "No STSPoint array!" << endl;
58  return kERROR;
59  }
60 
61  // Create and register output array
62  fHitArray = new TClonesArray("CbmStsHit");
63  ioman->Register(
64  "StsHit", "STS", fHitArray, IsOutputBranchPersistent("StsHit"));
65 
66 
67  if (fTrdGasPar) fTrdGasPar->Dump();
68 
69  cout << "-I- CbmStsHitProducerTaskIdeal: Intialisation successfull" << endl;
70 
71 
72  return kSUCCESS;
73 }
74 // -------------------------------------------------------------------------
75 
76 
77 std::vector<CbmStsPoint>
79 
80  std::vector<CbmStsPoint> vec;
81  Int_t entries = arr->GetEntriesFast();
82  if (entries > 0) {
83  CbmStsPoint* point = static_cast<CbmStsPoint*>(arr->At(0));
84  LOG(info) << "Entries in TCA for data type " << point->GetName() << ": "
85  << entries;
86  }
87  for (int i = 0; i < entries; ++i) {
88  CbmStsPoint* point = static_cast<CbmStsPoint*>(arr->At(i));
89  vec.emplace_back(*point);
90  }
91  return vec;
92 }
93 
94 
95 std::vector<CbmStsHit>
96 CbmStsHitProducerTaskIdeal::Algo(const std::vector<CbmStsPoint>& pointVect) {
97  // Declare some variables
98  // CbmStsPoint* point{nullptr};
99  Int_t detID {0}; // Detector ID
100  Double_t x {0.};
101  Double_t y {0.};
102  Double_t z {0.1}; // Position
103  Double_t dx {0.0001}; // Position error
104  TVector3 pos {};
105  TVector3 dpos {}; // Position and error vectors
106 
107  std::vector<CbmStsHit> hitVect {};
108 
109 
110  // for(auto point: pointVect) {
111  for (unsigned long iPoint = 0; iPoint < pointVect.size(); ++iPoint) {
112 
113  // Detector ID
114  detID = pointVect.at(iPoint).GetDetectorID();
115 
116  // Determine hit position (centre plane of station)
117  x = 0.5 * (pointVect.at(iPoint).GetXOut() + pointVect.at(iPoint).GetXIn());
118  y = 0.5 * (pointVect.at(iPoint).GetYOut() + pointVect.at(iPoint).GetYIn());
119  z = 0.5 * (pointVect.at(iPoint).GetZOut() + pointVect.at(iPoint).GetZIn());
120 
121  // Create new hit
122  pos.SetXYZ(x, y, z);
123  dpos.SetXYZ(dx, dx, 0.);
124 
125  hitVect.emplace_back(detID, pos, dpos, 0., iPoint, iPoint, 0., 0.);
126  } // Loop over MCPoints
127 
128  return hitVect;
129 }
130 // ----- Public method Exec --------------------------------------------
131 void CbmStsHitProducerTaskIdeal::Exec(Option_t* /*opt*/) {
132 
133  // Reset output array
134  if (!fHitArray) Fatal("Exec", "No StsHit array");
135 
136  // fHitArray->Clear();
137  fHitArray->Delete();
138 
139  if (fTrdGasPar) fTrdGasPar->Print();
140 
141  // ConvertToVector
142  std::vector<CbmStsPoint> points = Convert(fPointArray);
143 
144  // Pass the vector to the algorithm
145  // Get the vector with the newly created data objects from the algorithm
146  std::vector<CbmStsHit> hits = Algo(points);
147 
148  // Fill the content of vector into TCA
149 
150  int iPoint = 0;
151  for (auto const hit : hits) {
152  new ((*fHitArray)[iPoint]) CbmStsHit(hit);
153  iPoint++;
154  }
155 
156 
157  // Event summary
158  cout << "-I- CbmStsHitProducerTaskIdeal: " << points.size() << " StsPoints, "
159  << hits.size() << " Hits created." << endl;
160 }
161 // -------------------------------------------------------------------------
162 
163 
CbmStsHitProducerTaskIdeal.h
CbmStsHitProducerTaskIdeal::Algo
std::vector< CbmStsHit > Algo(const std::vector< CbmStsPoint > &)
Definition: CbmStsHitProducerTaskIdeal.cxx:96
CbmTrdParSetGas
Describe TRD module working settings (HV, etc)
Definition: CbmTrdParSetGas.h:15
CbmStsHitProducerTaskIdeal::fTrdGasPar
CbmTrdParSetGas * fTrdGasPar
Definition: CbmStsHitProducerTaskIdeal.h:65
CbmStsHitProducerTaskIdeal::fPointArray
TClonesArray * fPointArray
Definition: CbmStsHitProducerTaskIdeal.h:60
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
CbmStsHitProducerTaskIdeal::SetParContainers
virtual void SetParContainers()
Inherited from FairTask.
Definition: CbmStsHitProducerTaskIdeal.cxx:37
CbmStsPoint
Definition: CbmStsPoint.h:27
CbmStsHitProducerTaskIdeal::fHitArray
TClonesArray * fHitArray
Definition: CbmStsHitProducerTaskIdeal.h:63
CbmStsHit
data class for a reconstructed 3-d hit in the STS
Definition: CbmStsHit.h:31
dpos
TVector3 dpos
Definition: CbmMvdSensorDigiToHitTask.cxx:61
ClassImp
ClassImp(CbmConverterManager) InitStatus CbmConverterManager
Definition: CbmConverterManager.cxx:12
CbmStsHitProducerTaskIdeal
Definition: CbmStsHitProducerTaskIdeal.h:32
CbmStsHitProducerTaskIdeal::Exec
virtual void Exec(Option_t *opt)
Definition: CbmStsHitProducerTaskIdeal.cxx:131
CbmStsPoint.h
points
TClonesArray * points
Definition: Analyze_matching.h:18
x
Double_t x
Definition: CbmMvdSensorDigiToHitTask.cxx:68
y
Double_t y
Definition: CbmMvdSensorDigiToHitTask.cxx:68
hits
static vector< vector< QAHit > > hits
Definition: CbmTofHitFinderTBQA.cxx:114
pos
TVector3 pos
Definition: CbmMvdSensorDigiToHitTask.cxx:60
CbmTrdParSetGas.h
CbmStsHitProducerTaskIdeal::~CbmStsHitProducerTaskIdeal
~CbmStsHitProducerTaskIdeal()
Definition: CbmStsHitProducerTaskIdeal.cxx:34
CbmStsHitProducerTaskIdeal::Init
virtual InitStatus Init()
Definition: CbmStsHitProducerTaskIdeal.cxx:43
CbmStsHitProducerTaskIdeal::Convert
std::vector< CbmStsPoint > Convert(TClonesArray *arr)
Definition: CbmStsHitProducerTaskIdeal.cxx:78
CbmStsHitProducerTaskIdeal::CbmStsHitProducerTaskIdeal
CbmStsHitProducerTaskIdeal()
Definition: CbmStsHitProducerTaskIdeal.cxx:25
CbmStsHit.h
Data class for a reconstructed hit in the STS.