void runMCFOPI_const(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, //0=along y; 1= along x; 2=any angle Double_t phi=0, Double_t theta=0, Int_t bfield=1 ) { // ------------------------------------------------------------------------ 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(2,10.); // GeV/c (2,10) boxGen->SetRandAntiPart(); boxGen->SetDebug(0); //Standart Box generator setting //along y-axis if (type==0) { double shift=0.; shift=(16.+15.)/TMath::Tan(phi*TMath::DegToRad()); //boxGen->SetPhiRange(270.,270.); // Azimuth angle range [degree]; along Y boxGen->SetPhiRange(180.,180.); // Azimuth angle range [degree]; along X //boxGen->SetThetaRange(phi,phi); // Polar angle in lab system range [degree] //boxGen->SetBoxXYZ(-16.,16. , 16.,16.,-1-shift,73); theta=phi; if (theta>2 && theta<178) { double shift=0.; if (theta!=-1) { boxGen->SetThetaRange(theta,theta); //boxGen->SetThetaRange(0,90); shift=(16.+15.)/TMath::Tan(theta*TMath::DegToRad()); } else { boxGen->SetThetaRange(0,180); } //boxGen->SetBoxXYZ(-16.,16. , 16.,16.,-1-shift,73); //for along Y boxGen->SetBoxXYZ(16.,16. , -16.,16.,-1-shift,73); //for along X } else { if (theta<=2) boxGen->SetDonut(4.5,15.5,-1,-1); if (theta>=178) boxGen->SetDonut(4.5,15.5,74,74); boxGen->SetThetaRange(theta,theta); } } //along x-axis else if (type==1) { boxGen->SetPhiRange(180.,180.); // Azimuth angle range [degree] boxGen->SetThetaRange(90.,90.); // Polar angle in lab system range [degree] boxGen->SetBoxXYZ(16.,16. , -16.,16.,-1.,73.); } //along any angle else if (type==2) { boxGen->SetPhiRange(270-phi,270-phi); // Azimuth angle range [degree] double phi_rad=phi*TMath::DegToRad(); double x1=TMath::Sin(phi_rad)*16-TMath::Cos(phi_rad)*16; //sin(phi)*height - cos(phi)*rad double y1=TMath::Cos(phi_rad)*16+TMath::Sin(phi_rad)*16; double x2=TMath::Sin(phi_rad)*16+TMath::Cos(phi_rad)*16; double y2=TMath::Cos(phi_rad)*16-TMath::Sin(phi_rad)*16; boxGen->SetThetaRange(90. , 90.); // Polar angle in lab system range [degree] boxGen->SetPlane1XYZ(x1,x2, y1,y2,-1,73.); } else { std::cout<<"no type given, quitting\n"; return; } 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); if (bfield==1) 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; // ------------------------------------------------------------------------ }