6 # include "AliGenerator.h"
7 # include "AliRunLoader.h"
9 # include "AliHeader.h"
10 # include "AliGenEventHeader.h"
12 # include "AliCollisionGeometry.h"
13 # include "AliGenPythiaEventHeader.h"
14 # include "AliGenDPMjetEventHeader.h"
15 # include "AliGenGeVSimEventHeader.h"
16 # include "AliGenHerwigEventHeader.h"
17 # include "AliGenHijingEventHeader.h"
18 # include "AliGenCocktailEventHeader.h"
23 # include <TParticle.h>
26 # include <TClonesArray.h>
30 # include <TParticlePDG.h>
31 # include <TStopwatch.h>
33 # include <TProofOutputFile.h>
39 # include <TSystemDirectory.h>
40 # include <TFileCollection.h>
41 # include <TPRegexp.h>
53 class AliGenEventHeader;
60 class TProofOutputFile;
97 Register(
"list/histograms/b",
"hist", 0,
false);
98 Register(
"list/histograms/cent",
"hist", 0,
false);
99 Register(
"list/histograms/timing",
"hist", 0x18,
false);
100 Register(
"list/histograms/dNdeta",
"", 0x18,
false);
101 Register(
"list/histograms/dNdy",
"", 0x18,
false);
102 Register(
"list/estimators/rawV0MP",
"e", 0x02,
false);
103 if (gProof) gProof->AddFeedback(
"list");
171 if (egName.IsNull()) egName =
fEGName;
173 fn = Form(
"%s_%09d", egName.Data(),
fRunNo);
176 Int_t tgtA, tgtZ, projA, projZ;
178 fGenerator->GetProjectile(proj, projA, projZ);
179 fn.Append(Form(
"_%s%s", tgt.Data(), proj.Data()));
183 Long_t en = gROOT->ProcessLine(
"grp->energy");
186 fn.Append(Form(
"_%s%s", (
fIsTgtA ?
"A" :
"p"),
188 fn.Append(Form(
"_%05ld", (
fGRP ? en : 0)));
193 fn.Append(Form(
"_%lldM",
fNEvents/1000000));
195 fn.Append(Form(
"_%lldk",
fNEvents/1000));
210 const char*
GetName()
const {
return "FastSim"; }
216 const char*
GetTitle()
const {
return "ALICE Event Generator simulation"; }
226 else fsNN = gROOT->ProcessLine(
"grp->energy");
228 UShort_t sNN = (TMath::Abs(fsNN - 2760) < 10 ? 2760 :
229 TMath::Abs(fsNN - 5023) < 10 ? 5023 :
230 TMath::Abs(fsNN - 2360) < 10 ? 2360 :
231 TMath::Abs(fsNN - 900) < 10 ? 900 :
232 TMath::Abs(fsNN - 7000) < 10 ? 7000 :
233 TMath::Abs(fsNN - 8000) < 10 ? 8000 :
234 TMath::Abs(fsNN - 13000) < 10 ? 13000 :
256 Printf(
"=== Output =============================\n"
258 "========================================",
FileName());
260 if (
fVerbose) Info(
"SetupOutput",
"First the file");
262 if (fInput && fInput->FindObject(
"PROOF_Ordinal"))
265 Info(
"SetupOutput",
"Making Proof File");
276 if (
fVerbose) Info(
"SetupOutput",
"Making our tree: %s", tit.Data());
280 "run/i:event:ntgt:nproj:nbin:type:"
281 "ipx/D:ipy:ipz:b:c:phir:"
282 "nsnp/i:nsnt:nspp:nspt");
283 fTree->Branch(
"particles", &fParticles);
284 fTree->SetAutoSave(500);
285 fTree->SetDirectory(
fFile);
286 fTree->SetAlias(
"primary",
"(particles.fBits&(1<<14))");
287 fTree->SetAlias(
"weak",
"(particles.fBits&(1<<15))");
288 fTree->SetAlias(
"charged",
"(particles.fBits&(1<<16))");
289 fTree->SetAlias(
"pt",
"(sqrt(pow(particles.fPx,2)+"
290 "pow(particles.fPy,2)))");
291 fTree->SetAlias(
"eta",
"(particles.Pt()<1e-100?"
292 "(particles.fPz>0?100:-100):"
293 "-log(tan(atan2(particles.Pt(),particles.fPz)/2)))");
294 fTree->SetAlias(
"good",
"(primary&&charged&&abs(eta)<1000)");
295 fTree->SetAlias(
"sd",
"(header.fType & 0x1)");
296 fTree->SetAlias(
"dd",
"(header.fType & 0x2)");
297 fTree->SetAlias(
"pion",
"(abs(particles.fPdgCode)==211)");
298 fTree->SetAlias(
"kaon",
"(abs(particles.fPdgCode)==321)");
299 fTree->SetAlias(
"proton",
"(abs(particles.fPdgCode)==2212)");
300 fTree->SetAlias(
"electron",
"(abs(particles.fPdgCode)==11)");
301 fTree->SetAlias(
"other",
"(!pion&&!kaon&&!proton&&!electron)");
302 fTree->SetAlias(
"beta",
"(particles.P()/particle.Energy())");
303 fTree->SetAlias(
"gamma",
"(1./sqrt(1-beta*beta))");
304 fTree->SetAlias(
"npart",
"(header.ntgt+header.nproj)");
308 Info(
"SetupOutput",
"Making generator histogram: %s",tit.Data());
309 TH1* egTitle =
new TH1I(
"eg", tit.Data(), 1, 0, 1);
310 egTitle->SetDirectory(0);
312 egTitle->SetXTitle(
"N_{\\hbox{workers}}");
313 egTitle->SetYTitle(
"Count");
314 egTitle->SetFillColor(kYellow+4);
315 egTitle->SetLineColor(kYellow+4);
316 egTitle->SetMarkerColor(kYellow+4);
317 egTitle->SetFillStyle(1001);
318 egTitle->SetMarkerStyle(1);
319 egTitle->SetLineStyle(1);
320 egTitle->SetLineWidth(2);
321 egTitle->SetMarkerSize(1);
324 if (
fVerbose) Info(
"SetupOutput",
"Making histograms");
327 fHEta =
new TH1D(
"dNdeta",
"Charged particle pseudo-rapidity density",
328 Int_t(2*maxEta/dEta+.5), -maxEta, +maxEta);
330 fHEta->SetXTitle(
"\\eta");
331 fHEta->SetYTitle(
"\\hbox{d}N_{\\hbox{ch}}/\\hbox{d}\\eta");
332 fHEta->SetMarkerColor(kRed+2);
333 fHEta->SetMarkerStyle(20);
334 fHEta->SetDirectory(0);
336 fHY =
new TH1D(
"dNdy",
"Charged particle rapidity density",
337 Int_t(2*maxEta/dEta+.5), -maxEta, +maxEta);
339 fHY->SetXTitle(
"\\mathit{y}");
340 fHY->SetYTitle(
"\\hbox{d}N_{\\hbox{ch}}/\\hbox{d}y");
341 fHY->SetMarkerColor(kRed+2);
342 fHY->SetMarkerStyle(20);
343 fHY->SetDirectory(0);
345 fHIpz =
new TH1D(
"ipZ",
"Z-coordinate of interaction point",
347 fHIpz->SetMarkerColor(kGreen+2);
348 fHIpz->SetFillColor(kGreen+2);
349 fHIpz->SetFillStyle(3001);
350 fHIpz->SetXTitle(
"IP_{#it{z}} [cm]");
351 fHIpz->SetDirectory(0);
353 fHType =
new TH1D(
"type",
"Diffractive", 3, .5, 3.5);
354 fHType->SetMarkerColor(kOrange+2);
355 fHType->SetFillColor(kOrange+2);
356 fHType->SetFillStyle(3001);
358 fHType->GetXaxis()->SetBinLabel(1,
"Non");
359 fHType->GetXaxis()->SetBinLabel(2,
"Single");
360 fHType->GetXaxis()->SetBinLabel(3,
"Double");
362 fHCent =
new TH1D(
"cent",
"Centrality", 20, 0, 100);
363 fHCent->SetMarkerColor(kPink+2);
364 fHCent->SetFillColor(kPink+2);
365 fHCent->SetFillStyle(3001);
367 fHCent->SetYTitle(
"Events");
368 fHCent->SetXTitle(
"Centrality [%]");
370 fHB =
new TH1D(
"b",
"Impact parameter", 20, 0, 20);
371 fHB->SetMarkerColor(kYellow+2);
372 fHB->SetFillColor(kYellow+2);
373 fHB->SetFillStyle(3001);
374 fHB->SetYTitle(
"Events");
375 fHB->SetXTitle(
"#it{b} [fm]");
376 fHB->SetDirectory(0);
378 fHPhiR =
new TH1D(
"phiR",
"Event plane angle", 360, 0, 360);
379 fHPhiR->SetMarkerColor(kMagenta+2);
380 fHPhiR->SetFillColor(kMagenta+2);
381 fHPhiR->SetFillStyle(3001);
382 fHPhiR->SetXTitle(
"#it{#Phi}_{R} [degrees]");
385 fHTime =
new TH1D(
"timing",
"Timing of processing", 5,0.5,5.5);
386 fHTime->SetMarkerColor(kBlue+2);
387 fHTime->SetFillColor(kBlue+2);
388 fHTime->SetFillStyle(3001);
389 fHTime->SetYTitle(
"seconds / event");
390 fHTime->GetXaxis()->SetBinLabel(1,
"Reset");
391 fHTime->GetXaxis()->SetBinLabel(2,
"Generate");
392 fHTime->GetXaxis()->SetBinLabel(3,
"Header");
393 fHTime->GetXaxis()->SetBinLabel(4,
"Particles");
394 fHTime->GetXaxis()->SetBinLabel(5,
"Filling");
398 fList->SetName(
"list");
402 histos->SetName(
"histograms");
403 histos->SetOwner(
true);
415 estimators->SetName(
"estimators");
416 estimators->SetOwner(
true);
417 fList->Add(estimators);
422 while ((estimator = static_cast<FastCentEstimator*>(next()))) {
428 if (
fVerbose) Info(
"SetupOutput",
"Adding list ot outputs");
441 std::ifstream in(
"/dev/urandom");
443 in.read(reinterpret_cast<char*>(&seed),
sizeof(seed));
445 Printf(
"=== Random =============================\n"
446 " Random number seed: %d\n"
447 "========================================", seed);
452 Printf(
" === Setup ==============================");
453 Printf(
" Run #: %6d",
fRunNo);
454 Printf(
" EG: %30s",
fEGName.Data());
455 Printf(
" B range: %5.1ffm - %5.1ffm",
fBMin,
fBMax);
456 Printf(
" ========================================");
457 Printf(
"Macro path: %s", gROOT->GetMacroPath());
460 if (!
fGRP && fInput) {
461 fGRP = fInput->FindObject(
"GRP");
462 std::ofstream* pout =
new std::ofstream(
"grp.dat");
465 Info(
"SetupGRP",
"Writing GRP line '%s' to \"grp.dat\"",
467 std::ostream& out = *pout;
468 out <<
fGRP->GetTitle() << std::endl;
473 Info(
"SetupGRP",
"Overrides: %p Input: %p",
fOverrides, fInput);
477 Info(
"SetupGRP",
"No GRP overrides found in input:");
481 if (
fVerbose) Info(
"SetupGRP",
"Loading scripts");
483 if (gROOT->ProcessLine(
"grp") == 0)
484 gROOT->Macro(Form(
"GRP.C(%d)",
fRunNo));
485 if (
fVerbose) Info(
"SetupGRP",
"Perhaps override");
487 gROOT->ProcessLine(
"grp->Print()");
497 if (
fVerbose) Info(
"SetupGen",
"Load base config");
498 gROOT->Macro(
"BaseConfig.C");
499 if (
fVerbose) Info(
"SetupGen",
"Load EG config");
500 gROOT->Macro(
"EGConfig.C");
502 gROOT->ProcessLine(Form(
"VirtualEGCfg::LoadGen(\"%s\")",
fEGName.Data()));
506 TString egMk = Form(
"egCfg->MakeGenerator(\"%s\",%f,%f)",
508 Long64_t egPtr = gROOT->ProcessLine(egMk);
510 Error(
"SetupGen",
"Failed to make generator");
513 fGenerator =
reinterpret_cast<AliGenerator*
>(egPtr);
515 Int_t tgtA=0, tgtZ=0, projA=0, projZ=0;
517 fGenerator->GetProjectile(proj, projA, projZ);
518 fIsTgtA = !(tgtA == tgtZ && tgtA == 1);
519 fIsProjA = !(projA == projZ && projZ == 1);
521 Info(
"SetupGen",
"tgt=%s (%3d,%2d) proj=%s (%3d,%2d) CMS=%fGeV",
522 tgt.Data(), tgtA, tgtZ, proj.Data(), projA, projZ,
524 Info(
"SetupGen",
"Generator: %s",
fGenerator->GetTitle());
538 new AliRun(
"gAlice",
"The ALICE Off-line framework");
541 Printf(
"=== Run ================================\n"
542 " Number of events: %lld\n"
543 "========================================", nev);
544 TObject* ord = (fInput ? fInput->FindObject(
"PROOF_Ordinal") : 0);
549 TObject* save = fInput->FindObject(
"PROOF_SaveGALICE");
551 Info(
"SetupRun",
"Got save option:");
554 TString optSave(save ? save->GetTitle() :
"split");
556 if (optSave.EqualTo(
"none")) saveMode = 0;
557 else if (optSave.EqualTo(
"merge")) saveMode = 1;
558 else if (optSave.EqualTo(
"split")) saveMode = 2;
562 post = Form(
"_%s", ord->GetTitle());
564 TString galiceName(Form(
"%sgalice.root",dir.Data()));
565 TString kineName(Form(
"%sKinematics.root",dir.Data()));
569 fRunLoader = AliRunLoader::Open(galiceName,
"FASTRUN",
"RECREATE");
587 Info(
"SetupRun",
"Not saving galice.root and Kinematics.root");
591 TString aliceOut = Form(
"galice%s.root", post.Data());
592 fAliceFile =
new TProofOutputFile(aliceOut,
"M");
594 TString kineOut = Form(
"Kinematics%s.root", post.Data());
595 fKineFile =
new TProofOutputFile(kineOut,
"M");
605 std::ifstream* pin =
new std::ifstream(
"grp.dat");
607 Warning(
"ReadGRPLine",
"Failed to open \"grp.dat\"");
610 std::istream& in = *pin;
615 if (line.IsNull())
continue;
616 if (line.BeginsWith(
"#"))
continue;
623 Warning(
"ReadGRPLine",
"Got no line from \"grp.dat\"");
628 if (
fVerbose) Info(
"ReadGRPLine",
"Read \"%s\"", env.Data());
637 Long_t ret = gROOT->ProcessLine(
"grp");
639 Warning(
"OverrideGRP",
"GRP not set yet, cannot override");
643 if (
fVerbose) Info(
"OverrideGRP",
"No overrides defined");
648 while ((o = next())) {
650 Info(
"OverrideGRP",
"Overriding GRP setting %s with %s",
651 o->GetName(), o->GetTitle());
652 gROOT->ProcessLine(Form(
"grp->%s = %s;",
653 o->GetName(), o->GetTitle()));
655 Info(
"OverrideGRP",
"After overriding:");
656 gROOT->ProcessLine(
"grp->Print()");
688 if (
fVerbose) Info(
"Begin",
"Called for FastSim");
690 if (
fMonitor > 0 && !gROOT->IsBatch()) {
694 gROOT->Macro(Form(
"GRP.C(%d)",
fRunNo));
697 gProof->AddInput(
fGRP);
701 if (
fVerbose) Info(
"Begin",
"Perhaps override");
703 if (
fVerbose) Info(
"Begin",
"Defining centrality estimators");
731 while ((estimator = static_cast<FastCentEstimator*>(next()))) {
732 estimator->
Print(
"nah");
735 if (
fVerbose) Info(
"Begin",
"End of begin");
743 if (
fVerbose) Info(
"SlavesBegin",
"Called for FastSim");
769 while ((estimator = static_cast<FastCentEstimator*>(next())))
786 fHeader->GenEventHeader()->PrimaryVertex(ip);
792 AliGenEventHeader* genHeader =
fHeader->GenEventHeader();
793 AliCollisionGeometry* geometry =
794 dynamic_cast<AliCollisionGeometry*
>(genHeader);
795 AliGenPythiaEventHeader* pythia =
796 dynamic_cast<AliGenPythiaEventHeader*
>(genHeader);
797 AliGenDPMjetEventHeader* dpm =
798 dynamic_cast<AliGenDPMjetEventHeader*
>(genHeader);
799 AliGenGeVSimEventHeader* gev =
800 dynamic_cast<AliGenGeVSimEventHeader*
>(genHeader);
801 AliGenHerwigEventHeader* herwig =
802 dynamic_cast<AliGenHerwigEventHeader*
>(genHeader);
803 AliGenCocktailEventHeader* cocktail =
804 dynamic_cast<AliGenCocktailEventHeader*
>(genHeader);
805 AliGenHijingEventHeader* hijing =
806 dynamic_cast<AliGenHijingEventHeader*
>(genHeader);
808 TList* headers = cocktail->GetHeaders();
809 if (!headers) Warning(
"",
"No headers in cocktail!");
811 AliGenEventHeader* header = 0;
812 AliCollisionGeometry* geom = 0;
813 while ((header = static_cast<AliGenEventHeader*>(next()))) {
814 AliCollisionGeometry* g =
dynamic_cast<AliCollisionGeometry*
>(header);
816 hijing =
dynamic_cast<AliGenHijingEventHeader*
>(header);
818 if (geom) geometry = geom;
839 Int_t type = pythia->ProcessType();
842 case 92:
case 93: sd =
true;
break;
843 case 94: dd =
true;
break;
848 case 103:
case 104: sd =
true;
break;
849 case 105: dd =
true;
break;
864 for (
Int_t iPart = 0; iPart < nPart; iPart++) {
865 TParticle* particle =
fStack->Particle(iPart);
866 Int_t ks = particle->GetStatusCode();
868 if (ks == 13) side = -1;
869 if (ks == 14) side = +1;
870 if (side == 0)
continue;
871 Int_t kf = particle->GetPdgCode();
873 if (side < 0) nSpecNproj++;
877 if (side < 0) nSpecPproj++;
887 Int_t type = dpm->ProcessType();
888 #ifndef NO_DPMJET_TYPE
890 case 5:
case 6: sd =
true;
894 static bool first =
true;
897 Func_t add =
gSystem->DynFindSymbol(
"*",
"dtglcp_");
899 Warning(
"",
"Didn't find dtglcp_");
910 Int_t nsd1=0, nsd2=0, ndd=0;
911 Int_t npP = dpm->ProjectileParticipants();
912 Int_t npT = dpm->TargetParticipants();
914 dpm->GetNDiffractive(nsd1,nsd2,ndd);
916 if ((ndd == 0) && ((npP == nsd1) || (npT == nsd2))) sd =
true;
917 else if (ndd == (npP + npT)) dd =
true;
918 Int_t ncp = dpm->NN();
919 Int_t nct = dpm->NNw();
920 Int_t nwp = dpm->NwN();
921 Int_t nwt = dpm->NwNw();
925 Printf(
"@ Npp sd1 Npt sd2 dd tpe Ncp Nct Nwp Nwt acc sam");
928 Printf(
"@ %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d",
929 npP, nsd1, npT, nsd2, ndd, type, ncp, nct, nwp, nwt,
935 Int_t type = herwig->ProcessType();
937 case 5:
case 6: sd =
true;
break;
948 Info(
"ProcessHeader",
"b=%f isProjA=%d isTgtA=%d cms=%f",
963 if (!dd && !sd)
fHType->Fill(1);
965 fHEta ->AddBinContent(0);
966 fHY ->AddBinContent(0);
972 while ((estimator = static_cast<FastCentEstimator*>(next())))
987 for (
Int_t iPart = 0; iPart < nPart; iPart++) {
988 TParticle* particle =
fStack->Particle(iPart);
989 TParticlePDG*
pdg = particle->GetPDG();
991 Bool_t weakDecay =
fStack->IsSecondaryFromWeakDecay(iPart);
992 Bool_t charged = (pdg && TMath::Abs(pdg->Charge()) > 0);
993 if (primary) particle->SetBit(BIT(14));
994 if (weakDecay) particle->SetBit(BIT(15));
995 if (charged) particle->SetBit(BIT(16));
997 new ((*fParticles)[iPart]) TParticle(*particle);
1001 while ((estimator = static_cast<FastCentEstimator*>(next())))
1004 if (!selected || !charged || !primary)
continue;
1007 if (y >
fHY->GetXaxis()->GetXmin() &&
1008 y <
fHY->GetXaxis()->GetXmax())
1013 if (pT < 1e-10)
continue;
1015 Double_t theta = TMath::ATan2(pT, pZ);
1016 Double_t eta = -TMath::Log(TMath::Tan(theta/2));
1017 if (eta >
fHEta->GetXaxis()->GetXmin() &&
1018 eta <
fHEta->GetXaxis()->GetXmax())
1035 while ((estimator = static_cast<FastCentEstimator*>(next())))
1061 fHTime->Fill(1, timer.RealTime());
1066 fHTime->Fill(2, timer.RealTime());
1071 fHTime->Fill(3, timer.RealTime());
1076 fHTime->Fill(4, timer.RealTime());
1081 fHTime->Fill(5, timer.RealTime());
1104 fOutput->Add(
new TH1F(
"filename",
fFileName.Data(),1,0,1));
1108 fTree->Write(0, TObject::kOverwrite);
1135 Info(
"SlaveTerminate",
"Content of output list");
1136 gROOT->IncreaseDirLevel();
1138 gROOT->DecreaseDirLevel();
1140 gSystem->Exec(
"echo \"Content of working directory\"");
1141 gSystem->Exec(
"ls -l1 | sed 's/^/ /'");
1156 while ((o = next())) {
1157 if (o->IsA()->InheritsFrom(TCollection::Class())) {
1158 if (
fVerbose) Info(
"FlushList",
"Got collection: %s", c->GetName());
1159 TDirectory* cur = dir->mkdir(o->GetName());
1160 FlushList(static_cast<TCollection*>(o), cur);
1175 if (gProof) gProof->ClearFeedback();
1178 fList =
static_cast<TList*
>(fOutput->FindObject(
"histograms"));
1180 Error(
"Terminate",
"No output list");
1185 TObject* fn = fOutput->FindObject(
"filename");
1188 static_cast<TProofOutputFile*
>(fOutput->FindObject(
FileName()));
1195 TList* estimators =
static_cast<TList*
>(
fList->FindObject(
"estimators"));
1198 Warning(
"Terminate",
"No histogram list found in output");
1203 while ((estimator = static_cast<FastCentEstimator*>(next())))
1206 fHEta =
static_cast<TH1*
>(histos->FindObject(
"dNdeta"));
1207 fHY =
static_cast<TH1*
>(histos->FindObject(
"dNdy"));
1208 fHIpz =
static_cast<TH1*
>(histos->FindObject(
"ipZ"));
1209 fHType =
static_cast<TH1*
>(histos->FindObject(
"type"));
1210 fHCent =
static_cast<TH1*
>(histos->FindObject(
"cent"));
1211 fHB =
static_cast<TH1*
>(histos->FindObject(
"b"));
1212 fHPhiR =
static_cast<TH1*
>(histos->FindObject(
"phiR"));
1213 fHTime =
static_cast<TH1*
>(histos->FindObject(
"timing"));
1216 Warning(
"Terminate",
"Missing histograms (%p,%p,%p,%p,%p,%p,%p)",
1222 fHEta ->Scale(1./nTotal,
"width");
1223 fHY ->Scale(1./nTotal,
"width");
1224 fHB ->Scale(1./nTotal,
"width");
1225 fHPhiR->Scale(1./nTotal,
"width");
1226 fHTime->Scale(1./nTotal,
"width");
1229 Warning(
"Terminate",
"No file to write to");
1236 if (!
fTree) Warning(
"Terminate",
"No tree");
1252 TFile*
file = gROOT->GetFile(galiceName);
1254 Warning(
"GetGAlice",
"Didn't find galice file \"%s\"", galiceName.Data());
1255 gROOT->GetListOfFiles()->ls();
1268 TString kineName =
"Kinematics.root";
1271 if (dir.EqualTo(
".")) dir =
"";
1272 if (!dir.IsNull() && dir[dir.Length()-1] !=
'/') dir.Append(
"/");
1273 kineName.Prepend(dir);
1275 TFile*
file = gROOT->GetFile(kineName);
1277 Warning(
"GetKine",
"Didn't find kinematics file \"%s\"", kineName.Data());
1278 gROOT->GetListOfFiles()->ls();
1291 if (!fInput)
return;
1293 TObject* save = fInput->FindObject(
"PROOF_SaveGALICE");
1296 TString sMode = save->GetTitle();
1297 if (!sMode.EqualTo(
"split", TString::kIgnoreCase))
return;
1300 TSystemDirectory* dir =
new TSystemDirectory(
".",
1302 TList* files = dir->GetListOfFiles();
1303 TSystemFile*
file = 0;
1305 while ((file = static_cast<TSystemFile*>(next()))) {
1306 if (file->IsDirectory())
continue;
1308 if (!fn.BeginsWith(
"galice") && !fn.BeginsWith(
"Kinematics"))
1311 TPRegexp regex(
"(.*)_([^_]+)\\.root");
1313 if (matches->GetEntriesFast() < 3) {
1317 TString ord = matches->At(2)->GetName();
1318 TString bse = matches->At(1)->GetName();
1320 if (
gSystem->AccessPathName(ord,kFileExists))
1324 Info(
"MoveAliceFiles",
"Moving %s to %s/%s.root",
1325 fn.Data(), ord.Data(), bse.Data());
1326 file->Move(Form(
"%s/%s.root", ord.Data(), bse.Data()));
1328 if (!bse.EqualTo(
"galice"))
continue;
1329 TObjString*
url =
new TObjString(Form(
"file://%s/%s/%s.root?#TE",
1334 Info(
"MoveAliceFiles",
"Adding \"%s\" to file list",
1338 if (lst->GetEntries() <= 0)
return;
1341 TFile* out = TFile::Open(
"index.root",
"RECREATE");
1342 lst->Write(
"TE",TObject::kSingleKey);
1451 Printf(
"=== Event # %6lld/%6lld ==========================",
1465 if (!gProof)
return;
1469 clsLib.Add(
new TNamed(
"TVirtualMC",
"libVMC"));
1470 clsLib.Add(
new TNamed(
"TLorentzVector",
"libPhysics"));
1471 clsLib.Add(
new TNamed(
"TLinearFitter",
"libMinuit"));
1472 clsLib.Add(
new TNamed(
"TTree",
"libTree"));
1473 clsLib.Add(
new TNamed(
"TProof",
"libProof"));
1474 clsLib.Add(
new TNamed(
"TGFrame",
"libGui"));
1475 clsLib.Add(
new TNamed(
"TSAXParser",
"libXMLParser"));
1476 clsLib.Add(
new TNamed(
"AliVEvent",
"libSTEERBase"));
1477 clsLib.Add(
new TNamed(
"AliESDEvent",
"libESD"));
1478 clsLib.Add(
new TNamed(
"AliAODEvent",
"libAOD"));
1479 clsLib.Add(
new TNamed(
"AliAnalysisManager",
"libANALYSIS"));
1480 clsLib.Add(
new TNamed(
"AliCDBManager",
"libCDB"));
1481 clsLib.Add(
new TNamed(
"AliRawVEvent",
"libRAWDatabase"));
1482 clsLib.Add(
new TNamed(
"AliHit",
"libSTEER"));
1483 clsLib.Add(
new TNamed(
"AliGenMC",
"libEVGEN"));
1484 clsLib.Add(
new TNamed(
"AliFastEvent",
"libFASTSIM"));
1486 TIter next(&clsLib);
1488 while ((obj = next())) {
1489 gProof->Exec(Form(
"gROOT->LoadClass(\"%s\",\"%s\");",
1490 obj->GetName(), obj->GetTitle()));
1522 TProof::Reset(url.GetUrl());
1523 TProof::Open(url.GetUrl());
1524 gProof->ClearCache();
1529 TString fwd = phy +
"/PWGLF/FORWARD/analysis2";
1531 gProof->AddIncludePath(Form(
"%s/include", ali.Data()));
1532 gProof->AddIncludePath(Form(
"%s/include", phy.Data()));
1534 gProof->Load(Form(
"%s/sim/GRP.C",fwd.Data()),
true);
1535 gProof->Load(Form(
"%s/sim/BaseConfig.C",fwd.Data()),
true);
1536 gProof->Load(Form(
"%s/sim/EGConfig.C",fwd.Data()),
true);
1539 gProof->Load(Form(
"%s/sim/FastShortHeader.C", fwd.Data()));
1540 gProof->Load(Form(
"%s/sim/FastCentEstimators.C+%s",fwd.Data(),opt));
1541 gProof->Load(Form(
"%s/sim/FastMonitor.C+%s",fwd.Data(),opt));
1542 gProof->Load(Form(
"%s/sim/FastSim.C+%s", fwd.Data(), opt),
true);
1543 gProof->SetParameter(
"PROOF_SaveGALICE", save);
1548 gProof->Process(sim, nev,
"");
1567 Int_t idx = in.Index(sep);
1568 if (idx == kNPOS)
return false;
1571 val = in(idx+1, in.Length()-idx-1);
1576 if (
override.IsNull())
return;
1578 const char* valid[] = {
"beamEnergy",
1587 TObjArray* tokens =
override.Tokenize(
",");
1588 TObjString* token = 0;
1590 while ((token = static_cast<TObjString*>(next()))) {
1592 if (str.IsNull())
continue;
1596 Printf(
"Warning: FastSim::Run: incomplete override '%s'",str.Data());
1599 const char** pvalid = valid;
1601 if (key.EqualTo(*pvalid, TString::kIgnoreCase)) {
1607 Printf(
"Warning: FastSim::Run: Invalid override '%s'", key.Data());
1611 if (key.EqualTo(
"period",TString::kIgnoreCase))
1612 val = Form(
"\"%s\"", val.Data());
1650 Printf(
"Will run fast simulation with:\n\n\t%s\n\n",url);
1663 TObjString* token = 0;
1664 TIter nextToken(opts);
1665 while ((token = static_cast<TObjString*>(nextToken()))) {
1667 if (str.IsNull())
continue;
1669 if (str.EqualTo(
"verbose")) { verbose =
true; str =
""; }
1671 if (str.IsNull())
continue;
1675 if (!out.IsNull()) out.Append(
"&");
1680 if (key.EqualTo(
"events")) nev = val.Atoll();
1681 else if (key.EqualTo(
"run")) run = val.Atoi();
1682 else if (key.EqualTo(
"eg")) eg = val;
1683 else if (key.EqualTo(
"override"))
override = val;
1684 else if (key.EqualTo(
"save")) save = val;
1685 else if (key.EqualTo(
"monitor")) monitor = val.Atoi();
1686 else if (key.EqualTo(
"b")) {
1694 if (!out.IsNull()) out.Append(
"&");
1701 Printf(
"Error: FastSim::Run: URL %s is invalid", u.GetUrl());
1707 Printf(
"Run %s for %lld events anchored at %d\n"
1708 " Impact paramter range: %5.1f-%5.1f fm\n"
1709 " Monitor frequency: %d sec\n"
1710 " Execution url: %s",
1711 eg.Data(), nev, run, bMin, bMax, monitor, u.GetUrl());
1719 ret =
LocalRun(nev, run, eg, bMin, bMax, monitor, verbose,
override);
1721 ret =
ProofRun(u, nev, run, eg, bMin, bMax,
1722 monitor, verbose,
override, save, opt);
1735 :
FastSim(
"epos", run, 0, 20, 100000, monitor),
1788 while ((estimator = static_cast<FastCentEstimator*>(next()))) {
1789 if (!estimator->IsA()->InheritsFrom(V0CentEstimator::Class()))
1798 Info(
"Init",
"Initializing with tree %p (%s)",
1799 tree, (tree ? tree->ClassName() :
""));
1802 TFile*
file = tree->GetCurrentFile();
1803 Info(
"Init",
"Current file: (%p) %s", file,
1804 (file ? file->GetName() :
""));
1808 Fatal(
"Init",
"Failed to set-up branches");
1820 Warning(
"Notify",
"No tree set yet!");
1824 Info(
"Notify",
"processing file: (%p) %s", file,
1825 (file ? file->GetName() :
""));
1826 if (!file)
return true;
1828 Warning(
"Notify",
"Failed to set-up branches");
1837 fIsTgtA = gROOT->ProcessLine(
"grp->beam1.IsA()");
1838 fIsProjA = gROOT->ProcessLine(
"grp->beam2.IsA()");
1846 if (read <= 0)
return false;
1855 while ((estimator = static_cast<FastCentEstimator*>(next())))
1893 while ((estimator = static_cast<FastCentEstimator*>(next())))
1900 for (
Int_t iPart = 0; iPart < nTot; iPart++) {
1910 TParticle* particle =
1911 new ((*fParticles)[iPart]) TParticle(pdg, status,-1,-1,-1,-1,
1912 px, py, pz, e, 0, 0, 0, 0);
1913 TParticlePDG* pdgP = particle->GetPDG();
1914 Bool_t primary = status == 1;
1915 Bool_t weakDecay =
false;
1916 Bool_t charged = (pdgP && TMath::Abs(pdgP->Charge()) > 0);
1917 if (primary) particle->SetBit(BIT(14));
1918 if (weakDecay) particle->SetBit(BIT(15));
1919 if (charged) particle->SetBit(BIT(16));
1923 while ((estimator = static_cast<FastCentEstimator*>(next())))
1926 if (!selected || !charged || !primary)
continue;
1927 fHY ->Fill(particle->Y());
1929 if (pT < 1e-10)
continue;
1931 Double_t theta = TMath::ATan2(pT, pZ);
1932 Double_t eta = -TMath::Log(TMath::Tan(theta/2));
1943 while ((estimator = static_cast<FastCentEstimator*>(next())))
1990 Printf(
"=== Event # %6lld/%6lld ==========================",
2010 TProof::Reset(url.GetUrl());
2011 TProof::Open(url.GetUrl());
2012 gProof->ClearCache();
2017 TString fwd = phy +
"/PWGLF/FORWARD/analysis2";
2019 gProof->AddIncludePath(Form(
"%s/include", ali.Data()));
2020 gProof->AddIncludePath(Form(
"%s/include", phy.Data()));
2022 gProof->Load(Form(
"%s/sim/GRP.C",fwd.Data()),
true);
2023 gProof->Load(Form(
"%s/sim/BaseConfig.C",fwd.Data()),
true);
2024 gProof->Load(Form(
"%s/sim/EGConfig.C",fwd.Data()),
true);
2027 gProof->Load(Form(
"%s/sim/FastMonitor.C+%s",fwd.Data(),opt));
2028 gProof->Load(Form(
"%s/sim/FastShortHeader.C", fwd.Data()));
2029 gProof->Load(Form(
"%s/sim/FastCentEstimators.C+%s",fwd.Data(),opt));
2030 gProof->Load(Form(
"%s/sim/FastSim.C+%s", fwd.Data(), opt),
true);
2067 Printf(
"Will run fast simulation with:\n\n\t%s\n\n",url);
2075 TObjString* token = 0;
2076 TIter nextToken(opts);
2077 while ((token = static_cast<TObjString*>(nextToken()))) {
2079 if (str.IsNull())
continue;
2081 if (str.EqualTo(
"verbose")) { verbose =
true; str =
""; }
2083 if (str.IsNull())
continue;
2087 if (!out.IsNull()) out.Append(
"&");
2092 if (key.EqualTo(
"run")) run = val.Atoi();
2093 else if (key.EqualTo(
"monitor")) monitor = val.Atoi();
2094 else if (key.EqualTo(
"events")) nev = val.Atoi();
2096 if (!out.IsNull()) out.Append(
"&");
2103 Printf(
"Error: FastSim::Run: URL %s is invalid", u.GetUrl());
2107 Printf(
"Run EPos anchored at %d\n"
2108 " Monitor frequency: %d sec\n"
2109 " Execution url: %s",
2110 run, monitor, u.GetUrl());
2112 TString treeName = u.GetAnchor();
2113 if (treeName.IsNull()) treeName =
"Particle";
2114 TFile*
file = TFile::Open(u.GetFile(),
"READ");
2116 Printf(
"Error: FastAnalysis::Run: Failed to open %s",
2122 TObject* o = file->Get(treeName);
2124 Printf(
"Error: FastAnalysis::Run: Couldn't get %s from %s",
2125 treeName.Data(), u.GetFile());
2130 if (o->IsA()->InheritsFrom(TChain::Class()))
2131 cret = chain->Add(static_cast<TChain*>(o));
2132 else if (o->IsA()->InheritsFrom(TTree::Class()))
2133 cret = chain->AddFile(u.GetFile());
2134 else if (o->IsA()->InheritsFrom(TCollection::Class()))
2135 cret = chain->AddFileInfoList(static_cast<TCollection*>(o));
2136 else if (o->IsA()->InheritsFrom(TFileCollection::Class()))
2137 cret = chain->AddFileInfoList(static_cast<TFileCollection*>(o)
2141 Printf(
"Error: FastAnalysis::Run: Failed to create chain");
2145 TString proto = u.GetProtocol();
2146 Bool_t isProof = (proto.EqualTo(
"proof") || proto.EqualTo(
"lite"));
2154 if (nev < 0) nev = TChain::kBigNumber;
2159 Long64_t ret = chain->Process(sim,
"", nev, 0);
Bool_t PreEvent(Long64_t iEv)
static void ProofLoadLibs()
return jsonbuilder str().c_str()
virtual Bool_t SetupGRP()
Bool_t fIsProjA
True if target beam is nuclei.
const char * GetEGTitle() const
static Bool_t Run(const char *url, const char *opt="")
virtual void Init(TTree *)
virtual Bool_t Process(Long64_t iEv)
virtual void Begin(TTree *)
void FlushList(TCollection *c, TDirectory *dir)
static Bool_t SetupProof(const TUrl &url, const char *opt="")
AliStack * fStack
Loader of trees.
static Bool_t LocalRun(Long64_t nev, UInt_t run, Int_t monitor, Bool_t verbose)
virtual void Terminate(TCollection *out)=0
AliGenerator * fGenerator
TProofOutputFile * fAliceFile
Proof output file.
TList * fOverrides
GRP in one line.
virtual void ProcessHeader(FastShortHeader &)
const char * GetTitle() const
TProofOutputFile * fProofFile
Bool_t fVerbose
Output file name.
void Connect(Int_t freq=-1)
virtual void Print(Option_t *option="") const
const char * FileName() const
static Bool_t Str2KeyVal(const TString &in, TString &key, TString &val, const char sep='=')
TH1 * fHB
Event type histogram.
BCentEstimator * fBEstimator
void Flip(Bool_t onlySign=true)
FastShortHeader fShortHead
Double_t GetCentrality(Double_t b) const
const char * GetName() const
virtual UShort_t GetSNN() const
FastSim(const char *eg="", ULong_t runNo=0, Double_t bMin=0, Double_t bMax=20, Long64_t nEvents=0, Int_t monitor=0)
TH1 * fHType
IPz histogram.
TProofOutputFile * fKineFile
AliHeader * fHeader
Stack of particles.
TH1 * fHEta
List of outputs.
static Bool_t Run(const char *url, const char *opt="")
virtual Bool_t SetupGen()
TH1 * fHTime
Reaction plane.
void SetVerbose(Bool_t verb)
TList * GetListOfFiles(const char *input=".")
virtual void Process(const TParticle *p)=0
void Register(TObject *descr, Bool_t proof=true)
virtual Bool_t PreEvent(Long64_t iEv)
EPosSim(UInt_t run=0, Int_t monitor=0)
static Bool_t ProofRun(const TUrl &url, Long64_t nev, UInt_t run, const TString &gen, Double_t bMin, Double_t bMax, Int_t monitor=-1, Bool_t verbose=false, const TString &overrides="", const TString &save="none", const char *opt="")
FastSimMonitor(TSelector *s=0)
AliRunLoader * fRunLoader
Event generator.
TString fFileName
Output file.
static Bool_t LocalRun(Long64_t nev, UInt_t run, const TString &gen, Double_t bMin, Double_t bMax, Int_t monitor, Bool_t verbose, const TString &overrides="")
TClonesArray * fParticles
Custom tree.
virtual Bool_t SetupRun()
void AddOverride(const TString &field, const TString &value)
virtual const char * GetEGTitle() const
virtual Bool_t ProcessHeader()
virtual Bool_t ProcessParticles(Bool_t selected)
virtual Bool_t ProcessParticles(Bool_t selected)
virtual void Setup(TCollection *out, TTree *tree, UShort_t sNN, Bool_t tgtA, Bool_t projA)=0
TH1 * fHCent
Event type histogram.
Long64_t fNEvents
GRP setting to override.
static void SetOverrides(FastSim *sim, const TString &override)