CMS 3D CMS Logo

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

#include <L1TOccupancyClient.h>

Inheritance diagram for L1TOccupancyClient:
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

 L1TOccupancyClient (const edm::ParameterSet &ps)
 Constructor. More...
 
 ~L1TOccupancyClient () 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 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)
 

Protected Member Functions

void book (DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
 
void dqmEndJob (DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter) override
 
void dqmEndLuminosityBlock (DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override
 
double xySymmetry (const edm::ParameterSet &ps, std::string test_name, std::vector< std::pair< int, double > > &deadChannels, std::vector< std::pair< int, double > > &statDev, bool &enoughStats)
 
- 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

int compareWithStrip (TH2F *histo, std::string test, int binStrip, int nBins, int axis, double avg, const edm::ParameterSet &ps, std::vector< std::pair< int, double > > &deadChannels)
 
double getAvrg (TH2F *h2f, std::string test, int axis, int nBins, int binStrip, int avrgMode)
 
void getBinCoordinateOnAxisWithValue (TH2F *h2f, double content, int &coord, int axis)
 
void printDeadChannels (const std::vector< std::pair< int, double > > &deadChannels, TH2F *h2f, const std::vector< std::pair< int, double > > &statDev, std::string test_name)
 

Private Attributes

TFile * file_
 
L1TOccupancyClientHistogramServicehservice_
 
std::map< std::string, MonitorElement * > meCertification
 
std::map< std::string, MonitorElement * > meDifferential
 
std::map< std::string, MonitorElement * > meResults
 
std::vector< edm::ParameterSet * > mValidTests
 
edm::ParameterSet parameters_
 
std::vector< edm::ParameterSettests_
 
bool verbose_
 

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
 
- 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 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 29 of file L1TOccupancyClient.h.

Constructor & Destructor Documentation

◆ L1TOccupancyClient()

L1TOccupancyClient::L1TOccupancyClient ( const edm::ParameterSet ps)

Constructor.

Definition at line 28 of file L1TOccupancyClient.cc.

References gather_cfg::cout, and edm::ParameterSet::getParameter().

28  {
29  // Get parameters
30  parameters_ = ps;
31  verbose_ = ps.getParameter<bool>("verbose");
32  tests_ = ps.getParameter<std::vector<ParameterSet> >("testParams");
33 
34  if (verbose_) {
35  cout << "[L1TOccupancyClient:] Called constructor" << endl;
36  }
37 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::ParameterSet parameters_
std::vector< edm::ParameterSet > tests_

◆ ~L1TOccupancyClient()

L1TOccupancyClient::~L1TOccupancyClient ( )
override

Destructor.

Definition at line 43 of file L1TOccupancyClient.cc.

References gather_cfg::cout.

43  {
44  if (verbose_) {
45  cout << "[L1TOccupancyClient:] Called destructor" << endl;
46  }
47 }

Member Function Documentation

◆ book()

void L1TOccupancyClient::book ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter 
)
protected

Definition at line 56 of file L1TOccupancyClient.cc.

References dqm::implementation::IBooker::book1D(), dqm::implementation::IBooker::book2D(), gather_cfg::cout, edm::ParameterSet::getParameter(), L1TOccupancyClient_cfi::histPath, visualization-live-secondInstance_cfg::m, dqm::implementation::NavigatorBase::setCurrentFolder(), L1TBPTX_cfi::testName, and runGCPTkAlMap::title.

56  {
58 
59  if (verbose_) {
60  cout << "[L1TOccupancyClient:] Called beginRun" << endl;
61 
62  // In verbose mode we will produce an extra output file with several tests
63  file_ = TFile::Open("DQM_L1TOccupancyClient_Snapshots_LS.root", "RECREATE");
64  }
65 
66  ibooker.setCurrentFolder("L1T/L1TOccupancy/");
67  //dbe_->setCurrentFolder("L1T/L1TOccupancy/Results");
68  //dbe_->setCurrentFolder("L1T/L1TOccupancy/BadCellValues");
69  //dbe_->setCurrentFolder("L1T/L1TOccupancy/Certification");
70 
71  // Loop over all tests in defined
72  for (vector<ParameterSet>::iterator it = tests_.begin(); it != tests_.end(); it++) {
73  // If the test algorithm is XYSymmetry we create the necessary histograms
74  if ((*it).getUntrackedParameter<string>("algoName", "XYSymmetry") == "XYSymmetry") {
75  // Getting Parameters for the test
76  string testName = (*it).getParameter<string>("testName");
77  ParameterSet algoParameters = (*it).getParameter<ParameterSet>("algoParams");
78  string histPath = algoParameters.getParameter<string>("histPath");
79 
80  if (verbose_) {
81  cout << "[L1TOccupancyClient:] Monitored histogram path: " << histPath << endl;
82 
83  // Creating verbose file directory structure
84  // test_name/test_name_Results,
85  // test_name/test_name_Histos
86  // TDirectory *td = file_->mkdir(testName.c_str() ,testName.c_str());
87  //FIXME: sub never used gcc361 warning
88  //TDirectory *sub = td ->mkdir((testName+"_Results").c_str(),string("_Results").c_str());
89 
90  //sub = td->mkdir((testName+"_Histos").c_str() ,(testName+"_Histos").c_str());
91  //sub = td->mkdir((testName+"_Histos_AllLS").c_str(),(testName+"_Histos_AllLS").c_str());
92  }
93 
94  // Load histograms in service instance
95  if (hservice_->loadHisto(igetter, testName, histPath)) {
96  // Mask channels specified in python file
97  hservice_->setMaskedBins(testName, algoParameters.getParameter<vector<ParameterSet> >("maskedAreas"));
98 
99  // Book MonitorElements
100  // * Test results
101  ibooker.setCurrentFolder("L1T/L1TOccupancy/Results");
102  string title = testName;
104  m->setTitle(title);
105  m->Reset();
106  meResults[title] = m;
107 
108  // * Which cells are masked as bad
109  ibooker.setCurrentFolder("L1T/L1TOccupancy/HistogramDiff");
110  title = testName;
112  m->Reset();
113  m->setTitle(title);
115 
116  // * Fraction of bad cells
117  ibooker.setCurrentFolder("L1T/L1TOccupancy/Certification");
118  title = testName;
119  m = ibooker.book1D(title.c_str(), title.c_str(), 2500, -.5, 2500. - .5);
120  m->setTitle(title);
122 
123  mValidTests.push_back(&(*it));
124  }
125  }
126  }
127 }
std::map< std::string, MonitorElement * > meCertification
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
TH2F * loadHisto(DQMStore::IGetter &igetter, std::string test, std::string histo)
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
void setMaskedBins(std::string test, const std::vector< edm::ParameterSet > &mask)
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
std::map< std::string, MonitorElement * > meDifferential
edm::ParameterSet parameters_
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
std::vector< edm::ParameterSet * > mValidTests
std::map< std::string, MonitorElement * > meResults
std::vector< edm::ParameterSet > tests_
L1TOccupancyClientHistogramService * hservice_

◆ compareWithStrip()

int L1TOccupancyClient::compareWithStrip ( TH2F *  histo,
std::string  test,
int  binStrip,
int  nBins,
int  axis,
double  avg,
const edm::ParameterSet ps,
std::vector< std::pair< int, double > > &  deadChannels 
)
private

Definition at line 723 of file L1TOccupancyClient.cc.

References funct::abs(), gather_cfg::cout, MillePedeFileConverter_cfg::e, edm::ParameterSet::getUntrackedParameter(), mps_fire::i, infinity, and submitPVValidationJobs::params.

730  {
731  int dead = 0;
732 
733  //
734  if (iAxis == 1) {
735  // Get and set parameters for working curves
736  TF1* fmuup = new TF1("fmuup", "TMath::Log(TMath::PoissonI(x,[0])/TMath::PoissonI(x,[1]))", -10000., 10000.);
737  TF1* fmulow = new TF1("fmulow", "TMath::Log(TMath::PoissonI(x,[0])/TMath::PoissonI(x,[1]))", -10000., 10000.);
738  fmuup->SetParameter(0, iAvg * iPS.getUntrackedParameter<double>("factorup", 2.0));
739  fmuup->SetParameter(1, iAvg);
740  fmulow->SetParameter(0, iAvg * iPS.getUntrackedParameter<double>("factorlow", 0.1));
741  fmulow->SetParameter(1, iAvg);
742 
743  TF1* fchi = new TF1("fchi", "[0]*x**2+[1]*x+[2]", 0., 1500.);
744 
745  // Evaluate sigma up
746  vector<double> defaultChi2up;
747  defaultChi2up.push_back(5.45058e-05);
748  defaultChi2up.push_back(0.268756);
749  defaultChi2up.push_back(-11.7515);
750 
751  vector<double> params = iPS.getUntrackedParameter<vector<double> >("params_chi2_up", defaultChi2up);
752  for (unsigned int i = 0; i < params.size(); i++) {
753  fchi->SetParameter(i, params[i]);
754  }
755  double sigma_up = fchi->Eval(iAvg);
756 
757  // Evaluate sigma low
758  vector<double> defaultChi2low;
759  defaultChi2low.push_back(4.11095e-05);
760  defaultChi2low.push_back(0.577451);
761  defaultChi2low.push_back(-10.378);
762 
763  params = iPS.getUntrackedParameter<vector<double> >("params_chi2_low", defaultChi2low);
764  for (unsigned int i = 0; i < params.size(); i++) {
765  fchi->SetParameter(i, params[i]);
766  }
767  double sigma_low = fchi->Eval(iAvg);
768 
769  if (verbose_) {
770  cout << "binstrip= " << iBinStrip << ", sigmaup= " << sigma_up << ", sigmalow= " << sigma_low << endl;
771  }
772 
773  for (int i = 1; i <= iNBins; i++) {
774  if (verbose_) {
775  cout << " " << i << " binContent: up:" << fmuup->Eval(iHist->GetBinContent(iBinStrip, i))
776  << " low: " << fmulow->Eval(iHist->GetBinContent(iBinStrip, i)) << endl;
777  }
778 
779  // Evaluate chi2 for cells
780  double muup = fmuup->Eval(iHist->GetBinContent(iBinStrip, i));
781  double mulow = fmulow->Eval(iHist->GetBinContent(iBinStrip, i));
782 
783  // If channel is masked -> set it to value -1
784  if (hservice_->isMasked(iTestName, iBinStrip, i)) {
785  oChannels.push_back(pair<int, double>(iHist->GetBin(iBinStrip, i), -1.0));
786  }
787  //else perform test
788  else if (muup > sigma_up || mulow > sigma_low ||
789  ((fabs(muup) == std::numeric_limits<double>::infinity()) &&
790  (fabs(mulow) == std::numeric_limits<double>::infinity()))) {
791  dead++;
792  oChannels.push_back(
793  pair<int, double>(iHist->GetBin(iBinStrip, i), abs(iHist->GetBinContent(iBinStrip, i) - iAvg) / iAvg));
794  }
795  }
796  }
797  //
798  else if (iAxis == 2) {
799  //get and set parameters for working curves
800  TF1* fmuup = new TF1("fmuup", "TMath::Log(TMath::PoissonI(x,[0])/TMath::PoissonI(x,[1]))", -10000., 10000.);
801  TF1* fmulow = new TF1("fmulow", "TMath::Log(TMath::PoissonI(x,[0])/TMath::PoissonI(x,[1]))", -10000., 10000.);
802  fmuup->SetParameter(0, iAvg * iPS.getUntrackedParameter<double>("factorup", 2.0));
803  fmuup->SetParameter(1, iAvg);
804  fmulow->SetParameter(0, iAvg * iPS.getUntrackedParameter<double>("factorlow", 0.1));
805  fmulow->SetParameter(1, iAvg);
806 
807  TF1* fchi = new TF1("fchi", "[0]*x**2+[1]*x+[2]", 0., 1500.);
808 
809  // Evaluate sigma up
810  vector<double> defaultChi2up;
811  defaultChi2up.push_back(5.45058e-05);
812  defaultChi2up.push_back(0.268756);
813  defaultChi2up.push_back(-11.7515);
814 
815  vector<double> params = iPS.getUntrackedParameter<vector<double> >("params_chi2_up", defaultChi2up);
816  for (unsigned int i = 0; i < params.size(); i++) {
817  fchi->SetParameter(i, params[i]);
818  }
819  double sigma_up = fchi->Eval(iAvg);
820 
821  // Evaluate sigma low
822  vector<double> defaultChi2low;
823  defaultChi2low.push_back(4.11095e-05);
824  defaultChi2low.push_back(0.577451);
825  defaultChi2low.push_back(-10.378);
826 
827  params = iPS.getUntrackedParameter<vector<double> >("params_chi2_low", defaultChi2low);
828  for (unsigned int i = 0; i < params.size(); i++) {
829  fchi->SetParameter(i, params[i]);
830  }
831  double sigma_low = fchi->Eval(iAvg);
832 
833  if (verbose_) {
834  cout << "binstrip= " << iBinStrip << ", sigmaup= " << sigma_up << ", sigmalow= " << sigma_low << endl;
835  }
836 
837  for (int i = 1; i <= iNBins; i++) {
838  if (verbose_) {
839  cout << " " << i << " binContent: up:" << fmuup->Eval(iHist->GetBinContent(i, iBinStrip))
840  << " low: " << fmulow->Eval(iHist->GetBinContent(i, iBinStrip)) << endl;
841  }
842 
843  //evaluate chi2 for cells
844  double muup = fmuup->Eval(iHist->GetBinContent(i, iBinStrip));
845  double mulow = fmulow->Eval(iHist->GetBinContent(i, iBinStrip));
846 
847  //if channel is masked -> set it to value -1
848  if (hservice_->isMasked(iTestName, i, iBinStrip)) {
849  oChannels.push_back(pair<int, double>(iHist->GetBin(iBinStrip, i), -1.0));
850  }
851  //else perform test
852  else if (muup > sigma_up || mulow > sigma_low ||
853  ((fabs(muup) == std::numeric_limits<double>::infinity()) &&
854  (fabs(mulow) == std::numeric_limits<double>::infinity()))) {
855  dead++;
856  oChannels.push_back(
857  pair<int, double>(iHist->GetBin(i, iBinStrip), abs(iHist->GetBinContent(i, iBinStrip) - iAvg) / iAvg));
858  }
859  }
860  } else {
861  if (verbose_) {
862  cout << "invalid axis" << endl;
863  }
864  }
865 
866  return dead;
867 }
const double infinity
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool isMasked(std::string test, int x, int y)
L1TOccupancyClientHistogramService * hservice_

◆ dqmEndJob()

void L1TOccupancyClient::dqmEndJob ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter 
)
overrideprotectedvirtual

Implements DQMEDHarvester.

Definition at line 136 of file L1TOccupancyClient.cc.

References HLT_2022v15_cff::algo_name, newFWLiteAna::bin, gather_cfg::cout, edm::ParameterSet::getParameter(), L1TOccupancyClient_cfi::histPath, mps_fire::i, and str.

136  {
137  book(ibooker, igetter);
138 
139  if (verbose_) {
140  cout << "[L1TOccupancyClient:] Called endRun()" << endl;
141  }
142 
143  // Loop over every test in python
144  for (std::vector<ParameterSet*>::iterator it = mValidTests.begin(); it != mValidTests.end(); it++) {
145  ParameterSet& test = (**it);
146  string algo_name = test.getUntrackedParameter<string>("algoName", "XYSymmetry");
147  string test_name = test.getParameter<string>("testName");
148 
149  if (verbose_) {
150  cout << "[L1TOccupancyClient:] Starting calculations for: " << algo_name << " on: " << test_name << endl;
151  }
152 
153  if (algo_name == "XYSymmetry") {
154  ParameterSet ps = (**it).getParameter<ParameterSet>("algoParams");
155  string histPath = ps.getParameter<string>("histPath");
156 
157  vector<pair<int, double> > deadChannels;
158  vector<pair<int, double> > statDev;
159  bool enoughStats = false;
160 
161  // Make final block
162  hservice_->updateHistogramEndRun(test_name);
163 
164  // Perform the test
165  double dead = xySymmetry(ps, test_name, deadChannels, statDev, enoughStats);
166  stringstream str;
167  str << test_name << "_cumu_LS_EndRun";
168 
169  if (verbose_) {
170  TH2F* cumulative_save = (TH2F*)hservice_->getDifferentialHistogram(test_name)->Clone(str.str().c_str());
171 
172  cumulative_save->SetTitle(str.str().c_str());
173 
174  TDirectory* td = file_->GetDirectory(test_name.c_str());
175 
176  td->cd(string(test_name + "_Histos_AllLS").c_str());
177 
178  cumulative_save->Write();
179  }
180  // If we have enough statistics, we can write test result
181  if (enoughStats) {
182  // Make the result histogram
183  printDeadChannels(deadChannels, meResults[test_name]->getTH2F(), statDev, test_name);
184 
185  if (verbose_) {
186  TH2F* cumulative_save = (TH2F*)hservice_->getDifferentialHistogram(test_name)->Clone(str.str().c_str());
187  cumulative_save->SetTitle(str.str().c_str());
188  TDirectory* td = file_->GetDirectory(("DQM_L1TOccupancyClient_Snapshots_LS.root:/" + test_name).c_str());
189  td->cd(string(test_name + "_Histos").c_str());
190  cumulative_save->Write();
191 
192  // save the result histo
193  TH2F* h2f = meResults[test_name]->getTH2F();
194  stringstream str2;
195  str2 << test_name << "_result_LS_EndRun";
196  TH2F* dead_save = (TH2F*)h2f->Clone(str2.str().c_str());
197 
198  td->cd(string(test_name + "_Results").c_str());
199  dead_save->SetTitle(str2.str().c_str());
200  dead_save->Write();
201  }
202 
203  // Updating test results
204  meDifferential[test_name]->Reset();
205  meDifferential[test_name]->getTH2F()->Add(hservice_->getDifferentialHistogram(test_name));
206 
207  vector<int> lsCertification = hservice_->getLSCertification(test_name);
208 
209  // Fill fraction of dead channels
210  for (unsigned int i = 0; i < lsCertification.size(); i++) {
211  int bin = meCertification[test_name]->getTH1()->FindBin(lsCertification[i]);
212  meCertification[test_name]->getTH1()->SetBinContent(bin, 1 - dead);
213  }
214 
215  // Reset differential histo
216  hservice_->resetHisto(test_name);
217 
218  if (verbose_) {
219  cout << "Now we have enough statstics for " << test_name << endl;
220  }
221 
222  } else {
223  if (verbose_) {
224  cout << "we don't have enough statstics for " << test_name << endl;
225  }
226 
227  // Getting LS which this test monitored
228  vector<int> lsCertification = hservice_->getLSCertification(test_name);
229 
230  // Fill fraction of dead channels
231  for (unsigned int i = 0; i < lsCertification.size(); i++) {
232  int bin = meCertification[test_name]->getTH1()->FindBin(lsCertification[i]);
233  meCertification[test_name]->getTH1()->SetBinContent(bin, -1);
234  }
235  }
236  } else {
237  if (verbose_) {
238  cout << "No valid algorithm" << std::endl;
239  }
240  }
241  }
242 
243  if (verbose_) {
244  file_->Close();
245  }
246 
247  delete hservice_;
248 }
std::map< std::string, MonitorElement * > meCertification
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< int > getLSCertification(std::string iHistName)
void printDeadChannels(const std::vector< std::pair< int, double > > &deadChannels, TH2F *h2f, const std::vector< std::pair< int, double > > &statDev, std::string test_name)
double xySymmetry(const edm::ParameterSet &ps, std::string test_name, std::vector< std::pair< int, double > > &deadChannels, std::vector< std::pair< int, double > > &statDev, bool &enoughStats)
void book(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
std::map< std::string, MonitorElement * > meDifferential
std::vector< edm::ParameterSet * > mValidTests
#define str(s)
std::map< std::string, MonitorElement * > meResults
L1TOccupancyClientHistogramService * hservice_

◆ dqmEndLuminosityBlock()

void L1TOccupancyClient::dqmEndLuminosityBlock ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter,
const edm::LuminosityBlock lumiSeg,
const edm::EventSetup c 
)
overrideprotectedvirtual

Reimplemented from DQMEDHarvester.

Definition at line 265 of file L1TOccupancyClient.cc.

References HLT_2022v15_cff::algo_name, newFWLiteAna::bin, gather_cfg::cout, edm::ParameterSet::getParameter(), L1TOccupancyClient_cfi::histPath, mps_fire::i, edm::LuminosityBlockBase::id(), edm::LuminosityBlockID::luminosityBlock(), and str.

268  {
269  book(ibooker, igetter);
270 
271  int eventLS = lumiSeg.id().luminosityBlock();
272 
273  if (verbose_) {
274  cout << "[L1TOccupancyClient:] Called endLuminosityBlock()" << endl;
275  cout << "[L1TOccupancyClient:] Lumisection: " << eventLS << endl;
276  }
277 
278  // Loop over every test in python
279  for (std::vector<ParameterSet*>::const_iterator it = mValidTests.begin(); it != mValidTests.end(); it++) {
280  ParameterSet& test = (**it);
281  string algo_name = test.getUntrackedParameter<string>("algoName", "XYSymmetry");
282  string test_name = test.getParameter<string>("testName");
283 
284  if (verbose_) {
285  cout << "[L1TOccupancyClient:] Starting calculations for " << algo_name << " on:" << test_name << endl;
286  }
287 
288  if (algo_name == "XYSymmetry") {
289  ParameterSet ps = (**it).getParameter<ParameterSet>("algoParams");
290  string histPath = ps.getParameter<string>("histPath");
291 
292  vector<pair<int, double> > deadChannels;
293  vector<pair<int, double> > statDev;
294  bool enoughStats = false;
295 
296  // Update histo's data with data of this LS
297  hservice_->updateHistogramEndLS(igetter, test_name, histPath, eventLS);
298 
299  // Perform the test
300  double dead = xySymmetry(ps, test_name, deadChannels, statDev, enoughStats);
301  stringstream str;
302  str << test_name << "_cumu_LS_" << eventLS;
303 
304  if (verbose_) {
305  TH2F* cumulative_save = (TH2F*)hservice_->getDifferentialHistogram(test_name)->Clone(str.str().c_str());
306  cumulative_save->SetTitle(str.str().c_str());
307  TDirectory* td = file_->GetDirectory(test_name.c_str());
308  td->cd(string(test_name + "_Histos_AllLS").c_str());
309  cumulative_save->Write();
310  }
311 
312  // If we have enough statistics, we can write test result
313  if (enoughStats) {
314  // Make the result histogram
315  printDeadChannels(deadChannels, meResults[test_name]->getTH2F(), statDev, test_name);
316 
317  if (verbose_) {
318  TH2F* cumulative_save = (TH2F*)hservice_->getDifferentialHistogram(test_name)->Clone(str.str().c_str());
319  cumulative_save->SetTitle(str.str().c_str());
320  TDirectory* td = file_->GetDirectory(("DQM_L1TOccupancyClient_Snapshots_LS.root:/" + test_name).c_str());
321  td->cd(string(test_name + "_Histos").c_str());
322  cumulative_save->Write();
323 
324  // save the result histo
325  TH2F* h2f = meResults[test_name]->getTH2F();
326  stringstream str2;
327  str2 << test_name << "_result_LS_" << eventLS;
328  TH2F* dead_save = (TH2F*)h2f->Clone(str2.str().c_str());
329 
330  td->cd(string(test_name + "_Results").c_str());
331  dead_save->SetTitle(str2.str().c_str());
332  dead_save->Write();
333  }
334 
335  // Updating test results
336  meDifferential[test_name]->Reset();
337  meDifferential[test_name]->getTH2F()->Add(hservice_->getDifferentialHistogram(test_name));
338 
339  vector<int> lsCertification = hservice_->getLSCertification(test_name);
340 
341  // Fill fraction of dead channels
342  for (unsigned int i = 0; i < lsCertification.size(); i++) {
343  int bin = meCertification[test_name]->getTH1()->FindBin(lsCertification[i]);
344  meCertification[test_name]->getTH1()->SetBinContent(bin, 1 - dead);
345  }
346 
347  // Reset differential histo
348  hservice_->resetHisto(test_name);
349 
350  if (verbose_) {
351  cout << "Now we have enough statstics for " << test_name << endl;
352  }
353 
354  } else {
355  if (verbose_) {
356  cout << "we don't have enough statstics for " << test_name << endl;
357  }
358  }
359  } else {
360  if (verbose_) {
361  cout << "No valid algorithm" << std::endl;
362  }
363  }
364  }
365 }
std::map< std::string, MonitorElement * > meCertification
LuminosityBlockNumber_t luminosityBlock() const
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::vector< int > getLSCertification(std::string iHistName)
void printDeadChannels(const std::vector< std::pair< int, double > > &deadChannels, TH2F *h2f, const std::vector< std::pair< int, double > > &statDev, std::string test_name)
double xySymmetry(const edm::ParameterSet &ps, std::string test_name, std::vector< std::pair< int, double > > &deadChannels, std::vector< std::pair< int, double > > &statDev, bool &enoughStats)
void book(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter)
LuminosityBlockID id() const
std::map< std::string, MonitorElement * > meDifferential
void updateHistogramEndLS(DQMStore::IGetter &igetter, std::string test, std::string histo, int iLS)
std::vector< edm::ParameterSet * > mValidTests
#define str(s)
std::map< std::string, MonitorElement * > meResults
L1TOccupancyClientHistogramService * hservice_

◆ getAvrg()

double L1TOccupancyClient::getAvrg ( TH2F *  h2f,
std::string  test,
int  axis,
int  nBins,
int  binStrip,
int  avrgMode 
)
private

Definition at line 597 of file L1TOccupancyClient.cc.

References gather_cfg::cout, timingPdfMaker::histo, mps_fire::i, amptDefault_cfi::proj, and contentValuesCheck::values.

597  {
598  double avg = 0.0;
599  TH1D* proj = nullptr;
600  TH2F* histo = new TH2F(*iHist);
601 
602  std::vector<double> values;
603  int marked;
604 
605  if (iAxis == 1) {
606  switch (iAvgMode) {
607  // arithmetic average
608  case 1:
609  marked = hservice_->maskBins(iTestName, histo, iBinStrip, iAxis);
610  proj = histo->ProjectionX();
611  avg = proj->GetBinContent(iBinStrip) / (iNBins - marked);
612  break;
613 
614  // median
615  case 2:
616  marked = hservice_->maskBins(iTestName, histo, iBinStrip, iAxis);
617  proj = histo->ProjectionY("_py", iBinStrip, iBinStrip);
618  for (int i = 0; i < iNBins; i++) {
619  values.push_back(proj->GetBinContent(i + 1));
620  }
621  avg = TMath::Median(iNBins, &values[0]);
622  break;
623  default:
624  if (verbose_) {
625  cout << "Invalid averaging mode!" << endl;
626  }
627  break;
628  }
629  } else if (iAxis == 2) {
630  switch (iAvgMode) {
631  // arithmetic average
632  case 1:
633  marked = hservice_->maskBins(iTestName, histo, iBinStrip, iAxis);
634  proj = histo->ProjectionY();
635  avg = proj->GetBinContent(iBinStrip) / (iNBins - marked);
636  break;
637  // median
638  case 2:
639  marked = hservice_->maskBins(iTestName, histo, iBinStrip, iAxis);
640  proj = histo->ProjectionX("_px", iBinStrip, iBinStrip);
641  for (int i = 0; i < iNBins; i++) {
642  values.push_back(proj->GetBinContent(i + 1));
643  }
644 
645  avg = TMath::Median(iNBins, &values[0]);
646  break;
647  default:
648  if (verbose_) {
649  cout << "invalid averaging mode!" << endl;
650  }
651  break;
652  }
653  } else {
654  if (verbose_) {
655  cout << "invalid axis" << endl;
656  }
657  }
658  delete proj;
659  delete histo;
660  return avg;
661 }
int maskBins(std::string test, TH2F *histo, int strip, int axis)
L1TOccupancyClientHistogramService * hservice_

◆ getBinCoordinateOnAxisWithValue()

void L1TOccupancyClient::getBinCoordinateOnAxisWithValue ( TH2F *  h2f,
double  content,
int &  coord,
int  axis 
)
private

Definition at line 878 of file L1TOccupancyClient.cc.

References x.

878  {
879  int nBinsX = iHist->GetNbinsX(); //actual number of bins x
880  int nBinsY = iHist->GetNbinsY(); //actual number of bins y
881 
882  if (iAxis == 1) {
883  int global = iHist->GetXaxis()->FindFixBin(iValue);
884 
885  // If parameter exceeds axis' value: set to maximum number of bins in x-axis
886  if (global > nBinsX * nBinsY) {
887  global = iHist->GetXaxis()->GetLast();
888  }
889 
890  // Get coordinates of bin
891  int y, z;
892  iHist->GetBinXYZ(global, oBinCoordinate, y, z);
893  } else if (iAxis == 2) {
894  int global = iHist->GetYaxis()->FindFixBin(iValue);
895 
896  // If parameter exceeds axis' value: set to maximum number of bins in x-axis
897  if (global > nBinsX * nBinsY) {
898  global = iHist->GetYaxis()->GetLast();
899  }
900 
901  // Get coordinates of bin
902  int x, z;
903  iHist->GetBinXYZ(global, x, oBinCoordinate, z);
904  }
905 }

◆ printDeadChannels()

void L1TOccupancyClient::printDeadChannels ( const std::vector< std::pair< int, double > > &  deadChannels,
TH2F *  h2f,
const std::vector< std::pair< int, double > > &  statDev,
std::string  test_name 
)
private

Definition at line 672 of file L1TOccupancyClient.cc.

References newFWLiteAna::bin, gather_cfg::cout, trackerHitRTTI::vector, and x.

675  {
676  // Reset the dead channels histogram
677  oHistDeadChannels->Reset();
678  if (verbose_) {
679  cout << "suspect or masked channels of " << iTestName << ": ";
680  }
681 
682  int x, y, z;
683 
684  // put all bad (value=1) and masked (value=-1) cells in histo
685  for (std::vector<pair<int, double> >::const_iterator it = iDeadChannels.begin(); it != iDeadChannels.end(); it++) {
686  int bin = (*it).first;
687  oHistDeadChannels->GetBinXYZ(bin, x, y, z);
688 
689  if (hservice_->isMasked(iTestName, x, y)) {
690  oHistDeadChannels->SetBinContent(bin, -1);
691  if (verbose_) {
692  printf("(%4i,%4i) Masked\n", x, y);
693  }
694  } else {
695  oHistDeadChannels->SetBinContent(bin, 1);
696  if (verbose_) {
697  printf("(%4i,%4i) Failed test\n", x, y);
698  }
699  }
700  }
701 
702  if (verbose_) {
703  cout << "total number of suspect channels: " << (iDeadChannels.size() - (hservice_->getNBinsMasked(iTestName)))
704  << endl;
705  }
706 }
bool isMasked(std::string test, int x, int y)
L1TOccupancyClientHistogramService * hservice_

◆ xySymmetry()

double L1TOccupancyClient::xySymmetry ( const edm::ParameterSet ps,
std::string  test_name,
std::vector< std::pair< int, double > > &  deadChannels,
std::vector< std::pair< int, double > > &  statDev,
bool &  enoughStats 
)
protected

Definition at line 388 of file L1TOccupancyClient.cc.

References gather_cfg::cout, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), mps_fire::i, createfilelist::int, dqmiolumiharvest::j, dqmdumpme::k, METSkim_cff::Max, and submitPVValidationJobs::params.

