Skip to content

Commit 3d96f4d

Browse files
Dmitri Peresunkoshahor02
authored andcommitted
L1phase calib summary histo added; warning fixes
1 parent 308aea7 commit 3d96f4d

10 files changed

Lines changed: 133 additions & 37 deletions

Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSEnergyCalibrator.h

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class PHOSEnergySlot
7777
const std::vector<uint32_t>& getCollectedDigits() const { return mDigits; }
7878

7979
void setRunStartTime(long tf) { mRunStartTime = tf; }
80+
void setFillDigitsTree(bool toFill) { mFillDigitsTree = toFill; }
8081
void setCalibration(const CalibParams* c) { mCalibParams = c; }
8182
void setBadMap(const BadChannelsMap* map) { mBadMap = map; }
8283
void setCuts(float ptMin, float eminHGTime, float eminLGTime, float eDigMin, float eCluMin)
@@ -91,6 +92,7 @@ class PHOSEnergySlot
9192
private:
9293
void fillTimeMassHisto(const Cluster& clu, const gsl::span<const CluElement>& cluelements);
9394
bool checkCluster(const Cluster& clu);
95+
float Nonlinearity(float en);
9496

9597
long mRunStartTime = 0; /// start time of the run (sec)
9698
std::unique_ptr<RingBuffer> mBuffer; /// Buffer for current and previous events
@@ -101,11 +103,12 @@ class PHOSEnergySlot
101103
uint32_t mEvBC = 0;
102104
uint32_t mEvOrbit = 0;
103105
uint32_t mEvent = 0;
104-
float mPtMin = 2.; /// minimal pi0 pt to fill inv. mass histo
105-
float mEminHGTime = 2.; /// minimal cell energy to fill HG time histo
106-
float mEminLGTime = 6.; /// minimal cell energy to fill LG time histo
107-
float mDigitEmin = 0.005; /// minimal energy of stored digits
108-
float mClusterEmin = 0.4; /// minimal energy of cluster which digits will be stored
106+
float mPtMin = 2.; /// minimal pi0 pt to fill inv. mass histo
107+
float mEminHGTime = 2.; /// minimal cell energy to fill HG time histo
108+
float mEminLGTime = 6.; /// minimal cell energy to fill LG time histo
109+
float mDigitEmin = 0.005; /// minimal energy of stored digits
110+
float mClusterEmin = 0.4; /// minimal energy of cluster which digits will be stored
111+
bool mFillDigitsTree = false;
109112
std::vector<uint32_t> mDigits; /// list of calibration digits
110113
};
111114

@@ -125,6 +128,7 @@ class PHOSEnergyCalibrator final : public o2::calibration::TimeSlotCalibration<o
125128
void endOfStream();
126129

127130
const ETCalibHistos* getCollectedHistos() const { return mHistos.get(); }
131+
void setFillDigitsTree(bool toFill) { mFillDigitsTree = toFill; }
128132
void setCalibration(const CalibParams* c) { mCalibParams = c; }
129133
void setBadMap(const BadChannelsMap* map) { mBadMap = map; }
130134
void setCuts(float ptMin, float eminHGTime, float eminLGTime, float eDigMin, float eCluMin)
@@ -148,7 +152,8 @@ class PHOSEnergyCalibrator final : public o2::calibration::TimeSlotCalibration<o
148152
float mClusterEmin = 0.4; /// minimal energy of cluster which digits will be stored
149153
const CalibParams* mCalibParams = nullptr; /// Current calibration object
150154
const BadChannelsMap* mBadMap = nullptr; /// Current BadMap
151-
std::unique_ptr<ETCalibHistos> mHistos; /// final histograms
155+
bool mFillDigitsTree = false;
156+
std::unique_ptr<ETCalibHistos> mHistos; /// final histograms
152157
};
153158

154159
} // namespace phos

Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSL1phaseCalibDevice.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class PHOSL1phaseCalibDevice
4545
}
4646

4747
private:
48-
long mRunStartTime = 0; /// start time of the run (ms)
48+
unsigned long mRunStartTime = 0; /// start time of the run (ms)
4949
std::unique_ptr<o2::phos::PHOSL1phaseCalibrator> mCalibrator; /// Agregator of calibration TimeFrameSlots
5050
std::shared_ptr<o2::base::GRPGeomRequest> mCCDBRequest;
5151
};

Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSL1phaseCalibrator.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class PHOSL1phaseSlot
4545
void clear();
4646

