// fill GEANT ROOT tree and open new file if necessary // // called from gudigi.F // // last modified on 14/10/99 by R.Holzmann #include "filltree.h" #include "hgeantmedia.h" void opennewfile(void); void filltree() { // printf("\n Filling Geant ROOT HTree\n"); HTree* pHGeantTree = gHades->getTree(); pHGeantTree->Fill(); TFile* pHGeantFile = gHades->getOutputFile(); if(pHGeantFile->GetBytesWritten() > MAXFILESIZE) { printf("\n Maximum allowed file size exceeded\n"); opennewfile(); } } FCALLSCSUB0(filltree,FILLTREE,filltree) PROTOCCALLSFSUB2(KUPATL,kupatl,PSTRING,PINT) #define KUPATL(COMMAND,NARG) CCALLSFSUB2(KUPATL,kupatl,PSTRING,PINT,COMMAND,NARG) PROTOCCALLSFSUB2(KUGETC,kugetc,PSTRING,PINT) #define KUGETC(NAME,NLEN) CCALLSFSUB2(KUGETC,kugetc,PSTRING,PINT,NAME,NLEN) // MEDIA Common Block #define NMAXCHAR 200 #define MEDMAXNO 100 struct MEDIA_DEF { int ndefmedia; char mediumname[MEDMAXNO][NMAXCHAR]; int mediumindex[MEDMAXNO]; }; #define GEAMEDIA COMMON_BLOCK(GEAMEDIA,geamedia) COMMON_BLOCK_DEF(MEDIA_DEF,GEAMEDIA); void opennewfile(void) { // close ROOT file and open new one delete gHades; // throw away Hades object ... gHades = new Hades(); // ... and make new on HRecEvent* pHGeantEvent = new HRecEvent(); // create a new event gHades->setEvent(pHGeantEvent); pHGeantEvent->addPartialEvent(catSimul,"Simul","Simulated event"); char cstring[100]; int narg; if(batch<2) { // we are in interactive mode KUPATL(cstring,narg); // get HGeant command string and nb of arguments if(strcmp(cstring,"CLOSEFILE") == 0) { // close file SETITUP(0); // set itup to 0 (no file open) UHBOOK(); // call Fortran routine uhbook once more return; } if(strcmp(cstring,"NEWFILE") == 0) { // called as HGeant command NEWFILE char newName[100]; int len; KUGETC(newName,len); // get new file name and put into gRootFileName newName[len+1]='\0'; TString s=newName; s.ToLower(); s.Strip(s.kBoth); if (s.Length()>0) { gRootFileName = s; gRootFileNumber = 0; } SETITUP(1); } } gRootFileNumber++; // increment file counter for file name TString newFileName = gRootFileName; newFileName += gRootFileNumber; // insert file number into name newFileName += ".root"; gHades->setOutputFile((char*)newFileName.Data(),"RECREATE","HGeant data",2); // open file // write the media to the file // (same as in hgeahropen.cc for the first output file) HGeantMedia media("GeantMedia","List of Geant media"); for (Int_t k=0;k