CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
DiMuonMassBiasClient Class Reference

#include <DiMuonMassBiasClient.h>

Inheritance diagram for DiMuonMassBiasClient:
DQMEDHarvester edm::one::EDProducer< edm::EndLuminosityBlockProducer, edm::EndRunProducer, edm::EndProcessBlockProducer, edm::one::WatchLuminosityBlocks, edm::one::WatchRuns, edm::one::SharedResources, edm::Accumulator > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 DiMuonMassBiasClient (const edm::ParameterSet &ps)
 Constructor. More...
 
 ~DiMuonMassBiasClient () override
 Destructor. More...
 
- Public Member Functions inherited from DQMEDHarvester
void accumulate (edm::Event const &ev, edm::EventSetup const &es) final
 
void beginJob () override
 
void beginLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &) final
 
void beginRun (edm::Run const &run, edm::EventSetup const &) override
 
virtual void dqmAnalyze (DQMStore::IBooker &, DQMStore::IGetter &, edm::Event const &, edm::EventSetup const &)
 
 DQMEDHarvester (edm::ParameterSet const &iConfig)
 
 DQMEDHarvester ()
 
virtual void dqmEndLuminosityBlock (DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &)
 
virtual void dqmEndRun (DQMStore::IBooker &, DQMStore::IGetter &, edm::Run const &, edm::EventSetup const &)
 
void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) final
 
void endLuminosityBlockProduce (edm::LuminosityBlock &lumi, edm::EventSetup const &es) final
 
void endProcessBlockProduce (edm::ProcessBlock &) final
 
void endRun (edm::Run const &, edm::EventSetup const &) override
 
void endRunProduce (edm::Run &run, edm::EventSetup const &es) final
 
 ~DQMEDHarvester () override=default
 
- Public Member Functions inherited from edm::one::EDProducer< edm::EndLuminosityBlockProducer, edm::EndRunProducer, edm::EndProcessBlockProducer, edm::one::WatchLuminosityBlocks, edm::one::WatchRuns, edm::one::SharedResources, edm::Accumulator >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Protected Member Functions

void beginJob (void) override
 BeginJob. More...
 
void beginRun (edm::Run const &run, edm::EventSetup const &eSetup) override
 BeginRun. More...
 
void dqmEndJob (DQMStore::IBooker &ibooker_, DQMStore::IGetter &igetter_) override
 EndJob. More...
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Private Member Functions

void bookMEs (DQMStore::IBooker &ibooker)
 book MEs More...
 
void fitAndFillHisto (std::pair< std::string, MonitorElement *> toHarvest, DQMStore::IBooker &iBooker)
 
void fitAndFillProfile (std::pair< std::string, MonitorElement *> toHarvest, DQMStore::IBooker &iBooker)
 
diMuonMassBias::fitOutputs fitBWTimesCB (TH1 *hist) const
 
diMuonMassBias::fitOutputs fitLineShape (TH1 *hist, const bool &fitBackground=false) const
 
void getMEsToHarvest (DQMStore::IGetter &igetter)
 

Private Attributes

const bool debugMode_
 
const bool fitBackground_
 
std::map< std::string, MonitorElement * > harvestTargets_
 
float meanConfig_ [3]
 
std::map< std::string, MonitorElement * > meanHistos_
 
std::map< std::string, MonitorElement * > meanProfiles_
 
std::vector< std::string > MEtoHarvest_
 
float sigmaConfig_ [3]
 
const std::string TopFolder_
 
const bool useBWtimesCB_
 
const bool useRooCBShape_
 
const bool useRooCMSShape_
 
const bool useTH1s_
 
float widthConfig_ [3]
 
std::map< std::string, MonitorElement * > widthHistos_
 
std::map< std::string, MonitorElement * > widthProfiles_
 

Additional Inherited Members

- Public Types inherited from DQMEDHarvester
typedef dqm::harvesting::DQMStore DQMStore
 
typedef dqm::harvesting::MonitorElement MonitorElement
 
- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Protected Attributes inherited from DQMEDHarvester
DQMStoredqmstore_
 
edm::GetterOfProducts< DQMTokenjobmegetter_
 
edm::EDPutTokenT< DQMTokenjobToken_
 
edm::GetterOfProducts< DQMTokenlumimegetter_
 
edm::EDPutTokenT< DQMTokenlumiToken_
 
edm::GetterOfProducts< DQMTokenrunmegetter_
 
edm::EDPutTokenT< DQMTokenrunToken_
 

Detailed Description

Definition at line 59 of file DiMuonMassBiasClient.h.

Constructor & Destructor Documentation

◆ DiMuonMassBiasClient()

DiMuonMassBiasClient::DiMuonMassBiasClient ( const edm::ParameterSet ps)

Constructor.

Definition at line 21 of file DiMuonMassBiasClient.cc.

References debugMode_, diMuonMassBias::fillArrayF(), DiMuonMassBiasClient_cfi::fit_par, edm::ParameterSet::getParameter(), meanConfig_, sigmaConfig_, and widthConfig_.

