KaliVeda
Toolkit for HIC analysis
CompleteEventsFW.cpp

Selecting events which are 'complete' in the forward part of the CM

This analysis class demonstrates the use of global variables KVZtot and KVZVtot to calculate total charge and momentum in the forward hemisphere of the CM, normalisation of the values to the charge and momentum of the projectile nucleus, and rejection of events which do not fulfill required constraints on these global variables.

#pragma once
#include "KVReconEventSelector.h"
class CompleteEventsFW : public KVReconEventSelector
{
double ztot_proj, ztot_min, ztot_max;
double zvtot_proj, zvtot_min, zvtot_max;
public:
CompleteEventsFW() = default;
virtual void InitRun() override;
virtual void EndRun() override {}
virtual void InitAnalysis() override;
virtual Bool_t Analysis() override;
virtual void EndAnalysis() override {}
ClassDefOverride(CompleteEventsFW,1)
};
bool Bool_t
#define ClassDefOverride(name, id)
virtual void InitAnalysis()
virtual void EndRun()
virtual Bool_t Analysis()
virtual void EndAnalysis()
virtual void InitRun()
Base class for user analysis of reconstructed data.
#include "CompleteEventsFW.h"
#include "KVReconstructedNucleus.h"
#include "KVBatchSystem.h"
#include "KVDataAnalyser.h"
#include "KVMultiDetArray.h"
#include "TRandom.h"
void CompleteEventsFW::InitAnalysis(void)
{
// DEFINITION OF GLOBAL VARIABLES USED IN ANALYSIS
// KVZtot to calculate total charge
auto ztot = AddGV("KVZtot", "ztot");
// define which particles to include: all those with positive longitudinal CM velocities
ztot->SetFrame("CM");
ztot->SetSelection({"fwcm", [](const KVNucleus* nuc){ return nuc->GetVpar()>0; }});
// Define our event selection based on the ztot variable (see KVVarGlob::SetEventSelection()).
// 'val' will be the value of ztot for a given event
// Note that the limits ztot_min and ztot_max will be defined in InitRun()
ztot->SetEventSelection([&](const KVVarGlob* vg)
{
auto val = vg->GetValue();
return val>=ztot_min && val<=ztot_max;
}
);
// KVZVtot to calculate total pseudo-momentum (Z*V)
auto zvtot = AddGV("KVZVtot", "zvtot");
// define which particles to include: all those with positive longitudinal CM velocities
zvtot->SetFrame("CM");
zvtot->SetSelection({"fwcm", [](const KVNucleus* nuc){ return nuc->GetVpar()>0; }});
// limit the number of TTree branches created for this variable to just 1 (see below)
zvtot->SetMaxNumBranches(1);
// Define our event selection based on the zvtot variable.
// 'val' will be the value of the z-component of zvtot for a given event
// Note that the limits zvtot_min and zvtot_max will be defined in InitRun()
zvtot->SetEventSelection([&](const KVVarGlob* vg)
{
auto val = vg->GetValue("Z");
return val>=zvtot_min && val<=zvtot_max;
}
);
// Note: The global variables added with AddGV() are in the default list (KVGVList)
// for which only particles which are 'OK' are taken into account: this means those
// for which the default identification & calibration quality code selections are
// applied, unless this choice is modified in InitRun() (see below).
//
// If you want, you can define and use a different list of global variables (in fact,
// you can define as many as you want), and define the selection of particles it uses
// (or none at all if you wish): see KVEventSelector::AddGVList()
// 2D histo
AddHisto<TH2F>("ztot_zvtot", "Z_{tot}/Z_{proj} vs ZV_{tot}/ZV_{proj}", 200, 0, 1.5, 200, 0, 1.5);
// create TTree with branches for our global variables
auto t = AddTree("myTree");
// this will create a branch "ztot" for the KVZtot variable, and a branch "zvtot.Z" with
// the z-component (beam direction) of the total pseudo-momentum vector calculated by
// KVZVtot. if we had not limited the number of branches for this variable (see above)
// there would also be a "zvtot.X" and "zvtot.Y" branch.
GetGVList()->MakeBranches(t);
/*** DEFINE WHERE TO SAVE THE RESULTS ***/
// This filename will be used for interactive and PROOFlite jobs.
// When running in batch mode, this will automatically use the job name.
SetJobOutputFileName("CompleteEventsFW_results.root");
}
//_____________________________________
void CompleteEventsFW::InitRun(void)
{
// Initialisations for each run
// Called at the beginning of each run
// This is the place to define the correct identification/calibration codes for particles
// which will be used in your analysis. These particles will be labelled 'OK'
// (i.e. the method IsOK() for these particles returns kTRUE).
//
// If no explicit selection is indicated here, an automatic selection for each multidetector
// array will be made using the default accepted values which are defined in variables
// [array].ReconstructedNuclei.AcceptID/ECodes.
//
// You can change the selection (or deactivate it) here by doing any of the following:
//
// gMultiDetArray->AcceptIDCodes("12,33"); => accept only ID codes in list
// gMultiDetArray->AcceptAllIDCodes(); => accept particles with any ID code
//
// If the experiment used a combination of arrays, codes have to be set for
// each array individually:
// gMultiDetArray->GetArray("[name]")->Accept.. => setting for array [name]
// set title of TTree with name of analysed system
GetTree("myTree")->SetTitle(GetCurrentRun()->GetSystemName());
// retrieve the charge and pseudo-momentum of the projectile in the reaction being analysed
ztot_proj = GetCurrentRun()->GetSystem()->GetZproj();
// note that as the target has zero momentum (in the lab!) the total pseudo-momentum is that of the projectile
zvtot_proj = GetCurrentRun()->GetSystem()->GetZVtot();
// define the limits for our selections (see InitAnalysis()) based on analysed system characteristics
ztot_min = 0.5*ztot_proj;
ztot_max = 1.05*ztot_proj;
zvtot_min = 0.5*zvtot_proj;
zvtot_max = 1.1*zvtot_proj;
}
//_____________________________________
Bool_t CompleteEventsFW::Analysis(void)
{
// update values of all global variable branches
GetGVList()->FillBranches();
// save values in TTree
// fill our histogram ztot vs. zvtot (normalised to system values)
auto ztot = GetGV("ztot")->GetValue();
ztot += gRandom->Uniform(-.5,.5); // this is just to make it look nicer!
FillHisto("ztot_zvtot", GetGV("zvtot")->GetValue("Z")/zvtot_proj, ztot/ztot_proj);
return kTRUE;
}
constexpr Bool_t kTRUE
R__EXTERN TRandom * gRandom
Description of properties and kinematics of atomic nuclei.
Definition: KVNucleus.h:123
Base class for all global variable implementations.
Definition: KVVarGlob.h:233
Double_t GetValue(void) const
Definition: KVVarGlob.h:443
virtual Double_t Uniform(Double_t x1, Double_t x2)
void FillTree(TTree &myTree, const RooDataSet &data)