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