16 #include <fmt/format.h> 17 #include <fmt/printf.h> 94 mismatchedBField_{
false},
95 mismatchedLatency_{
false},
96 debug_(iConfig.getParameter<
bool>(
"debugMode")),
97 dqmDir_(iConfig.getParameter<
std::string>(
"dqmDir")),
98 fitRange_(iConfig.getParameter<std::vector<double>>(
"fitRange")),
99 recordName_(iConfig.getParameter<
std::string>(
"record")) {
101 if (fitRange_.size() == 2) {
102 theFitRange_.first = fitRange_[0];
103 theFitRange_.second = fitRange_[1];
105 throw cms::Exception(
"SiStripLorentzAnglePCLHarvester") <<
"Too many fit range parameters specified";
111 throw cms::Exception(
"SiStripLorentzAnglePCLHarvester") <<
"PoolDBService required";
148 auto dets =
geom->detsTIB();
149 dets.insert(dets.end(),
geom->detsTID().begin(),
geom->detsTID().end());
150 dets.insert(dets.end(),
geom->detsTOB().begin(),
geom->detsTOB().end());
151 dets.insert(dets.end(),
geom->detsTEC().begin(),
geom->detsTEC().end());
153 for (
auto det : dets) {
154 auto detid = det->geographicalId().rawId();
173 throw cms::Exception(
"SiStripLorentzAnglePCLHarvester") <<
"Trying to harvest runs with different B-field values!";
177 throw cms::Exception(
"SiStripLorentzAnglePCLHarvester") <<
"Trying to harvest runs with diffent APV modes!";
193 std::vector<std::string>
MEtoHarvest = {
"tanthcosphtrk_nstrip",
195 "tanthcosphtrk_var2",
196 "tanthcosphtrk_var3",
203 for (
int l = 1;
l <=
layers.second; ++
l) {
206 if (
l > 2 &&
t ==
"s")
208 std::string locationtype = Form(
"%s_L%d%s", subdet.c_str(),
l,
t.c_str());
210 const char* address = Form(
211 "%s/%s/L%d/%s_%s", folderToHarvest.c_str(), subdet.c_str(),
l, locationtype.c_str(), toHarvest.c_str());
215 iHists_.
h2_[Form(
"%s_%s", locationtype.c_str(), toHarvest.c_str())] = iGetter.
get(address);
216 if (
iHists_.
h2_[Form(
"%s_%s", locationtype.c_str(), toHarvest.c_str())] ==
nullptr) {
218 <<
"could not retrieve: " << Form(
"%s_%s", locationtype.c_str(), toHarvest.c_str());
230 ME.second->setOption(
"colz");
231 TProfile*
hp = (TProfile*)
ME.second->getTH2F()->ProfileX();
234 iHists_.
p_[
hp->GetName()]->setAxisTitle(
ME.second->getAxisTitle(2), 2);
243 std::map<std::string, std::pair<double, double>> LAMap_;
248 if ((prof.first).find(
"thetatrk_nstrip") != std::string::npos) {
252 double low = prof.second->getAxisMin(1);
253 double high = prof.second->getAxisMax(1);
262 prof.second->getTProfile()->Fit(fitFunc,
"F");
265 Double_t a_fit = fitFunc->GetParameter(0);
266 Double_t thetaL_fit = fitFunc->GetParameter(1);
267 Double_t b_fit = fitFunc->GetParameter(2);
269 Double_t a_fitError = fitFunc->GetParError(0);
270 Double_t thetaL_fitError = fitFunc->GetParError(1);
271 Double_t b_fitError = fitFunc->GetParError(2);
275 << prof.first <<
" fit result: " 276 <<
" a=" << a_fit <<
" +/ " << a_fitError <<
" theta_L=" << thetaL_fit <<
" +/- " << thetaL_fitError
277 <<
" b=" << b_fit <<
" +/- " << b_fitError;
280 LAMap_[
getStem(prof.first,
false)] = std::make_pair(thetaL_fit, thetaL_fitError);
285 for (
const auto& element : LAMap_) {
287 << element.first <<
" thetaLA = " << element.second.first <<
"+/-" << element.second.second;
292 std::shared_ptr<SiStripLorentzAngle> OutLorentzAngle = std::make_shared<SiStripLorentzAngle>();
299 if (!(loc.second).empty()) {
302 OutLorentzAngle->putLorentzAngle(loc.first,
iHists_.
la_db_[loc.first]);
313 edm::LogError(
"SiStripLorentzAngleDB") <<
"caught std::exception " << er.what();
316 edm::LogError(
"SiStripLorentzAngleDB") <<
"Service is unavailable";
322 std::vector<std::string> tokens;
329 while (std::getline(iss,
token,
'_')) {
331 tokens.push_back(
token);
335 output = tokens[0] +
"/" + tokens[1];
338 output = tokens[0] +
"_" + tokens[1];
346 desc.setComment(
"Harvester module of the SiStrip Lorentz Angle PCL monitoring workflow");
347 desc.add<
bool>(
"debugMode",
false)->setComment(
"determines if it's in debug mode");
348 desc.add<
std::string>(
"dqmDir",
"AlCaReco/SiStripLorentzAngle")->setComment(
"the directory of PCL Worker output");
349 desc.add<std::vector<double>>(
"fitRange", {0., 0.})->setComment(
"range of depths to perform the LA fit");
350 desc.add<
std::string>(
"record",
"SiStripLorentzAngleRcd")->setComment(
"target DB record");
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
std::vector< std::string > modtypes_
Base exception class for the object to relational access.
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > geomEsToken_
const std::vector< double > fitRange_
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
void beginRun(const edm::Run &, const edm::EventSetup &) override
virtual void setCurrentFolder(std::string const &fullpath)
ModuleDescription const & moduleDescription() const
const std::string recordName_
double fitFunction(double *x, double *par)
std::map< std::string, int > nlayers_
Log< level::Error, false > LogError
static constexpr float teslaToInverseGeV_
float inverseBzAtOriginInGeV() const
The inverse of field z component for this map in GeV.
std::map< std::string, dqm::reco::MonitorElement * > p_
SiStripLorentzAngleCalibrationHistograms iHists_
std::map< std::string, dqm::reco::MonitorElement * > h2_
std::map< uint32_t, std::string > moduleLocationType_
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())
const std::string fieldAsString(const float &inputField)
Abs< T >::type abs(const T &t)
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
SiStripLorentzAngleCalibrationHistograms hists_
static void fillDescriptions(edm::ConfigurationDescriptions &)
#define DEFINE_FWK_MODULE(type)
std::unique_ptr< TrackerTopology > theTrackerTopology_
const std::string apvModeAsString(const SiStripLatency *latency)
Log< level::Warning, true > LogPrint
Log< level::Info, false > LogInfo
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoEsTokenBR_
float getLorentzAngle(const uint32_t &) const
std::string getStem(const std::string &histoName, bool isFolder)
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
std::map< uint32_t, float > la_db_
std::pair< double, double > theFitRange_
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
const SiStripLorentzAngle * currentLorentzAngle_
virtual MonitorElement * get(std::string const &fullpath) const
SiStripLorentzAnglePCLHarvester(const edm::ParameterSet &)
void endRun(const edm::Run &, const edm::EventSetup &) override
~SiStripLorentzAnglePCLHarvester() override=default
char const * what() const noexcept override
const std::string dqmDir_
std::string moduleLocationType(const uint32_t &mod, const TrackerTopology *tTopo)
const edm::ESGetToken< SiStripLorentzAngle, SiStripLorentzAngleDepRcd > siStripLAEsToken_
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > topoEsTokenER_
const edm::ESGetToken< SiStripLatency, SiStripLatencyRcd > latencyToken_