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 final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices 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 ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
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...
 
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 * > meanProfiles_
 
std::vector< std::string > MEtoHarvest_
 
float sigmaConfig_ [3]
 
const std::string TopFolder_
 
const bool useRooCBShape_
 
const bool useRooCMSShape_
 
float widthConfig_ [3]
 
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 20 of file DiMuonMassBiasClient.cc.

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

21  : TopFolder_(iConfig.getParameter<std::string>("FolderName")),
22  fitBackground_(iConfig.getParameter<bool>("fitBackground")),
23  useRooCBShape_(iConfig.getParameter<bool>("useRooCBShape")),
24  useRooCMSShape_(iConfig.getParameter<bool>("useRooCMSShape")),
25  debugMode_(iConfig.getParameter<bool>("debugMode")),
26  MEtoHarvest_(iConfig.getParameter<std::vector<std::string>>("MEtoHarvest"))
27 //-----------------------------------------------------------------------------------
28 {
29  edm::LogInfo("DiMuonMassBiasClient") << "DiMuonMassBiasClient::Constructing DiMuonMassBiasClient ";
30 
31  // fill the parameters for the fit
32  edm::ParameterSet fit_par = iConfig.getParameter<edm::ParameterSet>("fit_par");
36 
37  if (debugMode_) {
38  edm::LogPrint("DiMuonMassBiasClient")
39  << "mean: " << meanConfig_[0] << " (" << meanConfig_[1] << "," << meanConfig_[2] << ") " << std::endl;
40  edm::LogPrint("DiMuonMassBiasClient")
41  << "width: " << widthConfig_[0] << " (" << widthConfig_[1] << "," << widthConfig_[2] << ")" << std::endl;
42  edm::LogPrint("DiMuonMassBiasClient")
43  << "sigma: " << sigmaConfig_[0] << " (" << sigmaConfig_[1] << "," << sigmaConfig_[2] << ")" << std::endl;
44  }
45 }
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 48 of file DiMuonMassBiasClient.cc.

50 {
51  edm::LogInfo("DiMuonMassBiasClient") << "DiMuonMassBiasClient::Deleting DiMuonMassBiasClient ";
52 }
Log< level::Info, false > LogInfo

Member Function Documentation

◆ beginJob()

void DiMuonMassBiasClient::beginJob ( void  )
overrideprotectedvirtual

BeginJob.

Reimplemented from edm::one::EDProducerBase.

Definition at line 55 of file DiMuonMassBiasClient.cc.

57 {
58  edm::LogInfo("DiMuonMassBiasClient") << "DiMuonMassBiasClient::beginJob done";
59 }
Log< level::Info, false > LogInfo

◆ beginRun()

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

BeginRun.

Definition at line 62 of file DiMuonMassBiasClient.cc.

64 {
65  edm::LogInfo("DiMuonMassBiasClient") << "DiMuonMassBiasClient:: Begining of Run";
66 }
Log< level::Info, false > LogInfo

◆ bookMEs()

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

book MEs

Definition at line 69 of file DiMuonMassBiasClient.cc.

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

Referenced by dqmEndJob().

71 {
72  iBooker.setCurrentFolder(TopFolder_ + "/DiMuonMassBiasMonitor/MassBias/Profiles");
73  for (const auto& [key, ME] : harvestTargets_) {
74  if (ME == nullptr) {
75  edm::LogError("DiMuonMassBiasClient") << "could not find MonitorElement for key: " << key << std::endl;
76  continue;
77  }
78 
79  const auto& title = ME->getTitle();
80  const auto& xtitle = ME->getAxisTitle(1);
81  const auto& ytitle = ME->getAxisTitle(2);
82 
83  const auto& nxbins = ME->getNbinsX();
84  const auto& xmin = ME->getAxisMin(1);
85  const auto& xmax = ME->getAxisMax(1);
86 
87  MonitorElement* meanToBook =
88  iBooker.book1D(("Mean" + key), (title + ";" + xtitle + ";" + ytitle), nxbins, xmin, xmax);
89  meanProfiles_.insert({key, meanToBook});
90 
91  MonitorElement* sigmaToBook =
92  iBooker.book1D(("Sigma" + key), (title + ";" + xtitle + ";" + "#sigma of " + ytitle), nxbins, xmin, xmax);
93  widthProfiles_.insert({key, sigmaToBook});
94  }
95 }
const std::string TopFolder_
Log< level::Error, false > LogError
std::map< std::string, MonitorElement * > harvestTargets_
std::map< std::string, MonitorElement * > meanProfiles_
std::map< std::string, MonitorElement * > widthProfiles_
Definition: ME.h:11

