10 #include "KVElasticScatterEvent.h"
11 #include "KVPosition.h"
12 #include "KVDetector.h"
13 #include "KVTelescope.h"
47 if (sim_evt)
delete sim_evt;
48 if (rec_evt)
delete rec_evt;
71 kIPPVector.SetXYZ(0, 0, 0);
97 ResetBit(kIsDetectionOn);
99 SetDiffNucleus(
"PROJ");
100 SetRandomOption(
"isotropic");
139 Error(
"SetSystem",
"KVDBSystem pointer is not valid");
173 targ->SetName(
"TARG");
175 ResetBit(kIsUpdated);
192 if (
name ==
"TARG") {
197 if (
name !=
"PROJ") {
198 Warning(
"SetDiffNucleus",
"%s Le nom en argument doit etre PROJ ou TARG, par defaut on choisit le projectile",
name.Data());
228 return strcmp(kRandomOpt,
"random");
250 if (choix >= 0 && choix <= 2)
265 proj->SetName(
"PROJ");
267 ResetBit(kIsUpdated);
281 if (sname ==
"PROJ")
return proj;
282 else if (sname ==
"TARG")
return targ;
295 if (ii == 1)
return proj;
296 else if (ii == 2)
return targ;
312 if (ktarget)
delete ktarget;
315 ktarget->SetRandomized(IsRandomized);
317 ResetBit(kIsUpdated);
327 if (gMultiDetArray) {
330 SetBit(kIsDetectionOn, On);
331 ResetBit(kIsUpdated);
336 Warning(
"MakeDetection",
"Detection asked but no multiDetArray defined");
386 Info(
"GenereKV2Body",
"On genere le KV2Body");
388 kb2 =
new KV2Body(*proj, *targ);
389 kb2->CalculateKinematics();
396 GetNucleus(
"PROJ")->Copy(*sim_evt->AddParticle());
397 GetNucleus(
"TARG")->Copy(*sim_evt->AddParticle());
411 else sim_evt->Clear();
414 else rec_evt->Clear();
435 if (GetTarget()->GetLayers()->GetEntries() == 0)
return kFALSE;
437 if (layer_name ==
"") {
439 mat = GetTarget()->GetLayerByIndex(kchoix_layer);
442 if (!(mat = GetTarget()->GetLayer(layer_name))) {
443 printf(
"le nom du layer %s ne correspond a aucun present dans le cible\n", layer_name.
Data());
444 printf(
"Attention le layer doit etre appele par son symbol (ie Calcium -> Ca)");
445 ktarget->GetLayers()->Print();
448 kchoix_layer = GetTarget()->GetLayerIndex(layer_name);
515 if (!IsProjNucSet()) {
516 Error(
"ValidateEntrance",
"Il n'y a pas de noyau projectile -> use SetProjNucleus()");
520 if (!IsTargNucSet()) {
521 Info(
"ValidateEntrance",
"Il n'y a pas de noyau cible");
522 if (!IsTargMatSet()) {
523 Error(
"ValidateEntrance",
"Il n'y a pas de noyau cible -> use SetTargNucleus() ou SetTargetMaterial");
527 if (DefineTargetNucleusFromLayer())
528 Info(
"ValidateEntrance",
"Definition du noyau cible via DefineTargetNucleusFromLayer()");
532 if (IsDetectionOn()) {
548 Warning(
"ValidateEntrance",
"Pas de calcul de perte dans la cible ... ");
553 Info(
"ValidateEntrance",
"The elastic scatter events will not be detected/filtered");
557 Info(
"ValidateEntrance",
"Fin de GenereKV2Body");
561 if (!ltree) DefineTrees();
583 Info(
"Process",
"Je Suis dans Process ... Youpee");
586 if (!ValidateEntrance())
return;
590 while (nn < ntimes) {
593 if ((nn % 1000) == 0) {
594 Info(
"Process",
"%d/%d diffusions treated", nn, ntimes);
597 Info(
"Process",
"End of process : %d diffusions performed", kTreatedNevts);
627 sim_evt->GetParameters()->Clear();
629 knuc.GetParameters()->Clear();
630 knuc.RemoveAllGroups();
634 if (IsTargMatSet()) {
635 NewInteractionPointInTargetLayer();
636 PropagateInTargetLayer();
642 if (tmin >= kb2->GetMaxAngleLab(kDiffNuc)) {
643 GetNucleus(
"PROJ")->SetMomentum(*GetNucleus(
"PROJ")->GetPInitial());
648 if (tmax <= kb2->GetMinAngleLab(kDiffNuc)) {
649 GetNucleus(
"PROJ")->SetMomentum(*GetNucleus(
"PROJ")->GetPInitial());
653 if (tmin < kb2->GetMinAngleLab(kDiffNuc)) tmin = kb2->GetMinAngleLab(kDiffNuc);
654 if (tmax > kb2->GetMaxAngleLab(kDiffNuc)) tmax = kb2->GetMaxAngleLab(kDiffNuc);
659 kposalea.SetPolarMinMax(tmin, tmax);
660 kposalea.SetAzimuthalMinMax(pmin, pmax);
663 kposalea.GetRandomAngles(th_deg, ph_deg, kRandomOpt);
665 SetAnglesForDiffusion(th_deg, ph_deg);
667 ((
TH2F*)lhisto->FindObject(
"phi_theta"))->Fill(th_deg, ph_deg);
671 if (IsDetectionOn()) {
696 if (kchoix_layer != -1) {
697 TVector3 dir = GetNucleus(
"PROJ")->GetMomentum();
698 ktarget->SetInteractionLayer(kchoix_layer, dir);
701 kIPPVector = ktarget->GetInteractionPoint(GetNucleus(
"PROJ"));
702 ((
TH1F*)lhisto->FindObject(
"target_layer_depth"))->Fill(kIPPVector.Z());
726 Double_t eLostInTarget = GetNucleus(
"PROJ")->GetKE();
727 ktarget->SetIncoming(
kTRUE);
728 ktarget->DetectParticle(GetNucleus(
"PROJ"), 0);
729 eLostInTarget -= GetNucleus(
"PROJ")->GetKE();
732 sim_evt->GetParticleWithName(
"PROJ")->GetParameters()->SetValue(
"TARGET In", eLostInTarget);
736 if (GetNucleus(
"PROJ")->GetKE() == 0) {
737 GetNucleus(
"PROJ")->Print();
738 printf(
"%lf / %lf\n", eLostInTarget, proj->GetKE());
740 kb2->GetNucleus(1)->SetKE(GetNucleus(
"PROJ")->GetKE());
741 kb2->CalculateKinematics();
743 ktarget->SetIncoming(
kFALSE);
773 ktarget->SetOutgoing(
kTRUE);
776 Double_t eLostInTarget = knuc.GetKE();
777 ktarget->DetectParticle(&knuc, 0);
778 eLostInTarget -= knuc.GetKE();
779 knuc.GetParameters()->SetValue(
"TARGET Out", eLostInTarget);
780 knuc.SetMomentum(*knuc.GetPInitial());
783 ktarget->SetOutgoing(
kFALSE);
812 nsol_kin = kb2->GetELab(kDiffNuc, theta, kDiffNuc, ediff1, ediff2);
818 if (kChoixSol == 1) ediff = ediff1;
819 else if (kChoixSol == 2) {
824 if (choix == 2) ediff = ediff2;
828 Bool_t sol2 = (ediff == ediff2);
830 kXruth_evt = kb2->GetXSecRuthLab(theta, kDiffNuc);
837 knuc = sim_evt->GetParticleWithName(
"PROJ");
839 knuc = sim_evt->GetParticleWithName(
"TARG");
848 TVector3 ptot = proj->Vect() + targ->Vect();
849 Double_t etot = proj->E() + targ->E();
851 ptot -= knuc->
Vect();
856 knuc = sim_evt->GetParticleWithName(
"TARG");
858 knuc = sim_evt->GetParticleWithName(
"PROJ");
865 sim_evt->SetNumber(kTreatedNevts);
867 sim_evt->GetParameters()->SetValue(
"XRuth", kXruth_evt);
868 sim_evt->GetParameters()->SetValue(
"ThDiff", theta);
869 sim_evt->GetParameters()->SetValue(
"EkDiff", ediff1);
870 sim_evt->GetParameters()->SetValue(
"IPz", kIPPVector.Z());
873 sim_evt->GetParameters()->SetValue(
"Sol2", 1);
877 GetNucleus(
"PROJ")->SetMomentum(*GetNucleus(
"PROJ")->GetPInitial());
894 Fatal(
"Filter",
"Must be reimplemented using KVDetectionSimulator and/or KVEventFiltering");
943 if (rec_evt->GetMult() > 0) {
944 TTree*
tt = (
TTree*)ltree->FindObject(
"ElasticScatter");
1034 printf(
"#####################\n");
1035 printf(
"## KVElasticScatterEvent::Print() ##\n");
1036 printf(
"# Diffusion elastique traitee :\n");
1037 printf(
"# %s+%s@%1.2lf MeV/A\n",
1038 GetNucleus(1)->GetSymbol(),
1039 GetNucleus(2)->GetSymbol(),
1040 GetNucleus(1)->GetKE() / GetNucleus(1)->GetA()
1042 if (IsTargMatSet()) {
1043 printf(
"-------------------------\n");
1044 printf(
"# Propagation dans une cible de:\n");
1045 for (
Int_t nn = 0; nn < GetTarget()->GetLayers()->GetEntries(); nn += 1) {
1047 printf(
"#\ttype:%s epaisseur:%lf (mg/cm**2) / %lf\n",
1048 GetTarget()->GetLayerByIndex(nn + 1)->
GetType(),
1050 GetTarget()->GetLayerByIndex(nn + 1)->GetThickness()
1054 printf(
"-------------------------\n");
1055 if (IsDetectionOn()) {
1056 printf(
"# Detection par %s\n", gMultiDetArray->
GetName());
1058 printf(
"#####################\n");
1077 Info(
"DefineHistos",
"DefineHistos");
1079 lhisto->SetOwner(
kTRUE);
1083 lhisto->
Add(
new TH2F(
"phi_theta",
"phi_theta", 180, 0, 180, 360, 0, 360));
1084 h2 = (
TH2F*)lhisto->Last();
1087 lhisto->Add(
new TH1F(
"costheta",
"costheta", 200, -1, 1));
1088 h1 = (
TH1F*)lhisto->Last();
1090 if (IsTargMatSet()) {
1091 Info(
"DefineHistos",
"Creation de l histo interaction dans la cible");
1092 Float_t thickness = GetTarget()->GetThickness();
1093 lhisto->Add(
new TH1F(
"target_layer_depth",
"target_layer_depth",
TMath::Nint(thickness * 110), 0, thickness * 1.1));
1094 h1 = (
TH1F*)lhisto->Last();
1097 Float_t totalE = GetNucleus(1)->GetKE();
1098 lhisto->Add(
new TH2F(
"ek_theta",
"ek_theta", 180, 0, 180,
TMath::Nint(totalE * 11), 0, totalE * 1.1));
1099 h2 = (
TH2F*)lhisto->Last();
1125 lhisto->Execute(
"Reset",
"");
1136 if (lhisto)
delete lhisto;
1166 Info(
"DefineTrees",
"DefineTrees");
1168 ltree->SetOwner(
kTRUE);
1171 tt =
new TTree(
"ElasticScatter",
IsA()->GetName());
1196 if (ltree)
delete ltree;
1211 ltree->Execute(
"Reset",
"");
1212 if (((
TTree*)ltree->FindObject(
"ElasticScatter"))->GetListOfAliases())
1213 ((
TTree*)ltree->FindObject(
"ElasticScatter"))->GetListOfAliases()->Clear();
1231 if (tmin != -1) th_min = tmin;
1232 if (tmax != -1) th_max = tmax;
1233 if (pmin != -1) phi_min = pmin;
1234 if (pmax != -1) phi_max = pmax;
1259 Double_t tmin = -1, tmax = -1, pmin = -1, pmax = -1;
1268 KVTelescope* pos_obj = (KVTelescope*)((KVDetector*)obj)->GetParentStructure(
"TELESCOPE");
1269 tmin = pos_obj->GetThetaMin();
1270 tmax = pos_obj->GetThetaMax();
1271 pmin = pos_obj->GetPhiMin();
1272 pmax = pos_obj->GetPhiMax();
1275 Warning(
"DefineAngularRange(KVASMultiDetArray*)",
"Needs reimplementing");
1294 printf(
"les objects de type %s ne sont pas implemente dans KVElasticScatterEvent::DefineAngularRange\n", obj->
IsA()->
GetName());
1298 DefineAngularRange(tmin, tmax, pmin, pmax);
1312 if (opt ==
"min")
return th_min;
1313 else if (opt ==
"max")
return th_max;
1329 if (opt ==
"min")
return phi_min;
1330 else if (opt ==
"max")
return phi_max;
R__EXTERN TRandom * gRandom
TClass * IsA() const override
Relativistic binary kinematics calculator.
KVNucleus * GetNucleus(Int_t i) const
Database class used to store information on different colliding systems studied during an experiment....
KVTarget * GetTarget() const
KV2Body * GetKinematics()
simulate ElasticScatterEvent and answer of a given (multi-)detector : A + B -> A + B
virtual void SetProjNucleus(KVNucleus *nuc)
Define new projectile nucleus.
virtual void SetSystem(KVDBSystem *sys)
virtual TVector3 & GetInteractionPointInTargetLayer()
return the last interaction point in the target
void Print(Option_t *="") const
virtual void ClearTrees()
Efface la liste des arbres et leur contenu et met le pointeur a zero.
virtual void DefineAngularRange(TObject *)
void SetDiffNucleus(KVString name="PROJ")
virtual void SetTargNucleus(KVNucleus *nuc)
Define new target nucleus.
virtual void DefineHistos()
Bool_t IsIsotropic() const
retoune kTRUE si l'option choisi est isotrope
virtual void SetAnglesForDiffusion(Double_t theta, Double_t phi)
void SetRandomOption(Option_t *opt="isotropic")
KVHashList * GetTrees() const
return the list where histo are stored
virtual void TreateEvent()
KVTarget * GetTarget() const
return the current target material
virtual void Process(Int_t ntimes=1, Bool_t reset=kTRUE)
void PropagateInTargetLayer()
virtual void ClearHistos()
Efface la liste des histo et leur contenu et met le pointeur a zero.
virtual void ResetHistos()
Reset histo in the list.
virtual void SetTargetMaterial(KVTarget *targ, Bool_t IsRandomized=kTRUE)
void NewInteractionPointInTargetLayer()
void SetDetectionOn(Bool_t On=kTRUE)
KVHashList * GetHistos() const
return the list where histo are stored
virtual ~KVElasticScatterEvent()
Destructor.
virtual void Reset()
Set contents/entries to zero for predifined histograms, trees.
virtual Bool_t ValidateEntrance()
virtual void DefineTrees()
virtual void MakeDiffusion()
KVNucleus * GetNucleus(const Char_t *name) const
return the current projectile ("PROJ") or the target ("TARG") nucleus
void ChooseKinSol(Int_t choix=1)
Bool_t DefineTargetNucleusFromLayer(KVString layer_name="")
Double_t GetPhi(KVString opt) const
Double_t GetTheta(KVString opt) const
virtual void ResetTrees()
static void MakeEventBranch(TTree *tree, const TString &branchname, T &event, Int_t bufsize=10000000)
Extended version of ROOT THashList.
Description of physical materials used to construct detectors & targets; interface to range tables.
void SetFilterType(Int_t t)
virtual void SetSimMode(Bool_t on=kTRUE)
virtual void SetTarget(KVTarget *target)
Description of properties and kinematics of atomic nuclei.
void Copy(TObject &) const override
Copy this KVNucleus into the KVNucleus object referenced by "obj".
void SetZandA(Int_t z, Int_t a)
Set atomic number and mass number.
void SetZAandE(Int_t z, Int_t a, Double_t ekin)
Set atomic number, mass number, and kinetic energy in MeV.
void SetTheta(Double_t theta)
void SetPhi(Double_t phi)
Double_t GetTheta() const
void SetKE(Double_t ecin)
void Set4Mom(const TLorentzVector &p)
Base class used for handling geometry in a multidetector array.
Double_t GetPhiMax() const
Double_t GetPhiMin() const
Double_t GetThetaMin() const
Double_t GetThetaMax() const
Event containing KVReconstructedNucleus nuclei reconstructed from hits in detectors.
Container class for simulated nuclei, KVSimNucleus.
Extension of ROOT TString class which allows backwards compatibility with ROOT v3....
Calculation/correction of energy losses of particles through an experimental target.
Wrapper class for iterating over nuclei in KVSimEvent accessed through base pointer or reference.
virtual Bool_t Add(const TH1 *h, const TH1 *h2, Double_t c1=1, Double_t c2=1)
virtual void SetXTitle(const char *title)
virtual void SetYTitle(const char *title)
const char * GetName() const override
virtual Bool_t InheritsFrom(const char *classname) const
virtual TClass * IsA() const
virtual Double_t Uniform(Double_t x1, Double_t x2)
const char * Data() const
RVec< PromoteTypes< T0, T1 > > pow(const T0 &x, const RVec< T1 > &v)
RVec< T > Filter(const RVec< T > &v, F &&f)
Type GetType(const std::string &Name)
constexpr Double_t DegToRad()