18#include <fairlogger/Logger.h>
35 mStatistics = ic.
options().
get<
int>(
"statistics");
36 LOG(info) <<
"PHOS pedestal init: will collect " << mStatistics <<
" events";
37 LOG(info) <<
"mUseCCDB (try to get current object) = " << mUseCCDB;
38 LOG(info) <<
"mForceUpdate (update CCDB anyway) =" << mForceUpdate;
41 mMeanHG.reset(
new TH2F(
"MeanHighGain",
"MeanHighGain",
n, 1792.5,
n + 1792.5, 100, 0., 100.));
42 mMeanLG.reset(
new TH2F(
"MeanLowGain",
"MeanLowGain",
n, 1792.5,
n + 1792.5, 100, 0., 100.));
43 mRMSHG.reset(
new TH2F(
"RMSHighGain",
"RMSHighGain",
n, 1792.5,
n + 1792.5, 100, 0., 10.));
44 mRMSLG.reset(
new TH2F(
"RMSLowGain",
"RMSLowGain",
n, 1792.5,
n + 1792.5, 100, 0., 10.));
51 if (mRunStartTime == 0) {
55 LOG(info) <<
"Getting calib from CCDB";
59 if (mStatistics <= 0) {
62 if (mStatistics % 100 == 0) {
63 LOG(info) << mStatistics <<
" left to produce calibration";
66 LOG(
debug) <<
"[PHOSPedestalCalibDevice - run] Received " <<
cells.size() <<
" cells, running calibration ...";
67 auto cellsTR = ctx.
inputs().
get<gsl::span<o2::phos::TriggerRecord>>(
"cellTriggerRecords");
68 for (
const auto& tr : cellsTR) {
69 int firstCellInEvent = tr.getFirstEntry();
70 int lastCellInEvent = firstCellInEvent + tr.getNumberOfObjects();
71 for (
int i = firstCellInEvent;
i < lastCellInEvent;
i++) {
73 if (
c.getHighGain()) {
74 mMeanHG->Fill(
c.getAbsId(),
c.getEnergy());
75 mRMSHG->Fill(
c.getAbsId(), 1.e+7 *
c.getTime());
77 mMeanLG->Fill(
c.getAbsId(),
c.getEnergy());
78 mRMSLG->Fill(
c.getAbsId(), 1.e+7 *
c.getTime());
83 if (mStatistics <= 0) {
92 if (mStatistics > 0) {
93 LOG(info) <<
"[PHOSPedestalCalibDevice - endOfStream]";
105 if (mUpdateCCDB || mForceUpdate) {
108 std::map<std::string, std::string> md;
109 long validityTime = mRunStartTime + 7776000000;
115 <<
" of size " <<
image->size()
127 dcsPedestals.emplace_back(mPedestals->getHGPedestal(absId));
130 dcsPedestals.emplace_back(mPedestals->getLGPedestal(absId));
134 std::map<std::string, std::string> mdDCS;
135 o2::ccdb::CcdbObjectInfo infoDCS(
"PHS/PedestalRun/Pedestals",
"PedestalsDCS", flNameDCS, mdDCS, mRunStartTime, validityTime);
146 LOG(info) <<
"[PHOSPedestalCalibDevice - run] Sending QC ";
152 LOG(info) <<
"Start pedestals calculation";
157 for (
unsigned short i = mMeanHG->GetNbinsX();
i > 0;
i--) {
158 TH1D* pr = mMeanHG->ProjectionY(Form(
"proj%d",
i),
i,
i);
159 float a = pr->GetMean();
160 short cellId =
static_cast<short>(mMeanHG->GetXaxis()->GetBinCenter(
i));
161 mPedestals->setHGPedestal(cellId, std::min(255,
int(
a)));
163 pr = mMeanLG->ProjectionY(Form(
"projLG%d",
i),
i,
i);
165 mPedestals->setLGPedestal(cellId, std::min(255,
int(
a)));
167 pr = mRMSHG->ProjectionY(Form(
"projRMS%d",
i),
i,
i);
169 mPedestals->setHGRMS(cellId,
a);
171 pr = mRMSLG->ProjectionY(Form(
"projRMSLG%d",
i),
i,
i);
173 mPedestals->setLGRMS(cellId,
a);
176 LOG(info) <<
"Pedestals calculated";
194 short dp = mPedestals->getHGPedestal(
i) - mOldPed->getHGPedestal(
i);
199 dp = mPedestals->getLGPedestal(
i) - mOldPed->getLGPedestal(
i);
205 LOG(info) << nChanged <<
" channels changed more that 1 ADC channel";
206 if (nChanged > kMinorChange) {
207 LOG(error) <<
"too many channels changed: " << nChanged <<
" (threshold not more than " << kMinorChange <<
")";
209 LOG(error) <<
"you may use --forceupdate option to force updating ccdb";
220 std::vector<InputSpec> inputs;
228 std::vector<OutputSpec> outputs;
238 o2::framework::adaptFromTask<PHOSPedestalCalibDevice>(useCCDB, forceUpdate),
Utils and constants for calibration and related workflows.
Definition of the Names Generator class.
static std::string generateFileName(const std::string &inp)
static std::unique_ptr< std::vector< char > > createObjectImage(const T *obj, CcdbObjectInfo *info=nullptr)
long getEndValidityTimestamp() const
const std::string & getPath() const
void setMetaData(const std::map< std::string, std::string > &md)
long getStartValidityTimestamp() const
const std::string & getFileName() const
T get(const char *key) const
DataAllocator & outputs()
ConfigParamRegistry const & options()
DataAllocator & outputs()
The data allocator is used to allocate memory for the output data.
InputRecord & inputs()
The inputs associated with this processing context.
ServiceRegistryRef services()
The services registry associated with this processing context.
static constexpr short NCHANNELS
Number of channels starting from 1.
void sendOutput(DataAllocator &output)
void calculatePedestals()
void run(o2::framework::ProcessingContext &pc) final
void init(o2::framework::InitContext &ic) final
void endOfStream(o2::framework::EndOfStreamContext &ec) final
This is invoked whenever we have an EndOfStream event.
GLboolean GLboolean GLboolean GLboolean a
constexpr o2::header::DataOrigin gDataOriginPHS
std::vector< ConfigParamSpec > ccdbParamSpec(std::string const &path, int runDependent, std::vector< CCDBMetadata > metadata={}, int qrate=0)
std::vector< ConfigParamSpec > Options
o2::framework::DataProcessorSpec getPedestalCalibSpec(bool useCCDB, bool forceUpdate)
static constexpr o2::header::DataOrigin gDataOriginCDBWrapper
static constexpr o2::header::DataOrigin gDataOriginCDBPayload
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"
std::vector< Cell > cells