22  : TopFolder_(iConfig.getParameter<std::string>("FolderName")),
23  useTH1s_(iConfig.getParameter<bool>("useTH1s")),
24  useBWtimesCB_(iConfig.getParameter<bool>("useBWtimesCB")),
25  fitBackground_(iConfig.getParameter<bool>("fitBackground")),
26  useRooCBShape_(iConfig.getParameter<bool>("useRooCBShape")),
27  useRooCMSShape_(iConfig.getParameter<bool>("useRooCMSShape")),
28  debugMode_(iConfig.getParameter<bool>("debugMode")),
29  MEtoHarvest_(iConfig.getParameter<std::vector<std::string>>("MEtoHarvest"))
30 //-----------------------------------------------------------------------------------
31 {
32  edm::LogInfo("DiMuonMassBiasClient") << "DiMuonMassBiasClient::Constructing DiMuonMassBiasClient ";
33 
34  // fill the parameters for the fit
35  edm::ParameterSet fit_par = iConfig.getParameter<edm::ParameterSet>("fit_par");
39 
40  if (debugMode_) {
41  edm::LogPrint("DiMuonMassBiasClient")
42  << "mean: " << meanConfig_[0] << " (" << meanConfig_[1] << "," << meanConfig_[2] << ") " << std::endl;
43  edm::LogPrint("DiMuonMassBiasClient")
44  << "width: " << widthConfig_[0] << " (" << widthConfig_[1] << "," << widthConfig_[2] << ")" << std::endl;
45  edm::LogPrint("DiMuonMassBiasClient")
46  << "sigma: " << sigmaConfig_[0] << " (" << sigmaConfig_[1] << "," << sigmaConfig_[2] << ")" << std::endl;
47  }
48 }
const std::string TopFolder_
std::vector< std::string > MEtoHarvest_
Log< level::Warning, true > LogPrint
Log< level::Info, false > LogInfo
void fillArrayF(float *x, const edm::ParameterSet &cfg, const char *name)

◆ ~DiMuonMassBiasClient()

DiMuonMassBiasClient::~DiMuonMassBiasClient ( )
override

Destructor.

Definition at line 51 of file DiMuonMassBiasClient.cc.

53 {
54  edm::LogInfo("DiMuonMassBiasClient") << "DiMuonMassBiasClient::Deleting DiMuonMassBiasClient ";
55 }
Log< level::Info, false > LogInfo

Member Function Documentation

◆ beginJob()

void DiMuonMassBiasClient::beginJob ( void  )
overrideprotectedvirtual

BeginJob.

Reimplemented from edm::one::EDProducerBase.

Definition at line 58 of file DiMuonMassBiasClient.cc.

60 {
61  edm::LogInfo("DiMuonMassBiasClient") << "DiMuonMassBiasClient::beginJob done";
62 }
Log< level::Info, false > LogInfo

◆ beginRun()

void DiMuonMassBiasClient::beginRun ( edm::Run const &  run,
edm::EventSetup const &  eSetup 
)
overrideprotected

BeginRun.

Definition at line 65 of file DiMuonMassBiasClient.cc.

67 {
68  edm::LogInfo("DiMuonMassBiasClient") << "DiMuonMassBiasClient:: Begining of Run";
69 }
Log< level::Info, false > LogInfo

◆ bookMEs()

void DiMuonMassBiasClient::bookMEs ( DQMStore::IBooker ibooker)
private

book MEs

Definition at line 72 of file DiMuonMassBiasClient.cc.

References dqm::implementation::IBooker::book1D(), harvestTargets_, submitPVResolutionJobs::key, meanHistos_, dqm::implementation::NavigatorBase::setCurrentFolder(), runGCPTkAlMap::title, TopFolder_, widthHistos_, TrackerOfflineValidation_Dqm_cff::xmax, TrackerOfflineValidation_Dqm_cff::xmin, compareTotals::xtitle, and compareTotals::ytitle.

Referenced by dqmEndJob().

74 {
75  iBooker.setCurrentFolder(TopFolder_ + "/DiMuonMassBiasMonitor/MassBias/Profiles");
76  for (const auto& [key, ME] : harvestTargets_) {
77  if (ME == nullptr) {
78  edm::LogError("DiMuonMassBiasClient") << "could not find MonitorElement for key: " << key << std::endl;
79  continue;
80  }
81 
82  const auto& title = ME->getTitle();
83  const auto& xtitle = ME->getAxisTitle(1);
84  const auto& ytitle = ME->getAxisTitle(2);
85 
86  const auto& nxbins = ME->getNbinsX();
87  const auto& xmin = ME->getAxisMin(1);
88  const auto& xmax = ME->getAxisMax(1);
89 
90  MonitorElement* meanToBook =
91  iBooker.book1D(("Mean" + key), (title + ";#LT M_{#mu^{-}#mu^{+}} #GT [GeV];" + ytitle), nxbins, xmin, xmax);
92  meanHistos_.insert({key, meanToBook});
93 
94  MonitorElement* sigmaToBook =
95  iBooker.book1D(("Sigma" + key), (title + ";" + xtitle + ";" + "#sigma of " + ytitle), nxbins, xmin, xmax);
96  widthHistos_.insert({key, sigmaToBook});
97  }
98 }
std::map< std::string, MonitorElement * > widthHistos_
const std::string TopFolder_
Log< level::Error, false > LogError
std::map< std::string, MonitorElement * > harvestTargets_
Definition: ME.h:11
key
prepare the HTCondor submission files and eventually submit them
std::map< std::string, MonitorElement * > meanHistos_