4747
void addMeanRms(std::array<std::array<float, 4>, 14>& sumMean, std::array<std::array<float, 4>, 14>& sumRMS, std::array<float, 14>& sumNorm);
48+
void addQcHistos(std::array<unsigned int, 1400> (&sum)[4]);
4849

4950
void setRunStartTime(long tf) { mRunStartTime = tf; }
5051

@@ -57,9 +58,10 @@ class PHOSL1phaseSlot
5758
std::array<std::array<float, 4>, mDDL> mRMS; /// Collected RMS
5859
std::array<std::array<float, 4>, mDDL> mMean; /// Collected RMS
5960
std::array<float, mDDL> mNorm; /// Normalization
60-
BadChannelsMap* mBadMap = nullptr; /// Latest bad channels map owned by CCDB manager
61-
CalibParams* mCalibParams = nullptr; /// Calibration parameters owned by CCDB manager
62-
ClassDefNV(PHOSL1phaseSlot, 1);
61+
std::array<unsigned int, 1400> mQcHisto[4]; //! Histograms for QC
62+
BadChannelsMap* mBadMap = nullptr; //! Latest bad channels map owned by CCDB manager
63+
CalibParams* mCalibParams = nullptr; //! Calibration parameters owned by CCDB manager
64+
ClassDefNV(PHOSL1phaseSlot, 2);
6365
};
6466

6567
//==========================================================================================
@@ -79,6 +81,7 @@ class PHOSL1phaseCalibrator final : public o2::calibration::TimeSlotCalibration<
7981
void endOfStream();
8082

8183
int getCalibration() { return mL1phase; }
84+
std::array<unsigned int, 1400>& getQcHistos() { return mQcHisto[0]; }
8285

8386
private:
8487
static constexpr int mDDL = 14; /// Number of PHOS DDLs
@@ -87,8 +90,9 @@ class PHOSL1phaseCalibrator final : public o2::calibration::TimeSlotCalibration<
8790
std::array<std::array<float, 4>, mDDL> mMean; /// Collected RMS
8891
std::array<float, mDDL> mNorm; /// Normalization
8992
int mL1phase = 0; /// Final calibration
93+
std::array<unsigned int, 1400> mQcHisto[4]; ///! Histograms for QC
9094

91-
ClassDefOverride(PHOSL1phaseCalibrator, 1);
95+
ClassDefOverride(PHOSL1phaseCalibrator, 2);
9296
};
9397

9498
} // namespace phos

Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSRunbyrunCalibDevice.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class PHOSRunbyrunCalibDevice
5555
bool mWriteRootOutput = true; /// Write local root files
5656
std::string mOutputDir; /// where to write calibration digits
5757
std::string mMetaFileDir; /// where to store meta files
58-
long mRunStartTime = 0; /// start time of the run (ms)
58+
unsigned long mRunStartTime = 0; /// start time of the run (ms)
5959
std::array<float, 8> mRunByRun; /// Final calibration object
6060
std::unique_ptr<PHOSRunbyrunCalibrator> mCalibrator; /// Agregator of calibration TimeFrameSlots
6161
std::shared_ptr<o2::base::GRPGeomRequest> mCCDBRequest;

Detectors/PHOS/calib/include/PHOSCalibWorkflow/PHOSTurnonCalibDevice.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class PHOSTurnonCalibDevice : public o2::framework::Task
5252

5353
private:
5454
bool mUseCCDB = false;
55-
long mRunStartTime = 0; /// start time of the run (ms)
55+
unsigned long mRunStartTime = 0; /// start time of the run (ms)
5656
std::unique_ptr<TriggerMap> mTriggerMap; /// Final calibration object
5757
std::unique_ptr<PHOSTurnonCalibrator> mCalibrator; /// Agregator of calibration TimeFrameSlots
5858
std::shared_ptr<o2::base::GRPGeomRequest> mCCDBRequest;

Detectors/PHOS/calib/src/PHOSEnergyCalibDevice.cxx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,19 @@ void PHOSEnergyCalibDevice::init(o2::framework::InitContext& ic)
4040

