void runMCFOPI_GiBUU(TString outdir, int nEvents=5000, Int_t run = 0, unsigned int seed=0,bool target=true, int jobset=0) { // ------------------------------------------------------------------------ gRandom->SetSeed(seed); gROOT->ProcessLine(".x $VMCWORKDIR/gconfig/rootlogon.C"); // ======================================================================== // Verbosity level (0=quiet, 1=event level, 2=track level, 3=debug) Int_t iVerbose = 1; FairRunSim *fRun = new FairRunSim(); // set the MC version used // -------------------------------------------------- TString mcMode = "TGeant3"; fRun->SetName(mcMode); TString jobdir=outdir; int length = jobdir.Length(); if(jobdir[length-1] != "/") jobdir.Append("/"); TString jobname; if(jobset!=0){ jobname=Form("GiBUU_FopiMC_set%i_run%i.mc.root",jobset,run); }else{ jobname=Form("GiBUU_FopiMC_%i.mc.root",jobset,run); } TString outfile = jobdir+jobname; std::cout<SetOutputFile(outfile); std::cout<<"Set output file to "<Getenv("VMCWORKDIR"); if(jobset!=0){ digifile += Form("/tpc/FOPI/par/tpc.gibuu_sverre_al%i.par",jobset); }else{ digifile += Form("/tpc/FOPI/par/tpc.gibuu_sverre.par",jobset); } cout<SetLogScreenLevel("WARNING"); FairRuntimeDb *rtdb=fRun->GetRuntimeDb(); FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo(); parIo1->open(digifile.Data(),"in"); rtdb->setFirstInput(parIo1); Bool_t kParameterMerged=kTRUE; FairParRootFileIo* parOut=new FairParRootFileIo(kParameterMerged); parOut->open(parfile.Data()); rtdb->setOutput(parOut); TpcDigiPar* par = (TpcDigiPar*) rtdb->getContainer("TpcDigiPar"); par->setInputVersion(fRun->GetRunId(),1); par->setChanged(kTRUE); par->init(); //================================================================================ // build a run specific geometry // run the FopiGeom.C in a separate root session // // taroff: distance between target and center of magnet // targetpos: distance between real target position and nominal FOPI target // position // In experiment S339 the distance between the nominal FOPI target position // and the center of the magnet is 41 cm. Double_t taroff = -65; Double_t targetpos = taroff+41.; // possible materials: copper (default), lead, carbon TString targetmat = TString("copper"); TString alignmentFileName = par->getAlignmentFile(); TString geoFile; TString command; command.Form(".! root -b -q '$VMCWORKDIR/macro/tpc/FOPI/make_TPC_geo.C(kTRUE,\"%s\")'",alignmentFileName.Data()); cout<ProcessLine(command); TString command2; // command2.Form(".! root -b -q '$VMCWORKDIR/macro/tpc/FOPI/make_FOPI_target.C(\"%s\")'",targetmat.Data()); gROOT->ProcessLine(command2); // In general, the following parts need not be touched // ======================================================================== // ----- Timer -------------------------------------------------------- TStopwatch timer; timer.Start(); // ------------------------------------------------------------------------ // Set Material file Name //----------------------- fRun->SetMaterials("media_pnd.geo"); // Create and add detectors //------------------------- // FairModule *Cave= new FopiDetector("FOPI"); // Cave->SetGeometryFileName(geoFile); // fRun->AddModule(Cave); FairModule *Cave= new PndCave("CAVE"); Cave->SetGeometryFileName("pndcave.geo"); fRun->AddModule(Cave); //FairModule* fopitarget= (FairModule*) new FopiTarget("fopitarget","fopi target"); //fopitarget->SetGeometryFileName("FOPI_TARGET.root"); // fRun->AddModule(fopitarget); TpcDetector *Tpc = new TpcDetector("TPC", kTRUE); //Tpc->SetGeometryFileName(geoFileName); Tpc->SetGeometryFileName("FOPI_TPC.root"); Tpc->SetMixture("TPCmixture"); // TPCmixture: Neon CO2 (90/10) //NEEDS TO BE IMPLEMENTED!! if(mcMode=="TGeant3") Tpc->SetAliMC(); fRun->AddModule(Tpc); // TpcShield* TpcShield = new TpcShield("SHIELD", kTRUE); // TpcShield->SetGeometryFileName("FOPI_TPC_SHIELD.root"); // fRun->AddModule(TpcShield); FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); fRun->SetGenerator(primGen); TpcAsciiGiBUUGenerator* gibuuGen = new TpcAsciiGiBUUGenerator("/nfs/hicran/data/tpc/fopi/2011/GiBUU/piCarbon11.dat"); // gibuuGen->SetStartEvent(220063); //Ordering of next two calls important! // gibuuGen->ParticleFilter(3122); gibuuGen->SetStartEvent(nEvents*run); gibuuGen->SetTargetThickness(0); gibuuGen->SetVetoRadius(0); primGen->AddGenerator(gibuuGen); // Create and Set Magnetic Field // -------------------- // Constant Field // PndConstField *fMagField=new PndConstField(); // fMagField->SetField(0., 0. , 6. ); // values are in kG // fMagField->SetFieldRegion(-50, 50,-50, 50, -2000, 2000); // values are in cm // fRun->SetField(fMagField); FOPIField *fMagField = new FOPIField(0.616); fMagField->SetTargetOffset(taroff); fRun->SetField(fMagField); /**Initialize the session*/ fRun->Init(); // PndStack* stack = (PndStack*) gMC->GetStack(); // stack->StoreSecondaries(kTRUE) // stack->SetMinPoints(0) // stack->SetEnergyCut(0) // stack->StoreMothers(kTRUE) // Initialize the Digimapper: // TpcDigiPar* tpcpar = FairRun::Instance()->GetRuntimeDb()->getContainer("TpcDigiPar"); // TpcDigiMapper::getInstance()->init(tpcpar); // //TpcDigiMapper::getInstance()->forceManualDriftVel(forceDriftVel); // TpcAlignmentManager::init(tpcpar->getAlignmentFile()); rtdb->saveOutput(); rtdb->print(); // Transport nEvents // ----------------- fRun->Run(nEvents); timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); cout << endl << endl; cout << "Macro finished succesfully." << endl; cout << "Output file is " << outfile << endl; cout << "Parameter file is " << parfile << endl; cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl; cout << endl; // ------------------------------------------------------------------------ }