CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Attributes
BrilClient Class Reference

#include <BrilClient.h>

Inheritance diagram for BrilClient:
DQMEDHarvester edm::one::EDAnalyzer< edm::one::WatchRuns, edm::one::WatchLuminosityBlocks, edm::one::SharedResources > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 BrilClient (const edm::ParameterSet &ps)
 
virtual ~BrilClient ()
 
- Public Member Functions inherited from DQMEDHarvester
virtual void analyze (edm::Event const &, edm::EventSetup const &) final
 
virtual void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) final
 
virtual void beginRun (edm::Run const &, edm::EventSetup const &)
 
 DQMEDHarvester (void)
 
virtual void endJob () final
 
virtual void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) final
 
virtual void endRun (edm::Run const &, edm::EventSetup const &)
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::WatchRuns, edm::one::WatchLuminosityBlocks, edm::one::SharedResources >
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDAnalyzerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Protected Member Functions

void beginJob () override
 
void dqmEndJob (DQMStore::IBooker &, DQMStore::IGetter &) override
 
void dqmEndLuminosityBlock (DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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 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)
 

Private Attributes

edm::EDGetTokenT< std::string > jsonToken_
 
edm::EDGetTokenT< std::string > pathToken_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Detailed Description

Definition at line 18 of file BrilClient.h.

Constructor & Destructor Documentation

BrilClient::BrilClient ( const edm::ParameterSet ps)

Definition at line 12 of file BrilClient.cc.

References HLT_FULL_cff::InputTag, jsonToken_, and pathToken_.

12  {
13  pathToken_ = consumes<std::string, edm::InLumi>(
14  edm::InputTag("source", "sourceDataPath"));
15  jsonToken_ = consumes<std::string, edm::InLumi>(
16  edm::InputTag("source", "sourceJsonPath"));
17 }
edm::EDGetTokenT< std::string > pathToken_
Definition: BrilClient.h:28
edm::EDGetTokenT< std::string > jsonToken_
Definition: BrilClient.h:32
BrilClient::~BrilClient ( )
virtual

Definition at line 19 of file BrilClient.cc.

19 {}

Member Function Documentation

void BrilClient::beginJob ( void  )
inlineoverrideprotectedvirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 24 of file BrilClient.h.

24 {};
void BrilClient::dqmEndJob ( DQMStore::IBooker ,
DQMStore::IGetter  
)
inlineoverrideprotectedvirtual

Implements DQMEDHarvester.

Definition at line 28 of file BrilClient.h.

28 {};
void BrilClient::dqmEndLuminosityBlock ( DQMStore::IBooker ibooker_,
DQMStore::IGetter igetter_,
edm::LuminosityBlock const &  lb,
edm::EventSetup const &   
)
overrideprotectedvirtual

Reimplemented from DQMEDHarvester.

Definition at line 30 of file BrilClient.cc.

References begin, DQMStore::IBooker::book2D(), bookConverter::elements, end, DQMStore::IGetter::get(), edm::LuminosityBlock::getByToken(), MonitorElement::getTH1F(), L1Trigger_dataformats::json, visualization-live-secondInstance_cfg::m, mergeVDriftHistosByStation::name, pathToken_, DQMStore::IBooker::setCurrentFolder(), DQMStore::IGetter::setCurrentFolder(), AlCaHLTBitMon_QueryRunRegistry::string, and indexGen::title.

33  {
34  edm::Handle<std::string> filePath_;
35  lb.getByToken(pathToken_, filePath_);
36 
37  // edm::Handle<std::string> jsonPath_;
38  // lb.getByToken(jsonToken_, jsonPath_);
39  //
40 
41  ptree json;
42  if (!boost::filesystem::exists(*filePath_)) {
43  edm::LogWarning("BrilClient") << "BrilClient"
44  << " File missing: " << *filePath_
45  << std::endl;
46 
47  return;
48  } else {
49  edm::LogWarning("BrilClient") << "BrilClient"
50  << " Opening: " << *filePath_ << std::endl;
51 
52  read_json(std::string(*filePath_), json);
53  }
54 
55  // Parse the json
56  for (auto& mainTree : json.get_child("OccupancyPlots")) {
57  std::string title = mainTree.second.get<std::string>("titles");
58  std::size_t pos = title.find(",");
59  if (pos <= 0) {
60  edm::LogWarning("BrilClient") << "BrilClient::dqmEndLuminosityBlock"
61  << " Invalid title" << title << std::endl;
62 
63  continue;
64  }
65  std::string name = title.substr(0, pos);
66 
67  auto nBins = as_vector<int>(mainTree.second, "nbins"); // x, y
68  auto xrange = as_vector<int>(mainTree.second, "xrange"); // min, max
69  auto yrange = as_vector<int>(mainTree.second, "yrange"); // min, max
70 
71  TH2F* th = new TH2F(name.c_str(), title.c_str(), nBins.at(0), xrange.at(0),
72  xrange.at(1), nBins.at(1), yrange.at(0), yrange.at(1));
73 
74  for (auto& dataArray : mainTree.second.get_child("data")) {
75  int elements[3] = {0, 0, 0}; // binX, binY, binCont;
76  auto element = std::begin(elements);
77 
78  for (auto& binContent : dataArray.second) {
79  *element++ = stoi(binContent.second.get_value<std::string>());
80  if (element == std::end(elements)) break;
81  }
82 
83  th->SetBinContent(elements[0], elements[1], elements[2]);
84  }
85 
86  // Add it to the DQM store
87  ibooker_.setCurrentFolder("BRIL/OccupancyPlots");
88  igetter_.setCurrentFolder("BRIL/OccupancyPlots");
89 
90  MonitorElement* m = igetter_.get(name);
91  if (m == nullptr) {
92  m = ibooker_.book2D(name, th);
93  } else {
94  m->getTH1F()->Add(th);
95  }
96  }
97 }
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:301
edm::EDGetTokenT< std::string > pathToken_
Definition: BrilClient.h:28
dictionary elements
#define end
Definition: vmac.h:37
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:273
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
TH1F * getTH1F(void) const
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:329
#define begin
Definition: vmac.h:30

Member Data Documentation

edm::EDGetTokenT<std::string> BrilClient::jsonToken_
private

Definition at line 32 of file BrilClient.h.

Referenced by BrilClient().

edm::EDGetTokenT<std::string> BrilClient::pathToken_
private

Definition at line 28 of file BrilClient.h.

Referenced by BrilClient(), and dqmEndLuminosityBlock().