Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Cluster
void setDispersion(float d) { mDispersion = d; }

float getDistanceToBadChannel() const { return mDistToBadChannel; }
void getElipsAxis(float lambdaShort, float lambdaLong) const
void getElipsAxis(float& lambdaShort, float& lambdaLong) const
{
lambdaShort = mLambdaShort;
lambdaLong = mLambdaLong;
Expand Down
6 changes: 3 additions & 3 deletions Detectors/PHOS/calib/src/PHOSBadMapCalibDevice.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,13 @@ void PHOSBadMapCalibDevice::sendOutput(DataAllocator& output)
std::string flName = o2::ccdb::CcdbApi::generateFileName("BadMap");
std::string kind;
if (mMode == 0) { // Occupancy
kind = "PHS/Calib/BadMapOcc";
kind = "PHS/BadMap/Occ";
}
if (mMode == 1) { // Chi2
kind = "PHS/Calib/BadMapChi";
kind = "PHS/BadMap/Chi";
}
if (mMode == 2) { // Pedestals
kind = "PHS/Calib/BadMapPed";
kind = "PHS/BadMap/Ped";
}
std::map<std::string, std::string> md;
o2::ccdb::CcdbObjectInfo info(kind, "BadMap", flName, md, mRunStartTime, mValidityTime);
Expand Down
3 changes: 2 additions & 1 deletion Detectors/PHOS/calib/src/PHOSHGLGRatioCalibDevice.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ void PHOSHGLGRatioCalibDevice::run(o2::framework::ProcessingContext& ctx)

// scan Cells stream, collect HG/LG pairs
if (mRunStartTime == 0) {
mRunStartTime = o2::header::get<o2::framework::DataProcessingHeader*>(ctx.inputs().get("cellTriggerRecords").header)->startTime;
const auto ref = ctx.inputs().getFirstValid(true);
mRunStartTime = DataRefUtils::getHeader<DataProcessingHeader*>(ref)->creation; // approximate time in ms
}

if (mStatistics <= 0) { // skip the rest of the run
Expand Down
28 changes: 25 additions & 3 deletions Detectors/PHOS/calib/src/PHOSPedestalCalibDevice.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ void PHOSPedestalCalibDevice::init(o2::framework::InitContext& ic)
{

mStatistics = ic.options().get<int>("statistics"); // desired number of events

LOG(info) << "PHOS pedestal init: will collect " << mStatistics << " events";
LOG(info) << "mUseCCDB (try to get current object) = " << mUseCCDB;
LOG(info) << "mForceUpdate (update CCDB anyway) =" << mForceUpdate;
// Create histograms for mean and RMS
short n = o2::phos::Mapping::NCHANNELS - 1792;
mMeanHG.reset(new TH2F("MeanHighGain", "MeanHighGain", n, 1792.5, n + 1792.5, 100, 0., 100.));
Expand All @@ -43,14 +45,19 @@ void PHOSPedestalCalibDevice::init(o2::framework::InitContext& ic)

void PHOSPedestalCalibDevice::run(o2::framework::ProcessingContext& ctx)
{
// scan Cells stream, collect mean and RMS then calculateaverage and post
// scan Cells stream, collect mean and RMS then calculate average and post

if (mRunStartTime == 0) {
mRunStartTime = o2::header::get<o2::framework::DataProcessingHeader*>(ctx.inputs().get("cellTriggerRecords").header)->startTime;
const auto ref = ctx.inputs().getFirstValid(true);
mRunStartTime = DataRefUtils::getHeader<DataProcessingHeader*>(ref)->creation; // approximate time in ms
}

if (mStatistics <= 0) { // skip the rest of the run
return;
}
if (mStatistics % 100 == 0) {
LOG(info) << mStatistics << " left to produce calibration";
}
auto cells = ctx.inputs().get<gsl::span<o2::phos::Cell>>("cells");
LOG(debug) << "[PHOSPedestalCalibDevice - run] Received " << cells.size() << " cells, running calibration ...";
auto cellsTR = ctx.inputs().get<gsl::span<o2::phos::TriggerRecord>>("cellTriggerRecords");
Expand All @@ -70,6 +77,7 @@ void PHOSPedestalCalibDevice::run(o2::framework::ProcessingContext& ctx)
--mStatistics;
}
if (mStatistics <= 0) {
LOG(info) << "Start calculating pedestals";
calculatePedestals();
checkPedestals();
sendOutput(ctx.outputs());
Expand Down Expand Up @@ -107,6 +115,19 @@ void PHOSPedestalCalibDevice::sendOutput(DataAllocator& output)
header::DataHeader::SubSpecificationType subSpec{(header::DataHeader::SubSpecificationType)0};
output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBPayload, "PHOS_Pedestal", subSpec}, *image.get());
output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, "PHOS_Pedestal", subSpec}, info);
// Now same for DCS as vector
std::vector<short> dcsPedestals(2 * (o2::phos::Mapping::NCHANNELS - 1792));
// copy HG then LG pedestals
for (short absId = 1793; absId <= o2::phos::Mapping::NCHANNELS; absId++) {
dcsPedestals.emplace_back(mPedestals->getHGPedestal(absId));
}
for (short absId = 1793; absId <= o2::phos::Mapping::NCHANNELS; absId++) {
dcsPedestals.emplace_back(mPedestals->getLGPedestal(absId));
}
auto imageDCS = o2::ccdb::CcdbApi::createObjectImage(&dcsPedestals, &info);
header::DataHeader::SubSpecificationType subSpec1{(header::DataHeader::SubSpecificationType)1};
output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBPayload, "PHOS_Pedestal", subSpec1}, *imageDCS.get());
output.snapshot(Output{o2::calibration::Utils::gDataOriginCDBWrapper, "PHOS_Pedestal", subSpec1}, info);
}
// Anyway send change to QC
LOG(info) << "[PHOSPedestalCalibDevice - run] Sending QC ";
Expand Down Expand Up @@ -137,6 +158,7 @@ void PHOSPedestalCalibDevice::calculatePedestals()
mPedestals->setLGRMS(cellId, a);
pr->Delete();
}
LOG(info) << "Pedestals calculated";
}