◆ dqmEndJob()

void DiMuonMassBiasClient::dqmEndJob ( DQMStore::IBooker ibooker_,
DQMStore::IGetter igetter_ 
)
overrideprotectedvirtual

EndJob.

Implements DQMEDHarvester.

Definition at line 262 of file DiMuonMassBiasClient.cc.

References bookMEs(), fitAndFillHisto(), fitAndFillProfile(), getMEsToHarvest(), harvestTargets_, and useTH1s_.

264 {
265  edm::LogInfo("DiMuonMassBiasClient") << "DiMuonMassBiasClient::endLuminosityBlock";
266 
267  getMEsToHarvest(igetter);
268 
269  // book the histograms upfront
270  if (useTH1s_) {
271  bookMEs(ibooker);
272  }
273 
274  for (const auto& element : harvestTargets_) {
275  if (!useTH1s_) {
276  // if using profiles
277  this->fitAndFillProfile(element, ibooker);
278  } else {
279  // if using histograms
280  this->fitAndFillHisto(element, ibooker);
281  }
282  }
283 }
void getMEsToHarvest(DQMStore::IGetter &igetter)
std::map< std::string, MonitorElement * > harvestTargets_
Log< level::Info, false > LogInfo
void fitAndFillProfile(std::pair< std::string, MonitorElement *> toHarvest, DQMStore::IBooker &iBooker)
void bookMEs(DQMStore::IBooker &ibooker)
book MEs
void fitAndFillHisto(std::pair< std::string, MonitorElement *> toHarvest, DQMStore::IBooker &iBooker)

◆ fillDescriptions()

void DiMuonMassBiasClient::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 504 of file DiMuonMassBiasClient.cc.

References edm::ConfigurationDescriptions::addWithDefaultLabel(), submitPVResolutionJobs::desc, DiMuonMassBiasClient_cfi::fit_par, WZElectronSkims53X_cff::max, and AlCaHLTBitMon_QueryRunRegistry::string.

506 {
508  desc.add<std::string>("FolderName", "DiMuonMassBiasMonitor");
509  desc.add<bool>("useTH1s", false);
510  desc.add<bool>("useBWtimesCB", false);
511  desc.add<bool>("fitBackground", false);
512  desc.add<bool>("useRooCMSShape", false);
513  desc.add<bool>("useRooCBShape", false);
514  desc.add<bool>("debugMode", false);
515 
517  fit_par.add<std::vector<double>>("mean_par",
520  std::numeric_limits<float>::max()}); // par = mean
521 
522  fit_par.add<std::vector<double>>("width_par",
525  std::numeric_limits<float>::max()}); // par = width
526 
527  fit_par.add<std::vector<double>>("sigma_par",
530  std::numeric_limits<float>::max()}); // par = sigma
531 
532  desc.add<edm::ParameterSetDescription>("fit_par", fit_par);
533 
534  desc.add<std::vector<std::string>>("MEtoHarvest",
535  {"DiMuMassVsMuMuPhi",
536  "DiMuMassVsMuMuEta",
537  "DiMuMassVsMuPlusPhi",
538  "DiMuMassVsMuPlusEta",
539  "DiMuMassVsMuMinusPhi",
540  "DiMuMassVsMuMinusEta",
541  "DiMuMassVsMuMuDeltaEta",
542  "DiMuMassVsCosThetaCS"});
543  descriptions.addWithDefaultLabel(desc);
544 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

◆ fitAndFillHisto()

void DiMuonMassBiasClient::fitAndFillHisto ( std::pair< std::string, MonitorElement *>  toHarvest,
DQMStore::IBooker iBooker 
)
private

Definition at line 215 of file DiMuonMassBiasClient.cc.

References newFWLiteAna::bin, debugMode_, Measurement1D::error(), fitBackground_, fitBWTimesCB(), fitLineShape(), submitPVResolutionJobs::key, meanHistos_, mysort::results, useBWtimesCB_, Measurement1D::value(), ApeEstimator_cff::width, widthHistos_, and LaserClient_cfi::xaxis.

Referenced by dqmEndJob().

