Belle II Software development
RefHistObject.cc
1
2/**************************************************************************
3 * basf2 (Belle II Analysis Software Framework) *
4 * Author: The Belle II Collaboration *
5 * *
6 * See git log for contributors and copyright holders. *
7 * This file is licensed under LGPL-3.0, see LICENSE.md. *
8 **************************************************************************/
9#include "dqm/core/RefHistObject.h"
10
11using namespace Belle2;
12
14{
15 auto orgref = m_refHist.get();
16 if (m_refCopy != nullptr) {
17 // if it exists already (->second call), we clear it only.
18 // thus the pointer is not changed!
19 m_refCopy->Reset();
20 m_refCopy->Add(orgref);
21 } else {
22 // is orgref is nullptr (not existing yet), make a copy of the original histogram
23 // but, as we want to have scaling, we may need to change the type to the next larger float.
24 if (orgref && (orgref->InheritsFrom("TH1C") or orgref->InheritsFrom("TH1S"))) {
25 m_refCopy = std::make_unique<TH1F>(); // we want it a float for better scaling
26 orgref->Copy(*m_refCopy.get());
27 } else if (orgref && (orgref->InheritsFrom("TH1I") or orgref->InheritsFrom("TH1L"))) {
28 m_refCopy = std::make_unique<TH1D>(); // we want it a float for better scaling
29 orgref->Copy(*m_refCopy.get());
30 } else {
31 // keep TProfile, TH1F or TH1D
32 m_refCopy = std::unique_ptr<TH1> (static_cast<TH1*>(orgref->Clone()));
33 }
34 m_refCopy->SetLineStyle(2);
35 m_refCopy->SetLineColor(3);
36 m_refCopy->SetFillColor(0);
37 m_refCopy->SetStats(kFALSE);
38 }
39}
40
42{
43 // make a new copy
45 // now the caller can modify (e.g. scale) the copy without interference
46 return m_refCopy.get();
47}
std::unique_ptr< TH1 > m_refCopy
Pointer to scaled reference histogram.
std::unique_ptr< TH1 > m_refHist
Pointer to reference histogram.
TH1 * getReference(void)
Get reference histogram pointer the pointer is to a freshly made copy, which can be modified by the c...
void makeReferenceCopy(void)
Make a copy of the underlying reference histogram which can be used for scaling.
Abstract base class for different kinds of events.