void PHOSPedestalCalibDevice::checkPedestals()
Expand Down
8 changes: 6 additions & 2 deletions Detectors/PHOS/calib/src/PHOSRunbyrunCalibDevice.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ void PHOSRunbyrunCalibDevice::init(o2::framework::InitContext& ic)
}
void PHOSRunbyrunCalibDevice::run(o2::framework::ProcessingContext& pc)
{
if (mRunStartTime == 0) {
const auto ref = pc.inputs().getFirstValid(true);
mRunStartTime = DataRefUtils::getHeader<DataProcessingHeader*>(ref)->creation; // approximate time in ms
}
auto tfcounter = o2::header::get<o2::framework::DataProcessingHeader*>(pc.inputs().get("clusters").header)->startTime; // is this the timestamp of the current TF?
auto clusters = pc.inputs().get<gsl::span<Cluster>>("clusters");
auto cluTR = pc.inputs().get<gsl::span<TriggerRecord>>("cluTR");
Expand Down Expand Up @@ -68,10 +72,10 @@ void PHOSRunbyrunCalibDevice::endOfStream(o2::framework::EndOfStreamContext& ec)
<< mRunByRun[4] << "+-" << mRunByRun[5] << ", "
<< mRunByRun[6] << "+-" << mRunByRun[7];
}
//TODO! Send mRunByRun for QC and trending plots
// TODO! Send mRunByRun for QC and trending plots
//

//Get ready for next run
// Get ready for next run
mCalibrator->initOutput(); // reset the outputs once they are already sent
}
bool PHOSRunbyrunCalibDevice::checkFitResult()
Expand Down
4 changes: 2 additions & 2 deletions Detectors/PHOS/calib/src/PHOSRunbyrunCalibrator.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void PHOSRunbyrunSlot::fill(const gsl::span<const Cluster>& clusters, const gsl:
auto& ccdbManager = o2::ccdb::BasicCCDBManager::instance();
ccdbManager.setURL(o2::base::NameConf::getCCDBServer());
LOG(info) << " set-up CCDB " << o2::base::NameConf::getCCDBServer();
mBadMap = std::make_unique<o2::phos::BadChannelsMap>(*(ccdbManager.get<o2::phos::BadChannelsMap>("PHS/BadMap")));
mBadMap = std::make_unique<o2::phos::BadChannelsMap>(*(ccdbManager.get<o2::phos::BadChannelsMap>("PHS/Calib/BadMap")));

if (!mBadMap) { // was not read from CCDB, but expected
LOG(fatal) << "Can not read BadMap from CCDB, you may use --not-use-ccdb option to create default bad map";
Expand Down Expand Up @@ -287,4 +287,4 @@ double PHOSRunbyrunCalibrator::CBSignal(double* x, double* par)
double PHOSRunbyrunCalibrator::bg(double* x, double* par)
{
return par[0] + par[1] * x[0] + par[2] * x[0] * x[0];
}
}
8 changes: 5 additions & 3 deletions Detectors/PHOS/reconstruction/src/Clusterer.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,7 @@ void Clusterer::processCells(gsl::span<const Cell> cells, gsl::span<const Trigge
x, z, i, 1.);
}
mLastElementInEvent = cluelements.size();

makeClusters(clusters, cluelements);

