StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StHbtMuDstReader.cxx
1 /***************************************************************************
2  *
3  * $Id: StHbtMuDstReader.cxx,v 1.10 2005/07/18 16:33:20 kopytin Exp $
4  * Author: Frank Laue, BNL, laue@bnl.gov
5  *
6  **************************************************************************/
7 #include "StChain.h"
8 
9 #include "StEvent/StEventTypes.h"
10 
11 #include "StEventUtilities/StuRefMult.hh"
12 #include "StEventUtilities/StuProbabilityPidAlgorithm.h"
13 
14 #include "StarClassLibrary/StPhysicalHelixD.hh"
15 #include "StarClassLibrary/StTimer.hh"
16 
17 #include "StIOMaker/StIOMaker.h"
18 
20 #include "StStrangeMuDstMaker/StStrangeEvMuDst.hh"
21 #include "StStrangeMuDstMaker/StV0MuDst.hh"
22 #include "StStrangeMuDstMaker/StV0Mc.hh"
23 #include "StStrangeMuDstMaker/StXiMuDst.hh"
24 #include "StStrangeMuDstMaker/StXiMc.hh"
25 #include "StStrangeMuDstMaker/StKinkMuDst.hh"
26 #include "StStrangeMuDstMaker/StKinkMc.hh"
27 
28 #include "StMuDSTMaker/COMMON/StMuException.hh"
29 #include "StMuDSTMaker/COMMON/StMuEvent.h"
30 #include "StMuDSTMaker/COMMON/StMuTrack.h"
31 #include "StMuDSTMaker/COMMON/StMuDebug.h"
32 #include "StMuDSTMaker/COMMON/StMuCut.h"
33 #include "StMuDSTMaker/COMMON/StMuDst.h"
34 
35 #include "StHbtMuDstReader.h"
36 #include "Infrastructure/StHbtEvent.hh"
37 #include "StHbtMaker/Base/StHbtEventCut.h"
38 
39 #include "TFile.h"
40 #include "TTree.h"
41 #include "TClass.h"
42 #include "TChain.h"
43 #include "TStreamerInfo.h"
44 #include "TClonesArray.h"
45 
46 ClassImp(StHbtMuDstReader)
47 
48 #if !(ST_NO_NAMESPACES)
49  using namespace units;
50 #endif
51 
52 
53 //-----------------------------------------------------------------------
54 //-----------------------------------------------------------------------
55 //-----------------------------------------------------------------------
56 StHbtMuDstReader::StHbtMuDstReader(int mode, int nameMode, const char* dirName, const char* fileName, const char* filter, int maxFiles) :
57  mStEvent(0), mStStrangeMuDstMaker(0), mIOMaker(0),
58  mIoMode((ioMode)mode), mIoNameMode((ioNameMode)nameMode),
59  mDirName(dirName), mFileName(fileName), mFilter(filter), mMaxFiles(maxFiles),
60  mTrackType(primary), mReadTracks(1),
61  mReadV0s(1), mReadXis(1), mReadKinks(1), mFinish(0),
62  mSplit(99), mCompress(9), mBufferSize(65536*4), mHbtEvent(0)
63 {
64  mReaderStatus = 0;
65  mEventCounter=0;
66  mStMuDst = new StMuDst();
68  for ( int i=0; i<__NARRAYS__; i++) {
69  arrays[i] = 0;
70  mArrays[i]= clonesArray(arrays[i],StMuArrays::arrayTypes[i],StMuArrays::arraySizes[i],StMuArrays::arrayCounters[i]);
71  }
73  for ( int i=0; i<__NSTRANGEARRAYS__; i++) {
74  strangeArrays[i] = 0;
75  mStrangeArrays[i]= clonesArray(strangeArrays[i],StMuArrays::strangeArrayTypes[i],StMuArrays::strangeArraySizes[i],StMuArrays::strangeArrayCounters[i]);
76  }
77 
78  mStMuDst->set(arrays,strangeArrays);
79 
80  if (mIoMode==ioRead) openRead();
81  if (mIoMode==ioWrite) mProbabilityPidAlgorithm = new StuProbabilityPidAlgorithm();
82 
83 }
84 
85 //-----------------------------------------------------------------------
86 //-----------------------------------------------------------------------
87 //-----------------------------------------------------------------------
88 StHbtMuDstReader::~StHbtMuDstReader(){
89 }
90 
91 //-----------------------------------------------------------------------
92 //-----------------------------------------------------------------------
93 //-----------------------------------------------------------------------
94 void StHbtMuDstReader::clear(){
95  DEBUGMESSAGE1("");
96 
97  // if (mHbtEvent) { delete mHbtEvent; mHbtEvent=0;}
99  for ( int i=0; i<__NARRAYS__; i++) {
100  clear(mArrays[i],StMuArrays::arrayCounters[i]);
101  }
102  for ( int i=0; i<__NSTRANGEARRAYS__; i++) {
103  clear(mStrangeArrays[i],StMuArrays::strangeArrayCounters[i]);
104  }
105 
106 
107 }
108 //-----------------------------------------------------------------------
109 //-----------------------------------------------------------------------
110 //-----------------------------------------------------------------------
111 void StHbtMuDstReader::clear(TClonesArray* t, int& counter){
112  if (t) t->Clear(""); counter=0;
113 }
114 //-----------------------------------------------------------------------
115 //-----------------------------------------------------------------------
116 //-----------------------------------------------------------------------
117 TClonesArray* StHbtMuDstReader::clonesArray(TClonesArray* p, const char* type, int size, int& counter) {
118  DEBUGMESSAGE1("");
119  if (!p) {
120  DEBUGVALUE2(type);
121  p = new TClonesArray(type, size);
122  counter=0;
123  }
124  if (!p) throw StMuExceptionNullPointer("could not create TClonesArray",__PRETTYF__);
125  return p;
126 }
127 //-----------------------------------------------------------------------
128 //-----------------------------------------------------------------------
129 //-----------------------------------------------------------------------
130 int StHbtMuDstReader::Init(){
131  DEBUGMESSAGE1("");
132 // mIOMaker = (StIOMaker*)GetMaker("IOMaker");
133 // mStStrangeMuDstMaker = (StStrangeMuDstMaker*)GetMaker("StrangeMaker");
134  return 0;
135 }
136 
137 //-----------------------------------------------------------------------
138 //-----------------------------------------------------------------------
139 //-----------------------------------------------------------------------
140 void StHbtMuDstReader::Clear(){
141  DEBUGMESSAGE1("");
142  clear();
143 }
144 //-----------------------------------------------------------------------
145 //-----------------------------------------------------------------------
146 //-----------------------------------------------------------------------
147 StHbtEvent* StHbtMuDstReader::ReturnHbtEvent(){
148  DEBUGMESSAGE1("");
149  StTimer timer;
150  timer.start();
151  clear();
152  try {
153  if (mIoMode == ioRead) read();
154  }
155  catch(StMuExceptionEOF e) {
156  e.print();
157  mReaderStatus = 2;
158  return 0;
159  }
160  catch(StMuException e) {
161  e.print();
162  mReaderStatus = 1;
163  return 0;
164  }
165  DEBUGVALUE1(timer.elapsedTime());
166  if (mStMuDst) {
167  mStMuDst->fixTrackIndices();
168  mHbtEvent = new StHbtEvent(mStMuDst, mTrackType);
169  }
170  if (mEventCut){
171  if (!(mEventCut->Pass(mHbtEvent))){
172  delete mHbtEvent;
173  mHbtEvent = 0;
174  return 0;
175  }
176  }
177  return mHbtEvent;
178 }
179 //-----------------------------------------------------------------------
180 //-----------------------------------------------------------------------
181 //-----------------------------------------------------------------------
182 void StHbtMuDstReader::fill(){
183  DEBUGMESSAGE1("");
184  // mStEvent = (StEvent*) GetInputDS("StEvent");
185  if (!mStEvent) {
186  DEBUGMESSAGE1("no StEvent");
187  return;
188  }
189 
192  if (mProbabilityPidAlgorithm) delete mProbabilityPidAlgorithm;
193  mProbabilityPidAlgorithm = new StuProbabilityPidAlgorithm(*mStEvent);
194  StMuTrack::setProbabilityPidAlgorithm(mProbabilityPidAlgorithm);
195  StMuTrack::setProbabilityPidCentrality(uncorrectedNumberOfNegativePrimaries(*mStEvent));
196 
197 
198  try {
199  fillTrees(mStEvent);
200  }
201  catch(StMuException e) {
202  e.print();
203  throw e;
204  }
205 }
206 //-----------------------------------------------------------------------
207 //-----------------------------------------------------------------------
208 //-----------------------------------------------------------------------
209 void StHbtMuDstReader::write(){
210  DEBUGMESSAGE1("");
211 
212 
213  try {
214  fill();
215  }
216  catch (StMuException e) {
217  return;
218  }
219 
220  // filename
221  string ioMakerFileName;
222  if (mIOMaker) { // if the ioMaker is specified, we take the output filename from the ioMaker
223  ioMakerFileName = string(mIOMaker->GetFile());
224  }
225  else { // if not then construct the filename
226  ioMakerFileName = mDirName+mFileName;
227  }
228  DEBUGVALUE1(ioMakerFileName.c_str());
229 
230 
231  string theFileName = buildFileName(mDirName,basename(ioMakerFileName),".MuDst.root");
232  if (theFileName != mCurrentFileName) {
233  closeWrite();
234  openWrite(theFileName);
235  mCurrentFileName = theFileName;
236  }
237 
238  DEBUGMESSAGE2("now fill tree");
239  mTTree->Fill();
240  DEBUGMESSAGE2("tree filled");
241 
242  return;
243 }
244 //-----------------------------------------------------------------------
245 //-----------------------------------------------------------------------
246 //-----------------------------------------------------------------------
247 void StHbtMuDstReader::Finish() {
248  if (mFinish) {
249  for ( int i=0; i<10; i++) {
250  cout << "why are you calling the Finish() again ???????" << endl;
251  cout << "are you the stupid chain destructor ???????????" << endl;
252  }
253  }
254  else {
255  if (mIoMode== ioWrite ) closeWrite();
256  if (mIoMode== ioRead ) closeRead();
257  mFinish = true;
258  }
259  return;
260 }
261 //-----------------------------------------------------------------------
262 //-----------------------------------------------------------------------
263 //-----------------------------------------------------------------------
264 void StHbtMuDstReader::openRead() {
265  DEBUGVALUE1(mDirName.c_str());
266  DEBUGVALUE1(mFileName.c_str());
267  DEBUGVALUE1(mFilter.c_str());
268 
269  makeChain(mDirName.c_str(), mFilter.c_str(),mMaxFiles);
270 
271  // muDst stuff
272  for ( int i=0; i<__NARRAYS__; i++) {
273  mChain->SetBranchAddress(StMuArrays::arrayNames[i],&mArrays[i]);
274  }
275 
276  // strange stuff
277  for ( int i=0; i<__NSTRANGEARRAYS__; i++) {
278  mChain->SetBranchAddress(StMuArrays::strangeArrayNames[i],&mStrangeArrays[i]);
279  }
280 
281  (void*)mChain->GetBranch("");
282  mTTree = mChain->GetTree();
283 
284  mStMuDst->set(mArrays,mStrangeArrays);
285 }
286 //-----------------------------------------------------------------------
287 //-----------------------------------------------------------------------
288 //-----------------------------------------------------------------------
289 void StHbtMuDstReader::read(){
290  DEBUGMESSAGE1("");
291  if ( !(mEventCounter<mChain->GetEntries()) ) throw StMuExceptionEOF("end of input",__PRETTYF__);
292  mChain->GetEntry(mEventCounter);
293  DEBUGVALUE2(mChain->GetCurrentFile()->GetName());
294  mEventCounter++;
295 
296  return;
297 }
298 //-----------------------------------------------------------------------
299 //-----------------------------------------------------------------------
300 //-----------------------------------------------------------------------
301 void StHbtMuDstReader::closeRead(){
302 }
303 //-----------------------------------------------------------------------
304 //-----------------------------------------------------------------------
305 //-----------------------------------------------------------------------
306 void StHbtMuDstReader::openWrite(string fileName) {
307  DEBUGVALUE1(fileName.c_str());
308  // creat a Picoevent and and output file
309  DEBUGMESSAGE2("now create file");
310  mCurrentFile = new TFile(fileName.c_str(),"RECREATE","StMuDst");
311 
312  if (!mCurrentFile) throw StMuExceptionNullPointer("no file openend",__PRETTYF__);
313 
314  mCurrentFile->SetCompressionLevel(mCompress);
315 
316  // Create a ROOT Tree and one superbranch
317  DEBUGMESSAGE2("now create trees and branches");
318 
319  TBranch* branch;
320  int bufsize = mBufferSize;
321  if (mSplit) bufsize /= 4;
322 
323  // muDst stuff
324  mTTree = new TTree("MuDst", "StMuDst",mSplit);
325  if (!mTTree) throw StMuExceptionNullPointer("can not create tree",__PRETTYF__);
326  mTTree->SetAutoSave(1000000); // autosave when 1 Mbyte written
327  DEBUGMESSAGE("arrays");
328  for ( int i=0; i<__NARRAYS__; i++) {
329  DEBUGVALUE2(i);
330  branch = mTTree->Branch(StMuArrays::arrayNames[i],&mArrays[i], bufsize, mSplit);
331  }
332 
333  // strange stuff
334  DEBUGMESSAGE("strange arrays");
335  for ( int i=0; i<__NSTRANGEARRAYS__; i++) {
336  DEBUGVALUE2(i);
337  branch = mTTree->Branch(StMuArrays::strangeArrayNames[i],&mStrangeArrays[i], bufsize, mSplit);
338  }
339 
340  mCurrentFileName = fileName;
341 }
342 //-----------------------------------------------------------------------
343 //-----------------------------------------------------------------------
344 //-----------------------------------------------------------------------
345 void StHbtMuDstReader::closeWrite(){
346  if (mTTree) mTTree->AutoSave();
347  if (mCurrentFile) mCurrentFile->Close();
348  mTTree = 0;
349  mCurrentFile = 0;
350 }
351 //-----------------------------------------------------------------------
352 //-----------------------------------------------------------------------
353 //-----------------------------------------------------------------------
354 void StHbtMuDstReader::fillTrees(StEvent* ev, StMuCut* cut){
355  DEBUGMESSAGE1("");
356 
357  try {
358  fillEvent(ev);
359  fillL3AlgorithmInfo(ev);
360  fillDetectorStates(ev);
361  }
362  catch(StMuException e) {
363  e.print();
364  }
365 
366  try {
367  fillTracks(ev,mTrackFilter);
368  }
369  catch(StMuException e) {
370  e.print();
371  }
372 
373  try {
374  fillL3Tracks(ev, mL3TrackFilter);
375  }
376  catch(StMuException e) {
377  e.print();
378  }
379 
380  try {
381  fillStrange(mStStrangeMuDstMaker);
382  }
383  catch(StMuException e) {
384  e.print();
385  }
386 }
387 
388 
389 
390 //-----------------------------------------------------------------------
391 //-----------------------------------------------------------------------
392 //-----------------------------------------------------------------------
393 void StHbtMuDstReader::fillEvent(StEvent* ev, StMuCut* cut) {
394  DEBUGMESSAGE1("");
395  StMuEvent typeOfEvent;
396  if (!ev) throw StMuExceptionNullPointer("no StEvent",__PRETTYF__);
397  StTimer timer;
398  timer.start();
399  if (!cut || cut->pass(ev)) {
400  DEBUGMESSAGE3("");
401  addType(mArrays[muEvent],ev,typeOfEvent);
402  }
403  timer.stop();
404  DEBUGVALUE2(timer.elapsedTime());
405 }
406 //-----------------------------------------------------------------------
407 //-----------------------------------------------------------------------
408 //-----------------------------------------------------------------------
409 void StHbtMuDstReader::fillL3AlgorithmInfo(StEvent* ev) {
410  DEBUGMESSAGE1("");
411  if ( !ev->l3Trigger() ) return;
412  if ( !ev->l3Trigger()->l3EventSummary()) return;
413 
414  StTimer timer;
415  timer.start();
416  StL3EventSummary* l3 = ev->l3Trigger()->l3EventSummary();
417  int n = l3->numberOfAlgorithms();
418  for (int i=0; i<n; i++) {
419  if (l3->algorithms()[i]->accept())
420  addType( mArrays[muAccept], *l3->algorithms()[i] );
421  else
422  addType( mArrays[muReject], *l3->algorithms()[i] );
423  }
424  timer.stop();
425  DEBUGVALUE2(timer.elapsedTime());
426 }
427 //-----------------------------------------------------------------------
428 //-----------------------------------------------------------------------
429 //-----------------------------------------------------------------------
430 void StHbtMuDstReader::fillTracks(StEvent* ev, StMuCut* cut) {
431  DEBUGMESSAGE1("");
432  StTimer timer;
433  timer.start();
434 
435  StSPtrVecTrackNode& nodes= ev->trackNodes();
436  DEBUGVALUE2(nodes.size());
437  for (StSPtrVecTrackNodeConstIterator iter=nodes.begin(); iter!=nodes.end(); iter++) {
438  addTrackNode(ev, *iter, cut, mArrays[muGlobal], mArrays[muPrimary], mArrays[muOther], false);
439  }
440  timer.stop();
441  DEBUGVALUE2(timer.elapsedTime());
442 }
443 //-----------------------------------------------------------------------
444 //-----------------------------------------------------------------------
445 //-----------------------------------------------------------------------
446 void StHbtMuDstReader::fillL3Tracks(StEvent* ev, StMuCut* cut) {
447  DEBUGMESSAGE1("");
448  if (!ev->l3Trigger()) return;
449 
450  StTimer timer;
451  timer.start();
452  StSPtrVecTrackNode& nodes= ev->l3Trigger()->trackNodes();
453  DEBUGVALUE2(nodes.size());
454  for (StSPtrVecTrackNodeConstIterator iter=nodes.begin(); iter!=nodes.end(); iter++) {
455  addTrackNode(ev, *iter, cut, mArrays[muL3], 0, 0, true );
456  }
457  timer.stop();
458  DEBUGVALUE2(timer.elapsedTime());
459 }
460 //-----------------------------------------------------------------------
461 //-----------------------------------------------------------------------
462 //-----------------------------------------------------------------------
463 void StHbtMuDstReader::fillDetectorStates(StEvent* ev) {
464  DEBUGMESSAGE1("");
465  StTimer timer;
466  timer.start();
467  for (int i=0; i<StMuArrays::arraySizes[muState]; i++) {
468  StDetectorState* state = ev->detectorState((StDetectorId) i);
469  if (state)
470  addType( mArrays[muState], ev->detectorState((StDetectorId)i) );
471  }
472  timer.stop();
473  DEBUGVALUE2(timer.elapsedTime());
474 }
475 //-----------------------------------------------------------------------
476 //-----------------------------------------------------------------------
477 //-----------------------------------------------------------------------
478 void StHbtMuDstReader::addTrackNode(const StEvent* ev, const StTrackNode* node, StMuCut* cut,
479  TClonesArray* gTCA, TClonesArray* pTCA, TClonesArray* oTCA, bool l3) {
480  DEBUGMESSAGE3("");
481  const StTrack* tr=0;
482 
484  int index2Global =-1;
485  if (gTCA) {
486  tr= node->track(global);
487  if (tr ) index2Global = addTrack(gTCA, ev, tr, cut, -1, l3);
488  }
490  int index;
491  if (pTCA) {
492  tr = node->track(primary);
493  if (tr) index = addTrack(pTCA, ev, tr, cut, index2Global, l3);
494  }
496  if (oTCA) {
497  size_t nEntries = node->entries();
498  for (size_t j=0; j<nEntries; j++) {
499  tr = node->track(j);
500  if (tr && (tr->type()!=global) && (tr->type()!=primary) ) {
501  index = addTrack(oTCA, ev, tr, cut, index2Global, l3);
502  }
503  }
504  }
505 }
506 //---------------------------------------------------------------------
507 //---------------------------------------------------------------------
508 //---------------------------------------------------------------------
509 int StHbtMuDstReader::addTrack(TClonesArray* tca, const StEvent* event, const StTrack* track, StMuCut* cut, int index2Global, bool l3) {
510  DEBUGMESSAGE3("");
511  StRichSpectra typeOfStRichSpectra;
512  int index = -1;
513  int index2RichSpectra=-1;
515  int counter = tca->GetEntries();
516  try{
517  if (cut && !cut->pass(track)) throw StMuExceptionBadValue("failed track cut",__PRETTYF__);
518  // add StRichSpectra if StRichPidTraits are found
519  // we have to do this more elegant
520  StRichSpectra* rich = richSpectra(track);
521  if (rich) {
522  index2RichSpectra = addType( mArrays[muRich], *rich );
523  }
524  new((*tca)[counter]) StMuTrack(event, track, 0, index2Global, index2RichSpectra, l3);
525  index = counter;
526  }
527  catch (StMuException e) {
528  IFDEBUG3(e.print());
529  }
530  return index;
531 }
532 //-----------------------------------------------------------------------
533 //-----------------------------------------------------------------------
534 //-----------------------------------------------------------------------
535 StRichSpectra* StHbtMuDstReader::richSpectra(const StTrack* track) {
536  DEBUGMESSAGE3("");
537  const StPtrVecTrackPidTraits& traits = track->pidTraits(kRichId);
538  for (StPtrVecTrackPidTraitsConstIterator traitIter=traits.begin();traitIter!=traits.end();++traitIter) {
539  StRichPidTraits* pid = dynamic_cast<StRichPidTraits*>(*traitIter);
540  if (pid) return pid->getRichSpectra();
541  }
542  return 0;
543 }
544 //-----------------------------------------------------------------------
545 //-----------------------------------------------------------------------
546 //-----------------------------------------------------------------------
547 void StHbtMuDstReader::fillStrange(StStrangeMuDstMaker* maker) {
548  DEBUGMESSAGE2("");
550  if (!maker) throw StMuExceptionNullPointer("no StrangeMuDstMaker",__PRETTYF__);
551 
552  StStrangeEvMuDst ev;
553  StV0MuDst v0;
554  StStrangeAssoc assoc;
555  StXiMuDst xi;
556  StKinkMuDst kink;
557  StV0Mc v0Mc;
558  StXiMc xiMc;
559  StKinkMc kinkMc;
560 
561  addType(maker->GetEvClonesArray(), mStrangeArrays[0],ev);
562  addType(maker->GetEvMcArray(), mStrangeArrays[1],ev);
563 
564  addType(maker->GetV0ClonesArray(), mStrangeArrays[2],v0);
565  addType(maker->GetV0McArray(), mStrangeArrays[3],v0Mc);
566  addType(maker->GetV0AssocArray(), mStrangeArrays[4],assoc);
567 
568  addType(maker->GetXiClonesArray(), mStrangeArrays[5],xi);
569  addType(maker->GetXiMcArray(), mStrangeArrays[6],xiMc);
570  addType(maker->GetXiAssocArray(), mStrangeArrays[7],assoc);
571 
572  addType(maker->GetKinkClonesArray(),mStrangeArrays[8],kink);
573  addType(maker->GetKinkMcArray(), mStrangeArrays[9],kinkMc);
574  addType(maker->GetKinkAssocArray(), mStrangeArrays[10],assoc);
575 
576 }
577 //-----------------------------------------------------------------------
578 //-----------------------------------------------------------------------
579 //-----------------------------------------------------------------------
580 template <class T>
581 void StHbtMuDstReader::addType(TClonesArray* tcaFrom, TClonesArray* tcaTo , T t) {
582  if (tcaFrom && tcaTo) {
583  int n = tcaFrom->GetEntries();
584  int counter = tcaTo->GetEntries();
585  for (int i=0; i<n;i++) {
586  new((*tcaTo)[counter++]) T( (T&)*tcaFrom->UncheckedAt(i) );
587  }
588  }
589 }
590 //-----------------------------------------------------------------------
591 //-----------------------------------------------------------------------
592 //-----------------------------------------------------------------------
593 template <class T>
594 int StHbtMuDstReader::addType(TClonesArray* tcaTo , T t) {
595  int counter =-1;
596  if (tcaTo) {
597  counter = tcaTo->GetEntries();
598  new((*tcaTo)[counter]) T( t );
599  }
600  return counter;
601 }
602 //-----------------------------------------------------------------------
603 //-----------------------------------------------------------------------
604 //-----------------------------------------------------------------------
605 template <class T, class U>
606 int StHbtMuDstReader::addType(TClonesArray* tcaTo , U u, T t) {
607  int counter =-1;
608  if (tcaTo) {
609  counter = tcaTo->GetEntries();
610  DEBUGMESSAGE("");
611  new((*tcaTo)[counter]) T(u);
612  }
613  return counter;
614 }
615 //-----------------------------------------------------------------------
616 //-----------------------------------------------------------------------
617 //-----------------------------------------------------------------------
618 string StHbtMuDstReader::buildFileName(string dir, string fileName, string extention){
619  DEBUGMESSAGE1("");
620  fileName = dir + "/" + fileName + extention;
621  return fileName;
622 }
623 //-----------------------------------------------------------------------
624 //-----------------------------------------------------------------------
625 //-----------------------------------------------------------------------
626 string StHbtMuDstReader::basename(string s){
627  string name(s);
628  while ( name.find("/") != string::npos ) {
629  string::size_type pos = name.find("/");
630  name.erase(0, pos+1 );
631  }
632  string::size_type pos = name.find(".event.root");
633  if (pos != string::npos) name.erase(pos,pos+11);
634  return name;
635 }
636 //-----------------------------------------------------------------------
637 //-----------------------------------------------------------------------
638 //-----------------------------------------------------------------------
639 void StHbtMuDstReader::makeChain(const char* dir, const char* filter, int maxFiles) {
640  DEBUGMESSAGE1("");
641  mChain = new TChain("MuDst");
642  // TChain* mChain2 = new TChain("StrangeMuDst");
643  // read directory
644  // now find the files that end in the specified extention
645  int fileCount(0);
646  if(strncmp(dir+strlen(dir)-4,".lis",4)==0){
647  ifstream tF(dir);
648  char tFileName[500];
649  int tNFile =0;
650  tF >> tFileName;
651  while ((!tF.eof()) && (tNFile<=maxFiles)){
652  cout << "Add file " << tFileName << endl;
653  mChain->Add(tFileName);
654  tNFile++;
655  tF >> tFileName;
656  }
657  fileCount = tNFile;
658  }
659  else{
660  const char* fileName(0);
661  void *pDir = gSystem->OpenDirectory(dir);
662  while((fileName = gSystem->GetDirEntry(pDir))){
663  if(strcmp(fileName,".")==0 || strcmp(fileName,"..")==0) continue;
664  if(strcmp(fileName,".event.root")==0 || strcmp(fileName,"..")==0) continue;
665  // if( !strcmp(fileName,".MuDst.root") ) continue;
666  if(strstr(fileName,filter) && strstr(fileName,".MuDst.root") ){ // found a match
667  char* fullFile = gSystem->ConcatFileName(dir,fileName);
668  // add it to the chain
669  cout << fileCount << " " << fullFile << endl;
670  mChain->Add(fullFile);
671  // mChain2->Add(mChain2);
672  delete fullFile;
673  if(++fileCount >= maxFiles) break;
674  }
675  }
676  }
677  DEBUGVALUE2(fileCount);
678 }
679 
680 void StHbtMuDstReader::setProbabilityPidFile(const char* file) {
681  if (mProbabilityPidAlgorithm)
682  mProbabilityPidAlgorithm->readParametersFromFile(file);
683 }
684 /***************************************************************************
685  *
686  * $Log: StHbtMuDstReader.cxx,v $
687  * Revision 1.10 2005/07/18 16:33:20 kopytin
688  * Brought addTrack in corresponce with MvL's new StMuTrack constructor list of arguments
689  *
690  * Revision 1.9 2005/07/01 00:23:15 chajecki
691  * fix of potential memory leak in ReturnHbtEvent method
692  * added 'delete mHbtEvent' if this method returns 0
693  * (can happend if an even didn't pass an event cut)
694  *
695  * Revision 1.8 2004/10/12 13:52:46 kisiel
696  * Properly hadle mReaderStatus to make frontLoadedEventCut work
697  *
698  * Revision 1.7 2004/02/24 19:45:34 magestro
699  * reverted to 1.5 code
700  *
701  * Revision 1.5 2004/02/17 16:46:38 jeromel
702  * PF to PRETTYF
703  *
704  * Revision 1.4 2002/12/13 11:27:58 kisiel
705  * List files support for StHbtMuDstReader
706  *
707  * Revision 1.3 2002/05/24 16:08:03 rcwells
708  * Added event cut to StHbtMuDstReader
709  *
710  * Revision 1.2 2002/03/22 14:17:49 laue
711  * minor changes for RH 7.2
712  *
713  * Revision 1.1 2002/03/20 19:32:24 laue
714  * new reader for common MuDsts
715  *
716  *
717  **************************************************************************/
718 
719 
720 
721 
722 
723 
724 
725 
726 
727 
728 
729 
730 
731 
732 
733 
734 
735 
static void set(StMuDstMaker *maker)
set the pointers to the TClonesArrays
Definition: StMuDst.cxx:146
static const char * arrayTypes[__NALLARRAYS__]
&lt; names of the classes, the TClonesArrays are arrays of this type
Definition: StMuArrays.h:120
bool pass(const StEvent *)
called by user code, returns true if argument passes cuts, else false
Definition: StMuCut.h:68
Definition: StV0Mc.hh:17
static int arrayCounters[__NALLARRAYS__]
&lt; number of entries in current event, currently not used
Definition: StMuArrays.h:164
static void setProbabilityPidCentrality(Double_t cent)
Sets the centrality for calculating Aihong&#39;s pid.
Definition: StMuTrack.h:268
Definition: StXiMc.hh:17
static void fixTrackIndices(TClonesArray *primary, TClonesArray *global)
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:291
static void setProbabilityPidAlgorithm(StuProbabilityPidAlgorithm *)
Sets the StuProbabilityPidAlgorithm. Important in order to calculate Aihong&#39;s pids.
Definition: StMuTrack.h:267
StHbtMuDstReader(int mode, int nameMode, const char *dirName="./", const char *fileName="test.event.root", const char *filter=".", int maxfiles=10)
static int arraySizes[__NALLARRAYS__]
&lt; maximum sizes of the TClonesArrays
Definition: StMuArrays.h:142