4 #include "MicroStat/MCSampler.h"
5 #include "KVNucleusEvent.h"
21 void MCSampler::init()
36 void MCSampler::initialiseWeightList()
48 MCSampler::MCSampler()
140 if (!fWeightList) initialiseWeightList();
144 for (
int i = 0; i < fPartitions; i++) {
150 fSumWeights +=
w->GetWeight();
181 for (i = 0; i < fPartitions; i++) {
186 if (i == fPartitions) {
187 fLastPicked =
nullptr;
198 void MCSampler::SetBranch(
TTree* theTree,
const TString& bname,
void* variable,
const TString& vartype)
200 TString leaflist = bname +
"/";
203 if (!b) theTree->
Branch(bname, variable, leaflist);
204 else b->SetAddress(variable);
236 SetBranch(theTree,
"ESTAR", &ESTAR,
"D");
237 SetBranch(theTree,
"EDISP", &EDISP,
"D");
238 SetBranch(theTree,
"IPART", &IPART,
"L");
262 Info(
"GenerateEvents",
"Generating events for E*=%f", Exx);
265 KVError::Error(
this,
"GenerateEvents",
"Excitation energy is too low, no channels are open");
270 while (npartitions--) {
275 for (
Long64_t iev = 0; iev < nev_part; iev++) {
302 if (fSumWeights == 0)
return kFALSE;
319 if (IPART < 0)
return kFALSE;
383 Bool_t makeLegend = (fLegendProbaMin > 0.0);
391 for (; i < fPartitions; i++) {
393 if (!i && !strcmp(opt,
"E*/A")) fac =
pt->GetSum(
"GetA");
395 g[i]->SetName(
pt->GetPartitionName());
396 g[i]->SetMarkerStyle(
mark);
397 g[i]->SetMarkerColor((i % 9) + 1);
398 g[i]->SetLineColor((i % 9) + 1);
399 g[i]->SetFillColor(0);
400 g[i]->ResetBit(
BIT(20));
410 for (
double E = emin;
E <= emax;
E += estep) {
413 for (i = 0; i < fPartitions; i++) {
421 g[voie]->SetPoint(
g[voie]->GetN(),
E, proba * 100.);
425 if (makeLegend && proba > fLegendProbaMin)
g[voie]->SetBit(
BIT(20));
431 if (!strcmp(opt,
"E*/A")) {
432 mg->GetHistogram()->SetXTitle(
"E*/A (MeV)");
439 mg->GetHistogram()->SetXTitle(
"E* (MeV)");
445 mg->GetHistogram()->SetYTitle(
"Probability");
447 mg->GetHistogram()->SetAxisRange(fLegendProbaMin * 100, 100.,
"Y");
449 fTheLegend =
new TLegend(.7, 0.12, .88, .88);
450 fTheLegend->
SetHeader(
Form(
"Channels with P>%4.1f%%", fLegendProbaMin * 100));
451 for (i = 0; i < mg->GetListOfGraphs()->GetSize(); i++) {
476 const int nparticles = 7;
479 TString particles[] = {
"1n",
"1H",
"2H",
"3H",
"3He",
"4He",
"Z>2"};
484 if (!strcmp(opt,
"E*/A")) {
486 fac =
pt->GetSum(
"GetA");
493 for (
int i = 0; i < nparticles; i++) {
495 g[i]->SetName(particles[i]);
496 g[i]->SetMarkerStyle(
mark);
497 g[i]->SetMarkerColor((i % 9) + 1);
498 g[i]->SetLineColor((i % 9) + 1);
499 g[i]->SetFillColor(0);
500 g[i]->ResetBit(
BIT(20));
514 for (
double E = emin;
E <= emax;
E += estep) {
517 Double_t multiplicities[nparticles];
518 memset(multiplicities, 0,
sizeof(
double)*nparticles);
520 for (
Long64_t i = 0; i < fPartitions; i++) {
526 if (proba > 1.e-06) {
529 for (
int j = 0; j < nparticles - 1; j++) {
530 if (!strcmp(
n.GetSymbol(), particles[j].
Data())) multiplicities[j] += proba;
532 if (
n.GetZ() > 2) multiplicities[nparticles - 1] += proba;
538 for (
int i = 0; i < nparticles; i++) {
539 g[i]->SetPoint(
g[i]->GetN(),
E, multiplicities[i]);
548 if (!strcmp(opt,
"E*/A")) {
549 mg->GetHistogram()->SetXTitle(
"E*/A (MeV)");
552 mg->GetHistogram()->SetXTitle(
"E* (MeV)");
555 mg->GetHistogram()->SetYTitle(
"Multiplicity");
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t b
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t g
R__EXTERN TRandom * gRandom
char * Form(const char *fmt,...)
Class for iterating over nuclei in events accessed through base pointer/reference.
Base class for KaliVeda framework.
Abstract base class container for multi-particle events.
virtual Double_t GetChannelQValue() const =0
Monte-Carlo sampling of events with statistical weights .
virtual ~MCSampler()
Destructor.
void PlotProbabilities(double emin=0., double emax=100., double estep=1., Option_t *opt="")
void PlotMultiplicities(double emin=0., double emax=100., double estep=1., Option_t *opt="")
StatWeight * GetWeight(Int_t i) const
void SetUpTreeBranches(KVEvent *&event, TTree *theTree, const TString &bname)
void SetEventList(TTree *t, const TString &branchname)
Define the TTree or TChain containing all possible events (partitions).
void GenerateEvents(TTree *, KVEvent *event, Double_t, Long64_t npartitions, Long64_t nev_part=10)
Bool_t SetExcitationEnergy(Double_t Exx)
Long64_t PickRandomChannel()
void CalculateWeights(Double_t excitation_energy)
KVEvent * GetPartition(Long64_t i)
void SetStatWeight(const TString &)
void GenerateEvent(TTree *theTree, KVEvent *event)
Double_t GetSumWeights() const
Abstract base class for calculating statistical weights for events .
void GenerateEvent(KVEvent *partition, KVEvent *event)
virtual void initGenerateEvent(KVEvent *partition)=0
Double_t GetAvailableEnergy() const
virtual void resetGenerateEvent()=0
Double_t GetWeight() const
Long64_t GetIndex() const
virtual void SetAddress(void *add)
static TClass * GetClass(Bool_t load=kTRUE, Bool_t silent=kFALSE)
void Sort(Int_t upto=kMaxInt) override
TObject * ConstructedAt(Int_t idx)
virtual void SetHeader(const char *header="", Option_t *option="")
TLegendEntry * AddEntry(const char *name, const char *label="", Option_t *option="lpf")
const char * GetName() const override
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
virtual void Info(const char *method, const char *msgfmt,...) const
virtual Double_t Uniform(Double_t x1, Double_t x2)
const char * Data() const
virtual TBranch * GetBranch(const char *name)
virtual Long64_t GetEntries() const
virtual Int_t Branch(const char *folder, Int_t bufsize=32000, Int_t splitlevel=99)
void Error(UserClass p, const char *location, const char *va_(fmt),...)