BmnRoot
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// -------------------------------------------------------------------------
5#include <iostream>
6
7#include "TClonesArray.h"
8
9#include "FairRootManager.h"
10
11#include "CbmStsHit.h"
13#include "CbmStsPoint.h"
14
15using std::cout;
16using std::endl;
17
18
19// ----- Default constructor -------------------------------------------
21 : FairTask("Ideal STS Hit Producer"),
22 fPointArray(NULL),
23 fHitArray()
24{
25}
26// -------------------------------------------------------------------------
27
28
29
30// ----- Destructor ----------------------------------------------------
32// -------------------------------------------------------------------------
33
34
35
36// ----- Public method Init --------------------------------------------
38
39 // Get RootManager
40 FairRootManager* ioman = FairRootManager::Instance();
41 if ( ! ioman ) {
42 cout << "-E- CbmStsHitProducerIdeal::Init: "
43 << "RootManager not instantised!" << endl;
44 return kFATAL;
45 }
46
47 // Get input array
48 fPointArray = (TClonesArray*) ioman->GetObject("StsPoint");
49 if ( ! fPointArray ) {
50 //cout << "-W- CbmStsHitProducerIdeal::Init: "<< "No STSPoint array!" << endl;
51 return kERROR;
52 }
53
54 // Create and register output array
55 fHitArray = new TClonesArray("CbmStsHit");
56 ioman->Register("StsHit", "STS", fHitArray, kTRUE);
57
58 cout << "-I- CbmStsHitProducerIdeal: Intialisation successfull" << endl;
59 return kSUCCESS;
60
61}
62// -------------------------------------------------------------------------
63
64
65
66// ----- Public method Exec --------------------------------------------
67void CbmStsHitProducerIdeal::Exec(Option_t* opt) {
68
69 // Reset output array
70 if ( ! fHitArray ) Fatal("Exec", "No StsHit array");
71
72 // fHitArray->Clear();
73 fHitArray->Delete();
74
75 // Declare some variables
76 CbmStsPoint* point = NULL;
77 Int_t detID = 0; // Detector ID
78 Int_t trackID = 0; // Track index
79 Double_t x, y, z; // Position
80 Double_t dx = 0.0001; // Position error
81 TVector3 pos, dpos; // Position and error vectors
82
83 // Loop over StsPoints
84 Int_t nPoints = fPointArray->GetEntriesFast();
85 for (Int_t iPoint=0; iPoint<nPoints; iPoint++) {
86 point = (CbmStsPoint*) fPointArray->At(iPoint);
87 if ( ! point) continue;
88
89 // Detector ID
90 detID = point->GetDetectorID();
91
92 // MCTrack ID
93 trackID = point->GetTrackID();
94
95 // Determine hit position (centre plane of station)
96 x = 0.5 * ( point->GetXOut() + point->GetXIn() );
97 y = 0.5 * ( point->GetYOut() + point->GetYIn() );
98 z = 0.5 * ( point->GetZOut() + point->GetZIn() );
99
100 // Create new hit
101 pos.SetXYZ(x,y,z);
102 dpos.SetXYZ(dx, dx, 0.);
103 new ((*fHitArray)[iPoint]) CbmStsHit(detID, pos, dpos, 0., iPoint, -1);
104
105 } // Loop over MCPoints
106
107 // Event summary
108 cout << "-I- CbmStsHitProducerIdeal: " << nPoints << " StsPoints, "
109 << nPoints << " Hits created." << endl;
110
111}
112// -------------------------------------------------------------------------
virtual void Exec(Option_t *opt)
Double_t GetXIn() const
Definition CbmStsPoint.h:69
Double_t GetZOut() const
Definition CbmStsPoint.h:74
Double_t GetYOut() const
Definition CbmStsPoint.h:73
Double_t GetZIn() const
Definition CbmStsPoint.h:71
Double_t GetYIn() const
Definition CbmStsPoint.h:70
Double_t GetXOut() const
Definition CbmStsPoint.h:72