LOG(debug) << "Found clusters from " << indexStart << " to " << clusters.size();
trigRec.emplace_back(tr.getBCData(), indexStart, clusters.size() - indexStart);
}
if (mProcessMC) {
Expand All @@ -148,6 +145,7 @@ void Clusterer::makeClusters(std::vector<Cluster>& clusters, std::vector<CluElem
// Cluster contains first and (next-to) last index of the combined list of clusterelements, so
// add elements to final list and mark element in internal list as used (zero energy)

LOG(debug) << "makeClusters: clusters size=" << clusters.size() << " elements=" << cluelements.size();
int iFirst = 0; // first index of digit which potentially can be a part of cluster
int n = mCluEl.size();
for (int i = iFirst; i < n; i++) {
Expand Down Expand Up @@ -202,6 +200,7 @@ void Clusterer::makeClusters(std::vector<Cluster>& clusters, std::vector<CluElem
}
} // loop over cluster
clu->setLastCluEl(cluelements.size());
LOG(debug) << "Cluster: elements from " << clu->getFirstCluEl() << " last=" << cluelements.size();

// Unfold overlapped clusters
// Split clusters with several local maxima if necessary
Expand Down Expand Up @@ -627,10 +626,12 @@ char Clusterer::getNumberOfLocalMax(Cluster& clu, std::vector<CluElement>& cluel
mIsLocalMax.reserve(clu.getMultiplicity());

uint32_t iFirst = clu.getFirstCluEl(), iLast = clu.getLastCluEl();
LOG(debug) << "getNumberOfLocalMax: iFirst=" << iFirst << " iLast=" << iLast << " elements=" << cluel.size();
for (uint32_t i = iFirst; i < iLast; i++) {
mIsLocalMax.push_back(cluel[i].energy > cluSeed);
}

LOG(debug) << "mIsLocalMax size=" << mIsLocalMax.size();
for (uint32_t i = iFirst; i < iLast - 1; i++) {
for (int j = i + 1; j < iLast; j++) {

Expand All @@ -652,6 +653,7 @@ char Clusterer::getNumberOfLocalMax(Cluster& clu, std::vector<CluElement>& cluel
} // digit j
} // digit i

LOG(debug) << " Filled mIsLocalMax";
int iDigitN = 0;
for (int i = 0; i < mIsLocalMax.size(); i++) {
if (mIsLocalMax[i]) {
Expand Down
2 changes: 1 addition & 1 deletion Detectors/PHOS/workflow/src/CellConverterSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void CellConverterSpec::run(framework::ProcessingContext& ctx)
auto& ccdbManager = o2::ccdb::BasicCCDBManager::instance();
ccdbManager.setURL(o2::base::NameConf::getCCDBServer());
LOG(info) << " set-up CCDB " << o2::base::NameConf::getCCDBServer();
mBadMap = ccdbManager.get<o2::phos::BadChannelsMap>("PHS/BadMap");
mBadMap = ccdbManager.get<o2::phos::BadChannelsMap>("PHS/Calib/BadMap");
if (!mBadMap) {
LOG(fatal) << "[PHOSCellConverter - run] can not get Bad Map";
}
Expand Down
4 changes: 2 additions & 2 deletions Detectors/PHOS/workflow/src/ClusterizerSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ void ClusterizerSpec::init(framework::InitContext& ctx)
ccdbManager.setURL(o2::base::NameConf::getCCDBServer());
LOG(info) << " set-up CCDB " << o2::base::NameConf::getCCDBServer();

BadChannelsMap* badMap = ccdbManager.get<o2::phos::BadChannelsMap>("PHS/BadMap");
CalibParams* calibParams = ccdbManager.get<o2::phos::CalibParams>("PHS/Calib");
BadChannelsMap* badMap = ccdbManager.get<o2::phos::BadChannelsMap>("PHS/Calib/BadMap");
CalibParams* calibParams = ccdbManager.get<o2::phos::CalibParams>("PHS/Calib/CalibParams");
Comment on lines 46 to 47
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for careful reading. Idea is to store intermediate maps from different methods in PHS/BadMap and manually combine them to final map stored in PHS/Calib/BadMap.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why manual (which we want to avoid). How often will you do this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ingredients of bad map will be run automatically. Combination will be done once per modification of electronics ~ as in Run2 per period or few periods.

if (badMap) {
mClusterizer.setBadMap(badMap);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ void StandaloneAODProducerSpec::run(ProcessingContext& pc)
c.getEnergy(), // lnAmplitude (dummy value)
(c.getType() == TRU2x2) ? 0 : 1, // triggerBits 0:L0 2x2, 1: L1 4x4
0); // caloType 0: PHOS
continue;
}

// TODO: should bad map be applied here? Unrecoverable loss of channels: special loose map?
// short absId = c.getAbsId();
// if (isBadChannel(absId)) {
// continue;
Expand Down