StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StKinkController.cxx
1 // $Id: StKinkController.cxx,v 3.7 2011/04/03 15:51:58 fisyak Exp $
2 // $Log: StKinkController.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:47 genevb
10 // Common muDst, improved MC code, better kinks, StrangeCuts now a branch
11 //
12 // Revision 3.4 2000/12/18 21:35:17 genevb
13 // Introduced variable buffer-sizing
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:47 genevb
25 // Revision 3 has event multiplicities and dedx information for vertex tracks
26 //
27 // Revision 2.1 2000/06/09 22:17:09 genevb
28 // Allow MC data to be copied between DSTs, other small improvements
29 //
30 // Revision 2.0 2000/06/05 05:19:39 genevb
31 // New version of Strangeness micro DST package
32 //
33 //
35 // //
36 // StKinkController strangeness micro DST controller for Kinks //
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 "StKinkVertex.h"
47 #include "StKinkMuDst.hh"
48 #include "StKinkMc.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 //_____________________________________________________________________________
56 StKinkController::StKinkController() : StStrangeControllerBase(kinkT) {
57  increment = 100;
58  max = 500;
59  bsize = 128000;
60 }
61 //_____________________________________________________________________________
62 StKinkController::~StKinkController() {
63 }
64 //_____________________________________________________________________________
65 Int_t StKinkController::MakeReadDst() {
66 
67  entries = GetN();
68  PrintNumCand("read",entries);
69  nEntries += entries;
70 
71  return kStOK;
72 }
73 //_____________________________________________________________________________
74 Int_t StKinkController::MakeCreateDst(StEvent& event) {
75 
76  // Loop over vertices to build array of candidates
77  StSPtrVecKinkVertex& kinkVertices = event.kinkVertices();
78  entries = kinkVertices.size();
79  Int_t asize = dataArray->GetSize();
80  if (entries > asize) dataArray->Expand(entries+increment);
81  Int_t j=0;
82  for (Int_t i=0; i<entries; i++) {
83  StKinkVertex* kinkVertex = kinkVertices[i];
84  if (kinkVertex)
85  new((*dataArray)[j++]) StKinkMuDst(kinkVertex);
86  }
87  entries = j;
88  PrintNumCand("found",entries);
89  nEntries += entries;
90 
91  return kStOK;
92 }
93 //_____________________________________________________________________________
94 Int_t StKinkController::MakeCreateMcDst(StMcVertex* mcVert) {
95 
96  mcKinkMapType* theMcKinkMap = 0;
97  mcTrackMapType* theMcTrackMap = 0;
98  if (assocMaker) {
99  theMcKinkMap = assocMaker->mcKinkMap();
100  theMcTrackMap = assocMaker->mcTrackMap();
101  }
102  if (!((assocMaker)&&(theMcKinkMap)&&(theMcTrackMap))) return kStOk;
103  const StKinkVertex* rcKinkPartner = 0;
104  StMcTrack* Daughter = 0;
105  Int_t indexRecoArray = -1;
106  Int_t count = theMcKinkMap->count(mcVert);
107  StSPtrVecMcTrack& Daughters = mcVert->daughters();
108 
109  for (StMcTrackIterator DTrackIt = Daughters.begin();
110  DTrackIt != Daughters.end(); DTrackIt++) {
111  if ((Int_t)(*DTrackIt)->particleDefinition()->charge()) {
112  Daughter = (*DTrackIt);
113  break;
114  }
115  }
116 
117  if (Daughter) {
118  StKinkMc* kinkMc = new((*mcArray)[mcEntries++]) StKinkMc(mcVert,Daughter);
119  if (count>0) {
120  pair<mcKinkMapIter,mcKinkMapIter> mcKinkBounds =
121  theMcKinkMap->equal_range(mcVert);
122  indexRecoArray = -1;
123 
124  rcKinkPartner = (*mcKinkBounds.first).second;
125  float x, y, z, delta, xd, yd, zd;
126  x = mcVert->position().x();
127  y = mcVert->position().y();
128  z = mcVert->position().z();
129  xd = x - rcKinkPartner->position().x();
130  yd = y - rcKinkPartner->position().y();
131  zd = z - rcKinkPartner->position().z();
132  delta = xd*xd + yd*yd + zd*zd;
133 
134  //Now loop over the bounds
135  for(mcKinkMapIter mcKinkMapIt = mcKinkBounds.first;
136  mcKinkMapIt != mcKinkBounds.second; ++mcKinkMapIt) {
137  const StKinkVertex *temp = (*mcKinkMapIt).second;
138  if (temp != rcKinkPartner) {
139  xd = x - temp->position().x();
140  yd = y - temp->position().y();
141  zd = z - temp->position().z();
142  float delta2 = xd*xd + yd*yd + zd*zd;
143  if (delta2 < delta) { rcKinkPartner = temp; delta = delta2; }
144  }
145  }
146  x = rcKinkPartner->position().x();
147  y = rcKinkPartner->position().y();
148  z = rcKinkPartner->position().z();
149  // stupid way
150  for(Int_t i = 0; i < GetN(); i++) {
151  StKinkMuDst* tmpKink = (StKinkMuDst*) dataArray->At(i);
152  if( fabs(x - tmpKink->positionX()) < 0.00001 &&
153  fabs(y - tmpKink->positionY()) < 0.00001 &&
154  fabs(z - tmpKink->positionZ()) < 0.00001 )
155  { indexRecoArray = i; break; }
156  }
157  new((*assocArray)[assocEntries++])
158  StStrangeAssoc(indexRecoArray,mcEntries-1);
159  if(indexRecoArray!=-1) {
160  pair<mcTrackMapIter,mcTrackMapIter> mcTrackBounds =
161  theMcTrackMap->equal_range(Daughter);
162  StTrackPairInfo* bestPairInfo = (*mcTrackBounds.first).second;
163  for(mcTrackMapIter mcMapIt = mcTrackBounds.first;
164  mcMapIt != mcTrackBounds.second; ++mcMapIt) {
165  if ((*mcMapIt).second->commonTpcHits() > bestPairInfo->commonTpcHits())
166  bestPairInfo = (*mcMapIt).second;
167  }
168  if (mcTrackBounds.first != mcTrackBounds.second) {
169  kinkMc->SetHitInfo(bestPairInfo->commonTpcHits());
170  }
171  }
172  }
173  }
174 
175  return kStOK;
176 }
177 //_____________________________________________________________________________
178 ClassImp(StKinkController)
Monte Carlo Track class All information on a simulated track is stored in this class: kinematics...
Definition: StMcTrack.hh:144
Definition: Stypes.h:40
Definition: Stypes.h:41