StStandardHbtEventReader.cxx 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. /***************************************************************************
  2. *
  3. * $Id: StStandardHbtEventReader.cxx,v 1.39 2003/05/16 21:30:18 magestro Exp $
  4. *
  5. * Author: Mike Lisa, Ohio State, lisa@mps.ohio-state.edu
  6. ***************************************************************************
  7. *
  8. * Description: part of STAR HBT Framework: StHbtMaker package
  9. * This is the HbtEventReader class to be used when running
  10. * root4star with StEventReaderMaker.
  11. * It inherits from StHbtReaderMaker
  12. *
  13. * Since this StHbtEventReader class gets its input from StEvent in root4star,
  14. * it needs to know what chain has the StEventReaderMaker on it. So you have
  15. * to initialize (thru SetTheEventMaker()).
  16. * Other StHbtEventReader classes (that might read ASCII files for example)
  17. * would need other information, like the filename I guess, and so would
  18. * have other private data members that they access.
  19. *
  20. ***************************************************************************
  21. *
  22. * $Log: StStandardHbtEventReader.cxx,v $
  23. * Revision 1.39 2003/05/16 21:30:18 magestro
  24. * Removed obsolete include file
  25. *
  26. * Revision 1.38 2003/05/07 20:05:26 magestro
  27. * Removed StFlowTagMaker.h include
  28. *
  29. * Revision 1.37 2003/01/31 20:22:57 magestro
  30. * Small changes to eliminate compiler warnings
  31. *
  32. * Revision 1.36 2001/12/05 14:42:18 laue
  33. * updated for trigger(action)word and l3TriggerAlgorithm
  34. *
  35. * Revision 1.33 2001/06/21 19:18:42 laue
  36. * Modified Files: (to match the changed base classes)
  37. * StHbtAsciiReader.cxx StHbtAsciiReader.h
  38. * StHbtAssociationReader.cxx StHbtAssociationReader.h
  39. * StHbtBinaryReader.cxx StHbtBinaryReader.h
  40. * StHbtGstarTxtReader.cxx StHbtGstarTxtReader.h
  41. * StHbtStrangeMuDstEventReader.cxx
  42. * StHbtStrangeMuDstEventReader.h StStandardHbtEventReader.cxx
  43. * Added Files: new reader
  44. * StHbtTTreeReader.cxx StHbtTTreeReader.h
  45. *
  46. * Revision 1.32 2001/06/04 19:09:54 rcwells
  47. * Adding B-field, run number, and improved reaction plane functionality
  48. *
  49. * Revision 1.31 2001/05/25 23:24:01 lisa
  50. * Added in StHbtKink stuff
  51. *
  52. * Revision 1.30 2001/05/15 15:30:18 rcwells
  53. * Added magnetic field to StHbtEvent
  54. *
  55. * Revision 1.29 2001/04/25 18:08:16 perev
  56. * HPcorrs
  57. *
  58. * Revision 1.28 2001/02/08 22:38:26 laue
  59. * Reader can now switch between different track types: primary is default
  60. *
  61. * Revision 1.26 2000/10/17 17:25:23 laue
  62. * Added the dE/dx information for v0s
  63. *
  64. * Revision 1.25 2000/08/31 22:32:37 laue
  65. * Readers updated for new StHbtEvent version 3.
  66. *
  67. * Revision 1.24 2000/07/16 21:14:45 laue
  68. * StStandardHbtEventReader modified to read primary tracks only
  69. *
  70. * Some unnecessary includes removed.
  71. * Changes from StV0MiniDst to StStrangeMuDst
  72. *
  73. * Revision 1.22 2000/06/08 16:12:11 laue
  74. * StStandardHbtEventReader.cxx: Topology map for V0 fixed
  75. * StHbtMcEventReader.cxx: V0 updated
  76. *
  77. * Revision 1.21 2000/05/25 21:04:30 laue
  78. * StStandarsHbtEventReader updated for the new StStrangMuDstMaker
  79. *
  80. * Revision 1.19 2000/04/03 16:22:07 laue
  81. * some include files changed
  82. *
  83. * Revision 1.18 2000/02/26 19:06:12 laue
  84. * Some unnecessary includes removed.
  85. * StThreeVectorD replace by StHbtThreeVector.
  86. * StHbtBinaryReader now can derive output filename from StIOMaker
  87. *
  88. * Revision 1.17 2000/02/18 22:01:56 laue
  89. * Implementation of a collections of StHbtEventWriters.
  90. * We now can write multiple microDsts at a time.
  91. *
  92. * All readers can have front-loaded cuts now. For that reason some
  93. * functionality was moved from the specific readers to the base class
  94. *
  95. * Revision 1.16 2000/02/01 00:35:29 laue
  96. * namespaces and other little things (see Thomas CC5 migration page) changed
  97. * to run on the new Solaris Compiler CC5
  98. *
  99. * Revision 1.15 2000/01/25 17:35:27 laue
  100. * I. In order to run the stand alone version of the StHbtMaker the following
  101. * changes have been done:
  102. * a) all ClassDefs and ClassImps have been put into #ifdef __ROOT__ statements
  103. * b) unnecessary includes of StMaker.h have been removed
  104. * c) the subdirectory StHbtMaker/doc/Make has been created including everything
  105. * needed for the stand alone version
  106. *
  107. * II. To reduce the amount of compiler warning
  108. * a) some variables have been type casted
  109. * b) some destructors have been declared as virtual
  110. *
  111. * Revision 1.14 1999/12/03 22:24:37 lisa
  112. * (1) make Cuts and CorrFctns point back to parent Analysis (as well as other way). (2) Accommodate new PidTraits mechanism
  113. *
  114. * Revision 1.13 1999/11/24 21:56:05 laue
  115. * a typo fixed ; ClassDef() was splitted by an accidental carriage-return
  116. * ----------------------------------------------------------------------
  117. *
  118. * Revision 1.12 1999/09/28 15:06:06 didenko
  119. * Cleanup dependencies on non existing h-files
  120. *
  121. * Revision 1.11 1999/09/24 01:23:14 fisyak
  122. * Reduced Include Path
  123. *
  124. * Revision 1.10 1999/09/17 22:38:03 lisa
  125. * first full integration of V0s into StHbt framework
  126. *
  127. * Revision 1.9 1999/09/16 18:48:01 lisa
  128. * replace placeholder HbtV0Track stuff with Helens StHbtV0 classes
  129. *
  130. * Revision 1.8 1999/09/08 04:15:53 lisa
  131. * persistent microDST implementation tweaked to please fickle solaris details
  132. *
  133. * Revision 1.7 1999/09/03 22:39:17 lisa
  134. * Readers now MUST have Report() methods and MAY have WriteHbtEvent() methods
  135. *
  136. * Revision 1.6 1999/07/27 20:21:10 lisa
  137. * Franks fixes of StTrack and subsequent changes to particleCut and EventReader
  138. *
  139. * Revision 1.5 1999/07/24 16:24:25 lisa
  140. * adapt StHbtMaker to dev version of library - solaris still gives problems with strings
  141. *
  142. * Revision 1.4 1999/07/19 14:24:07 hardtke
  143. * modifications to implement uDST
  144. *
  145. * Revision 1.3 1999/07/06 22:33:24 lisa
  146. * Adjusted all to work in pro and new - dev itself is broken
  147. *
  148. * Revision 1.2 1999/06/29 17:50:28 fisyak
  149. * formal changes to account new StEvent, does not complie yet
  150. *
  151. * Revision 1.1.1.1 1999/06/29 16:02:57 lisa
  152. * Installation of StHbtMaker
  153. *
  154. **************************************************************************/
  155. #include "StHbtMaker/Reader/StStandardHbtEventReader.h"
  156. #include "StChain.h"
  157. #include "StEvent.h"
  158. #include "StEventTypes.h"
  159. #include "StEventUtilities/StuRefMult.hh"
  160. #include "StEventSummary.h"
  161. #include "StGlobalTrack.h"
  162. #include "StTrackNode.h"
  163. #include "StContainers.h"
  164. #include "StPrimaryVertex.h"
  165. #include "StVertex.h"
  166. #include "StMeasuredPoint.h"
  167. #include "StDedxPidTraits.h"
  168. #include "StTrackPidTraits.h"
  169. #include "StTrackGeometry.h"
  170. #include "StTrackDetectorInfo.h"
  171. #include "StParticleTypes.hh"
  172. #include "StTpcDedxPidAlgorithm.h"
  173. #include "StHit.h"
  174. #include "StEventInfo.h"
  175. //#include "StuProbabilityPidAlgorithm.h" // new
  176. #include <math.h>
  177. #include "SystemOfUnits.h" // has "tesla" in it
  178. #include "StHbtMaker/Infrastructure/StHbtTrackCollection.hh"
  179. #include "StHbtMaker/Infrastructure/StHbtV0Collection.hh"
  180. #include "StHbtMaker/Infrastructure/StHbtXiCollection.hh"
  181. #include "StHbtMaker/Infrastructure/StHbtKinkCollection.hh"
  182. #include "StHbtMaker/Infrastructure/StHbtEvent.hh"
  183. #include "StHbtMaker/Base/StHbtEventCut.h"
  184. #include "StHbtMaker/Base/StHbtTrackCut.h"
  185. #include "StHbtMaker/Base/StHbtV0Cut.h"
  186. #include "StHbtMaker/Base/StHbtXiCut.h"
  187. #include "StHbtMaker/Base/StHbtKinkCut.h"
  188. #include "StStrangeMuDstMaker/StStrangeMuDstMaker.h"
  189. #include "StStrangeMuDstMaker/StV0MuDst.hh"
  190. #include "StStrangeMuDstMaker/StXiMuDst.hh"
  191. #include "StStrangeMuDstMaker/StKinkMuDst.hh"
  192. #include "StEventMaker/StEventMaker.h"
  193. #include "StFlowMaker/StFlowMaker.h"
  194. #include "StFlowMaker/StFlowEvent.h"
  195. #include "StFlowAnalysisMaker/StFlowAnalysisMaker.h"
  196. #include "StFlowMaker/StFlowSelection.h"
  197. //#define STHBTDEBUG
  198. #ifdef __ROOT__
  199. ClassImp(StStandardHbtEventReader)
  200. #endif
  201. #if !(ST_NO_NAMESPACES)
  202. using namespace units;
  203. #endif
  204. //__________________
  205. StStandardHbtEventReader::StStandardHbtEventReader() : mTrackType(primary), mReadTracks(1), mReadV0s(1), mReadXis(1), mReadKinks(1) {
  206. mTheEventMaker=0;
  207. mTheV0Maker=0;
  208. mTheTagReader = 0;
  209. mReaderStatus = 0; // "good"
  210. mFlowMaker = 0;
  211. mFlowAnalysisMaker = 0;
  212. }
  213. //__________________
  214. StStandardHbtEventReader::~StStandardHbtEventReader(){
  215. if (mEventCut) delete mEventCut;
  216. if (mTrackCut) delete mTrackCut;
  217. if (mV0Cut) delete mV0Cut;
  218. if (mXiCut) delete mXiCut;
  219. if (mKinkCut) delete mKinkCut;
  220. }
  221. //__________________
  222. StHbtString StStandardHbtEventReader::Report(){
  223. StHbtString temp = "\n This is the StStandardHbtEventReader\n";
  224. char ccc[100];
  225. sprintf(ccc," Track type is %d\n",mTrackType);
  226. temp += ccc;
  227. sprintf(ccc," mReadTracks is %d\n",mReadTracks);
  228. temp += ccc;
  229. sprintf(ccc," mReadV0s is %d\n",mReadV0s);
  230. temp += ccc;
  231. sprintf(ccc," mReadXis is %d\n",mReadXis);
  232. temp += ccc;
  233. temp += "---> EventCuts in Reader: ";
  234. if (mEventCut) {
  235. temp += mEventCut->Report();
  236. }
  237. else {
  238. temp += "NONE";
  239. }
  240. temp += "\n---> TrackCuts in Reader: ";
  241. if (mTrackCut) {
  242. temp += mTrackCut->Report();
  243. }
  244. else {
  245. temp += "NONE";
  246. }
  247. temp += "\n---> V0Cuts in Reader: ";
  248. if (mV0Cut) {
  249. temp += mV0Cut->Report();
  250. }
  251. else {
  252. temp += "NONE";
  253. }
  254. temp += "\n---> XiCuts in Reader: ";
  255. if (mXiCut) {
  256. temp += mXiCut->Report();
  257. }
  258. else {
  259. temp += "NONE";
  260. }
  261. temp += "\n---> KinkCuts in Reader: ";
  262. if (mKinkCut) {
  263. temp += mKinkCut->Report();
  264. }
  265. else {
  266. temp += "NONE";
  267. }
  268. temp += "\n";
  269. return temp;
  270. }
  271. //__________________
  272. StHbtEvent* StStandardHbtEventReader::ReturnHbtEvent(){
  273. cout << " StStandardHbtEventReader::ReturnHbtEvent()" << endl;
  274. /////////////////
  275. // get StEvent //
  276. /////////////////
  277. StEvent* rEvent = 0;
  278. if (mTheEventMaker) { // an event maker was specified in the macro
  279. StEventMaker* tempMaker = (StEventMaker*) mTheEventMaker;
  280. rEvent = tempMaker->event();
  281. }
  282. else { // no event maker was specified, we assume that an event.root file was read
  283. cout << " read from event.root file " << endl;
  284. rEvent = (StEvent *) GetInputDS("StEvent");
  285. cout << " read from event.root file " << endl;
  286. }
  287. if (!rEvent){
  288. cout << " StStandardHbtEventReader::ReturnHbtEvent() - No StEvent!!! " << endl;
  289. return 0;
  290. }
  291. /*
  292. StEventSummary* summary = rEvent->summary();
  293. if (!summary){
  294. cout << " StStandardHbtEventReader::ReturnHbtEvent() - No StEventSummary!!! " << endl;
  295. return 0;
  296. }
  297. */
  298. // if this event has no tags, then return
  299. if (!mTheTagReader)
  300. cout << " StStandardHbtEventReader::ReturnHbtEvent() - no tag reader " << endl;
  301. if (mTheTagReader) {
  302. cout << " StStandardHbtEventReader::ReturnHbtEvent() - tag reader is switched on " << endl;
  303. if (!mTheTagReader->EventMatch(rEvent->info()->runId() , rEvent->info()->id()) ) {
  304. cout << " StStandardHbtEventReader::ReturnHbtEvent() - no tags for this event" << endl;
  305. return 0;
  306. }
  307. }
  308. StHbtEvent* hbtEvent = new StHbtEvent;
  309. unsigned int mult = rEvent->trackNodes().size();
  310. if ( rEvent->numberOfPrimaryVertices() != 1) {
  311. cout << " StStandardHbtEventReader::ReturnHbtEvent() - rEvent->numberOfPrimaryVertices()=" <<
  312. rEvent->numberOfPrimaryVertices() << endl;
  313. delete hbtEvent;
  314. return 0;
  315. }
  316. StHbtThreeVector vp = rEvent->primaryVertex()->position();
  317. hbtEvent->SetPrimVertPos(vp);
  318. cout << " StStandardHbtEventReader::ReturnHbtEvent() - primary vertex : " << vp << endl;
  319. // Run number
  320. hbtEvent->SetRunNumber( rEvent->runId() );
  321. if ( rEvent->summary() ) {
  322. hbtEvent->SetMagneticField(rEvent->summary()->magneticField());
  323. cout <<" StStandardHbtEventReader - magnetic field " << hbtEvent->MagneticField() << endl;
  324. }
  325. else {
  326. cout << "StStandardHbtEventReader - no StEvent summary -> no magnetic field written to HbtEvent" << endl;
  327. }
  328. if ( rEvent->l0Trigger() ) {
  329. hbtEvent->SetTriggerWord(rEvent->l0Trigger()->triggerWord());
  330. hbtEvent->SetTriggerActionWord(rEvent->l0Trigger()->triggerActionWord());
  331. }
  332. else {
  333. cout << "StStandardHbtEventReader - no StEvent l0Trigger" << endl;
  334. }
  335. int nL3Processed,nL3Accept,nL3Build;
  336. unsigned int firedL3TriggerAlgorithm=0;
  337. if ( rEvent->l3Trigger() && rEvent->l3Trigger()->l3EventSummary()) {
  338. const StL3EventSummary* mL3EventSummary = rEvent->l3Trigger()->l3EventSummary();
  339. unsigned int nAlgorithms = mL3EventSummary->numberOfAlgorithms();
  340. cout << "Number of L3 algorithms for this run: " << nAlgorithms << endl;
  341. const StSPtrVecL3AlgorithmInfo& mL3AlgInfo = mL3EventSummary->algorithms();
  342. for (unsigned int i=0; i<nAlgorithms; i++) {
  343. int algId = mL3AlgInfo[i]->id();
  344. nL3Processed = mL3AlgInfo[i]->numberOfProcessedEvents();
  345. nL3Accept = mL3AlgInfo[i]->numberOfAcceptedEvents();
  346. nL3Build = mL3AlgInfo[i]->numberOfBuildEvents();
  347. if (mL3AlgInfo[i]->build()) cout << "**";
  348. cout << " alg id " << algId << ":\t #proc " << nL3Processed << "\t #accept " << nL3Accept << "\t #build " << nL3Build << endl;
  349. }
  350. // print triggered algorithms
  351. const StPtrVecL3AlgorithmInfo& mL3TriggerAlgInfo = mL3EventSummary->algorithmsAcceptingEvent();
  352. cout << "Number of L3 algorithms which triggered this event: " << mL3TriggerAlgInfo.size() << endl;
  353. cout << "triggered algorithms: ";
  354. for (unsigned int i=0; i<mL3TriggerAlgInfo.size(); i++) cout << mL3TriggerAlgInfo[i]->id() << " ";
  355. cout << endl;
  356. firedL3TriggerAlgorithm=0;
  357. for (StPtrVecL3AlgorithmInfoConstIterator theIter = mL3TriggerAlgInfo.begin(); theIter != mL3TriggerAlgInfo.end(); ++theIter) {
  358. firedL3TriggerAlgorithm |= ( 1<<((*theIter)->id()) );
  359. cout << ((*theIter)->id()) << " " << firedL3TriggerAlgorithm << endl;
  360. }
  361. hbtEvent->SetL3TriggerAlgorithm(0,firedL3TriggerAlgorithm);
  362. }
  363. else {
  364. cout << "StStandardHbtEventReader - no StEvent l3Trigger" << endl;
  365. }
  366. cout << "StStandardHbtEventReader - done" << endl;
  367. // By now, all event-wise information has been extracted and stored in hbtEvent
  368. // see if it passes any front-loaded event cut
  369. if (mEventCut){
  370. if (!(mEventCut->Pass(hbtEvent))){ // event failed! - return null pointer (but leave Reader status flag as "good")
  371. delete hbtEvent;
  372. return 0;
  373. }
  374. }
  375. StTrack* pTrack; // primary
  376. StTrack* gTrack; // global
  377. StTrack* cTrack; // current track
  378. cout << "StStandardHbtReader::ReturnHbtEvent() - We have " << mult << " tracks to store - we skip tracks with nhits==0" << endl;
  379. StTpcDedxPidAlgorithm* PidAlgorithm = new StTpcDedxPidAlgorithm();
  380. if (!PidAlgorithm) cout << " StStandardHbtEventReader::ReturnHbtEvent() - Whoa!! No PidAlgorithm!! " << endl;
  381. // the following just point to particle definitions in StEvent
  382. //StElectron* Electron = StElectron::instance();
  383. //StPionPlus* Pion = StPionPlus::instance();
  384. //StKaonPlus* Kaon = StKaonPlus::instance();
  385. //StProton* Proton = StProton::instance();
  386. int iNoHits = 0;
  387. int iNoPidTraits = 0;
  388. int iFailedCut =0;
  389. int iNoBestGuess =0;
  390. int iBadFlag =0;
  391. int iTracks = 0;
  392. int iGoodTracks =0;
  393. int iWrongTrackType =0;
  394. // loop over all the tracks, accept only global
  395. for (unsigned int icount=0; icount<(unsigned int)mult; icount++){
  396. cTrack = rEvent->trackNodes()[icount]->track(mTrackType);
  397. if (cTrack) {
  398. iTracks++;
  399. if (cTrack->flag()>=0) iGoodTracks++;
  400. #ifdef STHBTDEBUG
  401. cout << iTracks << " " << iGoodTracks << " : ";
  402. cout << cTrack->type() << " ";
  403. cout << cTrack->flag() << " ";
  404. cout << cTrack->key() << " ";
  405. cout << cTrack->impactParameter() << " ";
  406. cout << cTrack->numberOfPossiblePoints() << " ";
  407. cout << endl;
  408. #endif
  409. }
  410. }
  411. hbtEvent->SetNumberOfTracks(iTracks);
  412. hbtEvent->SetNumberOfGoodTracks(iGoodTracks);
  413. hbtEvent->SetUncorrectedNumberOfPositivePrimaries(uncorrectedNumberOfPositivePrimaries(*rEvent));
  414. hbtEvent->SetUncorrectedNumberOfNegativePrimaries(uncorrectedNumberOfNegativePrimaries(*rEvent));
  415. hbtEvent->SetEventNumber(rEvent->info()->id());
  416. if (rEvent->triggerDetectorCollection()) {
  417. StZdcTriggerDetector zdc = rEvent->triggerDetectorCollection()->zdc();
  418. hbtEvent->SetZdcAdcWest((int)zdc.adc(10)); // Zdc West sum attenuated
  419. hbtEvent->SetZdcAdcEast((int)zdc.adc(13)); // Zdc East sum attenuated
  420. }
  421. else {
  422. cout << "StStandardHbtEventReader::Return(...) - no triggerDetectorCollection " << endl;
  423. }
  424. /*
  425. // Randy commented this out since the RP is obtained from the FlowMaker now
  426. // Didn't remove in case someone found it useful
  427. if (mTheTagReader) {
  428. hbtEvent->SetEventNumber(mTheTagReader->tag("mEventNumber"));
  429. // reaction plane from tags
  430. StHbtThreeVector a( mTheTagReader->tag("qxa",1), mTheTagReader->tag("qya",1),0);
  431. StHbtThreeVector b( mTheTagReader->tag("qxb",1), mTheTagReader->tag("qyb",1),0);
  432. float reactionPlane = (a+b).phi();
  433. float reactionPlaneSubEventDifference = a.angle(b);
  434. cout << " reactionPlane : " << reactionPlane/3.1415927*180.;
  435. cout << " reactionPlaneSubEventDifference : " << reactionPlaneSubEventDifference/3.1415927*180. << endl;
  436. hbtEvent->SetReactionPlane(reactionPlane);
  437. hbtEvent->SetReactionPlaneSubEventDifference(reactionPlaneSubEventDifference);
  438. }
  439. */
  440. // For Aihong's pid
  441. // StuProbabilityPidAlgorithm aihongsPid(*rEvent);
  442. if (mReadTracks) {
  443. for (unsigned int icount=0; icount<(unsigned int)mult; icount++){
  444. #ifdef STHBTDEBUG
  445. cout << " track# " << icount;
  446. cout << " -1- ";
  447. #endif
  448. gTrack = rEvent->trackNodes()[icount]->track(global);
  449. pTrack = rEvent->trackNodes()[icount]->track(primary);
  450. cTrack = rEvent->trackNodes()[icount]->track(mTrackType);
  451. // don't make a hbtTrack if not a primary track
  452. if (!cTrack) { iWrongTrackType++; continue; }
  453. if (cTrack->flag() < 0) { iBadFlag++; continue; }
  454. if (!gTrack) {
  455. cout << "StStandardHbtEventReader::Return(...) - no global track pointer !?! " << endl;
  456. continue;
  457. }
  458. // check number points in tpc
  459. if (!cTrack->detectorInfo()) {
  460. cout << "StStandardHbtEventReader::Return(...) - no detector info " << endl;
  461. assert(0);
  462. }
  463. int nhits = cTrack->detectorInfo()->numberOfPoints(kTpcId);
  464. if (nhits==0) {
  465. iNoHits++;
  466. #ifdef STHBTDEBUG
  467. cout << "No hits -- skipping track (because it crashes otherwise)" << endl;
  468. #endif
  469. continue;
  470. }
  471. // while getting the bestGuess, the pidAlgorithm (StTpcDedxPidAlgorithm) is set up.
  472. // pointers to track and pidTraits are set
  473. StParticleDefinition* BestGuess = (StParticleDefinition*)cTrack->pidTraits(*PidAlgorithm);
  474. // if (BestGuess) cout << "best guess for particle is " << BestGuess->name() << endl; //2dec9
  475. if (!BestGuess){
  476. #ifdef STHBTDEBUG
  477. cout << " noGuess ";
  478. #endif
  479. iNoBestGuess++;
  480. continue;
  481. }
  482. #ifdef STHBTDEBUG
  483. cout << "Getting readty to instantiate new StHbtTrack " << endl;
  484. #endif
  485. // o.k., we got the track with all we need, let's create the StHbtTrack
  486. StHbtTrack* hbtTrack = new StHbtTrack(rEvent,cTrack);
  487. if (mTrackCut){
  488. #ifdef STHBTDEBUG
  489. cout << " -cut- ";
  490. cout << endl;
  491. #endif
  492. if (!(mTrackCut->Pass(hbtTrack))){ // track failed - delete it and skip the push_back
  493. iFailedCut++;
  494. delete hbtTrack;
  495. continue;
  496. }
  497. }
  498. #ifdef STHBTDEBUG
  499. cout << " -p- ";
  500. cout << endl;
  501. #endif
  502. hbtEvent->TrackCollection()->push_back(hbtTrack);
  503. }
  504. }
  505. printf(" StStandardHbtEventReader::ReturnHbtEvent() - %8i tracks of type %i \n",iTracks,mTrackType);
  506. printf(" StStandardHbtEventReader::ReturnHbtEvent() - %8i good tracks of type %i \n",iGoodTracks,mTrackType);
  507. printf(" StStandardHbtEventReader::ReturnHbtEvent() - %8i wrong type tracks \n",iWrongTrackType);
  508. printf(" StStandardHbtEventReader::ReturnHbtEvent() - %8i no hits, tracks skipped \n",iNoHits);
  509. printf(" StStandardHbtEventReader::ReturnHbtEvent() - %8i no tpcPidTraits, tracks skipped \n",iNoPidTraits);
  510. printf(" StStandardHbtEventReader::ReturnHbtEvent() - %8i failed tracks cuts, track skipped \n",iFailedCut);
  511. printf(" StStandardHbtEventReader::ReturnHbtEvent() - %8i bad flag, track skipped \n",iBadFlag);
  512. printf(" StStandardHbtEventReader::ReturnHbtEvent() - %8i(%i) tracks pushed into collection \n",hbtEvent->TrackCollection()->size(), mult);
  513. delete PidAlgorithm;
  514. //Now do v0 stuff
  515. //Pick up pointer v0 minidst maker
  516. //StV0MiniDstMaker* v0Maker = (StV0MiniDstMaker *) mTheV0Maker;
  517. StStrangeMuDstMaker* muDstMaker = (StStrangeMuDstMaker *) mTheV0Maker;
  518. /* **********************************************/
  519. /* now read the v0 from the StStrangeMuDstMaker */
  520. /* **********************************************/
  521. if( muDstMaker && mReadV0s ) {
  522. for( int i= 0; i < muDstMaker->GetNV0(); i++){
  523. StV0MuDst* v0FromMuDst = muDstMaker->GetV0(i);
  524. //v0FromMuDst->UpdateV0();
  525. StHbtV0* hbtV0 = new StHbtV0(*v0FromMuDst);
  526. // By now, all track-wise information has been extracted and stored in hbtTrack
  527. // see if it passes any front-loaded event cut
  528. if (mV0Cut){
  529. if (!(mV0Cut->Pass(hbtV0))){ // track failed - delete it and skip the push_back
  530. delete hbtV0;
  531. continue;
  532. }
  533. }
  534. hbtEvent->V0Collection()->push_back(hbtV0);
  535. } // end of loop over strangeness groups v0's
  536. printf(" StStandardHbtEventReader::ReturnHbtEvent() - %8i(%i) V0s pushed into collection \n",
  537. hbtEvent->V0Collection()->size(),
  538. muDstMaker->GetNV0());
  539. }
  540. /* **********************************************/
  541. /* now read the xi from the StStrangeMuDstMaker */
  542. /* **********************************************/
  543. if( muDstMaker && mReadXis ) {
  544. for( int i= 0; i < muDstMaker->GetNXi(); i++){
  545. StXiMuDst* xiFromMuDst = muDstMaker->GetXi(i);
  546. //xiFromMuDst->UpdateXi();
  547. StHbtXi* hbtXi = new StHbtXi(*xiFromMuDst);
  548. // By now, all track-wise information has been extracted and stored in hbtTrack
  549. // see if it passes any front-loaded event cut
  550. if (mXiCut){
  551. if (!(mXiCut->Pass(hbtXi))){ // track failed - delete it and skip the push_back
  552. delete hbtXi;
  553. continue;
  554. }
  555. }
  556. hbtEvent->XiCollection()->push_back(hbtXi);
  557. } // end of loop over strangeness groups xi's
  558. printf(" StStandardHbtEventReader::ReturnHbtEvent() - %8i(%i) Xis pushed into collection \n",
  559. hbtEvent->XiCollection()->size(),
  560. muDstMaker->GetNXi());
  561. }
  562. /* *************************************/
  563. /* now read the kinks from the StEvent */
  564. /* *************************************/
  565. // Now do the Kink Stuff - mal 25May2001
  566. //StKinkVertex* starKink;
  567. StHbtKink* hbtKink;
  568. if( mReadKinks ) {
  569. for (unsigned int icount=0; icount<(unsigned int)rEvent->kinkVertices().size(); icount++)
  570. {
  571. StKinkVertex* starKink = rEvent->kinkVertices()[icount];
  572. hbtKink = new StHbtKink(*starKink, vp);
  573. // before pushing onto the StHbtKinkCollection, make sure this kink passes any front-loaded cuts...
  574. if (mKinkCut){
  575. if (!(mKinkCut->Pass(hbtKink))){ // kink failed - the "continue" will skip the push_back
  576. delete hbtKink;
  577. continue;
  578. }
  579. }
  580. hbtEvent->KinkCollection()->push_back(hbtKink);
  581. }
  582. printf(" StStandardHbtEventReader::ReturnHbtEvent() - %8i(%i) Kinks pushed into collection \n",
  583. hbtEvent->KinkCollection()->size(),
  584. rEvent->kinkVertices().size());
  585. }
  586. // Can't get Reaction Plane until whole HbtEvent is filled
  587. if ( mFlowMaker && hbtEvent ) {
  588. // mFlowMaker->FillFlowEvent(hbtEvent);
  589. // // First get RP for whole event
  590. // mFlowMaker->FlowSelection()->SetSubevent(-1);
  591. // double reactionPlane = mFlowMaker->FlowEventPointer()->Psi(mFlowMaker->FlowSelection());
  592. // cout << "Reaction Plane " << reactionPlane << endl;
  593. // hbtEvent->SetReactionPlane(reactionPlane);
  594. // // Sub event RPs
  595. // mFlowMaker->FlowSelection()->SetSubevent(0);
  596. // double RP1 = mFlowMaker->FlowEventPointer()->Psi(mFlowMaker->FlowSelection());
  597. // mFlowMaker->FlowSelection()->SetSubevent(1);
  598. // double RP2 = mFlowMaker->FlowEventPointer()->Psi(mFlowMaker->FlowSelection());
  599. // hbtEvent->SetReactionPlaneSubEventDifference(RP1-RP2);
  600. // // if Flow Analysis is switched on ... make correction histogram
  601. // if (mFlowAnalysisMaker) mFlowAnalysisMaker->Make();
  602. }
  603. // There might be event cuts that modify the collections of Tracks or V0 in the event.
  604. // These cuts have to be done after the event is built. That's why we have the event cut
  605. // at this point for the second time.
  606. // An example of this kind of cuts will be an cut that removes spit tracks from the event.
  607. if (mEventCut){
  608. if (!(mEventCut->Pass(hbtEvent))){ // event failed! - return null pointer (but leave Reader status flag as "good")
  609. delete hbtEvent;
  610. return 0;
  611. }
  612. }
  613. return hbtEvent;
  614. }