218 {
219  const auto& key = toHarvest.first;
220  const auto& ME = toHarvest.second;
221 
222  if (debugMode_)
223  edm::LogPrint("DiMuonMassBiasClient") << "dealing with key: " << key << std::endl;
224 
225  if (ME == nullptr) {
226  edm::LogError("DiMuonMassBiasClient") << "could not find MonitorElement for key: " << key << std::endl;
227  return;
228  }
229 
230  TH2F* bareHisto = ME->getTH2F();
231  for (int bin = 1; bin <= ME->getNbinsX(); bin++) {
232  const auto& xaxis = bareHisto->GetXaxis();
233  const auto& low_edge = xaxis->GetBinLowEdge(bin);
234  const auto& high_edge = xaxis->GetBinUpEdge(bin);
235 
236  if (debugMode_)
237  edm::LogPrint("DiMuonMassBiasClient") << "dealing with bin: " << bin << " range: (" << std::setprecision(2)
238  << low_edge << "," << std::setprecision(2) << high_edge << ")";
239  TH1D* Proj = bareHisto->ProjectionY(Form("%s_proj_%i", key.c_str(), bin), bin, bin);
240  Proj->SetTitle(Form("%s #in (%.2f,%.2f), bin: %i", Proj->GetTitle(), low_edge, high_edge, bin));
241 
243 
244  if (results.isInvalid()) {
245  edm::LogWarning("DiMuonMassBiasClient") << "the current bin has invalid data" << std::endl;
246  continue;
247  }
248 
249  // fill the mean profiles
250  const Measurement1D& bias = results.getBias();
251  meanHistos_[key]->setBinContent(bin, bias.value());
252  meanHistos_[key]->setBinError(bin, bias.error());
253 
254  // fill the width profiles
255  const Measurement1D& width = results.getWidth();
256  widthHistos_[key]->setBinContent(bin, width.value());
257  widthHistos_[key]->setBinError(bin, width.error());
258  }
259 }
std::map< std::string, MonitorElement * > widthHistos_
diMuonMassBias::fitOutputs fitLineShape(TH1 *hist, const bool &fitBackground=false) const
Log< level::Error, false > LogError
Definition: ME.h:11
diMuonMassBias::fitOutputs fitBWTimesCB(TH1 *hist) const
key
prepare the HTCondor submission files and eventually submit them
Log< level::Warning, true > LogPrint
double value() const
Definition: Measurement1D.h:25
std::map< std::string, MonitorElement * > meanHistos_
results
Definition: mysort.py:8
double error() const
Definition: Measurement1D.h:27
Log< level::Warning, false > LogWarning

◆ fitAndFillProfile()

void DiMuonMassBiasClient::fitAndFillProfile ( std::pair< std::string, MonitorElement *>  toHarvest,
DQMStore::IBooker iBooker 
)
private

Definition at line 120 of file DiMuonMassBiasClient.cc.

References newFWLiteAna::bin, dqm::implementation::IBooker::bookProfile(), debugMode_, Measurement1D::error(), fitBackground_, fitBWTimesCB(), fitLineShape(), submitPVResolutionJobs::key, LogDebug, meanProfiles_, mysort::results, dqm::implementation::NavigatorBase::setCurrentFolder(), runGCPTkAlMap::title, TopFolder_, useBWtimesCB_, Measurement1D::value(), ApeEstimator_cff::width, widthProfiles_, LaserClient_cfi::xaxis, TrackerOfflineValidation_Dqm_cff::xmax, TrackerOfflineValidation_Dqm_cff::xmin, compareTotals::xtitle, and compareTotals::ytitle.

Referenced by dqmEndJob().

