R3BROOT
R3B analysis software
Loading...
Searching...
No Matches
R3BNeulandTcal.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// ------------------------------------------------------------
15// ----- R3BNeuLandTcal -----
16// ----- Created 27-01-2015 by M.Heil -----
17// ------------------------------------------------------------
18
19#include "R3BNeulandTcal.h"
20
21#include "R3BEventHeader.h"
22#include "R3BNeulandPmt.h"
24#include "R3BTCalEngine.h"
25#include "R3BTCalPar.h"
26
27#include "FairLogger.h"
28#include "FairRootManager.h"
29#include "FairRunAna.h"
30#include "FairRuntimeDb.h"
31
32#include "TClonesArray.h"
33
35 : FairTask("LandTcal", 1)
36 , fNEvents(0)
37 , fMappedHit(NULL)
38 , fPmt(new TClonesArray("R3BNeulandPmt"))
39 , fNPmt(0)
40 , fTcalPar(NULL)
41 , fTrigger(-1)
42 // , fMap17Seen()
43 // , fMapStopTime()
44 // , fMapStopClock()
45 , fClockFreq(1. / VFTX_CLOCK_MHZ * 1000.)
46{
47}
48
49R3BNeulandTcal::R3BNeulandTcal(const char* name, Int_t iVerbose)
50 : FairTask(name, iVerbose)
51 , fNEvents(0)
52 , fMappedHit(NULL)
53 , fPmt(new TClonesArray("R3BNeulandPmt"))
54 , fNPmt(0)
55 , fTcalPar(NULL)
56 , fTrigger(-1)
57 // , fMap17Seen()
58 // , fMapStopTime()
59 // , fMapStopClock()
60 , fClockFreq(1. / VFTX_CLOCK_MHZ * 1000.)
61{
62}
63
65{
66 if (fPmt)
67 {
68 delete fPmt;
69 fPmt = NULL;
70 fNPmt = 0;
71 }
72}
73
75{
76 LOG(info) << "R3BNeulandTcal::Init : read " << fTcalPar->GetNumModulePar() << " calibrated modules";
77 // fTcalPar->printParams();
78
79 FairRootManager* mgr = FairRootManager::Instance();
80 if (NULL == mgr)
81 {
82 LOG(fatal) << "FairRootManager not found";
83 }
84 /*
85 header = (R3BEventHeader*)mgr->GetObject("R3BEventHeader");
86 if (NULL == header)
87 {
88 FairLogger::GetLogger()->Fatal(MESSAGE_ORIGIN, "Branch R3BEventHeader not found");
89 }
90 */
91 fMappedHit = dynamic_cast<TClonesArray*>(mgr->GetObject("NeulandMappedData"));
92 if (NULL == fMappedHit)
93 {
94 LOG(fatal) << "Branch NeulandMappedData not found";
95 }
96
97 mgr->Register("NeulandPmt", "Land", fPmt, kTRUE);
98
99 return kSUCCESS;
100}
101
103{
104 FairRunAna* ana = FairRunAna::Instance();
105 FairRuntimeDb* rtdb = ana->GetRuntimeDb();
106 fTcalPar = dynamic_cast<R3BTCalPar*>(rtdb->getContainer("LandTCalPar"));
107}
108
110{
112 return kSUCCESS;
113}
114
115void R3BNeulandTcal::Exec(Option_t*)
116{
117 /*
118 if (fTrigger >= 0)
119 {
120 if (header->GetTrigger() != fTrigger)
121 {
122 return;
123 }
124 }
125*/
126 Int_t nHits = fMappedHit->GetEntriesFast();
127 /*
128 if (nHits > (fNofPMTs / 2))
129 {
130 return;
131 }
132 */
134 Int_t iPlane;
135 Int_t iBar;
136 Int_t channel = 0;
137 Int_t tdc;
138 R3BTCalModulePar* par;
139 Double_t timeLE;
140 Double_t timeTE;
141
142 for (Int_t ihit = 0; ihit < nHits; ihit++)
143 {
144 hit = dynamic_cast<R3BPaddleTamexMappedData*>(fMappedHit->At(ihit));
145 if (NULL == hit)
146 {
147 continue;
148 }
149 iPlane = hit->GetPlaneId();
150 iBar = hit->GetBarId();
151 if (hit->Is17())
152 {
153 // 17-th channel
154 continue;
155 }
156
157 for (Int_t iSide = 0; iSide < 2; iSide++)
158 {
159
160 // !!! There is the Edge missing GetModulePar( ... ) !!!
161 // Convert TDC to [ns]
162 if (!(par = fTcalPar->GetModuleParAt(iPlane, iBar, iSide)))
163 {
164 LOG(debug) << "R3BNeulandTcal::Exec : Tcal par not found, barId: " << iBar << ", side: " << iSide;
165 continue;
166 }
167
168 tdc = hit->GetFineTime(iSide, 0); // PM, edge
169 timeLE = par->GetTimeVFTX(tdc);
170
171 if (!(par = fTcalPar->GetModuleParAt(iPlane, iBar, iSide + 2)))
172 {
173 LOG(debug) << "R3BNeulandTcal::Exec : Tcal par not found, barId: " << iBar << ", side: " << iSide;
174 continue;
175 }
176
177 tdc = hit->GetFineTime(iSide, 1);
178 timeTE = par->GetTimeVFTX(tdc);
179
180 /*
181 if (timeLE < -1000.)
182 {
183 continue;
184 }
185 */
186 if (timeLE < 0. || timeLE > fClockFreq || timeTE < 0. || timeTE > fClockFreq)
187 {
188 LOG(error) << "R3BNeulandTcal::Exec : error in time calibration: ch= " << channel << ", tdc= " << tdc
189 << ", time leading edge = " << timeLE << ", time trailing edge = " << timeTE;
190 continue;
191 }
192
193 timeLE = fClockFreq - timeLE + hit->GetCoarseTime(iSide, 0) * fClockFreq;
194 timeTE = fClockFreq - timeTE + hit->GetCoarseTime(iSide, 1) * fClockFreq;
195
196 new ((*fPmt)[fNPmt]) R3BNeulandPmt(iPlane, iBar, iSide, timeLE, timeTE - timeLE);
197 fNPmt += 1;
198 } // for Side
199 }
200}
201
203{
204 if (fVerbose && 0 == (fNEvents % 1))
205 {
206 LOG(info) << "R3BNeulandTcal::Exec : event=" << fNEvents << " nPMTs=" << fNPmt;
207 }
208
209 if (fPmt)
210 {
211 fPmt->Clear();
212 fNPmt = 0;
213 }
214
215 fNEvents += 1;
216}
217
219
ClassImp(R3B::Neuland::Cal2HitPar)
An analysis task to apply TCAL calibration for NeuLAND.
virtual InitStatus Init()
Method for task initialization.
virtual void FinishEvent()
A method for finish of processing of an event.
R3BNeulandTcal()
Default constructor.
virtual ~R3BNeulandTcal()
Destructor.
virtual void SetParContainers()
Method for initialization of the parameter containers.
virtual void FinishTask()
Method for finish of the task execution.
virtual InitStatus ReInit()
Method for re-initialization of parameter containers in case the Run ID has changed.
virtual void Exec(Option_t *option)
Method for event loop implementation.
const Int_t & GetFineTime(int t, int e) const
const Int_t & GetCoarseTime(int t, int e) const