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/histograms/trigger",
"e", 0x10,
false);
103 Register(
"list/estimators/rawV0MP",
"e", 0x02,
false);
104 if (gProof) gProof->AddFeedback(
"list");
173 if (egName.IsNull()) egName =
fEGName;
175 fn = Form(
"%s_%09d", egName.Data(),
fRunNo);
178 Int_t tgtA, tgtZ, projA, projZ;
180 fGenerator->GetProjectile(proj, projA, projZ);
181 fn.Append(Form(
"_%s%s", tgt.Data(), proj.Data()));
185 Long_t en = gROOT->ProcessLine(
"grp->energy");
188 fn.Append(Form(
"_%s%s", (
fIsTgtA ?
"A" :
"p"),
190 fn.Append(Form(
"_%05ld", (
fGRP ? en : 0)));
195 fn.Append(Form(
"_%lldM",
fNEvents/1000000));
197 fn.Append(Form(
"_%lldk",
fNEvents/1000));
212 const char*
GetName()
const {
return "FastSim"; }
218 const char*
GetTitle()
const {
return "ALICE Event Generator simulation"; }
228 else fsNN = gROOT->ProcessLine(
"grp->energy");
230 UShort_t sNN = (TMath::Abs(fsNN - 2760) < 10 ? 2760 :
231 TMath::Abs(fsNN - 5023) < 10 ? 5023 :
232 TMath::Abs(fsNN - 2360) < 10 ? 2360 :
233 TMath::Abs(fsNN - 900) < 10 ? 900 :
234 TMath::Abs(fsNN - 7000) < 10 ? 7000 :
235 TMath::Abs(fsNN - 8000) < 10 ? 8000 :
236 TMath::Abs(fsNN - 13000) < 10 ? 13000 :
258 Printf(
"=== Output =============================\n"
260 "========================================",
FileName());
262 if (
fVerbose) Info(
"SetupOutput",
"First the file");
264 if (fInput && fInput->FindObject(
"PROOF_Ordinal"))
267 Info(
"SetupOutput",
"Making Proof File");
278 if (
fVerbose) Info(
"SetupOutput",
"Making our tree: %s", tit.Data());
282 "run/i:event:ntgt:nproj:nbin:type:"
283 "ipx/D:ipy:ipz:b:c:phir:"
284 "nsnp/i:nsnt:nspp:nspt:mask");
285 fTree->Branch(
"particles", &fParticles);
286 fTree->SetAutoSave(500);
287 fTree->SetDirectory(
fFile);
288 fTree->SetAlias(
"primary",
"(particles.fBits&(1<<14))");
289 fTree->SetAlias(
"weak",
"(particles.fBits&(1<<15))");
290 fTree->SetAlias(
"charged",
"(particles.fBits&(1<<16))");
291 fTree->SetAlias(
"pt",
"(sqrt(pow(particles.fPx,2)+"
292 "pow(particles.fPy,2)))");
293 fTree->SetAlias(
"eta",
"(particles.Pt()<1e-100?"
294 "(particles.fPz>0?100:-100):"
295 "-log(tan(atan2(particles.Pt(),particles.fPz)/2)))");
296 fTree->SetAlias(
"good",
"(primary&&charged&&abs(eta)<1000)");
297 fTree->SetAlias(
"sd",
"(header.fType & 0x1)");
298 fTree->SetAlias(
"dd",
"(header.fType & 0x2)");
299 fTree->SetAlias(
"pion",
"(abs(particles.fPdgCode)==211)");
300 fTree->SetAlias(
"kaon",
"(abs(particles.fPdgCode)==321)");
301 fTree->SetAlias(
"proton",
"(abs(particles.fPdgCode)==2212)");
302 fTree->SetAlias(
"electron",
"(abs(particles.fPdgCode)==11)");
303 fTree->SetAlias(
"other",
"(!pion&&!kaon&&!proton&&!electron)");
304 fTree->SetAlias(
"beta",
"(particles.P()/particle.Energy())");
305 fTree->SetAlias(
"gamma",
"(1./sqrt(1-beta*beta))");
306 fTree->SetAlias(
"npart",
"(header.ntgt+header.nproj)");
307 fTree->SetAlias(
"v0a",
"(header.mask&0x1)");
308 fTree->SetAlias(
"v0c",
"(header.mask&0x2)");
309 fTree->SetAlias(
"ada",
"(header.mask&0x4)");
310 fTree->SetAlias(
"adc",
"(header.mask&0x8)");
311 fTree->SetAlias(
"eta1",
"(header.mask&0x10)");
315 Info(
"SetupOutput",
"Making generator histogram: %s",tit.Data());
316 TH1* egTitle =
new TH1I(
"eg", tit.Data(), 1, 0, 1);
317 egTitle->SetDirectory(0);
319 egTitle->SetXTitle(
"N_{\\hbox{workers}}");
320 egTitle->SetYTitle(
"Count");
321 egTitle->SetFillColor(kYellow+4);
322 egTitle->SetLineColor(kYellow+4);
323 egTitle->SetMarkerColor(kYellow+4);
324 egTitle->SetFillStyle(1001);
325 egTitle->SetMarkerStyle(1);
326 egTitle->SetLineStyle(1);
327 egTitle->SetLineWidth(2);
328 egTitle->SetMarkerSize(1);
331 if (
fVerbose) Info(
"SetupOutput",
"Making histograms");
334 fHEta =
new TH1D(
"dNdeta",
"Charged particle pseudo-rapidity density",
335 Int_t(2*maxEta/dEta+.5), -maxEta, +maxEta);
337 fHEta->SetXTitle(
"\\eta");
338 fHEta->SetYTitle(
"\\hbox{d}N_{\\hbox{ch}}/\\hbox{d}\\eta");
339 fHEta->SetMarkerColor(kRed+2);
340 fHEta->SetMarkerStyle(20);
341 fHEta->SetDirectory(0);
343 fHY =
new TH1D(
"dNdy",
"Charged particle rapidity density",
344 Int_t(2*maxEta/dEta+.5), -maxEta, +maxEta);
346 fHY->SetXTitle(
"\\mathit{y}");
347 fHY->SetYTitle(
"\\hbox{d}N_{\\hbox{ch}}/\\hbox{d}y");
348 fHY->SetMarkerColor(kRed+2);
349 fHY->SetMarkerStyle(20);
350 fHY->SetDirectory(0);
352 fHIpz =
new TH1D(
"ipZ",
"Z-coordinate of interaction point",
354 fHIpz->SetMarkerColor(kGreen+2);
355 fHIpz->SetFillColor(kGreen+2);
356 fHIpz->SetFillStyle(3001);
357 fHIpz->SetXTitle(
"IP_{#it{z}} [cm]");
358 fHIpz->SetDirectory(0);
360 fHType =
new TH1D(
"type",
"Diffractive", 3, .5, 3.5);
361 fHType->SetMarkerColor(kOrange+2);
362 fHType->SetFillColor(kOrange+2);
363 fHType->SetFillStyle(3001);
365 fHType->GetXaxis()->SetBinLabel(1,
"Non");
366 fHType->GetXaxis()->SetBinLabel(2,
"Single");
367 fHType->GetXaxis()->SetBinLabel(3,
"Double");
369 fHCent =
new TH1D(
"cent",
"Centrality", 20, 0, 100);
370 fHCent->SetMarkerColor(kPink+2);
371 fHCent->SetFillColor(kPink+2);
372 fHCent->SetFillStyle(3001);
374 fHCent->SetYTitle(
"Events");
375 fHCent->SetXTitle(
"Centrality [%]");
377 fHB =
new TH1D(
"b",
"Impact parameter", 20, 0, 20);
378 fHB->SetMarkerColor(kYellow+2);
379 fHB->SetFillColor(kYellow+2);
380 fHB->SetFillStyle(3001);
381 fHB->SetYTitle(
"Events");
382 fHB->SetXTitle(
"#it{b} [fm]");
383 fHB->SetDirectory(0);
385 fHPhiR =
new TH1D(
"phiR",
"Event plane angle", 360, 0, 360);
386 fHPhiR->SetMarkerColor(kMagenta+2);
387 fHPhiR->SetFillColor(kMagenta+2);
388 fHPhiR->SetFillStyle(3001);
389 fHPhiR->SetXTitle(
"#it{#Phi}_{R} [degrees]");
392 fHTime =
new TH1D(
"timing",
"Timing of processing", 5,0.5,5.5);
393 fHTime->SetMarkerColor(kBlue+2);
394 fHTime->SetFillColor(kBlue+2);
395 fHTime->SetFillStyle(3001);
396 fHTime->SetYTitle(
"seconds / event");
397 fHTime->GetXaxis()->SetBinLabel(1,
"Reset");
398 fHTime->GetXaxis()->SetBinLabel(2,
"Generate");
399 fHTime->GetXaxis()->SetBinLabel(3,
"Header");
400 fHTime->GetXaxis()->SetBinLabel(4,
"Particles");
401 fHTime->GetXaxis()->SetBinLabel(5,
"Filling");
404 fHTrig =
new TH1D(
"trigger",
"Trigger bits set", 6, -0.5, 5.5);
405 fHTrig->SetMarkerColor(kMagenta+2);
406 fHTrig->SetFillColor(kMagenta+2);
407 fHTrig->SetFillStyle(3001);
408 fHTrig->SetYTitle(
"Events");
409 fHTrig->GetXaxis()->SetBinLabel(1,
"All");
410 fHTrig->GetXaxis()->SetBinLabel(2,
"V0A");
411 fHTrig->GetXaxis()->SetBinLabel(3,
"V0C");
412 fHTrig->GetXaxis()->SetBinLabel(4,
"ADA");
413 fHTrig->GetXaxis()->SetBinLabel(5,
"ADC");
414 fHTrig->GetXaxis()->SetBinLabel(6,
"N_{ch}|_{|#eta|<1}#ge1");
418 fList->SetName(
"list");
422 histos->SetName(
"histograms");
423 histos->SetOwner(
true);
436 estimators->SetName(
"estimators");
437 estimators->SetOwner(
true);
438 fList->Add(estimators);
443 while ((estimator = static_cast<FastCentEstimator*>(next()))) {
449 if (
fVerbose) Info(
"SetupOutput",
"Adding list ot outputs");
462 std::ifstream in(
"/dev/urandom");
464 in.read(reinterpret_cast<char*>(&seed),
sizeof(seed));
466 Printf(
"=== Random =============================\n"
467 " Random number seed: %d\n"
468 "========================================", seed);
473 Printf(
" === Setup ==============================");
474 Printf(
" Run #: %6d",
fRunNo);
475 Printf(
" EG: %30s",
fEGName.Data());
476 Printf(
" B range: %5.1ffm - %5.1ffm",
fBMin,
fBMax);
477 Printf(
" ========================================");
478 Printf(
"Macro path: %s", gROOT->GetMacroPath());
481 if (!
fGRP && fInput) {
482 fGRP = fInput->FindObject(
"GRP");
483 std::ofstream* pout =
new std::ofstream(
"grp.dat");
486 Info(
"SetupGRP",
"Writing GRP line '%s' to \"grp.dat\"",
488 std::ostream& out = *pout;
489 out <<
fGRP->GetTitle() << std::endl;
494 Info(
"SetupGRP",
"Overrides: %p Input: %p",
fOverrides, fInput);
498 Info(
"SetupGRP",
"No GRP overrides found in input:");
502 if (
fVerbose) Info(
"SetupGRP",
"Loading scripts");
504 if (gROOT->ProcessLine(
"grp") == 0)
505 gROOT->Macro(Form(
"GRP.C(%d)",
fRunNo));
506 if (
fVerbose) Info(
"SetupGRP",
"Perhaps override");
508 gROOT->ProcessLine(
"grp->Print()");
518 if (
fVerbose) Info(
"SetupGen",
"Load base config");
519 gROOT->Macro(
"BaseConfig.C");
520 if (
fVerbose) Info(
"SetupGen",
"Load EG config");
521 gROOT->Macro(
"EGConfig.C");
523 gROOT->ProcessLine(Form(
"VirtualEGCfg::LoadGen(\"%s\")",
fEGName.Data()));
527 TString egMk = Form(
"egCfg->MakeGenerator(\"%s\",%f,%f)",
529 Long64_t egPtr = gROOT->ProcessLine(egMk);
531 Error(
"SetupGen",
"Failed to make generator");
534 fGenerator =
reinterpret_cast<AliGenerator*
>(egPtr);
536 Int_t tgtA=0, tgtZ=0, projA=0, projZ=0;
538 fGenerator->GetProjectile(proj, projA, projZ);
539 fIsTgtA = !(tgtA == tgtZ && tgtA == 1);
540 fIsProjA = !(projA == projZ && projZ == 1);
542 Info(
"SetupGen",
"tgt=%s (%3d,%2d) proj=%s (%3d,%2d) CMS=%fGeV",
543 tgt.Data(), tgtA, tgtZ, proj.Data(), projA, projZ,
545 Info(
"SetupGen",
"Generator: %s",
fGenerator->GetTitle());
559 new AliRun(
"gAlice",
"The ALICE Off-line framework");
562 Printf(
"=== Run ================================\n"
563 " Number of events: %lld\n"
564 "========================================", nev);
565 TObject* ord = (fInput ? fInput->FindObject(
"PROOF_Ordinal") : 0);
570 TObject* save = fInput->FindObject(
"PROOF_SaveGALICE");
572 Info(
"SetupRun",
"Got save option:");
575 TString optSave(save ? save->GetTitle() :
"split");
577 if (optSave.EqualTo(
"none")) saveMode = 0;
578 else if (optSave.EqualTo(
"merge")) saveMode = 1;
579 else if (optSave.EqualTo(
"split")) saveMode = 2;
583 post = Form(
"_%s", ord->GetTitle());
585 TString galiceName(Form(
"%sgalice.root",dir.Data()));
586 TString kineName(Form(
"%sKinematics.root",dir.Data()));
590 fRunLoader = AliRunLoader::Open(galiceName,
"FASTRUN",
"RECREATE");
608 Info(
"SetupRun",
"Not saving galice.root and Kinematics.root");
612 TString aliceOut = Form(
"galice%s.root", post.Data());
613 fAliceFile =
new TProofOutputFile(aliceOut,
"M");
615 TString kineOut = Form(
"Kinematics%s.root", post.Data());
616 fKineFile =
new TProofOutputFile(kineOut,
"M");
626 std::ifstream* pin =
new std::ifstream(
"grp.dat");
628 Warning(
"ReadGRPLine",
"Failed to open \"grp.dat\"");
631 std::istream& in = *pin;
636 if (line.IsNull())
continue;
637 if (line.BeginsWith(
"#"))
continue;
644 Warning(
"ReadGRPLine",
"Got no line from \"grp.dat\"");
649 if (
fVerbose) Info(
"ReadGRPLine",
"Read \"%s\"", env.Data());
658 Long_t ret = gROOT->ProcessLine(
"grp");
660 Warning(
"OverrideGRP",
"GRP not set yet, cannot override");
664 if (
fVerbose) Info(
"OverrideGRP",
"No overrides defined");
669 while ((o = next())) {
671 Info(
"OverrideGRP",
"Overriding GRP setting %s with %s",
672 o->GetName(), o->GetTitle());
673 gROOT->ProcessLine(Form(
"grp->%s = %s;",
674 o->GetName(), o->GetTitle()));
676 Info(
"OverrideGRP",
"After overriding:");
677 gROOT->ProcessLine(
"grp->Print()");
709 if (
fVerbose) Info(
"Begin",
"Called for FastSim");
711 if (
fMonitor > 0 && !gROOT->IsBatch()) {
715 gROOT->Macro(Form(
"GRP.C(%d)",
fRunNo));
718 gProof->AddInput(
fGRP);
722 if (
fVerbose) Info(
"Begin",
"Perhaps override");
724 if (
fVerbose) Info(
"Begin",
"Defining centrality estimators");
752 while ((estimator = static_cast<FastCentEstimator*>(next()))) {
753 estimator->
Print(
"nah");
756 if (
fVerbose) Info(
"Begin",
"End of begin");
764 if (
fVerbose) Info(
"SlavesBegin",
"Called for FastSim");
790 while ((estimator = static_cast<FastCentEstimator*>(next())))
807 fHeader->GenEventHeader()->PrimaryVertex(ip);
813 AliGenEventHeader* genHeader =
fHeader->GenEventHeader();
814 AliCollisionGeometry* geometry =
815 dynamic_cast<AliCollisionGeometry*
>(genHeader);
816 AliGenPythiaEventHeader* pythia =
817 dynamic_cast<AliGenPythiaEventHeader*
>(genHeader);
818 AliGenDPMjetEventHeader* dpm =
819 dynamic_cast<AliGenDPMjetEventHeader*
>(genHeader);
820 AliGenGeVSimEventHeader* gev =
821 dynamic_cast<AliGenGeVSimEventHeader*
>(genHeader);
822 AliGenHerwigEventHeader* herwig =
823 dynamic_cast<AliGenHerwigEventHeader*
>(genHeader);
824 AliGenCocktailEventHeader* cocktail =
825 dynamic_cast<AliGenCocktailEventHeader*
>(genHeader);
826 AliGenHijingEventHeader* hijing =
827 dynamic_cast<AliGenHijingEventHeader*
>(genHeader);
829 TList* headers = cocktail->GetHeaders();
830 if (!headers) Warning(
"",
"No headers in cocktail!");
832 AliGenEventHeader* header = 0;
833 AliCollisionGeometry* geom = 0;
834 while ((header = static_cast<AliGenEventHeader*>(next()))) {
835 AliCollisionGeometry* g =
dynamic_cast<AliCollisionGeometry*
>(header);
837 hijing =
dynamic_cast<AliGenHijingEventHeader*
>(header);
839 if (geom) geometry = geom;
860 Int_t type = pythia->ProcessType();
863 case 92:
case 93: sd =
true;
break;
864 case 94: dd =
true;
break;
869 case 103:
case 104: sd =
true;
break;
870 case 105: dd =
true;
break;
885 for (
Int_t iPart = 0; iPart < nPart; iPart++) {
886 TParticle* particle =
fStack->Particle(iPart);
887 Int_t ks = particle->GetStatusCode();
889 if (ks == 13) side = -1;
890 if (ks == 14) side = +1;
891 if (side == 0)
continue;
892 Int_t kf = particle->GetPdgCode();
894 if (side < 0) nSpecNproj++;
898 if (side < 0) nSpecPproj++;
908 Int_t type = dpm->ProcessType();
909 #ifndef NO_DPMJET_TYPE
911 case 5:
case 6: sd =
true;
915 static bool first =
true;
918 Func_t add =
gSystem->DynFindSymbol(
"*",
"dtglcp_");
920 Warning(
"",
"Didn't find dtglcp_");
931 Int_t nsd1=0, nsd2=0, ndd=0;
932 Int_t npP = dpm->ProjectileParticipants();
933 Int_t npT = dpm->TargetParticipants();
935 dpm->GetNDiffractive(nsd1,nsd2,ndd);
937 if ((ndd == 0) && ((npP == nsd1) || (npT == nsd2))) sd =
true;
938 else if (ndd == (npP + npT)) dd =
true;
939 Int_t ncp = dpm->NN();
940 Int_t nct = dpm->NNw();
941 Int_t nwp = dpm->NwN();
942 Int_t nwt = dpm->NwNw();
946 Printf(
"@ Npp sd1 Npt sd2 dd tpe Ncp Nct Nwp Nwt acc sam");
949 Printf(
"@ %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d %3d",
950 npP, nsd1, npT, nsd2, ndd, type, ncp, nct, nwp, nwt,
956 Int_t type = herwig->ProcessType();
958 case 5:
case 6: sd =
true;
break;
969 Info(
"ProcessHeader",
"b=%f isProjA=%d isTgtA=%d cms=%f",
984 if (!dd && !sd)
fHType->Fill(1);
986 fHEta ->AddBinContent(0);
987 fHY ->AddBinContent(0);
993 while ((estimator = static_cast<FastCentEstimator*>(next())))
1005 if (eta < +5.1 && eta > +2.8)
1007 if (eta < -1.7 && eta > -3.7)
1009 if (eta < +6.3 && eta > +4.8)
1011 if (eta < -4.9 && eta > -7.0)
1013 if (TMath::Abs(eta) < 1)
1026 for (
Int_t iPart = 0; iPart < nPart; iPart++) {
1027 TParticle* particle =
fStack->Particle(iPart);
1028 TParticlePDG*
pdg = particle->GetPDG();
1030 Bool_t weakDecay =
fStack->IsSecondaryFromWeakDecay(iPart);
1031 Bool_t charged = (pdg && TMath::Abs(pdg->Charge()) > 0);
1032 if (primary) particle->SetBit(BIT(14));
1033 if (weakDecay) particle->SetBit(BIT(15));
1034 if (charged) particle->SetBit(BIT(16));
1036 new ((*fParticles)[iPart]) TParticle(*particle);
1040 while ((estimator = static_cast<FastCentEstimator*>(next())))
1043 if (!selected || !charged || !primary)
continue;
1046 if (y >
fHY->GetXaxis()->GetXmin() &&
1047 y <
fHY->GetXaxis()->GetXmax())
1052 if (pT < 1e-10)
continue;
1054 Double_t theta = TMath::ATan2(pT, pZ);
1055 Double_t eta = -TMath::Log(TMath::Tan(theta/2));
1057 if (eta >
fHEta->GetXaxis()->GetXmin() &&
1058 eta <
fHEta->GetXaxis()->GetXmax())
1082 while ((estimator = static_cast<FastCentEstimator*>(next())))
1108 fHTime->Fill(1, timer.RealTime());
1113 fHTime->Fill(2, timer.RealTime());
1118 fHTime->Fill(3, timer.RealTime());
1123 fHTime->Fill(4, timer.RealTime());
1128 fHTime->Fill(5, timer.RealTime());
1151 fOutput->Add(
new TH1F(
"filename",
fFileName.Data(),1,0,1));
1155 fTree->Write(0, TObject::kOverwrite);
1182 Info(
"SlaveTerminate",
"Content of output list");
1183 gROOT->IncreaseDirLevel();
1185 gROOT->DecreaseDirLevel();
1187 gSystem->Exec(
"echo \"Content of working directory\"");
1188 gSystem->Exec(
"ls -l1 | sed 's/^/ /'");
1203 while ((o = next())) {
1204 if (o->IsA()->InheritsFrom(TCollection::Class())) {
1205 if (
fVerbose) Info(
"FlushList",
"Got collection: %s", c->GetName());
1206 TDirectory* cur = dir->mkdir(o->GetName());
1207 FlushList(static_cast<TCollection*>(o), cur);
1222 if (gProof) gProof->ClearFeedback();
1225 fList =
static_cast<TList*
>(fOutput->FindObject(
"histograms"));
1227 Error(
"Terminate",
"No output list");
1232 TObject* fn = fOutput->FindObject(
"filename");
1235 static_cast<TProofOutputFile*
>(fOutput->FindObject(
FileName()));
1242 TList* estimators =
static_cast<TList*
>(
fList->FindObject(
"estimators"));
1245 Warning(
"Terminate",
"No histogram list found in output");
1250 while ((estimator = static_cast<FastCentEstimator*>(next())))
1253 fHEta =
static_cast<TH1*
>(histos->FindObject(
"dNdeta"));
1254 fHY =
static_cast<TH1*
>(histos->FindObject(
"dNdy"));
1255 fHIpz =
static_cast<TH1*
>(histos->FindObject(
"ipZ"));
1256 fHType =
static_cast<TH1*
>(histos->FindObject(
"type"));
1257 fHCent =
static_cast<TH1*
>(histos->FindObject(
"cent"));
1258 fHB =
static_cast<TH1*
>(histos->FindObject(
"b"));
1259 fHPhiR =
static_cast<TH1*
>(histos->FindObject(
"phiR"));
1260 fHTime =
static_cast<TH1*
>(histos->FindObject(
"timing"));
1261 fHTrig =
static_cast<TH1*
>(histos->FindObject(
"trigger"));
1264 Warning(
"Terminate",
"Missing histograms (%p,%p,%p,%p,%p,%p,%p)",
1270 fHEta ->Scale(1./nTotal,
"width");
1271 fHY ->Scale(1./nTotal,
"width");
1272 fHB ->Scale(1./nTotal,
"width");
1273 fHPhiR->Scale(1./nTotal,
"width");
1274 fHTime->Scale(1./nTotal,
"width");
1275 fHTrig->Scale(1./nTotal,
"width");
1278 Warning(
"Terminate",
"No file to write to");
1285 if (!
fTree) Warning(
"Terminate",
"No tree");
1301 TFile*
file = gROOT->GetFile(galiceName);
1303 Warning(
"GetGAlice",
"Didn't find galice file \"%s\"", galiceName.Data());
1304 gROOT->GetListOfFiles()->ls();
1317 TString kineName =
"Kinematics.root";
1320 if (dir.EqualTo(
".")) dir =
"";
1321 if (!dir.IsNull() && dir[dir.Length()-1] !=
'/') dir.Append(
"/");
1322 kineName.Prepend(dir);
1324 TFile*
file = gROOT->GetFile(kineName);
1326 Warning(
"GetKine",
"Didn't find kinematics file \"%s\"", kineName.Data());
1327 gROOT->GetListOfFiles()->ls();
1340 if (!fInput)
return;
1342 TObject* save = fInput->FindObject(
"PROOF_SaveGALICE");
1345 TString sMode = save->GetTitle();
1346 if (!sMode.EqualTo(
"split", TString::kIgnoreCase))
return;
1349 TSystemDirectory*
dir =
new TSystemDirectory(
".",
1351 TList* files = dir->GetListOfFiles();
1352 TSystemFile*
file = 0;
1354 while ((file = static_cast<TSystemFile*>(next()))) {
1355 if (file->IsDirectory())
continue;
1357 if (!fn.BeginsWith(
"galice") && !fn.BeginsWith(
"Kinematics"))
1360 TPRegexp regex(
"(.*)_([^_]+)\\.root");
1362 if (matches->GetEntriesFast() < 3) {
1366 TString ord = matches->At(2)->GetName();
1367 TString bse = matches->At(1)->GetName();
1369 if (
gSystem->AccessPathName(ord,kFileExists))
1373 Info(
"MoveAliceFiles",
"Moving %s to %s/%s.root",
1374 fn.Data(), ord.Data(), bse.Data());
1375 file->Move(Form(
"%s/%s.root", ord.Data(), bse.Data()));
1377 if (!bse.EqualTo(
"galice"))
continue;
1378 TObjString*
url =
new TObjString(Form(
"file://%s/%s/%s.root?#TE",
1383 Info(
"MoveAliceFiles",
"Adding \"%s\" to file list",
1387 if (lst->GetEntries() <= 0)
return;
1390 TFile* out = TFile::Open(
"index.root",
"RECREATE");
1391 lst->Write(
"TE",TObject::kSingleKey);
1501 Printf(
"=== Event # %6lld/%6lld ==========================",
1515 if (!gProof)
return;
1519 clsLib.Add(
new TNamed(
"TVirtualMC",
"libVMC"));
1520 clsLib.Add(
new TNamed(
"TLorentzVector",
"libPhysics"));
1521 clsLib.Add(
new TNamed(
"TLinearFitter",
"libMinuit"));
1522 clsLib.Add(
new TNamed(
"TTree",
"libTree"));
1523 clsLib.Add(
new TNamed(
"TProof",
"libProof"));
1524 clsLib.Add(
new TNamed(
"TGFrame",
"libGui"));
1525 clsLib.Add(
new TNamed(
"TSAXParser",
"libXMLParser"));
1526 clsLib.Add(
new TNamed(
"AliVEvent",
"libSTEERBase"));
1527 clsLib.Add(
new TNamed(
"AliESDEvent",
"libESD"));
1528 clsLib.Add(
new TNamed(
"AliAODEvent",
"libAOD"));
1529 clsLib.Add(
new TNamed(
"AliAnalysisManager",
"libANALYSIS"));
1530 clsLib.Add(
new TNamed(
"AliCDBManager",
"libCDB"));
1531 clsLib.Add(
new TNamed(
"AliRawVEvent",
"libRAWDatabase"));
1532 clsLib.Add(
new TNamed(
"AliHit",
"libSTEER"));
1533 clsLib.Add(
new TNamed(
"AliGenMC",
"libEVGEN"));
1534 clsLib.Add(
new TNamed(
"AliFastEvent",
"libFASTSIM"));
1536 TIter next(&clsLib);
1538 while ((obj = next())) {
1539 gProof->Exec(Form(
"gROOT->LoadClass(\"%s\",\"%s\");",
1540 obj->GetName(), obj->GetTitle()));
1572 TProof::Reset(url.GetUrl());
1573 TProof::Open(url.GetUrl());
1574 gProof->ClearCache();
1579 TString fwd = phy +
"/PWGLF/FORWARD/analysis2";
1581 gProof->AddIncludePath(Form(
"%s/include", ali.Data()));
1582 gProof->AddIncludePath(Form(
"%s/include", phy.Data()));
1584 gProof->Load(Form(
"%s/sim/GRP.C",fwd.Data()),
true);
1585 gProof->Load(Form(
"%s/sim/BaseConfig.C",fwd.Data()),
true);
1586 gProof->Load(Form(
"%s/sim/EGConfig.C",fwd.Data()),
true);
1589 gProof->Load(Form(
"%s/sim/FastShortHeader.C", fwd.Data()));
1590 gProof->Load(Form(
"%s/sim/FastCentEstimators.C+%s",fwd.Data(),opt));
1591 gProof->Load(Form(
"%s/sim/FastMonitor.C+%s",fwd.Data(),opt));
1592 gProof->Load(Form(
"%s/sim/FastSim.C+%s", fwd.Data(), opt),
true);
1593 gProof->SetParameter(
"PROOF_SaveGALICE", save);
1598 gProof->Process(sim, nev,
"");
1617 Int_t idx = in.Index(sep);
1618 if (idx == kNPOS)
return false;
1621 val = in(idx+1, in.Length()-idx-1);
1626 if (
override.IsNull())
return;
1628 const char* valid[] = {
"beamEnergy",
1637 TObjArray* tokens =
override.Tokenize(
",");
1638 TObjString* token = 0;
1640 while ((token = static_cast<TObjString*>(next()))) {
1641 TString& str = token->String();
1642 if (str.IsNull())
continue;
1646 Printf(
"Warning: FastSim::Run: incomplete override '%s'",str.Data());
1649 const char** pvalid = valid;
1651 if (key.EqualTo(*pvalid, TString::kIgnoreCase)) {
1657 Printf(
"Warning: FastSim::Run: Invalid override '%s'", key.Data());
1661 if (key.EqualTo(
"period",TString::kIgnoreCase))
1662 val = Form(
"\"%s\"", val.Data());
1700 Printf(
"Will run fast simulation with:\n\n\t%s\n\n",url);
1713 TObjString* token = 0;
1714 TIter nextToken(opts);
1715 while ((token = static_cast<TObjString*>(nextToken()))) {
1716 TString& str = token->String();
1717 if (str.IsNull())
continue;
1719 if (str.EqualTo(
"verbose")) { verbose =
true; str =
""; }
1721 if (str.IsNull())
continue;
1725 if (!out.IsNull()) out.Append(
"&");
1730 if (key.EqualTo(
"events")) nev = val.Atoll();
1731 else if (key.EqualTo(
"run")) run = val.Atoi();
1732 else if (key.EqualTo(
"eg")) eg = val;
1733 else if (key.EqualTo(
"override"))
override = val;
1734 else if (key.EqualTo(
"save")) save = val;
1735 else if (key.EqualTo(
"monitor")) monitor = val.Atoi();
1736 else if (key.EqualTo(
"b")) {
1744 if (!out.IsNull()) out.Append(
"&");
1751 Printf(
"Error: FastSim::Run: URL %s is invalid", u.GetUrl());
1757 Printf(
"Run %s for %lld events anchored at %d\n"
1758 " Impact paramter range: %5.1f-%5.1f fm\n"
1759 " Monitor frequency: %d sec\n"
1760 " Execution url: %s",
1761 eg.Data(), nev, run, bMin, bMax, monitor, u.GetUrl());
1769 ret =
LocalRun(nev, run, eg, bMin, bMax, monitor, verbose,
override);
1771 ret =
ProofRun(u, nev, run, eg, bMin, bMax,
1772 monitor, verbose,
override, save, opt);
1785 :
FastSim(
"epos", run, 0, 20, 100000, monitor),
1838 while ((estimator = static_cast<FastCentEstimator*>(next()))) {
1839 if (!estimator->IsA()->InheritsFrom(V0CentEstimator::Class()))
1848 Info(
"Init",
"Initializing with tree %p (%s)",
1849 tree, (tree ? tree->ClassName() :
""));
1852 TFile*
file = tree->GetCurrentFile();
1853 Info(
"Init",
"Current file: (%p) %s", file,
1854 (file ? file->GetName() :
""));
1858 Fatal(
"Init",
"Failed to set-up branches");
1870 Warning(
"Notify",
"No tree set yet!");
1874 Info(
"Notify",
"processing file: (%p) %s", file,
1875 (file ? file->GetName() :
""));
1876 if (!file)
return true;
1878 Warning(
"Notify",
"Failed to set-up branches");
1887 fIsTgtA = gROOT->ProcessLine(
"grp->beam1.IsA()");
1888 fIsProjA = gROOT->ProcessLine(
"grp->beam2.IsA()");
1896 if (read <= 0)
return false;
1905 while ((estimator = static_cast<FastCentEstimator*>(next())))
1943 while ((estimator = static_cast<FastCentEstimator*>(next())))
1950 for (
Int_t iPart = 0; iPart < nTot; iPart++) {
1960 TParticle* particle =
1961 new ((*fParticles)[iPart]) TParticle(pdg, status,-1,-1,-1,-1,
1962 px, py, pz, e, 0, 0, 0, 0);
1963 TParticlePDG* pdgP = particle->GetPDG();
1964 Bool_t primary = status == 1;
1965 Bool_t weakDecay =
false;
1966 Bool_t charged = (pdgP && TMath::Abs(pdgP->Charge()) > 0);
1967 if (primary) particle->SetBit(BIT(14));
1968 if (weakDecay) particle->SetBit(BIT(15));
1969 if (charged) particle->SetBit(BIT(16));
1973 while ((estimator = static_cast<FastCentEstimator*>(next())))
1976 if (!selected || !charged || !primary)
continue;
1977 fHY ->Fill(particle->Y());
1979 if (pT < 1e-10)
continue;
1981 Double_t theta = TMath::ATan2(pT, pZ);
1982 Double_t eta = -TMath::Log(TMath::Tan(theta/2));
1994 while ((estimator = static_cast<FastCentEstimator*>(next())))
2041 Printf(
"=== Event # %6lld/%6lld ==========================",
2061 TProof::Reset(url.GetUrl());
2062 TProof::Open(url.GetUrl());
2063 gProof->ClearCache();
2068 TString fwd = phy +
"/PWGLF/FORWARD/analysis2";
2070 gProof->AddIncludePath(Form(
"%s/include", ali.Data()));
2071 gProof->AddIncludePath(Form(
"%s/include", phy.Data()));
2073 gProof->Load(Form(
"%s/sim/GRP.C",fwd.Data()),
true);
2074 gProof->Load(Form(
"%s/sim/BaseConfig.C",fwd.Data()),
true);
2075 gProof->Load(Form(
"%s/sim/EGConfig.C",fwd.Data()),
true);
2078 gProof->Load(Form(
"%s/sim/FastMonitor.C+%s",fwd.Data(),opt));
2079 gProof->Load(Form(
"%s/sim/FastShortHeader.C", fwd.Data()));
2080 gProof->Load(Form(
"%s/sim/FastCentEstimators.C+%s",fwd.Data(),opt));
2081 gProof->Load(Form(
"%s/sim/FastSim.C+%s", fwd.Data(), opt),
true);
2118 Printf(
"Will run fast simulation with:\n\n\t%s\n\n",url);
2126 TObjString* token = 0;
2127 TIter nextToken(opts);
2128 while ((token = static_cast<TObjString*>(nextToken()))) {
2129 TString& str = token->String();
2130 if (str.IsNull())
continue;
2132 if (str.EqualTo(
"verbose")) { verbose =
true; str =
""; }
2134 if (str.IsNull())
continue;
2138 if (!out.IsNull()) out.Append(
"&");
2143 if (key.EqualTo(
"run")) run = val.Atoi();
2144 else if (key.EqualTo(
"monitor")) monitor = val.Atoi();
2145 else if (key.EqualTo(
"events")) nev = val.Atoi();
2147 if (!out.IsNull()) out.Append(
"&");
2154 Printf(
"Error: FastSim::Run: URL %s is invalid", u.GetUrl());
2158 Printf(
"Run EPos anchored at %d\n"
2159 " Monitor frequency: %d sec\n"
2160 " Execution url: %s",
2161 run, monitor, u.GetUrl());
2163 TString treeName = u.GetAnchor();
2164 if (treeName.IsNull()) treeName =
"Particle";
2165 TFile*
file = TFile::Open(u.GetFile(),
"READ");
2167 Printf(
"Error: FastAnalysis::Run: Failed to open %s",
2173 TObject* o = file->Get(treeName);
2175 Printf(
"Error: FastAnalysis::Run: Couldn't get %s from %s",
2176 treeName.Data(), u.GetFile());
2181 if (o->IsA()->InheritsFrom(TChain::Class()))
2182 cret = chain->Add(static_cast<TChain*>(o));
2183 else if (o->IsA()->InheritsFrom(TTree::Class()))
2184 cret = chain->AddFile(u.GetFile());
2185 else if (o->IsA()->InheritsFrom(TCollection::Class()))
2186 cret = chain->AddFileInfoList(static_cast<TCollection*>(o));
2187 else if (o->IsA()->InheritsFrom(TFileCollection::Class()))
2188 cret = chain->AddFileInfoList(static_cast<TFileCollection*>(o)
2192 Printf(
"Error: FastAnalysis::Run: Failed to create chain");
2196 TString proto = u.GetProtocol();
2197 Bool_t isProof = (proto.EqualTo(
"proof") || proto.EqualTo(
"lite"));
2205 if (nev < 0) nev = TChain::kBigNumber;
2210 Long64_t ret = chain->Process(sim,
"", nev, 0);
Bool_t PreEvent(Long64_t iEv)
static void ProofLoadLibs()
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
virtual void CheckTrigger(Double_t eta)
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)
Float_t nEvents[nProd]
Input train file.
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.
TFile * file
TList with histograms for a given trigger.
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)