◆ dqmEndJob()

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

EndJob.

Implements DQMEDHarvester.

Definition at line 117 of file DiMuonMassBiasClient.cc.

References newFWLiteAna::bin, bookMEs(), debugMode_, Measurement1D::error(), fitLineShape(), getMEsToHarvest(), harvestTargets_, crabWrapper::key, meanProfiles_, mysort::results, Measurement1D::value(), ApeEstimator_cff::width, widthProfiles_, and LaserClient_cfi::xaxis.

119 {
120  edm::LogInfo("DiMuonMassBiasClient") << "DiMuonMassBiasClient::endLuminosityBlock";
121 
122  getMEsToHarvest(igetter);
123  bookMEs(ibooker);
124 
125  for (const auto& [key, ME] : harvestTargets_) {
126  if (debugMode_)
127  edm::LogPrint("DiMuonMassBiasClient") << "dealing with key: " << key << std::endl;
128  TH2F* bareHisto = ME->getTH2F();
129  for (int bin = 1; bin <= ME->getNbinsX(); bin++) {
130  const auto& xaxis = bareHisto->GetXaxis();
131  const auto& low_edge = xaxis->GetBinLowEdge(bin);
132  const auto& high_edge = xaxis->GetBinUpEdge(bin);
133 
134  if (debugMode_)
135  edm::LogPrint("DiMuonMassBiasClient") << "dealing with bin: " << bin << " range: (" << std::setprecision(2)
136  << low_edge << "," << std::setprecision(2) << high_edge << ")";
137  TH1D* Proj = bareHisto->ProjectionY(Form("%s_proj_%i", key.c_str(), bin), bin, bin);
138  Proj->SetTitle(Form("%s #in (%.2f,%.2f), bin: %i", Proj->GetTitle(), low_edge, high_edge, bin));
139 
141 
142  if (results.isInvalid()) {
143  edm::LogWarning("DiMuonMassBiasClient") << "the current bin has invalid data" << std::endl;
144  continue;
145  }
146 
147  // fill the mean profiles
148  const Measurement1D& bias = results.getBias();
149  meanProfiles_[key]->setBinContent(bin, bias.value());
150  meanProfiles_[key]->setBinError(bin, bias.error());
151 
152  // fill the width profiles
153  const Measurement1D& width = results.getWidth();
154  widthProfiles_[key]->setBinContent(bin, width.value());
155  widthProfiles_[key]->setBinError(bin, width.error());
156  }
157  }
158 }
void getMEsToHarvest(DQMStore::IGetter &igetter)
diMuonMassBias::fitOutputs fitLineShape(TH1 *hist, const bool &fitBackground=false) const
std::map< std::string, MonitorElement * > harvestTargets_
std::map< std::string, MonitorElement * > meanProfiles_
std::map< std::string, MonitorElement * > widthProfiles_
Definition: ME.h:11
Log< level::Warning, true > LogPrint
Log< level::Info, false > LogInfo
double value() const
Definition: Measurement1D.h:25
void bookMEs(DQMStore::IBooker &ibooker)
book MEs
results
Definition: mysort.py:8
double error() const
Definition: Measurement1D.h:27
Log< level::Warning, false > LogWarning

