20#include "FairLogger.h"
21#include "FairRootManager.h"
22#include "FairRunAna.h"
23#include "FairRuntimeDb.h"
28#include "R3BTCalEngine.h"
29#include "R3BTCalPar.h"
30#include "TClonesArray.h"
34#define planes fNofPMTs / 100
35#define toID(x, y, z) (((x - 1) * 50 + (y - 1)) * 2 + (z - 1))
37Double_t
wlk(Double_t x)
41 Double_t par1 = 1500.;
42 Double_t par2 = 0.00075;
43 y = par1 * TMath::Power(x, par2) - (par1 * TMath::Power(400., par2));
52 : FairTask(
"NeulandTacquilaMapped2Cal", 1)
57 , fPmt(new TClonesArray(
"R3BNeulandCalData"))
66 , fClockFreq(1. / TACQUILA_CLOCK_MHZ * 1000.)
71 : FairTask(name, iVerbose)
76 , fPmt(new TClonesArray(
"R3BNeulandCalData"))
85 , fClockFreq(1. / TACQUILA_CLOCK_MHZ * 1000.)
101 LOG(info) <<
"R3BNeulandTacquilaMapped2Cal::Init : read " << fTcalPar->GetNumModulePar() <<
" calibrated modules";
104 FairRootManager* mgr = FairRootManager::Instance();
107 LOG(fatal) <<
"FairRootManager not found";
110 header =
dynamic_cast<R3BEventHeader*
>(mgr->GetObject(
"EventHeader."));
113 LOG(fatal) <<
"Branch R3BEventHeader not found";
116 fRawHit =
dynamic_cast<TClonesArray*
>(mgr->GetObject(
"NeulandTacquilaMappedData"));
119 LOG(fatal) <<
"Branch NeulandTacquilaMappedData not found";
122 mgr->Register(
"NeulandCalData",
"Neuland", fPmt, kTRUE);
124 fh_pulser_5_2 =
new TH1F(
"h_pulser_5_2",
"Single PMT resolution Bar 5 vs 2", 40000, -200., 200.);
125 fh_pulser_105_2 =
new TH1F(
"h_pulser_105_2",
"Single PMT resolution Bar 105 vs 2", 40000, -200., 200.);
134 FairRunAna* ana = FairRunAna::Instance();
135 FairRuntimeDb* rtdb = ana->GetRuntimeDb();
136 fTcalPar =
dynamic_cast<R3BTCalPar*
>(rtdb->getContainer(
"LandTCalPar"));
137 fQCalPar =
dynamic_cast<R3BNeulandQCalPar*
>(rtdb->getContainer(
"NeulandQCalPar"));
140void R3BNeulandTacquilaMapped2Cal::SetParameter()
143 std::map<Int_t, Double_t> tempMapQdcOffset;
145 for (Int_t plane = 1; i <=
planes; plane++)
146 for (Int_t bar = 1; bar <= 50; bar++)
147 for (Int_t side = 1; side <= 2; side++)
149 tempMapQdcOffset[i] = fQCalPar->
GetParAt(plane, bar, side);
153 LOG(info) <<
"R3BNeulandTacquilaMapped2Cal::SetParameter : Number of Parameters: " << i;
155 fMapQdcOffset = tempMapQdcOffset;
169 if (header->GetTrigger() != fTrigger)
175 Int_t nHits = fRawHit->GetEntriesFast();
178 if (nHits < fNofPMTs)
185 if (nHits > (fNofPMTs / 2))
199 Double_t time1 = nan(
"");
200 for (Int_t i = 0; i < fNPmt; i++)
209 for (Int_t i = 0; i < fNPmt; i++)
214 fh_pulser_5_2->Fill(pmt1->
GetTime() - time1);
218 fh_pulser_105_2->Fill(pmt1->
GetTime() - time1);
224void R3BNeulandTacquilaMapped2Cal::MakeCal()
226 Int_t nHits = fRawHit->GetEntriesFast();
234 R3BTCalModulePar* par;
239 for (Int_t khit = 0; khit < nHits; khit++)
251 if (!(par = fTcalPar->GetModuleParAt(iPlane, iPaddle, iSide)))
253 LOG(debug) <<
"R3BNeulandTacquilaMapped2Cal::Exec : Tcal par not found, channel: " << iPlane <<
" / "
254 << iPaddle <<
" / " << iSide;
259 time = par->GetTimeTacquila(tdc);
260 if (time < 0. || time > fClockFreq)
262 LOG(error) <<
"R3BNeulandTacquilaMapped2Cal::Exec : error in time calibration: ch=" << channel
263 <<
", tdc=" << tdc <<
", time=" << time;
267 if (!(par = fTcalPar->GetModuleParAt(iPlane, iPaddle, iSide + 2)))
269 LOG(debug) <<
"R3BNeulandTacquilaMapped2Cal::Exec : Tcal par not found, channel: " << iPlane <<
" / "
270 << iPaddle <<
" / " << (iSide + 2);
275 time2 = par->GetTimeTacquila(tdc);
276 if (time2 < 0. || time2 > fClockFreq)
278 LOG(error) <<
"R3BNeulandTacquilaMapped2Cal::Exec : error in time calibration: ch=" << channel
279 <<
", tdc=" << tdc <<
", time=" << time2;
283 qdc = hit2->
GetQdcData() - fMapQdcOffset[
toID(iPlane, iPaddle, iSide)];
284 qdc = std::max(qdc, 0);
286 time = time - time2 + hit2->
GetClock() * fClockFreq;
291 new ((*fPmt)[fNPmt]) R3BNeulandCalData((iPlane - 1) * 50 + iPaddle, iSide, time, NAN, qdc);
298 if (fVerbose && 0 == (fNEvents % 1000))
300 LOG(info) <<
"R3BNeulandTacquilaMapped2Cal::Exec : event=" << fNEvents <<
" nPMTs=" << fNPmt;
309 fMapStopTime.clear();
310 fMapStopClock.clear();
317 fh_pulser_5_2->Write();
318 fh_pulser_105_2->Write();
ClassImp(R3B::Neuland::Cal2HitPar)
Int_t GetParAt(Int_t plane, Int_t bar, Int_t side)
Method to get the pedestal offset of a PMT.
An analysis task to apply TCAL calibration for NeuLAND.
virtual void Exec(Option_t *option)
Method for event loop implementation.
virtual InitStatus ReInit()
Method for re-initialization of parameter containers in case the Run ID has changed.
virtual void FinishEvent()
A method for finish of processing of an event.
virtual void FinishTask()
Method for finish of the task execution.
virtual ~R3BNeulandTacquilaMapped2Cal()
Destructor.
virtual void SetParContainers()
Method for initialization of the parameter containers.
virtual InitStatus Init()
Method for task initialization.
R3BNeulandTacquilaMapped2Cal()
Default constructor.
UShort_t GetClock() const
UShort_t GetQdcData() const
UShort_t GetStopT() const
UShort_t GetTacData() const