CMS 3D CMS Logo

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::EDProducer< edm::Accumulator, edm::EndLuminosityBlockProducer, edm::EndRunProducer, edm::one::WatchLuminosityBlocks, edm::one::WatchRuns, edm::one::SharedResources > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Member Functions

 BrilClient (const edm::ParameterSet &ps)
 
 ~BrilClient () override
 
- Public Member Functions inherited from DQMEDHarvester
void accumulate (edm::Event const &ev, edm::EventSetup const &es) final
 
void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) final
 
void beginRun (edm::Run const &, edm::EventSetup const &) override
 
 DQMEDHarvester ()
 
void endJob () final
 
void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) final
 
void endLuminosityBlockProduce (edm::LuminosityBlock &, edm::EventSetup const &) final
 
void endRun (edm::Run const &, edm::EventSetup const &) override
 
void endRunProduce (edm::Run &run, edm::EventSetup const &setup) override
 
 ~DQMEDHarvester () override=default
 
- Public Member Functions inherited from edm::one::EDProducer< edm::Accumulator, edm::EndLuminosityBlockProducer, edm::EndRunProducer, edm::one::WatchLuminosityBlocks, edm::one::WatchRuns, edm::one::SharedResources >
 EDProducer ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () 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
 
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)
 
 ~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
 
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::vector< ModuleDescription const * > &modules, 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
 
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 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
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
edm::EDPutTokenT< DQMTokenlumiToken_
 
edm::EDPutTokenT< DQMTokenrunToken_
 

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 jsonToken_, and pathToken_.

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

Definition at line 17 of file BrilClient.cc.

17 {}

Member Function Documentation

void BrilClient::beginJob ( void  )
inlineoverrideprotectedvirtual

Reimplemented from edm::one::EDProducerBase.

Definition at line 24 of file BrilClient.h.

References dqmEndLuminosityBlock().

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

Implements DQMEDHarvester.

Definition at line 29 of file BrilClient.h.

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

Reimplemented from DQMEDHarvester.

Definition at line 29 of file BrilClient.cc.

References begin, DQMStore::IBooker::book2D(), DEFINE_FWK_MODULE, allElectronIsolations_cfi::elements, end, DQMStore::IGetter::get(), edm::LuminosityBlock::getByToken(), MonitorElement::getTH1F(), edmPickEvents::json, funct::m, dataset::name, pathToken_, DQMStore::IBooker::setCurrentFolder(), DQMStore::IGetter::setCurrentFolder(), AlCaHLTBitMon_QueryRunRegistry::string, and fftjetcommon_cfi::title.

Referenced by beginJob().

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

Member Data Documentation

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

Definition at line 33 of file BrilClient.h.

Referenced by BrilClient().

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

Definition at line 29 of file BrilClient.h.

Referenced by BrilClient(), and dqmEndLuminosityBlock().