◆ fillDescriptions()

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

Definition at line 296 of file DiMuonMassBiasClient.cc.

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

298 {
300  desc.add<std::string>("FolderName", "DiMuonMassBiasMonitor");
301  desc.add<bool>("fitBackground", false);
302  desc.add<bool>("useRooCMSShape", false);
303  desc.add<bool>("useRooCBShape", false);
304  desc.add<bool>("debugMode", false);
305 
307  fit_par.add<std::vector<double>>("mean_par",
310  std::numeric_limits<float>::max()}); // par = mean
311 
312  fit_par.add<std::vector<double>>("width_par",
315  std::numeric_limits<float>::max()}); // par = width
316 
317  fit_par.add<std::vector<double>>("sigma_par",
320  std::numeric_limits<float>::max()}); // par = sigma
321 
322  desc.add<edm::ParameterSetDescription>("fit_par", fit_par);
323 
324  desc.add<std::vector<std::string>>("MEtoHarvest",
325  {"DiMuMassVsMuMuPhi",
326  "DiMuMassVsMuMuEta",
327  "DiMuMassVsMuPlusPhi",
328  "DiMuMassVsMuPlusEta",
329  "DiMuMassVsMuMinusPhi",
330  "DiMuMassVsMuMinusEta",
331  "DiMuMassVsMuMuDeltaEta",
332  "DiMuMassVsCosThetaCS"});
333  descriptions.addWithDefaultLabel(desc);
334 }
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)

◆ fitLineShape()

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

Definition at line 161 of file DiMuonMassBiasClient.cc.

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

Referenced by dqmEndJob().

