CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
SiPixelQualityProbabilitiesTestWriter Class Reference

#include <CondFormats/SiPixelObjects/plugins/SiPixelQualityProbabilitiesTestWriter.cc>

Inheritance diagram for SiPixelQualityProbabilitiesTestWriter:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 SiPixelQualityProbabilitiesTestWriter (const edm::ParameterSet &)
 
 ~SiPixelQualityProbabilitiesTestWriter () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer<>
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~EDAnalyzerBase () 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
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > 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
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

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

Private Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void endJob () override
 

Private Attributes

const std::string m_ProbInputs
 
const std::string m_record
 
const std::string m_SnapshotInputs
 
std::unique_ptr< SiPixelQualityProbabilitiesmyProbabilities
 
const bool printdebug_
 

Additional Inherited Members

- Public Types inherited from edm::one::EDAnalyzerBase
typedef EDAnalyzerBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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 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)
 

Detailed Description

Description: class to build the SiPixel Quality probabilities

Definition at line 37 of file SiPixelQualityProbabilitiesTestWriter.cc.

Constructor & Destructor Documentation

◆ SiPixelQualityProbabilitiesTestWriter()

SiPixelQualityProbabilitiesTestWriter::SiPixelQualityProbabilitiesTestWriter ( const edm::ParameterSet iConfig)
explicit

Definition at line 59 of file SiPixelQualityProbabilitiesTestWriter.cc.

References myProbabilities.

60  : m_ProbInputs(iConfig.getParameter<std::string>("probabilities")),
61  m_SnapshotInputs(iConfig.getParameter<std::string>("snapshots")),
62  m_record(iConfig.getParameter<std::string>("record")),
63  printdebug_(iConfig.getUntrackedParameter<bool>("printDebug", false)) {
64  //now do what ever initialization is needed
65  myProbabilities = std::make_unique<SiPixelQualityProbabilities>();
66 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
T getUntrackedParameter(std::string const &, T const &) const
std::unique_ptr< SiPixelQualityProbabilities > myProbabilities

◆ ~SiPixelQualityProbabilitiesTestWriter()

SiPixelQualityProbabilitiesTestWriter::~SiPixelQualityProbabilitiesTestWriter ( )
overridedefault

Member Function Documentation

◆ analyze()

void SiPixelQualityProbabilitiesTestWriter::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)
overrideprivatevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 75 of file SiPixelQualityProbabilitiesTestWriter.cc.

References mps_fire::i, EcalPhiSymFlatTableProducers_cfi::id, relval_nano::ls, m_ProbInputs, m_SnapshotInputs, myProbabilities, printdebug_, writedatasetfile::run, AlCaHLTBitMon_QueryRunRegistry::string, and to_string().

75  {
76  using namespace edm;
77  std::ifstream myfile(m_ProbInputs);
78  std::ifstream mysnapshots(m_SnapshotInputs);
79  std::string line1, line2;
80  std::map<int, std::string> snapshotIdToString;
81 
82  if (mysnapshots.is_open()) {
83  while (getline(mysnapshots, line1)) {
84  //edm::LogInfo("SiPixelQualityProbabilitiesTestWriter") << line1 << std::endl;
85  std::istringstream iss(line1);
86  int id, run, ls;
87  iss >> id >> run >> ls;
88  snapshotIdToString[id] = std::to_string(run) + "_" + std::to_string(ls);
89  }
90  }
91 
93 
94  if (myfile.is_open()) {
95  while (getline(myfile, line2)) {
96  edm::LogInfo("SiPixelQualityProbabilitiesTestWriter") << line2 << std::endl;
97  std::istringstream iss(line2);
98  int pileupBinId, nEntries;
99  iss >> pileupBinId >> nEntries;
100  edm::LogInfo("SiPixelQualityProbabilitiesTestWriter")
101  << "PILEUP BIN/ENTRIES: " << pileupBinId << " " << nEntries << std::endl;
102  std::vector<int> ids(nEntries, 0);
103  std::vector<float> probs(nEntries, 0.0);
104  for (int i = 0; i < nEntries; ++i) {
105  iss >> ids.at(i) >> probs.at(i);
106  //edm::LogInfo("SiPixelQualityProbabilitiesTestWriter") << ids.at(i) << " " << probs.at(i)<< std::endl;
107  auto idAndProb = std::make_pair(snapshotIdToString.at(ids.at(i)), probs.at(i));
108  myProbVector.push_back(idAndProb);
109  }
110  if (nEntries > 0)
111  myProbabilities->setProbabilities(pileupBinId, myProbVector);
112  myProbVector.clear();
113  }
114  myfile.close();
115  }
116 
117  if (printdebug_) {
118  edm::LogInfo("SiPixelQualityProbabilitiesTestWriter") << "Content of SiPixelQualityProbabilities " << std::endl;
119  // use buil-in method in the CondFormat
120  myProbabilities->printAll();
121  }
122 }
static std::string to_string(const XMLCh *ch)
std::vector< std::pair< std::string, float > > probabilityVec
Log< level::Info, false > LogInfo
HLT enums.
std::unique_ptr< SiPixelQualityProbabilities > myProbabilities

