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);
93 for (
const auto& detid :
detids_) {
94 detid.channelName(ch_name);
95 const auto chid = detid.rawId();
97 (
int)detid.arm(), (
int)detid.station(), (
int)detid.plane(), (
int)detid.channel()};
99 calib_params[
key] = {0, 0, 0, 0};
103 if (
hists.leadingTime[chid] ==
nullptr) {
104 edm::LogInfo(
"PPSTimingCalibrationPCLHarvester:dqmEndJob")
105 <<
"Failed to retrieve leading time monitor for channel (" << detid <<
").";
109 if (
hists.toT[chid] ==
nullptr) {
110 edm::LogInfo(
"PPSTimingCalibrationPCLHarvester:dqmEndJob")
111 <<
"Failed to retrieve time over threshold monitor for channel (" << detid <<
").";
114 hists.leadingTimeVsToT[chid] = iGetter.
get(
dqmDir_ +
"/tvstot_" + ch_name);
115 if (
hists.leadingTimeVsToT[chid] ==
nullptr) {
116 edm::LogInfo(
"PPSTimingCalibrationPCLHarvester:dqmEndJob")
117 <<
"Failed to retrieve leading time vs. time over threshold monitor for channel (" << detid <<
").";
122 <<
"Not enough entries for channel (" << detid <<
"): " <<
hists.leadingTimeVsToT[chid]->getEntries() <<
" < " 126 const double upper_tot_range =
hists.toT[chid]->getMean() + 2.5;
130 detid.channelName(ch_name);
131 auto profile = iBooker.
bookProfile(ch_name +
"_prof_x", ch_name +
"_prof_x", 240, 0., 60., 450, -20., 25.);
133 std::unique_ptr<TProfile> prof(
hists.leadingTimeVsToT[chid]->getTH2F()->ProfileX(
"_prof_x", 1, -1));
134 *(
profile->getTProfile()) = *((TProfile*)prof->Clone());
135 profile->getTProfile()->SetTitle(ch_name.c_str());
136 profile->getTProfile()->SetName(ch_name.c_str());
138 interp_.SetParameters(
hists.leadingTime[chid]->getRMS(),
139 hists.toT[chid]->getMean(),
141 hists.leadingTime[chid]->getMean() -
hists.leadingTime[chid]->getRMS());
142 const auto&
res =
profile->getTProfile()->Fit(&
interp_,
"B+",
"", 10.4, upper_tot_range);
144 calib_params[
key] = {
152 <<
"Fit did not converge for channel (" << detid <<
").";
169 ->setComment(
"input path for the various DQM plots");
171 ->setComment(
"interpolation formula for the time walk component");
172 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)
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 &)
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)
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_
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_