void runMCFOPISphere(Int_t field, TString gas, Int_t gain, TString outdir, int nEvents=5000, Int_t run = 1, unsigned int seed=0, TString addon="") { // ------------------------------------------------------------------------ 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"; cout<GetRuntimeDb(); FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo(); cout<<"opening parfile\n"; parIo1->open(digifile.Data(),"in"); rtdb->setFirstInput(parIo1); Bool_t kParameterMerged=kTRUE; cout<<"setting par output\n"; FairParRootFileIo* parOut=new FairParRootFileIo(kParameterMerged); parOut->open(parfile.Data()); rtdb->setOutput(parOut); // In general, the following parts need not be touched // ======================================================================== // ----- Timer -------------------------------------------------------- cout<<"start timer\n"; TStopwatch timer; timer.Start(); // ------------------------------------------------------------------------ // Set Material file Name //----------------------- cout<<"setting materials\n"; fRun->SetMaterials("media_pnd.geo"); // Create and add detectors //------------------------- cout<<"creating digipar\n"; 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(); std::cout<<"Using Alignment File: "<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()); 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(2,10.); // GeV/c (2,10) boxGen->SetRandAntiPart(); boxGen->SetSphere(90,0,0,36.4); boxGen->SetShift(-16,16,-16,16,-43,43); //boxGen->SetThetaRange(90.,90.); boxGen->SetThetaRange(0.,180.); //boxGen->SetPhiRange(0.,360.); boxGen->SetPhiRange(90.,90.); //boxGen->SetDebug(kTRUE); primGen->AddGenerator(boxGen); // Create and Set Magnetic Field // -------------------- // Constant Field //PndConstField *fMagField=new PndConstField(); //fMagField->SetField(0., 0. , 0. ); // 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(); 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; // ------------------------------------------------------------------------ }