284 #ifndef ST_NO_NAMESPACES
292 #include "StMcEventMaker.h"
294 #include "PhysicalConstants.h"
295 #include "SystemOfUnits.h"
296 #include "StGlobals.hh"
297 #include "StMessMgr.h"
298 #include "StMemoryInfo.hh"
299 #include "StTimer.hh"
301 #include "StThreeVectorF.hh"
302 #include "StParticleDefinition.hh"
304 #include "St_DataSet.h"
305 #include "St_DataSetIter.h"
307 #include "tables/St_g2t_event_Table.h"
308 #include "tables/St_g2t_ftp_hit_Table.h"
309 #include "tables/St_g2t_rch_hit_Table.h"
310 #include "tables/St_g2t_ctf_hit_Table.h"
311 #include "tables/St_g2t_mtd_hit_Table.h"
312 #include "tables/St_g2t_svt_hit_Table.h"
313 #include "tables/St_g2t_ssd_hit_Table.h"
314 #include "tables/St_g2t_tpc_hit_Table.h"
315 #include "tables/St_g2t_emc_hit_Table.h"
316 #include "tables/St_g2t_pix_hit_Table.h"
317 #include "tables/St_g2t_ist_hit_Table.h"
318 #include "tables/St_g2t_fgt_hit_Table.h"
319 #include "tables/St_g2t_etr_hit_Table.h"
320 #include "tables/St_g2t_track_Table.h"
321 #include "tables/St_g2t_vertex_Table.h"
322 #include "tables/St_particle_Table.h"
324 #include "StMcEventTypes.hh"
326 #include "StEmcUtil/geometry/StEmcGeom.h"
329 #include "StEEmcUtil/EEmcMC/EEmcMCData.h"
331 static double vertexCut = .0000025;
336 static const char rcsid[] =
"$Id: StMcEventMaker.cxx,v 1.79 2016/08/04 01:54:33 perev Exp $";
337 static long NTracks = 0;
340 #define AddHit2Track(G2Type,DET) \
341 Int_t iTrkId = ( G2Type ## HitTable[ihit].track_p) - 1; \
342 if (iTrkId >= 0 && iTrkId < NTracks ) { \
343 th->setParentTrack(ttemp[iTrkId]); \
344 ttemp[iTrkId]->add ## DET ## Hit(th); \
346 #define AddHits(G2Type,det,DET) \
347 if (doUse ## DET) { \
348 if (g2t_ ## G2Type ## _hitTablePointer) { \
349 StMc ## DET ## Hit* th = 0; \
350 Int_t NHits = g2t_ ## G2Type ## _hitTablePointer->GetNRows(); \
351 for(Int_t ihit=0; ihit<NHits; ihit++) { \
352 th = new StMc ## DET ## Hit(& G2Type ## HitTable[ihit]); \
353 mCurrentMcEvent-> det ## HitCollection()->addHit(th); \
354 AddHit2Track(G2Type,DET); \
356 if (Debug()) cout << "Filled " << mCurrentMcEvent-> det ## HitCollection()->numberOfHits() << #DET << " Hits" << endl; \
357 } else if (Debug()) cout << "No " << #DET << "/" << #det << " Hits in this event" << endl; \
363 StMcEventMaker::StMcEventMaker(
const char*name,
const char * title) :
365 doPrintEventInfo (kFALSE),
366 doPrintMemoryInfo(kFALSE),
367 doPrintCpuInfo (kFALSE),
395 StMcEventMaker::~StMcEventMaker()
398 if (Debug()>=2) cout <<
"Inside ReaderMaker Destructor" << endl;
406 void StMcEventMaker::Clear(
const char*)
410 if (mCurrentMcEvent) {
415 StMemoryInfo::instance()->snapshot();
416 StMemoryInfo::instance()->print();
435 Int_t StMcEventMaker::Init()
437 if (Debug()>=1) cout <<
"This is StMcEventMaker::Init() - by Ming" << endl;
438 return StMaker::Init();
446 if (doPrintCpuInfo) timer.start();
449 if (Debug()>=1) cout <<
"Inside StMcEventMaker::Make()" << endl;
452 const Char_t* geaTmp[3]={
"geant",
"event/geant/Event",
"bfcTree/geantBranch"};
454 for(UInt_t i=0; i<3; i++){
455 dsGeant = GetDataSet(geaTmp[i]);
456 if(!dsGeant || !dsGeant->GetList()) {
457 gMessMgr->Warning() <<
"Could not find dataset " << geaTmp[i] << endm;
458 dsGeant = GetDataSet(
"event/geant/Event");
460 if (Debug()) gMessMgr->Info() <<
"Get Geant info from dataset " << geaTmp[i] << endm;
493 St_g2t_event *g2t_eventTablePointer = (St_g2t_event *) geantDstI(
"g2t_event");
494 St_g2t_vertex *g2t_vertexTablePointer = (St_g2t_vertex *) geantDstI(
"g2t_vertex");
495 St_g2t_track *g2t_trackTablePointer = (St_g2t_track *) geantDstI(
"g2t_track");
496 St_g2t_tpc_hit *g2t_tpc_hitTablePointer = (St_g2t_tpc_hit *) geantDstI(
"g2t_tpc_hit");
497 St_g2t_svt_hit *g2t_svt_hitTablePointer = (St_g2t_svt_hit *) geantDstI(
"g2t_svt_hit");
498 St_g2t_ssd_hit *g2t_ssd_hitTablePointer = (St_g2t_ssd_hit *) geantDstI(
"g2t_ssd_hit");
499 St_g2t_ftp_hit *g2t_ftp_hitTablePointer = (St_g2t_ftp_hit *) geantDstI(
"g2t_ftp_hit");
500 St_g2t_rch_hit *g2t_rch_hitTablePointer = (St_g2t_rch_hit *) geantDstI(
"g2t_rch_hit");
501 St_g2t_emc_hit *g2t_emc_hitTablePointer = (St_g2t_emc_hit *) geantDstI(
"g2t_emc_hit");
502 St_g2t_emc_hit *g2t_smd_hitTablePointer = (St_g2t_emc_hit *) geantDstI(
"g2t_smd_hit");
503 St_g2t_ctf_hit *g2t_ctb_hitTablePointer = (St_g2t_ctf_hit *) geantDstI(
"g2t_ctb_hit");
504 St_g2t_ctf_hit *g2t_tof_hitTablePointer = (St_g2t_ctf_hit *) geantDstI(
"g2t_tof_hit");
505 St_g2t_ctf_hit *g2t_tfr_hitTablePointer = (St_g2t_ctf_hit *) geantDstI(
"g2t_tfr_hit");
506 St_g2t_mtd_hit *g2t_mtd_hitTablePointer = (St_g2t_mtd_hit *) geantDstI(
"g2t_mtd_hit");
507 St_g2t_emc_hit *g2t_eem_hitTablePointer = (St_g2t_emc_hit *) geantDstI(
"g2t_eem_hit");
508 St_g2t_emc_hit *g2t_esm_hitTablePointer = (St_g2t_emc_hit *) geantDstI(
"g2t_esm_hit");
509 St_g2t_emc_hit *g2t_fpd_hitTablePointer = (St_g2t_emc_hit *) geantDstI(
"g2t_fpd_hit");
510 St_g2t_emc_hit *g2t_fsc_hitTablePointer = (St_g2t_emc_hit *) geantDstI(
"g2t_fsc_hit");
511 St_g2t_pix_hit *g2t_pix_hitTablePointer = (St_g2t_pix_hit *) geantDstI(
"g2t_pix_hit");
512 St_g2t_ist_hit *g2t_ist_hitTablePointer = (St_g2t_ist_hit *) geantDstI(
"g2t_ist_hit");
513 St_g2t_fgt_hit *g2t_fgt_hitTablePointer = (St_g2t_fgt_hit *) geantDstI(
"g2t_fgt_hit");
514 St_g2t_etr_hit *g2t_etr_hitTablePointer = (St_g2t_etr_hit *) geantDstI(
"g2t_etr_hit");
515 St_particle *particleTablePointer = (St_particle *) geantDstI(
"particle");
521 if (!particleTablePointer)
522 particleTablePointer = (St_particle *) dstDstI(
"particle");
523 if (!g2t_rch_hitTablePointer)
524 g2t_rch_hitTablePointer = (St_g2t_rch_hit *) dstDstI(
"g2t_rch_hit");
528 if (g2t_vertexTablePointer && g2t_trackTablePointer){
529 long NVertices = g2t_vertexTablePointer->GetNRows();
530 NTracks = g2t_trackTablePointer->GetNRows();
531 if (NVertices > 0 && NTracks > 0) {
535 g2t_event_st *eventTable = 0;
538 if (g2t_eventTablePointer)
539 eventTable = g2t_eventTablePointer->GetTable();
541 if (Debug()) cerr <<
"Table g2t_event Not found in Dataset " << geantDstI.Pwd()->GetName() << endl;
544 if(!g2t_eventTablePointer->GetNRows()) {
545 cout <<
"Event Table is EMPTY!! " << endl;
546 PR(g2t_eventTablePointer->GetNRows());
552 g2t_vertex_st *vertexTable = g2t_vertexTablePointer->GetTable();
553 g2t_track_st *trackTable = g2t_trackTablePointer->GetTable();
558 g2t_tpc_hit_st *tpcHitTable = 0;
559 if (g2t_tpc_hitTablePointer)
560 tpcHitTable = g2t_tpc_hitTablePointer->GetTable();
562 if (Debug()) cerr <<
"Table g2t_tpc_hit Not found in Dataset " << geantDstI.Pwd()->GetName() << endl;
566 g2t_ftp_hit_st *ftpHitTable = 0;
567 if (g2t_ftp_hitTablePointer)
568 ftpHitTable = g2t_ftp_hitTablePointer->GetTable();
570 if (Debug()) cerr <<
"Table g2t_ftp_hit Not found in Dataset " << geantDstI.Pwd()->GetName() << endl;
575 g2t_svt_hit_st *svtHitTable = 0;
576 if (g2t_svt_hitTablePointer)
577 svtHitTable = g2t_svt_hitTablePointer->GetTable();
579 if (Debug()) cerr <<
"Table g2t_svt_hit Not found in Dataset " << geantDstI.Pwd()->GetName() << endl;
584 g2t_ssd_hit_st *ssdHitTable = 0;
585 if (g2t_ssd_hitTablePointer)
586 ssdHitTable = g2t_ssd_hitTablePointer->GetTable();
588 if (Debug()) cerr <<
"Table g2t_ssd_hit Not found in Dataset " << geantDstI.Pwd()->GetName() << endl;
593 g2t_rch_hit_st *rchHitTable = 0;
594 if (g2t_rch_hitTablePointer)
595 rchHitTable = g2t_rch_hitTablePointer->GetTable();
597 if (Debug()) cerr <<
"Table g2t_rch_hit Not found in Dataset " << geantDstI.Pwd()->GetName() << endl;
601 g2t_ctf_hit_st *ctbHitTable = 0;
602 if (g2t_ctb_hitTablePointer)
603 ctbHitTable = g2t_ctb_hitTablePointer->GetTable();
605 if (Debug()) cerr <<
"Table g2t_rch_hit Not found in Dataset " << geantDstI.Pwd()->GetName() << endl;
609 g2t_ctf_hit_st *tofHitTable = 0;
610 if (g2t_tof_hitTablePointer)
611 tofHitTable = g2t_tof_hitTablePointer->GetTable();
613 if (Debug()) cerr <<
"Table g2t_tof_hit Not found in Dataset " << geantDstI.Pwd()->GetName() << endl;
615 g2t_ctf_hit_st *tfrHitTable = 0;
616 if (g2t_tfr_hitTablePointer)
617 tfrHitTable = g2t_tfr_hitTablePointer->GetTable();
619 if (Debug()) cerr <<
"Table g2t_tfr_hit Not found in Dataset " << geantDstI.Pwd()->GetName() << endl;
623 g2t_mtd_hit_st *mtdHitTable = 0;
624 if (g2t_mtd_hitTablePointer)
625 mtdHitTable = g2t_mtd_hitTablePointer->GetTable();
627 if (Debug()) cerr <<
"Table g2t_mtd_hit Not found in Dataset " << geantDstI.Pwd()->GetName() << endl;
632 g2t_emc_hit_st *emcHitTable = 0;
633 if (g2t_emc_hitTablePointer)
634 emcHitTable = g2t_emc_hitTablePointer->GetTable();
636 if (Debug()) cerr <<
"Table g2t_emc_hit Not found in Dataset " << geantDstI.Pwd()->GetName() << endl;
641 g2t_emc_hit_st *smdHitTable = 0;
642 if (g2t_smd_hitTablePointer)
643 smdHitTable = g2t_smd_hitTablePointer->GetTable();
645 if (Debug()) cerr <<
"Table g2t_smd_hit Not found in Dataset " << geantDstI.Pwd()->GetName() << endl;
650 g2t_emc_hit_st *eemHitTable = 0;
651 if (g2t_eem_hitTablePointer)
652 eemHitTable = g2t_eem_hitTablePointer->GetTable();
654 if (Debug()) cerr <<
"Table g2t_eem_hit Not found in Dataset " << geantDstI.Pwd()->GetName() << endl;
659 g2t_emc_hit_st *esmHitTable = 0;
660 if (g2t_esm_hitTablePointer)
661 esmHitTable = g2t_esm_hitTablePointer->GetTable();
663 if (Debug()) cerr <<
"Table g2t_esm_hit Not found in Dataset " << geantDstI.Pwd()->GetName() << endl;
668 g2t_emc_hit_st* fpdHitTable = 0;
669 if (g2t_fpd_hitTablePointer)
670 fpdHitTable = g2t_fpd_hitTablePointer->GetTable();
672 if (Debug()) cout <<
"Table g2t_fpd_hit Not found in Dataset " << geantDstI.Pwd()->GetName() << endl;
677 g2t_emc_hit_st* fscHitTable = 0;
678 if (g2t_fsc_hitTablePointer)
679 fscHitTable = g2t_fsc_hitTablePointer->GetTable();
681 if (Debug()) cout <<
"Table g2t_fsc_hit Not found in Dataset " << geantDstI.Pwd()->GetName() << endl;
686 g2t_pix_hit_st *pixHitTable=0;
687 if (g2t_pix_hitTablePointer)
688 pixHitTable = g2t_pix_hitTablePointer->GetTable();
690 if (Debug()) cerr <<
"Table g2t_pix_hit Not found in Dataset " << geantDstI.Pwd()->GetName() << endl;
695 g2t_ist_hit_st *istHitTable=0;
696 if (g2t_ist_hitTablePointer)
697 istHitTable = g2t_ist_hitTablePointer->GetTable();
699 if (Debug()) cerr <<
"Table g2t_ist_hit Not found in Dataset " << geantDstI.Pwd()->GetName() << endl;
703 g2t_fgt_hit_st *fgtHitTable=0;
704 if (g2t_fgt_hitTablePointer)
705 fgtHitTable = g2t_fgt_hitTablePointer->GetTable();
707 if (Debug()) cerr <<
"Table g2t_fgt_hit Not found in Dataset " << geantDstI.Pwd()->GetName() << endl;
712 g2t_etr_hit_st *etrHitTable=0;
713 if (g2t_etr_hitTablePointer)
714 etrHitTable = g2t_etr_hitTablePointer->GetTable();
715 if (Debug()) cerr <<
"Table g2t_etr_hit found in Dataset " << geantDstI.Pwd()->GetName() << endl;
717 if (Debug()) cerr <<
"Table g2t_etr_hit Not found in Dataset " << geantDstI.Pwd()->GetName() << endl;
722 particle_st *particleTable = 0;
723 if (particleTablePointer)
724 particleTable = particleTablePointer->GetTable();
726 if (Debug()) cerr <<
"Table particle Not found in Dataset " << geantDstI.Pwd()->GetName() << endl;
779 mCurrentMcEvent =
new StMcEvent(eventTable);
781 gMessMgr->Warning() <<
"StMcEventMaker::Make(): g2t_event Table not found. Using default constructor." << endm;
785 if (mCurrentMcEvent) {
786 if (Debug()) cout <<
"**** Created new StMcEvent, Event No. " << mCurrentMcEvent->eventNumber() << endl;
789 gMessMgr->Warning() <<
"Could not create StMcEvent! Exit from StMcEventMaker." << endm;
797 vector<vertexFlag> vtemp(NVertices);
799 if (Debug()>=1) cout <<
"Preparing to process and fill VERTEX information ....." << endl;
806 mCurrentMcEvent->vertices().push_back(v);
807 vtemp[vertexTable[0].id - 1].vtx = v;
808 vtemp[vertexTable[0].id - 1].primaryFlag = 1;
809 mCurrentMcEvent->setPrimaryVertex(v);
814 int nThrownVertices = 0;
815 for (
long ivtx=1; ivtx<NVertices; ivtx++)
820 testVertexPos = v->position();
822 if (vertexTable[ivtx].eg_label == 0 ||
823 abs(primVertexPos - testVertexPos) > vertexCut ) {
825 mCurrentMcEvent->vertices().push_back(v);
826 vtemp[vertexTable[ivtx].id - 1].primaryFlag = 0;
827 vtemp[vertexTable[ivtx].id - 1].vtx = v;
831 vtemp[vertexTable[ivtx].id - 1].primaryFlag = 1;
834 vtemp[vertexTable[ivtx].id - 1].vtx = mCurrentMcEvent->primaryVertex();
838 gMessMgr->Warning() <<
"StMcEventMaker::Make(): Throwing " << nThrownVertices
839 <<
" that are the same as the primary vertex." << endm;
844 size_t usedTracksG2t = 0;
845 long NGeneratorTracks = (particleTablePointer) ? particleTablePointer->GetNRows() : 0;
846 size_t usedTracksEvGen = 0;
847 ttemp.resize(NTracks);
848 ttempParticle.resize(NGeneratorTracks);
849 if (Debug()>=1) cout <<
"Preparing to process and fill TRACK information ....." << endl;
851 size_t nParticlesInBothTables = 0;
852 if (Debug()>=1) cout <<
"Event Generator Tracks..." << endl;
858 long motherIndex = -1;
859 {
for (
long gtrk=0; gtrk<NGeneratorTracks; gtrk++) {
861 egTrk =
new StMcTrack(&(particleTable[gtrk]));
862 egTrk->setEventGenLabel(gtrk+1);
863 egTrk->setPrimary(0);
864 ttempParticle[gtrk] = egTrk;
865 mCurrentMcEvent->tracks().push_back(egTrk);
871 long iStartVtxId = 0;
873 long iItrmdVtxId = 0;
875 int nThrownTracks = 0;
876 if (Debug()>=1) cout <<
"g2t Tracks..." << endl;
878 {
for (
long itrk=0; itrk<NTracks; itrk++) {
879 iStopVtxId = (trackTable[itrk].stop_vertex_p) - 1;
881 if (iStopVtxId >= 0) {
882 if (vtemp[iStopVtxId].primaryFlag == 1) {
890 if (trackTable[itrk].e<trackTable[itrk].ptot)
891 trackTable[itrk].ptot=trackTable[itrk].e;
893 if (trackTable[itrk].ge_pid<0) trackTable[itrk].ge_pid=0;
894 if (trackTable[itrk].ge_pid>0xffff) trackTable[itrk].ge_pid=0;
898 ttemp[ trackTable[itrk].id - 1 ] = t;
901 mCurrentMcEvent->tracks().push_back(t);
905 if (iStopVtxId >= 0) {
906 t->setStopVertex(vtemp[iStopVtxId].vtx);
907 vtemp[iStopVtxId].vtx->setParent(t);
914 iStartVtxId = trackTable[itrk].start_vertex_p - 1;
916 v = vtemp[iStartVtxId].vtx;
918 t->setStartVertex(v);
919 t->setPrimary(t->startVertex() == mCurrentMcEvent->primaryVertex() ? kTRUE : kFALSE);
926 iItrmdVtxId = (trackTable[itrk].itrmd_vertex_p) - 1;
928 if (iItrmdVtxId >= 0) {
929 t->intermediateVertices().push_back(vtemp[iItrmdVtxId].vtx);
931 vtemp[iItrmdVtxId].vtx->setParent(t);
935 while(vertexTable[iItrmdVtxId].next_itrmd_p != 0) {
936 iItrmdVtxId = (vertexTable[iItrmdVtxId].next_itrmd_p) - 1;
937 t->intermediateVertices().push_back(vtemp[iItrmdVtxId].vtx);
938 vtemp[iItrmdVtxId].vtx->setParent(t);
946 long iEventGeneratorLabel = (trackTable[itrk].eg_label) - 1;
947 if (iEventGeneratorLabel >=0 ) {
952 if (iEventGeneratorLabel < NGeneratorTracks) {
958 nParticlesInBothTables++;
960 if (particleTable[iEventGeneratorLabel].jmohep[0] && !(ttempParticle[particleTable[iEventGeneratorLabel].jmohep[0]])) {
961 cout <<
"There should be a parent and there isn't one!\n";
962 PR(iEventGeneratorLabel);
963 PR(particleTable[iEventGeneratorLabel].jmohep[0]);
964 PR(ttempParticle[particleTable[iEventGeneratorLabel].jmohep[0]]);
968 if (particleTable[iEventGeneratorLabel].jmohep[0])
969 t->setParent(ttempParticle[particleTable[iEventGeneratorLabel].jmohep[0]]);
970 StMcTrackIterator trkToErase = find (mCurrentMcEvent->tracks().begin(),
971 mCurrentMcEvent->tracks().end(),
972 ttempParticle[iEventGeneratorLabel]);
975 mCurrentMcEvent->tracks().erase(trkToErase);
977 ttempParticle[iEventGeneratorLabel] = t;
984 motherIndex = trackTable[itrk].next_parent_p;
985 if ((motherIndex > 0) && (motherIndex <= NTracks)) {
986 if (motherIndex > itrk+1) {
989 <<
"Wrong ordering! Track " << itrk+1 <<
"from particle table: "
990 <<
"Can't assign mother track " << motherIndex
991 <<
"because it has not been created yet!" << endm;
994 else {t->setParent(ttemp[motherIndex-1]);}
998 {
for (
long gtrk=0; gtrk<NGeneratorTracks; gtrk++) {
1000 motherIndex = particleTable[gtrk].jmohep[0];
1001 if ((motherIndex > 0) && (motherIndex <= NGeneratorTracks)) {
1002 if (motherIndex > gtrk+1) {
1005 <<
"Wrong ordering! Track " << gtrk+1 <<
" from particle table: "
1006 <<
"Can't assign mother track " << motherIndex
1007 <<
" to track with index " << gtrk << endm;
1010 else ttempParticle[gtrk]->setParent(ttempParticle[motherIndex-1]);
1012 cout <<
"Particle table (generator) track " << gtrk <<
", key " << ttempParticle[gtrk]->key() << endl;
1013 cout <<
"Mother Index-1 (off-by-1) " << motherIndex-1 << endl;
1014 cout <<
"PDG ID of generator track " << particleTable[gtrk].idhep << endl;
1015 cout <<
"PDG ID of mother track " << particleTable[motherIndex-1].idhep << endl;
1016 if (ttempParticle[gtrk]->particleDefinition())
1017 cout <<
"particle " << ttempParticle[gtrk]->particleDefinition()->name() << endl;
1018 if (ttempParticle[gtrk]->parent() && ttempParticle[gtrk]->parent()->particleDefinition())
1019 cout <<
"parent " << ttempParticle[gtrk]->parent()->particleDefinition()->name() << endl;
1021 if (motherIndex && !(ttempParticle[gtrk]->parent())) {
1022 cout <<
"Error in assigning parent to particle table!\n There should be a parent and there isn't one!\n";
1023 PR(particleTable[gtrk].jmohep[0]);
1024 PR(ttempParticle[gtrk]->parent());
1030 gMessMgr->Warning() <<
"StMcEventMaker::Make(): Throwing " << nThrownTracks
1031 <<
" whose stop vertex is the same as primary vertex." << endm;
1034 for (
long gtrk=0; gtrk<NGeneratorTracks; gtrk++)
1035 if (ttempParticle[gtrk]->parent() && ttempParticle[gtrk]->parent() != ttempParticle[particleTable[gtrk].jmohep[0]-1]) {
1036 cout <<
"The indexing got screwed up!" << endl;
1037 PR(ttempParticle[gtrk]->eventGenLabel());
1038 PR(ttempParticle[gtrk]->key());
1039 PR(ttempParticle[gtrk]->parent());
1040 PR(ttempParticle[particleTable[gtrk].jmohep[0]-1]);
1041 if (ttempParticle[gtrk]->particleDefinition()) cout <<
"particle " << ttempParticle[gtrk]->particleDefinition()->name() << endl;
1042 if (ttempParticle[gtrk]->parent() && ttempParticle[gtrk]->parent()->particleDefinition()) cout <<
"parent " << ttempParticle[gtrk]->parent()->particleDefinition()->name() << endl;
1045 cout <<
"Used tracks from g2t_track table: " << usedTracksG2t << endl;
1046 cout <<
"Avail. tracks from g2t_track table: " << NTracks << endl;
1047 cout <<
"Used tracks from particle table: " << usedTracksEvGen << endl;
1048 cout <<
"Avail. tracks from particle table: " << NGeneratorTracks << endl;
1049 cout <<
"Tracks appearing in both tables : " << nParticlesInBothTables << endl;
1050 cout <<
"Total tracks in StMcEvent : " << mCurrentMcEvent->tracks().size() << endl;
1053 ttempParticle.clear();
1058 if (Debug()) cout <<
"Preparing to process and fill HIT information ....." << endl;
1065 if (g2t_tpc_hitTablePointer) {
1067 long NHits = g2t_tpc_hitTablePointer->GetNRows();
1069 long nPseudoPadrow = 0;
1071 for(ihit=0; ihit<NHits; ihit++) {
1073 if (tpcHitTable[ihit].volume_id < 101 || tpcHitTable[ihit].volume_id > 2472) {
1074 if (tpcHitTable[ihit].volume_id <= 202472 &&
1075 tpcHitTable[ihit].volume_id > 2472) nPseudoPadrow++;
1083 if(!mCurrentMcEvent->tpcHitCollection()->addHit(th)) {
1091 AddHit2Track(tpc,Tpc);
1094 cout <<
"Filled " << mCurrentMcEvent->tpcHitCollection()->numberOfHits() <<
" TPC Hits" << endl;
1095 cout <<
"Found " << nPseudoPadrow <<
" Hits in Pseudo-Padrows." << endl;
1096 if (nBadVolId) {gMessMgr->Warning() <<
"StMcEventMaker::Make(): cannot store " << nBadVolId
1097 <<
" TPC hits, wrong Volume Id." << endm;}
1100 for (
unsigned int iSector=0;
1101 iSector<mCurrentMcEvent->tpcHitCollection()->numberOfSectors(); iSector++)
1102 for (
unsigned int iPadrow=0;
1103 iPadrow<mCurrentMcEvent->tpcHitCollection()->sector(iSector)->numberOfPadrows();
1105 StSPtrVecMcTpcHit& tpcHits = mCurrentMcEvent->tpcHitCollection()->sector(iSector)->padrow(iPadrow)->hits();
1107 Int_t nhits = tpcHits.size();
1108 cout <<
"Tpc hits before sort" << endl;
1109 for (
int i = 0; i < nhits; i++) {
1110 cout << *(tpcHits[i]) << endl;
1113 sort (tpcHits.begin(), tpcHits.end(),
compMcHit() );
1115 Int_t nhits = tpcHits.size();
1116 cout <<
"Tpc hits after sort" << endl;
1117 for (
int i = 0; i < nhits; i++) {
1118 cout << *(tpcHits[i]) << endl;
1125 if (Debug()) cout <<
"No TPC Hits in this event" << endl;
1133 if (g2t_svt_hitTablePointer) {
1135 long NHits = g2t_svt_hitTablePointer->GetNRows();
1138 for(ihit=0; ihit<NHits; ihit++) {
1139 if (svtHitTable[ihit].volume_id < 1101 || svtHitTable[ihit].volume_id > 9000) {
1144 if (!mCurrentMcEvent->svtHitCollection()->addHit(th)) {
1153 AddHit2Track(svt,Svt);
1156 cout <<
"Filled " << mCurrentMcEvent->svtHitCollection()->numberOfHits() <<
" SVT Hits" << endl;
1157 cout <<
"Nhits, " << NHits <<
" rows from table" << endl;
1159 gMessMgr->Warning() <<
"StMcEventMaker::Make(): cannot store " << nBadVolId
1160 <<
" SVT hits, wrong Volume Id." << endm;
1163 for (
unsigned int iBarrel=0;
1164 iBarrel<mCurrentMcEvent->svtHitCollection()->numberOfBarrels(); iBarrel++)
1165 for (
unsigned int iLadder=0;
1166 iLadder<mCurrentMcEvent->svtHitCollection()->barrel(iBarrel)->numberOfLadders();
1168 for (
unsigned int iWafer=0;
1169 iWafer<mCurrentMcEvent->svtHitCollection()->barrel(iBarrel)->ladder(iLadder)->numberOfWafers();
1171 StSPtrVecMcSvtHit& svtHits = mCurrentMcEvent->svtHitCollection()->barrel(iBarrel)->ladder(iLadder)->wafer(iWafer)->hits();
1172 sort (svtHits.begin(), svtHits.end(),
compMcHit() );
1178 if (Debug()) cout <<
"No SVT Hits in this event" << endl;
1186 if (g2t_ssd_hitTablePointer) {
1188 long NHits = g2t_ssd_hitTablePointer->GetNRows();
1191 for(ihit=0; ihit<NHits; ihit++) {
1192 if (ssdHitTable[ihit].volume_id < 7000 || ssdHitTable[ihit].volume_id > 9000) {
1197 if (!mCurrentMcEvent->ssdHitCollection()->addHit(th)) {
1206 AddHit2Track(ssd,Ssd);
1209 cout <<
"Filled " << mCurrentMcEvent->ssdHitCollection()->numberOfHits() <<
" SSD Hits" << endl;
1210 cout <<
"Nhits, " << NHits <<
" rows from table" << endl;
1212 gMessMgr->Warning() <<
"StMcEventMaker::Make(): cannot store " << nBadVolId
1213 <<
" SSD hits, wrong Volume Id." << endm;
1218 if (Debug()) cout <<
"No SSD Hits in this event" << endl;
1227 if (g2t_ftp_hitTablePointer) {
1229 long NHits = g2t_ftp_hitTablePointer->GetNRows();
1232 for(ihit=0; ihit<NHits; ihit++) {
1237 if (ftpHitTable[ihit].volume_id < 101 || ftpHitTable[ihit].volume_id > 2906) {
1244 if (!mCurrentMcEvent->ftpcHitCollection()->addHit(th)){
1252 AddHit2Track(ftp,Ftpc);
1255 cout <<
"Filled " << mCurrentMcEvent->ftpcHitCollection()->numberOfHits() <<
" FTPC Hits" << endl;
1257 gMessMgr->Warning() <<
"StMcEventMaker::Make(): cannot store " << nBadVolId
1258 <<
" FTPC hits, wrong Volume Id." << endm;
1261 for (
unsigned int iPlane=0;
1262 iPlane<mCurrentMcEvent->ftpcHitCollection()->numberOfPlanes(); iPlane++) {
1263 StSPtrVecMcFtpcHit& ftpcHits = mCurrentMcEvent->ftpcHitCollection()->plane(iPlane)->hits();
1269 if (Debug()) cout <<
"No FTPC Hits in this event" << endl;
1272 AddHits(rch,rich,Rich);
1273 AddHits(ctb,ctb,Ctb);
1275 AddHits(tfr,
tof,Tof);
1276 AddHits(mtd,mtd,Mtd);
1277 AddHits(pix,pxl,Pxl);
1278 AddHits(ist,ist,Ist);
1279 AddHits(fgt,fgt,Fgt);
1280 AddHits(etr,etr,Etr);
1283 if (doUseBemc) fillBemc(g2t_emc_hitTablePointer);
1286 if (doUseBsmd) fillBsmd(g2t_smd_hitTablePointer);
1289 if (doUseEemc) fillEemc(g2t_eem_hitTablePointer,g2t_esm_hitTablePointer);
1292 if (doUseFpd) fillFpd(g2t_fpd_hitTablePointer);
1295 if (doUseFsc) fillFsc(g2t_fsc_hitTablePointer);
1306 if (!g2t_vertexTablePointer)
1307 gMessMgr->Warning() <<
"StMcEventMaker: g2t_vertex Table Not found " << endm;
1308 if (!g2t_trackTablePointer)
1309 gMessMgr->Warning() <<
"StMcEventMaker: g2t_track Table Not found " << endm;
1310 if (!g2t_tpc_hitTablePointer)
1311 gMessMgr->Info() <<
"StMcEventMaker: g2t_tpc_hit Table Not found " << endm;
1312 if (!particleTablePointer)
1313 gMessMgr->Info() <<
"StMcEventMaker: particle Table Not found " << endm;
1315 if (doPrintEventInfo) printEventInfo();
1317 StMemoryInfo::instance()->snapshot();
1318 StMemoryInfo::instance()->print();
1320 if (doPrintCpuInfo) {
1322 cout <<
"CPU time for StMcEventMaker::Make(): "
1323 << timer.elapsedTime() <<
" sec\n" << endl;
1331 void StMcEventMaker::fillBemc(St_g2t_emc_hit* g2t_emc_hitTablePointer)
1333 if (g2t_emc_hitTablePointer == 0) {
1334 if (Debug()) cout <<
"No BEMC and BPRS Hits in this event" << endl;
1338 g2t_emc_hit_st* emcHitTable = g2t_emc_hitTablePointer->GetTable();
1339 StEmcGeom *geomBemc = StEmcGeom::getEmcGeom(1);
1340 int module, eta, sub, detector;
1347 long NHits = g2t_emc_hitTablePointer->GetNRows();
1349 for(
long ihit=0; ihit<NHits; ihit++,emcHitTable++) {
1351 geomBemc->getVolIdBemc(emcHitTable->volume_id, module,eta,sub,detector);
1358 if (emcHitTable->track_p <= 0 || emcHitTable->track_p > NTracks)
continue;
1359 tr = ttemp[emcHitTable->track_p - 1];
1360 de = emcHitTable->de;
1362 if (detector == 1 || detector == 2) {
1365 StMcEmcHitCollection::EAddHit bemcNew = bemcColl->addHit(emchBemc);
1367 if (bemcNew == StMcEmcHitCollection::kNew){
1368 tr->addBemcHit(emchBemc);
1371 else if(bemcNew == StMcEmcHitCollection::kAdd){
1372 emchBprs = emchBemc;
1374 else if(bemcNew == StMcEmcHitCollection::kErr){
1377 gMessMgr->Warning()<<
"<E> Bad hit in Bemc collection " << endm;
1383 gMessMgr->Warning()<<
"<E> Funny return value! EAddHit = " <<
static_cast<int>(bemcNew) <<endm;
1386 if (detector == 2 && emchBprs) {
1387 StMcEmcHitCollection::EAddHit bprsNew = bprsColl->addHit(emchBprs);
1388 if (bprsNew == StMcEmcHitCollection::kNew) {
1389 tr->addBprsHit(emchBprs);
1402 gMessMgr->Warning() <<
"<E> Bad EMC detector number " << detector <<
" volume_id "
1403 << emcHitTable->volume_id <<
" detector "<< detector << endm;
1407 cout <<
"Filled " << mCurrentMcEvent->bemcHitCollection()->numberOfHits() <<
" BEMC Hits" << endl;
1408 cout <<
"Filled " << mCurrentMcEvent->bprsHitCollection()->numberOfHits() <<
" BPRS Hits" << endl;
1413 void StMcEventMaker::fillBsmd(St_g2t_emc_hit* g2t_smd_hitTablePointer)
1415 if (g2t_smd_hitTablePointer == 0) {
1416 if (Debug()) cout <<
"No BSMDE and BSMDP Hits in this event" << endl;
1420 g2t_emc_hit_st* smdHitTable = g2t_smd_hitTablePointer->GetTable();
1421 StEmcGeom *geomBsmd = StEmcGeom::getEmcGeom(3);
1422 int module, eta, sub, detector;
1429 long NHits = g2t_smd_hitTablePointer->GetNRows();
1430 for(
long ihit=0; ihit<NHits; ihit++,smdHitTable++) {
1431 geomBsmd->getVolIdBsmd(smdHitTable->volume_id, module,eta,sub,detector);
1432 if (smdHitTable->track_p <= 0 || smdHitTable->track_p > NTracks)
continue;
1433 tr = ttemp[smdHitTable->track_p - 1];
1434 de = smdHitTable->de;
1436 if (detector == 3) {
1438 StMcEmcHitCollection::EAddHit bsmdeNew = bsmdeColl->addHit(emchBsmde);
1439 if (bsmdeNew == StMcEmcHitCollection::kNew) {
1440 tr->addBsmdeHit(emchBsmde);
1447 else if (detector == 4) {
1449 StMcEmcHitCollection::EAddHit bsmdpNew = bsmdpColl->addHit(emchBsmdp);
1450 if (bsmdpNew == StMcEmcHitCollection::kNew) {
1451 tr->addBsmdpHit(emchBsmdp);
1459 gMessMgr->Warning() <<
"<E> Bad SMD detector number " << detector <<
" volume_id "
1460 << smdHitTable->volume_id <<
" detector "<< detector << endm;
1464 cout <<
"Filled " << mCurrentMcEvent->bsmdeHitCollection()->numberOfHits() <<
" BSMDE Hits" << endl;
1465 cout <<
"Filled " << mCurrentMcEvent->bsmdpHitCollection()->numberOfHits() <<
" BSMDP Hits" << endl;
1470 void StMcEventMaker::fillEemc(St_g2t_emc_hit* g2t_tile, St_g2t_emc_hit* g2t_smd){
1472 gMessMgr->Info() <<
GetName() <<
"fillEemc() called" << endm;
1475 mEemcGeant.unpackGeantHits(g2t_tile, g2t_smd);
1485 if (!eemcColl || !eprsColl || !esmduColl || !esmdvColl) {
1486 gMessMgr->Warning()<<
GetName() <<
"::fillEemc(), sth wrong with StMcEEmcCollection,\n skip EEMC GEANT hits"<<endm;
1492 const EEmcMCHit *h = mEemcGeant.getGeantHits(nHit);
1493 for(Int_t i=0; i<nHit; i++,h++) {
1494 int detId=h->detector;
1495 if (h->track_p <= 0 || h->track_p > NTracks)
continue;
1497 int Beta=0,Bsub=0,Bmodule=0;
1508 StMcEmcHitCollection::EAddHit addRet=StMcEmcHitCollection::kErr;
1509 if (Debug()>1) printf(
"StMcAdd:detID=%d iHit=%d de=%g\n",detId,i,h->de);
1513 case EEmcMCData::kEEmcMCTowerId:
1517 addRet = eemcColl->addHit(stMcHit);
1518 if(addRet==StMcEmcHitCollection::kNew) tr->addEemcHit(stMcHit);
1522 case EEmcMCData::kEEmcMCPostShowerId: off++;
1523 case EEmcMCData::kEEmcMCPreShower2Id: off++;
1524 case EEmcMCData::kEEmcMCPreShower1Id:
1526 Bsub=h->tower.ssec +5*off;
1528 addRet = eprsColl->addHit(stMcHit);
1529 if(addRet==StMcEmcHitCollection::kNew) tr->addEprsHit(stMcHit);
1532 case EEmcMCData::kEEmcMCSmdUStripId:
1536 addRet = esmduColl->addHit(stMcHit);
1537 if(addRet==StMcEmcHitCollection::kNew) tr->addEsmduHit(stMcHit);
1540 case EEmcMCData::kEEmcMCSmdVStripId:
1544 addRet = esmdvColl->addHit(stMcHit);
1545 if(addRet==StMcEmcHitCollection::kNew) tr->addEsmdvHit(stMcHit);
1548 gMessMgr->Warning()<<
GetName() <<
"::fillEemc(), wrong detectorId=" << detId <<
" from EEmcMCHit. iHit="<<i<<
"\n It is fatal - bug in the code, fix it, JB"<<endm;
1555 case StMcEmcHitCollection::kNew:
break;
1556 case StMcEmcHitCollection::kAdd:
delete stMcHit;
break;
1557 case StMcEmcHitCollection::kErr:
1558 gMessMgr->Warning()<<
"<E> Bad hit in Eemc collection" << endm;
1562 gMessMgr->Warning()<<
"<E> Funny return value! EAddHit = " <<
static_cast<int>(addRet) << endm;
1567 if (Debug()) gMessMgr->Info()<<
GetName() <<
"::fillEemc() done, nHit="<<nHit<<endm;
1571 void StMcEventMaker::fillFpd(St_g2t_emc_hit* g2t_fpd_hitTablePointer)
1573 if (!g2t_fpd_hitTablePointer) {
1574 if (Debug()) cout <<
"No FPD Hits in this event" << endl;
1578 g2t_emc_hit_st* fpdHitTable = g2t_fpd_hitTablePointer->GetTable();
1581 for (
int iHit = 0; iHit < g2t_fpd_hitTablePointer->GetNRows(); ++iHit) {
1582 g2t_emc_hit_st&
hit = fpdHitTable[iHit];
1584 int volume_id = hit.volume_id;
1585 int ch = volume_id % 1000;
1587 int nstb = volume_id % 10;
1588 int ew = volume_id / 10;
1589 if (hit.track_p <= 0 || hit.track_p > NTracks)
continue;
1593 StMcEmcHitCollection::EAddHit fpdNew = fpdColl->addHit(fpdHit);
1594 if (fpdNew == StMcEmcHitCollection::kNew) {
1595 track->addFpdHit(fpdHit);
1597 delete fpdHit; fpdHit = 0;
1601 if (Debug()) cout <<
"Filled " << mCurrentMcEvent->fpdHitCollection()->numberOfHits() <<
" FPD Hits" << endl;
1605 void StMcEventMaker::fillFsc(St_g2t_emc_hit* g2t_fsc_hitTablePointer)
1607 if (!g2t_fsc_hitTablePointer) {
1608 if (Debug()) cout <<
"No FSC Hits in this event" << endl;
1612 g2t_emc_hit_st* fscHitTable = g2t_fsc_hitTablePointer->GetTable();
1615 for (
int iHit = 0; iHit < g2t_fsc_hitTablePointer->GetNRows(); ++iHit) {
1616 g2t_emc_hit_st& hit = fscHitTable[iHit];
1618 int volume_id = hit.volume_id;
1621 int eta = floor(
float(volume_id) /
float(80));
1622 int sub = volume_id % 80;
1623 if (hit.track_p <= 0 || hit.track_p > NTracks)
continue;
1624 StMcTrack* track = ttemp[hit.track_p - 1];
1627 StMcEmcHitCollection::EAddHit fscNew = fscColl->addHit(fscHit);
1628 if (fscNew == StMcEmcHitCollection::kNew) {
1629 track->addFscHit(fscHit);
1631 delete fscHit; fscHit = 0;
1635 if (Debug()) cout <<
"Filled " << mCurrentMcEvent->fscHitCollection()->numberOfHits() <<
" FSC Hits" << endl;
1640 void StMcEventMaker::printEventInfo()
1642 cout <<
"---------------------------------------------------------" << endl;
1643 cout <<
"StMcEvent at " << (
void*) mCurrentMcEvent << endl;
1644 cout <<
"---------------------------------------------------------" << endl;
1645 if (! mCurrentMcEvent)
return;
1646 cout << *mCurrentMcEvent << endl;
1647 mCurrentMcEvent->Print(
"");
virtual void AddData(TDataSet *data, const char *dir=".data")
User methods.
virtual void Clear(Option_t *option="")
User defined functions.
Monte Carlo Track class All information on a simulated track is stored in this class: kinematics...
Filling of all StMcEvent classes from g2t tables Transform all the data in the g2t tables into the co...
Bool_t doPrintMemoryInfo
lots of screen output
virtual const char * GetName() const
special overload
Event data structure to hold all information from a Monte Carlo simulation. This class is the interfa...