StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StXiController.cxx
1 // $Id: StXiController.cxx,v 3.7 2011/04/03 15:51:58 fisyak Exp $
2 // $Log: StXiController.cxx,v $
3 // Revision 3.7 2011/04/03 15:51:58 fisyak
4 // Fix effect of constness in StAssociationMaker
5 //
6 // Revision 3.6 2002/06/13 16:06:01 genevb
7 // Additional security against zombies in StEvent vectors
8 //
9 // Revision 3.5 2002/04/30 16:02:48 genevb
10 // Common muDst, improved MC code, better kinks, StrangeCuts now a branch
11 //
12 // Revision 3.4 2001/05/04 20:15:15 genevb
13 // Common interfaces and reorganization of components, add MC event info
14 //
15 // Revision 3.3 2000/09/18 19:25:19 genevb
16 // Additional protection for missing MC info
17 //
18 // Revision 3.2 2000/07/17 20:28:40 genevb
19 // File size limitation workaround, some under the hood improvements
20 //
21 // Revision 3.1 2000/07/14 21:28:34 genevb
22 // Added V0Mc index for XiMc, fixed bug with entries for XiMc, cleaned up controllers
23 //
24 // Revision 3.0 2000/07/14 12:56:50 genevb
25 // Revision 3 has event multiplicities and dedx information for vertex tracks
26 //
27 // Revision 2.1 2000/06/09 22:17:11 genevb
28 // Allow MC data to be copied between DSTs, other small improvements
29 //
30 // Revision 2.0 2000/06/05 05:19:46 genevb
31 // New version of Strangeness micro DST package
32 //
33 //
35 // //
36 // StXiController strangeness micro DST controller for Xis //
37 // //
39 #include "TTree.h"
40 #include "StEvent/StEvent.h"
41 #include "StMcEventMaker/StMcEventMaker.h"
42 #include "StAssociationMaker/StAssociationMaker.h"
43 #include "StAssociationMaker/StTrackPairInfo.hh"
44 #include "StTrack.h"
45 #include "StGlobalTrack.h"
46 #include "StXiVertex.h"
47 #include "StXiMuDst.hh"
48 #include "StXiMc.hh"
49 #include "StMcEventTypes.hh"
50 #include "StParticleDefinition.hh"
51 #include "StTrackDetectorInfo.h"
52 
53 #include "StStrangeControllerInclude.h" // Location of header for this class
54 
55 class StStrangeEvMuDst;
56 
57 //_____________________________________________________________________________
58 StXiController::StXiController() : StStrangeControllerBase(xiT) {
59 }
60 //_____________________________________________________________________________
61 StXiController::~StXiController() {
62 }
63 //_____________________________________________________________________________
64 Int_t StXiController::MakeReadDst() {
65 
66  Int_t j;
67  StStrangeEvMuDst* ev = masterMaker->GetEvent(); // Tell the vertices
68  entries = GetN(); // about the event
69  for (j = 0; j<entries; j++) {
70  StXiMuDst* xi = (StXiMuDst*) (*dataArray)[j];
71  xi->SetEvent(ev);
72  }
73  PrintNumCand("read",entries);
74  nEntries += entries;
75 
76  if (doMc) {
77  ev = masterMaker->GetMcEvent();
78  Int_t mc_entries = GetNMc();
79  for (j = 0; j<mc_entries; j++) {
80  StXiMc* mc_xi = (StXiMc*) (*mcArray)[j];
81  mc_xi->SetEvent(ev);
82  }
83  }
84 
85  return kStOK;
86 }
87 //_____________________________________________________________________________
88 Int_t StXiController::MakeCreateDst(StEvent& event) {
89 
90  // Loop over vertices to build array of candidates
91  Int_t nBad = 0;
92  StSPtrVecXiVertex& xiVertices = event.xiVertices();
93  entries = xiVertices.size();
94  Int_t asize = dataArray->GetSize();
95  if (entries > asize) dataArray->Expand(entries+increment);
96  StStrangeEvMuDst* ev = masterMaker->GetEvent();
97  Int_t j=0;
98  for (Int_t i=0; i<entries; i++) {
99  StXiVertex* xiVertex = xiVertices[i];
100  if (xiVertex) {
101  StV0Vertex* v0Vertex = xiVertex->v0Vertex();
102  if (v0Vertex) {
103  new((*dataArray)[j++]) StXiMuDst(xiVertex,v0Vertex,ev);
104  } else nBad++;
105  }
106  }
107  entries = j;
108  PrintNumCand("found",entries);
109  if (nBad) gMessMgr->Warning() << "StXiController: " << nBad
110  << "with missing V0 vertices" << endm;
111  nEntries += entries;
112 
113  return kStOK;
114 }
115 //_____________________________________________________________________________
116 Int_t StXiController::MakeCreateMcDst(StMcVertex* mcVert) {
117 
118  mcXiMapType* theMcXiMap = 0;
119  mcTrackMapType* theMcTrackMap = 0;
120  if (assocMaker) {
121  theMcXiMap = assocMaker->mcXiMap();
122  theMcTrackMap = assocMaker->mcTrackMap();
123  }
124  if (!((assocMaker)&&(theMcXiMap)&&(theMcTrackMap))) return kStOk;
125  StStrangeEvMuDst* ev = masterMaker->GetMcEvent();
126  const StXiVertex* rcXiPartner = 0;
127  StMcTrack* Bach = 0;
128  StMcTrack* V0daughter = 0;
129  Int_t indexRecoArray = -1;
130  Int_t count = theMcXiMap->count(mcVert);
131  StSPtrVecMcTrack& Daughters = mcVert->daughters();
132 
133  for (StMcTrackIterator DTrackIt = Daughters.begin();
134  DTrackIt != Daughters.end(); DTrackIt++) {
135  if ((Int_t)(*DTrackIt)->particleDefinition()->charge())
136  Bach = (*DTrackIt);
137  else
138  V0daughter = (*DTrackIt);
139  }
140 
141  if (Bach) {
142  StXiMc* xiMc = new((*mcArray)[mcEntries++]) StXiMc(mcVert,Bach,ev);
143  if (V0daughter) {
144  StStrangeControllerBase* v0Cont = masterMaker->Get(v0T);
145  if (v0Cont) {
146  StMcVertex* v0Vertex = V0daughter->stopVertex();
147  if (v0Vertex) {
148  Int_t before = v0Cont->GetNMc();
149  v0Cont->MakeCreateMcDst(v0Vertex);
150  Int_t after = v0Cont->GetNMc();
151  if (!(before==after)) xiMc->SetV0Index(before);
152  }
153  }
154  }
155  if (count>0) {
156  pair<mcXiMapIter,mcXiMapIter> mcXiBounds =
157  theMcXiMap->equal_range(mcVert);
158  indexRecoArray = -1;
159  for(mcXiMapIter mcXiMapIt = mcXiBounds.first;
160  mcXiMapIt != mcXiBounds.second; ++mcXiMapIt) {
161  rcXiPartner = (*mcXiMapIt).second;
162  float x, y, z, delta, xd, yd, zd;
163  x = mcVert->position().x();
164  y = mcVert->position().y();
165  z = mcVert->position().z();
166  xd = x - rcXiPartner->position().x();
167  yd = y - rcXiPartner->position().y();
168  zd = z - rcXiPartner->position().z();
169  delta = xd*xd + yd*yd + zd*zd;
170 
171  //Now loop over the bounds
172  for(mcXiMapIter mcXiMapIt = mcXiBounds.first;
173  mcXiMapIt != mcXiBounds.second; ++mcXiMapIt) {
174  const StXiVertex *temp = (*mcXiMapIt).second;
175  if (temp != rcXiPartner) {
176  xd = x - temp->position().x();
177  yd = y - temp->position().y();
178  zd = z - temp->position().z();
179  float delta2 = xd*xd + yd*yd + zd*zd;
180  if (delta2 < delta) { rcXiPartner = temp; delta = delta2; }
181  }
182  }
183  x = rcXiPartner->position().x();
184  y = rcXiPartner->position().y();
185  z = rcXiPartner->position().z();
186  // stupid way
187  for(Int_t i = 0; i <= GetN(); i++) {
188  StXiMuDst* tmpXi = (StXiMuDst*) dataArray->At(i);
189  if( fabs(x - tmpXi->decayVertexXiX()) < 0.00001 &&
190  fabs(y - tmpXi->decayVertexXiY()) < 0.00001 &&
191  fabs(z - tmpXi->decayVertexXiZ()) < 0.00001 )
192  { indexRecoArray = i; break; }
193  }
194  }
195  new((*assocArray)[assocEntries++])
196  StStrangeAssoc(indexRecoArray,(mcEntries-1));
197  if(indexRecoArray!=-1) {
198  pair<mcTrackMapIter,mcTrackMapIter> mcTrackBounds =
199  theMcTrackMap->equal_range(Bach);
200  StTrackPairInfo* bestPairInfo = (*mcTrackBounds.first).second;
201  for(mcTrackMapIter mcMapIt = mcTrackBounds.first;
202  mcMapIt != mcTrackBounds.second; ++mcMapIt) {
203  if ((*mcMapIt).second->commonTpcHits() > bestPairInfo->commonTpcHits())
204  bestPairInfo = (*mcMapIt).second;
205  }
206  if (mcTrackBounds.first != mcTrackBounds.second) {
207  xiMc->SetHitInfo(bestPairInfo->commonTpcHits());
208  }
209  }
210  }
211  }
212 
213  return kStOK;
214 }
215 //_____________________________________________________________________________
216 ClassImp(StXiController)
Monte Carlo Track class All information on a simulated track is stored in this class: kinematics...
Definition: StMcTrack.hh:144
StStrangeEvMuDst * GetMcEvent()
Event information.
Definition: Stypes.h:40
Definition: StXiMc.hh:17
virtual void SetEvent(StStrangeEvMuDst *)
Set pointer to event information.
Definition: StV0I.hh:290
Int_t event() const
Event number.
Definition: Stypes.h:41
Float_t decayVertexXiZ() const
Coordinates of decay vertex.
Definition: StXiMuDst.hh:105