BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
CbmStsHitProducerIdeal.cxx
Go to the documentation of this file.
1// -------------------------------------------------------------------------
2// ----- CbmStsHitProducerIdeal source file -----
3// ----- Created 10/01/06 by V. Friese -----
4// -------------------------------------------------------------------------
6
7#include "CbmStsHit.h"
8#include "CbmStsPoint.h"
9#include "FairRootManager.h"
10#include "TClonesArray.h"
11
12#include <iostream>
13
14using std::cout;
15using std::endl;
16
17// ----- Default constructor -------------------------------------------
19 : FairTask("Ideal STS Hit Producer")
20 , fPointArray(NULL)
21 , fHitArray()
22{}
23// -------------------------------------------------------------------------
24
25// ----- Destructor ----------------------------------------------------
27// -------------------------------------------------------------------------
28
29// ----- Public method Init --------------------------------------------
31{
32
33 // Get RootManager
34 FairRootManager* ioman = FairRootManager::Instance();
35 if (!ioman) {
36 cout << "-E- CbmStsHitProducerIdeal::Init: "
37 << "RootManager not instantised!" << endl;
38 return kFATAL;
39 }
40
41 // Get input array
42 fPointArray = (TClonesArray*)ioman->GetObject("StsPoint");
43 if (!fPointArray) {
44 // cout << "-W- CbmStsHitProducerIdeal::Init: "<< "No STSPoint array!" << endl;
45 return kERROR;
46 }
47
48 // Create and register output array
49 fHitArray = new TClonesArray("CbmStsHit");
50 ioman->Register("StsHit", "STS", fHitArray, kTRUE);
51
52 cout << "-I- CbmStsHitProducerIdeal: Intialisation successfull" << endl;
53 return kSUCCESS;
54}
55// -------------------------------------------------------------------------
56
57// ----- Public method Exec --------------------------------------------
59{
60
61 // Reset output array
62 if (!fHitArray)
63 Fatal("Exec", "No StsHit array");
64
65 // fHitArray->Clear();
66 fHitArray->Delete();
67
68 // Declare some variables
69 CbmStsPoint* point = NULL;
70 Int_t detID = 0; // Detector ID
71 Int_t trackID = 0; // Track index
72 Double_t x, y, z; // Position
73 Double_t dx = 0.0001; // Position error
74 TVector3 pos, dpos; // Position and error vectors
75
76 // Loop over StsPoints
77 Int_t nPoints = fPointArray->GetEntriesFast();
78 for (Int_t iPoint = 0; iPoint < nPoints; iPoint++) {
79 point = (CbmStsPoint*)fPointArray->At(iPoint);
80 if (!point)
81 continue;
82
83 // Detector ID
84 detID = point->GetDetectorID();
85
86 // MCTrack ID
87 trackID = point->GetTrackID();
88
89 // Determine hit position (centre plane of station)
90 x = 0.5 * (point->GetXOut() + point->GetXIn());
91 y = 0.5 * (point->GetYOut() + point->GetYIn());
92 z = 0.5 * (point->GetZOut() + point->GetZIn());
93
94 // Create new hit
95 pos.SetXYZ(x, y, z);
96 dpos.SetXYZ(dx, dx, 0.);
97 new ((*fHitArray)[iPoint]) CbmStsHit(detID, pos, dpos, 0., iPoint, -1);
98
99 } // Loop over MCPoints
100
101 // Event summary
102 cout << "-I- CbmStsHitProducerIdeal: " << nPoints << " StsPoints, " << nPoints << " Hits created." << endl;
103}
104// -------------------------------------------------------------------------
int Int_t
double Double_t
constexpr Bool_t kTRUE
const char Option_t
void Fatal(const char *location, const char *msgfmt,...)
TClonesArray * fHitArray
Output array of CbmStsHits.
TClonesArray * fPointArray
Input array of CbmStsPoints.
virtual InitStatus Init()
Virtual method Init.
CbmStsHitProducerIdeal()
Default constructor.
virtual void Exec(Option_t *opt)
Virtual method Exec.
Double_t GetXIn() const
Accessors.
Definition CbmStsPoint.h:64
Double_t GetZOut() const
Definition CbmStsPoint.h:69
Double_t GetYOut() const
Definition CbmStsPoint.h:68
Double_t GetZIn() const
Definition CbmStsPoint.h:66
Double_t GetYIn() const
Definition CbmStsPoint.h:65
Double_t GetXOut() const
Definition CbmStsPoint.h:67
void SetXYZ(Double_t x, Double_t y, Double_t z)