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