28 #include "TFitResult.h" 58 dqmDir_(iConfig.getParameter<
std::
string>(
"dqmDir")),
59 formula_(iConfig.getParameter<
std::
string>(
"formula")),
60 min_entries_(iConfig.getParameter<unsigned
int>(
"minEntries")),
61 threshold_fraction_of_max_(iConfig.getParameter<double>(
"thresholdFractionOfMax")),
62 interp_(
"interp", formula_.c_str(), 10.5, 25.) {
66 throw cms::Exception(
"PPSTimingCalibrationPCLHarvester") <<
"PoolDBService required";
69 interp_.SetParLimits(1, 9., 15.);
70 interp_.SetParLimits(2, 0.2, 2.5);
98 for (
const auto& detid :
detids_) {
99 detid.channelName(ch_name);
100 const auto chid = detid.rawId();
102 (
int)detid.arm(), (
int)detid.station(), (
int)detid.plane(), (
int)detid.channel()};
104 calib_params[
key] = {0, 0, 0, 0};
108 if (
hists.leadingTime[chid] ==
nullptr) {
109 edm::LogInfo(
"PPSTimingCalibrationPCLHarvester:dqmEndJob")
110 <<
"Failed to retrieve leading time monitor for channel (" << detid <<
").";
114 if (
hists.toT[chid] ==
nullptr) {
115 edm::LogInfo(
"PPSTimingCalibrationPCLHarvester:dqmEndJob")
116 <<
"Failed to retrieve time over threshold monitor for channel (" << detid <<
").";
119 hists.leadingTimeVsToT[chid] = iGetter.
get(
dqmDir_ +
"/tvstot_" + ch_name);
120 if (
hists.leadingTimeVsToT[chid] ==
nullptr) {
121 edm::LogInfo(
"PPSTimingCalibrationPCLHarvester:dqmEndJob")
122 <<
"Failed to retrieve leading time vs. time over threshold monitor for channel (" << detid <<
").";
127 <<
"Not enough entries for channel (" << detid <<
"): " <<
hists.leadingTimeVsToT[chid]->getEntries() <<
" < " 134 for (
int i = 0;
i <
hists.toT[chid]->getNbinsX();
i++) {
135 double bin_value =
hists.toT[chid]->getBinContent(
i);
136 int bin_x_pos =
hists.toT[chid]->getTH1()->GetXaxis()->GetBinCenter(
i);
139 if (bin_value >
hists.toT[chid]->getBinContent(max_bin_pos))
143 int upper_limit_pos = max_bin_pos;
144 int lower_limit_pos = max_bin_pos;
156 double upper_tot_range =
hists.toT[chid]->getTH1()->GetXaxis()->GetBinCenter(upper_limit_pos);
157 double lower_tot_range =
hists.toT[chid]->getTH1()->GetXaxis()->GetBinCenter(lower_limit_pos);
162 detid.channelName(ch_name);
163 auto profile = iBooker.
bookProfile(ch_name +
"_prof_x", ch_name +
"_prof_x", 240, 0., 60., 450, -20., 25.);
165 std::unique_ptr<TProfile> prof(
hists.leadingTimeVsToT[chid]->getTH2F()->ProfileX(
"_prof_x", 1, -1));
166 *(
profile->getTProfile()) = *((TProfile*)prof->Clone());
167 profile->getTProfile()->SetTitle(ch_name.c_str());
168 profile->getTProfile()->SetName(ch_name.c_str());
170 interp_.SetParameters(
hists.leadingTime[chid]->getRMS(),
171 hists.toT[chid]->getMean(),
173 hists.leadingTime[chid]->getMean() -
hists.leadingTime[chid]->getRMS());
174 const auto&
res =
profile->getTProfile()->Fit(&
interp_,
"B+",
"", lower_tot_range, upper_tot_range);
176 calib_params[
key] = {
184 <<
"Fit did not converge for channel (" << detid <<
").";
201 ->setComment(
"input path for the various DQM plots");
203 ->setComment(
"interpolation formula for the time walk component");
204 desc.add<
unsigned int>(
"minEntries", 100)->setComment(
"minimal number of hits to extract calibration");
205 desc.add<
double>(
"thresholdFractionOfMax", 0.05)
206 ->setComment(
"threshold for TOT fit, defined as percent of max count in 1D TOT");
std::map< Key, std::pair< double, double > > TimingMap
PPSTimingCalibrationPCLHarvester(const edm::ParameterSet &)
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
virtual void setCurrentFolder(std::string const &fullpath)
edm::ESGetToken< CTPPSGeometry, VeryForwardRealGeometryRecord > geomEsToken_
const std::string dqmDir_
static void fillDescriptions(edm::ConfigurationDescriptions &)
static constexpr double upper_limit_max_search_
const double threshold_fraction_of_max_
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)
static constexpr double lower_limit_range_search_
key
prepare the HTCondor submission files and eventually submit them
#define DEFINE_FWK_MODULE(type)
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_
static constexpr double upper_limit_range_search_
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_