123 {
124  const auto& key = toHarvest.first;
125  const auto& ME = toHarvest.second;
126 
127  if (debugMode_)
128  edm::LogPrint("DiMuonMassBiasClient") << "dealing with key: " << key << std::endl;
129 
130  if (ME == nullptr) {
131  edm::LogError("DiMuonMassBiasClient") << "could not find MonitorElement for key: " << key << std::endl;
132  return;
133  }
134 
135  const auto& title = ME->getTitle();
136  const auto& xtitle = ME->getAxisTitle(1);
137  const auto& ytitle = ME->getAxisTitle(2);
138 
139  const auto& nxbins = ME->getNbinsX();
140  const auto& xmin = ME->getAxisMin(1);
141  const auto& xmax = ME->getAxisMax(1);
142 
143  TProfile* p_mean = new TProfile(("Mean" + key).c_str(),
144  (title + ";" + xtitle + ";#LT M_{#mu^{-}#mu^{+}} #GT [GeV]").c_str(),
145  nxbins,
146  xmin,
147  xmax,
148  "g");
149 
150  TProfile* p_width = new TProfile(
151  ("Sigma" + key).c_str(), (title + ";" + xtitle + ";#sigma of " + ytitle).c_str(), nxbins, xmin, xmax, "g");
152 
153  p_mean->Sumw2();
154  p_width->Sumw2();
155 
156  TH2F* bareHisto = ME->getTH2F();
157  for (int bin = 1; bin <= nxbins; bin++) {
158  const auto& xaxis = bareHisto->GetXaxis();
159  const auto& low_edge = xaxis->GetBinLowEdge(bin);
160  const auto& high_edge = xaxis->GetBinUpEdge(bin);
161 
162  if (debugMode_)
163  edm::LogPrint("DiMuonMassBiasClient") << "dealing with bin: " << bin << " range: (" << std::setprecision(2)
164  << low_edge << "," << std::setprecision(2) << high_edge << ")";
165 
166  TH1D* Proj = bareHisto->ProjectionY(Form("%s_proj_%i", key.c_str(), bin), bin, bin);
167  Proj->SetTitle(Form("%s #in (%.2f,%.2f), bin: %i", Proj->GetTitle(), low_edge, high_edge, bin));
168 
170 
171  if (results.isInvalid()) {
172  edm::LogWarning("DiMuonMassBiasClient") << "the current bin has invalid data" << std::endl;
173  continue;
174  }
175 
176  // fill the mean profiles
177  const Measurement1D& bias = results.getBias();
178 
179  // ============================================= DISCLAIMER ================================================
180  // N.B. this is sort of a hack in order to fill arbitrarily both central values and error bars of a TProfile.
181  // Choosing the option "g" in the constructor the bin error will be 1/sqrt(W(j)), where W(j) is the sum of weights.
182  // Filling the sum of weights with the 1 / err^2, the bin error automatically becomes "err".
183  // In order to avoid the central value to be shifted, that's divided by 1 / err^2 as well.
184  // For more information, please consult the https://root.cern.ch/doc/master/classTProfile.html
185 
186  p_mean->SetBinContent(bin, bias.value() / (bias.error() * bias.error()));
187  p_mean->SetBinEntries(bin, 1. / (bias.error() * bias.error()));
188 
189  if (debugMode_)
190  LogDebug("DiMuonBassBiasClient") << " Bin: " << bin << " value: " << bias.value() << " from profile ( "
191  << p_mean->GetBinContent(bin) << ") - error: " << bias.error()
192  << " from profile ( " << p_mean->GetBinError(bin) << " )";
193 
194  // fill the width profiles
195  const Measurement1D& width = results.getWidth();
196 
197  // see discussion above
198  p_width->SetBinContent(bin, width.value() / (width.error() * width.error()));
199  p_width->SetBinEntries(bin, 1. / (width.error() * width.error()));
200  }
201 
202  // now book the profiles
203  iBooker.setCurrentFolder(TopFolder_ + "/DiMuonMassBiasMonitor/MassBias/Profiles");
204  MonitorElement* meanToBook = iBooker.bookProfile(p_mean->GetName(), p_mean);
205  meanProfiles_.insert({key, meanToBook});
206 
207  MonitorElement* sigmaToBook = iBooker.bookProfile(p_width->GetName(), p_width);
208  widthProfiles_.insert({key, sigmaToBook});
209 
210  delete p_mean;
211  delete p_width;
212 }
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
diMuonMassBias::fitOutputs fitLineShape(TH1 *hist, const bool &fitBackground=false) const
const std::string TopFolder_
Log< level::Error, false > LogError
std::map< std::string, MonitorElement * > meanProfiles_
std::map< std::string, MonitorElement * > widthProfiles_
Definition: ME.h:11
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())
Definition: DQMStore.h:408
diMuonMassBias::fitOutputs fitBWTimesCB(TH1 *hist) const
key
prepare the HTCondor submission files and eventually submit them
Log< level::Warning, true > LogPrint
double value() const
Definition: Measurement1D.h:25
results
Definition: mysort.py:8
double error() const
Definition: Measurement1D.h:27
Log< level::Warning, false > LogWarning
#define LogDebug(id)

◆ fitBWTimesCB()

diMuonMassBias::fitOutputs DiMuonMassBiasClient::fitBWTimesCB ( TH1 *  hist) const
private

Definition at line 421 of file DiMuonMassBiasClient.cc.

References alignmentValidation::c1, compareTotals::hist, instance, diMuonMassBias::minimumHits, multiplicitycorr_cfi::xMax, and photonAnalyzer_cfi::xMin.

Referenced by fitAndFillHisto(), and fitAndFillProfile().

