R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BNeulandProvideTStart.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 "FairRootManager.h"
16#include "R3BEventHeader.h"
17
19 : FairTask("R3BNeulandProvideTStart", 0)
20 , fNeulandCalData("NeulandCalData")
21 , fEventHeader(nullptr)
22{
23}
24
26{
27 fNeulandCalData.Init();
28
29 auto ioman = FairRootManager::Instance();
30 if (ioman == nullptr)
31 {
32 throw std::runtime_error("R3BNeulandProvideTStart: No FairRootManager");
33 }
34
35 fEventHeader = dynamic_cast<R3BEventHeader*>(ioman->GetObject("EventHeader."));
36 if (fEventHeader == nullptr)
37 {
38 throw std::runtime_error("R3BNeulandProvideTStart: No R3BEventHeader");
39 }
40
41 return kSUCCESS;
42}
43
44void R3BNeulandProvideTStart::Exec(Option_t*) { fEventHeader->SetTStart(GetTStart()); }
45
46Double_t R3BNeulandProvideTStart::GetTStart() const
47{
48 const auto calData = fNeulandCalData.Retrieve();
49
50 double tref[2] = { NAN, NAN };
51 double eref[2] = { NAN, NAN };
52 int fref = 0;
53
54 for (const auto& data : calData)
55 {
56 const auto side = data->GetSide() - 1; // [1,2] -> [0,1]
57 const auto bar = data->GetBarId();
58
59 // proton beam 2020, neuland bar 701 used as a start detector
60 if (bar == 701)
61 {
62 tref[side] = data->GetTime();
63 eref[side] = data->GetQdc();
64 fref++;
65 }
66 }
67
68 double pstart = NAN;
69 if (fref == 2)
70 {
71 if (tref[0] - tref[1] < -0.5 * 5. * 2048)
72 tref[1] = tref[1] - 5. * 2048;
73 if (tref[0] - tref[1] > 0.5 * 5. * 2048)
74 tref[0] = tref[0] - 5. * 2048;
75
76 pstart = 0.5 * (tref[0] + tref[1]);
77 }
78
79 return pstart;
80}
81
82bool R3BNeulandProvideTStart::IsBeam() const { return !std::isnan(GetTStart()); }
83
ClassImp(R3B::Neuland::Cal2HitPar)
void SetTStart(const double tStart)
void Exec(Option_t *) override
std::vector< T * > Retrieve() const