16 #include <fmt/format.h> 17 #include <fmt/printf.h> 95 mismatchedBField_{
false},
96 mismatchedLatency_{
false},
97 debug_(iConfig.getParameter<
bool>(
"debugMode")),
98 dqmDir_(iConfig.getParameter<
std::string>(
"dqmDir")),
99 fitRange_(iConfig.getParameter<std::vector<double>>(
"fitRange")),
100 recordName_(iConfig.getParameter<
std::string>(
"record")) {
102 if (fitRange_.size() == 2) {
103 theFitRange_.first = fitRange_[0];
104 theFitRange_.second = fitRange_[1];
106 throw cms::Exception(
"SiStripLorentzAnglePCLHarvester") <<
"Too many fit range parameters specified";
112 throw cms::Exception(
"SiStripLorentzAnglePCLHarvester") <<
"PoolDBService required";
149 auto dets =
geom->detsTIB();
150 dets.insert(dets.end(),
geom->detsTID().begin(),
geom->detsTID().end());
151 dets.insert(dets.end(),
geom->detsTOB().begin(),
geom->detsTOB().end());
152 dets.insert(dets.end(),
geom->detsTEC().begin(),
geom->detsTEC().end());
154 for (
auto det : dets) {
155 auto detid = det->geographicalId().rawId();
174 throw cms::Exception(
"SiStripLorentzAnglePCLHarvester") <<
"Trying to harvest runs with different B-field values!";
178 throw cms::Exception(
"SiStripLorentzAnglePCLHarvester") <<
"Trying to harvest runs with diffent APV modes!";
194 std::vector<std::string>
MEtoHarvest = {
"tanthcosphtrk_nstrip",
196 "tanthcosphtrk_var2",
197 "tanthcosphtrk_var3",
204 for (
int l = 1;
l <=
layers.second; ++
l) {
207 if (
l > 2 &&
t ==
"s")
209 std::string locationtype = Form(
"%s_L%d%s", subdet.c_str(),
l,
t.c_str());
211 const char* address = Form(
212 "%s/%s/L%d/%s_%s", folderToHarvest.c_str(), subdet.c_str(),
l, locationtype.c_str(), toHarvest.c_str());
216 iHists_.
h2_[Form(
"%s_%s", locationtype.c_str(), toHarvest.c_str())] = iGetter.
get(address);
217 if (
iHists_.
h2_[Form(
"%s_%s", locationtype.c_str(), toHarvest.c_str())] ==
nullptr) {
219 <<
"could not retrieve: " << Form(
"%s_%s", locationtype.c_str(), toHarvest.c_str());
230 TProfile*
hp = (TProfile*)
ME.second->getTH2F()->ProfileX();
233 iHists_.
p_[
hp->GetName()]->setAxisTitle(
ME.second->getAxisTitle(2), 2);
242 std::map<std::string, std::pair<double, double>> LAMap_;
247 if ((prof.first).find(
"thetatrk_nstrip") != std::string::npos) {
251 double low = prof.second->getAxisMin(1);
252 double high = prof.second->getAxisMax(1);
261 prof.second->getTProfile()->Fit(fitFunc,
"F");
264 Double_t a_fit = fitFunc->GetParameter(0);
265 Double_t thetaL_fit = fitFunc->GetParameter(1);
266 Double_t b_fit = fitFunc->GetParameter(2);
268 Double_t a_fitError = fitFunc->GetParError(0);
269 Double_t thetaL_fitError = fitFunc->GetParError(1);
270 Double_t b_fitError = fitFunc->GetParError(2);
274 << prof.first <<
" fit result: " 275 <<
" a=" << a_fit <<
" +/ " << a_fitError <<
" theta_L=" << thetaL_fit <<
" +/- " << thetaL_fitError
276 <<
" b=" << b_fit <<
" +/- " << b_fitError;
279 LAMap_[
getStem(prof.first,
false)] = std::make_pair(thetaL_fit, thetaL_fitError);
284 for (
const auto& element : LAMap_) {
286 << element.first <<
" thetaLA = " << element.second.first <<
"+/-" << element.second.second;
291 std::shared_ptr<SiStripLorentzAngle> OutLorentzAngle = std::make_shared<SiStripLorentzAngle>();
298 if (!(loc.second).empty()) {
301 OutLorentzAngle->putLorentzAngle(loc.first,
iHists_.
la_db_[loc.first]);
312 edm::LogError(
"SiStripLorentzAngleDB") <<
"caught std::exception " << er.what();
315 edm::LogError(
"SiStripLorentzAngleDB") <<
"Service is unavailable";
321 std::vector<std::string> tokens;
328 while (std::getline(iss,
token,
'_')) {
330 tokens.push_back(
token);
334 output = tokens[0] +
"/" + tokens[1];
337 output = tokens[0] +
"_" + tokens[1];
345 desc.setComment(
"Harvester module of the SiStrip Lorentz Angle PCL monitoring workflow");
346 desc.add<
bool>(
"debugMode",
false)->setComment(
"determines if it's in debug mode");
347 desc.add<
std::string>(
"dqmDir",
"AlCaReco/SiStripLorentzAngle")->setComment(
"the directory of PCL Worker output");
348 desc.add<std::vector<double>>(
"fitRange", {0., 0.})->setComment(
"range of depths to perform the LA fit");
349 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_