423 {
424  if (hist->GetEntries() < diMuonMassBias::minimumHits) {
425  edm::LogWarning("DiMuonMassBiasClient") << " Input histogram:" << hist->GetName() << " has not enough entries ("
426  << hist->GetEntries() << ") for a meaningful Voigtian fit!\n"
427  << "Skipping!";
428 
429  return diMuonMassBias::fitOutputs(Measurement1D(0., 0.), Measurement1D(0., 0.));
430  }
431 
432  TCanvas* c1 = new TCanvas();
433  if (debugMode_) {
434  c1->Clear();
435  c1->SetLeftMargin(0.15);
436  c1->SetRightMargin(0.10);
437  }
438 
439  // silence messages
440  RooMsgService::instance().setGlobalKillBelow(RooFit::FATAL);
441 
442  Double_t xMean = 91.1876;
443  Double_t xMin = hist->GetXaxis()->GetXmin();
444  Double_t xMax = hist->GetXaxis()->GetXmax();
445 
446  if (debugMode_) {
447  edm::LogPrint("DiMuonMassBiasClient") << "fitting range: (" << xMin << "-" << xMax << ")" << std::endl;
448  }
449 
450  double sigma(2.);
451  double sigmaMin(0.1);
452  double sigmaMax(10.);
453 
454  double sigma2(0.1);
455  double sigma2Min(0.);
456  double sigma2Max(10.);
457 
458  std::unique_ptr<FitWithRooFit> fitter = std::make_unique<FitWithRooFit>();
459 
460  bool useChi2(false);
461 
462  fitter->useChi2_ = useChi2;
463  fitter->initMean(xMean, xMin, xMax);
464  fitter->initSigma(sigma, sigmaMin, sigmaMax);
465  fitter->initSigma2(sigma2, sigma2Min, sigma2Max);
466  fitter->initAlpha(1.5, 0.05, 10.);
467  fitter->initN(1, 0.01, 100.);
468  fitter->initFGCB(0.4, 0., 1.);
469  fitter->initGamma(2.4952, 0., 10.);
470  fitter->gamma()->setConstant(kTRUE);
471  fitter->initMean2(0., -20., 20.);
472  fitter->mean2()->setConstant(kTRUE);
473  fitter->initSigma(1.2, 0., 5.);
474  fitter->initAlpha(1.5, 0.05, 10.);
475  fitter->initN(1, 0.01, 100.);
476  fitter->initExpCoeffA0(-1., -10., 10.);
477  fitter->initExpCoeffA1(0., -10., 10.);
478  fitter->initExpCoeffA2(0., -2., 2.);
479  fitter->initFsig(0.9, 0., 1.);
480  fitter->initA0(0., -10., 10.);
481  fitter->initA1(0., -10., 10.);
482  fitter->initA2(0., -10., 10.);
483  fitter->initA3(0., -10., 10.);
484  fitter->initA4(0., -10., 10.);
485  fitter->initA5(0., -10., 10.);
486  fitter->initA6(0., -10., 10.);
487 
488  fitter->fit(hist, "breitWignerTimesCB", "exponential", xMin, xMax, false);
489 
490  TString histName = hist->GetName();
491 
492  if (debugMode_) {
493  c1->Print("fit_debug" + histName + ".pdf");
494  }
495  delete c1;
496 
497  Measurement1D resultM(fitter->mean()->getVal(), fitter->mean()->getError());
498  Measurement1D resultW(fitter->sigma()->getVal(), fitter->sigma()->getError());
499 
500  return diMuonMassBias::fitOutputs(resultM, resultW);
501 }
static PFTauRenderPlugin instance
Log< level::Warning, true > LogPrint
static constexpr int minimumHits
Log< level::Warning, false > LogWarning

◆ fitLineShape()

diMuonMassBias::fitOutputs DiMuonMassBiasClient::fitLineShape ( TH1 *  hist,
const bool &  fitBackground = false 
) const
private

Definition at line 286 of file DiMuonMassBiasClient.cc.

References b, alignmentValidation::c1, crystalball(), DiMuonMassBiasClient_cfi::fitBackground, compareTotals::hist, instance, SiStripPI::mean, diMuonMassBias::minimumHits, alignCSCRings::s, ApeEstimator_cff::width, TrackerOfflineValidation_Dqm_cff::xmax, and TrackerOfflineValidation_Dqm_cff::xmin.

Referenced by fitAndFillHisto(), and fitAndFillProfile().