392  {
393  // Getting differential histogram for this this thes
394  TH2F* diffHist = hservice_->getDifferentialHistogram(iTestName);
395 
396  int pAxis = ps.getUntrackedParameter<int>("axis", 1);
397  int pAverageMode = ps.getUntrackedParameter<int>("averageMode", 2); // 1=arith. mean, 2=median
398  int nBinsX = diffHist->GetNbinsX(); // actual number of bins x
399  int nBinsY = diffHist->GetNbinsY(); // actual number of bins y
400 
401  // Axis==1 : Means symmetry axis is vertical
402  if (pAxis == 1) {
403  int maxBinStrip, centralBinStrip; // x-coordinate of strips
404 
405  maxBinStrip = nBinsX;
406 
407  // If takeCenter=true determine central bin of the pAxis
408  // If takeCenter=false determine the bin to use based user input
409  if (ps.getUntrackedParameter<bool>("takeCenter", true)) {
410  centralBinStrip = nBinsX / 2 + 1;
411  } else {
412  double pAxisSymmetryValue = ps.getParameter<double>("axisSymmetryValue");
413  getBinCoordinateOnAxisWithValue(diffHist, pAxisSymmetryValue, centralBinStrip, 1);
414  }
415 
416  // Assuming odd number of strips --> first comparison is middle strip to itself
417  int upBinStrip = centralBinStrip;
418  int lowBinStrip = centralBinStrip;
419 
420  // If even number decrease lowBinstrip by one
421  if (nBinsX % 2 == 0) {
422  lowBinStrip--;
423  }
424 
425  // Do we have enough statistics? Min(Max(strip_i,strip_j))>threshold
426  std::unique_ptr<double[]> maxAvgs(new double[maxBinStrip - upBinStrip + 1]);
427 
428  int nActualStrips = 0; //number of strips that are not fully masked
429  for (int i = 0, j = upBinStrip, k = lowBinStrip; j <= maxBinStrip; i++, j++, k--) {
430  double avg1 = getAvrg(diffHist, iTestName, pAxis, nBinsY, j, pAverageMode);
431  double avg2 = getAvrg(diffHist, iTestName, pAxis, nBinsY, k, pAverageMode);
432 
433  // Protection for when both strips are masked
434  if (!hservice_->isStripMasked(iTestName, j, pAxis) && !hservice_->isStripMasked(iTestName, k, pAxis)) {
435  maxAvgs[i] = TMath::Max(avg1, avg2);
436  nActualStrips++;
437  }
438  }
439 
440  vector<double> defaultMu0up;
441  defaultMu0up.push_back(13.7655);
442  defaultMu0up.push_back(184.742);
443  defaultMu0up.push_back(50735.3);
444  defaultMu0up.push_back(-97.6793);
445 
446  TF1 tf("myFunc", "[0]*(TMath::Log(x*[1]+[2]))+[3]", 10., 11000.);
447  vector<double> params = ps.getUntrackedParameter<vector<double> >("params_mu0_up", defaultMu0up);
448  for (unsigned int i = 0; i < params.size(); i++) {
449  tf.SetParameter(i, params[i]);
450  }
451  int statsup = (int)tf.Eval(hservice_->getNBinsHistogram(iTestName));
452 
453  vector<double> defaultMu0low;
454  defaultMu0low.push_back(2.19664);
455  defaultMu0low.push_back(1.94546);
456  defaultMu0low.push_back(-99.3263);
457  defaultMu0low.push_back(19.388);
458 
459  params = ps.getUntrackedParameter<vector<double> >("params_mu0_low", defaultMu0low);
460  for (unsigned int i = 0; i < params.size(); i++) {
461  tf.SetParameter(i, params[i]);
462  }
463  int statslow = (int)tf.Eval(hservice_->getNBinsHistogram(iTestName));
464 
465  if (verbose_) {
466  cout << "nbins: " << hservice_->getNBinsHistogram(iTestName) << endl;
467  cout << "statsup= " << statsup << ", statslow= " << statslow << endl;
468  }
469 
470  enoughStats = TMath::MinElement(nActualStrips, maxAvgs.get()) > TMath::Max(statsup, statslow);
471  if (verbose_) {
472  cout << "stats: " << TMath::MinElement(nActualStrips, maxAvgs.get())
473  << ", statsAvg: " << diffHist->GetEntries() / hservice_->getNBinsHistogram(iTestName)
474  << ", threshold: " << TMath::Max(statsup, statslow) << endl;
475  }
476 
477  //if enough statistics
478  //make the test
479  if (enoughStats) {
480  for (; upBinStrip <= maxBinStrip; upBinStrip++, lowBinStrip--) {
481  double avg = getAvrg(diffHist, iTestName, pAxis, nBinsY, upBinStrip, pAverageMode);
483  diffHist, iTestName, lowBinStrip, nBinsY, pAxis, avg, ps, deadChannels); //compare with lower side
484 
485  avg = getAvrg(diffHist, iTestName, pAxis, nBinsY, lowBinStrip, pAverageMode);
487  diffHist, iTestName, upBinStrip, nBinsY, pAxis, avg, ps, deadChannels); //compare with upper side
488  }
489  }
490  }
491 
492  // pAxis==2 : Means symetry pAxis is horizontal
493  else if (pAxis == 2) {
494  int maxBinStrip, centralBinStrip; //x-coordinate of strips
495 
496  maxBinStrip = nBinsY;
497 
498  // Determine center of diagram: either with set pAxis or middle of diagram
499  if (ps.getUntrackedParameter<bool>("takeCenter", true)) {
500  centralBinStrip = nBinsY / 2 + 1;
501  } else {
502  double pAxisSymmetryValue = ps.getParameter<double>("axisSymmetryValue");
503  getBinCoordinateOnAxisWithValue(diffHist, pAxisSymmetryValue, centralBinStrip, 2);
504  }
505 
506  //assuming odd number of strips --> first comparison is middle strip to itself
507  int lowBinStrip = centralBinStrip, upBinStrip = centralBinStrip;
508 
509  //if even number
510  if (nBinsX % 2 == 0) {
511  //decrease lowBinstrip by one
512  lowBinStrip--;
513  }
514 
515  //do we have enough statistics? Min(Max(strip_i,strip_j))>threshold
516  std::unique_ptr<double[]> maxAvgs(new double[maxBinStrip - upBinStrip + 1]);
517  int nActualStrips = 0;
518  for (int i = 0, j = upBinStrip, k = lowBinStrip; j <= maxBinStrip; i++, j++, k--) {
519  double avg1 = getAvrg(diffHist, iTestName, pAxis, nBinsX, j, pAverageMode);
520  double avg2 = getAvrg(diffHist, iTestName, pAxis, nBinsX, k, pAverageMode);
521  if (!hservice_->isStripMasked(iTestName, j, pAxis) && !hservice_->isStripMasked(iTestName, k, pAxis)) {
522  maxAvgs[i] = TMath::Max(avg1, avg2);
523  nActualStrips++;
524  }
525  }
526 
527  vector<double> defaultMu0up;
528  defaultMu0up.push_back(13.7655);
529  defaultMu0up.push_back(184.742);
530  defaultMu0up.push_back(50735.3);
531  defaultMu0up.push_back(-97.6793);
532 
533  vector<double> params = ps.getUntrackedParameter<std::vector<double> >("params_mu0_up", defaultMu0up);
534  TF1 tf("myFunc", "[0]*(TMath::Log(x*[1]+[2]))+[3]", 10., 11000.);
535  for (unsigned int i = 0; i < params.size(); i++) {
536  tf.SetParameter(i, params[i]);
537  }
538  int statsup = (int)tf.Eval(hservice_->getNBinsHistogram(iTestName));
539 
540  vector<double> defaultMu0low;
541  defaultMu0low.push_back(2.19664);
542  defaultMu0low.push_back(1.94546);
543  defaultMu0low.push_back(-99.3263);
544  defaultMu0low.push_back(19.388);
545 
546  params = ps.getUntrackedParameter<std::vector<double> >("params_mu0_low", defaultMu0low);
547  for (unsigned int i = 0; i < params.size(); i++) {
548  tf.SetParameter(i, params[i]);
549  }
550  int statslow = (int)tf.Eval(hservice_->getNBinsHistogram(iTestName));
551  if (verbose_) {
552  cout << "statsup= " << statsup << ", statslow= " << statslow << endl;
553  }
554  enoughStats = TMath::MinElement(nActualStrips, maxAvgs.get()) > TMath::Max(statsup, statslow);
555  if (verbose_) {
556  cout << "stats: " << TMath::MinElement(nActualStrips, maxAvgs.get())
557  << ", statsAvg: " << diffHist->GetEntries() / hservice_->getNBinsHistogram(iTestName)
558  << ", threshold: " << TMath::Max(statsup, statslow) << endl;
559  }
560 
561  //if we have enough statistics
562  //make the test
563  if (enoughStats) {
564  for (; upBinStrip <= maxBinStrip; upBinStrip++, lowBinStrip--) {
565  double avg = getAvrg(diffHist, iTestName, pAxis, nBinsX, upBinStrip, pAverageMode);
567  diffHist, iTestName, lowBinStrip, nBinsX, pAxis, avg, ps, deadChannels); //compare with lower side
568 
569  avg = getAvrg(diffHist, iTestName, pAxis, nBinsX, lowBinStrip, pAverageMode);
571  diffHist, iTestName, upBinStrip, nBinsX, pAxis, avg, ps, deadChannels); //compare with upper side
572  }
573  }
574  } else {
575  if (verbose_) {
576  cout << "Invalid axis" << endl;
577  }
578  }
579 
580  return (deadChannels.size() - hservice_->getNBinsMasked(iTestName)) * 1.0 / hservice_->getNBinsHistogram(iTestName);
581 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void getBinCoordinateOnAxisWithValue(TH2F *h2f, double content, int &coord, int axis)
double getAvrg(TH2F *h2f, std::string test, int axis, int nBins, int binStrip, int avrgMode)
T getUntrackedParameter(std::string const &, T const &) const
bool isStripMasked(std::string test, int binStrip, int axis)
int compareWithStrip(TH2F *histo, std::string test, int binStrip, int nBins, int axis, double avg, const edm::ParameterSet &ps, std::vector< std::pair< int, double > > &deadChannels)
L1TOccupancyClientHistogramService * hservice_

