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
8 changes: 6 additions & 2 deletions Modules/FV0/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ target_sources(O2QcFV0 PRIVATE src/DigitQcTask.cxx
src/BasicPPTask.cxx
src/OutOfBunchCollTask.cxx
src/OutOfBunchCollCheck.cxx
#src/TriggerQcTask.cxx
src/TriggerQcTask.cxx
src/CalibrationTask.cxx
src/ChannelTimeCalibrationCheck.cxx
)

target_include_directories(
Expand All @@ -31,7 +33,9 @@ add_root_dictionary(O2QcFV0
include/FV0/BasicPPTask.h
include/FV0/OutOfBunchCollTask.h
include/FV0/OutOfBunchCollCheck.h
#include/FV0/TriggerQcTask.h
include/FV0/TriggerQcTask.h
include/FV0/CalibrationTask.h
include/FV0/ChannelTimeCalibrationCheck.h
LINKDEF include/FV0/LinkDef.h
BASENAME O2QcFV0)

Expand Down
67 changes: 67 additions & 0 deletions Modules/FV0/include/FV0/CalibrationTask.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

///
/// \file CalibrationTask.h
/// \author Milosz Filus

#ifndef QUALITYCONTROL_FV0_CALIBRATIONTASK_H
#define QUALITYCONTROL_FV0_CALIBRATIONTASK_H

#include "QualityControl/TaskInterface.h"
#include <memory>
#include "TH1.h"
#include "TH2.h"
#include "TTree.h"
#include "TFile.h"
#include "TGraph.h"
#include "TMultiGraph.h"
#include "Rtypes.h"
#include "FV0Calibration/FV0ChannelTimeCalibrationObject.h"

using namespace o2::quality_control::core;

namespace o2::quality_control_modules::fv0
{

class CalibrationTask final : public TaskInterface
{
public:
/// \brief Constructor
CalibrationTask() = default;
/// Destructor
~CalibrationTask() override;

// Definition of the methods for the template method pattern
void initialize(o2::framework::InitContext& ctx) override;
void startOfActivity(Activity& activity) override;
void startOfCycle() override;
void monitorData(o2::framework::ProcessingContext& ctx) override;
void endOfCycle() override;
void endOfActivity(Activity& activity) override;
void reset() override;

private:
static constexpr int CHANNEL_TIME_HISTOGRAM_RANGE = 200;
static constexpr const char* CCDB_PARAM_KEY = "CCDBUrl";

// Object which will be published
std::unique_ptr<TH1F> mNotCalibratedChannelTimeHistogram;
std::unique_ptr<TH1F> mCalibratedChannelTimeHistogram;
std::unique_ptr<TGraph> mChannelTimeCalibrationObjectGraph;
std::unique_ptr<TH2F> mCalibratedTimePerChannelHistogram;
std::unique_ptr<TH2F> mNotCalibratedTimePerChannelHistogram;
o2::fv0::FV0ChannelTimeCalibrationObject* mCurrentChannelTimeCalibrationObject;
};

} // namespace o2::quality_control_modules::fv0

#endif //QUALITYCONTROL_FV0_CALIBRATIONTASK_H
58 changes: 58 additions & 0 deletions Modules/FV0/include/FV0/ChannelTimeCalibrationCheck.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

///
/// \file ChannelTimeCalibrationCheck.h
/// \author Milosz Filus

#ifndef QC_MODULE_FV0_FV0CalibrationCheck_H
#define QC_MODULE_FV0_FV0CalibrationCheck_H

// Quality Control
#include "QualityControl/CheckInterface.h"

namespace o2::quality_control_modules::fv0
{

/// \brief
///
class ChannelTimeCalibrationCheck : public o2::quality_control::checker::CheckInterface
{
public:
/// Default constructor
ChannelTimeCalibrationCheck() = default;
/// Destructor
~ChannelTimeCalibrationCheck() override = default;

// Override interface
void configure(std::string name) override;
Quality check(std::map<std::string, std::shared_ptr<MonitorObject>>* moMap) override;
void beautify(std::shared_ptr<MonitorObject> mo, Quality checkResult) override;
ClassDefOverride(ChannelTimeCalibrationCheck, 1);

private:
static constexpr const char* MEAN_WARNING_KEY = "MeanWarning";
static constexpr const char* MEAN_ERROR_KEY = "MeanError";
static constexpr const char* RMS_WARNING_KEY = "RMSWarning";
static constexpr const char* RMS_ERROR_KEY = "RMSError";
static constexpr const char* MIN_ENTRIES_KEY = "MinEntries";

private:
double mMeanWarning;
double mMeanError;
double mRMSWarning;
double mRMSError;
int mMinEntries;
};

} // namespace o2::quality_control_modules::fv0

#endif
4 changes: 3 additions & 1 deletion Modules/FV0/include/FV0/LinkDef.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
#pragma link C++ class o2::quality_control_modules::fv0::BasicPPTask + ;
#pragma link C++ class o2::quality_control_modules::fv0::OutOfBunchCollTask + ;
#pragma link C++ class o2::quality_control_modules::fv0::CFDEffCheck + ;
// #pragma link C++ class o2::quality_control_modules::fv0::TriggerQcTask + ;
#pragma link C++ class o2::quality_control_modules::fv0::OutOfBunchCollCheck + ;
#pragma link C++ class o2::quality_control_modules::fv0::TriggerQcTask + ;
#pragma link C++ class o2::quality_control_modules::fv0::CalibrationTask + ;
#pragma link C++ class o2::quality_control_modules::fv0::ChannelTimeCalibrationCheck + ;

#endif
99 changes: 99 additions & 0 deletions Modules/FV0/include/FV0/TriggerQcTask.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

///
/// \file TriggerQcTask.h
/// \author Sebastian Bysiak sbysiak@cern.ch
///

#ifndef QC_MODULE_FV0_FV0TRIGGERQCTASK_H
#define QC_MODULE_FV0_FV0TRIGGERQCTASK_H

#include "QualityControl/TaskInterface.h"
#include "QualityControl/QcInfoLogger.h"
#include "DataFormatsFV0/BCData.h"
#include "DataFormatsFV0/ChannelData.h"
#include "FV0/Helper.h"

#include "TH1.h"
#include "TH2.h"

using namespace o2::quality_control::core;

namespace o2::quality_control_modules::fv0
{
namespace ch_data = helper::channel_data;
using ChannelData = o2::fv0::ChannelData;
using Digit = o2::fv0::BCData;

/// \brief Task to verify in software triggers generated on FEE
/// \author Sebastian Bysiak sbysiak@cern.ch
class TriggerQcTask final : public TaskInterface
{
public:
/// \brief Constructor
TriggerQcTask() = default;
/// Destructor
~TriggerQcTask() override;

void initialize(o2::framework::InitContext& ctx) override;
void startOfActivity(Activity& activity) override;
void startOfCycle() override;
void monitorData(o2::framework::ProcessingContext& ctx) override;
void endOfCycle() override;
void endOfActivity(Activity& activity) override;
void reset() override;

private:
unsigned int getModeParameter(std::string, unsigned int, std::map<unsigned int, std::string>);
int getNumericalParameter(std::string, int);

// temp, order important
enum ETrgMenu { kMinBias,
kOuterRing,
kNChannels,
kCharge,
kInnerRing
};
// only for Inner/Outer trigger
enum TrgModeThresholdVar { kAmpl,
kNchannels
};
enum ComparisonResult { kSWonly,
kTCMonly,
kNone,
kBoth
};

std::map<int, std::string> mMapDigitTrgNames;
std::map<int, bool> mMapTrgSoftware;

constexpr static int sNCHANNELS_PM = 48; //48(for PM), nothing more
constexpr static int sNCHANNELS_PM_INNER = 24; // "Inner" = 3 inner rings = first 24 channels

unsigned int mModeInnerOuterThresholdVar;
// full set of possible parameters:
// to be eliminated after decision about Inner/Outer trigger type
int mThresholdCharge;
int mThresholdChargeOuter;
int mThresholdChargeInner;
int mThresholdNChannels;
int mThresholdNChannelsOuter;
int mThresholdNChannelsInner;

// Objects which will be published
std::unique_ptr<TH1F> mHistTriggersSw;
std::unique_ptr<TH2F> mHistTriggersSoftwareVsTCM;
};

} // namespace o2::quality_control_modules::fv0

#endif // QC_MODULE_FV0_FV0TRIGGERQCTASK_H
129 changes: 129 additions & 0 deletions Modules/FV0/src/CalibrationTask.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
// All rights not expressly granted are reserved.
//
// This software is distributed under the terms of the GNU General Public
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
//
// In applying this license CERN does not waive the privileges and immunities
// granted to it by virtue of its status as an Intergovernmental Organization
// or submit itself to any jurisdiction.

///
/// \file CalibrationTask.cxx
/// \author Milosz Filus
///

#include "TCanvas.h"
#include "TH1.h"
#include "TGraph.h"

#include "QualityControl/QcInfoLogger.h"
#include "FV0/CalibrationTask.h"
//#include "DataFormatsFV0/Digit.h"
#include "DataFormatsFV0/BCData.h"
#include "DataFormatsFV0/ChannelData.h"
#include "FV0Base/Constants.h"
#include <Framework/InputRecord.h>
#include "DetectorsCalibration/Utils.h"
#include "CCDB/BasicCCDBManager.h"
#include "FITCalibration/FITCalibrationApi.h"

namespace o2::quality_control_modules::fv0
{

CalibrationTask::~CalibrationTask()
{
}

void CalibrationTask::initialize(o2::framework::InitContext& /*ctx*/)
{
ILOG(Info, Support) << "initialize CalibrationTask" << ENDM; // QcInfoLogger is used. FairMQ logs will go to there as well.
constexpr std::size_t Nchannels_FV0 = o2::fv0::Constants::nFv0Channels; // 48 // hsharma
mNotCalibratedChannelTimeHistogram = std::make_unique<TH1F>("Not_calibrated_time", "Not_calibrated_time", 2 * CHANNEL_TIME_HISTOGRAM_RANGE, -CHANNEL_TIME_HISTOGRAM_RANGE, CHANNEL_TIME_HISTOGRAM_RANGE);
mCalibratedChannelTimeHistogram = std::make_unique<TH1F>("Calibrated_time", "Calibrated_time", 2 * CHANNEL_TIME_HISTOGRAM_RANGE, -CHANNEL_TIME_HISTOGRAM_RANGE, CHANNEL_TIME_HISTOGRAM_RANGE);
mCalibratedTimePerChannelHistogram = std::make_unique<TH2F>("Calibrated_time_per_channel", "Calibrated_time_per_channel", Nchannels_FV0, 0, Nchannels_FV0, 2 * CHANNEL_TIME_HISTOGRAM_RANGE, -CHANNEL_TIME_HISTOGRAM_RANGE, CHANNEL_TIME_HISTOGRAM_RANGE);
mNotCalibratedTimePerChannelHistogram = std::make_unique<TH2F>("Not_calibrated_time_per_channel", "Not_calibrated_time_per_channel", Nchannels_FV0, 0, Nchannels_FV0, 2 * CHANNEL_TIME_HISTOGRAM_RANGE, -CHANNEL_TIME_HISTOGRAM_RANGE, CHANNEL_TIME_HISTOGRAM_RANGE);
mChannelTimeCalibrationObjectGraph = std::make_unique<TGraph>(Nchannels_FV0);
mChannelTimeCalibrationObjectGraph->SetName("Channel_time_calibration_object");
mChannelTimeCalibrationObjectGraph->SetTitle("Channel_time_calibration_object");
mChannelTimeCalibrationObjectGraph->SetMarkerStyle(20);
mChannelTimeCalibrationObjectGraph->SetLineColor(kWhite);
mChannelTimeCalibrationObjectGraph->SetFillColor(kBlack);
getObjectsManager()->startPublishing(mNotCalibratedChannelTimeHistogram.get());
getObjectsManager()->startPublishing(mCalibratedChannelTimeHistogram.get());
getObjectsManager()->startPublishing(mCalibratedTimePerChannelHistogram.get());
getObjectsManager()->startPublishing(mNotCalibratedTimePerChannelHistogram.get());
getObjectsManager()->startPublishing(mChannelTimeCalibrationObjectGraph.get());
ccdb::BasicCCDBManager::instance().setURL(mCustomParameters.at(CCDB_PARAM_KEY));
}

void CalibrationTask::startOfActivity(Activity& activity)
{
ILOG(Info, Support) << "startOfActivity" << activity.mId << ENDM;
mNotCalibratedChannelTimeHistogram->Reset();
mCalibratedChannelTimeHistogram->Reset();
mCalibratedTimePerChannelHistogram->Reset();
mNotCalibratedTimePerChannelHistogram->Reset();
}

void CalibrationTask::startOfCycle()
{
ILOG(Info, Support) << "startOfCycle" << ENDM;
mNotCalibratedChannelTimeHistogram->Reset();
mCalibratedChannelTimeHistogram->Reset();
mCalibratedTimePerChannelHistogram->Reset();
mNotCalibratedTimePerChannelHistogram->Reset();
mCurrentChannelTimeCalibrationObject = ccdb::BasicCCDBManager::instance().get<o2::fv0::FV0ChannelTimeCalibrationObject>(o2::fit::FITCalibrationApi::getObjectPath<o2::fv0::FV0ChannelTimeCalibrationObject>());
for (std::size_t chID = 0; chID < o2::fv0::Constants::nFv0Channels; ++chID) {
if (mCurrentChannelTimeCalibrationObject) {
mChannelTimeCalibrationObjectGraph->SetPoint(chID, chID, mCurrentChannelTimeCalibrationObject->mTimeOffsets[chID]);
} else {
mChannelTimeCalibrationObjectGraph->SetPoint(chID, chID, 0);
}
}
}

void CalibrationTask::monitorData(o2::framework::ProcessingContext& ctx)
{

auto channels = ctx.inputs().get<gsl::span<o2::fv0::ChannelData>>("channels");

for (auto& channel : channels) {
if (mCurrentChannelTimeCalibrationObject) {
// mCalibratedChannelTimeHistogram->Fill(channel.time + mCurrentChannelTimeCalibrationObject->mTimeOffsets[channel.getChannelID()]);
// mCalibratedTimePerChannelHistogram->Fill(channel.getChannelID(), channel.time + mCurrentChannelTimeCalibrationObject->mTimeOffsets[channel.getChannelID()]);
mCalibratedChannelTimeHistogram->Fill(channel.time - mCurrentChannelTimeCalibrationObject->mTimeOffsets[channel.getChannelID()]);
mCalibratedTimePerChannelHistogram->Fill(channel.getChannelID(), channel.time - mCurrentChannelTimeCalibrationObject->mTimeOffsets[channel.getChannelID()]);

} else {
mCalibratedChannelTimeHistogram->Fill(channel.time);
mCalibratedTimePerChannelHistogram->Fill(channel.getChannelID(), channel.time);
}
mNotCalibratedChannelTimeHistogram->Fill(channel.time);
mNotCalibratedTimePerChannelHistogram->Fill(channel.getChannelID(), channel.time);
// std::cout << "-------++++++++++++++++++++++----------++++++++++++++------------_+++++++++++++++++ " << std::endl;
// std::cout << channel.time << std::endl;
// std::cout << "-------++++++++++++++++++++++----------++++++++++++++------------_+++++++++++++++++ " << std::endl;
}
}
void CalibrationTask::endOfCycle()
{
ILOG(Info, Support) << "endOfCycle" << ENDM;
}

void CalibrationTask::endOfActivity(Activity& /*activity*/)
{
ILOG(Info, Support) << "endOfActivity" << ENDM;
}

void CalibrationTask::reset()
{
// clean all the monitor objects here
mNotCalibratedChannelTimeHistogram->Reset();
mCalibratedChannelTimeHistogram->Reset();
mCalibratedTimePerChannelHistogram->Reset();
mNotCalibratedTimePerChannelHistogram->Reset();
}

} // namespace o2::quality_control_modules::fv0
Loading