R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BNeulandMultiplicityCalorimetricPar.cxx
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) 2019 GSI Helmholtzzentrum für Schwerionenforschung GmbH *
3 * Copyright (C) 2019-2025 Members of R3B Collaboration *
4 * *
5 * This software is distributed under the terms of the *
6 * GNU General Public Licence (GPL) version 3, *
7 * copied verbatim in the file "LICENSE". *
8 * *
9 * In applying this license GSI does not waive the privileges and immunities *
10 * granted to it by virtue of its status as an Intergovernmental Organization *
11 * or submit itself to any jurisdiction. *
12 ******************************************************************************/
13
15#include "FairLogger.h"
16#include "TObjString.h"
17
19 const char* title,
20 const char* context)
21 : FairParGenericSet(name, title, context)
22 , fNeutronCuts(nullptr)
23{
24}
25
27{
28 // Note: Deleting stuff here or in clear() causes segfaults?
29}
30
32
34{
35 if (!l)
36 {
37 return;
38 }
39 l->addObject("NeulandNeutronCuts", fNeutronCuts);
40}
41
43{
44 if (!l)
45 {
46 return kFALSE;
47 }
48 if (!l->fillObject("NeulandNeutronCuts", fNeutronCuts))
49 {
50 return kFALSE;
51 }
52 return kTRUE;
53}
54
56{
57 LOG(info) << "R3BNeulandMultiplicityCalorimetricPar: Neuland Neutron Cuts ...";
58 for (const auto& nc : GetNeutronCuts())
59 {
60 LOG(info) << nc.first;
61 nc.second->Print();
62 }
63}
64
65void R3BNeulandMultiplicityCalorimetricPar::SetNeutronCuts(const std::map<UInt_t, TCutG*>& cuts)
66{
67 fNeutronCuts = new TMap();
68 fNeutronCuts->SetOwner(kTRUE);
69 for (const auto& nc : cuts)
70 {
71 auto key = new TObjString(TString::Itoa(nc.first, 10));
72 fNeutronCuts->Add(key, nc.second->Clone());
73 }
74}
75
77{
78 if (fNeutronCuts == nullptr)
79 {
80 LOG(fatal) << "R3BNeulandMultiplicityCalorimetricPar: NeutronCuts not set!";
81 }
82
83 std::map<UInt_t, TCutG*> map;
84
85 TObjString* key;
86 TIterator* nextobj = fNeutronCuts->MakeIterator();
87 while ((key = dynamic_cast<TObjString*>(nextobj->Next())))
88 {
89 UInt_t nNeutrons = key->GetString().Atoi();
90 map[nNeutrons] = dynamic_cast<TCutG*>(fNeutronCuts->GetValue(key)->Clone());
91 }
92
93 return map;
94}
95
96TCutG* R3BNeulandMultiplicityCalorimetricPar::GetNeutronCut(const Int_t n) const { return GetNeutronCuts().at(n); }
97
99 const Double_t nClusters) const
100{
101 // Note: it might be better to implement std::map as a member and sync between the tmap for this type of usage.
102 if (fNeutronCuts == nullptr)
103 {
104 LOG(fatal) << "R3BNeulandMultiplicityCalorimetricPar: NeutronCuts not set!";
105 }
106
107 if (nClusters < 1)
108 {
109 return 0;
110 }
111
112 TObjString* key;
113 TIterator* nextobj = fNeutronCuts->MakeIterator();
114 while ((key = dynamic_cast<TObjString*>(nextobj->Next())))
115 {
116 // UInt_t nNeutrons = key->GetString().Atoi();
117 if ((dynamic_cast<TCutG*>(fNeutronCuts->GetValue(key)))->IsInside(energy, nClusters))
118 {
119 return (UInt_t)key->GetString().Atoi();
120 }
121 }
122 // Assume if no match is found, the neutron multiplicity must be higher than the highest saved cut.
123 return GetNeutronCuts().rbegin()->first + 1;
124}
125
ClassImp(R3BNeulandMultiplicityCalorimetricPar)
NeuLAND number of clusters / energy - neutron multiplicity parameter storage.
void SetNeutronCuts(const std::map< UInt_t, TCutG * > &cuts)
UInt_t GetNeutronMultiplicity(const Double_t energy, const Double_t nClusters) const
R3BNeulandMultiplicityCalorimetricPar(const char *name="R3BNeulandMultiplicityCalorimetricPar", const char *title="Neuland Neutron 2D Parameters", const char *context="TestDefaultContext")
STL class.