Member Data Documentation

◆ file_

TFile* L1TOccupancyClient::file_
private

Definition at line 55 of file L1TOccupancyClient.h.

◆ hservice_

L1TOccupancyClientHistogramService* L1TOccupancyClient::hservice_
private

Definition at line 54 of file L1TOccupancyClient.h.

◆ meCertification

std::map<std::string, MonitorElement*> L1TOccupancyClient::meCertification
private

Definition at line 66 of file L1TOccupancyClient.h.

◆ meDifferential

std::map<std::string, MonitorElement*> L1TOccupancyClient::meDifferential
private

Definition at line 65 of file L1TOccupancyClient.h.

◆ meResults

std::map<std::string, MonitorElement*> L1TOccupancyClient::meResults
private

Definition at line 64 of file L1TOccupancyClient.h.

◆ mValidTests

std::vector<edm::ParameterSet*> L1TOccupancyClient::mValidTests
private

Definition at line 62 of file L1TOccupancyClient.h.

◆ parameters_

edm::ParameterSet L1TOccupancyClient::parameters_
private

◆ tests_

std::vector<edm::ParameterSet> L1TOccupancyClient::tests_
private

Definition at line 61 of file L1TOccupancyClient.h.

◆ verbose_

bool L1TOccupancyClient::verbose_
private

Definition at line 58 of file L1TOccupancyClient.h.