FairRoot/PandaRoot
PndHypHitProducerIdeal.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- PndHypHitProducerIdeal source file -----
3 // -------------------------------------------------------------------------
4 
5 
6 #include "TClonesArray.h"
7 
8 #include "FairRootManager.h"
10 #include "PndHypHit.h"
11 #include "PndHypHitInfo.h"
12 #include "PndHypPoint.h"
13 #include "FairRunAna.h"
14 #include "FairRuntimeDb.h"
15 
16 
17 // ----- Default constructor -------------------------------------------
19  FairTask("Ideal PndHyp Hit Producer")
20 {
21  fBranchName = "HypPoint";
22 }
23 // -------------------------------------------------------------------------
24 
25 
26 
27 // ----- Destructor ----------------------------------------------------
29 {
30 }
31 
32 // ----- Public method Init --------------------------------------------
34 {
35  // Get RootManager
36  FairRootManager* ioman = FairRootManager::Instance();
37 
38  if ( ! ioman )
39  {
40  std::cout << "-E- PndHypHitProducerIdeal::Init: "
41  << "RootManager not instantiated!" << std::endl;
42  return kFATAL;
43  }
44 
45  // Get input array
46  fPointArray = (TClonesArray*) ioman->GetObject(fBranchName);
47 
48  if ( ! fPointArray )
49  {
50  std::cout << "-W- PndHypHitProducerIdeal::Init: "
51  << "No HypPoint array!" << std::endl;
52  return kERROR;
53  }
54 
55  // Create and register output array
56  fHitArray = new TClonesArray("PndHypHit");
57  ioman->Register("HypHit", "Hyp", fHitArray, kTRUE);
58 
59  std::cout << "-I- PndHypHitProducerIdeal: Intialisation successfull" << std::endl;
60  return kSUCCESS;
61 }
62 // -------------------------------------------------------------------------
64 {
65  // Get Base Container
66  FairRun* ana = FairRun::Instance();
67  FairRuntimeDb* rtdb=ana->GetRuntimeDb();
68  fGeoPar = (PndGeoHypPar*)(rtdb->getContainer("PndGeoHypPar"));
69 
70 }
71 
72 
73 // ----- Public method Exec --------------------------------------------
75 {
76  // Reset output array
77  if ( ! fHitArray )
78  Fatal("Exec", "No HitArray");
79 
80  fHitArray->Delete();
81 
82  // Declare some variables
83  PndHypPoint *point = 0;
84 
85  Int_t
86  detID = 0; // Detector ID
87  //trackID = 0; // Track index //[R.K.03/2017] unused variable
88 
89  TVector3
90  dpos; // Position and error vectors
91 
92  // Loop over PndHypPoints
93  Int_t
94  nPoints = fPointArray->GetEntriesFast();
95 
96  for (Int_t iPoint = 0; iPoint < nPoints; iPoint++)
97  {
98  point = (PndHypPoint*) fPointArray->At(iPoint);
99 // std::cout << " Ideal Hit Producer -Point-: " << point << std::endl;
100  if ( ! point)
101  continue;
102 
103  // Detector ID
104  detID = point->GetVolumeID();
105 
106  // MCTrack ID
107  //trackID = point->GetTrackID(); //[R.K.03/2017] unused variable
108 
109  TVector3 position(point->GetXin(), point->GetYin(), point->GetZin());
110  //point->Position(pos);
111  dpos.SetXYZ(0.2,0.2,0.2);
112  smear(position,dpos);
113 
114  // Create new hit
115  new ((*fHitArray)[iPoint]) PndHypHit( detID, point->GetDetName(), position, dpos, iPoint, point->GetEnergyLoss(),1);
116  std::cout << "Hit created for module: " << point->GetDetName() << std::endl;
117 
118 
119 
120  } // Loop over MCPoints
121 
122  // Event summary
123  std::cout << "-I- PndHypHitProducerIdeal: " << nPoints << " HypPoints, "
124  << nPoints << " Hits created." << std::endl;
125 
126 }
127 // -------------------------------------------------------------------------
128 void PndHypHitProducerIdeal::smear(TVector3& pos, TVector3& dpos)
129 {
131 
132  double x=pos.x(),
133  y=pos.y(),
134  z=pos.z(),
135  sigx=dpos.x(),
136  sigy=dpos.y(),
137  sigz=dpos.z();
138 
139  sigx=gRandom->Gaus(0,sigx);
140  sigy=gRandom->Gaus(0,sigy);
141  sigz=gRandom->Gaus(0,sigz);
142 
143  x += sigx;
144  y += sigy;
145  z += sigz;
146 
147  pos.SetXYZ(x,y,z);
148  return;
149 }
150 
151 
152 
153 
154 
TVector3 pos
Double_t GetZin() const
Definition: PndHypPoint.h:94
Double_t GetXin() const
Definition: PndHypPoint.h:92
Int_t GetVolumeID() const
Definition: PndHypPoint.h:91
void smear(TVector3 &pos, TVector3 &dpos)
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
Double_t z
Double_t GetYin() const
Definition: PndHypPoint.h:93
Double_t x
TString GetDetName() const
Definition: PndHypPoint.h:119
ClassImp(PndAnaContFact)
Double_t y
virtual void Exec(Option_t *opt)
PndSdsMCPoint * point
Definition: anaLmdCluster.C:72