StHbtPythia6DstReader.cxx 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889
  1. #include "StHbtPythia6DstReader.h"
  2. #include "StarClassLibrary/StPhysicalHelixD.hh"
  3. #include "StarClassLibrary/StTimer.hh"
  4. #include "StHbtMaker/Infrastructure/StHbtEvent.hh"
  5. #include "StHbtMaker/Infrastructure/StHbtTrack.hh"
  6. #include "StHbtMaker/Infrastructure/StHbtV0.hh"
  7. #include "StHbtMaker/Infrastructure/StHbtTrackCollection.hh"
  8. #include "StHbtMaker/Infrastructure/StHbtV0Collection.hh"
  9. #include "StHbtMaker/Base/StHbtEventCut.h"
  10. #include "StThreeVector.hh"
  11. #include "TStreamerInfo.h"
  12. #include "TClonesArray.h"
  13. #include "TLorentzVector.h"
  14. #include "TMath.h"
  15. #include "TMCParticle.h"
  16. #include "TDatabasePDG.h"
  17. ClassImp(StHbtPythia6DstReader)
  18. const Float_t PYHIA_BFIELD = -4.989478911781311; //From AuAu200 y2011
  19. //_________________
  20. StHbtPythia6DstReader::StHbtPythia6DstReader(TPythia6* dst,
  21. int genVersion) {
  22. mReaderStatus = 0;
  23. mEventCounter = 0;
  24. mEventTries = 0;
  25. mEventIsGood = false;
  26. mPartId = -999;
  27. mGenVersion = genVersion;
  28. mSelPartNum = 0;
  29. mPythiaDst = dst; //Get the pythia instance
  30. }
  31. //_________________
  32. StHbtPythia6DstReader::~StHbtPythia6DstReader(){
  33. /*empty*/
  34. }
  35. //_________________
  36. void StHbtPythia6DstReader::clear() {
  37. mEventIsGood = false;
  38. mSelPartNum = 0;
  39. }
  40. //_________________
  41. int StHbtPythia6DstReader::Init(const char* ReadWrite, StHbtString& Message){
  42. #ifdef STHBTDEBUG
  43. std::cout << "StHbtPythia6DstReader:Init -- nothing to do here"
  44. << std::endl;
  45. #endif
  46. return kStOK;
  47. }
  48. //_________________
  49. StHbtEvent* StHbtPythia6DstReader::ReturnHbtEvent(){
  50. #ifdef STHBTDEBUG
  51. std::cout << "StHbtPythia6DstReader::ReturnHbtEvent() " << std::endl;
  52. #endif
  53. //Usage:
  54. //mGenVersion = 0 - Clean min. bias generated event
  55. //mGenVersion = 1 - Two-particle selection
  56. if (!mPythiaDst) return 0;
  57. if(mGenVersion<0 || mGenVersion>2) {
  58. mGenVersion = 0;
  59. }
  60. //Create empty StHbtEvent
  61. StHbtEvent* mHbtEvent = new StHbtEvent;
  62. if(mGenVersion == 0) {
  63. RandomGeneration(mHbtEvent);
  64. }
  65. else if(mGenVersion == 1) {
  66. PrimaryTrackGeneration(mHbtEvent);
  67. }
  68. else if(mGenVersion == 2) {
  69. V0Generation(mHbtEvent);
  70. }
  71. /*
  72. std::cout << "StHbtPythia6DstReader::ReturnHbtEvent(): " << std::endl
  73. << "Tracks pushed to collection: " << mHbtEvent->TrackCollection()->size() << std::endl
  74. << "V0s pushed to collection : " << mHbtEvent->V0Collection()->size() << std::endl;
  75. */
  76. return mHbtEvent;
  77. }
  78. //_________________
  79. void StHbtPythia6DstReader::Finish() {
  80. std::cout << "StHbtPythia6DstReader:Finish" << std::endl
  81. << "Number of good events: " << mEventCounter
  82. << "\tNumber of generations: " << mEventTries << std::endl;
  83. }
  84. //________________
  85. Double_t StHbtPythia6DstReader::dedxMean(Double_t mass, Double_t momentum) {
  86. Double_t dedxMean;
  87. Double_t tpcDedxGain = 0.174325e-06;
  88. Double_t tpcDedxOffset = -2.71889;
  89. Double_t tpcDedxRise = 776.626;
  90. Double_t gamma = TMath::Sqrt(momentum*momentum/(mass*mass)+1.);
  91. Double_t beta = TMath::Sqrt(1. - 1./(gamma*gamma));
  92. Double_t rise = tpcDedxRise* beta*beta*gamma*gamma;
  93. if ( beta > 0)
  94. dedxMean = tpcDedxGain/(beta*beta) * (0.5*TMath::Log(rise) - beta*beta
  95. - tpcDedxOffset);
  96. else
  97. dedxMean = 1000.;
  98. return dedxMean;
  99. }
  100. //_________________
  101. void StHbtPythia6DstReader::RandomGeneration(StHbtEvent *mHbtEvent) {
  102. //Variables for the StHbtEvent
  103. StThreeVectorF mPrimVertPos = StThreeVectorF(0., 0., 0.);
  104. Float_t mVpdVz = 0.;
  105. Float_t mMagneticField = PYHIA_BFIELD;
  106. //added by gnigmat
  107. #ifdef STHBTDEBUG
  108. std::cout << "ReturnHbtEvent: start generation process" << std::endl;
  109. #endif
  110. //Array of generated particles
  111. TObjArray *pyParticles = NULL;
  112. TMCParticle *pyParticle = NULL;
  113. Int_t mNumParticles = 0;
  114. Int_t pyPosTrkNum = 0;
  115. Int_t pyNegTrkNum = 0;
  116. Int_t pyRefMult = 0;
  117. TLorentzVector pyTrack, pyPosTrack, pyNegTrack;
  118. float mPseudoRapidity;
  119. Int_t pyKF, pyKS, pyCharge;
  120. short pyLocalCharge = 0;
  121. Float_t pyTrkNSigmaElectron, pyTrkNSigmaPion;
  122. Float_t pyTrkNSigmaKaon, pyTrkNSigmaProton;
  123. Float_t pyTrkPidProbElectron, pyTrkPidProbPion;
  124. Float_t pyTrkPidProbKaon, pyTrkPidProbProton;
  125. Float_t pyTrkDCAxy, pyTrkDCAz, pyTrkMass;
  126. //Start event generation here
  127. do {
  128. clear();
  129. mPythiaDst->GenerateEvent();
  130. pyParticles = mPythiaDst->GetListOfParticles();
  131. mEventTries++;
  132. if(pyParticles) {
  133. mEventIsGood = true;
  134. }
  135. } while(!mEventIsGood);
  136. mEventCounter++;
  137. mNumParticles = pyParticles->GetEntries();
  138. //mPythiaDst->Pylist(1);
  139. //Number of particles in acceptance
  140. pyRefMult = 0;
  141. //Main particle loop
  142. for(Int_t iTrk=0; iTrk<mNumParticles; iTrk++) {
  143. pyKF = 0;
  144. pyKS = 0;
  145. pyCharge = 0;
  146. pyParticle = (TMCParticle*)pyParticles->At(iTrk);
  147. //Use final-state particles
  148. if(!pyParticle || pyParticle->GetKS()!=1) continue;
  149. pyKF = pyParticle->GetKF();
  150. pyKS = pyParticle->GetKS();
  151. pyCharge = TDatabasePDG::Instance()->GetParticle(pyKF)->Charge();
  152. pyTrack.SetPxPyPzE(pyParticle->GetPx(),
  153. pyParticle->GetPy(),
  154. pyParticle->GetPz(),
  155. pyParticle->GetEnergy());
  156. if(pyTrack.P() < 0.1) continue;
  157. mPseudoRapidity = 0.5*TMath::Log( (pyTrack.P() + pyTrack.Pz()) /
  158. (pyTrack.P() - pyTrack.Pz()) );
  159. //Calculate multiplicity
  160. if( pyTrack.P() >= 0.1 && TMath::Abs(mPseudoRapidity)<=0.5 &&
  161. pyCharge!=0 ) {
  162. pyRefMult++;
  163. if(pyCharge>0) {
  164. pyPosTrkNum++;
  165. pyLocalCharge = 1;
  166. }
  167. else if( pyCharge<0) {
  168. pyNegTrkNum++;
  169. pyLocalCharge = -1;
  170. }
  171. }
  172. //Do not use particles that not pass next cut
  173. if(pyTrack.P()<0.1 || TMath::Abs(mPseudoRapidity)>1.1) continue;
  174. //Primary tracks
  175. if(TMath::Abs(pyKF)!=211 && TMath::Abs(pyKF)!=321 &&
  176. TMath::Abs(pyKF)!=2212) continue;
  177. //Factor 10 converts mm to cm
  178. pyTrkDCAxy = TMath::Sqrt(pyParticle->GetVx()*pyParticle->GetVx() +
  179. pyParticle->GetVy()*pyParticle->GetVy()) / 10;
  180. pyTrkDCAz = pyParticle->GetVz() / 10;
  181. //Primary track cut (5 cm)
  182. if(pyTrkDCAxy > 5. ||
  183. pyTrkDCAz > 5.) continue;
  184. if(pyKF>0) {
  185. pyLocalCharge = +1;
  186. }
  187. else if(pyKF<0) {
  188. pyLocalCharge = -1;
  189. }
  190. pyTrkMass = pyParticle->GetMass();
  191. switch(TMath::Abs(pyKF)) {
  192. case 211:
  193. pyTrkNSigmaElectron = -999.;
  194. pyTrkNSigmaPion = 0.;
  195. pyTrkNSigmaKaon = -999.;
  196. pyTrkNSigmaProton = -999.;
  197. pyTrkPidProbElectron = -999.;
  198. pyTrkPidProbPion = 0.;
  199. pyTrkPidProbKaon = -999.;
  200. pyTrkPidProbProton = -999.;
  201. break;
  202. case 321:
  203. pyTrkNSigmaElectron = -999.;
  204. pyTrkNSigmaPion = -999.;
  205. pyTrkNSigmaKaon = 0.;
  206. pyTrkNSigmaProton = -999.;
  207. pyTrkPidProbElectron = -999.;
  208. pyTrkPidProbPion = -999.;
  209. pyTrkPidProbKaon = 0.;
  210. pyTrkPidProbProton = -999.;
  211. break;
  212. case 2212:
  213. pyTrkNSigmaElectron = -999.;
  214. pyTrkNSigmaPion = -999.;
  215. pyTrkNSigmaKaon = -999.;
  216. pyTrkNSigmaProton = 0.;
  217. pyTrkPidProbElectron = -999.;
  218. pyTrkPidProbPion = -999.;
  219. pyTrkPidProbKaon = -999.;
  220. pyTrkPidProbProton = 0.;
  221. break;
  222. default:
  223. pyTrkNSigmaElectron = -999.;
  224. pyTrkNSigmaPion = -999.;
  225. pyTrkNSigmaKaon = -999.;
  226. pyTrkNSigmaProton = -999.;
  227. pyTrkPidProbElectron = -999.;
  228. pyTrkPidProbPion = -999.;
  229. pyTrkPidProbKaon = -999.;
  230. pyTrkPidProbProton = -999.;
  231. };
  232. StHbtTrack *track = new StHbtTrack;
  233. //0-global, 1-primary
  234. //track->SetTrackType(1);
  235. track->SetFlag(100);
  236. //track->SetCharge(pyLocalCharge);
  237. track->SetNHits(pyLocalCharge * 45);
  238. //track->SetNHitsFit(45);
  239. track->SetNHitsPossible(45);
  240. track->SetNSigmaElectron(pyTrkNSigmaElectron);
  241. track->SetNSigmaPion(pyTrkNSigmaPion);
  242. track->SetNSigmaKaon(pyTrkNSigmaKaon);
  243. track->SetNSigmaProton(pyTrkNSigmaProton);
  244. track->SetPidProbElectron(pyTrkPidProbElectron);
  245. track->SetPidProbPion(pyTrkPidProbPion);
  246. track->SetPidProbKaon(pyTrkPidProbKaon);
  247. track->SetPidProbProton(pyTrkPidProbProton);
  248. track->SetdEdx( dedxMean(pyTrkMass, pyTrack.P() ) );
  249. //track->SetDCAxy(pyTrkDCAxy);
  250. //track->SetDCAz(pyTrkDCAz);
  251. track->SetDCAxyGlobal(pyTrkDCAxy);
  252. track->SetDCAzGlobal(pyTrkDCAz);
  253. track->SetChi2(0.);
  254. //track->SetChiSquaredXY(1.);
  255. //track->SetChiSquaredZ(1.);
  256. track->SetP(StThreeVectorF(pyTrack.Px(), pyTrack.Py(), pyTrack.Pz()));
  257. track->SetPGlobal(StThreeVectorF(pyTrack.Px(),pyTrack.Py(),pyTrack.Pz()));
  258. StPhysicalHelixD mHelix = StPhysicalHelixD(StThreeVectorF(pyTrack.Px(),
  259. pyTrack.Py(),
  260. pyTrack.Pz()),
  261. StThreeVectorF(0,0,0),
  262. mMagneticField*kilogauss,
  263. pyLocalCharge);
  264. track->SetHelix(mHelix);
  265. track->SetHelixGlobal(mHelix);
  266. track->SetTopologyMap(0, 0.);
  267. track->SetTopologyMap(1, 0.);
  268. short pyId=iTrk;
  269. track->SetTrackId(pyId);
  270. track->SetTofBeta(pyTrack.P()/pyParticle->GetEnergy());
  271. track->SetHiddenInfo(0);
  272. mHbtEvent->TrackCollection()->push_back(track);
  273. } //for (int iTrk=0; iTrk<mNumParticles; iTrk++)
  274. mHbtEvent->SetEventNumber(mEventCounter);
  275. mHbtEvent->SetRunNumber(mEventCounter);
  276. mHbtEvent->SetCtbMult(0);
  277. mHbtEvent->SetZdcAdcEast(0);
  278. mHbtEvent->SetZdcAdcWest(0);
  279. mHbtEvent->SetNumberOfTpcHits(0);
  280. mHbtEvent->SetNumberOfTracks(pyRefMult);
  281. mHbtEvent->SetNumberOfGoodTracks(pyRefMult);
  282. mHbtEvent->SetReactionPlane(0.);
  283. mHbtEvent->SetReactionPlaneError(0.);
  284. mHbtEvent->SetReactionPlaneSubEventDifference(0.);
  285. mHbtEvent->SetPrimVertPos(mPrimVertPos);
  286. mHbtEvent->SetUncorrectedNumberOfPositivePrimaries(pyPosTrkNum);
  287. mHbtEvent->SetUncorrectedNumberOfNegativePrimaries(pyNegTrkNum);
  288. mHbtEvent->SetUncorrectedNumberOfPrimaries(pyRefMult);
  289. mHbtEvent->SetMagneticField(mMagneticField);
  290. mHbtEvent->SetVpdVz(mVpdVz);
  291. }
  292. //_________________
  293. void StHbtPythia6DstReader::PrimaryTrackGeneration(StHbtEvent *mHbtEvent) {
  294. //Variables for the StHbtEvent
  295. StThreeVectorF mPrimVertPos = StThreeVectorF(0., 0., 0.);
  296. Float_t mVpdVz = 0.;
  297. Float_t mMagneticField = PYHIA_BFIELD;
  298. //added by gnigmat
  299. #ifdef STHBTDEBUG
  300. std::cout << "ReturnHbtEvent: start generation process" << std::endl;
  301. #endif
  302. //Array of generated particles
  303. TObjArray *pyParticles = NULL;
  304. TMCParticle *pyParticle = NULL;
  305. Int_t mNumParticles = 0;
  306. Int_t pyPosTrkNum = 0;
  307. Int_t pyNegTrkNum = 0;
  308. Int_t pyRefMult = 0;
  309. TLorentzVector pyTrack, pyPosTrack, pyNegTrack;
  310. float mPseudoRapidity;
  311. Int_t pyKF, pyKS, pyCharge;
  312. short pyLocalCharge = 0;
  313. Float_t pyTrkNSigmaElectron, pyTrkNSigmaPion;
  314. Float_t pyTrkNSigmaKaon, pyTrkNSigmaProton;
  315. Float_t pyTrkPidProbElectron, pyTrkPidProbPion;
  316. Float_t pyTrkPidProbKaon, pyTrkPidProbProton;
  317. Float_t pyTrkDCAxy, pyTrkDCAz, pyTrkMass;
  318. //Start event generation here
  319. do {
  320. clear();
  321. mPythiaDst->GenerateEvent();
  322. pyParticles = mPythiaDst->GetListOfParticles();
  323. mEventTries++;
  324. if(!pyParticles) continue;
  325. mNumParticles = pyParticles->GetEntries();
  326. //mPythiaDst->Pylist(1);
  327. //Number of particles in acceptance
  328. pyRefMult = 0;
  329. //Main particle loop
  330. for(Int_t iTrk=0; iTrk<mNumParticles; iTrk++) {
  331. pyKF = 0;
  332. pyKS = 0;
  333. pyCharge = 0;
  334. pyParticle = (TMCParticle*)pyParticles->At(iTrk);
  335. //Use final-state particles
  336. if(!pyParticle || pyParticle->GetKS()!=1) continue;
  337. pyKF = pyParticle->GetKF();
  338. pyKS = pyParticle->GetKS();
  339. pyCharge = TDatabasePDG::Instance()->GetParticle(pyKF)->Charge();
  340. pyTrack.SetPxPyPzE(pyParticle->GetPx(),
  341. pyParticle->GetPy(),
  342. pyParticle->GetPz(),
  343. pyParticle->GetEnergy());
  344. if(pyTrack.P() < 0.1) continue;
  345. mPseudoRapidity = 0.5*TMath::Log( (pyTrack.P() + pyTrack.Pz()) /
  346. (pyTrack.P() - pyTrack.Pz()) );
  347. //Calculate multiplicity
  348. if( pyTrack.P() >= 0.1 && TMath::Abs(mPseudoRapidity)<=0.5 &&
  349. pyCharge!=0 ) {
  350. pyRefMult++;
  351. if(pyCharge>0) {
  352. pyPosTrkNum++;
  353. pyLocalCharge = 1;
  354. }
  355. else if( pyCharge<0) {
  356. pyNegTrkNum++;
  357. pyLocalCharge = -1;
  358. }
  359. }
  360. //Do not use particles that not pass next cut
  361. if(pyTrack.P()<0.1 || TMath::Abs(mPseudoRapidity)>1.1) continue;
  362. //Primary tracks
  363. if(TMath::Abs(pyKF)!=211 && TMath::Abs(pyKF)!=321 &&
  364. TMath::Abs(pyKF)!=2212) continue;
  365. if(TMath::Abs(pyKF) != TMath::Abs(mPartId)) continue;
  366. //Factor 10 converts mm to cm
  367. pyTrkDCAxy = TMath::Sqrt(pyParticle->GetVx()*pyParticle->GetVx() +
  368. pyParticle->GetVy()*pyParticle->GetVy()) / 10;
  369. pyTrkDCAz = pyParticle->GetVz() / 10;
  370. //Primary track cut (5 cm)
  371. if(pyTrkDCAxy > 5. ||
  372. pyTrkDCAz > 5.) continue;
  373. mSelPartNum++;
  374. pyTrkMass = pyParticle->GetMass();
  375. switch(TMath::Abs(pyKF)) {
  376. case 211:
  377. pyTrkNSigmaElectron = -999.;
  378. pyTrkNSigmaPion = 0.;
  379. pyTrkNSigmaKaon = -999.;
  380. pyTrkNSigmaProton = -999.;
  381. pyTrkPidProbElectron = -999.;
  382. pyTrkPidProbPion = 0.;
  383. pyTrkPidProbKaon = -999.;
  384. pyTrkPidProbProton = -999.;
  385. break;
  386. case 321:
  387. pyTrkNSigmaElectron = -999.;
  388. pyTrkNSigmaPion = -999.;
  389. pyTrkNSigmaKaon = 0.;
  390. pyTrkNSigmaProton = -999.;
  391. pyTrkPidProbElectron = -999.;
  392. pyTrkPidProbPion = -999.;
  393. pyTrkPidProbKaon = 0.;
  394. pyTrkPidProbProton = -999.;
  395. break;
  396. case 2212:
  397. pyTrkNSigmaElectron = -999.;
  398. pyTrkNSigmaPion = -999.;
  399. pyTrkNSigmaKaon = -999.;
  400. pyTrkNSigmaProton = 0.;
  401. pyTrkPidProbElectron = -999.;
  402. pyTrkPidProbPion = -999.;
  403. pyTrkPidProbKaon = -999.;
  404. pyTrkPidProbProton = 0.;
  405. break;
  406. default:
  407. pyTrkNSigmaElectron = -999.;
  408. pyTrkNSigmaPion = -999.;
  409. pyTrkNSigmaKaon = -999.;
  410. pyTrkNSigmaProton = -999.;
  411. pyTrkPidProbElectron = -999.;
  412. pyTrkPidProbPion = -999.;
  413. pyTrkPidProbKaon = -999.;
  414. pyTrkPidProbProton = -999.;
  415. };
  416. StHbtTrack *track = new StHbtTrack;
  417. //0-global, 1-primary
  418. //track->SetTrackType(1);
  419. track->SetFlag(300);
  420. //track->SetCharge(pyLocalCharge);
  421. track->SetNHits(pyLocalCharge * 45);
  422. //track->SetNHitsFit(45);
  423. track->SetNHitsPossible(45);
  424. track->SetNSigmaElectron(pyTrkNSigmaElectron);
  425. track->SetNSigmaPion(pyTrkNSigmaPion);
  426. track->SetNSigmaKaon(pyTrkNSigmaKaon);
  427. track->SetNSigmaProton(pyTrkNSigmaProton);
  428. track->SetPidProbElectron(pyTrkPidProbElectron);
  429. track->SetPidProbPion(pyTrkPidProbPion);
  430. track->SetPidProbKaon(pyTrkPidProbKaon);
  431. track->SetPidProbProton(pyTrkPidProbProton);
  432. track->SetdEdx( dedxMean(pyTrkMass, pyTrack.P()) );
  433. //track->SetDCAxy(pyTrkDCAxy);
  434. //track->SetDCAz(pyTrkDCAz);
  435. track->SetDCAxyGlobal(pyTrkDCAxy);
  436. track->SetDCAzGlobal(pyTrkDCAz);
  437. track->SetChi2(1.);
  438. //track->SetChiSquaredXY(1.);
  439. //track->SetChiSquaredZ(1.);
  440. track->SetP(StThreeVectorF(pyTrack.Px(), pyTrack.Py(), pyTrack.Pz()));
  441. track->SetPGlobal(StThreeVectorF(pyTrack.Px(),pyTrack.Py(),pyTrack.Pz()));
  442. StPhysicalHelixD mHelix = StPhysicalHelixD(StThreeVectorF(pyTrack.Px(),
  443. pyTrack.Py(),
  444. pyTrack.Pz()),
  445. StThreeVectorF(0,0,0),
  446. mMagneticField*kilogauss,
  447. pyLocalCharge);
  448. track->SetHelix(mHelix);
  449. track->SetHelixGlobal(mHelix);
  450. track->SetTopologyMap(0, 0.);
  451. track->SetTopologyMap(1, 0.);
  452. track->SetTrackId(iTrk);
  453. track->SetTofBeta(pyTrack.P()/pyParticle->GetEnergy());
  454. track->SetHiddenInfo(0);
  455. mHbtEvent->TrackCollection()->push_back(track);
  456. } //for (int iTrk=0; iTrk<mNumParticles; iTrk++)
  457. if(mSelPartNum>=1) {
  458. mEventIsGood = true;
  459. }
  460. } while(!mEventIsGood);
  461. mEventCounter++;
  462. mHbtEvent->SetEventNumber(mEventCounter);
  463. mHbtEvent->SetRunNumber(mEventCounter);
  464. mHbtEvent->SetCtbMult(0);
  465. mHbtEvent->SetZdcAdcEast(0);
  466. mHbtEvent->SetZdcAdcWest(0);
  467. mHbtEvent->SetNumberOfTpcHits(0);
  468. mHbtEvent->SetNumberOfTracks(pyRefMult);
  469. mHbtEvent->SetNumberOfGoodTracks(pyRefMult);
  470. mHbtEvent->SetReactionPlane(0.);
  471. mHbtEvent->SetReactionPlaneError(0.);
  472. mHbtEvent->SetReactionPlaneSubEventDifference(0.);
  473. mHbtEvent->SetPrimVertPos(mPrimVertPos);
  474. mHbtEvent->SetUncorrectedNumberOfPositivePrimaries(pyPosTrkNum);
  475. mHbtEvent->SetUncorrectedNumberOfNegativePrimaries(pyNegTrkNum);
  476. mHbtEvent->SetUncorrectedNumberOfPrimaries(pyRefMult);
  477. mHbtEvent->SetMagneticField(mMagneticField);
  478. mHbtEvent->SetVpdVz(mVpdVz);
  479. }
  480. //_________________
  481. void StHbtPythia6DstReader::V0Generation(StHbtEvent *mHbtEvent) {
  482. //Variables for the StHbtEvent
  483. StThreeVectorF mPrimVertPos = StThreeVectorF(0., 0., 0.);
  484. Float_t mVpdVz = 0.;
  485. Float_t mMagneticField = PYHIA_BFIELD;
  486. //added by gnigmat
  487. #ifdef STHBTDEBUG
  488. std::cout << "ReturnHbtEvent: start generation process" << std::endl;
  489. #endif
  490. //Array of generated particles
  491. TObjArray *pyParticles = NULL;
  492. TMCParticle *pyParticle = NULL;
  493. TMCParticle *pyPosParticle, *pyNegParticle;
  494. Int_t mNumParticles = 0;
  495. Int_t pyPosTrkNum = 0;
  496. Int_t pyNegTrkNum = 0;
  497. Int_t pyRefMult = 0;
  498. TLorentzVector pyTrack, pyPosTrack, pyNegTrack;
  499. float mPseudoRapidity;
  500. Int_t pyKF, pyKS, pyCharge;
  501. short pyLocalCharge = 0;
  502. Float_t pyTrkNSigmaElectron, pyTrkNSigmaPion;
  503. Float_t pyTrkNSigmaKaon, pyTrkNSigmaProton;
  504. Float_t pyTrkDCAxy, pyTrkDCAz, pyTrkMass;
  505. Int_t mV0Num = 0;
  506. //Start event generation here
  507. do {
  508. clear();
  509. mPythiaDst->GenerateEvent();
  510. pyParticles = mPythiaDst->GetListOfParticles();
  511. mEventTries++;
  512. if(!pyParticles) continue;
  513. mNumParticles = pyParticles->GetEntries();
  514. //mPythiaDst->Pylist(1);
  515. //Initialize counters
  516. mV0Num = 0;
  517. pyRefMult = 0;
  518. //Main particle loop
  519. for(Int_t iTrk=0; iTrk<mNumParticles; iTrk++) {
  520. pyKF = 0;
  521. pyKS = 0;
  522. pyCharge = 0;
  523. pyParticle = (TMCParticle*)pyParticles->At(iTrk);
  524. //Use final-state particles
  525. if(!pyParticle) continue;
  526. pyKF = pyParticle->GetKF();
  527. pyKS = pyParticle->GetKS();
  528. pyCharge = TDatabasePDG::Instance()->GetParticle(pyKF)->Charge();
  529. pyTrack.SetPxPyPzE(pyParticle->GetPx(),
  530. pyParticle->GetPy(),
  531. pyParticle->GetPz(),
  532. pyParticle->GetEnergy());
  533. //Calculate stable particles for refmult
  534. if(pyParticle->GetKS()==1) {
  535. if(pyTrack.P() < 0.1) continue;
  536. mPseudoRapidity = 0.5*TMath::Log( (pyTrack.P() + pyTrack.Pz()) /
  537. (pyTrack.P() - pyTrack.Pz()) );
  538. //Calculate multiplicity
  539. if( pyTrack.P() >= 0.1 && TMath::Abs(mPseudoRapidity)<=0.5 &&
  540. pyCharge!=0 ) {
  541. pyRefMult++;
  542. if(pyCharge>0) {
  543. pyPosTrkNum++;
  544. pyLocalCharge = 1;
  545. }
  546. else if( pyCharge<0) {
  547. pyNegTrkNum++;
  548. pyLocalCharge = -1;
  549. }
  550. }
  551. } //if(pyParticle->GetKS()==1)
  552. //Select V0s here
  553. if(pyKF==333) {
  554. //Factor 10 converts mm to cm
  555. pyTrkDCAxy = TMath::Sqrt(pyParticle->GetVx()*pyParticle->GetVx() +
  556. pyParticle->GetVy()*pyParticle->GetVy()) / 10;
  557. pyTrkDCAz = pyParticle->GetVz() / 10;
  558. Float_t pyTrkDCA2PrimVtx = TMath::Sqrt(pyParticle->GetVx()*pyParticle->GetVx() +
  559. pyParticle->GetVy()*pyParticle->GetVy() +
  560. pyParticle->GetVz()*pyParticle->GetVz()) / 10;
  561. pyTrkMass = pyParticle->GetMass();
  562. Int_t mFirstDaughterId = pyParticle->GetFirstChild();
  563. Int_t mSecondDaugherId = pyParticle->GetLastChild();
  564. Int_t pyPosCharge = 0;
  565. Int_t pyNegCharge = 0;
  566. Int_t pyPosKF = 0;
  567. Int_t pyNegKF = 0;
  568. Int_t pyPosId;
  569. Int_t pyNegId;
  570. pyPosParticle = (TMCParticle*)pyParticles->At(mFirstDaughterId-1);
  571. pyNegParticle = (TMCParticle*)pyParticles->At(mSecondDaugherId-1);
  572. pyPosKF = pyPosParticle->GetKF();
  573. pyNegKF = pyNegParticle->GetKF();
  574. pyPosTrack.SetPxPyPzE(pyPosParticle->GetPx(), pyPosParticle->GetPy(),
  575. pyPosParticle->GetPz(), pyPosParticle->GetEnergy());
  576. pyNegTrack.SetPxPyPzE(pyNegParticle->GetPx(), pyNegParticle->GetPy(),
  577. pyNegParticle->GetPz(), pyNegParticle->GetEnergy());
  578. //phi->K+K- only.
  579. if(TMath::Abs(pyPosKF)!=321 || TMath::Abs(pyNegKF)!=321 ||
  580. pyPosTrack.P()<0.1 || pyPosTrack.PseudoRapidity()>1.1 ||
  581. pyNegTrack.P()<0.1 || pyNegTrack.PseudoRapidity()>1.1) continue;
  582. pyPosCharge = TDatabasePDG::Instance()->GetParticle(pyPosKF)->Charge();
  583. pyNegCharge = TDatabasePDG::Instance()->GetParticle(pyNegKF)->Charge();
  584. if(pyPosCharge>0 && pyNegCharge<0) {
  585. pyPosId = mFirstDaughterId;
  586. pyNegId = mSecondDaugherId;
  587. }
  588. else if(pyPosCharge<0 && pyNegCharge>0) { //Switch positive and negative daughters
  589. pyPosParticle = (TMCParticle*)pyParticles->At(mSecondDaugherId-1);
  590. pyNegParticle = (TMCParticle*)pyParticles->At(mFirstDaughterId-1);
  591. pyPosKF = pyPosParticle->GetKF();
  592. pyNegKF = pyNegParticle->GetKF();
  593. pyPosCharge = TDatabasePDG::Instance()->GetParticle(pyPosKF)->Charge();
  594. pyNegCharge = TDatabasePDG::Instance()->GetParticle(pyNegKF)->Charge();
  595. pyPosTrack.SetPxPyPzE(pyPosParticle->GetPx(), pyPosParticle->GetPy(),
  596. pyPosParticle->GetPz(), pyPosParticle->GetEnergy());
  597. pyNegTrack.SetPxPyPzE(pyNegParticle->GetPx(), pyNegParticle->GetPy(),
  598. pyNegParticle->GetPz(), pyNegParticle->GetEnergy());
  599. pyNegId = mFirstDaughterId;
  600. pyPosId = mSecondDaugherId;
  601. }
  602. #ifdef STHBTDEBUG
  603. std::cout << "V0 is found: " << std::endl
  604. << Form("KF: %5d mass: %5.3f mom: %5.3f PosChildId: %d NegChildId: %d",
  605. pyKF, pyParticle->GetMass(), pyTrack.P(), pyPosId, pyNegId) << std::endl
  606. << Form("PosChild KF: %5d mass: %5.3f mom: %5.3f charge: %d",
  607. pyPosKF, pyPosParticle->GetMass(), pyPosTrack.P(), pyPosCharge) << std::endl
  608. << Form("NegChild KF: %5d mass: %5.3f mom: %5.3f charge: %d",
  609. pyNegKF, pyNegParticle->GetMass(), pyNegTrack.P(), pyNegCharge) << std::endl;
  610. #endif
  611. Float_t mDecayLengthV0 = TMath::Sqrt( pyParticle->GetVx()*pyParticle->GetVx() +
  612. pyParticle->GetVy()*pyParticle->GetVy() +
  613. pyParticle->GetVz()*pyParticle->GetVz() )/10;
  614. //Increment number of V0s
  615. mV0Num++;
  616. //Create an instance ov StHbtV0, fill it and add to mHbtEvent
  617. StHbtV0 *mHbtV0 = new StHbtV0;
  618. mHbtV0->SetdecayLengthV0(mDecayLengthV0);
  619. mHbtV0->SetdecayVertexV0( StHbtThreeVector(pyParticle->GetVx() * 0.1,
  620. pyParticle->GetVy() * 0.1,
  621. pyParticle->GetVz() * 0.1) );
  622. mHbtV0->SetdcaV0Daughters(0.);
  623. mHbtV0->SetmomV0( StHbtThreeVector(pyParticle->GetPx(), pyParticle->GetPy(),
  624. pyParticle->GetPz()) );
  625. mHbtV0->SetprimaryVertex( StHbtThreeVector(0., 0., 0.) );
  626. mHbtV0->SetHiddenInfo(0);
  627. //Positively charged daughter
  628. switch(TMath::Abs(pyPosKF)) {
  629. case 211:
  630. pyTrkNSigmaElectron = -999.;
  631. pyTrkNSigmaPion = 0.;
  632. pyTrkNSigmaKaon = -999.;
  633. pyTrkNSigmaProton = -999.;
  634. break;
  635. case 321:
  636. pyTrkNSigmaElectron = -999.;
  637. pyTrkNSigmaPion = -999.;
  638. pyTrkNSigmaKaon = 0.;
  639. pyTrkNSigmaProton = -999.;
  640. break;
  641. case 2212:
  642. pyTrkNSigmaElectron = -999.;
  643. pyTrkNSigmaPion = -999.;
  644. pyTrkNSigmaKaon = -999.;
  645. pyTrkNSigmaProton = 0.;
  646. break;
  647. default:
  648. pyTrkNSigmaElectron = -999.;
  649. pyTrkNSigmaPion = -999.;
  650. pyTrkNSigmaKaon = -999.;
  651. pyTrkNSigmaProton = -999.;
  652. };
  653. mHbtV0->SetdcaPosToPrimVertex(pyTrkDCA2PrimVtx);
  654. mHbtV0->SetmomPos( StHbtThreeVector(pyPosTrack.Px(), pyPosTrack.Py(), pyPosTrack.Pz()) );
  655. mHbtV0->SettpcHitsPos(45);
  656. //mHbtV0->SetnHitsFitPos(45);
  657. mHbtV0->SetnHitsPossiblePos(45);
  658. mHbtV0->SetidPos(pyPosId);
  659. mHbtV0->SetkeyPos(pyPosId);
  660. mHbtV0->SetdedxPos( dedxMean(pyPosTrack.P(), pyPosParticle->GetMass()) );
  661. mHbtV0->SetlendedxPos(150.);
  662. mHbtV0->SetnSigmaElectronPos(pyTrkNSigmaElectron);
  663. mHbtV0->SetnSigmaPionPos(pyTrkNSigmaPion);
  664. mHbtV0->SetnSigmaKaonPos(pyTrkNSigmaKaon);
  665. mHbtV0->SetnSigmaProtonPos(pyTrkNSigmaProton);
  666. mHbtV0->SettofBetaPos(pyPosTrack.P()/pyPosTrack.Energy());
  667. StPhysicalHelixD mHelixPos = StPhysicalHelixD(StThreeVectorF(pyPosTrack.Px(),
  668. pyPosTrack.Py(),
  669. pyPosTrack.Pz()),
  670. StThreeVectorF(0.,0.,0.),
  671. mMagneticField*kilogauss,
  672. pyPosCharge);
  673. mHbtV0->SetHelixPos(mHelixPos);
  674. mHbtV0->SetTrackTopologyMapPos(0, 0.);
  675. mHbtV0->SetTrackTopologyMapPos(1, 0.);
  676. //Negatively charged daughter
  677. switch(TMath::Abs(pyNegKF)) {
  678. case 211:
  679. pyTrkNSigmaElectron = -999.;
  680. pyTrkNSigmaPion = 0.;
  681. pyTrkNSigmaKaon = -999.;
  682. pyTrkNSigmaProton = -999.;
  683. break;
  684. case 321:
  685. pyTrkNSigmaElectron = -999.;
  686. pyTrkNSigmaPion = -999.;
  687. pyTrkNSigmaKaon = 0.;
  688. pyTrkNSigmaProton = -999.;
  689. break;
  690. case 2212:
  691. pyTrkNSigmaElectron = -999.;
  692. pyTrkNSigmaPion = -999.;
  693. pyTrkNSigmaKaon = -999.;
  694. pyTrkNSigmaProton = 0.;
  695. break;
  696. default:
  697. pyTrkNSigmaElectron = -999.;
  698. pyTrkNSigmaPion = -999.;
  699. pyTrkNSigmaKaon = -999.;
  700. pyTrkNSigmaProton = -999.;
  701. };
  702. mHbtV0->SetdcaNegToPrimVertex(pyTrkDCA2PrimVtx);
  703. mHbtV0->SetmomNeg( StHbtThreeVector(pyNegTrack.Px(), pyNegTrack.Py(), pyNegTrack.Pz()) );
  704. mHbtV0->SettpcHitsNeg(45);
  705. //mHbtV0->SetnHitsFitNeg(45);
  706. mHbtV0->SetnHitsPossibleNeg(45);
  707. mHbtV0->SetidNeg(pyNegId);
  708. mHbtV0->SetkeyNeg(pyNegId);
  709. mHbtV0->SetdedxNeg( dedxMean(pyNegTrack.P(), pyNegParticle->GetMass()) );
  710. mHbtV0->SetlendedxNeg(150.);
  711. mHbtV0->SetnSigmaElectronNeg(pyTrkNSigmaElectron);
  712. mHbtV0->SetnSigmaPionNeg(pyTrkNSigmaPion);
  713. mHbtV0->SetnSigmaKaonNeg(pyTrkNSigmaKaon);
  714. mHbtV0->SetnSigmaProtonNeg(pyTrkNSigmaProton);
  715. mHbtV0->SettofBetaNeg(pyNegTrack.P()/pyNegTrack.Energy());
  716. StPhysicalHelixD mHelixNeg = StPhysicalHelixD(StThreeVectorF(pyNegTrack.Px(),
  717. pyNegTrack.Py(),
  718. pyNegTrack.Pz()),
  719. StThreeVectorF(0.,0.,0.),
  720. mMagneticField*kilogauss,
  721. pyNegCharge);
  722. mHbtV0->SetHelixNeg(mHelixNeg);
  723. mHbtV0->SetTrackTopologyMapNeg(0, 0.);
  724. mHbtV0->SetTrackTopologyMapNeg(1, 0.);
  725. mHbtV0->UpdateV0();
  726. mHbtEvent->V0Collection()->push_back(mHbtV0);
  727. } //if(pyKF==333)
  728. } //for (int iTrk=0; iTrk<mNumParticles; iTrk++)
  729. if(mV0Num>=1) {
  730. mEventIsGood = true;
  731. }
  732. } while(!mEventIsGood);
  733. mEventCounter++;
  734. mHbtEvent->SetEventNumber(mEventCounter);
  735. mHbtEvent->SetRunNumber(mEventCounter);
  736. mHbtEvent->SetCtbMult(0);
  737. mHbtEvent->SetZdcAdcEast(45000);
  738. mHbtEvent->SetZdcAdcWest(45000);
  739. mHbtEvent->SetNumberOfTpcHits(450);
  740. mHbtEvent->SetNumberOfTracks(pyRefMult);
  741. mHbtEvent->SetNumberOfGoodTracks(pyRefMult);
  742. mHbtEvent->SetReactionPlane(0.);
  743. mHbtEvent->SetReactionPlaneError(0.);
  744. mHbtEvent->SetReactionPlaneSubEventDifference(0.);
  745. mHbtEvent->SetPrimVertPos(mPrimVertPos);
  746. mHbtEvent->SetUncorrectedNumberOfPositivePrimaries(pyPosTrkNum);
  747. mHbtEvent->SetUncorrectedNumberOfNegativePrimaries(pyNegTrkNum);
  748. mHbtEvent->SetUncorrectedNumberOfPrimaries(pyRefMult);
  749. mHbtEvent->SetMagneticField(mMagneticField);
  750. mHbtEvent->SetVpdVz(mVpdVz);
  751. }