12 if (trg_name.length() == 0) {
13 trg_name = Form(
"target_%ld",
fTargets.size());
21 std::string h_name_base =
"";
23 if (element_i < 8)
continue;
26 if (element_j < 8)
continue;
30 if (unit_i >= unit_j)
continue;
32 for (
auto& [trg_name, trg] :
fTargets) {
33 h_name_base = Form(
"0x%x:0x%x_%s", element_i, element_j, trg_name.c_str());
47 h_name = Form(
"%s_Y_vs_X", h_name_base.c_str());
48 fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), nb_bins_x,
fSampleRangeXmin,
50 fH2D[h_name]->GetXaxis()->SetTitle(
"X [cm]");
51 fH2D[h_name]->GetYaxis()->SetTitle(
"Y [cm]");
53 h_name = Form(
"%s_X_vs_Z", h_name_base.c_str());
54 fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), nb_bins_z,
fSampleRangeZmin,
56 fH2D[h_name]->GetXaxis()->SetTitle(
"Z [cm]");
57 fH2D[h_name]->GetYaxis()->SetTitle(
"X [cm]");
59 h_name = Form(
"%s_Y_vs_Z", h_name_base.c_str());
60 fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), nb_bins_z,
fSampleRangeZmin,
62 fH2D[h_name]->GetXaxis()->SetTitle(
"Z [cm]");
63 fH2D[h_name]->GetYaxis()->SetTitle(
"Y [cm]");
65 h_name = Form(
"%s_Y_beam_vs_X_beam", h_name_base.c_str());
66 fH2D[h_name] = std::make_unique<TH2D>(h_name.c_str(), h_name.c_str(), nb_bins_x,
fSampleRangeXmin,
68 fH2D[h_name]->GetXaxis()->SetTitle(
"X_beam [cm]");
69 fH2D[h_name]->GetYaxis()->SetTitle(
"Y_beam [cm]");
79 TVector3 n1(.0, .0, 1.);
82 TVector3 l0(hit_0->
GetX(), hit_0->
GetY(), hit_0->
GetZ());
85 double l1_dot_n1 = l1.Dot(n1);
86 if (l1_dot_n1 <= 1e-6) {
87 throw std::invalid_argument(
"Track-let parallel to target plane");
90 double t = (n0 - l0).Dot(n1) / l1.Dot(n1);
97 for (
int sts_unit_i = 0; sts_unit_i <
nb_sts_station_ - 1; sts_unit_i++) {
98 for (
int sts_unit_j = sts_unit_i + 1; sts_unit_j <
nb_sts_station_; sts_unit_j++) {
99 for (
auto sts_hit_i :
fStsHits[sts_unit_i]) {
100 for (
auto sts_hit_j :
fStsHits[sts_unit_j]) {
101 int32_t sts_address_i = sts_hit_i->GetAddress();
102 int32_t sts_address_j = sts_hit_j->GetAddress();
104 for (
auto& [trg_name, trg] :
fTargets) {
106 std::string h_name_base = Form(
"0x%x:0x%x_%s", sts_address_i, sts_address_j, trg_name.c_str());
108 std::string h_name = Form(
"%s_X_vs_Z", h_name_base.c_str());
109 fH2D[h_name]->Fill(sol.Pz(), sol.Px());
111 h_name = Form(
"%s_Y_vs_Z", h_name_base.c_str());
112 fH2D[h_name]->Fill(sol.Pz(), sol.Py());
114 h_name = Form(
"%s_Y_vs_X", h_name_base.c_str());
115 fH2D[h_name]->Fill(sol.Px(), sol.Py());
117 TVector3 sol_beam = sol - trg->GetPosition();
119 double x_beam = sol_beam.Px() /
cos(trg->GetRotation());
120 double y_beam = sol_beam.Py();
121 h_name = Form(
"%s_Y_beam_vs_X_beam", h_name_base.c_str());
122 fH2D[h_name]->Fill(x_beam, y_beam);
139 for (
int hit_evt_idx = 0; hit_evt_idx < nb_sts_hits; hit_evt_idx++) {
148 if (hit ==
nullptr)
return;
164 LOG(info) <<
"Running CbmStsRecoBeamSpot - Event like - Entry:" <<
entry_ <<
"\tEvents: " << nb_events;
165 for (uint32_t evt_idx = 0; evt_idx < nb_events; evt_idx++) {
176 LOG(info) <<
"Running CbmStsRecoBeamSpot - Time like - Entry:" <<
entry_ <<
"\tStsHit: " << n_of_hits;
177 for (uint32_t hit_idx = 0; hit_idx < n_of_hits; hit_idx++) {
188 LOG(debug) <<
"Init CbmStsRecoBeamSpot ...";
190 FairRootManager* ioman = FairRootManager::Instance();
191 if (ioman ==
nullptr)
return kERROR;
193 fCbmEvtArray = (TClonesArray*) ioman->GetObject(
"CbmEvent");
194 fStsHitArray = (TClonesArray*) ioman->GetObject(
"StsHit");
195 fStsCluArray = (TClonesArray*) ioman->GetObject(
"StsCluster");
197 for (
auto& [trg_name, trg] :
fTargets) {
198 LOG(debug) << trg_name <<
": " << trg->ToString();
friend fvec cos(const fvec &a)
Class characterising one event by a collection of links (indices) to data objects,...
size_t GetNofData() const
uint32_t GetIndex(ECbmDataType type, uint32_t iData) const
int32_t GetAddress() const
CbmCutMap * fAnalysisCuts
std::map< std::string, std::unique_ptr< TH2D > > fH2D
void SaveToFile()
It write all mapped objects to the FairRunAna sink file.
void LoadSetup()
Load the STS setup and fill the map with XYZ boundaries for each STS setup element....
std::unordered_map< int32_t, std::vector< double > > fStsGeoInfo
data class for a reconstructed 3-d hit in the STS
TVector3 ExtrapolateTrackTo(CbmPixelHit *, CbmPixelHit *, CbmTarget *)
Extrapolate a track-let to a target plane.
void AddTarget(CbmTarget *target=nullptr)
Add a CbmTarget object to the list of targets.
TClonesArray * fCbmEvtArray
void ProcessEvent(CbmEvent *)
Process an Cbm events It filters event based on the provided CbmCutMap.
TClonesArray * fStsCluArray
void ProcessHit(CbmStsHit *)
Process an STS hit It filters hits based on the provided CbmCutMap.
void BeamSpotReco()
Reconstruct the beam spot at each target planes.
std::map< std::string, CbmTarget * > fTargets
std::map< int32_t, std::vector< CbmStsHit * > > fStsHits
TClonesArray * fStsHitArray
Class for constructing the geometry of the CBM target.
Double_t GetRotation() const
Get target rotation angle.
TVector3 GetPosition() const
uint32_t GetElementId(int32_t address, int32_t level)
Get the index of an element.