288 {
289  if (hist->GetEntries() < diMuonMassBias::minimumHits) {
290  edm::LogWarning("DiMuonMassBiasClient") << " Input histogram:" << hist->GetName() << " has not enough entries ("
291  << hist->GetEntries() << ") for a meaningful Voigtian fit!\n"
292  << "Skipping!";
293 
294  return diMuonMassBias::fitOutputs(Measurement1D(0., 0.), Measurement1D(0., 0.));
295  }
296 
297  TCanvas* c1 = new TCanvas();
298  if (debugMode_) {
299  c1->Clear();
300  c1->SetLeftMargin(0.15);
301  c1->SetRightMargin(0.10);
302  }
303 
304  // silence messages
305  RooMsgService::instance().setGlobalKillBelow(RooFit::FATAL);
306 
307  Double_t xmin = hist->GetXaxis()->GetXmin();
308  Double_t xmax = hist->GetXaxis()->GetXmax();
309 
310  if (debugMode_) {
311  edm::LogPrint("DiMuonMassBiasClient") << "fitting range: (" << xmin << "-" << xmax << ")" << std::endl;
312  }
313 
314  RooRealVar InvMass("InvMass", "di-muon mass M(#mu^{+}#mu^{-}) [GeV]", xmin, xmax);
315  std::unique_ptr<RooPlot> frame{InvMass.frame()};
316  RooDataHist datahist("datahist", "datahist", InvMass, RooFit::Import(*hist));
317  datahist.plotOn(frame.get());
318 
319  // parameters of the Voigtian
320  RooRealVar mean("#mu", "mean", meanConfig_[0], meanConfig_[1], meanConfig_[2]); //90.0, 60.0, 120.0 (for Z)
321  RooRealVar width("width", "width", widthConfig_[0], widthConfig_[1], widthConfig_[2]); // 5.0, 0.0, 120.0 (for Z)
322  RooRealVar sigma("#sigma", "sigma", sigmaConfig_[0], sigmaConfig_[1], sigmaConfig_[2]); // 5.0, 0.0, 120.0 (for Z)
323  RooVoigtian voigt("voigt", "voigt", InvMass, mean, width, sigma);
324 
325  // parameters of the Crystal-ball
326  RooRealVar peakCB("peakCB", "peakCB", meanConfig_[0], meanConfig_[1], meanConfig_[2]);
327  RooRealVar sigmaCB("#sigma", "sigma", sigmaConfig_[0], sigmaConfig_[1], sigmaConfig_[2]);
328  RooRealVar alphaCB("#alpha", "alpha", 1., 0., 10.);
329  RooRealVar nCB("n", "n", 1., 0., 100.);
330  RooCBShape crystalball("crystalball", "crystalball", InvMass, peakCB, sigmaCB, alphaCB, nCB);
331 
332  // for the simple background fit
333  RooRealVar lambda("#lambda", "slope", 0., -50., 50.);
334  RooExponential expo("expo", "expo", InvMass, lambda);
335 
336  // for the more refined background fit
337  RooRealVar exp_alpha("#alpha", "alpha", 40.0, 20.0, 160.0);
338  RooRealVar exp_beta("#beta", "beta", 0.05, 0.0, 2.0);
339  RooRealVar exp_gamma("#gamma", "gamma", 0.02, 0.0, 0.1);
340  RooRealVar exp_peak("peak", "peak", meanConfig_[0]);
341  RooCMSShape exp_pdf("exp_pdf", "bkg shape", InvMass, exp_alpha, exp_beta, exp_gamma, exp_peak);
342 
343  // define the signal and background fractions
344  RooRealVar b("N_{b}", "Number of background events", 0, hist->GetEntries() / 10.);
345  RooRealVar s("N_{s}", "Number of signal events", 0, hist->GetEntries());
346 
347  if (fitBackground) {
348  RooArgList listPdf;
349  if (useRooCBShape_) {
350  if (useRooCMSShape_) {
351  // crystal-ball + CMS-shape fit
352  listPdf.add(crystalball);
353  listPdf.add(exp_pdf);
354  } else {
355  // crystal-ball + exponential fit
356  listPdf.add(crystalball);
357  listPdf.add(expo);
358  }
359  } else {
360  if (useRooCMSShape_) {
361  // voigtian + CMS-shape fit
362  listPdf.add(voigt);
363  listPdf.add(exp_pdf);
364  } else {
365  // voigtian + exponential fit
366  listPdf.add(voigt);
367  listPdf.add(expo);
368  }
369  }
370 
371  RooAddPdf fullModel("fullModel", "Signal + Background Model", listPdf, RooArgList(s, b));
372  fullModel.fitTo(datahist, RooFit::PrintLevel(-1));
373  fullModel.plotOn(frame.get(), RooFit::LineColor(kRed));
374  if (useRooCMSShape_) {
375  fullModel.plotOn(frame.get(), RooFit::Components(exp_pdf), RooFit::LineStyle(kDashed)); //Other option
376  } else {
377  fullModel.plotOn(frame.get(), RooFit::Components(expo), RooFit::LineStyle(kDashed)); //Other option
378  }
379  fullModel.paramOn(frame.get(), RooFit::Layout(0.65, 0.90, 0.90));
380  } else {
381  if (useRooCBShape_) {
382  // use crystal-ball for a fit-only signal
383  crystalball.fitTo(datahist, RooFit::PrintLevel(-1));
384  crystalball.plotOn(frame.get(), RooFit::LineColor(kRed)); //this will show fit overlay on canvas
385  crystalball.paramOn(frame.get(),
386  RooFit::Layout(0.65, 0.90, 0.90)); //this will display the fit parameters on canvas
387  } else {
388  // use voigtian for a fit-only signal
389  voigt.fitTo(datahist, RooFit::PrintLevel(-1));
390  voigt.plotOn(frame.get(), RooFit::LineColor(kRed)); //this will show fit overlay on canvas
391  voigt.paramOn(frame.get(), RooFit::Layout(0.65, 0.90, 0.90)); //this will display the fit parameters on canvas
392  }
393  }
394 
395  // Redraw data on top and print / store everything
396  datahist.plotOn(frame.get());
397  frame->GetYaxis()->SetTitle("n. of events");
398  TString histName = hist->GetName();
399  frame->SetName("frame" + histName);
400  frame->SetTitle(hist->GetTitle());
401  frame->Draw();
402 
403  if (debugMode_) {
404  c1->Print("fit_debug" + histName + ".pdf");
405  }
406  delete c1;
407 
408  float mass_mean = useRooCBShape_ ? peakCB.getVal() : mean.getVal();
409  float mass_sigma = useRooCBShape_ ? sigmaCB.getVal() : sigma.getVal();
410 
411  float mass_mean_err = useRooCBShape_ ? peakCB.getError() : mean.getError();
412  float mass_sigma_err = useRooCBShape_ ? sigmaCB.getError() : sigma.getError();
413 
414  Measurement1D resultM(mass_mean, mass_mean_err);
415  Measurement1D resultW(mass_sigma, mass_sigma_err);
416 
417  return diMuonMassBias::fitOutputs(resultM, resultW);
418 }
static PFTauRenderPlugin instance
Log< level::Warning, true > LogPrint
double b
Definition: hdecay.h:120
static constexpr int minimumHits
double crystalball(double *x, double *par)
Definition: myFunctions.cc:98
Log< level::Warning, false > LogWarning

