28 #include "TFitResult.h" 54 dqmDir_(iConfig.getParameter<
std::
string>(
"dqmDir")),
55 formula_(iConfig.getParameter<
std::
string>(
"formula")),
56 min_entries_(iConfig.getParameter<unsigned
int>(
"minEntries")),
57 interp_(
"interp", formula_.c_str(), 10.5, 25.) {
61 throw cms::Exception(
"PPSTimingCalibrationPCLHarvester") <<
"PoolDBService required";
64 interp_.SetParLimits(1, 9., 15.);
65 interp_.SetParLimits(2, 0.2, 2.5);
72 for (
auto it =
geom.beginSensor(); it !=
geom.endSensor(); ++it) {
94 for (
const auto& detid :
detids_) {
95 detid.channelName(ch_name);
96 const auto chid = detid.rawId();
98 (
int)detid.arm(), (
int)detid.station(), (
int)detid.plane(), (
int)detid.channel()};
100 calib_params[
key] = {0, 0, 0, 0};
104 if (
hists.leadingTime[chid] ==
nullptr) {
105 edm::LogInfo(
"PPSTimingCalibrationPCLHarvester:dqmEndJob")
106 <<
"Failed to retrieve leading time monitor for channel (" << detid <<
").";
110 if (
hists.toT[chid] ==
nullptr) {
111 edm::LogInfo(
"PPSTimingCalibrationPCLHarvester:dqmEndJob")
112 <<
"Failed to retrieve time over threshold monitor for channel (" << detid <<
").";
115 hists.leadingTimeVsToT[chid] = iGetter.
get(
dqmDir_ +
"/tvstot_" + ch_name);
116 if (
hists.leadingTimeVsToT[chid] ==
nullptr) {
117 edm::LogInfo(
"PPSTimingCalibrationPCLHarvester:dqmEndJob")
118 <<
"Failed to retrieve leading time vs. time over threshold monitor for channel (" << detid <<
").";
123 <<
"Not enough entries for channel (" << detid <<
"): " <<
hists.leadingTimeVsToT[chid]->getEntries() <<
" < " 127 const double upper_tot_range =
hists.toT[chid]->getMean() + 2.5;
131 detid.channelName(ch_name);
132 auto profile = iBooker.
bookProfile(ch_name +
"_prof_x", ch_name +
"_prof_x", 240, 0., 60., 450, -20., 25.);
134 std::unique_ptr<TProfile> prof(
hists.leadingTimeVsToT[chid]->getTH2F()->ProfileX(
"_prof_x", 1, -1));
135 *(
profile->getTProfile()) = *((TProfile*)prof->Clone());
136 profile->getTProfile()->SetTitle(ch_name.c_str());
137 profile->getTProfile()->SetName(ch_name.c_str());
139 interp_.SetParameters(
hists.leadingTime[chid]->getRMS(),
140 hists.toT[chid]->getMean(),
142 hists.leadingTime[chid]->getMean() -
hists.leadingTime[chid]->getRMS());
143 const auto&
res =
profile->getTProfile()->Fit(&
interp_,
"B+",
"", 10.4, upper_tot_range);
145 calib_params[
key] = {
153 <<
"Fit did not converge for channel (" << detid <<
").";
170 ->setComment(
"input path for the various DQM plots");
172 ->setComment(
"interpolation formula for the time walk component");
173 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
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
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
static constexpr double offset_
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_
static constexpr double resolution_