R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BNeulandCalTest.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
14#include "R3BNeulandCalTest.h"
15#include "FairLogger.h"
16#include "FairRootManager.h"
17#include "R3BLosHit.h"
18#include "R3BNeulandCalData.h"
19#include "R3BNeulandPmt.h"
20#include "TClonesArray.h"
21#include "TH1F.h"
22#include "TH2F.h"
23#include "TMath.h"
24
25Double_t walk(Double_t x)
26{
27 Double_t y = 0;
28
29 Double_t par1 = 1500.; // +-0.2238
30 Double_t par2 = 0.00075; //+-2.355e-05
31 y = par1 * TMath::Power(x, par2) - (par1 * TMath::Power(400., par2)); // Michael's
32
33 // y=2.29083*log(x)-0.0870157*log(x)*log(x)-4.57824; // mine
34
35 return y;
36 // return 0.;
37}
38
40 : fnEvents(0)
41 , fLandPmt(NULL)
42 , fNeulandPmt(NULL)
43 , fLosHit(NULL)
44{
45}
46
47R3BNeulandCalTest::R3BNeulandCalTest(const char* name, Int_t iVerbose)
48 : FairTask(name, iVerbose)
49 , fnEvents(0)
50 , fLandPmt(NULL)
51 , fNeulandPmt(NULL)
52 , fLosHit(NULL)
53{
54}
55
57
59{
60 FairRootManager* fMan = FairRootManager::Instance();
61 if (!fMan)
62 {
63 LOG(fatal) << "FairRootManager not found";
64 }
65 fLandPmt = (TClonesArray*)fMan->GetObject("NeulandCalData");
66 fNeulandPmt = (TClonesArray*)fMan->GetObject("NeulandPmt");
67 fLosHit = (TClonesArray*)fMan->GetObject("LosHit");
68 CreateHistos();
69
70 return kSUCCESS;
71}
72
73void R3BNeulandCalTest::Exec(Option_t* option)
74{
75 Bool_t startSeen = kTRUE;
76 Double_t startTime = 0.;
77 if (fLosHit)
78 {
79 Int_t nLosHit = fLosHit->GetEntriesFast();
80 Double_t stime[4];
81 R3BLosHit* losHit;
82 Int_t ch;
83 Bool_t seen[] = { kFALSE, kFALSE, kFALSE, kFALSE };
84 for (Int_t i = 0; i < nLosHit; i++)
85 {
86 losHit = (R3BLosHit*)fLosHit->At(i);
87 ch = losHit->GetChannel();
88 if (ch > 3)
89 {
90 continue;
91 }
92 else
93 {
94 seen[ch] = kTRUE;
95 stime[ch] = losHit->GetTime();
96 }
97 }
98
99 for (Int_t i = 0; i < 4; i++)
100 {
101 if (1 == i)
102 {
103 continue;
104 }
105 if (!seen[i])
106 {
107 startSeen = kFALSE;
108 break;
109 }
110 }
111 if (startSeen)
112 {
113 startTime = (stime[0] + stime[2] + stime[3]) / 3.;
114 }
115 }
116
117 if (fLandPmt)
118 {
119 Int_t nLandPmt = fLandPmt->GetEntriesFast();
120 R3BNeulandCalData* pmt1;
121 R3BNeulandCalData* pmt2;
122 Int_t barId;
123 Double_t time1, time2;
124 for (Int_t i1 = 0; i1 < nLandPmt; i1++)
125 {
126 pmt1 = (R3BNeulandCalData*)fLandPmt->At(i1);
127 barId = pmt1->GetBarId();
128 time1 = pmt1->GetTime();
129 time1 += walk(pmt1->GetQdc());
130
131 for (Int_t i2 = 0; i2 < nLandPmt; i2++)
132 {
133 if (i2 == i1)
134 {
135 continue;
136 }
137 pmt2 = (R3BNeulandCalData*)fLandPmt->At(i2);
138 if (barId != pmt2->GetBarId())
139 {
140 continue;
141 }
142 time2 = pmt2->GetTime();
143 time2 += walk(pmt2->GetQdc());
144
145 if (startSeen && barId == 125)
146 {
147 fh_los_corr->Fill((time1 + time2) / 2., startTime);
148 fh_tof->Fill((time1 + time2) / 2. - startTime);
149 fh_qdctof->Fill((time1 + time2) / 2. - startTime - 1563. + 30.,
150 TMath::Sqrt(pmt1->GetQdc() * pmt2->GetQdc()));
151 }
152 if (startSeen && barId == 225)
153 {
154 fh_qdctof->Fill((time1 + time2) / 2. - startTime - 1571. + 30.,
155 TMath::Sqrt(pmt1->GetQdc() * pmt2->GetQdc()));
156 }
157 }
158 }
159 }
160 if (fNeulandPmt)
161 {
162 Int_t nNeulandPmt = fNeulandPmt->GetEntriesFast();
163 R3BNeulandPmt* pmt1;
164 R3BNeulandPmt* pmt2;
165 Int_t planeId;
166 Int_t barId;
167 Double_t time1, time2;
168 for (Int_t i1 = 0; i1 < nNeulandPmt; i1++)
169 {
170 pmt1 = (R3BNeulandPmt*)fNeulandPmt->At(i1);
171 planeId = pmt1->GetPlaneId();
172 barId = pmt1->GetBarId();
173 time1 = pmt1->GetTime();
174 time1 += walk(pmt1->GetCharge());
175
176 for (Int_t i2 = i1 + 1; i2 < nNeulandPmt; i2++)
177 {
178 if (i2 == i1)
179 {
180 continue;
181 }
182 pmt2 = (R3BNeulandPmt*)fNeulandPmt->At(i2);
183 if (barId != pmt2->GetBarId())
184 {
185 continue;
186 }
187 time2 = pmt2->GetTime();
188 time2 += walk(pmt2->GetCharge());
189
190 fh_tdiff->Fill(time1 - time2);
191 /*
192 if (startSeen && barId == 125)
193 {
194 fh_los_corr->Fill((time1 + time2) / 2., startTime);
195 fh_tof->Fill((time1 + time2) / 2. - startTime);
196 fh_qdctof->Fill((time1 + time2) / 2. - startTime - 1563. + 30.,
197 TMath::Sqrt(pmt1->GetQdc()*pmt2->GetQdc()));
198 }
199 if (startSeen && barId == 225)
200 {
201 fh_qdctof->Fill((time1 + time2) / 2. - startTime - 1571. + 30.,
202 TMath::Sqrt(pmt1->GetQdc()*pmt2->GetQdc()));
203 }
204 */
205 }
206 }
207 }
208
209 fnEvents += 1;
210}
211
212void R3BNeulandCalTest::FinishTask() { WriteHistos(); }
213
214void R3BNeulandCalTest::CreateHistos()
215{
216 fh_los_corr = new TH2F("h_los_corr", "LOS vs NeuLAND", 1000, 100, 400., 1000, -1360., -1310.);
217 fh_tof = new TH1F("h_tof", "ToF", 1000, 1500., 1700.);
218 fh_qdctof = new TH2F("h_qdctof", "QDC vs ToF", 1000, 0., 100., 200, 0., 2000.);
219 fh_qdctof_2 = new TH2F("h_qdctof_2", "QDC vs ToF", 1000, 0., 100., 200, 0., 2000.);
220 fh_tdiff = new TH1F("h_tdiff", "Tdiff", 10000, -50, 50.);
221}
222
223void R3BNeulandCalTest::WriteHistos()
224{
225 fh_los_corr->Write();
226 fh_tof->Write();
227 fh_qdctof->Write();
228 fh_qdctof_2->Write();
229 fh_tdiff->Write();
230}
231
Double_t walk(Double_t x)
ClassImp(R3B::Neuland::Cal2HitPar)
Double_t GetTime() const
auto GetQdc() const -> double
Int_t GetBarId() const
virtual InitStatus Init()
virtual void FinishTask()
virtual void Exec(Option_t *option)
const Double_t & GetTime() const
const Int_t & GetBarId() const
const Int_t & GetPlaneId() const
const Double_t & GetCharge() const