◆ getMEsToHarvest()

void DiMuonMassBiasClient::getMEsToHarvest ( DQMStore::IGetter igetter)
private

Definition at line 101 of file DiMuonMassBiasClient.cc.

References dqm::implementation::IGetter::get(), harvestTargets_, MEtoHarvest_, AlCaHLTBitMon_QueryRunRegistry::string, and TopFolder_.

Referenced by dqmEndJob().

103 {
104  std::string inFolder = TopFolder_ + "/DiMuonMassBiasMonitor/MassBias/";
105 
106  //loop on the list of histograms to harvest
107  for (const auto& hname : MEtoHarvest_) {
108  MonitorElement* toHarvest = iGetter.get(inFolder + hname);
109 
110  if (toHarvest == nullptr) {
111  edm::LogError("DiMuonMassBiasClient") << "could not find input MonitorElement: " << inFolder + hname << std::endl;
112  continue;
113  }
114 
115  harvestTargets_.insert({hname, toHarvest});
116  }
117 }
const std::string TopFolder_
Log< level::Error, false > LogError
std::map< std::string, MonitorElement * > harvestTargets_
std::vector< std::string > MEtoHarvest_

Member Data Documentation

◆ debugMode_

const bool DiMuonMassBiasClient::debugMode_
private

Definition at line 95 of file DiMuonMassBiasClient.h.

Referenced by DiMuonMassBiasClient(), fitAndFillHisto(), and fitAndFillProfile().

◆ fitBackground_

const bool DiMuonMassBiasClient::fitBackground_
private

Definition at line 92 of file DiMuonMassBiasClient.h.

Referenced by fitAndFillHisto(), and fitAndFillProfile().

◆ harvestTargets_

std::map<std::string, MonitorElement*> DiMuonMassBiasClient::harvestTargets_
private

Definition at line 113 of file DiMuonMassBiasClient.h.

Referenced by bookMEs(), dqmEndJob(), and getMEsToHarvest().

◆ meanConfig_

float DiMuonMassBiasClient::meanConfig_[3]
private

Definition at line 97 of file DiMuonMassBiasClient.h.

Referenced by DiMuonMassBiasClient().

◆ meanHistos_

std::map<std::string, MonitorElement*> DiMuonMassBiasClient::meanHistos_
private

Definition at line 105 of file DiMuonMassBiasClient.h.

Referenced by bookMEs(), and fitAndFillHisto().

◆ meanProfiles_

std::map<std::string, MonitorElement*> DiMuonMassBiasClient::meanProfiles_
private

Definition at line 109 of file DiMuonMassBiasClient.h.

Referenced by fitAndFillProfile().

◆ MEtoHarvest_

std::vector<std::string> DiMuonMassBiasClient::MEtoHarvest_
private

Definition at line 102 of file DiMuonMassBiasClient.h.

Referenced by getMEsToHarvest().

◆ sigmaConfig_

float DiMuonMassBiasClient::sigmaConfig_[3]
private

Definition at line 99 of file DiMuonMassBiasClient.h.

Referenced by DiMuonMassBiasClient().

◆ TopFolder_

const std::string DiMuonMassBiasClient::TopFolder_
private

Definition at line 89 of file DiMuonMassBiasClient.h.

Referenced by bookMEs(), fitAndFillProfile(), and getMEsToHarvest().

◆ useBWtimesCB_

const bool DiMuonMassBiasClient::useBWtimesCB_
private

Definition at line 91 of file DiMuonMassBiasClient.h.

Referenced by fitAndFillHisto(), and fitAndFillProfile().

◆ useRooCBShape_

const bool DiMuonMassBiasClient::useRooCBShape_
private

Definition at line 93 of file DiMuonMassBiasClient.h.

◆ useRooCMSShape_

const bool DiMuonMassBiasClient::useRooCMSShape_
private

Definition at line 94 of file DiMuonMassBiasClient.h.

◆ useTH1s_

const bool DiMuonMassBiasClient::useTH1s_
private

Definition at line 90 of file DiMuonMassBiasClient.h.

Referenced by dqmEndJob().

◆ widthConfig_

float DiMuonMassBiasClient::widthConfig_[3]
private

Definition at line 98 of file DiMuonMassBiasClient.h.

Referenced by DiMuonMassBiasClient().

◆ widthHistos_

std::map<std::string, MonitorElement*> DiMuonMassBiasClient::widthHistos_
private

Definition at line 106 of file DiMuonMassBiasClient.h.

Referenced by bookMEs(), and fitAndFillHisto().

◆ widthProfiles_

std::map<std::string, MonitorElement*> DiMuonMassBiasClient::widthProfiles_
private

Definition at line 110 of file DiMuonMassBiasClient.h.

Referenced by fitAndFillProfile().