590 #include "St_geant_Maker.h"
591 #include "TDataSetIter.h"
599 #include "TGeometry.h"
600 #include "TMaterial.h"
601 #include "TMixture.h"
604 #include "TInterpreter.h"
605 #include "TClassTable.h"
608 #include "TFileSet.h"
627 #include "TGeoMaterial.h"
628 #include "TGeoMatrix.h"
629 #include "TGeoNode.h"
630 #include "TGeoManager.h"
631 #include "TGeoVolume.h"
632 #include "TGeoPcon.h"
633 #include "TGeoPgon.h"
634 #include "TObjString.h"
639 #include "StarMagField.h"
641 #include "tables/St_g2t_event_Table.h"
642 #include "tables/St_g2t_pythia_Table.h"
643 #include "tables/St_g2t_gepart_Table.h"
644 #include "tables/St_g2t_vertex_Table.h"
645 #include "tables/St_g2t_track_Table.h"
646 #include "tables/St_geom_gdat_Table.h"
647 #include "StDetectorDbMaker/St_MagFactorC.h"
648 #include "tables/St_det_user_Table.h"
649 #include "tables/St_det_hit_Table.h"
650 #include "tables/St_det_path_Table.h"
651 #include "tables/St_mfld_mflg_Table.h"
652 #include "TDataSetIter.h"
653 #include "TTreeIter.h"
655 #include "g2t/St_g2t_get_event_Module.h"
657 #include "g2t/St_g2t_get_pythia_Module.h"
659 #include "g2t/St_g2t_get_kine_Module.h"
660 #include "g2t/St_g2t_particle_Module.h"
662 #include "g2t/St_g2t_svt_Module.h"
663 #include "g2t/St_g2t_ssd_Module.h"
664 #include "g2t/St_g2t_pix_Module.h"
665 #include "g2t/St_g2t_hpd_Module.h"
666 #include "g2t/St_g2t_ist_Module.h"
667 #include "g2t/St_g2t_igt_Module.h"
668 #include "g2t/St_g2t_gem_Module.h"
669 #include "g2t/St_g2t_fst_Module.h"
670 #include "g2t/St_g2t_fgt_Module.h"
671 #include "g2t/St_g2t_tpc_Module.h"
672 #include "g2t/St_g2t_mwc_Module.h"
673 #include "g2t/St_g2t_ftp_Module.h"
674 #include "g2t/St_g2t_ctb_Module.h"
675 #include "g2t/St_g2t_tof_Module.h"
676 #include "g2t/St_g2t_tfr_Module.h"
677 #include "g2t/St_g2t_eto_Module.h"
678 #include "g2t/St_g2t_rch_Module.h"
679 #include "g2t/St_g2t_emc_Module.h"
680 #include "g2t/St_g2t_smd_Module.h"
681 #include "g2t/St_g2t_eem_Module.h"
682 #include "g2t/St_g2t_esm_Module.h"
683 #include "g2t/St_g2t_zdc_Module.h"
684 #include "g2t/St_g2t_vpd_Module.h"
685 #include "g2t/St_g2t_pmd_Module.h"
686 #include "g2t/St_g2t_bbc_Module.h"
687 #include "g2t/St_g2t_fpd_Module.h"
688 #include "g2t/St_g2t_fsc_Module.h"
689 #include "g2t/St_g2t_mtd_Module.h"
690 #include "g2t/St_g2t_etr_Module.h"
691 #include "g2t/St_g2t_hca_Module.h"
692 #include "g2t/St_g2t_wca_Module.h"
693 #include "g2t/St_g2t_pre_Module.h"
694 #include "g2t/St_g2t_fts_Module.h"
695 #include "g2t/St_g2t_stg_Module.h"
696 #include "g2t/St_g2t_epd_Module.h"
698 #include "St_db_Maker/St_db_Maker.h"
699 #include "TUnixTime.h"
700 #include "StarCallf77.h"
702 #include "StMessMgr.h"
704 #include "StarDetectorMap.h"
706 #include "StDetectorDbMaker/St_vertexSeedC.h"
708 #define geometry F77_NAME(geometry,GEOMETRY)
709 #define agstroot F77_NAME(agstroot,AGSTROOT)
710 #define csaddr F77_NAME(csaddr,CSADDR)
711 #define csjcal F77_NAME(csjcal,CSJCAL)
712 #define g2t_volume_id F77_NAME(g2t_volume_id,G2T_VOLUME_ID)
713 #define g2r_get_sys F77_NAME(g2r_get_sys,G2R_GET_SYS)
714 #define gfrotm F77_NAME(gfrotm,GFROTM)
715 #define gfxzrm F77_NAME(gfxzrm,GFXZRM)
716 #define dzddiv F77_NAME(dzddiv,DZDDIV)
717 #define agnzgete F77_NAME(agnzgete,AGNZGETE)
718 #define rootmaptable F77_NAME(rootmaptable,ROOTMAPTABLE)
719 #define agvolume F77_NAME(agvolume,AGVOLUME)
720 #define agvoluma F77_NAME(agvoluma,AGVOLUMA)
721 #define uhtoc F77_NAME(uhtoc,UHTOC)
722 #define agfpath F77_NAME(agfpath,UHTOC)
724 #define mfldgeo F77_NAME(mfldgeo,MFLDGEO)
726 #define agfdig0 F77_NAME(agfdig0,AGFDIG0)
727 #define agfdpar F77_NAME(agfdpar,AGFDPAR)
729 #define acfromr F77_NAME(acfromr,ACFROMR)
731 #define dstkine F77_NAME(dstkine,DSTKINE)
733 typedef long int (*addrfun)();
735 void *getPntB(
int myDif);
736 void type_of_call geometry();
737 int type_of_call agstroot();
738 void type_of_call *csaddr(
char *name,
int l77name=0);
739 long int type_of_call csjcal(
744 int type_of_call g2t_volume_id (DEFCHARD,
int* DEFCHARL);
745 void type_of_call g2r_get_sys (DEFCHARD, DEFCHARD,
int&,
int& DEFCHARL DEFCHARL);
746 void type_of_call gfrotm (
int&,Float_t&,Float_t&,Float_t&,Float_t&,Float_t&,Float_t&);
747 void type_of_call gfxzrm (
int &NLEV_0,Float_t &X,Float_t &Y,Float_t &Z,
748 Float_t &TET1,Float_t &PHI1,
749 Float_t &TET2,Float_t &PHI2,
750 Float_t &TET3,Float_t &PHI3,Float_t &TYPE);
751 void type_of_call agnzgete (
int &ILK,
int &IDE,
752 int &NPART,
int &IRUN,
int &IEVT,DEFCHARD CGNAM,
753 Float_t *VERT,
int &IWTFL,Float_t &WEIGH DEFCHARL);
754 void type_of_call dzddiv (
int &,
int &,DEFCHARD,DEFCHARD,
755 int &,
int &,
int &,
int & DEFCHARL DEFCHARL);
767 void type_of_call rootmaptable_(DEFCHARD,DEFCHARD,DEFCHARD,
int&,Char_t *
768 DEFCHARL DEFCHARL DEFCHARL);
769 int type_of_call agvolume(uint64_t&, uint64_t&, uint64_t&, uint64_t&,
int&
770 ,
int&, uint64_t&,
int&,
int *);
771 int type_of_call agvoluma(
void*,
void*,
void*,
void*,
void*,
void*,
void*,
void*,
void*,
void*);
772 void type_of_call uhtoc(
int&,
int &,DEFCHARD,
int& DEFCHARL);
773 int type_of_call agfdig0 (
const char*,
const char*,
int,
int);
774 void type_of_call agfdpar (
float &hits,
const char *chit,
float &alim,
float &blim,
float &bin,
int);
775 void type_of_call agfpath(
int *);
776 void type_of_call dstkine();
778 Char_t type_of_call *acfromr(Float_t r=8009359);
780 Quest_t *St_geant_Maker::cquest;
781 Gclink_t *St_geant_Maker::clink;
782 Gcflag_t *St_geant_Maker::cflag;
783 Gcvolu_t *St_geant_Maker::cvolu;
784 Gcnum_t *St_geant_Maker::cnum;
785 int *St_geant_Maker::z_iq, *St_geant_Maker::z_lq;
786 Float_t *St_geant_Maker::z_q;
787 Gcsets_t *St_geant_Maker::csets;
788 Gckine_t *St_geant_Maker::ckine;
789 Gcking_t *St_geant_Maker::cking;
791 Gcmate_t *St_geant_Maker::cmate;
792 Gccuts_t *St_geant_Maker::ccuts;
793 Gcphys_t *St_geant_Maker::cphys;
794 int St_geant_Maker::nlev;
801 Float_t lseen, lstyle, lwidth, lcolor, lfill;
814 fNwGeant(nwgeant), fNwPaw(nwpaw), fIwType(iwtype),
815 fVolume(0), fTopGeoVolume(0),
816 fInputFile(""),fGeoDirectory(0), fEvtHddr(0),
817 fRemakeGeometry(kFALSE),m_geom_gdat(0),mInitialization(""), mFieldOpt(""), mHitCounts()
825 TDataSet *St_geant_Maker::FindDataSet (
const char* logInput,
const StMaker *uppMk,
828 bool lookupHall = !strcmp(logInput,
"HALL");
829 bool lookupGeoDir = !strcmp(logInput,
"GeometryDirectory");
832 if ( !(lookupHall || lookupGeoDir) ) {
833 ds = StMaker::FindDataSet(logInput,uppMk,dowMk);
842 TList *listOfVolume = gGeometry->GetListOfNodes();
845 listOfVolume->
Remove(fVolume);
846 listOfVolume->Remove(fVolume);
850 if (Debug()) fVolume->
ls(3);
853 }
else if (lookupGeoDir) {
854 if (!fGeoDirectory) {
855 TString file(
"pams/geometry");
861 TString starRoot =
"$STAR/" + file;
862 geoDir =
new TFileSet(starRoot.Data());
864 LOG_DEBUG <<
"NO STAR geometry source directory has been found" << endm;
865 delete geoDir; geoDir = 0;
867 TString star(
"$STAR/pams");
868 gSystem->ExpandPathName(star);
869 geoDir->SetTitle(star.Data());
872 TString wd = gSystem->WorkingDirectory();
874 geoDir->SetTitle(wd.Data());
879 container->Add(geoDir);
882 if (Debug()) fGeoDirectory->
ls(3);
891 int St_geant_Maker::Init(){
893 if ( geant3)
return kStOK;
895 geant3 =
new TGiant3(
"C++ Interface to Geant3",fNwGeant,fNwPaw,fIwType);
897 cquest = (Quest_t *) geant3->Quest();
898 clink = (Gclink_t *) geant3->Gclink();
899 cflag = (Gcflag_t *) geant3->Gcflag();
900 cvolu = (Gcvolu_t *) geant3->Gcvolu();
901 cnum = (Gcnum_t *) geant3->Gcnum();
902 z_iq = (
int *) geant3->Iq();
903 z_lq = (
int *) geant3->Lq();
904 z_q = (Float_t *) geant3->Q();
905 csets = (Gcsets_t *) geant3->Gcsets();
906 ckine = (Gckine_t *) geant3->Gckine();
907 cking = (Gcking_t *) geant3->Gcking();
908 ctrak = (
Gctrak_t *) geant3->Gctrak();
909 cmate = (Gcmate_t *) geant3->Gcmate();
910 ccuts = (Gccuts_t *) geant3->Gccuts();
911 cphys = (Gcphys_t *) geant3->Gcphys();
912 Do(
"kuip/s/filecase KEEP");
913 TString InputFile(fInputFile);
914 if (fInputFile !=
"") {
916 if (Debug()) LOG_INFO <<
"St_geant_Maker::Init File " << fInputFile.Data() << endm;
918 if (InputFile.Contains(
".fz")) {ifz = 1; kuip =
"gfile p "; kuip += InputFile;}
919 else if (InputFile.Contains(
".nt")) {kuip =
"user/input user "; kuip += InputFile;}
920 else if (InputFile.Contains(
".tx")) {kuip =
"user/input tx "; kuip += InputFile;}
921 else if (InputFile.Contains(
".MuDst")) {
922 if (! MuDstIter) MuDstIter =
new TTreeIter();
923 MuDstIter->AddFile(InputFile);
924 kuip =
"user/input please MuDst.Dst";
927 SetAttr(
"Don'tTouchTimeStamp",kTRUE);
928 SetDatimeFromMuDst();
931 if (Debug()) LOG_INFO <<
"St_geant_Maker::Init kuip " << kuip.Data() << endm;
933 if (cquest->iquest[0] >
kStOK) {
934 LOG_INFO <<
"St_geant_Maker::Init File " << InputFile.Data() <<
" cannot be opened. Exit!" << endm;
942 if (IAttr(
"Pythia")) {
945 Do(
"MDCY (102,1)=0");
946 Do(
"MDCY (106,1)=0");
947 Do(
"MDCY (109,1)=0");
948 Do(
"MDCY (116,1)=0");
949 Do(
"MDCY (112,1)=0");
950 Do(
"MDCY (105,1)=0");
951 Do(
"MDCY (164,1)=0");
952 Do(
"MDCY (167,1)=0");
953 Do(
"MDCY (162,1)=0");
954 Do(
"MDCY (169,1)=0");
955 Do(
"MDCY (172,1)=0");
956 Do(
"MDCY (174,1)=0");
957 Do(
"MDCY (176,1)=0");
960 Double_t sqrtS = 510;
961 Do(Form(
"ener %f",sqrtS));
962 Do(
"CALL PyTUNE(329)");
963 Do(
"gspread 0.015 0.015 42.00");
972 Do(
"call closeDecays(24)");
974 Do(
"call openDecay(24,206,1)");
977 Do(
"call pystat(1)");
980 Do(
"gkine 80 6 1. 1. -2. 2. 0 6.28 0. 0.;");
982 Do(
"mode g2tm prin 1;");
998 int St_geant_Maker::InitRun(
int run){
999 static Bool_t InitRunDone = kFALSE;
1000 if (InitRunDone)
return kStOK;
1001 InitRunDone = kTRUE;
1002 if (mInitialization !=
"") {
1003 LOG_INFO <<
"St_geant_Maker::InitRun -- Do geometry initialization" << endm;
1004 LOG_INFO <<
"St_geant_Maker::InitRun -- with " << mInitialization.Data() << endm;
1005 Do(mInitialization.Data());
1007 mInitialization =
"";
1008 if (IAttr(
"phys_off")) {
1009 LOG_INFO <<
"St_geant_Maker::Init switch off physics" << endm;
1026 Do(
"CUTS 1e-3 1e-3 1e-3 1e-3 1e-3 1e-3 1e-3 1e-3 1e-3 1e-3 50.e-6");
1028 }
else if (IAttr(
"hadr_off")) {
1029 LOG_INFO <<
"St_geant_Maker::Init switch off hadron interactions" << endm;
1045 Do(
"CUTS 1e-3 1e-3 1e-3 1e-3 1e-3 1e-3 1e-3 1e-3 1e-3 1e-3 50.e-6");
1047 }
else if (IAttr(
"flux")) {
1051 Do(
"CUTS 1e-5 1e-5 1e-3 1e-14 1e-3 1e-3 1e-3 1e-3 1e-3 1e-3 10");
1057 if (IAttr(
"RunG")) {
1058 LOG_INFO <<
"St_geant_Maker::InitRun -- Set RunG/rndm " << IAttr(
"RunG") << endl;
1059 Do(Form(
"rung %d 1",IAttr(
"RunG")));
1060 Do(Form(
"rndm %d",IAttr(
"RunG")));
1063 LOG_INFO <<
"St_geant_Maker::InitRun -- Do mag.field initialization" << endm;
1064 m_geom_gdat = (St_geom_gdat *)
Find(
".runco/geom/geom_gdat");
1065 if (! m_geom_gdat) {
1066 St_geom_gdat *geom_gdat = (St_geom_gdat *)
Find(
".const/geom/geom_gdat");
1068 m_geom_gdat =
new St_geom_gdat(*geom_gdat);
1069 AddRunco(m_geom_gdat);
1073 if (! IAttr(
"Don'tTouchTimeStamp") && IsActive() ) {
1074 fEvtHddr = (
StEvtHddr*) GetTopChain()->GetDataSet(
"EvtHddr");
1077 fEvtHddr->SetRunNumber(0);
1078 SetOutput(fEvtHddr);
1084 if (! m_geom_gdat) {
1085 m_geom_gdat =
new St_geom_gdat(
"geom_gdat",1);
1086 AddRunco(m_geom_gdat);
1087 geom_gdat_st row = {{0,0}, 1,
"gstar"};
1088 m_geom_gdat->AddAt(&row);
1093 if (StarMagField::Instance() && StarMagField::Instance()->IsLocked()) {
1095 LOG_INFO <<
"St_geant_Maker::InitRun passive mode. Don't update Mag.Field from DB" << endm;
1097 Float_t fScale = St_MagFactorC::instance()->ScaleFactor();
1098 if (TMath::Abs(fScale) < 1e-3) fScale = 1e-3;
1099 LOG_INFO <<
"St_geant_Maker::InitRun active mode ";
1100 if (! StarMagField::Instance()) {
1102 LOG_INFO <<
"Initialize STAR magnetic field with scale factor " << fScale << endm;
1104 StarMagField::Instance()->SetFactor(fScale);
1105 LOG_INFO <<
"Reset STAR magnetic field with scale factor " << fScale << endm;
1109 Float_t mfscale = 1;
1111 geom_gdat_st *gdat = m_geom_gdat->GetTable();
1112 mfscale = gdat->mfscale;
1113 LOG_INFO <<
"St_geant_Maker::Init geom_gdata is found in fz-file ! ";
1115 St_mfld_mflg *mfld_mflg = (St_mfld_mflg *)
Find(
".const/geom/mfld_mflg");
1117 LOG_INFO <<
"St_geant_Maker::Init mfld_mflg is found in fz-file ! ";
1118 mfld_mflg_st *s = mfld_mflg->GetTable();
1119 mfscale = s->bfield/5.0;
1121 LOG_INFO <<
"St_geant_Maker::Init geom_gdata is missing in fz-file ! Use default mag.field scale factor ";
1124 LOG_INFO <<
"St_geant_Maker::Init mfscale = " << mfscale << endm;
1129 const Field_t FieldOptions[5] = {
1130 {
"FullMagFNegative", -1.0},
1131 {
"FullMagFPositive", 1.0},
1132 {
"HalfMagFNegative", -0.5},
1133 {
"HalfMagFPositive", 0.5},
1136 TString FieldOption(
"");
1137 for (
int i = 0; i < 5; i++) {
1138 if (TMath::Abs(mfscale - FieldOptions[i].scale) < 2.e-2) {
1139 FieldOption = FieldOptions[i].name;
1143 if (FieldOption !=
"") {
1144 SetFlavor(FieldOption.Data(),
"MagFactor");
1145 LOG_INFO <<
"St_geant_Maker::Init SetFlavor(\"" << FieldOption.Data()
1146 <<
"\",\"MagFactor\")" << endm;
1148 delete StarMagField::Instance();
1149 if (! StarMagField::Instance()) {
1150 new StarMagField ( StarMagField::kMapped, mfscale, kTRUE);
1151 LOG_INFO <<
"St_geant_Maker::Init Create StarMagField and lock it"
1155 StarMagField::Instance()->SetFactor(mfscale);
1156 StarMagField::Instance()->SetLock();
1157 LOG_INFO <<
"St_geant_Maker::Init Reset StarMagField and lock it"
1163 if (IsActive() && IAttr(
"Pythia")) {
1164 if (IAttr(
"beamLine")) {
1167 Double_t x0 = vSeed->x0() ;
1168 Double_t y0 = vSeed->y0() ;
1169 Double_t dxdz = vSeed->dxdz();
1170 Double_t dydz = vSeed->dydz();
1171 Do(Form(
"gvertex %f %f 1",x0,y0));
1172 Do(Form(
"gslope %f %f", dxdz, dydz));
1180 int link=1,ide=1,npart,irun,ievt,iwtfl;
1181 Float_t vert[4],weigh;
1182 if (GetDebug()) {
Do(
"debug on;"); }
else {
Do(
"debug off;"); }
1183 int iRes = 0;
if(iRes) {};
1187 if (cquest->iquest[0]) {
return kStEOF;}
1189 St_g2t_event *g2t_event =
new St_g2t_event(
"g2t_event",1);
1192 Char_t cgnam[21] =
" \0";
1193 Agnzgete(link,ide,npart,irun,ievt,cgnam,vert,iwtfl,weigh);
1196 if (! IAttr(
"Don'tTouchTimeStamp")) {
1199 if (fEvtHddr->GetRunNumber() != *(z_iq+clink->jhead+1))
1200 fEvtHddr->SetRunNumber(*(z_iq+clink->jhead+1));
1201 fEvtHddr->SetEventNumber(*(z_iq+clink->jhead+2));
1203 if (fInputFile !=
"") fEvtHddr->SetEventType(TString(gSystem->BaseName(fInputFile.Data()),7));
1204 fEvtHddr->SetProdDateTime();
1211 St_particle *particle =
new St_particle(
"particle",npart);
1212 AddData(particle); iRes = g2t_particle(particle);
1214 if (Debug() > 1) particle->Print(0,10);
1215 particle_st *p = particle->GetTable();
1221 if (! IAttr(
"Don'tTouchTimeStamp")) {
1222 if ( (p->isthep == 10 && p->idhep == 9999999 && fEvtHddr) ||
1223 (p->isthep >= 11 && p->idhep == 999998 && fEvtHddr)) {
1225 fEvtHddr->SetBImpact (p->phep[0]);
1226 fEvtHddr->SetPhImpact (p->phep[1]);
1227 fEvtHddr->SetCenterOfMassEnergy(p->phep[2]);
1238 if (! IAttr(
"KeepRunNumber") &&
1239 p->vhep[0] > 0 && p->vhep[0] < 10000 &&
1240 fEvtHddr->GetRunNumber() != p->vhep[0]) {
1241 fEvtHddr->SetRunNumber((
int)p->vhep[0]);
1243 fEvtHddr->SetEventNumber((
int)p->vhep[1]);
1244 int id = p->jdahep[0];
1245 int it = p->jdahep[1];
1247 if (
id <= 0)
id = 19991231;
1248 if (
id <= 19000000)
id +=19000000;
1249 if (
id >= 20500000)
id = 19991231;
1250 if (it < 0) it = 235959;
1251 if (it > 246060) it = 235959;
1252 fEvtHddr->SetDateTime(
id,it);
1258 if (!cnum->nvertx || !cnum->ntrack)
return kStErr;
1259 St_g2t_vertex *g2t_vertex =
new St_g2t_vertex(
"g2t_vertex",cnum->nvertx);
1261 St_g2t_track *g2t_track =
new St_g2t_track (
"g2t_track",cnum->ntrack);
1264 g2t_get_kine (g2t_vertex,g2t_track);
1266 g2t_vertex->Print(0,10);
1267 g2t_track->Print(0,10);
1270 iRes = g2t_get_event(g2t_event);
1272 g2t_event->Print(0,10);
1276 St_g2t_pythia *g2t_pythia =
new St_g2t_pythia(
"g2t_pythia",1);
1278 LOG_INFO <<
"Pythia event header captured" << endm;
1279 g2t_get_pythia(g2t_pythia);
1284 if (! IAttr(
"Don'tTouchTimeStamp") ) {
1286 fEvtHddr->SetAEast((*g2t_event)[0].n_wounded_east);
1287 fEvtHddr->SetAWest((*g2t_event)[0].n_wounded_west);
1293 AddHits<St_g2t_svt_hit>(
"SVTH", {
"SVTD"} ,
"g2t_svt_hit", g2t_svt );
1296 AddHits<St_g2t_ssd_hit>(
"SISH", {
"SFSD"} ,
"g2t_ssd_hit", g2t_ssd );
1297 AddHits<St_g2t_pix_hit>(
"PIXH", {
"PLAC"} ,
"g2t_pix_hit", g2t_pix );
1298 AddHits<St_g2t_ist_hit>(
"ISTH", {
"IBSS"} ,
"g2t_ist_hit", g2t_ist );
1301 AddHits<St_g2t_hpd_hit>(
"HPDH", {
"YPLA"} ,
"g2t_hpd_hit", g2t_hpd );
1302 AddHits<St_g2t_gem_hit>(
"GEMH", {
"GMDI"} ,
"g2t_gem_hit", g2t_gem );
1303 AddHits<St_g2t_igt_hit>(
"IGTH", {
"IGAL"} ,
"g2t_igt_hit", g2t_igt );
1307 AddHits<St_g2t_fgt_hit>(
"FGTH", {
"FGZC",
"FGZD",
"FZCB"},
"g2t_fgt_hit", g2t_fgt );
1310 AddHits<St_g2t_tpc_hit>(
"TPCH", {
"TPAD"} ,
"g2t_tpc_hit", g2t_tpc );
1311 AddHits<St_g2t_mwc_hit>(
"TPCH", {
"TMSE"} ,
"g2t_mwc_hit", g2t_mwc );
1314 AddHits<St_g2t_ftp_hit>(
"FTPH", {
"FSEC"} ,
"g2t_ftp_hit", g2t_ftp );
1317 AddHits<St_g2t_ctf_hit>(
"BTOH", {
"BXSA"} ,
"g2t_ctb_hit", g2t_ctb );
1318 AddHits<St_g2t_ctf_hit>(
"BTOH", {
"BCSB"} ,
"g2t_tof_hit", g2t_tof );
1319 AddHits<St_g2t_ctf_hit>(
"BTOH", {
"BRSG"} ,
"g2t_tfr_hit", g2t_tfr );
1322 AddHits<St_g2t_ctf_hit>(
"ETOH", {
"ECEL"},
"g2t_eto_hit", g2t_eto );
1325 AddHits<St_g2t_rch_hit>(
"RICH", {
"RGAP",
"RSCI",
"FREO",
"QUAR"},
"g2t_rch_hit", g2t_rch );
1328 AddHits<St_g2t_emc_hit>(
"CALH", {
"CSUP"},
"g2t_emc_hit", g2t_emc );
1329 AddHits<St_g2t_emc_hit>(
"CALH", {
"CSDA"},
"g2t_smd_hit", g2t_smd );
1332 AddHits<St_g2t_emc_hit>(
"ECAH",{
"ESCI",
"ELGR",
"EPCT" },
"g2t_eem_hit", g2t_eem );
1333 AddHits<St_g2t_emc_hit>(
"ECAH",{
"EXSE",
"EHMS" },
"g2t_esm_hit", g2t_esm );
1336 AddHits<St_g2t_vpd_hit>(
"VPDH", {
"VRAD"},
"g2t_vpd_hit", g2t_vpd );
1339 AddHits<St_g2t_pmd_hit>(
"PHMH", {
"PDGS"} ,
"g2t_pmd_hit", g2t_pmd );
1342 AddHits<St_g2t_emc_hit>(
"ZCAH", {
"QSCI"} ,
"g2t_zdc_hit", g2t_zdc );
1345 AddHits<St_g2t_ctf_hit>(
"BBCH", {
"BPOL"} ,
"g2t_bbc_hit", g2t_bbc );
1348 AddHits<St_g2t_emc_hit>(
"FPDH", {
"FLGR",
"FLXF",
"FPSC",
"FOSC"},
"g2t_fpd_hit", g2t_fpd );
1351 AddHits<St_g2t_emc_hit>(
"FSCH", {
"FSCT"} ,
"g2t_fsc_hit", g2t_fsc );
1354 AddHits<St_g2t_mtd_hit>(
"MUTH",{
"MIGG",
"MTTT",
"MTTF" },
"g2t_mtd_hit", g2t_mtd );
1357 AddHits<St_g2t_etr_hit>(
"EIDH", {
"TABD"} ,
"g2t_etr_hit", g2t_etr );
1363 AddHits<St_g2t_fts_hit>(
"FTSH",{
"FTSA",
"FSIA",
"FSIB",
"FSIC"},
"g2t_fts_hit", g2t_fts );
1365 AddHits<St_g2t_fts_hit>(
"FSTH",{
"FTOS",
"FTIS",
"FTUS"},
"g2t_fsi_hit", g2t_fts );
1366 AddHits<St_g2t_fts_hit>(
"STGH",{
"STGP",
"STGL",
"STGS"},
"g2t_stg_hit", g2t_stg );
1367 AddHits<St_g2t_emc_hit>(
"WCAH",{
"WSCI"},
"g2t_wca_hit", g2t_wca );
1368 AddHits<St_g2t_hca_hit>(
"HCAH",{
"HSCI"},
"g2t_hca_hit", g2t_hca );
1369 AddHits<St_g2t_emc_hit>(
"PREH",{
"PSCI"},
"g2t_pre_hit", g2t_pre );
1373 AddHits<St_g2t_epd_hit>(
"EPDH", {
"EPDT"} ,
"g2t_epd_hit", g2t_epd );
1375 if (cflag->ieorun)
return kStEOF;
1376 if (cflag->ieotri)
return kStErr;
1378 if (IAttr(
"flux")) {
1379 static TH1D *Vx = 0, *Vy = 0, *Vz = 0;
1380 static TH2D *BbcC = 0;
1382 if (GetChain()->GetTFile()) GetChain()->GetTFile()->cd();
1383 Vx =
new TH1D(
"Vx",
"Geant primary vertex X",50,-5.0,5.0);
1384 Vy =
new TH1D(
"Vy",
"Geant primary vertex Y",50,-5.0,5.0);
1385 Vz =
new TH1D(
"Vz",
"Geant primary vertex Z",50,-100,100);
1387 St_g2t_vertex *geantVertex=(St_g2t_vertex *) GetDataSet(
"g2t_vertex");
1388 g2t_vertex_st *gvt=geantVertex->GetTable();
1389 Vx->Fill(gvt->ge_x[0]);
1390 Vy->Fill(gvt->ge_x[1]);
1391 Vz->Fill(gvt->ge_x[2]);
1393 BbcC =
new TH2D(
"BbcC",
"BBC East versus BBC West",100,-1,9,100,-1,9);
1395 Double_t BbcW = 0, BbcE = 0;
1396 St_g2t_ctf_hit *g2t_bbc_hit = (St_g2t_ctf_hit *) GetDataSet(
"g2t_bbc_hit");
1397 int N = g2t_bbc_hit->GetNRows();
1398 g2t_ctf_hit_st *bbc = g2t_bbc_hit->GetTable();
1399 for (
int i = 0; i < N; i++, bbc++) {
1400 if (bbc->tof > 100e-9)
continue;
1401 if (bbc->volume_id < 2000) BbcW++;
1404 if (BbcW <= 0) BbcW = 0.1;
1405 if (BbcE <= 0) BbcE = 0.1;
1406 BbcC->Fill(TMath::Log10(BbcW),TMath::Log10(BbcE));
1413 LOG_QA <<
"St_geant_Maker summary -QA- total number of active volumes with hits: " << mHitCounts.size() << endm;
1414 LOG_QA <<
"St_geant_Maker summary -QA- list of volumes with hits: " << endm;
1415 for (
auto i : mHitCounts ) {
1416 LOG_QA <<
"St_geant_Maker summary -QA- g2t hits (" << i.first.c_str() <<
") nhits = " << i.second << endm;
1418 LOG_QA <<
"St_geant_Maker summary -QA- energy deposition by container:" << endm;
1419 for (
auto i : mHitSum ) {
1420 LOG_QA <<
"St_geant_Maker summary -QA- g2t Esum (" << i.first.c_str() <<
") Esum = " << i.second << endm;
1428 if (strlen(option))
Do (option);
1433 mInitialization = option;
1437 void St_geant_Maker::Draw(
const char* opt)
1442 const char *path =
" ";
1443 Dzddiv (two,zero,path,opt,one,zero,one,one);
1449 if (l) geant3->Kuexel(job);
1454 TVolume *St_geant_Maker::MakeVolume(TString *name,
int ivo,
int Nlevel,
int *Names,
int *Numbers){
1456 int jvolum = clink->jvolum;
1457 int jvo = z_lq[jvolum-ivo];
1459 node = (
TVolume *) topnode->FindObject(name->Data());
1461 TShape *shape = (TShape *) gGeometry->GetListOfShapes()->FindObject(name->Data());
1462 if (!shape ) {shape = MakeShape(name,ivo);}
1463 node =
new TVolume(name->Data(), name->Data(), shape);
1466 int nin =(int) z_q[jvo+3];
1470 for (
int in=1; in<= nin; in++)
1472 int jin = z_lq[jvo-in];
1473 int ivom = (int) z_q[jin+2];
1474 int nuser = (int) z_q[jin+3];
1475 TString namem((
const Char_t *) &(z_iq[jvolum+ivom]), 4);
1477 Names[Nlevel] = z_iq[jvolum+ivom];
1478 Numbers[Nlevel] = nuser;
1479 int nlevv = Nlevel+1;
1481 Float_t xx[3], theta1,phi1, theta2,phi2, theta3,phi3, type;
1483 geant3->Glvolu(nlevv, Names, Numbers);
1485 Gfxzrm(Nlevel, xx[0],xx[1],xx[2],
1486 theta1,phi1, theta2,phi2, theta3,phi3, type);
1487 TVolume *newnode = (
TVolume *) topnode->FindObject(namem.Data());
1490 { newnode = MakeVolume(&namem, ivom, nlevv, Names, Numbers); }
1494 sprintf(ss,
"rotm%i",irot);
1495 TRotMatrix *rotm =
new TRotMatrix(ss,ss,
1496 theta1,phi1, theta2,phi2, theta3,phi3);
1497 node->Add(newnode,xx[0],xx[1],xx[2],rotm);
1503 if (nin == 0) {Nlevel--;}
1508 TShape *St_geant_Maker::MakeShape(TString *name,
int ivo){
1510 typedef enum {BOX=1,TRD1,TRD2,TRAP,TUBE,TUBS,CONE,CONS,SPHE,PARA,
1511 PGON,PCON,ELTU,HYPE,GTRA=28,CTUB} shapes;
1512 int jvolum = clink->jvolum;
1513 int jvo = z_lq[jvolum-ivo];
1515 shapes shape = (shapes) z_q[jvo+2];
1516 int numed = (int) z_q[jvo+4];
1517 int npar = (int) z_q[jvo+5];
1520 int jtmed = clink->jtmed;
1521 int jtm = z_lq[jtmed-numed];
1522 int nmat = (int)z_q[jtm+6];
1523 int jmate = clink->jmate;
1524 int jma = z_lq[jmate-nmat];
1525 int nmixt = (int) z_q[jma+11];
1526 int nm = TMath::Abs(nmixt);
1529 if (nm <= 1) sprintf (astring,
"mat%i",nmat);
1530 else sprintf (astring,
"mix%i",nmat);
1532 TString Astring(astring);
1533 t = (TShape *) gGeometry->GetListOfShapes()->FindObject(name->Data());
1536 case BOX: t =
new TBRIK((Char_t *) name->Data(),
"BRIK",(Char_t *) Astring.Data(),
1537 p->par[0],p->par[1],p->par[2]);
1539 case TRD1: t =
new TTRD1((Char_t *) name->Data(),
"TRD1",(Char_t *) Astring.Data(),
1540 p->par[0],p->par[1],p->par[2],p->par[3]);
1542 case TRD2: t =
new TTRD2((Char_t *) name->Data(),
"TRD2",(Char_t *) Astring.Data(),
1543 p->par[0],p->par[1],p->par[2],p->par[3],p->par[4]);
1545 case TRAP: t =
new TTRAP((Char_t *) name->Data(),
"TRAP",(Char_t *) Astring.Data(),
1546 p->par[0],p->par[1],p->par[2],p->par[3],p->par[4],
1547 p->par[5],p->par[6],p->par[7],p->par[8],p->par[9],
1550 case TUBE: t =
new TTUBE((Char_t *) name->Data(),
"TUBE",(Char_t *) Astring.Data(),
1551 p->par[0],p->par[1],p->par[2]);
1553 case TUBS: t =
new TTUBS((Char_t *) name->Data(),
"TUBS",(Char_t *) Astring.Data(),
1554 p->par[0],p->par[1],p->par[2],p->par[3],p->par[4]);
1556 case CONE: t =
new TCONE((Char_t *) name->Data(),
"CONE",(Char_t *) Astring.Data(),
1557 p->par[0],p->par[1],p->par[2],p->par[3],p->par[4]);
1559 case CONS: t =
new TCONS((Char_t *) name->Data(),
"CONS",(Char_t *) Astring.Data(),
1560 p->par[0],p->par[1],p->par[2],p->par[3],p->par[4],
1561 p->par[5],p->par[6]);
1563 case SPHE: t =
new TSPHE((Char_t *) name->Data(),
"SPHE",(Char_t *) Astring.Data(),
1564 p->par[0],p->par[1],p->par[2],p->par[3],p->par[4],
1567 case PARA: t =
new TPARA((Char_t *) name->Data(),
"PARA",(Char_t *) Astring.Data(),
1568 p->par[0],p->par[1],p->par[2],p->par[3],p->par[4],
1571 case PGON: t =
new TPGON((Char_t *) name->Data(),
"PGON",(Char_t *) Astring.Data(),
1572 p->par[0],p->par[1],(int)p->par[2],(
int)p->par[3]);
1574 case PCON: t =
new TPCON((Char_t *) name->Data(),
"PCON",(Char_t *) Astring.Data(),
1575 p->par[0],p->par[1],(int)p->par[2]);
1577 case ELTU: t =
new TELTU((Char_t *) name->Data(),
"ELTU",(Char_t *) Astring.Data(),
1578 p->par[0],p->par[1],p->par[2]);
1583 case GTRA: t =
new TGTRA((Char_t *) name->Data(),
"GTRA",(Char_t *) Astring.Data(),
1584 p->par[0],p->par[1],p->par[2],p->par[3],p->par[4],
1585 p->par[5],p->par[6],p->par[7],p->par[8],p->par[9],
1586 p->par[10],p->par[11]);
1588 case CTUB: t =
new TCTUB((Char_t *) name->Data(),
"CTUB",(Char_t *) Astring.Data(),
1589 p->par[0],p->par[1],p->par[2],p->par[3],p->par[4],
1590 p->par[5],p->par[6],p->par[7],p->par[8],p->par[9],
1600 if (att->lseen != 1) t->SetVisibility((
int)att->lseen);
1601 if (att->lstyle != 1) t->SetLineStyle ((
int)att->lstyle);
1602 if (att->lwidth != 1) t->SetLineWidth ((
int)att->lwidth);
1603 if (att->lcolor != 1) t->SetLineColor ((
int)att->lcolor);
1604 if (att->lfill != 1) t->SetFillStyle ((
int)att->lfill);
1609 void St_geant_Maker::Call(
const Char_t *name)
1612 addrfun *address = (addrfun *) csaddr_((Char_t *)name, strlen(name));
1613 if (address) csjcal_(address, &narg);
1616 void St_geant_Maker::ClearRootGeoms()
1621 fVolume->
Shunt(dataSet);
1624 if (fTopGeoVolume) {
1625 LOG_ERROR <<
"Fix me we !!!. Seg fault danger !!!" <<endm;
1626 delete fTopGeoVolume;
1634 if (mInitialization !=
"") {
1638 { Char_t name[20];
int nmat, isvol, ifield; Float_t fieldm; };
1640 { Char_t name[4],nick[4];
int npar; Float_t par[50]; };
1646 Float_t *volu=0, *position=0, *mother=0, *p=0;
1647 int who=0, copy=0, npar=0;
1648 int nvol=cnum->nvolum;
1649 Float_t theta1,phi1, theta2,phi2, theta3,phi3, type;
1650 TObjArray nodes(nvol+1);
1652 if (!gGeometry)
new TGeometry(
"STAR",
"nash STAR");
1655 printf(
" looping on agvolume \n");
1659 while (Agvolume(node,volu,position,mother,who,copy,p,npar,matName))
1662 typedef enum {BOX=1,TRD1,TRD2,TRAP,TUBE,TUBS,CONE,CONS,SPHE,PARA,
1663 PGON,PCON,ELTU,HYPE,GTRA=28,CTUB} shapes;
1665 shapes shape = (shapes) volu[1];
1668 int np = (int) volu[4];
1669 Float_t* p0 = volu+6;
1670 Float_t* att = p0+np;
1671 Char_t name[] = {0,0,0,0,0};
1672 Char_t nick[] = {0,0,0,0,0};
1673 float xx[3] = {0.,0.,0.};
1678 strncpy(nick,(
const Char_t*)&cvolu->names[cvolu->nlevel-1],4);
1679 strncpy(name,(
const Char_t*)(volu-5),4);
1681 Hp = (
TVolume *) H->GetPointer(p,npar+1);
1682 if (Hp) newVolume = Hp;
1686 {
case BOX: t=
new TBRIK(nick,
"BRIK",matName,
1687 p[0],p[1],p[2]);
break;
1688 case TRD1: t=
new TTRD1(nick,
"TRD1",matName,
1689 p[0],p[1],p[2],p[3]);
break;
1690 case TRD2: t=
new TTRD2(nick,
"TRD2",matName,
1691 p[0],p[1],p[2],p[3],p[4]);
break;
1692 case TRAP: t=
new TTRAP(nick,
"TRAP",matName,
1693 p[0],p[1],p[2],p[3],p[4],p[5],
1694 p[6],p[7],p[8],p[9],p[10]);
break;
1695 case TUBE: t=
new TTUBE(nick,
"TUBE",matName,
1696 p[0],p[1],p[2]);
break;
1697 case TUBS: t=
new TTUBS(nick,
"TUBS",matName,
1698 p[0],p[1],p[2],p[3],p[4]);
break;
1699 case CONE: t=
new TCONE(nick,
"CONE",matName,
1700 p[0],p[1],p[2],p[3],p[4]);
break;
1701 case CONS: t=
new TCONS(nick,
"CONS",matName,
1702 p[0],p[1],p[2],p[3],p[4],p[5],p[6]);
break;
1704 case SPHE: t=
new TSPHE(nick,
"SPHE",matName,
1705 p[0],p[1],p[2],p[3],p[4],p[5]);
break;
1706 case PARA: t=
new TPARA(nick,
"PARA",matName,
1707 p[0],p[1],p[2],p[3],p[4],p[5]);
break;
1708 case PGON: t=
new TPGON(nick,
"PGON",matName,p[0],p[1],(
int)p[2],(
int)p[3]);
1709 { Float_t *pp = p+4;
1710 for (
int i=0; i<p[3]; i++) {
1712 Float_t rmin = *pp++;
1713 Float_t rmax = *pp++;
1714 ((TPCON *)t)->DefineSection(i,z,rmin,rmax);
1719 case PCON: t=
new TPCON(nick,
"PCON",matName,p[0],p[1],(
int)p[2]);
1720 { Float_t *pp = p+3;
1721 for (
int i=0; i<p[2]; i++) {
1723 Float_t rmin = *pp++;
1724 Float_t rmax = *pp++;
1725 ((TPCON *)t)->DefineSection(i,z,rmin,rmax);
1730 case ELTU: t=
new TELTU(nick,
"ELTU",matName,
1731 p[0],p[1],p[2]);
break;
1734 case GTRA: t=
new TGTRA(nick,
"GTRA",matName,
1735 p[0],p[1],p[2],p[3],p[4],p[5],
1736 p[6],p[7],p[8],p[9],p[10],p[11]);
break;
1737 case CTUB: t=
new TCTUB(nick,
"CTUB",matName,
1738 p[0],p[1],p[2],p[3],p[4],p[5],
1739 p[6],p[7],p[8],p[9],p[10]);
break;
1740 default: t=
new TBRIK(nick,
"BRIK",matName,
1741 p[0],p[1],p[2]);
break;
1743 t->SetLineColor((
int)att[4]);
1746 std::string nickMat = Form(
"%s(%s)", nick,matName);
1747 newVolume =
new TVolume(name,nickMat.c_str(),t);
1750 H->SetPointer(newVolume);
1754 { Gfxzrm(nlev, xx[0],xx[1],xx[2], theta1,phi1,
1755 theta2,phi2, theta3,phi3, type);
1756 TRotMatrix *matrix=GetMatrix(theta1,phi1,theta2,phi2,theta3,phi3);
1757 node->Add(newVolume,xx[0],xx[1],xx[2],matrix,UInt_t(copy));
1767 if ( gGeometry ) gGeometry->GetListOfNodes()->Add(node);
1771 void St_geant_Maker::Mark(
TVolume *topvol) {
1772 int JSET = clink->jset;
1773 if (JSET <= 0)
return;
1774 int NSET=z_iq[JSET-1];
1775 Char_t Uset[5], Udet[5], Uvol[5];
1776 memset (Uset, 0, 5);
1777 memset (Udet, 0, 5);
1778 memset (Uvol, 0, 5);
1779 for (
int ISET=1;ISET<=NSET;ISET++) {
1780 int JS=z_lq[JSET-ISET];
1781 if (JS <= 0)
continue;
1782 int NDET=z_iq[JS-1];
1783 memcpy (Uset, &z_iq[JSET+ISET], 4);
1784 for (
int IDET=1;IDET<=NDET;IDET++) {
1785 int JD=z_lq[JS-IDET];
1786 if (JD <=0)
continue;
1788 int NWHI=z_iq[JD+7];
1789 int NWDI=z_iq[JD+8];
1790 memcpy (Udet, &z_iq[JS+IDET], 4);
1791 LOG_INFO <<
" Set " << Uset <<
" Detector " << Udet
1792 <<
" NV " << NV <<
" NWHI " << NWHI <<
" NWDI " << NWDI << endm;
1793 int JDU = z_lq[JD-3];
1795 int i1 = (int)z_q[JDU+3], i2 = (
int)z_q[JDU+5];
1796 LOG_INFO <<
" Volume/Bits :" << i1 <<
"/" << i2 << endm;
1797 for (
int i=i1;i<i2;i += 3) {
1799 int iv = (int)z_q[j+1];
1800 int Nmx = (int)z_q[j+2];
1801 int Nam = (int)z_iq[clink->jvolum+iv];
1802 int Nb = (
int)z_q[j+3];
1803 memcpy (Uvol, &Nam, 4);
1804 LOG_INFO <<
"\t" << Uvol <<
"\t" << Nmx <<
"\t" << Nb << endm;
1809 LOG_INFO <<
" Volume/Bits ";
1810 for (
int I=1; I<=NV; I++) {
1811 memcpy (Uvol, &z_iq[JD+2*I+9], 4);
1812 LOG_INFO <<
"\t" << Uvol <<
"/\t" << z_iq[JD+2*I+10];
1821 if (csets->iset && csets->idet) {
1822 LOG_INFO <<
"Set/Det \t" << csets->iset <<
"/" << csets->idet
1823 <<
"\tidtype = \t" << csets->idtype
1824 <<
"\tnvname = \t" << csets->nvname << endm;
1825 int nLev, lNam[15], lNum[15];
1827 geant3->Gfpath(csets->iset,csets->idet,csets->numbv, nLev, lNam, lNum);
1829 for (
int i=0; i< nLev; i++) {
1830 uhtoc(lNam[i],four,PASSCHARD(Name),four PASSCHARL(Name));
1831 LOG_INFO <<
"\t" << Name <<
"\t" << lNum[i];
1838 static Bool_t CompareMatrix(TRotMatrix &a,TRotMatrix &b)
1839 {
double *pa=a.GetMatrix();
double *pb=b.GetMatrix();
1840 for (
int i=0; i<9; i++)
if (pa[i]!=pb[i])
return kFALSE;
1844 TRotMatrix *St_geant_Maker::GetMatrix(
float thet1,
float phii1,
1845 float thet2,
float phii2,
1846 float thet3,
float phii3)
1848 THashList *list = gGeometry->GetListOfMatrices();
1849 int n=list->GetSize(); sprintf(mname,
"matrix%d",n+1);
1850 TRotMatrix *pattern=
new TRotMatrix(mname,mname,
1851 thet1,phii1,thet2,phii2,thet3,phii3);
1853 TRotMatrix *matrix=0; TIter nextmatrix(list);
1854 while ((matrix=(TRotMatrix *) nextmatrix()))
1855 {
if (matrix!=pattern)
1856 {
if (CompareMatrix(*matrix,*pattern))
1857 { list->Remove(pattern);
delete pattern;
return matrix; }
1862 TString St_geant_Maker::GetVolumeSrcFile(
const char *volumeName)
const
1866 TString vName = volumeName;
1868 if (fVolume && volumeName && volumeName[0]) {
1870 TFileSet *geoSrc =
dynamic_cast<TFileSet*
>(GetDataSet(
"GeometryDirectory"));
1871 if (geoSrc && myVolume ) {
1874 TString pattern = myVolume->GetName();
1878 }
while (!found && (myVolume = myVolume->GetParent()) );
1882 TString path = found->
Path();
1883 Ssiz_t pos = path.Index(
"/geometry/");
1884 TString topDir = geoSrc->GetTitle();
1885 path.Replace(0,pos,topDir);
1892 int St_geant_Maker::SetInputFile(
const char *file)
1898 int St_geant_Maker::Skip(
int Nskip)
1902 sprintf (kuip,
"trig %i",Nskip);
1903 if (GetDebug()) printf(
"St_geant_Maker skip %i\n record(s)",Nskip);
1904 Do((
const char*)kuip);
1906 if (cquest->iquest[0]) {
return kStEOF;}
1911 void type_of_call rootmaptable_(
const Char_t* cdest,
const Char_t* table ,
const Char_t* spec,
1913 const int lCdest,
const int lTable,
const int lSpec)
1915 Char_t *Cdest =
new char[(lCdest+1)]; strncpy(Cdest,cdest,lCdest); Cdest[lCdest] = 0;
1916 Char_t *Table =
new char[(lTable+1)]; strncpy(Table,table,lTable); Table[lTable] = 0;
1917 Char_t *
Spec =
new char[(lSpec+1)]; strncpy(Spec,spec,lSpec); Spec[lSpec] = 0;
1918 St_geant_Maker::RootMapTable(Cdest,Table,Spec, k, iq);
1924 void St_geant_Maker::RootMapTable(Char_t *Cdest,Char_t *Table, Char_t*
Spec,
1927 TString TableName(Table);
1928 TString t = TableName.Strip();
1934 #if ROOT_VERSION_CODE >= ROOT_VERSION(3,05,04)
1935 if (table) {fgGeom->Add(table); table->SetBit(TTable::kIsNotOwn);}
1937 if (table) {fgGeom->Add(table); table->SetBit(kIsNotOwn);}
1940 if (fgGeantMk->Debug() > 1) {
1943 if (N > 10) N = 10; table->
Print(0,N);
1945 else LOG_DEBUG <<
"St_geant_Maker::Dictionary for table :" << t.Data()
1946 <<
" has not been defined yet. Skip it"
1951 int St_geant_Maker::G2t_volume_id(
const Char_t *name,
int *numbv){
1952 return g2t_volume_id(PASSCHARD(name),numbv PASSCHARL(name));
1955 int St_geant_Maker::Agvolume(
TVolume *&node, Float_t *&par, Float_t *&pos
1956 ,Float_t *&mot,
int &who,
int ©
1957 ,Float_t *&par1,
int &npar,
char matName[24])
1959 uint64_t myNode = (uint64_t)node;
1960 uint64_t myPar=0,myPos=0,myMot=0,myPar1=0;
1961 int ans = agvolume(myNode,myPar,myPos,myMot,who,copy,myPar1,npar,(
int*)matName);
1963 par = (
float*)myPar;
1964 pos = (
float*)myPos;
1965 mot = (
float*)myMot;
1966 par1 = (
float*)myPar1;
1968 matName[20]=0;
char *cc = strstr(matName,
" ");
if (cc) *cc=0;
1974 void St_geant_Maker::Agnzgete (
int &ILK,
int &IDE,
1975 int &NPART,
int &IRUN,
int &IEVT,
const Char_t *CGNAM,
1976 Float_t *VERT,
int &IWTFL,Float_t &WEIGH){
1977 agnzgete (ILK,IDE,NPART,IRUN,IEVT,PASSCHARD(CGNAM),VERT,IWTFL,WEIGH
1981 void St_geant_Maker::Geometry() {
1985 LOG_WARN <<
"The local version of the <libgeometry.so> shared library is to be re-built" << endm;
1986 gSystem->Exec(
"cons +geometry");
1987 LOG_WARN <<
"The local version of the <libgeometry.so> shared library has been re-built" << endm;
1988 LOG_WARN <<
"One has to re-load Geometry browser to see the new geometry" << endm;
1989 LOG_WARN <<
"Ask Pavel Nevski, \"Why?\"" << endm;
1997 int St_geant_Maker::Agstroot() {
2002 void St_geant_Maker::Gfxzrm(
int & Nlevel,
2003 Float_t &x, Float_t &y, Float_t &z,
2004 Float_t &Theta1, Float_t & Phi1,
2005 Float_t &Theta2, Float_t & Phi2,
2006 Float_t &Theta3, Float_t & Phi3,
2008 gfxzrm(Nlevel, x, y, z,
2011 Theta3, Phi3, Type);
2014 void St_geant_Maker::Dzddiv(
int& idiv ,
int &Ldummy,
const Char_t* path,
const Char_t* opt,
2015 int& one,
int &two,
int &three,
int& iw){
2016 dzddiv (idiv,Ldummy,PASSCHARD(path),PASSCHARD(opt),
2017 one,two,three,iw PASSCHARL(path) PASSCHARL(opt));
2020 void St_geant_Maker::SetDateTime(
int idat,
int itime) {
2022 if (IAttr(
"KeepRunNumber") || ! fEvtHddr )
return;
2023 if (! m_geom_gdat) {
2024 LOG_INFO <<
"St_geant_Maker:: geom_gdat table is missing. Try to get it from GEANT." << endm;
2025 int jrung = clink->jrung;
2026 if (jrung > 0 && z_iq[jrung-1]>=10) {
2027 int jrunh = z_lq[jrung-1];
2029 int l = z_iq[jrunh-1];
2030 Char_t *buf =
new Char_t[4*l+1];
2031 memcpy (buf, &z_iq[jrunh+1], 4*l);
2033 LOG_INFO <<
"St_geant_Maker::SetDateTime runh buffer: " << buf << endm;
2036 Ssiz_t begin, index;
2039 Float_t mfscale = 5;
2041 while ( ( begin < C.Length()) && (index != kNPOS) ) {
2043 index = C.Index(
';',1, begin,TString::kExact);
2044 if (index > begin) {
2045 TString line(C(begin,index-begin));
2047 if (Debug()) LOG_INFO << line << endm;
2048 if (line.Contains(
"detp")) {
2049 int indx = line.Index(
"year");
2051 int end = line.Index(
" ",1,indx,TString::kExact);
2053 version = TString(line(indx,end-indx));
2056 indx = line.Index(
"field");
2058 int eq = line.Index(
"=",indx+4,TString::kExact);
2059 sscanf(line.Data()+eq+1,
"%f",&mfscale);
2065 if (version.Length()) {
2066 m_geom_gdat =
new St_geom_gdat(
"geom_gdat",1);
2067 AddRunco(m_geom_gdat);
2071 gdat.mfscale = mfscale/5.;
2072 memset (&gdat.gtag[0], 0, 8);
2073 strncpy(&gdat.gtag[0], version.Data(), 8);
2074 m_geom_gdat->AddAt(&gdat);
2075 if (Debug()) m_geom_gdat->Print(0,1);
2076 if (StarMagField::Instance()) StarMagField::Instance()->SetFactor(gdat.mfscale);
2082 geom_gdat_st *gdat = m_geom_gdat->GetTable();
2083 TString version(&gdat->gtag[0],8);
2086 if (version !=
"") {
2087 int id = St_db_Maker::AliasDate(version.Data());
2088 int it = St_db_Maker::AliasTime(version.Data());
2089 if (
id && GetDate() >= 20330101) {
2090 LOG_INFO <<
"St_geant_Maker::SetDateTime Date/Time = "
2091 <<
id <<
"/" << it <<
"\tas " << version << endm;
2092 fEvtHddr->SetDateTime(
id,it);
2098 Char_t *acfromr(Float_t r) {
2099 const Char_t *S=
" 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ";
2100 Char_t *charm =
new Char_t[5];
2101 memset (&charm[0], 0, 5);
2103 for (
int i = 3; i >= 0; i--) {
2104 int j = 077 & k; k = k >> 6; charm[i] = S[j];
2111 int St_geant_Maker::AgstHits()
2113 if (! geant3)
return kStErr;
2114 int JSET = clink->jset;
2115 if (JSET <= 0)
return kStErr;
2116 int NSET=z_iq[JSET-1];
2117 Char_t Uset[8], Udet[8], Uvol[8];
2118 memset (Uset, 0, 8);
2119 memset (Udet, 0, 8);
2120 memset (Uvol, 0, 8);
2122 for (
int ISET=1;ISET<=NSET;ISET++) {
2123 int JS=z_lq[JSET-ISET];
2124 if (JS <= 0)
continue;
2125 int NDET=z_iq[JS-1];
2126 memcpy (Uset, &z_iq[JSET+ISET], 4);
2128 m_Detectors->Add(set);
2129 for (
int IDET=1;IDET<=NDET;IDET++) {
2130 int JD=z_lq[JS-IDET];
2131 if (JD <=0)
continue;
2133 int NWHI=z_iq[JD+7];
2134 int NWDI=z_iq[JD+8];
2135 memcpy (Udet, &z_iq[JS+IDET], 4);
2137 LOG_INFO <<
" Set " << Uset <<
" Detector " << Udet
2138 <<
" NV " << NV <<
" NWHI " << NWHI <<
" NWDI " << NWDI << endm;
2140 int JDU = z_lq[JD-3];
2145 St_det_user *detu =
new St_det_user(
"User",1); det->Add(detu);
2148 rowU.i0 = (int) z_q[JDU+1];
2149 rowU.N = (int) z_q[JDU+2];
2150 rowU.i1 = (int) z_q[JDU+3];
2151 rowU.Nva = (int) z_q[JDU+4];
2152 rowU.i2 = (int) z_q[JDU+5];
2153 rowU.Nvb = (int) z_q[JDU+6];
2154 rowU.Goption = (int) z_q[JDU+7];
2155 rowU.Serial = (int) z_q[JDU+8];
2156 rowU.IdType = (int) z_q[JDU+9];
2157 rowU.Iprin = (int) z_q[JDU+10];
2160 LOG_INFO <<
" displacement for hit description part = 10 " << rowU.i0 << endm;
2161 LOG_INFO <<
" Number of all hit descriptors (both in non- and cum. parts) " << rowU.N << endm;
2162 LOG_INFO <<
" displacement for volume description part=10+10*Nh " << rowU.i1 << endm;
2163 LOG_INFO <<
" Number of all volume descriptors (branching or not) " << rowU.Nva << endm;
2164 LOG_INFO <<
" displacement for the free space = 10+10*Nh+3*Nv " << rowU.i2 << endm;
2165 LOG_INFO <<
" number of real volume branchings for NUMBV " << rowU.Nvb << endm;
2166 LOG_INFO <<
" Hit option: 1 - single step, 4 - Calorimetry " << rowU.Goption << endm;
2167 LOG_INFO <<
" Valid serial number for this subset " << rowU.Serial << endm;
2168 LOG_INFO <<
" USER detector number " << rowU.IdType << endm;
2169 LOG_INFO <<
" current print flag both for HITS and DIGI " << rowU.Iprin << endm;
2171 St_det_path *detuV =
new St_det_path(
"Path",rowU.Nva);
2172 St_det_hit *detuH =
new St_det_hit(
"Hit",rowU.N);
2177 agfdig0(Uset,Udet,strlen(Uset),strlen(Udet));
2178 float hits[15],alim[15],blim[15],bin[15];
2179 memset (&hits[0],0,15*
sizeof(
float));
2180 memset (&alim[0],0,15*
sizeof(
float));
2181 memset (&blim[0],0,15*
sizeof(
float));
2182 memset (&bin[0] ,0,15*
sizeof(
float));
2183 const char chit[60]=
"";
2184 agfdpar(hits[0],chit,alim[0],blim[0],bin[0],4);
2185 for (i = 0; i < rowU.N; i++) {
2186 memset(&rowH,0,detuH->GetRowSize());
2187 int j = JDU + rowU.i0 + 10*i;
2190 Char_t *HitName = acfromr(z_q[j+ 1]);
2191 memcpy (&rowH.hit[0], HitName, 4);
2193 rowH.option = (int) z_q[j+ 2];
2194 rowH.Nb = (int) z_q[j+ 3];
2195 rowH.Fmin = z_q[j+ 4];
2196 rowH.Fmax = z_q[j+ 5];
2197 rowH.Origin = z_q[j+ 6];
2198 rowH.Factor = z_q[j+ 7];
2199 rowH.Nbit = (int) z_q[j+ 8];
2200 rowH.Iext = (int) z_q[j+ 9];
2201 rowH.Ifun = (int) z_q[j+10];
2207 LOG_INFO <<
"\thit \toption \tNb \tFmin \tFmax \tOrigin \tFactor \tNbit \tIext \tIfun" << endm;
2208 LOG_INFO <<
"\t" << setw(4) << rowH.hit
2209 <<
"\t" << rowH.option
2211 <<
"\t" << rowH.Fmin
2212 <<
"\t" << rowH.Fmax
2213 <<
"\t" << rowH.Origin
2214 <<
"\t" << rowH.Factor
2215 <<
"\t" << rowH.Nbit
2216 <<
"\t" << rowH.Iext
2217 <<
"\t" << rowH.Ifun
2220 detuH->AddAt(&rowH);
2222 if (Debug()) detuH->Print(0,rowU.N);
2223 for (i = rowU.i1; i < rowU.i2; i += 3) {
2224 memset(&rowV,0,detuV->GetRowSize());
2226 int iv = (int) z_q[j+1];
2227 rowV.Ncopy = (int) z_q[j+2];
2228 int Nam = (int) z_iq[clink->jvolum+iv];
2229 rowV.Nb = (
int) z_q[j+3];
2230 memcpy (&rowV.VName[0], &Nam, 4);
2231 Char_t Udvol[] =
" ";
2233 int Namd = (int) z_iq[JD+2*ivd+11]; ivd++;
2234 memcpy (Udvol, &Namd, 4);
2237 LOG_INFO <<
"\t" << setw(4) << rowV.VName <<
"/" << Udvol
2238 <<
"\t" << rowV.Ncopy <<
"\t" << rowV.Nb << endm;
2240 detuV->AddAt(&rowV);
2243 for (; ivd<NV; ivd++) {
2244 int Namd = (int) z_iq[JD+2*ivd+11]; ivd++;
2245 Char_t Udvol[] =
" ";
2246 memcpy (Udvol, &Namd, 4);
2247 LOG_INFO <<
"\t" <<
" " <<
"/" << Udvol << endm;
2249 int n = detuV->GetNRows();
2257 #ifdef DetectorIndex
2259 void St_geant_Maker::DetSetIndex() {
2260 TString vers = mInitialization;
2261 vers.ReplaceAll(
"detp geometry ",
"");
2262 LOG_INFO <<
"St_geant_Maker::DetSetIndex for geometry version " << vers << endm;
2263 int JSET = clink->jset;
2264 if (JSET <= 0)
return;
2265 int NSET=z_iq[JSET-1];
2266 Char_t Uset[5], Udet[5], Uvol[5];
2267 memset (Uset, 0, 5);
2268 memset (Udet, 0, 5);
2269 memset (Uvol, 0, 5);
2270 for (
int ISET=1;ISET<=NSET;ISET++) {
2271 int JS=z_lq[JSET-ISET];
2272 if (JS <= 0)
continue;
2273 int NDET=z_iq[JS-1];
2274 memcpy (Uset, &z_iq[JSET+ISET], 4);
2277 for (
int IDET=1;IDET<=NDET;IDET++) {
2278 int JD=z_lq[JS-IDET];
2279 if (JD <=0)
continue;
2280 memcpy (Udet, &z_iq[JS+IDET], 4);
2281 agfdig0(Uset,Udet,strlen(Uset),strlen(Udet));
2282 int JDU = z_lq[JD-3];
2284 int i1 = (int) z_q[JDU+3];
2285 int i2 = (int) z_q[JDU+5];
2286 int Nva = (int) z_q[JDU+4];
2287 int Nvb = (int) z_q[JDU+6];
2288 LOG_INFO <<
" Set " << Uset <<
" Detector " << Udet <<
"\tNva = " << Nva <<
"\tNvb = " << Nvb << endm;
2292 for (
int i = i1; i < i2; i += 3) {
2294 int iv = (int) z_q[j+1];
2295 int Ncopy = (int) z_q[j+2];
2296 int Nam = (int) z_iq[clink->jvolum+iv];
2297 int Nb = (
int) z_q[j+3];
2298 memcpy (&Uvol[0], &Nam, 4);
2302 if (Nb <= 0) fmt +=
"_1";
2303 else {NVmax[ivv] = Ncopy; ivv++; fmt +=
"_%d";}
2307 for (
int i = 0; i < NoDetectors; i++)
2308 if (TString(Detectors[i].det) == Vol && TString(Detectors[i].set) !=
"") {
2309 CSYS = Detectors[i].Csys;
2314 DumpIndex(Uvol, vers, fmt, NVmax, Ids0);
2318 LOG_INFO <<
"format: " << fmt << endm;
2319 LOG_INFO <<
"NVmax";
2320 for (
int i = 0; i < Nvb; i++) {Nelem *= NVmax[i]; LOG_INFO <<
"[" << NVmax[i] <<
"]";}
2323 memset (numbv, 0, 15*
sizeof(
int));
2327 for (
int i = Nvb-1; i >= 0; i--) {
2328 numbv[i] = e%NVmax[i] + 1;
2332 int volid = G2t_volume_id(CSYS.Data(), numbv);
2333 if (volid < 0) volid = 0;
2336 DumpIndex(Uvol, vers, fmt, NVmax, Ids);
2343 void St_geant_Maker::DumpIndex(
const Char_t *name,
const Char_t *vers,
const Char_t *fmt, TArrayI &NVmax, TArrayI &Ids) {
2350 LOG_INFO <<
"Create " << fOut << endm;
2351 out.open(fOut.Data());
2352 out <<
"TDataSet *CreateTable() {" << endl;
2353 out <<
" if (!gROOT->GetClass(\"StarVMCDetector\")) return 0;" << endl;
2354 int NV = NVmax.GetSize();
2355 int Nelem = Ids.GetSize();
2357 out <<
" int NVmax[" << NV <<
"] = {";
2358 for (
int i = 0; i < NV; i++) {
2360 if (i < NV - 1) out <<
",";
2366 out <<
" int Ids[" << Nelem <<
"] = {" << endl;
2369 if (Ids[0] > 0 && TMath::Log10(Ids[0]) > 7) nn = 10;
2370 int nvl = NVmax[NV-1];
2371 if (nvl > 5 && nvl < nn) nn = NVmax[NV-1];
2372 if (nn >= nvl) nvl = Nelem;
2374 for (
int i = 0; i < Nelem; i++) {
2377 if (i < Nelem - 1) {
2379 if (j % nn == 0 || (i+1) % nvl == 0) {out << endl; out <<
"\t"; j = 0;}
2386 out <<
" StarVMCDetector *Set = new StarVMCDetector(\"" << name <<
"\");" << endl;
2388 out <<
" Set->SetNVmax(" << NV <<
", NVmax);" << endl;
2389 if (Nelem > 0) out <<
" Set->SetIds(" << Nelem <<
", Ids);" << endl;
2390 else out <<
" Set->SetIds();" << endl;
2392 out <<
" Set->SetFMT(\"" << fmt <<
"\");" << endl;
2393 out <<
" return (TDataSet *)Set;" << endl;
2400 St_geant_Maker::instance()->KinematicsFromMuDst();
2403 int St_geant_Maker::SetDatimeFromMuDst() {
2404 KinematicsFromMuDst(1);
2408 int St_geant_Maker::KinematicsFromMuDst(
int flag) {
2410 static const int*& MuEvent_mEventInfo_mRunId = muDstIter(
"MuEvent.mEventInfo.mRunId");
2411 static const int*& MuEvent_mEventInfo_mId = muDstIter(
"MuEvent.mEventInfo.mId");
2412 static const int*& MuEvent_mEventInfo_mTime = muDstIter(
"MuEvent.mEventInfo.mTime");
2413 static const int*& MuEvent_mEventSummary_mNumberOfTracks = muDstIter(
"MuEvent.mEventSummary.mNumberOfTracks");
2414 static const int& NoPrimaryVertices = muDstIter(
"PrimaryVertices");
2415 static const Float_t*& PrimaryVertices_mPosition_mX1 = muDstIter(
"PrimaryVertices.mPosition.mX1");
2416 static const Float_t*& PrimaryVertices_mPosition_mX2 = muDstIter(
"PrimaryVertices.mPosition.mX2");
2417 static const Float_t*& PrimaryVertices_mPosition_mX3 = muDstIter(
"PrimaryVertices.mPosition.mX3");
2418 static const int& NoPrimaryTracks = muDstIter(
"PrimaryTracks");
2419 static const int*& PrimaryTracks_mIndex2Global = muDstIter(
"PrimaryTracks.mIndex2Global");
2420 static const int*& PrimaryTracks_mVertexIndex = muDstIter(
"PrimaryTracks.mVertexIndex");
2421 static const Float_t*& PrimaryTracks_mP_mX1 = muDstIter(
"PrimaryTracks.mP.mX1");
2422 static const Float_t*& PrimaryTracks_mP_mX2 = muDstIter(
"PrimaryTracks.mP.mX2");
2423 static const Float_t*& PrimaryTracks_mP_mX3 = muDstIter(
"PrimaryTracks.mP.mX3");
2424 static const Short_t*& PrimaryTracks_mHelix_mQ = muDstIter(
"PrimaryTracks.mHelix.mQ");
2425 static const int*& PrimaryTracks_mNSigmaElectron = muDstIter(
"PrimaryTracks.mNSigmaElectron");
2426 static const int*& PrimaryTracks_mNSigmaPion = muDstIter(
"PrimaryTracks.mNSigmaPion");
2427 static const int*& PrimaryTracks_mNSigmaKaon = muDstIter(
"PrimaryTracks.mNSigmaKaon");
2428 static const int*& PrimaryTracks_mNSigmaProton = muDstIter(
"PrimaryTracks.mNSigmaProton");
2429 static const Short_t*& GlobalTracks_mFlag = muDstIter(
"GlobalTracks.mFlag");
2431 #ifdef __USE_GLOBAL__
2432 static const int& NoGlobalTracks = muDstIter(
"GlobalTracks");
2433 static const Float_t*& GlobalTracks_mP_mX1 = muDstIter(
"GlobalTracks.mP.mX1");
2434 static const Float_t*& GlobalTracks_mP_mX2 = muDstIter(
"GlobalTracks.mP.mX2");
2435 static const Float_t*& GlobalTracks_mP_mX3 = muDstIter(
"GlobalTracks.mP.mX3");
2436 static const Short_t*& GlobalTracks_mHelix_mQ = muDstIter(
"GlobalTracks.mHelix.mQ");
2437 static const Float_t*& GlobalTracks_mFirstPoint_mX1 = muDstIter(
"GlobalTracks.mFirstPoint.mX1");
2438 static const Float_t*& GlobalTracks_mFirstPoint_mX2 = muDstIter(
"GlobalTracks.mFirstPoint.mX2");
2439 static const Float_t*& GlobalTracks_mFirstPoint_mX3 = muDstIter(
"GlobalTracks.mFirstPoint.mX3");
2440 static const int*& GlobalTracks_mNSigmaElectron = muDstIter(
"GlobalTracks.mNSigmaElectron");
2441 static const int*& GlobalTracks_mNSigmaPion = muDstIter(
"GlobalTracks.mNSigmaPion");
2442 static const int*& GlobalTracks_mNSigmaKaon = muDstIter(
"GlobalTracks.mNSigmaKaon");
2443 static const int*& GlobalTracks_mNSigmaProton = muDstIter(
"GlobalTracks.mNSigmaProton");
2445 static const Double_t __SIGMA_SCALE__ = 1000.;
2446 static int flagS = -1;
2450 if (! MuDstIter->Next()) {
return kStEOF;}
2452 TUnixTime ut(MuEvent_mEventInfo_mTime[0]); ut.GetGTime(
id,it);
2453 fEvtHddr = (
StEvtHddr*)GetDataSet(
"EvtHddr");
2456 SetOutput(fEvtHddr);
2458 fEvtHddr->SetDateTime(
id,it);
2459 fEvtHddr->SetRunNumber(MuEvent_mEventInfo_mRunId[0]);
2460 fEvtHddr->SetEventNumber(MuEvent_mEventInfo_mId[0]);
2461 if (! MuEvent_mEventSummary_mNumberOfTracks[0])
continue;
2464 if (flagS == 1)
return kStOK;
2471 static int pId[4][2] = {
2477 for (
int l = 0; l < NoPrimaryVertices; l++) {
2478 v[0] = PrimaryVertices_mPosition_mX1[l];
2479 v[1] = PrimaryVertices_mPosition_mX2[l];
2480 v[2] = PrimaryVertices_mPosition_mX3[l];
2481 nvtx = geant3->Gsvert(v, 0, 0);
2482 assert(nvtx == l+1);
2483 for (
int k = 0; k < NoPrimaryTracks; k++) {
2484 if (l != PrimaryTracks_mVertexIndex[k])
continue;
2485 int kg = PrimaryTracks_mIndex2Global[k];
2486 if (GlobalTracks_mFlag[kg] < 100)
continue;
2487 plab[0] = PrimaryTracks_mP_mX1[k];
2488 plab[1] = PrimaryTracks_mP_mX2[k];
2489 plab[2] = PrimaryTracks_mP_mX3[k];
2491 Double_t nSigma[4] = {
2492 PrimaryTracks_mNSigmaElectron[k]/__SIGMA_SCALE__,
2493 PrimaryTracks_mNSigmaKaon[k]/__SIGMA_SCALE__,
2494 PrimaryTracks_mNSigmaProton[k]/__SIGMA_SCALE__,
2495 PrimaryTracks_mNSigmaPion[k]/__SIGMA_SCALE__};
2497 if (PrimaryTracks_mHelix_mQ[k] < 0) s = 1;
2499 Double_t nSigmaMin = 1e9;
2500 for (
int i = 0; i < 4; i++) {
2501 if (TMath::Abs(nSigma[i]) < nSigmaMin) {
2502 nSigmaMin = TMath::Abs(nSigma[i]);
2506 if (nSigmaMin > 2) ipart = pId[3][s];
2509 if (PrimaryTracks_mHelix_mQ[k] < 0) ipart = 6;
2511 geant3->Gskine(plab, ipart, nvtx);
2514 #ifdef __USE_GLOBAL__
2515 for (
int kg = 0; kg < NoGlobalTracks; kg++) {
2516 if (GlobalTracks_mFlag[kg] < 100)
continue;
2517 Double_t nSigmaMin = 1e9;
2518 Double_t nSigma[4] = {
2519 GlobalTracks_mNSigmaElectron[kg]/__SIGMA_SCALE__,
2520 GlobalTracks_mNSigmaKaon[kg]/__SIGMA_SCALE__,
2521 GlobalTracks_mNSigmaProton[kg]/__SIGMA_SCALE__,
2522 GlobalTracks_mNSigmaPion[kg]/__SIGMA_SCALE__};
2524 if (GlobalTracks_mHelix_mQ[kg] < 0) s = 1;
2525 for (
int k = 0; k < NoPrimaryTracks; k++) {
2526 if (kg == PrimaryTracks_mIndex2Global[k]) {
2530 v[0] = GlobalTracks_mFirstPoint_mX1[kg];
2531 v[1] = GlobalTracks_mFirstPoint_mX2[kg];
2532 v[2] = GlobalTracks_mFirstPoint_mX3[kg];
2533 nvtx = geant3->Gsvert(v, 0, 0);
2534 plab[0] = GlobalTracks_mP_mX1[kg];
2535 plab[1] = GlobalTracks_mP_mX2[kg];
2536 plab[2] = GlobalTracks_mP_mX3[kg];
2538 for (
int i = 0; i < 4; i++) {
2539 if (TMath::Abs(nSigma[i]) < nSigmaMin) {
2540 nSigmaMin = TMath::Abs(nSigma[i]);
2544 if (nSigmaMin > 2) ipart = pId[3][s];
2545 geant3->Gskine(plab, ipart, nvtx);
2556 int St_geant_Maker::ipartx(
int id) {
2558 if (
id == 1) ipartxf = 1;
2559 else if (
id == 2 ||
id == 3) ipartxf = 2;
2560 else if (
id == 5 ||
id == 6) ipartxf = 3;
2561 else if (
id == 13) ipartxf = 4;
2562 else if ((
id >= 8 &&
id <= 9) ||
2563 (
id >= 11 &&
id <= 15)) ipartxf = 0;
2567 Float_t St_geant_Maker::dose(Float_t Z) {
2572 static TGraph *graph = 0;
2575 Double_t x[] = {11., 12., 13., 14., 15., 17., 18., 19., 20., 22.,
2576 23., 24., 25., 26., 27., 28., 29., 30., 32., 33.,
2577 34., 35., 38., 40., 41., 42., 43., 46., 47., 48.,
2578 49., 50., 51., 53., 57., 66., 73., 74., 78., 79.,
2580 Double_t y[] = {8.8033795E-02, 0.1175197 , 0.1043398 , 8.3658338E-02,
2581 7.6843806E-02, 5.7563554E-02, 4.0977564E-02, 4.6153713E-02,
2582 4.0977564E-02, 0.1257856 , 0.1797267 , 0.1679161 ,
2583 0.1650867 , 0.1828069 , 0.1828069 , 0.1956649 ,
2584 0.2094273 , 0.1923680 , 0.1923680 , 0.2612006 ,
2585 0.2795725 , 0.3095814 , 0.4499212 , 0.6880791 ,
2586 0.7240669 , 0.6213810 , 0.5 , 0.5 ,
2587 0.5 , 0.3546627 , 0.3796084 , 0.3428115 ,
2588 0.2941946 , 0.3370352 , 0.3 , 0.2702305 ,
2589 0.2941946 , 0.2567994 , 0.3607410 , 0.3607410 ,
2590 0.3428115 , 0.3 , 0.4};
2591 graph =
new TGraph(n,x,y);
2593 return 13.1286072899874E-6*TMath::Max(0., TMath::Min(0.5, graph->Eval(Z)));
2596 void St_geant_Maker::usflux() {
2602 Float_t stepF, destepF, XYZ[3];
2605 enum {Nregions = 1, Nparts = 5, NH1T = 3, NH2T = 9};
2606 const Char_t *NameV[Nregions] = {
""};
2607 static TH1D *histV1[Nregions][NH1T][Nparts];
2608 static TH2D *histV2[Nregions][NH2T][Nparts];
2609 static TH2D *tofg = 0;
2610 static Bool_t first = kTRUE;
2612 assert(GetChain()->GetTFile());
2613 GetChain()->GetTFile()->cd();
2615 memset(histV1, 0,
sizeof(histV1));
2616 memset(histV2, 0,
sizeof(histV2));
2619 Double_t xmax = 2000, xmin = - xmax;
2620 Double_t ymax = 1000, ymin = 0;
2621 int nx = (xmax - xmin)/xstep;
2622 int ny = (ymax - ymin)/ystep;
2625 const Char_t *Title;
2630 Double_t xMin, xMax;
2632 Double_t yMin, yMax;
2634 tofg =
new TH2D(
"tofg",
"log_{10} (tof [nsec]) @ step versus particle type",140,-1,13,50,0.5,50.5);
2635 Name_t Particles[Nparts] = {
2636 {
"",
"#pi/K/p and others"},
2642 NameX_t Types1[NH1T] = {
2643 {{
"Ekin10" ,
"Log_{10}(GEKIN) for %s for %s" }, 340, -14., 3.0, 0, 0, 0},
2644 {{
"Ekin10s" ,
"Log_{10}(GEKIN) for %s at step for %s Z < 0" }, 340, -14., 3.0, 0, 0, 0},
2645 {{
"Ekin10V" ,
"Log_{10}(GEKIN) for %s at production Vx for %s"}, 340, -14., 3.0, 0, 0, 0}
2647 NameX_t Types2[NH2T] = {
2648 {{
"flux" ,
"flux from %s * step for %s" }, nx, xmin, xmax, ny, ymin, ymax},
2649 {{
"flux100keV",
"flux from %s * step E_{kin} > 100 keV for %s" }, nx, xmin, xmax, ny, ymin, ymax},
2650 {{
"flux250meV",
"flux from %s * step E_{kin} < 250 meV for %s" }, nx, xmin, xmax, ny, ymin, ymax},
2651 {{
"entries" ,
"entries from %s for %s" }, nx, xmin, xmax, ny, ymin, ymax},
2652 {{
"VxProd" ,
"Vertex Production of %s for %s" }, nx, xmin, xmax, ny, ymin, ymax},
2653 {{
"dose" ,
"dose from charged particles and #gamma for %s" }, nx, xmin, xmax, ny, ymin, ymax},
2654 {{
"star" ,
"star density for %s" }, nx, xmin, xmax, ny, ymin, ymax},
2655 {{
"RD" ,
"Residual Dose for %s" }, nx, xmin, xmax, ny, ymin, ymax},
2656 {{
"DepEnergy" ,
"Deposited energy at step (keV) for %s" }, nx, xmin, xmax, ny, ymin, ymax}
2658 for (p = 0; p < Nparts; p++) {
2659 for (
int r = 0; r < Nregions; r++) {
2660 for (
int t = 0; t < NH1T; t++) {
2661 TString Name(Types1[t].name.Name); Name += Particles[p].Name; Name += NameV[r];
2662 TString Title(Form(Types1[t].name.Title,Particles[p].Title,NameV[r]));
2664 new TH1D(Name,Title,Types1[t].nX,Types1[t].xMin,Types1[t].xMax);
2666 for (
int t = 0; t < NH2T; t++) {
2667 TString Name(Types2[t].name.Name); Name += Particles[p].Name; Name += NameV[r];
2668 TString Title(Form(Types2[t].name.Title,Particles[p].Title,NameV[r]));
2670 new TH2D(Name,Title,Types2[t].nX,Types2[t].xMin,Types2[t].xMax,Types2[t].nY,Types2[t].yMin,Types2[t].yMax);
2677 int Ipart = ckine->ipart%100;
2679 Double_t tofg10 = - 1;
2680 if (ctrak->tofg > 0) tofg10 = TMath::Log10(1e9*ctrak->tofg);
2681 tofg->Fill(tofg10,Ipart);
2683 if (ctrak->gekin <= 0.0) {
2687 if (ctrak->upwght < 1) ctrak->upwght = 1;
2689 RR = TMath::Sqrt(ctrak->vect[0]*ctrak->vect[0] + ctrak->vect[1]*ctrak->vect[1]);
2690 ZZ = ctrak->vect[2];
2691 Double_t Phi = TMath::RadToDeg()*TMath::ATan2(ctrak->vect[1],ctrak->vect[0]);
2692 if (Phi < -180) Phi += 360;
2693 if (Phi > 180) Phi -= 360;
2695 if (! (ckine->charge == 0 && p < 0)) {
2699 if (ctrak->step > 0.0) {
2700 NstepB = ctrak->step + 0.5;
2701 NstepB = TMath::Max (1, NstepB);
2702 stepF = ctrak->step/NstepB;
2703 destepF = 1e6*ctrak->destep/NstepB;
2704 for (i = 1; i <= NstepB; i++) {
2705 XYZ[0] = ctrak->vect[0] + ctrak->vect[3]*stepF*(0.5 - i);
2706 XYZ[1] = ctrak->vect[1] + ctrak->vect[4]*stepF*(0.5 - i);
2707 XYZ[2] = ctrak->vect[2] + ctrak->vect[5]*stepF*(0.5 - i);
2708 RADIUS = TMath::Sqrt(XYZ[0]*XYZ[0] + XYZ[1]*XYZ[1]);
2709 Double_t phi = TMath::RadToDeg()*TMath::ATan2(XYZ[1],XYZ[0]);
2710 if (phi < -180) phi += 360;
2711 if (phi > 180) phi -= 360;
2712 histV2[r][0][p]->Fill(XYZ[2], RADIUS, stepF);
2713 if (ctrak->gekin >= 1.E-4) histV2[r][1][p]->Fill(XYZ[2], RADIUS, stepF);
2714 if (ctrak->gekin <= 0.25E-9) histV2[r][2][p]->Fill(XYZ[2], RADIUS, stepF);
2715 if (cmate->dens > 2.E-3 && ctrak->destep > 0.0)
2716 histV2[r][5][p]->Fill(XYZ[2], RADIUS, destepF/cmate->dens);
2717 histV2[r][8][p]->Fill(XYZ[2], RADIUS, destepF);
2719 histV1[r][0][p]->Fill(TMath::Log10(ctrak->gekin));
2720 if (ctrak->vect[2] < 0.0) histV1[r][1][p]->Fill(TMath::Log10(ctrak->gekin));
2721 if (ctrak->inwvol == 1) {
2722 histV2[r][3][p]->Fill(ZZ, RR);
2724 for (
int i = 0; i < cking->ngkine; i++) {
2725 id = ((int)cking->gkin[i][4])%100;
2730 Float_t mass, charge, tlife;
2731 TGiant3::Geant3()->Gfpart(
id,name,itrtyp,mass,charge,tlife);
2732 histV2[r][4][p]->Fill(ZZ, RR);
2734 TMath::Sqrt(cking->gkin[i][0]*cking->gkin[i][0] +
2735 cking->gkin[i][1]*cking->gkin[i][1] +
2736 cking->gkin[i][2]*cking->gkin[i][2] + mass*mass) - mass;
2737 ekin = TMath::Max (1e-14, ekin);
2738 histV1[r][2][p]->Fill(TMath::Log10(ekin));
2743 if (cking->ngkine > 0) {
2744 if (ctrak->vect[6] > 0.300 && p <= 0) {
2745 for (
int i = 0; i < ctrak->nmec; i++) {
2746 if (ctrak->lmec[i] >= 12 && ctrak->lmec[i] <= 20) {
2747 if ( p>=0 ) histV2[r][6][p]->Fill(ZZ, RR);
2748 OmegaN = dose(cmate->z);
2749 if ( p>=0 ) histV2[r][7][p]->Fill(ZZ, RR, OmegaN );
2759 void St_geant_Maker::PhysicsOff()
2761 geant3->SetProcess(
"DCAY", 0);
2762 geant3->SetProcess(
"ANNI", 0);
2763 geant3->SetProcess(
"BREM", 0);
2764 geant3->SetProcess(
"COMP", 0);
2765 geant3->SetProcess(
"HADR", 0);
2766 geant3->SetProcess(
"MUNU", 0);
2767 geant3->SetProcess(
"PAIR", 0);
2768 geant3->SetProcess(
"PFIS", 0);
2769 geant3->SetProcess(
"PHOT", 0);
2770 geant3->SetProcess(
"RAYL", 0);
2771 geant3->SetProcess(
"LOSS", 4);
2773 geant3->SetProcess(
"DRAY", 0);
2774 geant3->SetProcess(
"MULS", 0);
2775 geant3->SetProcess(
"STRA", 0);
2776 geant3->SetCut(
"CUTGAM", 1e-3 );
2777 geant3->SetCut(
"CUTELE", 1e-3 );
2778 geant3->SetCut(
"CUTHAD", .001 );
2779 geant3->SetCut(
"CUTNEU", .001 );
2780 geant3->SetCut(
"CUTMUO", .001 );
2781 geant3->SetCut(
"BCUTE", .001 );
2782 geant3->SetCut(
"BCUTM", .001 );
2783 geant3->SetCut(
"DCUTE", 1e-3 );
2784 geant3->SetCut(
"DCUTM", .001 );
2785 geant3->SetCut(
"PPCUTM", .001 );
2786 geant3->SetCut(
"TOFMAX", 50.e-6);
static Int_t MapGEANT2StNodeVis(Int_t vis)
virtual void AddData(TDataSet *data, const char *dir=".data")
User methods.
virtual void Remove(TDataSet *set)
Remiove the "set" from this TDataSet.
void version(std::ostream &os=std::cout)
print HepMC version
virtual Long_t GetNRows() const
Returns the number of the used rows for the wrapped table.
virtual void ls(Option_t *option="") const
virtual void Do(const Char_t *option="dcut cave x 0.1 10 10 0.03 0.03")
Executes a KUIP command.
static TTable * New(const Char_t *name, const Char_t *type, void *array, UInt_t size)
This static method creates a new TTable object if provided.
virtual void Shunt(TDataSet *newParent=0)
virtual TDataSet * FindByName(const char *name, const char *path="", Option_t *opt="") const
virtual TString Path() const
return the full path of this data set
virtual Char_t * Print(Char_t *buf, Int_t n) const
Create IDL table defintion (to be used for XDF I/O)
virtual void LoadGeometry(const Char_t *option="detp geometry field_only")
Specifies GEANT3 geometry command.
virtual TDataSet * Find(const char *path) const