22#include <fairlogger/Logger.h>
30 const int nMass = 150.;
31 const float massMax = 0.3;
32 for (
int mod = 0; mod < 4; mod++) {
33 mReMi[2 * mod] = boost::histogram::make_histogram(boost::histogram::axis::regular<>(nMass, 0., massMax,
"mgg"));
34 mReMi[2 * mod + 1] = boost::histogram::make_histogram(boost::histogram::axis::regular<>(nMass, 0., massMax,
"mgg"));
40 mUseCCDB =
other.mUseCCDB;
41 mRunStartTime =
other.mRunStartTime;
42 mCCDBPath =
other.mCCDBPath;
43 const int nMass = 150.;
44 const float massMax = 0.3;
45 for (
int mod = 0; mod < 4; mod++) {
46 mReMi[2 * mod] = boost::histogram::make_histogram(boost::histogram::axis::regular<>(nMass, 0., massMax,
"mgg"));
47 mReMi[2 * mod + 1] = boost::histogram::make_histogram(boost::histogram::axis::regular<>(nMass, 0., massMax,
"mgg"));
57 for (
int mod = 0; mod < 4; mod++) {
58 s[mod] = boost::histogram::algorithm::sum(mReMi[2 * mod]);
60 LOG(info) <<
"Total number of entries in pi0 region: " << s[0] <<
"," << s[1] <<
"," << s[2] <<
"," << s[3];
67 LOG(info) <<
"Retrieving BadMap from CCDB";
71 mBadMap = std::make_unique<o2::phos::BadChannelsMap>(*(ccdbManager.get<
o2::phos::BadChannelsMap>(
"PHS/Calib/BadMap")));
74 LOG(fatal) <<
"Can not read BadMap from CCDB, you may use --not-use-ccdb option to create default bad map";
77 LOG(info) <<
"Do not use CCDB, create default BadMap";
82 for (
auto& tr : trs) {
84 int firstCluInEvent = tr.getFirstEntry();
85 int lastCluInEvent = firstCluInEvent + tr.getNumberOfObjects();
88 TVector3
vertex = {0., 0., 0.};
89 mBuffer->startNewEvent();
90 for (
int i = firstCluInEvent;
i < lastCluInEvent;
i++) {
93 if (!checkCluster(
clu)) {
103 vec3 *= 1. / vec3.Mag();
104 TLorentzVector
v(vec3.X() * e, vec3.Y() * e, vec3.Z() * e, e);
105 for (
short ip = mBuffer->size(); ip--;) {
106 const TLorentzVector& vp = mBuffer->getEntry(ip);
107 TLorentzVector
sum =
v + vp;
108 if (
sum.Pt() > mPtCut) {
109 if (mBuffer->isCurrentEvent(ip)) {
116 mBuffer->addEntry(
v);
124bool PHOSRunbyrunSlot::checkCluster(
const Cluster&
clu)
134 if (!mBadMap->isChannelGood(absId)) {
141 for (
int mod = 0; mod < 8; mod++) {
150 const int nMass = 150.;
151 const float massMax = 0.3;
152 for (
int mod = 0; mod < 4; mod++) {
153 mReMi[2 * mod] =
new TH1F(Form(
"hReInvMassMod%d", mod),
"Real inv. mass per module", nMass, 0., massMax);
154 mReMi[2 * mod + 1] =
new TH1F(Form(
"hMiInvMassMod%d", mod),
"Mixed inv. mass per module", nMass, 0., massMax);
159 for (
int mod = 0; mod < 8; mod++) {
161 mReMi[mod]->Delete();
162 mReMi[mod] =
nullptr;
182 for (
int mod = 0; mod < 8; mod++) {
185 for (
auto&&
x : boost::histogram::indexed(tmp)) {
186 mReMi[mod]->SetBinContent(indx,
x.get() + mReMi[mod]->GetBinContent(indx));
197 auto& slot = front ? cont.emplace_front(tstart, tend) : cont.emplace_back(tstart, tend);
198 slot.setContainer(std::make_unique<PHOSRunbyrunSlot>(mUseCCDB, mCCDBPath));
207 slotTF.getContainer()->setRunStartTime(
tf);
208 slotTF.getContainer()->fill(
clu, tr);
221 for (
int mod = 0; mod < 4; mod++) {
222 mReMi[2 * mod]->Sumw2();
223 mReMi[2 * mod + 1]->Sumw2();
224 TH1D* tmp = (TH1D*)mReMi[2 * mod]->Clone(
"Ratio");
225 tmp->Divide(mReMi[2 * mod + 1]);
226 fRatio.SetParameters(1., 0.134, 0.005, 0.01, 0., 0.);
227 tmp->Fit(&fRatio,
"q",
"", 0.07, 0.22);
228 fBg.SetParameters(fRatio.GetParameter(3), fRatio.GetParameter(4), fRatio.GetParameter(5));
229 mReMi[2 * mod + 1]->Multiply(&fBg);
231 fSignal.SetParameters(0.3 * mReMi[2 * mod]->Integral(65, 67,
""), 0.135, 0.005);
232 mReMi[2 * mod]->Fit(&fSignal,
"q",
"", 0.07, 0.22);
233 mRunByRun[2 * mod] = fSignal.GetParameter(1);
234 mRunByRun[2 * mod + 1] = fSignal.GetParError(1);
236 mReMi[2 * mod]->Write();
237 mReMi[2 * mod + 1]->Write();
240 mReMi[2 * mod]->Reset();
241 mReMi[2 * mod + 1]->Reset();
244 LOG(info) <<
"Wrote Run-by-run calibration histos";
250 const double n = 4.1983;
251 const double a = 1.5;
252 const double A = TMath::Power((
n / TMath::Abs(
a)),
n) * TMath::Exp(-
a *
a / 2);
253 const double B =
n / TMath::Abs(
a) - TMath::Abs(
a);
254 double dx = (
x[0] -
m) / s;
256 return par[0] *
exp(-dx * dx / 2.) +
257 par[3] + par[4] *
x[0] + par[5] *
x[0] *
x[0];
259 return par[0] *
A * TMath::Power((
B - dx), -
n) +
260 par[3] + par[4] *
x[0] + par[5] *
x[0] *
x[0];
267 const double n = 4.1983;
268 const double a = 1.5;
269 const double A = TMath::Power((
n / TMath::Abs(
a)),
n) * TMath::Exp(-
a *
a / 2);
270 const double B =
n / TMath::Abs(
a) - TMath::Abs(
a);
271 double dx = (
x[0] -
m) / s;
273 return par[0] *
exp(-dx * dx / 2.) + par[3];
275 return par[0] *
A * TMath::Power((
B - dx), -
n) + par[3];
280 return par[0] + par[1] *
x[0] + par[2] *
x[0] *
x[0];
uint64_t exp(uint64_t base, uint8_t exp) noexcept
static std::string getCCDBServer()
o2::calibration::TFType TFType
Slot & getSlotForTF(TFType tf)
const Container * getContainer() const
TFType getTFStart() const
static BasicCCDBManager & instance()
CCDB container for bad (masked) channels in PHOS.
Contains PHOS cluster parameters.
int getMultiplicity() const
void getLocalPosition(float &posX, float &posZ) const
static void relPosToAbsId(char module, float x, float z, short &absId)
void local2Global(char module, float x, float z, TVector3 &globaPos) const
static Geometry * GetInstance()
double CBSignal(double *x, double *p)
~PHOSRunbyrunCalibrator() final
bool process(TFType tf, const gsl::span< const Cluster > &clu, const gsl::span< const TriggerRecord > &trs)
bool hasEnoughData(const Slot &slot) const final
double CBRatio(double *x, double *p)
double bg(double *x, double *p)
void finalizeSlot(Slot &slot) final
Slot & emplaceNewSlot(bool front, TFType tstart, TFType tend) final
void fill(const gsl::span< const Cluster > &clusters, const gsl::span< const TriggerRecord > &trs)
void merge(const PHOSRunbyrunSlot *prev)
boost::histogram::histogram< std::tuple< boost::histogram::axis::regular< double, boost::use_default, boost::use_default, boost::use_default > >, boost::histogram::unlimited_storage< std::allocator< char > > > boostHisto
PHOSRunbyrunSlot(bool useCCDB, std::string path)
float sum(float s, o2::dcs::DataPointValue v)
GLsizei const GLchar *const * path
GLboolean GLboolean GLboolean GLboolean a
std::unique_ptr< GPUReconstructionTimeframe > tf
VectorOfTObjectPtrs other
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< Cluster > clusters