◆ endJob()

void SiPixelQualityProbabilitiesTestWriter::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 125 of file SiPixelQualityProbabilitiesTestWriter.cc.

References cond::service::PoolDBOutputService::currentTime(), edm::Service< T >::isAvailable(), m_record, myProbabilities, and cond::service::PoolDBOutputService::writeOneIOV().

125  {
126  edm::LogInfo("SiPixelQualityProbabilitiesTestWriter")
127  << "Size of SiPixelQualityProbabilities object " << myProbabilities->size() << std::endl
128  << std::endl;
129 
130  // Form the data here
132  if (poolDbService.isAvailable()) {
133  cond::Time_t valid_time = poolDbService->currentTime();
134  // this writes the payload to begin in current run defined in cfg
135  poolDbService->writeOneIOV(*myProbabilities, valid_time, m_record);
136  }
137 }
unsigned long long Time_t
Definition: Time.h:14
Hash writeOneIOV(const T &payload, Time_t time, const std::string &recordName)
Log< level::Info, false > LogInfo
bool isAvailable() const
Definition: Service.h:40
std::unique_ptr< SiPixelQualityProbabilities > myProbabilities

◆ fillDescriptions()

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

Definition at line 140 of file SiPixelQualityProbabilitiesTestWriter.cc.

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

140  {
142  desc.setComment("Writes payloads of type SiPixelQualityProbabilities");
143  desc.addUntracked<bool>("printDebug", true);
144  desc.add<std::string>("record", "SiPixelStatusScenarioProbabilityRcd");
145  desc.add<std::string>("snapshots", "");
146  desc.add<std::string>("probabilities", "");
147  descriptions.add("SiPixelQualityProbabilitiesTestWriter", desc);
148 }
void add(std::string const &label, ParameterSetDescription const &psetDescription)

Member Data Documentation

◆ m_ProbInputs

const std::string SiPixelQualityProbabilitiesTestWriter::m_ProbInputs
private

Definition at line 49 of file SiPixelQualityProbabilitiesTestWriter.cc.

Referenced by analyze().

◆ m_record

const std::string SiPixelQualityProbabilitiesTestWriter::m_record
private

Definition at line 51 of file SiPixelQualityProbabilitiesTestWriter.cc.

Referenced by endJob().

◆ m_SnapshotInputs

const std::string SiPixelQualityProbabilitiesTestWriter::m_SnapshotInputs
private

Definition at line 50 of file SiPixelQualityProbabilitiesTestWriter.cc.

Referenced by analyze().

◆ myProbabilities

std::unique_ptr<SiPixelQualityProbabilities> SiPixelQualityProbabilitiesTestWriter::myProbabilities
private

◆ printdebug_

const bool SiPixelQualityProbabilitiesTestWriter::printdebug_
private

Definition at line 52 of file SiPixelQualityProbabilitiesTestWriter.cc.

Referenced by analyze().