28 #include "TFitResult.h" 52 dqmDir_(iConfig.getParameter<
std::
string>(
"dqmDir")),
53 formula_(iConfig.getParameter<
std::
string>(
"formula")),
54 min_entries_(iConfig.getParameter<unsigned
int>(
"minEntries")),
55 interp_(
"interp", formula_.c_str(), 10.5, 25.) {
59 throw cms::Exception(
"PPSTimingCalibrationPCLHarvester") <<
"PoolDBService required";
62 interp_.SetParLimits(1, 9., 15.);
63 interp_.SetParLimits(2, 0.2, 2.5);
70 for (
auto it =
geom.beginSensor(); it !=
geom.endSensor(); ++it) {
92 for (
const auto& detid :
detids_) {
93 detid.channelName(ch_name);
94 const auto chid = detid.rawId();
96 (
int)detid.arm(), (
int)detid.station(), (
int)detid.plane(), (
int)detid.channel()};
98 if (
hists.leadingTime[chid] ==
nullptr) {
99 edm::LogInfo(
"PPSTimingCalibrationPCLHarvester:dqmEndJob")
100 <<
"Failed to retrieve leading time monitor for channel (" << detid <<
").";
104 if (
hists.toT[chid] ==
nullptr) {
105 edm::LogInfo(
"PPSTimingCalibrationPCLHarvester:dqmEndJob")
106 <<
"Failed to retrieve time over threshold monitor for channel (" << detid <<
").";
109 hists.leadingTimeVsToT[chid] = iGetter.
get(
dqmDir_ +
"/tvstot_" + ch_name);
110 if (
hists.leadingTimeVsToT[chid] ==
nullptr) {
111 edm::LogInfo(
"PPSTimingCalibrationPCLHarvester:dqmEndJob")
112 <<
"Failed to retrieve leading time vs. time over threshold monitor for channel (" << detid <<
").";
117 <<
"Not enough entries for channel (" << detid <<
"): " <<
hists.leadingTimeVsToT[chid]->getEntries() <<
" < " 121 const double upper_tot_range =
hists.toT[chid]->getMean() + 2.5;
123 std::unique_ptr<TProfile> prof(
hists.leadingTimeVsToT[chid]->getTH2F()->ProfileX(
"_prof_x", 1, -1));
124 interp_.SetParameters(
hists.leadingTime[chid]->getRMS(),
125 hists.toT[chid]->getMean(),
127 hists.leadingTime[chid]->getMean() -
hists.leadingTime[chid]->getRMS());
128 TFitResultPtr
res = prof->Fit(&
interp_,
"B+",
"", 10.4, upper_tot_range);
131 calib_params[
key] = {
133 calib_time[
key] = std::make_pair(0.1, 0.);
137 <<
"Fit did not converge for channel (" << detid <<
").";
154 ->setComment(
"input path for the various DQM plots");
156 ->setComment(
"interpolation formula for the time walk component");
157 desc.add<
unsigned int>(
"minEntries", 100)->setComment(
"minimal number of hits to extract calibration");
std::map< Key, std::pair< double, double > > TimingMap
PPSTimingCalibrationPCLHarvester(const edm::ParameterSet &)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
virtual void setCurrentFolder(std::string const &fullpath)
edm::ESGetToken< CTPPSGeometry, VeryForwardRealGeometryRecord > geomEsToken_
#define DEFINE_FWK_MODULE(type)
const std::string dqmDir_
static void fillDescriptions(edm::ConfigurationDescriptions &)
const unsigned int min_entries_
cond::Time_t currentTime() const
Helper structure for indexing calibration data.
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
bool getData(T &iHolder) const
static bool check(unsigned int raw)
returns true if the raw ID is a PPS-timing one
Log< level::Info, false > LogInfo
void beginRun(const edm::Run &, const edm::EventSetup &) override
virtual MonitorElement * get(std::string const &fullpath) const
std::map< Key, std::vector< double > > ParametersMap
Detector ID class for CTPPS Timing Diamond detectors. Bits [19:31] : Assigend in CTPPSDetId Calss Bit...
Log< level::Warning, false > LogWarning
const std::string formula_
std::vector< CTPPSDiamondDetId > detids_