void runMCFOPI_target_mb(Int_t field, TString gas, Int_t gain, TString outdir, int nEvents=5000, Int_t run = 1, unsigned int seed=0, TString addon="", Int_t type=0, //not used Double_t phi=0,//not used Double_t theta=0//not used ) { // ------------------------------------------------------------------------ gRandom->SetSeed(seed); // ======================================================================== // 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=Form("Cosmics_FopiMC_%i%s%i_%i.mc.root",field,gas.Data(),gain,run); TString outfile = jobdir+jobname; std::cout<SetOutputFile(outfile); std::cout<<"Set output file to "<Getenv("VMCWORKDIR"); digifile += Form("/tpc/FOPI/par/tpc.%i%s%iMC",field,gas.Data(),gain); digifile += addon; digifile += ".par"; std::cout<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); // In general, the following parts need not be touched // ======================================================================== // ----- Timer -------------------------------------------------------- TStopwatch timer; timer.Start(); // ------------------------------------------------------------------------ // Set Material file Name //----------------------- fRun->SetMaterials("media_pnd.geo"); TpcDigiPar* par = (TpcDigiPar*) rtdb->getContainer("TpcDigiPar"); par->setInputVersion(fRun->GetRunId(),1); par->setChanged(kTRUE); par->init(); Double_t taroff = -65; Double_t targetpos = taroff+41.; // possible materials: copper (default), lead, carbon TString targetmat = TString("copper"); TString alignmentFileName = par->getAlignmentFile(); TFile* geotmp =new TFile("geometry/FOPI_TPC.root","READ"); if(geotmp->IsOpen()) { std::cout<<"geofile exists already\n"; geotmp->Close(); } else { TString command; command.Form(".! root -b -q '$PANDAPATH/macro/tpc/FOPI/make_TPC_geo.C(true,\"%s\")'",alignmentFileName.Data()); std::cout<ProcessLine(command); } FairModule *Cave= new PndCave("CAVE"); Cave->SetGeometryFileName("pndcave.geo"); fRun->AddModule(Cave); TpcDetector *Tpc = new TpcDetector("TPC", kTRUE); Tpc->SetGeometryFileName("FOPI_TPC.root"); Tpc->SetMixture("TPCFOPI_mix"); // TPCFOPI_mix: Ar CO2 (90/10) if(mcMode=="TGeant3") Tpc->SetAliMC(); //Tpc->SetAllSensitive(kTRUE); fRun->AddModule(Tpc); FairPrimaryGenerator* primGen = new FairPrimaryGenerator(); fRun->SetGenerator(primGen); FairBoxGeneratorMOD* boxGen = new FairBoxGeneratorMOD(13,1); boxGen->SetPRange(1,2); // GeV/c boxGen->SetPhiRange(0.,360.); // Azimuth angle range [degree] boxGen->SetThetaRange(4.,176.); // Polar angle in lab system range [degree] //boxGen->SetBoxXYZ(-1.,1. , 1.,1., 0., 75.); //random along zaxis boxGen->SetBoxXYZ(-1.,1. , -1.,1., 37, 38); // boxGen->SetPhiRange(262.,278.); // Azimuth angle range [degree] // boxGen->SetThetaRange(57.,96.); // Polar angle in lab system range [degree] // boxGen->SetXYZ(0., 100., 0.); // boxGen->SetPhiRange(269.14,270.86); // Azimuth angle range [degree] // boxGen->SetThetaRange(89.2, 93.7); // Polar angle in lab system range [degree] // boxGen->SetXYZ(0., 1000., 0.); primGen->AddGenerator(boxGen); FairBoxGenerator* targetGen = new FairBoxGenerator(13, 1); targetGen->SetPRange(0.1,0.5); // GeV/c targetGen->SetPhiRange(0, 360); // Azimuth angle range [degree] targetGen->SetThetaRange(4., 176.); // Polar angle in lab system range [degree] targetGen->SetXYZ(0., 0., 35.); //primGen->AddGenerator(targetGen); // 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 Double_t taroff= -65; FOPIField * fMagField = new FOPIField(0.616); fMagField->SetTargetOffset(taroff); fRun->SetField(fMagField); /**Initialize the session*/ fRun->Init(); rtdb->saveOutput(); rtdb->print(); // Transport nEvents // ----------------- fRun->Run(nEvents); timer.Stop(); Double_t rtime = timer.RealTime(); Double_t ctime = timer.CpuTime(); std::cout << std::endl << std::endl; std::cout << "Macro finished succesfully." << std::endl; std::cout << "Output file is " << outfile << std::endl; std::cout << "Parameter file is " << parfile << std::endl; std::cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << std::endl; std::cout << std::endl; // ------------------------------------------------------------------------ }