163 {
164  if (hist->GetEntries() < diMuonMassBias::minimumHits) {
165  edm::LogWarning("DiMuonMassBiasClient") << " Input histogram:" << hist->GetName() << " has not enough entries ("
166  << hist->GetEntries() << ") for a meaningful Voigtian fit!\n"
167  << "Skipping!";
168 
169  return diMuonMassBias::fitOutputs(Measurement1D(0., 0.), Measurement1D(0., 0.));
170  }
171 
172  TCanvas* c1 = new TCanvas();
173  if (debugMode_) {
174  c1->Clear();
175  c1->SetLeftMargin(0.15);
176  c1->SetRightMargin(0.10);
177  }
178 
179  // silence messages
180  RooMsgService::instance().setGlobalKillBelow(RooFit::FATAL);
181 
182  Double_t xmin = hist->GetXaxis()->GetXmin();
183  Double_t xmax = hist->GetXaxis()->GetXmax();
184 
185  if (debugMode_) {
186  edm::LogPrint("DiMuonMassBiasClient") << "fitting range: (" << xmin << "-" << xmax << ")" << std::endl;
187  }
188 
189  RooRealVar InvMass("InvMass", "di-muon mass M(#mu^{+}#mu^{-}) [GeV]", xmin, xmax);
190  std::unique_ptr<RooPlot> frame{InvMass.frame()};
191  RooDataHist datahist("datahist", "datahist", InvMass, RooFit::Import(*hist));
192  datahist.plotOn(frame.get());
193 
194  // parameters of the Voigtian
195  RooRealVar mean("#mu", "mean", meanConfig_[0], meanConfig_[1], meanConfig_[2]); //90.0, 60.0, 120.0 (for Z)
196  RooRealVar width("width", "width", widthConfig_[0], widthConfig_[1], widthConfig_[2]); // 5.0, 0.0, 120.0 (for Z)
197  RooRealVar sigma("#sigma", "sigma", sigmaConfig_[0], sigmaConfig_[1], sigmaConfig_[2]); // 5.0, 0.0, 120.0 (for Z)
198  RooVoigtian voigt("voigt", "voigt", InvMass, mean, width, sigma);
199 
200  // parameters of the Crystal-ball
201  RooRealVar peakCB("peakCB", "peakCB", meanConfig_[0], meanConfig_[1], meanConfig_[2]);
202  RooRealVar sigmaCB("#sigma", "sigma", sigmaConfig_[0], sigmaConfig_[1], sigmaConfig_[2]);
203  RooRealVar alphaCB("#alpha", "alpha", 1., 0., 10.);
204  RooRealVar nCB("n", "n", 1., 0., 100.);
205  RooCBShape crystalball("crystalball", "crystalball", InvMass, peakCB, sigmaCB, alphaCB, nCB);
206 
207  // for the simple background fit
208  RooRealVar lambda("#lambda", "slope", 0., -50., 50.);
209  RooExponential expo("expo", "expo", InvMass, lambda);
210 
211  // for the more refined background fit
212  RooRealVar exp_alpha("#alpha", "alpha", 40.0, 20.0, 160.0);
213  RooRealVar exp_beta("#beta", "beta", 0.05, 0.0, 2.0);
214  RooRealVar exp_gamma("#gamma", "gamma", 0.02, 0.0, 0.1);
215  RooRealVar exp_peak("peak", "peak", meanConfig_[0]);
216  RooCMSShape exp_pdf("exp_pdf", "bkg shape", InvMass, exp_alpha, exp_beta, exp_gamma, exp_peak);
217 
218  // define the signal and background fractions
219  RooRealVar b("N_{b}", "Number of background events", 0, hist->GetEntries() / 10.);
220  RooRealVar s("N_{s}", "Number of signal events", 0, hist->GetEntries());
221 
222  if (fitBackground_) {
223  RooArgList listPdf;
224  if (useRooCBShape_) {
225  if (useRooCMSShape_) {
226  // crystal-ball + CMS-shape fit
227  listPdf.add(crystalball);
228  listPdf.add(exp_pdf);
229  } else {
230  // crystal-ball + exponential fit
231  listPdf.add(crystalball);
232  listPdf.add(expo);
233  }
234  } else {
235  if (useRooCMSShape_) {
236  // voigtian + CMS-shape fit
237  listPdf.add(voigt);
238  listPdf.add(exp_pdf);
239  } else {
240  // voigtian + exponential fit
241  listPdf.add(voigt);
242  listPdf.add(expo);
243  }
244  }
245 
246  RooAddPdf fullModel("fullModel", "Signal + Background Model", listPdf, RooArgList(s, b));
247  fullModel.fitTo(datahist, RooFit::PrintLevel(-1));
248  fullModel.plotOn(frame.get(), RooFit::LineColor(kRed));
249  if (useRooCMSShape_) {
250  fullModel.plotOn(frame.get(), RooFit::Components(exp_pdf), RooFit::LineStyle(kDashed)); //Other option
251  } else {
252  fullModel.plotOn(frame.get(), RooFit::Components(expo), RooFit::LineStyle(kDashed)); //Other option
253  }
254  fullModel.paramOn(frame.get(), RooFit::Layout(0.65, 0.90, 0.90));
255  } else {
256  if (useRooCBShape_) {
257  // use crystal-ball for a fit-only signal
258  crystalball.fitTo(datahist, RooFit::PrintLevel(-1));
259  crystalball.plotOn(frame.get(), RooFit::LineColor(kRed)); //this will show fit overlay on canvas
260  crystalball.paramOn(frame.get(),
261  RooFit::Layout(0.65, 0.90, 0.90)); //this will display the fit parameters on canvas
262  } else {
263  // use voigtian for a fit-only signal
264  voigt.fitTo(datahist, RooFit::PrintLevel(-1));
265  voigt.plotOn(frame.get(), RooFit::LineColor(kRed)); //this will show fit overlay on canvas
266  voigt.paramOn(frame.get(), RooFit::Layout(0.65, 0.90, 0.90)); //this will display the fit parameters on canvas
267  }
268  }
269 
270  // Redraw data on top and print / store everything
271  datahist.plotOn(frame.get());
272  frame->GetYaxis()->SetTitle("n. of events");
273  TString histName = hist->GetName();
274  frame->SetName("frame" + histName);
275  frame->SetTitle(hist->GetTitle());
276  frame->Draw();
277 
278  if (debugMode_) {
279  c1->Print("fit_debug" + histName + ".pdf");
280  }
281  delete c1;
282 
283  float mass_mean = useRooCBShape_ ? peakCB.getVal() : mean.getVal();
284  float mass_sigma = useRooCBShape_ ? sigmaCB.getVal() : sigma.getVal();
285 
286  float mass_mean_err = useRooCBShape_ ? peakCB.getError() : mean.getError();
287  float mass_sigma_err = useRooCBShape_ ? sigmaCB.getError() : sigma.getError();
288 
289  Measurement1D resultM(mass_mean, mass_mean_err);
290  Measurement1D resultW(mass_sigma, mass_sigma_err);
291 
292  return diMuonMassBias::fitOutputs(resultM, resultW);
293 }
static PFTauRenderPlugin instance
Log< level::Warning, true > LogPrint
double b
Definition: hdecay.h:118
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 98 of file DiMuonMassBiasClient.cc.

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

