StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StMuDst.cxx
1 /***************************************************************************
2  *
3  * $Id: StMuDst.cxx,v 1.70 2019/02/21 13:32:54 jdb Exp $
4  * Author: Frank Laue, BNL, laue@bnl.gov
5  *
6  ***************************************************************************/
7 
8 #include <map>
9 
10 #include "StMuDst.h"
11 
12 #include "StContainers.h"
13 #include "StEvent/StEventTypes.h"
14 #include "StEvent/StTriggerData.h"
15 #include "StEvent/StTriggerData2003.h"
16 #include "StEvent/StTriggerData2004.h"
17 #include "StEvent/StTriggerData2005.h"
18 #include "StEvent/StTriggerData2007.h"
19 #include "StEvent/StTriggerData2008.h"
20 #include "StEvent/StTriggerData2009.h"
21 
22 #include "StarClassLibrary/StTimer.hh"
23 #include "StMuDstMaker.h"
24 #include "StMuEvent.h"
25 #include "StMuPrimaryVertex.h"
26 #include "StMuRpsCollection.h"
27 #include "StMuMtdCollection.h"
28 #include "StMuTrack.h"
29 #include "StMuDebug.h"
30 #include "StMuEmcUtil.h"
31 #include "StMuFmsUtil.h"
32 #include "StMuFcsUtil.h"
33 #include "StMuFttUtil.h"
34 #include "StMuFstUtil.h"
35 #include "StMuPmdUtil.h"
37 #include "StBTofCollection.h"
38 #include "StBTofRawHit.h"
39 #include "StBTofHeader.h"
40 #include "StBTofPidTraits.h"
41 #include "StMuBTofHit.h"
42 #include "StETofCollection.h" // fseck
43 #include "StMuETofCollection.h" // fseck
44 #include "StMuETofHeader.h" // fseck
45 #include "StMuETofDigi.h" // fseck
46 #include "StMuETofHit.h" // fseck
47 #include "StMuEpdHitCollection.h" // MALisa
48 #include "StMuEpdHit.h" // MALisa
49 #include "StMuMtdHit.h"
50 #include "StMuMtdHeader.h"
51 #include "TClonesArray.h"
52 #include "TTree.h"
53 #ifndef __NO_STRANGE_MUDST__
54 #include "StStrangeMuDstMaker/StV0MuDst.hh"
55 #include "StStrangeMuDstMaker/StXiMuDst.hh"
56 #include "StStrangeMuDstMaker/StKinkMuDst.hh"
57 #endif
58 TClonesArray** StMuDst::arrays = 0;
59 #ifndef __NO_STRANGE_MUDST__
60 TClonesArray** StMuDst::strangeArrays= 0;
61 #endif
62 #include "StMuMcVertex.h"
63 #include "StMuMcTrack.h"
64 TClonesArray** StMuDst::mcArrays = 0;
65 TClonesArray** StMuDst::emcArrays = 0;
66 TClonesArray** StMuDst::fmsArrays = 0;
67 TClonesArray** StMuDst::fcsArrays = 0;
68 TClonesArray** StMuDst::fttArrays = 0;
69 TClonesArray** StMuDst::fstArrays = 0;
70 TClonesArray** StMuDst::pmdArrays = 0;
71 TClonesArray** StMuDst::tofArrays = 0;
72 TClonesArray** StMuDst::btofArrays = 0;
73 TClonesArray** StMuDst::etofArrays = 0;
74 TClonesArray** StMuDst::epdArrays = 0;
75 TClonesArray** StMuDst::mtdArrays = 0;
76 TClonesArray** StMuDst::fgtArrays = 0;
77 TClonesArray *StMuDst::mMuEmcCollectionArray = 0;
83 TClonesArray *StMuDst::mMuPmdCollectionArray = 0;
87 TClonesArray** StMuDst::eztArrays = 0;
88 
89 Int_t StMuDst::mCurrVertexId = -2;
90 TObjArray* StMuDst::mCurrPrimaryTracks = 0;
91 
93  DEBUGMESSAGE("");
94  /* no-op */
95 }
96 
97 //-----------------------------------------------------------------------
98 //-----------------------------------------------------------------------
99 //-----------------------------------------------------------------------
101  arrays = 0;
102 #ifndef __NO_STRANGE_MUDST__
103  strangeArrays = 0;
104 #endif
105  mcArrays = 0;
106  emcArrays = 0;
107  fmsArrays = 0;
108  fcsArrays = 0;
109  fttArrays = 0;
110  fstArrays = 0;
111  pmdArrays = 0;
112  tofArrays = 0;
113  btofArrays = 0; // dongx
114  mtdArrays = 0; // dongx
115  etofArrays = 0; // jdb
116  epdArrays = 0; // MALisa
117  fgtArrays = 0;
118  mMuEmcCollectionArray = 0;
119  mMuEmcCollection = 0;
120  mMuFmsCollection = 0;
121  mMuFcsCollection = 0;
122  mMuFttCollection = 0;
123  mMuFstCollection = 0;
124  mMuPmdCollectionArray = 0;
125  mMuPmdCollection = 0;
126  mEmcCollection = 0;
127  mFmsCollection = 0;
128  eztArrays = 0;
129  mtdArrays = 0;
130 }
131 //-----------------------------------------------------------------------
132 //-----------------------------------------------------------------------
133 //-----------------------------------------------------------------------
135  DEBUGMESSAGE2("");
136  if (!maker) { DEBUGVALUE(maker); return;}
137  arrays = maker->mArrays;
138 #ifndef __NO_STRANGE_MUDST__
139  strangeArrays = maker->mStrangeArrays;
140 #endif
141  mcArrays = maker->mMCArrays;
142  emcArrays = maker->mEmcArrays;
143  fmsArrays = maker->mFmsArrays;
144  fcsArrays = maker->mFcsArrays;
145  fttArrays = maker->mFttArrays;
146  fstArrays = maker->mFstArrays;
147  pmdArrays = maker->mPmdArrays;
148  tofArrays = maker->mTofArrays;
149  btofArrays = maker->mBTofArrays; // dongx
150  etofArrays = maker->mETofArrays; // jdb
151  epdArrays = maker->mEpdArrays; // MALisa
152  mtdArrays = maker->mMtdArrays;
153  fgtArrays = maker->mFgtArrays;
154 
155 
156  mMuEmcCollectionArray = maker->mEmcCollectionArray;
157  mMuEmcCollection = maker->mEmcCollection;
158  mMuFmsCollection = maker->mFmsCollection;
159  mMuFcsCollection = maker->mFcsCollection;
160  mMuFttCollection = maker->mFttCollection;
161  mMuFstCollection = maker->mFstCollection;
162  mMuPmdCollectionArray = maker->mPmdCollectionArray;
163  mMuPmdCollection = maker->mPmdCollection;
164  eztArrays = maker->mEztArrays;
165 
166 #ifndef __NO_STRANGE_MUDST__
168  int nV0s = v0s()->GetEntriesFast(); for (int i=0;i<nV0s; i++) v0s(i)->SetEvent(ev); // set the pointer to the StStrangeEvMuDst which is not read from disk
169  int nXis = xis()->GetEntriesFast(); for (int i=0;i<nXis; i++) xis(i)->SetEvent(ev); // set the pointer to the StStrangeEvMuDst which is not read from disk
170  // int nKinks = kinks()->GetEntriesFast(); for (int i=0;i<nKinks; i++) kinks(i)->SetEvent(ev);
171 #endif
172 }
173 //-----------------------------------------------------------------------
174 //-----------------------------------------------------------------------
175 //-----------------------------------------------------------------------
176 void StMuDst::set(TClonesArray** theArrays,
177 #ifndef __NO_STRANGE_MUDST__
178  TClonesArray** theStrangeArrays,
179 #endif
180  TClonesArray** theMCArrays,
181  TClonesArray** theEmcArrays,
182  TClonesArray** theFmsArrays,
183  TClonesArray** theFcsArrays,
184  TClonesArray** theFttArrays,
185  TClonesArray** theFstArrays,
186  TClonesArray** thePmdArrays,
187  TClonesArray** theTofArrays,
188  TClonesArray** theBTofArrays, // dongx
189  TClonesArray** theETofArrays, // jdb
190  TClonesArray** theEpdArrays, // MALisa
191  TClonesArray** theMTDArrays,
192  TClonesArray** theFgtArrays,
193  TClonesArray** theEztArrays,
194  TClonesArray* emc_arr,
195  StMuEmcCollection *emc,
196  StMuFmsCollection *fms,
197  StMuFcsCollection *fcs,
198  StMuFttCollection *ftt,
199  StMuFstCollection *fst,
200  TClonesArray* pmd_arr,
201  StMuPmdCollection *pmd)
202 {
203  // I don't understand why this method is still needed,
204  // but cannot comile dictionary when it is removed
205  DEBUGMESSAGE2("");
206  arrays = theArrays;
207 #ifndef __NO_STRANGE_MUDST__
208  strangeArrays = theStrangeArrays;
209 #endif
210  mcArrays = theMCArrays;
211  emcArrays = theEmcArrays;
212  fmsArrays = theFmsArrays;
213  fcsArrays = theFcsArrays;
214  fttArrays = theFttArrays;
215  fstArrays = theFstArrays;
216  fgtArrays = theFgtArrays;
217  pmdArrays = thePmdArrays;
218  tofArrays = theTofArrays;
219  btofArrays = theBTofArrays; // dongx
220  etofArrays = theETofArrays; // jdb
221  epdArrays = theEpdArrays; // MALisa
222  mMuEmcCollectionArray = emc_arr;
223  mMuEmcCollection = emc;
224  mMuFmsCollection = fms;
225  mMuFcsCollection = fcs;
226  mMuFttCollection = ftt;
227  mMuFstCollection = fst;
228  mMuPmdCollectionArray = pmd_arr;
229  mMuPmdCollection = pmd;
230  eztArrays = theEztArrays;
231  mtdArrays = theMTDArrays;
232 }
233 //-----------------------------------------------------------------------
234 //-----------------------------------------------------------------------
235 //-----------------------------------------------------------------------
237  if (mCurrPrimaryTracks == 0)
238  mCurrPrimaryTracks = new TObjArray();
239  Int_t n_track = arrays[muPrimary]->GetEntriesFast();
240  mCurrPrimaryTracks->Clear();
241  for (Int_t i_track = 0; i_track < n_track; i_track++) {
242  if (((StMuTrack*)arrays[muPrimary]->UncheckedAt(i_track))->vertexIndex() == mCurrVertexId)
243  mCurrPrimaryTracks->AddLast(arrays[muPrimary]->UncheckedAt(i_track));
244  }
245 }
246 //-----------------------------------------------------------------------
247 //-----------------------------------------------------------------------
248 //-----------------------------------------------------------------------
249 void StMuDst::setVertexIndex(Int_t vtx_id) {
250  if (mCurrVertexId == vtx_id)
251  return;
252  mCurrVertexId = vtx_id;
254 }
255 //-----------------------------------------------------------------------
256 //-----------------------------------------------------------------------
257 //-----------------------------------------------------------------------
262  fixTrackIndices( arrays[muPrimary], arrays[muGlobal] );
263 }
264 //-----------------------------------------------------------------------
265 //-----------------------------------------------------------------------
266 //-----------------------------------------------------------------------
267 void StMuDst::fixTrackIndices(TClonesArray* primary, TClonesArray* global) {
275 
276  if ( !(global&&primary) ) return;
277  DEBUGMESSAGE1("");
278  StTimer timer;
279  timer.start();
280 
281  static int warningPrinted = 0;
282  if (!warningPrinted) {
283  LOG_WARN << "WARNING: You are using " << __PRETTY_FUNCTION__
284  << " which does not work properly "
285  " for productions with FTPC >= SL04d and <= SL05g" << endm;
286  warningPrinted = 1;
287  }
288  int nGlobals = global->GetEntriesFast();
289  int nPrimaries = primary->GetEntriesFast();
290  // map to keep track of index numbers, key is track->id(), value is index of track in MuDst
291  map<short,unsigned short> globalIndex;
292 
293  for (int i=0; i<nGlobals; i++) {
294  StMuTrack *g = (StMuTrack*) global->UncheckedAt(i);
295  if (g) {
296  globalIndex[g->id()] = i+1;
297  globalTracks(i)->setIndex2Global(i);
298  }
299  }
300  // set the indices for the primary tracks
301  DEBUGVALUE2(primary->GetEntriesFast());
302  for (int i=0; i<nPrimaries; i++) {
303  StMuTrack *p = (StMuTrack*) primary->UncheckedAt(i);
304  if (p) {
305  if (globalIndex[p->id()])
306  p->setIndex2Global( globalIndex[ p->id() ]-1 );
307  else
308  p->setIndex2Global(-1);
309  }
310  }
311  DEBUGVALUE2(timer.elapsedTime());
312 }
313 
316  //mult = 0 means there is just a single vertex in the event, mult>0 means there are multiple...
317 
318  if (mult==0){
319  if(!(fabs(event()->primaryVertexPosition().x()) < 1.e-5 && fabs(event()->primaryVertexPosition().y()) < 1.e-5 && fabs(event()->primaryVertexPosition().z()) < 1.e-5)){
320  int startpos = 0;
321  int tid, pid;
322  if(!globalTracks()) return;
323  for (int i=0;i<globalTracks()->GetEntriesFast();i++){
324  tid = globalTracks(i)->id();
325  globalTracks(i)->setIndex2Global(-2);
326  if(!primaryTracks()) return;
327  for(int j=startpos;j<primaryTracks()->GetEntriesFast();j++){
328  pid = primaryTracks(j)->id();
329  if(pid==tid) {
330  globalTracks(i)->setIndex2Global(j);
331  if (j==startpos) startpos++;
332  break;
333  }
334  else if (pid > tid) break;
335  }
336  }
337  }
338  return;
339  }
340  //New MuDsts with multiple vertices....
341  if(!primaryVertices()) return;
342  const int Nvert = primaryVertices()->GetEntriesFast();
343  if(!Nvert) return;
344  int curVer = currentVertexIndex();
345  int startpos[Nvert];
346  for(int i=0;i<Nvert;i++) startpos[i]=0;
347  int tid, pid;
348  if(!globalTracks()) return;
349 
350  for (int i=0;i<globalTracks()->GetEntriesFast();i++){
351  tid = globalTracks(i)->id();
352  globalTracks(i)->setIndex2Global(-2);
353  globalTracks(i)->setVertexIndex(-2);
354  //Scan through vertices
355  for(int j=0;j<Nvert;j++){
356  if(globalTracks(i)->index2Global() >= 0) break;
357  setVertexIndex(j);
358  if(!primaryTracks()) continue;
359  for(int k=startpos[j];k<primaryTracks()->GetEntriesFast();k++){
360  pid = primaryTracks(k)->id();
361  if(pid==tid) {
362  globalTracks(i)->setIndex2Global(k);
363  globalTracks(i)->setVertexIndex(j);
364  if (k==startpos[j]) startpos[j]++;
365  break;
366  }
367  else if (pid > tid) break;
368  }
369  }
370  }
371  setVertexIndex(curVer);
372 }
373 //-----------------------------------------------------------------------
374 //-----------------------------------------------------------------------
375 //-----------------------------------------------------------------------
380  fixTofTrackIndices( btofArrays[muBTofHit], arrays[muPrimary], arrays[muGlobal] );
381 }
382 //-----------------------------------------------------------------------
383 //-----------------------------------------------------------------------
384 //-----------------------------------------------------------------------
385 void StMuDst::fixTofTrackIndices(TClonesArray* btofHit, TClonesArray* primary, TClonesArray* global) {
386 
387  if ( !(primary&&global&&btofHit) ) return;
388  DEBUGMESSAGE1("");
389  StTimer timer;
390  timer.start();
391 
392  int nPrimarys = primary->GetEntriesFast();
393  int nGlobals = global->GetEntriesFast();
394  int nBTofHits = btofHit->GetEntriesFast();
395  // map to keep track of index numbers, key is track->id(), value is index of track in MuDst
396  map<short,unsigned short> tofIndex;
397  map<short,unsigned short> globalIndex;
398  map<short,unsigned short> primaryIndex;
399 
400  for (int i=0; i<nBTofHits; i++) {
401  StMuBTofHit *t = (StMuBTofHit*) btofHit->UncheckedAt(i);
402  if (t) {
403  tofIndex[t->associatedTrackId()] = i+1; // starting from 1
404  }
405  }
406 
407  for (int i=0; i<nGlobals; i++) {
408  StMuTrack *g = (StMuTrack*) global->UncheckedAt(i);
409  if (g) {
410  globalIndex[g->id()] = i+1;
411 
412  if(tofIndex[g->id()])
413  g->setIndex2BTofHit( tofIndex[g->id()]-1 );
414  else
415  g->setIndex2BTofHit(-1);
416  }
417  }
418  for (int i=0; i<nPrimarys; i++) {
419  StMuTrack *p = (StMuTrack*) primary->UncheckedAt(i);
420  if (p) {
421  primaryIndex[p->id()] = i+1;
422 
423  if(tofIndex[p->id()])
424  p->setIndex2BTofHit( tofIndex[p->id()]-1 );
425  else
426  p->setIndex2BTofHit(-1);
427  }
428  }
429 
431  for (int i=0; i<nBTofHits; i++) {
432  StMuBTofHit *t = (StMuBTofHit*) btofHit->UncheckedAt(i);
433  if (t) {
434  if(globalIndex[t->associatedTrackId()])
435  t->setIndex2Global( globalIndex[t->associatedTrackId()]-1 );
436  else
437  t->setIndex2Global(-1);
438 
439  if(primaryIndex[t->associatedTrackId()])
440  t->setIndex2Primary( primaryIndex[t->associatedTrackId()]-1 );
441  else
442  t->setIndex2Primary(-1);
443  }
444  }
445 
446  DEBUGVALUE2(timer.elapsedTime());
447 }
448 
449 //-----------------------------------------------------------------------
450 //-----------------------------------------------------------------------
451 //-----------------------------------------------------------------------
456  fixETofTrackIndices( etofArrays[muETofHit], arrays[muPrimary], arrays[muGlobal] );
457 }
458 //-----------------------------------------------------------------------
459 //-----------------------------------------------------------------------
460 //-----------------------------------------------------------------------
461 void StMuDst::fixETofTrackIndices( TClonesArray* etofHit, TClonesArray* primary, TClonesArray* global ) {
462 
463  if( !( primary && global && etofHit ) ) return;
464  DEBUGMESSAGE1("");
465  StTimer timer;
466  timer.start();
467 
468  int nPrimaries = primary->GetEntriesFast();
469  int nGlobals = global->GetEntriesFast();
470  int nETofHits = etofHit->GetEntriesFast();
471  // map to keep track of index numbers, key is track->id(), value is index of track in MuDst
472  map<short,unsigned short> etofIndex;
473  map<short,unsigned short> globalIndex;
474  map<short,unsigned short> primaryIndex;
475 
476  for( int i=0; i<nETofHits; i++ ) {
477  StMuETofHit* t = (StMuETofHit*) etofHit->UncheckedAt(i);
478  if( t ) {
479  etofIndex[t->associatedTrackId()] = i+1; // starting from 1
480  }
481  }
482 
483  for( int i=0; i<nGlobals; i++ ) {
484  StMuTrack* g = (StMuTrack*) global->UncheckedAt(i);
485  if( g ) {
486  globalIndex[g->id()] = i+1;
487 
488  if( etofIndex[g->id()] ) {
489  g->setIndex2ETofHit( etofIndex[g->id()]-1 );
490  }
491  else {
492  g->setIndex2ETofHit( -1 );
493  }
494  }
495  }
496  for( int i=0; i<nPrimaries; i++ ) {
497  StMuTrack* p = (StMuTrack*) primary->UncheckedAt(i);
498  if( p ) {
499  primaryIndex[p->id()] = i+1;
500 
501  if( etofIndex[p->id()] ) {
502  p->setIndex2ETofHit( etofIndex[p->id()]-1 );
503  }
504  else {
505  p->setIndex2ETofHit( -1 );
506  }
507  }
508  }
509 
511  for( int i=0; i<nETofHits; i++ ) {
512  StMuETofHit* t = (StMuETofHit*) etofHit->UncheckedAt( i );
513  if( t ) {
514  if( globalIndex[t->associatedTrackId()] )
515  t->setIndex2Global( globalIndex[t->associatedTrackId()]-1 );
516  else
517  t->setIndex2Global( -1 );
518 
519  if(primaryIndex[t->associatedTrackId()])
520  t->setIndex2Primary( primaryIndex[t->associatedTrackId()]-1 );
521  else
522  t->setIndex2Primary( -1 );
523  }
524  }
525 
526  DEBUGVALUE2(timer.elapsedTime());
527 }
528 
529 //-----------------------------------------------------------------------
530 //-----------------------------------------------------------------------
531 //-----------------------------------------------------------------------
536  fixMtdTrackIndices( mtdArrays[muMTDHit], arrays[muPrimary], arrays[muGlobal] );
537 }
538 //-----------------------------------------------------------------------
539 //-----------------------------------------------------------------------
540 //-----------------------------------------------------------------------
541 void StMuDst::fixMtdTrackIndices(TClonesArray* mtdHit, TClonesArray* primary, TClonesArray* global) {
542 
543  if ( !(primary&&global&&mtdHit) ) return;
544  DEBUGMESSAGE1("");
545  StTimer timer;
546  timer.start();
547 
548  int nPrimarys = primary->GetEntriesFast();
549  int nGlobals = global->GetEntriesFast();
550  int nMtdHits = mtdHit->GetEntriesFast();
551  // map to keep track of index numbers, key is track->id(), value is index of track in MuDst
552  map<short,unsigned short> mtdIndex;
553  map<short,unsigned short> globalIndex;
554  map<short,unsigned short> primaryIndex;
555 
556  for (int i=0; i<nMtdHits; i++) {
557  StMuMtdHit *t = (StMuMtdHit*) mtdHit->UncheckedAt(i);
558  if (t) {
559  mtdIndex[t->associatedTrackKey()] = i+1; // starting from 1
560  }
561  }
562 
563  for (int i=0; i<nGlobals; i++) {
564  StMuTrack *g = (StMuTrack*) global->UncheckedAt(i);
565  if (g) {
566  globalIndex[g->id()] = i+1;
567 
568  if(mtdIndex[g->id()])
569  g->setIndex2MtdHit( mtdIndex[g->id()]-1 );
570  else
571  g->setIndex2MtdHit(-1);
572  }
573  }
574  for (int i=0; i<nPrimarys; i++) {
575  StMuTrack *p = (StMuTrack*) primary->UncheckedAt(i);
576  if (p) {
577  primaryIndex[p->id()] = i+1;
578 
579  if(mtdIndex[p->id()])
580  p->setIndex2MtdHit( mtdIndex[p->id()]-1 );
581  else
582  p->setIndex2MtdHit(-1);
583  }
584  }
585 
587  for (int i=0; i<nMtdHits; i++) {
588  StMuMtdHit *t = (StMuMtdHit*) mtdHit->UncheckedAt(i);
589  if (t) {
590  if(globalIndex[t->associatedTrackKey()])
591  t->setIndex2Global( globalIndex[t->associatedTrackKey()]-1 );
592  else
593  t->setIndex2Global(-1);
594 
595  if(primaryIndex[t->associatedTrackKey()])
596  t->setIndex2Primary( primaryIndex[t->associatedTrackKey()]-1 );
597  else
598  t->setIndex2Primary(-1);
599  }
600  }
601 
602  DEBUGVALUE2(timer.elapsedTime());
603 }
604 
605 //-----------------------------------------------------------------------
606 //-----------------------------------------------------------------------
607 //-----------------------------------------------------------------------
611 
612  mtdArrays[muMTDHit]->Clear();
613  StMuMtdCollection mMTD(*mtd_coll);
614  for(size_t i=0; i < (size_t)mMTD.hitsPresent(); i++)
615  {
616  StMuMtdHit* mtdHit = (StMuMtdHit*)mMTD.MtdHit(i);
617  new((*mtdArrays[muMTDHit])[i]) StMuMtdHit(*mtdHit);
618  }
619 
620  StMuMtdHeader *mtdHead = mMTD.mtdHeader();
621  if(mtdHead)
622  {
623  mtdArrays[muMTDHeader]->Clear();
624  new((*mtdArrays[muMTDHeader])[0]) StMuMtdHeader(*mtdHead);
625  }
626 }
627 
628 //-----------------------------------------------------------------------
629 void StMuDst::setETofArray( const StETofCollection* etof_coll ) {
632 
633  etofArrays[ muETofDigi ]->Clear();
634  etofArrays[ muETofHit ]->Clear();
635  StMuETofCollection muETofColl( etof_coll );
636 
637  for( size_t i=0; i < (size_t) muETofColl.digisPresent(); i++ ) {
638  StMuETofDigi* etofDigi = ( StMuETofDigi* ) muETofColl.etofDigi( i );
639  new( ( *etofArrays[ muETofDigi ] )[ i ] ) StMuETofDigi( *etofDigi );
640  }
641 
642  for( size_t i=0; i < (size_t) muETofColl.hitsPresent(); i++ ) {
643  StMuETofHit* etofHit = ( StMuETofHit* ) muETofColl.etofHit( i );
644  new( ( *etofArrays[ muETofHit ] )[ i ] ) StMuETofHit( *etofHit );
645  }
646 
647  StMuETofHeader* etofHead = muETofColl.etofHeader();
648  if( etofHead ) {
649  etofArrays[ muETofHeader ]->Clear();
650  new( ( *etofArrays[ muETofHeader ] )[ 0 ] ) StMuETofHeader( *etofHead );
651  }
652 }
653 
654 //-----------------------------------------------------------------------
657  if( hit ) {
658  unsigned int index = etofArrays[ muETofHit ]->GetEntriesFast();
659  LOG_DEBUG << "hit will be added as index: " << index << endm;
660 
661  new( ( *etofArrays[ muETofHit ] )[ index ] ) StMuETofHit( *hit );
662  }
663  LOG_DEBUG << "done. -> new array size: " << etofArrays[ muETofHit ]->GetEntriesFast() << endm;
664 }
665 
666 //-----------------------------------------------------------------------
667 //-----------------------------------------------------------------------
668 //-----------------------------------------------------------------------
669 //-----------------------------------------------------------------------
670 //-----------------------------------------------------------------------
671 //-----------------------------------------------------------------------
672 //-----------------------------------------------------------------------
673 //-----------------------------------------------------------------------
674 //-----------------------------------------------------------------------
675 //-----------------------------------------------------------------------
676 //-----------------------------------------------------------------------
677 //-----------------------------------------------------------------------
679  DEBUGMESSAGE1("");
680  StTimer timer;
681  timer.start();
682 
683  StMuEvent* mu = event();
684  if(!mu) return NULL;
685  StEvent* ev = new StEvent();
686 
687  ev->setInfo( new StEventInfo(mu->eventInfo()) );
688  ev->setRunInfo( new StRunInfo(mu->runInfo()) );
689  ev->setSummary( new StEventSummary(mu->eventSummary()) );
690  // ev->setSoftwareMonitor(SoftwareMonitor*);
691  // ev->setTpcHitCollection(StTpcHitCollection*);
692  // ev->setFtpcHitCollection(StFtpcHitCollection*);
693  // ev->setSvtHitCollection(StSvtHitCollection*);
694  // ev->setSsdHitCollection(StSsdHitCollection*);
695  // ev->setEmcCollection(StEmcCollection*);
696  // ev->setRichCollection(StRichCollection*);
697  // ev->setTofCollection(StTofCollection*);
698  //ev->setTofCollection( new StTofCollection() );
700  trg_coll->vpd()=mu->vpdTriggerDetector();
701  trg_coll->bbc()=mu->bbcTriggerDetector();
702  trg_coll->ctb()=mu->ctbTriggerDetector();
703  trg_coll->emc()=mu->emcTriggerDetector();
704  trg_coll->fpd()=mu->fpdTriggerDetector();
705  trg_coll->zdc()=mu->zdcTriggerDetector();
706  ev->setTriggerDetectorCollection(trg_coll);
707 
708  ev->setFpdCollection( new StFpdCollection(mu->fpdCollection()) );
709  // ev->setTriggerDetectorCollection(muStTriggerDetectorCollection*); <<< WE DON'T WANT THAT
710  ev->setL0Trigger ( new StL0Trigger(mu->l0Trigger()) );
711  // ev->setL1Trigger ( new StL0Trigger(mu->l0Trigger()) );
712  ev->setL3Trigger ( new StL3Trigger() );
713 
714  StPrimaryVertex* vp = new StPrimaryVertex();
715  ev->addPrimaryVertex(vp);
716  vp->setPosition( mu->eventSummary().primaryVertexPosition() );
717 
718  int nGlobals = arrays[muGlobal]->GetEntriesFast();
719 
720  StSPtrVecTrackNode &trackNodes = ev->trackNodes();
721  TArrayI global_indices(nGlobals); // Temporary array to keep track of index numbers on trackNodes
722 
723  // add global tracks to tracknodes
724  for (int i=0; i<nGlobals; i++) {
725  if(globalTracks(i)) {
726  StTrackNode *node = new StTrackNode();
727  node->addTrack(createStTrack(globalTracks(i)));
728  trackNodes.push_back(node);
729  global_indices[i]=trackNodes.size()-1;
730  }
731  else {
732  global_indices[i]=-1;
733  }
734  }
735 
740 
741  TObjArray *prim_tracks=primaryTracks();
742 
743  int nPrimaries = prim_tracks->GetEntriesFast();
744  for (int i=0; i<nPrimaries; i++) if(primaryTracks(i)) {
745  StTrack* t = createStTrack((StMuTrack*)prim_tracks->At(i));
746  Int_t global_idx=primaryTracks(i)->index2Global();
747  if (global_idx >= 0 && global_indices[global_idx] >= 0)
748  trackNodes[global_indices[global_idx]]->addTrack( t );
749  else {
750  StTrackNode *node=new StTrackNode();
751  node->addTrack(t);
752  trackNodes.push_back(node);
753  }
754  vp->addDaughter( t );
755  }
756 
761 
762  // add detector states
763  int nStates = arrays[muState]->GetEntriesFast();
764  for (int i=0; i<nStates; i++) {
766  ev->addDetectorState(det);
767  }
768 
769 
770  // now get the EMC stuff and put it in the StEvent
771  static StMuEmcUtil* mEmcUtil = new StMuEmcUtil();
773  if(emc) { // transform to StEvent format and fill it
774  StEmcCollection *EMC = mEmcUtil->getEmc(emc);
775  if(EMC) ev->setEmcCollection(EMC);
776  }
777  // now get the FMS stuff and put it in the StEvent
778  static StMuFmsUtil* mFmsUtil = new StMuFmsUtil();
780  if(fms) { // transform to StEvent format and fill it
781  StFmsCollection *FMS = mFmsUtil->getFms(fms);
782  if(FMS) ev->setFmsCollection(FMS);
783  }
784  // now get the FMS stuff and put it in the StEvent
785  static StMuFcsUtil* mFcsUtil = new StMuFcsUtil();
787  if(fcs) { // transform to StEvent format and fill it
788  StFcsCollection *FCS = mFcsUtil->getFcs(fcs);
789  if(FCS) ev->setFcsCollection(FCS);
790  }
791  // now get the FTT stuff and put it in the StEvent
792  static StMuFttUtil* mFttUtil = new StMuFttUtil();
794  if(ftt) { // transform to StEvent format and fill it
795  StFttCollection *FTT = mFttUtil->getFtt(ftt);
796  if(FTT) ev->setFttCollection(FTT);
797  }
798  // now get the FST stuff and put it in the StEvent
799  static StMuFstUtil* mFstUtil = new StMuFstUtil();
801  if(fst) { // transform to StEvent format and fill it
802  StFstHitCollection *FST = mFstUtil->getFst(fst);
803  if(FST) ev->setFstHitCollection(FST);
804  }
805  // now get the PMD stuff and put it in the StEvent
806  static StMuPmdUtil* mPmdUtil = new StMuPmdUtil();
808  if(pmd) { // transform to StEvent format and fill it
809  StPhmdCollection *PMD = mPmdUtil->getPmd(pmd);
810  if(PMD) ev->setPhmdCollection(PMD);
811  }
812 
813 // now get tof (after fix from Xin)
814  StTofCollection *tofcoll = new StTofCollection();
815  ev->setTofCollection(tofcoll);
816  int nTofData = tofArrays[muTofData]->GetEntriesFast();
817  for(int i=0;i<nTofData;i++) {
818  StTofData *aData;
819  if(tofData(i)) {
820  unsigned short id = tofData(i)->dataIndex();
821  unsigned short adc = tofData(i)->adc();
822  unsigned short tdc = tofData(i)->tdc();
823  short tc = tofData(i)->tc();
824  unsigned short sc = tofData(i)->sc();
825  // run 5 - dongx
826  aData = new StTofData(id, adc, tdc, tc, sc, 0, 0);
827  } else {
828  aData = new StTofData(0, 0, 0, 0, 0, 0, 0);
829  }
830  tofcoll->addData(aData);
831  }
832  // run 5 - dongx
833  int nTofRawData = tofArrays[muTofRawData]->GetEntriesFast();
834  for(int i=0;i<nTofRawData;i++) {
835  StTofRawData *aRawData;
836  if(tofRawData(i)) {
837  unsigned short tray = tofRawData(i)->tray();
838  unsigned short leteFlag = tofRawData(i)->leteFlag();
839  unsigned short channel = tofRawData(i)->channel();
840  unsigned int tdc = tofRawData(i)->tdc();
841  unsigned int triggertime = tofRawData(i)->triggertime();
842  unsigned short quality = tofRawData(i)->quality();
843  aRawData = new StTofRawData(leteFlag,tray,channel,tdc,triggertime,quality);
844  } else {
845  aRawData = new StTofRawData(0, 0, 0, 0, 0, 0);
846  }
847  tofcoll->addRawData(aRawData);
848  }
849 
850  // now create, fill the StBTofCollection - dongx
851  StBTofCollection *btofcoll = new StBTofCollection();
852  ev->setBTofCollection(btofcoll);
853  int nBTofRawHits = btofArrays[muBTofRawHit]->GetEntriesFast();
854  for(int i=0;i<nBTofRawHits;i++) {
855  StBTofRawHit *aRawHit;
856  if(btofRawHit(i)) {
857  aRawHit = new StBTofRawHit(*(btofRawHit(i)));
858  } else {
859  aRawHit = new StBTofRawHit();
860  }
861  btofcoll->addRawHit(aRawHit);
862  }
863  if(btofHeader()) btofcoll->setHeader(new StBTofHeader(*(btofHeader())));
864  // now create, fill and add new StTriggerIdCollection to the StEvent
865  StTriggerIdCollection* triggerIdCollection = new StTriggerIdCollection();
866  StTriggerId triggerId;
867  triggerId = mu->triggerIdCollection().l1();
868  if ( !StMuTriggerIdCollection::isEmpty( triggerId ) ) triggerIdCollection->setL1( new StTriggerId( triggerId ) );
869  triggerId = mu->triggerIdCollection().l2();
870  if ( !StMuTriggerIdCollection::isEmpty( triggerId ) ) triggerIdCollection->setL2( new StTriggerId( triggerId ) );
871  triggerId = mu->triggerIdCollection().l3();
872  if ( !StMuTriggerIdCollection::isEmpty( triggerId ) ) triggerIdCollection->setL3( new StTriggerId( triggerId ) );
873  triggerId = mu->triggerIdCollection().nominal();
874  if ( !StMuTriggerIdCollection::isEmpty( triggerId ) ) triggerIdCollection->setNominal( new StTriggerId( triggerId ) );
875  ev->setTriggerIdCollection( triggerIdCollection );
876 
877 
878  DEBUGVALUE2(timer.elapsedTime());
879  return ev;
880 }
881 
882 #include "StarClassLibrary/SystemOfUnits.h"
883 #include "StarClassLibrary/PhysicalConstants.h"
885  static StPhysicalHelixD nullHelix;
886  StHelixModel* model=0;
887  if (nullHelix==*h) return 0;
888  if (fabs(h->curvature()) > 100) return 0;
889  if (fabs(h->origin().x())>1000) return 0;
890  if (fabs(h->origin().y())>1000) return 0;
891  if (fabs(h->origin().z())>1000) return 0;
892 
893  model = new StHelixModel(q, h->phase()+h->h()*pi/2, h->curvature(), h->dipAngle(), h->origin(),
894  h->momentumAt(0,event()->runInfo().magneticField()*kilogauss), h->h());
895  return model;
896 }
897 
899  StTrack* t=0;
900  StTrackGeometry *tg;
901  if (track->bad()) return 0;
902 
903  if (track->type() == primary) t = new StPrimaryTrack();
904  if (track->type() == global) t = new StGlobalTrack();
905  assert(t);
906  t->setFlag( track->flag() );
907  t->setFlagExtension( track->flagExtension() );
908  t->setKey( track->id() );
909 
910  StPhysicalHelixD helix;
911  helix = track->helix();
912  tg = trackGeometry( track->charge(), &helix );
913  if (tg) t->setGeometry( tg );
914  helix = track->outerHelix();
915  tg = trackGeometry( track->charge(), &helix );
916  if (tg) t->setOuterGeometry( tg );
917 
918  t->setIdTruth(track->idTruth(), track->qaTruth());
919  t->setIdParentVx( track->idParentVx() );
920  t->setLength(track->length());
921  t->setImpactParameter(track->dca().mag());
922  t->addPidTraits(new StDedxPidTraits(kTpcId, kTruncatedMeanId, track->nHitsDedx(), track->dEdx(),0));
923  Float_t a[2],b[15];
924  a[0]=track->chi2();
925  a[1]=0;
926  memset(b,0,15*sizeof(Float_t));
927 
928  StTrackFitTraits traits(0,0,a,b);
929  traits.setNumberOfFitPoints(track->nHitsFit(kTpcId),kTpcId);
930  traits.setNumberOfFitPoints(track->nHitsFit(kFtpcEastId),kFtpcEastId);
931  traits.setNumberOfFitPoints(track->nHitsFit(kFtpcWestId),kFtpcWestId);
932  traits.setNumberOfFitPoints(track->nHitsFit(kSvtId),kSvtId);
933  traits.setNumberOfFitPoints(track->nHitsFit(kSsdId),kSsdId);
934  // Set flag for primary tracks, but not if data is old-style
935  // Old style data has +1 for vertex built-in for Ftpc (not sure about Tpc)
936  if (track->type() == primary && track->mNHitsFitTpc != 255)
937  traits.setPrimaryVertexUsedInFit(kTRUE);
938  t->setFitTraits(traits);
939 
940  t->setNumberOfPossiblePoints(track->nHitsPoss(kTpcId),kTpcId);
941  t->setNumberOfPossiblePoints(track->nHitsPoss(kFtpcEastId),kFtpcEastId);
942  t->setNumberOfPossiblePoints(track->nHitsPoss(kFtpcWestId),kFtpcWestId);
943  t->setNumberOfPossiblePoints(track->nHitsPoss(kSvtId),kSvtId);
944  t->setNumberOfPossiblePoints(track->nHitsPoss(kSsdId),kSsdId);
945  t->setNumberOfPossiblePoints(track->nHitsPoss(kSstId), kSstId);
946  t->setNumberOfPossiblePoints(track->nHitsPoss(kPxlId), kPxlId);
947  t->setNumberOfPossiblePoints(track->nHitsPoss(kIstId), kIstId);
948 
949  // set the topology map
950  t->setTopologyMap( track->topologyMap() );
951 
952  // set the btofPidTraits - dongx
953  t->addPidTraits(track->btofPidTraits().createBTofPidTraits());
954 
955  // set the etofPidTraits - fseck
956  t->addPidTraits(track->etofPidTraits().createETofPidTraits());
957 
958  return t;
959 }
960 
961 void StMuDst::Print(Option_t *option) const {
962  StMuEvent *event = 0;
963  if ((event = StMuDst::event())) {
964  cout << "++++++++++++++ MuDst run " << event->runId() << " event " << event->eventId() << " ++++++++++++++" << endl;
965  cout << endl << "primary vertex pos " << event->primaryVertexPosition() << endl;
966  }
967  else
968  cout << "No event structure (StMuEvent) found!" << endl;
969 
970 
971  cout << numberOfPrimaryVertices() << " vertices reconstructed" << endl;
972  cout << numberOfPrimaryTracks() << " primary tracks, ";
973  if (mCurrVertexId != 0)
974  cout << "( note vtx_id " << mCurrVertexId << " ) " ;
975  cout << numberOfGlobalTracks() << " global " << endl;
976 
977 #ifndef __NO_STRANGE_MUDST__
978  cout << numberOfV0s() << " V0s, " << numberOfXis() << " Xis "
979  << numberOfKinks() << " kinks" << endl;
980 #endif
981  cout << endl;
982  if (muEmcCollection())
983  cout << "EMC data present" << endl;
984  else
985  cout << "No EMC data present" << endl;
986  cout << endl;
987  if (muFmsCollection())
988  cout << "FMS data present" << endl;
989  else
990  cout << "No FMS data present" << endl;
991  if (pmdCollection())
992  cout << "PMD data present" << endl;
993  else
994  cout << "No PMD data present" << endl;
995 
996  if (numberOfTofHit())
997  cout << "TOF data present" << endl;
998  else
999  cout << "No TOF data present" << endl;
1000  cout << endl;
1001 }
1002 
1003 void StMuDst::printVertices() {
1004  if (numberOfPrimaryVertices() == 0) {
1005  cout << "No vertices stored (for older data, check StMuEvent)" << endl;
1006  return;
1007  }
1008  cout << endl;
1009  cout << "+++++++++ vertex list ( " << numberOfPrimaryVertices() << " entries )" << endl << endl;
1010  for (UInt_t i_vtx = 0; i_vtx < numberOfPrimaryVertices(); i_vtx++) {
1011  cout << "+++ Vertex " << i_vtx << endl;
1012  primaryVertex(i_vtx)->Print();
1013  cout << endl;
1014  }
1015 }
1016 
1017 void StMuDst::printPrimaryTracks() {
1018  if (numberOfPrimaryTracks() == 0) {
1019  cout << "No primary tracks found!" << endl;
1020  return;
1021  }
1022  cout << endl;
1023  cout << "+++++++++ PRIMARY track list ( " << numberOfPrimaryTracks() << " entries )" << endl << endl;
1024  for (UInt_t i_trk = 0; i_trk < numberOfPrimaryTracks(); i_trk++) {
1025  cout << "+++ Primary track " << i_trk << endl;
1026  primaryTracks(i_trk)->Print();
1027  cout << endl;
1028  }
1029 }
1030 
1031 void StMuDst::printGlobalTracks() {
1032  if (numberOfGlobalTracks() == 0) {
1033  cout << "No global tracks found!" << endl;
1034  return;
1035  }
1036  cout << endl;
1037  cout << "+++++++++ GLOBAL track list ( " << numberOfGlobalTracks() << " entries )" << endl << endl;
1038  for (UInt_t i_trk = 0; i_trk < numberOfGlobalTracks(); i_trk++) {
1039  cout << "+++ Global track " << i_trk << endl;
1040  globalTracks(i_trk)->Print();
1041  cout << endl;
1042  }
1043 }
1044 
1045 ClassImp(StMuDst)
1046 
1047 /***************************************************************************
1048  *
1049  * $Log: StMuDst.cxx,v $
1050  * Revision 1.70 2019/02/21 13:32:54 jdb
1051  * Inclusion of ETOF MuDst code. This code adds support for the full set of ETOF data which includes EtofDigi, EtofHit, EtofHeader. The code essentially copies similar structures from StEvent and additionally rebuilds the maps between Digis and Hits. Accessor methods are added based on the pattern from BTOF to provide access to data at various levels. The code for accessing the PID traits provided by ETOF is also provided
1052  *
1053  * Revision 1.69 2018/02/27 04:11:57 jdb
1054  * Added epdArrays
1055  *
1056  * Revision 1.68 2017/01/19 23:03:19 smirnovd
1057  * Copy previously missing values in StMuTrack to StTrack conversion
1058  *
1059  * Revision 1.67 2017/01/19 23:03:13 smirnovd
1060  * Promise to not modify original StMuTrack when converting to StTrack
1061  *
1062  * Revision 1.66 2016/10/01 21:23:25 jdb
1063  * Changed default vertex index to -2. Recently changed it to -1 which caused unintended segfault since -1 is used as a special case value in other parts of the code.
1064  *
1065  * Revision 1.65 2016/09/30 01:06:40 jdb
1066  * initialize mCurrVertexId to -1 (was 0) so that when it is set the first time it will always cause the needed function call to collectVertexTracks().
1067  *
1068  * Revision 1.64 2014/06/25 01:26:39 jdb
1069  * Updated StMuDst::setMtdArray() and reset the MTD header. Needed for Run12 UU data where only the muMtdCollection is available.
1070  *
1071  * Revision 1.63 2014/05/16 15:06:45 jdb
1072  * chaned StMuDst{.h,.cxx} to add setMtdArray function
1073  *
1074  * Revision 1.62 2014/04/15 04:48:47 jdb
1075  * Changed mtdArrays[muBTofHit] to mtdArrays[muMTDHit] in StMuDst.cxx in function fixMtdTrackIndices
1076  *
1077  * Revision 1.61 2014/03/03 23:11:46 jdb
1078  * Added Rongrongs changes to StMuDst.cxx and StMuMtdHit.{cxx,h} for mtd tracks
1079  *
1080  * Revision 1.60 2013/12/04 19:56:32 jdb
1081  * Added StMuMtdPidTraits.{cxx, h} added Mtd items to StMuMtdHit.h, StMuDst.{cxx,h}, StMuDstMaker.cxx, StMuTrack.{cxx,h}
1082  *
1083  * Revision 1.59 2012/11/26 23:14:32 fisyak
1084  * Replace GetEntries() by GetEntriesFast(), fix print outs
1085  *
1086  * Revision 1.58 2012/11/15 22:26:13 sangalin
1087  * Added the FGT. Fixed bugs in array offsets for the MTD.
1088  *
1089  * Revision 1.57 2012/09/28 22:38:05 tone421
1090  * Changed array stucture of MTD upon request of the TOF group. MTD arrays now on top level, rather than within __NARRAYS__
1091  *
1092  * Revision 1.56 2011/10/17 00:19:13 fisyak
1093  * Active handing of IdTruth
1094  *
1095  * Revision 1.55 2011/05/04 19:51:32 tone421
1096  * Added MTD infomation
1097  *
1098  * Revision 1.54 2011/04/08 01:25:50 fisyak
1099  * Add branches for MC track and vertex information, add IdTruth to tracks and vertices, reserve a possiblity to remove Strange MuDst
1100  *
1101  * Revision 1.53 2010/05/26 04:25:50 tone421
1102  * Added StTriggerData arrays in muevent and fixed an issue with PMD arrays being read....
1103  *
1104  * Revision 1.52 2010/03/10 15:03:06 tone421
1105  * Added more pointer protection in StMuDst::fixTrackIndicesG()
1106  *
1107  * Revision 1.51 2010/03/09 23:59:49 tone421
1108  * Added null point protection in StMuDst::fixTrackIndicesG(int mult)
1109  *
1110  * Revision 1.50 2010/03/08 19:06:51 tone421
1111  * Two things. Global tracks how are filled with an index to primary at birth. Added StMuDst::fixTrackIndicesG(), which is used for matching the primary track indices to global tracks. Previously, this was quite slow - see this post:
1112  *
1113  * http://www.star.bnl.gov/HyperNews-star/protected/get/starsoft/8092/1/1/1.html
1114  *
1115  * for more details.
1116  *
1117  * Revision 1.49 2010/02/01 23:15:27 fine
1118  * replace non-static method
1119  *
1120  * Revision 1.48 2010/01/25 03:57:39 tone421
1121  * Added FMS and Roman pot arrays
1122  *
1123  * Revision 1.47 2009/12/01 03:42:54 tone421
1124  * Fixed small bug in StMuDst::fixTrackIndices and StMuDst::fixTofTrackIndices(), added StMuTrack::primaryTrack() and ensured StMuTrack::vertexIndex() returns some sensible for globals.
1125  *
1126  * Revision 1.46 2009/03/05 04:39:25 tone421
1127  * Added safety check for btofcoll->setHeader(new StBTofHeader(*(btofHeader()))) on line 456
1128  *
1129  * Revision 1.45 2009/02/20 16:37:44 tone421
1130  * *** empty log message ***
1131  *
1132  * Revision 1.43 2008/06/26 15:48:04 tone421
1133  *
1134  * Get info from StEvent so vpd z vertex infomation is available in StMuEvent
1135  *
1136  * Revision 1.42 2007/09/18 02:29:57 mvl
1137  * Added basic printing functionality. For convenience and to assist data consistency checks
1138  *
1139  * Revision 1.41 2007/05/16 18:50:49 mvl
1140  * Cleanup of output. Replaced cout with LOG_INFO etc.
1141  *
1142  * Revision 1.40 2007/04/20 06:25:21 mvl
1143  * Removed Q-vectors (will implement utility class).
1144  * Added Vpd info.
1145  *
1146  * Revision 1.39 2006/02/07 03:26:08 mvl
1147  * Changed createStEvent (use by MuDst2StEventmaker) to only copy primary tracks
1148  * that belong to the first primary vertex. This prevents segvio for events with
1149  * multiple primary vertices.
1150  *
1151  * Revision 1.38 2005/12/13 03:12:13 mvl
1152  * Changes to StMuDst2StEventMaker (code in StMuDst) and StMuDstFilterMaker
1153  * to no longer rely on track keys for matching global and primary tracks.
1154  * This was needed because track keys are not guaranteed to be unique anymore.
1155  *
1156  * Revision 1.37 2005/08/19 19:46:05 mvl
1157  * Further updates for multiple vertices. The main changes are:
1158  * 1) StMudst::primaryTracks() now returns a list (TObjArray*) of tracks
1159  * belonging to the 'current' primary vertex. The index number of the
1160  * 'current' vertex can be set using StMuDst::setCurrentVertex().
1161  * This also affects StMuDst::primaryTracks(int i) and
1162  * StMuDst::numberOfprimaryTracks().
1163  * 2) refMult is now stored for all vertices, in StMuPrimaryVertex. The
1164  * obvious way to access these numbers is from the StMuprimaryVertex structures,
1165  * but for ebakcward compatibility a function is provided in StMuEvent as well
1166  * (this is the only function taht works for existing MuDst)
1167  *
1168  * As an aside, I've also changes the internals of StMuDst::createStEvent and
1169  * StMuDst::fixTrackIndices() to be able to deal with a larger range of index numbers for tracks as generated by Ittf.
1170  *
1171  * BIG FAT WARNING: StMudst2StEventMaker and StMuDstFilterMaker
1172  * do not fully support the multiple vertex functionality yet.
1173  *
1174  * Revision 1.36 2005/05/20 20:30:35 mvl
1175  * More fixed to StMuDst::fixTrackIndices(). The bug afafcets only few tracks
1176  * for events with many tracks, so most people will not be much affected by it.
1177  * After heavy filtering with StMuDstFilterMaker (many fewer tracks than tack-ids)
1178  * the bug became apparent.
1179  *
1180  * Revision 1.35 2005/05/18 20:56:57 mvl
1181  * Fixed inconsistency in fixTrackIndices (pointed out by Alex Suaide):
1182  * now using the TClonesArray that are passed to the function, instead of the
1183  * ones in StMuDst.
1184  *
1185  * Revision 1.34 2005/04/12 21:56:29 mvl
1186  * Changes by Xin Dong for year-5 TOF data format: extra TClonesArray and routines to fill it from StEvent (StTofRawData).
1187  *
1188  * Revision 1.33 2004/10/28 00:11:33 mvl
1189  * Added stuff to support ezTree mode of MuDstMaker.
1190  * This is a special mode for fast-online processing of fast-detector data.
1191  *
1192  * Revision 1.32 2004/10/22 23:44:07 mvl
1193  * Fixed StMuDst::fixTrackIndices()
1194  *
1195  * Revision 1.31 2004/10/21 02:56:35 mvl
1196  * Added pointer to StEmcColleciton for Emc clustering etc.
1197  * Also made some technical changes for backward compatibility mode with
1198  * StMuIOMaker (pointers to TClonesArray for StMuEmcCollection)
1199  *
1200  * Revision 1.30 2004/10/19 01:45:26 mvl
1201  * Changes to split Emc and Pmd collections. Minor change to track copying logic
1202  *
1203  * Revision 1.29 2004/08/14 00:48:41 mvl
1204  * Bug fix in createStTrack & mods for vertex flag in fitTraits
1205  *
1206  * Revision 1.28 2004/08/07 02:44:06 mvl
1207  * Added support for fitted and possible points in different detectors, for ITTF
1208  *
1209  * Revision 1.27 2004/04/20 18:41:20 perev
1210  * Change arrays to pointer to StMuDstMaker::arrays StMuDst.h
1211  *
1212  * Revision 1.26 2004/04/14 17:15:56 subhasis
1213  * Xin's TOF reinclusion
1214  *
1215  * Revision 1.25 2004/04/09 22:04:55 subhasis
1216  * after tof createevent fix by Xin
1217  *
1218  * Revision 1.24 2004/04/09 03:36:14 jeromel
1219  * Removed TOF support entirely for now as we need a working version ... Will
1220  * revisit later.
1221  *
1222  * Revision 1.23 2004/04/08 23:58:07 jeromel
1223  * Small protection on tofcoll
1224  *
1225  * Revision 1.22 2004/04/06 00:25:35 jeromel
1226  * Missing TofCollection addition
1227  *
1228  * Revision 1.21 2004/04/02 03:24:53 jeromel
1229  * Changes implements PMD and TOF. TOF is clearly incomplete.
1230  *
1231  * Revision 1.20 2003/10/31 19:12:56 laue
1232  * added filling of track id to createStTrack() function
1233  *
1234  * Revision 1.19 2003/10/28 18:57:56 perev
1235  * BadData protection added
1236  *
1237  * Revision 1.18 2003/10/23 04:08:29 perev
1238  * use SetBranchStatus fixed
1239  *
1240  * Revision 1.17 2003/10/20 22:55:39 laue
1241  * added filling of the topology map in the createStTrack function
1242  *
1243  * Revision 1.16 2003/10/14 14:35:53 laue
1244  * Alex Suaide EMC updates
1245  *
1246  * Revision 1.15 2003/08/04 14:38:10 laue
1247  * Alex Suaide's updated for the EMC. Now EEMC is included.
1248  *
1249  * Revision 1.14 2003/04/15 18:48:34 laue
1250  * Minor changes to be able to filter MuDst.root files and an example
1251  * how to do this. The StMuDstFilterMaker is just an example, it has to be
1252  * customized (spoilers, chrome weels, etc.) by the user.
1253  *
1254  * Revision 1.13 2003/03/19 18:58:04 laue
1255  * StMuChainMaker: updates for moved file catalog
1256  * StTriggerIdCollection added to the createStEvent function in StMuDst.cxx
1257  *
1258  * Revision 1.12 2003/02/18 20:38:30 laue
1259  * updates from Alex Suaide for filling StTrack from StMuTrack
1260  *
1261  * Revision 1.11 2003/01/09 18:59:45 laue
1262  * initial check in of new EMC classes and the changes required
1263  *
1264  * Revision 1.10 2002/09/21 00:26:09 laue
1265  * Bug fix in createStEvent() function. Now you can delete the StEvent
1266  *
1267  * Revision 1.9 2002/08/27 19:05:56 laue
1268  * Minor updates to make the muDst from simulation work
1269  *
1270  * Revision 1.8 2002/08/20 19:55:48 laue
1271  * Doxygen comments added
1272  *
1273  * Revision 1.7 2002/06/18 19:21:00 laue
1274  * cout statement taken out
1275  *
1276  * Revision 1.6 2002/05/20 18:57:18 laue
1277  * update for Christof
1278  *
1279  * Revision 1.5 2002/03/27 00:50:11 laue
1280  * bux fix from earlier check in
1281  *
1282  * Revision 1.4 2002/03/26 19:33:14 laue
1283  * minor updates
1284  *
1285  * Revision 1.3 2002/03/20 16:04:11 laue
1286  * minor changes, mostly added access functions
1287  *
1288  * Revision 1.2 2002/03/14 04:12:55 laue
1289  * bug fix: StMuL3EventSummary.cxx
1290  * update: StMuDst.h StMuDst.cxx
1291  *
1292  * Revision 1.1 2002/03/08 17:04:17 laue
1293  * initial revision
1294  *
1295  *
1296  **************************************************************************/
static TObjArray * mCurrPrimaryTracks
Temporary array to collect tracks from currect primary vertex.
Definition: StMuDst.h:233
static StMuFcsCollection * muFcsCollection()
returns pointer to current StMuFcsCollection
Definition: StMuDst.h:370
static void unset()
resets the pointers to the TClonesArrays to 0
Definition: StMuDst.cxx:100
static TClonesArray ** tofArrays
array of TClonesArrays for the stuff inherited from the TOF
Definition: StMuDst.h:195
static StMuFstCollection * mMuFstCollection
pointer to FstCollection (manages the FstArrays)
Definition: StMuDst.h:219
static StMuPrimaryVertex * primaryVertex()
return pointer to current primary vertex
Definition: StMuDst.h:299
short type() const
Returns the track type: 0=global, 1=primary, etc (see StEvent manual for type information) ...
Definition: StMuTrack.h:229
static StMuFmsCollection * muFmsCollection()
returns pointer to current StMuFmsCollection
Definition: StMuDst.h:368
static TObjArray * globalTracks()
returns pointer to the global tracks list
Definition: StMuDst.h:280
void fixTofTrackIndices()
Definition: StMuDst.cxx:376
static StMuPmdCollection * pmdCollection()
returns pointer to current StMuPmdCollection
Definition: StMuDst.h:376
static StMuFttCollection * muFttCollection()
returns pointer to current StMuFttCollection
Definition: StMuDst.h:372
static void set(StMuDstMaker *maker)
set the pointers to the TClonesArrays
Definition: StMuDst.cxx:134
static StMuFttCollection * mMuFttCollection
pointer to FttCollection (manages the FttArrays)
Definition: StMuDst.h:217
static StMuFmsCollection * mMuFmsCollection
pointer to FmsCollection (manages the FmsArrays)
Definition: StMuDst.h:213
int h() const
y-center of circle in xy-plane
Definition: StHelix.hh:174
short id() const
Returns the track id(or key), is unique for a track node, i.e. global and primary tracks have the sam...
Definition: StMuTrack.h:228
static TClonesArray ** fgtArrays
array of TClonesArrays for the stuff inherited from the Fgt
Definition: StMuDst.h:205
UShort_t nHitsDedx() const
Return number of hits used for dEdx.
Definition: StMuTrack.h:238
Double_t length() const
Returns length of track (cm) from primary vertex to last measured point.
Definition: StMuTrack.cxx:416
static StTofRawData * tofRawData(int i)
returns pointer to the i-th tofRawData
Definition: StMuDst.h:388
void setETofArray(const StETofCollection *etof_coll)
Definition: StMuDst.cxx:629
static TClonesArray ** pmdArrays
array of TClonesArrays for the stuff inherited from the Pmd
Definition: StMuDst.h:193
static StMuEmcCollection * mMuEmcCollection
pointer to EmcCollection (manages the EmcArrays)
Definition: StMuDst.h:209
Double_t chi2() const
Returns chi2 of fit.
Definition: StMuTrack.h:251
static StMuETofHit * etofHit(int i)
returns pointer to the i-th StMuETofHit
Definition: StMuDst.h:400
static TClonesArray * v0s()
returns pointer to the v0 list
Definition: StMuDst.h:331
const StMuETofPidTraits & etofPidTraits() const
dongx
Definition: StMuTrack.h:265
static TClonesArray * primaryVertices()
returns pointer to the primary vertex list
Definition: StMuDst.h:276
virtual void Print(Option_t *option="") const
Print basic event info.
Definition: StMuDst.cxx:961
static TClonesArray ** fmsArrays
array of TClonesArrays for the stuff inherited from the Fms
Definition: StMuDst.h:185
static void collectVertexTracks()
Helper function to collect tracks for the current prim vertex.
Definition: StMuDst.cxx:236
static void fixTrackIndicesG(int mult=1)
Definition: StMuDst.cxx:314
void fixTrackIndices()
checks and if necessary corrects the indecies of elements pointing to each other (e.g., a primary track&#39;s index to the corresponding global track)
Definition: StMuDst.cxx:258
static TClonesArray ** mtdArrays
array of TClonesArrays for the stuff inherited from the Mtd
Definition: StMuDst.h:203
void setIndex2Global(Int_t i)
Set index of associated global track.
Definition: StMuTrack.h:211
void fixETofTrackIndices()
Definition: StMuDst.cxx:452
static StTofData * tofData(int i)
returns pointer to the i-th tofData
Definition: StMuDst.h:385
static StEmcCollection * mEmcCollection
pointer to EmcCollecion (for Emc clusterfinding etc)
Definition: StMuDst.h:223
static TClonesArray ** eztArrays
array of TClonesArrays for the stuff inherited from the EZT (ezTree)
Definition: StMuDst.h:228
static TClonesArray ** fttArrays
array of TClonesArrays for the stuff inherited from the Ftt
Definition: StMuDst.h:189
static StMuPmdCollection * mMuPmdCollection
pointer to PmdCollection (manages the PmdArrays)
Definition: StMuDst.h:221
StPhysicalHelixD helix() const
Returns inner helix (first measured point)
Definition: StMuTrack.cxx:407
UShort_t nHitsFit() const
Return total number of hits used in fit.
Definition: StMuTrack.h:239
static StStrangeEvMuDst * strangeEvent()
returns pointer to current StStrangeEvMuDst (class holding the event wise information, e.g. event number, run number)
Definition: StMuDst.h:327
void fixMtdTrackIndices()
Definition: StMuDst.cxx:532
short flag() const
Returns flag, (see StEvent manual for type information)
Definition: StMuTrack.h:230
Short_t charge() const
Returns charge.
Definition: StMuTrack.h:255
static TClonesArray ** fcsArrays
array of TClonesArrays for the stuff inherited from the Fcs
Definition: StMuDst.h:187
Collection of trigger ids as stored in StEvent.
static StBTofRawHit * btofRawHit(int i)
returns pointer to the i-th btofRawHit - dongx
Definition: StMuDst.h:392
static TClonesArray * detectorStates()
returns pointer to the list of detector states
Definition: StMuDst.h:288
static StMuFstCollection * muFstCollection()
returns pointer to current StMuFstCollection
Definition: StMuDst.h:374
int associatedTrackId() const
id to the track which has been matched to this hit
Definition: StMuETofHit.h:205
static TObjArray * primaryTracks()
returns pointer to a list of tracks belonging to the selected primary vertex
Definition: StMuDst.h:278
const StThreeVector< double > & origin() const
-sign(q*B);
Definition: StHelix.hh:224
UShort_t nHitsPoss() const
Return number of possible hits on track.
Definition: StMuTrack.cxx:242
TClonesArray ** mBTofArrays
dongx
Definition: StMuDstMaker.h:383
static StMuEmcCollection * muEmcCollection()
returns pointer to current StMuEmcCollection
Definition: StMuDst.h:366
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
Definition: StMuDst.h:297
StMuDst()
constructor
Definition: StMuDst.cxx:92
static StTrackGeometry * trackGeometry(int q, StPhysicalHelixD *h)
helper function to create a StTrackGeometry
Definition: StMuDst.cxx:884
static StMuETofDigi * etofDigi(int i)
returns pointer to the i-th StMuEtofDigi
Definition: StMuDst.h:398
static StTrack * createStTrack(const StMuTrack *)
creates a StTrack from an StMuTrack and return pointer to it
Definition: StMuDst.cxx:898
StThreeVectorF dca(Int_t vtx_id=-1) const
Returns 3D distance of closest approach to primary vertex.
Definition: StMuTrack.cxx:359
static TClonesArray * xis()
returns pointer to the xi list
Definition: StMuDst.h:337
Double_t dEdx() const
Returns measured dE/dx value.
Definition: StMuTrack.h:248
static TClonesArray ** strangeArrays
array of TClonesArrays for the stuff inherited from the StStrangeMuDst
Definition: StMuDst.h:179
void addETofHit(const StMuETofHit *hit)
Definition: StMuDst.cxx:655
static TClonesArray ** emcArrays
array of TClonesArrays for the stuff inherited from the Emc
Definition: StMuDst.h:183
static StBTofHeader * btofHeader()
returns pointer to the btofHeader - dongx
Definition: StMuDst.h:394
static StMuFcsCollection * mMuFcsCollection
pointer to FcsCollection (manages the FcsArrays)
Definition: StMuDst.h:215
static TClonesArray ** epdArrays
array of TClonesArrays for Epd
Definition: StMuDst.h:201
void setMtdArray(StMtdCollection *mtd_coll)
Definition: StMuDst.cxx:608
static Int_t currentVertexIndex()
Get the index number of the current primary vertex.
Definition: StMuDst.h:241
static TClonesArray ** etofArrays
array of TClonesArrays for ETof
Definition: StMuDst.h:199
StEvent * createStEvent()
creates a StEvent from the StMuDst (this) and returns a pointer to it. (This function is not yet fini...
Definition: StMuDst.cxx:678
static TClonesArray ** fstArrays
array of TClonesArrays for the stuff inherited from the Fst
Definition: StMuDst.h:191
StPhysicalHelixD outerHelix() const
Returns outer helix (last measured point)
Definition: StMuTrack.cxx:412
static void setVertexIndex(Int_t vtx_id)
Set the index number of the current primary vertex (used by both primaryTracks() functions and for St...
Definition: StMuDst.cxx:249
static TClonesArray ** arrays
array of TClonesArrays
Definition: StMuDst.h:176
StTrackTopologyMap topologyMap() const
Returns topology map.
Definition: StMuTrack.h:254
static Int_t mCurrVertexId
Index number of current primary vertex.
Definition: StMuDst.h:231
static TClonesArray ** btofArrays
array of TClonesArrays for the stuff inherited from the BTOF // dongx
Definition: StMuDst.h:197
double phase() const
1/R in xy-plane
Definition: StHelix.hh:180
static StFmsCollection * mFmsCollection
pointer to FmsCollecion (for Fms clusterfinding etc)
Definition: StMuDst.h:225
virtual void Print(Option_t *option="") const
Print essential vertex info.
void setIndex2ETofHit(Int_t i)
dongx
Definition: StMuTrack.h:146