24#include "R3BTCalEngine.h"
25#include "R3BTCalPar.h"
27#include "FairLogger.h"
28#include "FairRootManager.h"
29#include "FairRunAna.h"
30#include "FairRuntimeDb.h"
32#include "TClonesArray.h"
35 : FairTask(
"LandTcal", 1)
38 , fPmt(new TClonesArray(
"R3BNeulandPmt"))
45 , fClockFreq(1. / VFTX_CLOCK_MHZ * 1000.)
50 : FairTask(name, iVerbose)
53 , fPmt(new TClonesArray(
"R3BNeulandPmt"))
60 , fClockFreq(1. / VFTX_CLOCK_MHZ * 1000.)
76 LOG(info) <<
"R3BNeulandTcal::Init : read " << fTcalPar->GetNumModulePar() <<
" calibrated modules";
79 FairRootManager* mgr = FairRootManager::Instance();
82 LOG(fatal) <<
"FairRootManager not found";
91 fMappedHit =
dynamic_cast<TClonesArray*
>(mgr->GetObject(
"NeulandMappedData"));
92 if (NULL == fMappedHit)
94 LOG(fatal) <<
"Branch NeulandMappedData not found";
97 mgr->Register(
"NeulandPmt",
"Land", fPmt, kTRUE);
104 FairRunAna* ana = FairRunAna::Instance();
105 FairRuntimeDb* rtdb = ana->GetRuntimeDb();
106 fTcalPar =
dynamic_cast<R3BTCalPar*
>(rtdb->getContainer(
"LandTCalPar"));
126 Int_t nHits = fMappedHit->GetEntriesFast();
138 R3BTCalModulePar* par;
142 for (Int_t ihit = 0; ihit < nHits; ihit++)
157 for (Int_t iSide = 0; iSide < 2; iSide++)
162 if (!(par = fTcalPar->GetModuleParAt(iPlane, iBar, iSide)))
164 LOG(debug) <<
"R3BNeulandTcal::Exec : Tcal par not found, barId: " << iBar <<
", side: " << iSide;
169 timeLE = par->GetTimeVFTX(tdc);
171 if (!(par = fTcalPar->GetModuleParAt(iPlane, iBar, iSide + 2)))
173 LOG(debug) <<
"R3BNeulandTcal::Exec : Tcal par not found, barId: " << iBar <<
", side: " << iSide;
178 timeTE = par->GetTimeVFTX(tdc);
186 if (timeLE < 0. || timeLE > fClockFreq || timeTE < 0. || timeTE > fClockFreq)
188 LOG(error) <<
"R3BNeulandTcal::Exec : error in time calibration: ch= " << channel <<
", tdc= " << tdc
189 <<
", time leading edge = " << timeLE <<
", time trailing edge = " << timeTE;
193 timeLE = fClockFreq - timeLE + hit->
GetCoarseTime(iSide, 0) * fClockFreq;
194 timeTE = fClockFreq - timeTE + hit->
GetCoarseTime(iSide, 1) * fClockFreq;
196 new ((*fPmt)[fNPmt])
R3BNeulandPmt(iPlane, iBar, iSide, timeLE, timeTE - timeLE);
204 if (fVerbose && 0 == (fNEvents % 1))
206 LOG(info) <<
"R3BNeulandTcal::Exec : event=" << fNEvents <<
" nPMTs=" << fNPmt;
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 & GetPlaneId() const
const Int_t & GetFineTime(int t, int e) const
const Int_t & GetBarId() const
const Int_t & GetCoarseTime(int t, int e) const