15#include "FairLogger.h"
16#include "FairRootManager.h"
17#include "FairRunAna.h"
18#include "FairRuntimeDb.h"
24#include "R3BTCalEngine.h"
25#include "R3BTCalPar.h"
26#include "TClonesArray.h"
31 : FairTask(
"NeulandMapped2Cal", 1)
38 ,
fCal(new TClonesArray(
"R3BNeulandCalData"))
47 : FairTask(name, iVerbose)
54 ,
fCal(new TClonesArray(
"R3BNeulandCalData"))
78 LOG(error) <<
"There are no TCal parameters in container LandTCalPar";
82 LOG(info) <<
"R3BNeulandMapped2Cal::Init : read " <<
fNofTcalPars <<
" calibrated modules";
84 FairRootManager* mgr = FairRootManager::Instance();
87 LOG(fatal) <<
"FairRootManager not found";
93 LOG(fatal) <<
"Branch R3BEventHeader not found";
96 fMapped =
dynamic_cast<TClonesArray*
>(mgr->GetObject(
"NeulandMappedData"));
99 LOG(fatal) <<
"Branch NeulandMapped not found";
101 fMappedTrigger =
dynamic_cast<TClonesArray*
>(mgr->GetObject(
"NeulandTrigMappedData"));
104 LOG(info) <<
"Branch NeulandTrigMapped not found";
107 mgr->Register(
"NeulandCalData",
"Neuland",
fCal, kTRUE);
110 htcal1 =
new TH2F(
"htcal1",
"htcal1", 800, 0.5, 800.5, 500, -1., 6.);
111 htcal2 =
new TH2F(
"htcal2",
"htcal2", 800, 0.5, 800.5, 500, -1., 6.);
112 htcal3 =
new TH2F(
"htcal3",
"htcal3", 800, 0.5, 800.5, 500, -1., 6.);
113 htcal4 =
new TH2F(
"htcal4",
"htcal4", 800, 0.5, 800.5, 500, -1., 6.);
123 FairRuntimeDb* rtdb = FairRuntimeDb::instance();
124 R3BLOG_IF(error, !rtdb,
"FairRuntimeDb not found");
127 R3BLOG_IF(warn, !
fMapPar,
"Could not get access to neulandMappingPar container");
129 fTcalPar =
dynamic_cast<R3BTCalPar*
>(rtdb->getContainer(
"LandTCalPar"));
133 LOG(error) <<
"Could not get access to LandTCalPar-Container.";
171 Int_t nHits =
fMapped->GetEntriesFast();
197 std::vector<double> trig_map(13 *
fNofPlanes);
201 for (
int i = 0; i < nHits; ++i)
205 auto par =
fTcalPar->GetModuleParAt(100, iBar, 10);
210 auto time = par->GetTimeVFTX(mapped->fFineTime1LE);
214 nHits =
fMapped->GetEntriesFast();
216 R3BTCalModulePar* par;
222 for (Int_t ihit = 0; ihit < nHits; ihit++)
237 double trig_ns = NAN;
239 trig_ns = trig_map.at(trig_i);
249 LOG(info) <<
"R3BNeulandMapped2TCal::Exec : Plane number out of range: " << iPlane;
254 LOG(info) <<
"R3BNeulandMapped2TCal::Exec : Bar number out of range: " << iBar;
258 int edge = 2 * iSide - 1;
261 if (!(par =
fTcalPar->GetModuleParAt(iPlane, iBar, edge)))
263 LOG(debug) <<
"R3BNeulandTcal::Exec : Tcal par not found, barId: " << iBar <<
", side: " << iSide;
268 timeLE = par->GetTimeVFTX(tdc);
271 if (!(par =
fTcalPar->GetModuleParAt(iPlane, iBar, edge + 1)))
273 LOG(debug) <<
"R3BNeulandTcal::Exec : Tcal par not found, barId: " << iBar <<
", side: " << iSide;
278 timeTE = par->GetTimeVFTX(tdc);
282 LOG(error) <<
"R3BNeulandMapped2Tcal::Exec : error in time calibration: ch= " << iPlane << iBar << iSide
283 <<
", tdc= " << tdc <<
", time leading edge = " << timeLE <<
", time trailing edge = " << timeTE;
289 htcal1->Fill((iPlane - 1) * 50 + iBar, timeLE);
290 htcal2->Fill((iPlane - 1) * 50 + iBar, timeTE);
294 htcal3->Fill((iPlane - 1) * 50 + iBar, timeLE);
295 htcal4->Fill((iPlane - 1) * 50 + iBar, timeTE);
303 if (timeTE - timeLE < 0)
309 qdc = timeTE - timeLE;
317 LOG(debug2) <<
"tot: " << qdc <<
"lt: " << timeLE <<
"trigT: " << trig_ns <<
"\n";
335 if (fVerbose && 0 == (
fNEvents % 100000))
337 LOG(info) <<
"R3BNeulandMapped2Cal::Exec : event=" <<
fNEvents <<
" nPMTs=" <<
fNPmt;
364 x = x * 17.2278 / 162.464;
366 y0 = -4.29359 + 17.3841 / sqrt(x) + 0.073181;
368 y1 = 1.59667 + 78.5274 * pow(x, -1.97051) - 4.00192 / x - 0.125473 * x + 0.00130958 * x * x;
#define R3BLOG(severity, x)
#define R3BLOG_IF(severity, condition, x)
ClassImp(R3B::Neuland::Cal2HitPar)
R3BNeulandCalData()=default
An analysis task to apply TCAL calibration for NeuLAND.
virtual InitStatus ReInit()
Method for re-initialization of parameter containers in case the Run ID has changed.
virtual void FinishTask()
Method for finish of the task execution.
virtual void SetParContainers()
Method for initialization of the parameter containers.
virtual void FinishEvent()
A method for finish of processing of an event.
Double_t WalkCorrection(Double_t)
TClonesArray * fMapped
Array with raw items - input data.
Int_t fNEvents
Event counter.
Int_t fNofBarsPerPlane
Number of photomultipliers.
Int_t fNPmt
Number of produced time items per event.
Bool_t fPulserMode
Running with pulser data.
Int_t fNofPlanes
Number of photomultipliers.
Int_t fNofPMTs
Number of photomultipliers.
Double_t fClockFreq
Clock cycle in [ns].
UInt_t fNofTcalPars
Number of modules in parameter file.
R3BNeulandMapped2Cal()
Default constructor.
virtual InitStatus Init()
Method for task initialization.
R3BTCalPar * fTcalPar
TCAL parameter container.
TClonesArray * fCal
Array with time items - output data.
virtual ~R3BNeulandMapped2Cal()
Destructor.
virtual void Exec(Option_t *option)
Method for event loop implementation.
Bool_t fWalkEnabled
Enable / Disable walk correction.
Int_t fTrigger
Trigger value.
R3BNeulandMappingPar * fMapPar
R3BEventHeader * header
Event header.
TClonesArray * fMappedTrigger
Array with raw items - input data.
const Int_t GetNbPaddles()
const Int_t GetTrigMap(UInt_t plane, UInt_t paddle, UInt_t pmt)
const Int_t GetNbPlanes()
Accessor functions.
const Int_t & GetPlaneId() const
const Int_t & GetBarId() const