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