4141
LOG(info) << "Energy calibration options";
4242
LOG(info) << " output-dif=" << mOutputDir;
43+
bool toFillDigits = mOutputDir.compare("/dev/null");
44+
if (toFillDigits) {
45+
LOG(info) << " Digits tree will be created";
46+
} else {
47+
LOG(info) << " Digits tree will NOT be created";
48+
}
4349
LOG(info) << " meta-output-dir=" << mMetaFileDir;
4450
LOG(info) << " mgg histo ptMin=" << mPtMin;
4551
LOG(info) << " Emin for HG time=" << mEminHGTime;
4652
LOG(info) << " Emin for LG time=" << mEminLGTime;
4753
LOG(info) << " Emin for out digits=" << mEDigMin;
4854
LOG(info) << " Cluster Emin for out digits=" << mECluMin;
55+
4956
LOG(info) << " Root output dir=" << mOutputDir;
5057

5158
mCalibrator = std::make_unique<PHOSEnergyCalibrator>();
@@ -60,6 +67,7 @@ void PHOSEnergyCalibDevice::init(o2::framework::InitContext& ic)
6067
mHasCalib = true;
6168
}
6269
mCalibrator->setCuts(mPtMin, mEminHGTime, mEminLGTime, mEminHGTime, mEminLGTime);
70+
mCalibrator->setFillDigitsTree(toFillDigits);
6371
mCalibrator->setUpdateAtTheEndOfRunOnly();
6472

6573
// Create geometry instance (inclusing reading mis-alignement)
@@ -165,7 +173,7 @@ void PHOSEnergyCalibDevice::fillOutputTree()
165173
if (!br) {
166174
br = mTreeOut->Branch("PHOSCalib", &mOutputDigits);
167175
}
168-
int abits = mTreeOut->Fill();
176+
mTreeOut->Fill();
169177
}
170178

171179
void PHOSEnergyCalibDevice::writeOutFile()

Detectors/PHOS/calib/src/PHOSEnergyCalibrator.cxx

