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());
229 auto sumValues = [](
int accumulator,
const std::pair<std::string, int>& element) {
237 auto setHistoLabels = [](TH2F* histogram,
const std::map<std::string, int>&
nlayers) {
239 histogram->SetOption(
"colz1");
240 histogram->SetStats(
false);
241 histogram->GetYaxis()->SetLabelSize(0.05);
242 histogram->GetXaxis()->SetLabelSize(0.05);
245 histogram->GetXaxis()->SetBinLabel(1,
"r-#phi");
246 histogram->GetXaxis()->SetBinLabel(2,
"stereo");
250 for (
const auto& subdet : {
"TIB",
"TOB"}) {
253 histogram->GetYaxis()->SetBinLabel(binCounter++,
label.c_str());
256 histogram->GetXaxis()->LabelsOption(
"h");
260 std::string d_text =
"SiStrip tan#theta_{LA}/B;module type (r-#phi/stereo);layer number;tan#theta_{LA}/B [1/T]";
262 iBooker.
book2D(d_name.c_str(), d_text.c_str(), 2, -0.5, 1.5, totalLayers, -0.5, totalLayers - 0.5);
266 d_name =
"h2_byLayerSiStripLADiff";
267 d_text =
"SiStrip #Delta#mu_{H}/#mu_{H};module type (r-#phi/stereo);ladder number;#Delta#mu_{H}/#mu_{H} [%%]";
269 iBooker.
book2D(d_name.c_str(), d_text.c_str(), 2, -0.5, 1.5, totalLayers, -0.5, totalLayers - 0.5);
278 ME.second->setOption(
"colz");
279 TProfile*
hp = (TProfile*)
ME.second->getTH2F()->ProfileX();
282 iHists_.
p_[
hp->GetName()]->setAxisTitle(
ME.second->getAxisTitle(2), 2);
291 std::map<std::string, std::pair<double, double>> LAMap_;
296 if ((prof.first).find(
"thetatrk_nstrip") != std::string::npos) {
300 double low = prof.second->getAxisMin(1);
301 double high = prof.second->getAxisMax(1);
310 prof.second->getTProfile()->Fit(fitFunc,
"F");
313 Double_t a_fit = fitFunc->GetParameter(0);
314 Double_t thetaL_fit = fitFunc->GetParameter(1);
315 Double_t b_fit = fitFunc->GetParameter(2);
317 Double_t a_fitError = fitFunc->GetParError(0);
318 Double_t thetaL_fitError = fitFunc->GetParError(1);
319 Double_t b_fitError = fitFunc->GetParError(2);
323 << prof.first <<
" fit result: " 324 <<
" a=" << a_fit <<
" +/ " << a_fitError <<
" theta_L=" << thetaL_fit <<
" +/- " << thetaL_fitError
325 <<
" b=" << b_fit <<
" +/- " << b_fitError;
328 LAMap_[
getStem(prof.first,
false)] = std::make_pair(thetaL_fit, thetaL_fitError);
333 for (
const auto& element : LAMap_) {
335 << element.first <<
" thetaLA = " << element.second.first <<
"+/-" << element.second.second;
340 std::shared_ptr<SiStripLorentzAngle> OutLorentzAngle = std::make_shared<SiStripLorentzAngle>();
342 bool isPayloadChanged{
false};
343 std::vector<std::pair<int, int>> treatedIndices;
352 OutLorentzAngle->putLorentzAngle(loc.first,
iHists_.
la_db_[loc.first]);
356 if ((loc.second).empty()) {
361 LogDebug(
"SiStripLorentzAnglePCLHarvester")
362 << loc.first <<
" : " << loc.second <<
" index: " << index2D.first <<
"-" << index2D.second << std::endl;
365 if (index2D != std::make_pair(-1, -1)) {
368 auto it =
std::find(treatedIndices.begin(), treatedIndices.end(), index2D);
369 if (
it == treatedIndices.end()) {
371 LogTrace(
"SiStripLorentzAnglePCLHarvester") <<
"accepted " << loc.first <<
" : " << loc.second <<
" bin (" 372 << index2D.first <<
"," << index2D.second <<
")";
374 const auto& outputLA = OutLorentzAngle->getLorentzAngle(loc.first);
377 LogTrace(
"SiStripLorentzAnglePCLHarvester") <<
"inputLA: " << inputLA <<
" outputLA: " << outputLA;
381 float deltaMuHoverMuH = (inputLA != 0.f) ? (inputLA - outputLA) / inputLA : 0.f;
383 treatedIndices.emplace_back(index2D);
388 if (deltaMuHoverMuH != 0.
f) {
389 isPayloadChanged =
true;
390 LogDebug(
"SiStripLorentzAnglePCLHarvester")
391 <<
"accepted " << loc.first <<
" : " << loc.second <<
" bin (" << index2D.first <<
"," << index2D.second
392 <<
") " << deltaMuHoverMuH;
398 <<
"Trying to fill an inexistent module location from " << loc.second <<
"!";
402 if (isPayloadChanged) {
411 edm::LogError(
"SiStripLorentzAngleDB") <<
"caught std::exception " << er.what();
414 edm::LogError(
"SiStripLorentzAngleDB") <<
"Service is unavailable!";
418 <<
"****** WARNING ******\n* " << __PRETTY_FUNCTION__
419 <<
"\n* There is no new valid measurement to append!\n* Will NOT update the DB!\n*********************";
std::vector< std::string > modtypes_
Base exception class for the object to relational access.
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_
dqm::reco::MonitorElement * h2_byLayerLA_
Log< level::Error, false > LogError
std::pair< int, int > locationTypeIndex(const std::string &locType)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
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())
Abs< T >::type abs(const T &t)
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
Log< level::Warning, true > LogPrint
Log< level::Info, false > LogInfo
float getLorentzAngle(const uint32_t &) const
std::string getStem(const std::string &histoName, bool isFolder)
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
std::map< uint32_t, float > la_db_
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
std::pair< double, double > theFitRange_
dqm::reco::MonitorElement * h2_byLayerDiff_
const SiStripLorentzAngle * currentLorentzAngle_
virtual MonitorElement * get(std::string const &fullpath) const
char const * what() const noexcept override
const std::string dqmDir_