StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StRedoTracks.cxx
1 // //
3 // StRedoTracks redoes the space charge correction //
4 // //
6 
7 #include "StRedoTracks.h"
8 #include "StDbUtilities/StMagUtilities.h"
9 #include "StEventTypes.h"
10 #include "StMessMgr.h"
11 #include "StTpcDb/StTpcDb.h"
12 #include "StTpcDb/StTpcDbMaker.h"
13 #include "St_db_Maker/St_db_Maker.h"
14 
15 
16 ClassImp(StRedoTracks)
17 
18 //_____________________________________________________________________________
19 StRedoTracks::StRedoTracks(const char *name, StTpcDbMaker* mkr):StMaker(name),
20  m_ExB(0), tpcDbMaker(mkr), redo(kTRUE) {
21 }
22 //_____________________________________________________________________________
23 StRedoTracks::~StRedoTracks() {}
24 //_____________________________________________________________________________
25 Int_t StRedoTracks::Init(){
26  // Find StTpcDbMaker
27  if (!tpcDbMaker) {
28  StMakerIter iter(GetParentChain());
29  StMaker* mkr;
30  while ((mkr = iter.NextMaker())) {
31  if (mkr->IsA() == StTpcDbMaker::Class()) {
32  tpcDbMaker = (StTpcDbMaker*) mkr;
33  break;
34  }
35  }
36  if (!tpcDbMaker) gMessMgr->Warning("StRedoTracks: No StTpcDbMaker found.");
37  }
38  return StMaker::Init();
39 }
40 //_____________________________________________________________________________
42  // Get instance of StMagUtilities
43  int option = 0;
44  if (!m_ExB) {
45 #ifdef __NEW_MagUtilities__
46  m_ExB = new StMagUtilities(tpcDbMaker->tpcDbInterface(),option);
47 #else
48  TDataSet *RunLog = GetDataBase("RunLog/MagFactor");
49  if (!RunLog) gMessMgr->Warning("StRedoTracks: No RunLog/MagFactor found.");
50  m_ExB = new StMagUtilities(tpcDbMaker->tpcDbInterface(),RunLog,option);
51 #endif
52  }
53 
54  StEvent* event = (StEvent*) GetInputDS("StEvent");
55  if (!event) {
56  gMessMgr->Warning("StRedoTracks: no StEvent; skipping event.");
57  return kStWarn;
58  }
59 
60  unsigned int i,j,k;
61  float x[3],p[3],x_new[3],p_new[3];
62  StTrackGeometry* triGeom = 0;
63  StThreeVectorD ooo;
64  StTrackType typ;
65  Prime typ2;
66 
67  StPrimaryVertex* pvtx = event->primaryVertex();
68  if (!pvtx) return kStOk;
69  ooo = pvtx->position();
70  StSPtrVecTrackNode& theNodes = event->trackNodes();
71 
72  // Assign an error to the primary vertex for primary track fits
73  // Currently set to 200 microns for infinite tracks, goes as 1/::sqrt(Ntracks)
74  UInt_t nPrims = pvtx->numberOfDaughters();
75  Float_t pv_err = TMath::Sqrt(0.0004 + (0.11/nPrims));
76 
77  for (i=0; i<theNodes.size(); i++) {
78  typ = global; typ2 = IsGlobal;
79  Bool_t iterate = kTRUE;
80  while (iterate) {
81  for (j=0; j<theNodes[i]->entries(typ); j++) {
82  StTrack* tri = (StTrack *) theNodes[i]->track(typ,j);
83  const StTrackTopologyMap& map = tri->topologyMap();
84  for (k=0; k<2; k++) {
85  if (k) triGeom = tri->outerGeometry();
86  else triGeom = tri->geometry();
87 
88  StThreeVectorF xvec = triGeom->origin();
89  if (!(xvec.x() || xvec.y() || xvec.z())) continue;
90  StThreeVectorF pvec = triGeom->momentum();
91  if (!(pvec.x() || pvec.y())) continue;
92 
93  float oldPt = pvec.perp();
94  if (oldPt < 0.0001) continue;
95  p[0] = pvec.x();
96  p[1] = pvec.y();
97  p[2] = pvec.z();
98  x[0] = xvec.x();
99  x[1] = xvec.y();
100  x[2] = xvec.z();
101 
102  if (!redo) continue;
103  m_ExB->FixSpaceChargeDistortion(triGeom->charge(),x,p,
104  typ2,x_new,p_new,map.data(0),map.data(1),pv_err);
105 
106  StThreeVectorF npvec(p_new);
107  StThreeVectorF nxvec(x_new);
108  float newPt = npvec.perp();
109  float inv_newPt = 1.0/newPt;
110  float psi = TMath::ACos(npvec.x()*inv_newPt);
111  if (npvec.y() < 0) psi = TMath::TwoPi() - psi; // psi: 0...2pi
112 
113  triGeom->setMomentum(npvec);
114  triGeom->setOrigin(nxvec);
115  triGeom->setCurvature(triGeom->curvature()*pvec.perp()*inv_newPt);
116  triGeom->setDipAngle(TMath::ATan(npvec.z()*inv_newPt));
117  triGeom->setPsi(psi);
118 
119  }
120  } // loop over j tracks
121  if (typ == global) { typ = primary; typ2 = IsPrimary; }
122  else iterate = kFALSE;
123  } // loop over track types
124  } // loop over i Nodes
125 
126 
127  return kStOK;
128 }
129 //_____________________________________________________________________________
130 // $Id: StRedoTracks.cxx,v 1.7 2018/06/29 17:21:24 perev Exp $
131 // $Log: StRedoTracks.cxx,v $
132 // Revision 1.7 2018/06/29 17:21:24 perev
133 // Irakli_Jun29
134 //
135 // Revision 1.6 2012/11/07 23:27:55 fisyak
136 // Add place holder for new StMagUtilities
137 //
138 // Revision 1.5 2012/10/01 17:50:06 genevb
139 // Reduce some overhead DB queries by being more specific about needed tables
140 //
141 // Revision 1.4 2003/09/02 17:58:09 perev
142 // gcc 3.2 updates + WarnOff
143 //
144 // Revision 1.3 2003/07/02 15:32:38 genevb
145 // Remove StTpcDb.so dependence
146 //
147 // Revision 1.1 2003/06/28 00:46:15 genevb
148 // Introduction of StRedoTracks class
149 //
150 //
virtual void FixSpaceChargeDistortion(const Int_t Charge, const Float_t x[3], const Float_t p[3], const Prime PrimaryOrGlobal, Float_t x_new[3], Float_t p_new[3], const unsigned int RowMask1=0xFFFFFF00, const unsigned int RowMask2=0x1FFFFF, const Float_t VertexError=0.0200)
Convert from the old (Uniform) space charge correction to the new (1/R**2) space charge correction...
virtual Int_t Make()
Definition: Stypes.h:42
Definition: Stypes.h:40
Definition: Stypes.h:41