Lines changed: 61 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ PHOSEnergySlot::PHOSEnergySlot(const PHOSEnergySlot& other)
3636
mPtMin = other.mPtMin;
3737
mEminHGTime = other.mEminHGTime;
3838
mEminLGTime = other.mEminLGTime;
39+
mFillDigitsTree = other.mFillDigitsTree;
3940
mDigits.clear();
4041
mHistos = std::make_unique<ETCalibHistos>();
4142
}
@@ -50,15 +51,20 @@ void PHOSEnergySlot::fill(const gsl::span<const Cluster>& clusters, const gsl::s
5051
// Scan current list of clusters
5152
// Fill time, non-linearity and mgg histograms
5253
// Fill list of re-calibraiable digits
53-
mDigits.clear();
54+
if (mFillDigitsTree) {
55+
mDigits.clear();
56+
}
5457
for (auto& tr : cluTR) {
55-
// Mark new event
56-
// First goes new event marker + BC (16 bit), next word orbit (32 bit)
57-
EventHeader h = {0};
58-
h.mMarker = 16383;
59-
h.mBC = tr.getBCData().bc;
60-
mDigits.push_back(h.mDataWord);
61-
mDigits.push_back(tr.getBCData().orbit);
58+
59+
if (mFillDigitsTree) {
60+
// Mark new event
61+
// First goes new event marker + BC (16 bit), next word orbit (32 bit)
62+
EventHeader h = {0};
63+
h.mMarker = 16383;
64+
h.mBC = tr.getBCData().bc;
65+
mDigits.push_back(h.mDataWord);
66+
mDigits.push_back(tr.getBCData().orbit);
67+
}
6268
mEvBC = tr.getBCData().bc;
6369

6470
int firstCluInEvent = tr.getFirstEntry();
@@ -87,6 +93,10 @@ void PHOSEnergySlot::fill(const gsl::span<const Cluster>& clusters, const gsl::s
8793
}
8894
fillTimeMassHisto(clu, cluelements);
8995

96+
if (!mFillDigitsTree) {
97+
continue;
98+
}
99+
90100
uint32_t firstCE = clu.getFirstCluEl();
91101
uint32_t lastCE = clu.getLastCluEl();
92102
for (uint32_t idig = firstCE; idig < lastCE; idig++) {
@@ -127,9 +137,15 @@ void PHOSEnergySlot::fillTimeMassHisto(const Cluster& clu, const gsl::span<const
127137
uint32_t firstCE = clu.getFirstCluEl();
128138
uint32_t lastCE = clu.getLastCluEl();
129139

140+
short absIdMax = 0;
141+
float maxE = 0.;
130142
for (uint32_t idig = firstCE; idig < lastCE; idig++) {
131143
const CluElement& ce = cluelements[idig];
132144
short absId = ce.absId;
145+
if (ce.energy > maxE) {
146+
maxE = ce.energy;
147+
absIdMax = absId;
148+
}
133149
if (ce.isHG) {
134150
if (ce.energy > mEminHGTime) {
135151
mHistos->fill(ETCalibHistos::kTimeHGPerCell, absId, ce.time);
@@ -155,14 +171,21 @@ void PHOSEnergySlot::fillTimeMassHisto(const Cluster& clu, const gsl::span<const
155171
// prepare TLorentsVector
156172
float posX, posZ;
157173
clu.getLocalPosition(posX, posZ);
174+
175+
// Correction for the depth of the shower starting point (TDR p 127)
176+
const float para = 0.925;
177+
const float parb = 6.52;
178+
float depth = para * TMath::Log(clu.getEnergy()) + parb;
179+
posX -= posX * depth / 460.;
180+
posZ -= posZ * depth / 460.;
181+
158182
TVector3 vec3;
159183
mGeom->local2Global(clu.module(), posX, posZ, vec3);
160-
float e = clu.getEnergy();
161-
short absId;
162-
mGeom->relPosToAbsId(clu.module(), posX, posZ, absId);
163-
164-
vec3 *= 1. / vec3.Mag();
165-
TLorentzVector v(vec3.X() * e, vec3.Y() * e, vec3.Z() * e, e);
184+
// float e = clu.getEnergy();
185+
float e = Nonlinearity(clu.getCoreEnergy());
186+
// Non-perp inc., nonlin
187+
vec3 *= e / vec3.Mag();
188+
TLorentzVector v(vec3.X(), vec3.Y(), vec3.Z(), e);
166189
// Fill calibration histograms for all cells, even bad, but partners in inv, mass should be good
167190
bool isGood = checkCluster(clu);
168191
for (short ip = mBuffer->size(); ip--;) {
@@ -173,20 +196,20 @@ void PHOSEnergySlot::fillTimeMassHisto(const Cluster& clu, const gsl::span<const
173196
mHistos->fill(ETCalibHistos::kReInvMassNonlin, e, sum.M());
174197
}
175198
if (sum.Pt() > mPtMin) {
176-
mHistos->fill(ETCalibHistos::kReInvMassPerCell, absId, sum.M());
199+
mHistos->fill(ETCalibHistos::kReInvMassPerCell, absIdMax, sum.M());
177200
}
178201
} else { // Mixed
179202
if (isGood) {
180203
mHistos->fill(ETCalibHistos::kMiInvMassNonlin, e, sum.M());
181204
}
182205
if (sum.Pt() > mPtMin) {
183-
mHistos->fill(ETCalibHistos::kMiInvMassPerCell, absId, sum.M());
206+
mHistos->fill(ETCalibHistos::kMiInvMassPerCell, absIdMax, sum.M());
184207
}
185208
}
186209
}
187210

188211
// Add to list ot partners only if cluster is good
189-
if (isGood) {
212+
if (isGood && e > 0.2) {
190213
mBuffer->addEntry(v);
191214
}
192215
}
@@ -204,6 +227,22 @@ bool PHOSEnergySlot::checkCluster(const Cluster& clu)
204227

205228
return (clu.getEnergy() > 0.3 && clu.getMultiplicity() > 1);
206229
}
230+
float PHOSEnergySlot::Nonlinearity(float en)
231+
{
232+
// Correct for non-linearity
233+
const double a = 9.34913e-01;
234+
const double b = 2.33e-03;
235+
const double c = -8.10e-05;
236+
const double d = 3.2e-02;
237+
const double f = -8.0e-03;
238+
const double g = 1.e-01;
239+
const double h = 2.e-01;
240+
const double k = -1.48e-04;
241+
const double l = 0.194;
242+
const double m = 0.0025;
243+
244+
return en * (a + b * en + c * en * en + d / en + f / ((en - g) * (en - g) + h) + k / ((en - l) * (en - l) + m));
245+
}
207246

208247
//==================================================
209248

@@ -229,6 +268,7 @@ Slot& PHOSEnergyCalibrator::emplaceNewSlot(bool front, TFType tstart, TFType ten
229268
auto& cont = getSlots();
230269
auto& slot = front ? cont.emplace_front(tstart, tend) : cont.emplace_back(tstart, tend);
231270
slot.setContainer(std::make_unique<es>());
271+
slot.getContainer()->setFillDigitsTree(mFillDigitsTree);
232272
slot.getContainer()->setBadMap(mBadMap);
233273
slot.getContainer()->setCalibration(mCalibParams);
234274
slot.getContainer()->setCuts(mPtMin, mEminHGTime, mEminLGTime, mDigitEmin, mClusterEmin);
@@ -246,8 +286,10 @@ bool PHOSEnergyCalibrator::process(uint64_t tf, const gsl::span<const Cluster>&
246286
slotTF.getContainer()->setRunStartTime(tf);
247287
slotTF.getContainer()->fill(clusters, cluelements, cluTR);
248288
// Add collected Digits
249-
auto tmpD = slotTF.getContainer()->getCollectedDigits();
250-
outputDigits.insert(outputDigits.end(), tmpD.begin(), tmpD.end());
289+
if (mFillDigitsTree) {
290+
auto tmpD = slotTF.getContainer()->getCollectedDigits();
291+
outputDigits.insert(outputDigits.end(), tmpD.begin(), tmpD.end());
292+
}
251293
return true;
252294
}
253295

Detectors/PHOS/calib/src/PHOSL1phaseCalibDevice.cxx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ void PHOSL1phaseCalibDevice::endOfStream(o2::framework::EndOfStreamContext& ec)
5050

5151
std::vector<int> l1phase{mCalibrator->getCalibration()};
5252
LOG(info) << "End of stream reached, sending output to CCDB";
53-
//prepare all info to be sent to CCDB
53+
// prepare all info to be sent to CCDB
5454
auto flName = o2::ccdb::CcdbApi::generateFileName("L1phase");
5555
std::map<std::string, std::string> md;
5656
o2::ccdb::CcdbObjectInfo info("PHS/Calib/L1phase", "L1phase", flName, md, mRunStartTime - o2::ccdb::CcdbObjectInfo::MINUTE,
@@ -65,6 +65,9 @@ void PHOSL1phaseCalibDevice::endOfStream(o2::framework::EndOfStreamContext& ec)
6565

6666
ec.outputs().snapshot(Output{o2::calibration::Utils::gDataOriginCDBPayload, "PHOS_L1phase", 0}, *image.get());
6767
ec.outputs().snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, "PHOS_L1phase", 0}, info);
68+
// Send summary to QC
69+
LOG(info) << "Sending histos to QC ";
70+
ec.outputs().snapshot(o2::framework::Output{"PHS", "L1PHASEHISTO", 0, o2::framework::Lifetime::Sporadic}, mCalibrator->getQcHistos());
6871
}
6972

7073
o2::framework::DataProcessorSpec o2::phos::getPHOSL1phaseCalibDeviceSpec()
@@ -73,6 +76,7 @@ o2::framework::DataProcessorSpec o2::phos::getPHOSL1phaseCalibDeviceSpec()
7376
std::vector<OutputSpec> outputs;
7477
outputs.emplace_back(o2::calibration::Utils::gDataOriginCDBPayload, "PHOS_L1phase", 0, Lifetime::Sporadic);
7578
outputs.emplace_back(o2::calibration::Utils::gDataOriginCDBWrapper, "PHOS_L1phase", 0, Lifetime::Sporadic);
79+
outputs.emplace_back(o2::header::gDataOriginPHS, "L1PHASEHISTO", 0, o2::framework::Lifetime::Sporadic);
7680

7781
std::vector<InputSpec> inputs;
7882
inputs.emplace_back("cells", "PHS", "CELLS");

0 commit comments

Comments
 (0)