24 : fInData(nullptr), fInTrackData(nullptr), fOutData(nullptr), fInGeom(nullptr),
25 fDetectorPrm(nullptr), fTargetPrm(nullptr), srim(nullptr) {
26 RegisterInputCollection(
"InputCollection",
"input branch (collection) name",
fInputColName, TString(
"ions"));
27 RegisterInputCollection(
"InputTrackCollection",
"input track branch (collection) name",
fInputTrackColName, TString(
"track"));
28 RegisterOutputCollection(
"OutputCollection",
"output branch (collection) name",
fOutputColName,
29 TString(
"reaction_particles"));
31 RegisterProcessorParameter(
"TargetIsGas",
"Bool, target is targer or not",
fTargetIsGas,
false);
32 RegisterProcessorParameter(
"TargetName",
"gas target name",
fTargetName, TString(
""));
33 RegisterProcessorParameter(
"TargetPressure",
"Target presure",
fTargetPressure, 0.0);
35 DoubleVec_t init_d_vec;
36 RegisterProcessorParameter(
"EnergyResolution",
"energy resolution MeV unit",
fEResolution, init_d_vec);
37 RegisterProcessorParameter(
"TimingResolution",
"timing resolution ns unit",
fTResolution, init_d_vec);
40 TString(
"prm_detectors"), &
fDetectorPrm,
"TClonesArray",
"art::crib::TDetectorParameter");
43 TString(
"prm_targets"), &
fTargetPrm,
"TClonesArray",
"art::crib::TTargetParameter");
54 fInGeom =
reinterpret_cast<TGeoManager **
>(col->GetObjectRef(
"geom"));
56 SetStateError(
"gate array not found. Run TUserGeoInitializer before this.");
64 SetStateError(Form(
"input not found: %s",
fInputColName.Data()));
67 const TClass *
const cl1 = (*fInData)->GetClass();
68 if (!cl1->InheritsFrom(art::crib::TParticleInfo::Class())) {
69 SetStateError(
"contents of input array must inherit from art::crib::TParticleInfo");
77 const TClass *
const cl2 = (*fInTrackData)->GetClass();
78 if (!cl2->InheritsFrom(art::TTrack::Class())) {
79 SetStateError(
"contents of input array must inherit from art::TTrack");
87 auto det_num = (*fDetectorPrm)->GetEntriesFast();
88 Info(
"Init",
"set %d number of detectors", det_num);
96 for (Int_t iDet = 0; iDet < det_num - 1; iDet++) {
100 for (Int_t iDet = 0; iDet < det_num; iDet++) {
104 SetStateError(Form(
"Resolution parameter size is wrong, should be %d, but %ld",
105 (*fDetectorPrm)->GetEntriesFast(),
fEResolution.size()));
110 for (Int_t iDet = 0; iDet < det_num - 1; iDet++) {
114 for (Int_t iDet = 0; iDet < det_num; iDet++) {
118 SetStateError(Form(
"Resolution parameter size is wrong, should be %d, but %ld",
119 (*fDetectorPrm)->GetEntriesFast(),
fTResolution.size()));
123 fOutData =
new TClonesArray(
"art::crib::TTelescopeData");
128 const char *tsrim_path = std::getenv(
"TSRIM_DATA_HOME");
130 SetStateError(
"TSRIM_DATA_HOME environment variable is not defined");
134 Info(
"Init",
"Initializing SRIM table...");
135 srim =
new TSrim(
"srim", 16,
137 Info(
"Init",
"\t\"%s\" list loaded.",
fTargetName.Data());
139 StringVec_t material_names;
140 for (
auto i = 0; i < det_num; i++) {
142 for (
auto j = 0; j < detprm->GetN(); j++) {
143 material_names.emplace_back(detprm->GetMaterial(j));
147 for (
const auto &str : unique_names) {
148 srim->AddElement(
"srim", 16, Form(
"%s/%s/range_fit_pol16_%s.txt", tsrim_path, str.Data(), str.Data()));
151 gRandom->SetSeed(time(
nullptr));
156 TGeoManager *geom =
static_cast<TGeoManager *
>(*fInGeom);
158 for (Int_t iData = 0; iData < (*fInData)->GetEntriesFast(); ++iData) {
163 outData->SetID(iData);
172 TVector3 first_position(track.GetX(current_z), track.GetY(current_z), current_z);
176 geom->SetCurrentPoint(first_position.X(), first_position.Y(), first_position.Z());
177 geom->SetCurrentDirection(velocity.X(), velocity.Y(), velocity.Z());
180 geom->GetCurrentNode();
184 geom->FindNextBoundary();
185 Double_t distance = geom->GetStep();
187 Bool_t isHit = geom->IsStepEntering();
192 TString hitname = geom->GetPath();
193 auto index_hitpath = hitname.Last(
'_');
194 TString det_id = hitname(index_hitpath + 1, hitname.Length());
195 if (hitname.Length() < 8 || det_id.Atoi() >= (*fDetectorPrm)->GetEntriesFast()) {
208 outData->
SetTelID(det_id.Atoi() + 1);
209 TVector3 det_position(distance * velocity.X(), distance * velocity.Y(), distance * velocity.Z());
210 det_position += first_position;
218 det_position.RotateY(-Prm->
GetAngle());
222 if (outData->
GetXID() == -1 || outData->
GetYID() == -1) {
228 Double_t duration = distance / (TMath::Sqrt(1.0 - TMath::Power(ion_mass / (ion_mass + energy), 2.0)) *
c);
233 Double_t energy_total = 0.0;
234 for (
auto iMat = 0; iMat < Prm->
GetN(); iMat++) {
238 energy_total += energy - new_energy;
249 const TTrack *
const TrackData =
dynamic_cast<const TTrack *
>(inTrackData);
250 TVector3 beam(TrackData->GetX(1.0) - TrackData->GetX(0.0), TrackData->GetY(1.0) - TrackData->GetY(0.0), 1.0);
251 Double_t theta = beam.Angle(velocity);
252 outData->
SetTheta_L(theta * TMath::RadToDeg());
257 std::unordered_set<std::string> uniqueSet;
258 std::vector<TString> result;
260 for (
const auto &tstr : input) {
261 std::string str(tstr.Data());
262 if (uniqueSet.find(str) == uniqueSet.end()) {
263 uniqueSet.insert(str);
264 result.emplace_back(tstr);
ClassImp(TDetectParticleProcessor)
particle information class
TClonesArray ** fTargetPrm
TClonesArray ** fInTrackData
TString fTargetParameterName
TString fDetectorParameterName
TClonesArray ** fDetectorPrm
~TDetectParticleProcessor() override
DoubleVec_t fTResolution
x 100 = %, index=telescope id
void Init(TEventCollection *col) override
Int_t GetStripID(Double_t pos, Int_t max_strip, Double_t size)
std::vector< TString > GetUniqueElements(const std::vector< TString > &input)
TSrim * srim
x 100 = %, index=telescope id
Double_t GetCurrentZ() const
TLorentzVector GetLorentzVector() const
Int_t GetAtomicNumber() const
Double_t GetEnergy() const
Int_t GetMassNumber() const
Double_t GetDurationTime() const