17 if (prefix==
"" || inputGen==
"" || pbeam==0.)
20 cout <<
"prod_fsim.C( <pref>, <nevt>, <gen>, <pbeam>, <simopt> )\n\n";
21 cout <<
" <pref> : output file names prefix\n";
22 cout <<
" <nevt> : number of events\n";
23 cout <<
" <gen> : generator input: EvtGen decfile; DPM/FTF/BOX uses DPM/FTF generator (inelastic mode) or BOX generator instead\n";
24 cout <<
" DPM settings: DPM = inelastic only, DPM1 = inel. + elastic, DPM2 = elastic only\n";
25 cout <<
" FTF settings: FTF = inel. + elastic, FTF1 = inelastic only\n";
26 cout <<
" BOX settings: type[pdgcode,mult] and optional ranges 'p/tht/phi[min,max]' separated with colon; example: 'BOX:type[211,1]:p[1,5]:tht[45]:phi[90,210]'\n";
27 cout <<
" <pbeam> : pbar momentum (for BOX generator it still controls the magnetic field) \n";
28 cout <<
" <simopt> : option like e.g. \"SetupB:Filter2:EMC[22-120]\"\n\n";
29 cout <<
"Example 1 : root -l -b -q 'prod_fsim.C(\"EvtD0D0b\", 100, \"D0toKpi.dec:pbarpSystem0\", 12.)'\n";
30 cout <<
"Example 2 : root -l -b -q 'prod_fsim.C(\"DpmInel\", 100, \"DPM\", 12.)'\n";
31 cout <<
"Example 3 : root -l -b -q 'prod_fsim.C(\"SingleK\", 100, \"BOX:type[321,1]:p[0.1,10]:tht[22,140]:phi[0,360]\", 12.)'\n\n";
52 std::vector<TString> opts;
59 if (op==
"setupb") setupmode=1;
62 if (op.BeginsWith(
"emc"))
64 op.ReplaceAll(
"emc[",
"");
65 op.ReplaceAll(
"]",
"");
67 thtmin = ((
TString)op(0,op.Index(
"-"))).Atof();
68 thtmax = ((
TString)op(op.Index(
"-")+1,1000)).Atof();
72 if (op.BeginsWith(
"slc"))
74 op.ReplaceAll(
"slc[",
"");
75 op.ReplaceAll(
"]",
"");
77 phimin = ((
TString)op(0,op.Index(
"-"))).Atof();
78 phimax = ((
TString)op(op.Index(
"-")+1,1000)).Atof();
82 if (op.BeginsWith(
"filter"))
84 op.ReplaceAll(
"filter",
"");
85 filtermode = op.Atoi();
89 if (op.BeginsWith(
"seed"))
91 op.ReplaceAll(
"seed",
"");
96 gRandom->SetSeed(rndseed);
99 cout <<
"------------------------------"<<endl;
100 cout <<
"Setup : "<<(setupmode==0?
"A":
"B")<<endl;
101 cout <<
"Filter : "<<filtermode<<endl;
102 cout <<
"EMC Barrel tht : "<<thtmin<<
" < tht < "<<thtmax<<endl;
103 cout <<
"EMC Barrel phi : "<<phimin<<
" < phi < "<<phimax<<
" OR "<<phimin+180.<<
" phi "<<phimax+180<<endl;
104 cout <<
"Rndm seed : "<<gRandom->GetSeed()<<endl;
105 cout <<
"------------------------------"<<endl;
113 double mp = 0.938272;
116 double X = (pbeam*pbeam-2*mp*
mp)/(2*mp);
117 pbeam =
sqrt(X*X-mp*mp);
119 double Ecm =
sqrt(pow(
sqrt(pbeam*pbeam + mp*mp) + mp,2) - pbeam*pbeam);
123 TLorentzVector
fIni(0,0,pbeam,mp+
sqrt(pbeam*pbeam+mp*mp));
124 TDatabasePDG *pdg = TDatabasePDG::Instance();
125 pdg->AddParticle(
"pbarpSystem",
"pbarpSystem",fIni.M(),kFALSE,0.1,0,
"",88888,0);
126 pdg->AddParticle(
"pbarpSystem0",
"pbarpSystem0",fIni.M(),kFALSE,0.1,0,
"",88880,0);
127 pdg->AddParticle(
"eta_c1",
"eta_c1",4.3,kFALSE,0.02,0,
"",999441);
131 Bool_t enableSplitoff =
true;
132 Bool_t mergeNeutrals =
true;
133 Bool_t electronBrems =
true;
136 Bool_t usePndEventFilter = (filtermode >= 0);
140 TString BaseDir = gSystem->Getenv(
"VMCWORKDIR");
141 TString splitpars = BaseDir+
"/fsim/splitpars.dat";
144 TString OutputFile = prefix+
"_fsim.root";
155 FairRunSim *
fRun =
new FairRunSim();
156 fRun->SetOutputFile(OutputFile.Data());
157 fRun->SetGenerateRunInfo(kFALSE);
160 FairLogger::GetLogger()->SetLogToFile(kFALSE);
167 if (!usePndEventFilter) primGen->
SetVerbose(0);
168 fRun->SetGenerator(primGen);
169 fRun->SetName(
"TGeant3");
179 if (inputGen.BeginsWith(
"DPM",TString::kIgnoreCase) && !inputGen.EndsWith(
".dec",TString::kIgnoreCase))
183 if (inputGen==
"dpm1") mode = 1;
184 if (inputGen==
"dpm2") mode = 2;
199 primGen->AddGenerator(Dpm);
205 else if (inputGen.BeginsWith(
"FTF",TString::kIgnoreCase) && !inputGen.EndsWith(
".dec",TString::kIgnoreCase))
209 primGen->AddGenerator(Ftf);
215 else if (inputGen.BeginsWith(
"BOX",TString::kIgnoreCase) && !inputGen.EndsWith(
".dec",TString::kIgnoreCase))
235 inputGen.ReplaceAll(
"box",
"");
236 inputGen.ReplaceAll(
" ",
"");
239 while (inputGen.Contains(
":"))
241 TString curpar = inputGen(0,inputGen.Index(
":"));
242 inputGen = inputGen(inputGen.Index(
":")+1,1000);
243 curpar.ReplaceAll(
"[",
"("); curpar.ReplaceAll(
"]",
")");
245 if (curpar.BeginsWith(
"type(")) {
getRange(curpar,type,
mult); BoxType = (Int_t)type; BoxMult = (Int_t)
mult; }
246 if (curpar.BeginsWith(
"p("))
getRange(curpar,BoxMomMin,BoxMomMax);
247 if (curpar.BeginsWith(
"tht("))
getRange(curpar,BoxThtMin,BoxThtMax);
248 if (curpar.BeginsWith(
"ctht(")) {
getRange(curpar,BoxThtMin,BoxThtMax); BoxCosTht=
true;}
249 if (curpar.BeginsWith(
"phi("))
getRange(curpar,BoxPhiMin,BoxPhiMax);
253 cout <<
"BOX generator range: type["<<BoxType<<
","<<BoxMult<<
"] p["<<BoxMomMin<<
","<<BoxMomMax
254 <<
"] tht["<<BoxThtMin<<
","<<BoxThtMax<<
"]"<<(BoxCosTht?
"*":
"")<<
" phi["<<BoxPhiMin<<
","<<BoxPhiMax<<
"]"<<endl;
260 boxGen->SetPRange(BoxMomMin,BoxMomMax);
261 boxGen->SetPhiRange(BoxPhiMin, BoxPhiMax);
262 boxGen->SetThetaRange(BoxThtMin, BoxThtMax);
264 if (BoxCosTht) boxGen->SetCosTheta();
266 boxGen->SetXYZ(0., 0., 0.);
267 primGen->AddGenerator(boxGen);
276 Resonance.ReplaceAll(
"pbp",
"pbarpSystem");
280 primGen->AddGenerator(EvtGen);
284 primGen->DoTracking(kFALSE);
288 fRun->SetField(fField);
302 if (usePndEventFilter)
305 cout <<
"Using FairEventFilter"<<endl;
420 fastSim->
AddDetector(
"ScMvdGem",
"thtMin=5. thtMax=7.8 ptmin=0.1 pmin=0.0 pRes=0.04 thtRes=0.003 phiRes=0.003 efficiency=0.55");
421 fastSim->
AddDetector(
"ScSttMvdGem",
"thtMin=7.8 thtMax=20.9 ptmin=0.1 pmin=0.0 pRes=0.025 thtRes=0.002 phiRes=0.002 efficiency=0.82");
422 fastSim->
AddDetector(
"ScSttMvd",
"thtMin=20.9 thtMax=145. ptmin=0.1 pmin=0.0 pRes=0.03 thtRes=0.003 phiRes=0.003 efficiency=0.80");
423 fastSim->
AddDetector(
"ScSttAlone",
"thtMin=145. thtMax=159.5 ptmin=0.1 pmin=0.0 pRes=0.05 thtRes=0.006 phiRes=0.007 efficiency=0.25");
433 fastSim->
AddDetector(
"ScVtxNoMvd",
"thtMin=5. thtMax=145. ptmin=0.1 vtxRes=0.02 efficiency=1.");
441 fastSim->
AddDetector(
"EmcFwCap",
"thtMin=10.0 thtMax=22.0 Emin=0.01 dist=2.5");
442 fastSim->
AddDetector(
"EmcBwCap",
"thtMin=142.0 thtMax=160.0 Emin=0.01 dist=0.7");
444 fastSim->
AddDetector(
"EmcFS",
"thtMin=0.05 thtMax=10.0 aPar=0.013 bPar=0.0283 Emin=0.01 dist=8.2");
449 fastSim->
AddDetector(
"EmcBarrel1", Form(
"thtMin=%.1f thtMax=%.1f phiMin=%.1f phiMax=%.1f Emin=0.01 barrelRadius=0.5", thtmin, thtmax, phimin, phimax));
450 fastSim->
AddDetector(
"EmcBarrel2", Form(
"thtMin=%.1f thtMax=%.1f phiMin=%.1f phiMax=%.1f Emin=0.01 barrelRadius=0.5", thtmin, thtmax, phimin-180., phimax-180.));
458 fastSim->
AddDetector(
"DrcBarrel",
"thtMin=22.0 thtMax=140.0 dthtc=0.01 nPhotMin=5 effNPhotons=0.075");
463 fastSim->
AddDetector(
"Tof",
"thtMin=22.0 thtMax=140.0 dp=0.01");
467 fastSim->
AddDetector(
"SttPid",
"thtMin=7.8 thtMax=159.5 ptmin=0.1 dEdxRes=0.15 efficiency=1.");
469 fastSim->
AddDetector(
"MvdPid",
"thtMin=5. thtMax=133.6 ptmin=0.1 dEdxResMulti=1. efficiency=1.");
474 fastSim->
AddDetector(
"ScMdtPidBarrel",
"thtMin=10.0 thtMax=130.0 pmin=0.5 efficiency=0.95 misId=0.01");
475 fastSim->
AddDetector(
"ScMdtPidForward",
"thtMin=0.0 thtMax=10.0 pmin=0.5 efficiency=0.95 misId=0.01");
479 fastSim->
AddDetector(
"ScEmcPidFwCap",
"thtMin=10.0 thtMax=22.0 ptmin=0.0 pmin=0.0 efficiency=1.0");
480 fastSim->
AddDetector(
"ScEmcPidBwCap",
"thtMin=142.0 thtMax=160.0 ptmin=0.0 pmin=0.0 efficiency=1.0");
483 fastSim->
AddDetector(
"ScEmcPidFS",
"thtMin=0.5 thtMax=10.0 ptmin=0.0 pmin=0.5 efficiency=1.0");
488 fastSim->
AddDetector(
"ScEmcPidBarrel1", Form(
"thtMin=%.1f thtMax=%.1f phiMin=%.1f phiMax=%.1f ptmin=0.2 pmin=0.0 efficiency=1.0", thtmin, thtmax, phimin, phimax));
489 fastSim->
AddDetector(
"ScEmcPidBarrel2", Form(
"thtMin=%.1f thtMax=%.1f phiMin=%.1f phiMax=%.1f ptmin=0.2 pmin=0.0 efficiency=1.0", thtmin, thtmax, phimin-180., phimax-180.));
498 fRun->AddTask(fastSim);
511 FairSystemInfo sysInfo;
512 Float_t maxMemory=sysInfo.GetMaxMemory();
516 Float_t cpuUsage=ctime/
rtime;
519 cout <<
"[INFO ] Macro call : prod_fsim.C(\""<<prefix<<
"\", "<<
nEvents<<
", \""<<inputGen<<
"\", "<<pbeam<<
")" <<endl;
521 cout <<
"[INFO ] Output file : " << OutputFile << endl;
522 cout <<
"[INFO ] Real time : " << rtime <<
" s, CPU time " << ctime <<
"s" << endl;
523 cout <<
"[INFO ] CPU usage : " << cpuUsage*100. <<
"%" << endl;
524 cout <<
"[INFO ] Max Memory : " << maxMemory <<
" MB" << endl;
525 cout <<
"[INFO ] Macro finished successfully." << endl<<endl;
533 par.ReplaceAll(
" ",
"");
534 par =
par(par.Index(
"(")+1, par.Length()-par.Index(
"(")-2);
538 if (par.Contains(
","))
540 smin =
par(0,par.Index(
","));
541 smax =
par(par.Index(
",")+1,1000);
555 if (fEvtGenFile.Contains(
":"))
557 IniRes = fEvtGenFile(fEvtGenFile.Index(
":")+1,1000);
558 fEvtGenFile = fEvtGenFile(0,fEvtGenFile.Index(
":"));
563 std::ifstream fs(fEvtGenFile.Data());
568 fs.getline(line,249);
570 s.ReplaceAll(
"\r",
"");
571 if (IniRes==
"" && s.Contains(
"Decay "))
573 if (s.Contains(
"#")) s=
s(0,s.Index(
"#"));
574 s.ReplaceAll(
"Decay ",
"");
575 s.ReplaceAll(
" ",
"");
589 TObjArray *tok = s.Tokenize(delim);
590 int N = tok->GetEntries();
591 for (
int i=0;
i<N;++
i)
593 TString token = (((TObjString*)tok->At(
i))->String()).Strip(TString::kBoth);
594 toks.push_back(token);
Int_t GetNumberOfGeneratedEvents()
returns the total (accepted + rejected) number of events generated by the event generators. If no event filters are used this number is equal to the number of simulated events.
Bool_t SetMinMaxCounts(Int_t min, Int_t max)
void WriteEvtFilterStatsToRootFile(TFile *outputFile=NULL)
Writes all relevant event filter information to the output root file.
friend F32vec4 sqrt(const F32vec4 &a)
void AndFilter(FairEvtFilter *filter)
Register a non-veto event filter using a logical AND to connect with previously defined non-veto even...
bool AddDetector(std::string name, std::string params="")
TString getInitialResonance(TString &fEvtGenFile)
void SetFilterMaxTries(Int_t maxTries=99999)
Define the maximum number of times that this object should try to find an event which suits all event...
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
void getRange(TString par, double &min, double &max)
void SetUseFlatCov(bool v=true)
FairPrimaryGenerator * primGen
Bool_t SetMinMaxInvMass(Double_t min, Double_t max)
void SetUnstable(int pdg)
Bool_t AndMinCharge(Int_t min, ChargeState charge)
Primary generator with added event filtering capabilities.
bool MergeNeutralClusters(bool merge=true, double par=0.389)
void SetStoreTree(Bool_t store=true)
int prod_fsim(TString prefix="", Int_t nEvents=100, TString inputGen="", Float_t pbeam=0., TString simopt="")
void EnableElectronBremsstrahlung(bool brems=true)
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
bool EnableSplitoffs(std::string fname="splitpars.dat")
int SplitString(TString s, TString delim, StrVec &toks)
FairBoxGenerator * boxGen
void SetVerbosity(int vb)
Bool_t SetPdgCodesToCombine(Int_t pdgCode1, Int_t pdgCode2, Int_t pdgCode3=kInvalidPdgCode, Int_t pdgCode4=kInvalidPdgCode, Int_t pdgCode5=kInvalidPdgCode)
void SetVerbose(Int_t verbose=12)
Set the level of commenting output.