Referenced by dqmEndJob().

100 {
101  std::string inFolder = TopFolder_ + "/DiMuonMassBiasMonitor/MassBias/";
102 
103  //loop on the list of histograms to harvest
104  for (const auto& hname : MEtoHarvest_) {
105  MonitorElement* toHarvest = iGetter.get(inFolder + hname);
106 
107  if (toHarvest == nullptr) {
108  edm::LogError("DiMuonMassBiasClient") << "could not find input MonitorElement: " << inFolder + hname << std::endl;
109  continue;
110  }
111 
112  harvestTargets_.insert({hname, toHarvest});
113  }
114 }
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 90 of file DiMuonMassBiasClient.h.

Referenced by DiMuonMassBiasClient(), and dqmEndJob().

◆ fitBackground_

const bool DiMuonMassBiasClient::fitBackground_
private

Definition at line 87 of file DiMuonMassBiasClient.h.

◆ harvestTargets_

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

Definition at line 104 of file DiMuonMassBiasClient.h.

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

◆ meanConfig_

float DiMuonMassBiasClient::meanConfig_[3]
private

Definition at line 92 of file DiMuonMassBiasClient.h.

Referenced by DiMuonMassBiasClient().

◆ meanProfiles_

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

Definition at line 100 of file DiMuonMassBiasClient.h.

Referenced by bookMEs(), and dqmEndJob().

◆ MEtoHarvest_

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

Definition at line 97 of file DiMuonMassBiasClient.h.

Referenced by getMEsToHarvest().

◆ sigmaConfig_

float DiMuonMassBiasClient::sigmaConfig_[3]
private

Definition at line 94 of file DiMuonMassBiasClient.h.

Referenced by DiMuonMassBiasClient().

◆ TopFolder_

const std::string DiMuonMassBiasClient::TopFolder_
private

Definition at line 86 of file DiMuonMassBiasClient.h.

Referenced by bookMEs(), and getMEsToHarvest().

◆ useRooCBShape_

const bool DiMuonMassBiasClient::useRooCBShape_
private

Definition at line 88 of file DiMuonMassBiasClient.h.

◆ useRooCMSShape_

const bool DiMuonMassBiasClient::useRooCMSShape_
private

Definition at line 89 of file DiMuonMassBiasClient.h.

◆ widthConfig_

float DiMuonMassBiasClient::widthConfig_[3]
private

Definition at line 93 of file DiMuonMassBiasClient.h.

Referenced by DiMuonMassBiasClient().

◆ widthProfiles_

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

Definition at line 101 of file DiMuonMassBiasClient.h.

Referenced by bookMEs(), and dqmEndJob().