FairRoot/PandaRoot
PndSttHitProducerIdeal.cxx
Go to the documentation of this file.
1 // -------------------------------------------------------------------------
2 // ----- PndSttHitProducerIdeal source file -----
3 // -------------------------------------------------------------------------
4 
6 
7 #include "PndSttHit.h"
8 #include "PndSttHitInfo.h"
9 #include "PndSttPoint.h"
10 #include "PndSttTube.h"
11 #include "PndSttSingleStraw.h"
12 #include "PndSttMapCreator.h"
13 
14 #include "FairRootManager.h"
15 #include "FairRunAna.h"
16 #include "FairRuntimeDb.h"
17 
18 #include "TClonesArray.h"
19 #include "TRandom.h"
20 
21 #include <iostream>
22 #include <cmath>
23 
24 using std::cout;
25 using std::endl;
26 using std::sqrt;
27 
28 // TODO: read this from a configuration file
29 #define foldResolution 0 // <===== NO SMEARING
30 #define radialResolutionPolynomialConstant1 0.0150
31 #define radialResolutionPolynomialConstant2 0.
32 #define radialResolutionPolynomialConstant3 0.
33 //#define longitudinalResolutionPolynomialConstant1 3.
34 #define longitudinalResolutionPolynomialConstant1 0.0001
35 #define longitudinalResolutionPolynomialConstant2 0.
36 #define longitudinalResolutionPolynomialConstant3 0.
37 
38 // TODO: read this from geant initialization
39 #define innerStrawDiameter 1.
40 
41 // ----- Default constructor -------------------------------------------
43  PndPersistencyTask("Ideal STT Hit Producer",0)
44 {
45  SetPersistency(kTRUE);
46 
47  fPointArray = NULL;
48  fHitArray = NULL;
49  fHitInfoArray = NULL;
50  fTubeArray = NULL;
51 
52  fSttParameters = 0;
53 }
54 // -------------------------------------------------------------------------
55 
56 
57 
58 // ----- Destructor ----------------------------------------------------
60 {
61 }
62 // -------------------------------------------------------------------------
63 
64 
65 
66 // ----- Public method Init --------------------------------------------
68 {
69  // Get RootManager
70  FairRootManager* ioman = FairRootManager::Instance();
71 
72  if ( ! ioman )
73  {
74  cout << "-E- PndSttHitProducerIdeal::Init: "
75  << "RootManager not instantiated!" << endl;
76  return kFATAL;
77  }
78 
79  // Get input array
80  fPointArray = (TClonesArray*) ioman->GetObject("STTPoint");
81 
82  if ( ! fPointArray )
83  {
84  cout << "-W- PndSttHitProducerIdeal::Init: "
85  << "No STTPoint array!" << endl;
86  return kERROR;
87  }
88 
89  // Create and register output array
90  fHitArray = new TClonesArray("PndSttHit");
91  ioman->Register("STTHit", "STT", fHitArray, GetPersistency());
92 
93  // Create and register output array
94  fHitInfoArray = new TClonesArray("PndSttHitInfo");
95  ioman->Register("STTHitInfo", "STT", fHitInfoArray,GetPersistency());
96 
97  // CHECK added
98 // PndSttMapCreator *mapper = new PndSttMapCreator(fSttParameters);
99 // fTubeArray = mapper->FillTubeArray();
100 
101  cout << "-I- PndSttHitProducerIdeal: Intialisation successfull" << endl;
102  return kSUCCESS;
103 }
104 // -------------------------------------------------------------------------
105 
106 // CHECK added
108  FairRuntimeDb* rtdb = FairRunAna::Instance()->GetRuntimeDb();
109  fSttParameters = (PndGeoSttPar*) rtdb->getContainer("PndGeoSttPar");
110 }
111 
112 // ----- Public method Exec --------------------------------------------
114 {
115  if ( fTubeArray == NULL ) {
117  fTubeArray = mapper.FillTubeArray();
118  }
119 
120  // Reset output array
121  if ( ! fHitArray )
122  Fatal("Exec", "No HitArray");
123 
124  fHitArray->Delete();
125  fHitInfoArray->Delete();
126 
127  // Declare some variables
129  *point = NULL;
130 
131  Int_t
132  detID = 0, // Detector ID
133  trackID = 0; // Track index
134 
135  TVector3
136  pos, dpos; // Position and error vectors
137 
138  // Loop over SttPoints
139  Int_t
140  nPoints = fPointArray->GetEntriesFast();
141  Int_t counter=0;
142  for (Int_t iPoint = 0; iPoint < nPoints; iPoint++)
143  {
144  point = (PndSttPoint*) fPointArray->At(iPoint);
145 
146  if ( ! point)
147  continue;
148 
149  // Detector ID
150  detID = point->GetDetectorID();
151 
152  // MCTrack ID
153  trackID = point->GetTrackID();
154 
155  // tubeID CHECK added
156  Int_t tubeID = point->GetTubeID();
157  PndSttTube *tube = (PndSttTube*) fTubeArray->At(tubeID);
158 
159  // Determine hit position and isochrone (x,y of wire, measured z position)
160  TVector3
161  posInLocal(point->GetXInLocal(), point->GetYInLocal(), point->GetZInLocal()),
162  posOutLocal(point->GetXOutLocal(), point->GetYOutLocal(), point->GetZOutLocal()),
163  position;
164  position = tube->GetPosition(); // CHECK added
165 
166  Double_t
167  closestDistance,
168  closestDistanceError;
169 
170  //GetClostestApproachToWire(closestDistance, closestDistanceError,
171  // posInLocal, posOutLocal);
172 
173  //minimum distance ----------------
174 
175  //Double_t fd_in = sqrt(point->GetXInLocal()*point->GetXInLocal()+point->GetYInLocal()*point->GetYInLocal()); //[R.K. 01/2017] unused variable?
176  //cout<<fd_in<<endl;
177  double InOut[6];
178  memset(InOut, 0, sizeof(InOut));
179 
180  InOut[0] = point->GetXInLocal();
181  InOut[1] = point->GetYInLocal();
182  InOut[2] = point->GetZInLocal();
183  InOut[3] = point->GetXOutLocal();
184  InOut[4] = point->GetYOutLocal();
185  InOut[5] = point->GetZOutLocal();
186 
187  PndSttSingleStraw stt;
188  stt.PutWireXYZ(0., 0., -75., 0., 0., 75.);
189  closestDistance = stt.TrueDist(InOut);
190  closestDistanceError =0.;
191 
192  Double_t eloss = point->GetEnergyLoss();
193  //---------------------
194 
195  Double_t
196  zpos = position.Z() + ((posOutLocal.Z() + posInLocal.Z()) / 2.),
197  zposError;
198 
199  FoldZPosWithResolution(zpos, zposError,
200  posInLocal, posOutLocal);
201 
202  // Create new hit
203  // pos.SetXYZ(position.X(), position.Y(), zpos);
204  pos.SetXYZ(position.X(), position.Y(), position.Z()); // CHECK!
205  dpos.SetXYZ(innerStrawDiameter / 2., innerStrawDiameter / 2., GetLongitudinalResolution(position.Z()));
206 
207  // if(fabs(fd_in-0.5)>0.001) continue;
208 
209  new ((*fHitArray)[counter]) PndSttHit(detID, tubeID, iPoint, pos, dpos, 0, closestDistance, closestDistanceError, eloss * 1e6);
210 
211  new ((*fHitInfoArray)[counter]) PndSttHitInfo(0, 0, trackID, iPoint,
212  0, kFALSE);
213  counter++;
214  } // Loop over MCPoints
215 
216  // Event summary
217  if ( fVerbose > 1)
218  cout << "-I- PndSttHitProducerIdeal: " << nPoints << " SttPoints, "
219  << nPoints << " Hits created." << endl;
220 
221 }
222 // -------------------------------------------------------------------------
223 
224 // ----- Private method GetRadialResolution-------------------------------
226 {
229  radius * radius * radialResolutionPolynomialConstant3;
230 }
231 // -------------------------------------------------------------------------
232 
233 
234 
235 // ----- Private method GetLongitudinalResolution ------------------------
237 {
241 }
242 // -------------------------------------------------------------------------
243 
244 // ----- Private method GetClostestApproachToWire ------------------------
246  Double_t &closestDistanceError,
247  TVector3 localInPos,
248  TVector3 localOutPos)
249 {
250  Double_t
251  a = (localOutPos.X() - localInPos.X()),
252  b = (localOutPos.Y() - localInPos.Y()),
253  c = sqrt(a * a + b * b) / 2.;
254 
255  // fold with Gaussian for resolution
256 
257  if (c > innerStrawDiameter / 2.)
258  {
259  c = innerStrawDiameter / 2.;
260  }
261 
262  closestDistance = sqrt((innerStrawDiameter / 2.) * (innerStrawDiameter / 2.) - c * c);
263  closestDistanceError = 0.;
264 
265  if (foldResolution)
266  {
267  closestDistanceError = GetRadialResolution(closestDistance);
268  closestDistance += gRandom->Gaus(0., closestDistanceError);
269  }
270 }
271 // -------------------------------------------------------------------------
272 
274  TVector3 localInPos, TVector3 localOutPos)
275 {
276  Double_t
277  zPosInStrawFrame = (localOutPos.Z() - localInPos.Z()) / 2.;
278 
279  zposError = gRandom->Gaus(0., GetLongitudinalResolution(zPosInStrawFrame));
280 
281  zpos += zposError;
282  // cout << "zpos in prod: " << zpos << endl;
283 }
284 
285 
286 
TVector3 pos
int fVerbose
Definition: poormantracks.C:24
#define radialResolutionPolynomialConstant2
#define radialResolutionPolynomialConstant1
Double_t GetYOutLocal() const
Definition: PndSttPoint.h:47
Int_t GetTubeID()
Definition: PndSttPoint.h:77
void GetClostestApproachToWire(Double_t &closestDistance, Double_t &closestDistanceError, TVector3 inPos, TVector3 outPos)
void PutWireXYZ(Double_t w1, Double_t w2, Double_t w3, Double_t w4, Double_t w5, Double_t w6)
TTree * b
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:29
Double_t GetZInLocal() const
Definition: PndSttPoint.h:51
Double_t GetXInLocal() const
Definition: PndSttPoint.h:49
double eloss
Definition: anaLmdSim.C:34
void SetPersistency(Bool_t val=kTRUE)
Double_t TrueDist(Double_t Point[])
#define longitudinalResolutionPolynomialConstant2
Double_t GetYInLocal() const
Definition: PndSttPoint.h:50
Double_t GetZOutLocal() const
Definition: PndSttPoint.h:48
Double_t GetXOutLocal() const
Definition: PndSttPoint.h:46
Int_t a
Definition: anaLmdDigi.C:126
int counter
Definition: ZeeAnalysis.C:59
#define radialResolutionPolynomialConstant3
void FoldZPosWithResolution(Double_t &zpos, Double_t &zposError, TVector3 localInPos, TVector3 localOutPos)
Double_t
const Double_t zpos
TVector3 GetPosition()
Definition: PndSttTube.cxx:87
TClonesArray * point
Definition: anaLmdDigi.C:29
virtual void Exec(Option_t *opt)
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
Double_t GetLongitudinalResolution(Double_t zpos)
TClonesArray * FillTubeArray()
#define foldResolution
#define longitudinalResolutionPolynomialConstant3
#define longitudinalResolutionPolynomialConstant1
#define innerStrawDiameter
ClassImp(PndAnaContFact)
Double_t GetRadialResolution(Double_t radius)