22 if (fff.IsZombie()) fileok=
false;
23 TTree *
t=(TTree*)fff.Get(
"pndsim");
24 if (t==0
x0) fileok=
false;
26 if (!fileok) cout <<
"Skipping broken file '"<<fn<<
"'"<<endl;
33 s.ReplaceAll(
"\t",
" ");
36 while (s.Contains(delim))
39 s.Remove(0,tok.Length()+delim.Length());
40 tok = (
TString)tok.Strip(TString::kBoth);
49 ifstream input(filename.Data(), std::ifstream::in);
53 for( std::string line; getline( input, line ); )
56 if (modeline.Contains(
"#")) modeline = modeline(0, modeline.Index(
"#"));
57 modeline = modeline.Strip(TString::kBoth);
58 if (modeline!=
"") res.push_back(
TString(modeline));
70 TString path =
TString(gSystem->Getenv(
"VMCWORKDIR"))+
"/macro/production/scripts/";
71 TString modefile = path+
"table_modes_prod_ana.txt";
72 std::vector<TString> modetab =
ReadModeTab(modefile);
84 TString anadecay =
"D0 -> K- pi+; pbp->D0 D0_bar";
85 TString anaparms =
"fit4cbest:mwin=0.8";
88 for (
int i=0;
i<(int)modetab.size(); ++
i)
92 if (v[0].Atoi() ==
mode)
98 anaparms +=
":algo=PidAlgoMvd;PidAlgoMdtHardCuts;PidAlgoDrc;PidAlgoStt;PidAlgoEmcBayes;PidAlgoSciT;PidAlgoFtof";
106 bool fastsim =
false;
124 if (prefix==
"" || prefix==
"!")
126 cout <<
"Example analysis macro using PndSimpleCombiner(Task). !! MODIFY for your purpose !!\n\n";
128 cout <<
"prod_ana.C( <pref>, <from>, <to>, [mode], [nevt] )\n\n";
129 cout <<
" <pref> : input/output file names prefix or full input file name\n";
130 cout <<
" <from> : first run number\n";
131 cout <<
" <to> : last run number\n";
132 cout <<
" [mode] : arbitrary mode number; default: 0\n";
133 cout <<
" [nevt] : number of events; default: 0 = all\n\n";
134 cout <<
"Example : root -l -b -q 'prod_ana.C(\"mysim\",1,20,10)'\n\n";
136 if (modetab.size()>0) cout <<
"\nFound "<<modetab.size()<<
" analysis modes in "<<modefile<<
".\n"<<endl;
138 if (modetab.size()>0 && prefix==
"!")
140 for (
int i=0;
i <(int)modetab.size(); ++
i)
143 printf(
"(%02d) Mode %4s @ %s = %7s GeV : %s [PARM: %s]\n", i, v[0].Data(), v[1].Atof()<0 ?
"E" :
"p", v[1].Data(), v[2].Data(), v[3].Data());
150 double mp = 0.938272;
157 double X = (Mom*Mom-2*mp*
mp)/(2*mp);
158 Mom =
sqrt(X*X-mp*mp);
162 Ecm =
sqrt(pow(
sqrt(Mom*Mom + mp*mp) + mp,2) - Mom*Mom);
166 cout <<
"------------------------------------------------\n";
167 cout <<
" Current analysis configuration\n";
168 cout <<
"------------------------------------------------\n";
169 printf(
" Mode : %d (%d)\n",
mode, modefromtab);
170 printf(
" p_beam : %.3f GeV/c\n", Mom);
171 printf(
" E_cm : %.3f GeV\n", Ecm);
172 cout <<
" reco : "<<anadecay<<endl;
173 cout <<
" params : "<<anaparms<<endl;
174 cout <<
" softtrig : "<<(runST?
"yes":
"no")<<endl;
175 cout <<
"------------------------------------------------\n\n";
178 prefix.ReplaceAll(
"!",
"");
179 if (prefix==
"")
return 0;
182 TString suffix = fastsim ?
"fsim" :
"pid";
184 TString outFile = TString::Format(
"%s_ana_%d_%d.root",prefix.Data(), from, to);
186 TString firstFile = TString::Format(
"%s_%d_%s.root",prefix.Data(),from,suffix.Data());
189 if (prefix.EndsWith(
".root"))
193 outFile.ReplaceAll(
".root",
"_ana.root");
198 else if (from>=to) outFile = TString::Format(
"%s_%d_ana.root", prefix.Data(), from);
208 FairRunAna *
fRun =
new FairRunAna();
209 FairFileSource *fSrc =
new FairFileSource(firstFile);
212 for (
int i=from+1;
i<=to;++
i)
214 TString fname = TString::Format(
"%s_%d_%s.root",prefix.Data(),
i,suffix.Data());
215 if (
checkfile(fname) ) fSrc->AddFile(fname);
218 fRun->SetSource(fSrc);
221 TString pidParFile =
TString(gSystem->Getenv(
"VMCWORKDIR"))+
"/macro/params/all.par";
224 FairLogger::GetLogger()->SetLogToFile(kFALSE);
244 fRun->SetOutputFile(outFile);
262 TString pidalgo =
"PidAlgoEmcBayes;PidAlgoDrc;PidAlgoDisc;PidAlgoStt;PidAlgoMdtHardCuts;PidAlgoSciT";
263 if (fastsim) pidalgo =
"PidChargedProbability";
266 anadecay.ReplaceAll(
"pbp",
"pbarpSystem");
267 anadecay.ReplaceAll(
"pbp0",
"pbarpSystem0");
268 anaparms.ReplaceAll(
"pbp",
"pbarpSystem");
269 anaparms.ReplaceAll(
"pbp0",
"pbarpSystem0");
273 TDatabasePDG::Instance()->AddParticle(
"pbarpSystem",
"pbarpSystem",3,kFALSE,0.1,0,
"",88888);
274 TDatabasePDG::Instance()->AddParticle(
"pbarpSystem0",
"pbarpSystem0",3,kFALSE,0.1,0,
"",88880);
278 if (fastsim) anaparms+=
":algo="+pidalgo;
282 fRun->AddTask(scTask);
296 bool partQA = (anaparms.Contains(
"qapart"));
297 bool mc = !(anaparms.Contains(
"!mc"));
298 bool neut = !(anaparms.Contains(
"!neut"));
299 bool chrg = !(anaparms.Contains(
"!chrg"));
304 fRun->AddTask(partQaTask);
320 TString triggercfg =
TString(gSystem->Getenv(
"VMCWORKDIR"))+
"/softrig/triggerlines.cfg";
321 if (fastsim) triggercfg =
TString(gSystem->Getenv(
"VMCWORKDIR"))+
"/softrig/triggerlines_fsim.cfg";
325 if (fastsim) stTask->SetFastSimDefaults();
326 else stTask->SetFullSimDefaults();
328 fRun->AddTask(stTask);
342 FairSystemInfo sysInfo;
343 Float_t maxMemory=sysInfo.GetMaxMemory();
347 Float_t cpuUsage=ctime/
rtime;
350 cout <<
"[INFO ] Macro call : prod_fsim.C(\""<<prefix<<
"\", "<<from<<
", "<<to<<
", "<<
mode<<
", "<<nevts<<
")" <<endl;
351 cout <<
"[INFO ] Output file : " << outFile << endl;
352 cout <<
"[INFO ] Real time : " << rtime <<
" s, CPU time " << ctime <<
"s" << endl;
353 cout <<
"[INFO ] CPU usage : " << cpuUsage*100. <<
"%" << endl;
354 cout <<
"[INFO ] Max Memory : " << maxMemory <<
" MB" << endl;
355 cout <<
"[INFO ] Macro finished successfully." << endl<<endl;
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
friend F32vec4 sqrt(const F32vec4 &a)
void SetPidAlgo(TString algo)
StrVec ReadModeTab(TString filename)
int prod_ana(TString prefix="", int from=1, int to=1, int mode=0, int nevts=0)
int SplitString(TString s, TString delim, StrVec &toks)
bool checkfile(TString fn)