CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
SiStripDetVOffTkMapPlotter Class Reference
Inheritance diagram for SiStripDetVOffTkMapPlotter:
edm::one::EDAnalyzer<> edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

void analyze (const edm::Event &evt, const edm::EventSetup &evtSetup) override
 
 SiStripDetVOffTkMapPlotter (const edm::ParameterSet &iConfig)
 
 ~SiStripDetVOffTkMapPlotter () 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)
 

Private Member Functions

std::string formatIOV (cond::Time_t iov, std::string format="%Y-%m-%d__%H_%M_%S")
 

Private Attributes

edm::ESGetToken< GeometricDet, IdealGeometryRecordgeomDetToken_
 
std::string m_condDb
 
cond::persistency::ConnectionPool m_connectionPool
 
cond::Time_t m_IOV
 
std::string m_outputFile
 
std::string m_plotFormat
 
std::string m_plotTag
 
std::string m_Time
 
edm::ESGetToken< TkDetMap, TrackerTopologyRcdtkDetMapToken_
 

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)
 
- 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

Definition at line 22 of file SiStripDetVOffTkMapPlotter.cc.

Constructor & Destructor Documentation

◆ SiStripDetVOffTkMapPlotter()

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

Definition at line 48 of file SiStripDetVOffTkMapPlotter.cc.

References cond::persistency::ConnectionPool::configure(), edm::ParameterSet::getParameter(), m_connectionPool, and cond::persistency::ConnectionPool::setParameters().

49  : m_connectionPool(),
50  m_condDb(iConfig.getParameter<std::string>("conditionDatabase")),
51  m_plotTag(iConfig.getParameter<std::string>("Tag")),
52  m_IOV(iConfig.getUntrackedParameter<cond::Time_t>("IOV", 0)),
53  m_Time(iConfig.getUntrackedParameter<std::string>("Time", "")),
54  m_plotFormat(iConfig.getUntrackedParameter<std::string>("plotFormat", "png")),
55  m_outputFile(iConfig.getUntrackedParameter<std::string>("outputFile", "")),
60 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
void setParameters(const edm::ParameterSet &connectionPset)
T getUntrackedParameter(std::string const &, T const &) const
unsigned long long Time_t
Definition: Time.h:14
cond::persistency::ConnectionPool m_connectionPool
edm::ESGetToken< GeometricDet, IdealGeometryRecord > geomDetToken_
edm::ESGetToken< TkDetMap, TrackerTopologyRcd > tkDetMapToken_

◆ ~SiStripDetVOffTkMapPlotter()

SiStripDetVOffTkMapPlotter::~SiStripDetVOffTkMapPlotter ( )
overridedefault

Member Function Documentation

◆ analyze()

void SiStripDetVOffTkMapPlotter::analyze ( const edm::Event evt,
const edm::EventSetup evtSetup 
)
overridevirtual

Implements edm::one::EDAnalyzerBase.

Definition at line 64 of file SiStripDetVOffTkMapPlotter.cc.

References cond::persistency::ConnectionPool::createSession(), TkHistoMap::dumpInTkMap(), cond::persistency::Session::fetchPayload(), TkHistoMap::fill(), cond::persistency::IOVArray::find(), formatIOV(), cond::time::from_boost(), geomDetToken_, edm::EventSetup::getData(), TrackerGeometryUtils::getSiStripDetIds(), m_condDb, m_connectionPool, m_IOV, m_outputFile, m_plotFormat, m_plotTag, m_Time, jetsAK4_Puppi_cff::payload, cond::persistency::Session::readIov(), TkHistoMap::save(), TrackerMap::save(), cond::persistency::IOVProxy::selectAll(), TrackerMap::setPalette(), cond::persistency::Transaction::start(), tkDetMapToken_, cond::time::to_boost(), to_string(), and cond::persistency::Session::transaction().

64  {
65  cond::Time_t theIov = 0;
66  if (m_IOV != 0) {
67  theIov = m_IOV;
68  } else if (!m_Time.empty()) {
69  theIov = cond::time::from_boost(boost::posix_time::time_from_string(m_Time));
70  } else {
71  // Use the current time if no input. Will get the last IOV.
72  theIov = cond::time::from_boost(boost::posix_time::second_clock::universal_time());
73  }
74 
75  // open db session
76  edm::LogInfo("SiStripDetVOffMapPlotter") << "[SiStripDetVOffMapPlotter::" << __func__ << "] "
77  << "Query the condition database " << m_condDb << " for tag " << m_plotTag;
79  condDbSession.transaction().start(true);
80  cond::persistency::IOVProxy iovProxy = condDbSession.readIov(m_plotTag);
81  auto iovs = iovProxy.selectAll();
82  auto iiov = iovs.find(theIov);
83  if (iiov == iovs.end())
84  throw cms::Exception("Input IOV " + std::to_string(m_IOV) + "/" + m_Time + " is invalid!");
85 
86  theIov = (*iiov).since;
87  edm::LogInfo("SiStripDetVOffMapPlotter") << "[SiStripDetVOffMapPlotter::" << __func__ << "] "
88  << "Make tkMap for IOV " << theIov << " ("
89  << boost::posix_time::to_simple_string(cond::time::to_boost(theIov)) << ")";
90  auto payload = condDbSession.fetchPayload<SiStripDetVOff>((*iiov).payloadId);
91 
92  const TkDetMap* tkDetMap = &evtSetup.getData(tkDetMapToken_);
93  TrackerMap lvmap, hvmap;
94  TkHistoMap lvhisto(tkDetMap, "LV_Status", "LV_Status", -1);
95  TkHistoMap hvhisto(tkDetMap, "HV_Status", "HV_Status", -1);
96 
97  const auto detids = TrackerGeometryUtils::getSiStripDetIds(evtSetup.getData(geomDetToken_));
98  for (auto id : detids) {
99  if (payload->IsModuleLVOff(id))
100  lvhisto.fill(id, 1); // RED
101  else
102  lvhisto.fill(id, 0.5);
103 
104  if (payload->IsModuleHVOff(id))
105  hvhisto.fill(id, 1); // RED
106  else
107  hvhisto.fill(id, 0.5);
108  }
109 
110  lvhisto.dumpInTkMap(&lvmap);
111  hvhisto.dumpInTkMap(&hvmap);
112  lvmap.setPalette(1);
113  hvmap.setPalette(1);
114  lvmap.save(true, 0, 0, "LV_tkMap_" + formatIOV(theIov) + "." + m_plotFormat);
115  hvmap.save(true, 0, 0, "HV_tkMap_" + formatIOV(theIov) + "." + m_plotFormat);
116 
117  if (!m_outputFile.empty()) {
118  lvhisto.save(m_outputFile);
119  hvhisto.save(m_outputFile);
120  }
121 }
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
void start(bool readOnly=true)
Definition: Session.cc:18
std::unique_ptr< T > fetchPayload(const cond::Hash &payloadHash)
Definition: Session.h:213
Transaction & transaction()
Definition: Session.cc:52
static std::string to_string(const XMLCh *ch)
unsigned long long Time_t
Definition: Time.h:14
void setPalette(int numpalette)
Definition: TrackerMap.h:154
void save(bool print_total=true, float minval=0., float maxval=0., std::string s="svgmap.svg", int width=1500, int height=800)
Definition: TrackerMap.cc:844
std::vector< uint32_t > getSiStripDetIds(const GeometricDet &geomDet)
Definition: utils.cc:5
Session createSession(const std::string &connectionString, bool writeCapable=false)
Iterator find(cond::Time_t time) const
Definition: IOVProxy.cc:101
Time_t from_boost(boost::posix_time::ptime bt)
cond::persistency::ConnectionPool m_connectionPool
IOVProxy readIov(const std::string &tag)
Definition: Session.cc:63
edm::ESGetToken< GeometricDet, IdealGeometryRecord > geomDetToken_
std::string formatIOV(cond::Time_t iov, std::string format="%Y-%m-%d__%H_%M_%S")
Log< level::Info, false > LogInfo
edm::ESGetToken< TkDetMap, TrackerTopologyRcd > tkDetMapToken_
boost::posix_time::ptime to_boost(Time_t iValue)

◆ formatIOV()

std::string SiStripDetVOffTkMapPlotter::formatIOV ( cond::Time_t  iov,
std::string  format = "%Y-%m-%d__%H_%M_%S" 
)
private

Definition at line 123 of file SiStripDetVOffTkMapPlotter.cc.

References cms::cuda::stream, and cond::time::to_boost().

Referenced by analyze().

123  {
124  auto facet = new boost::posix_time::time_facet(format.c_str());
125  std::ostringstream stream;
126  stream.imbue(std::locale(stream.getloc(), facet));
128  return stream.str();
129 }
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
boost::posix_time::ptime to_boost(Time_t iValue)

Member Data Documentation

◆ geomDetToken_

edm::ESGetToken<GeometricDet, IdealGeometryRecord> SiStripDetVOffTkMapPlotter::geomDetToken_
private

Definition at line 45 of file SiStripDetVOffTkMapPlotter.cc.

Referenced by analyze().

◆ m_condDb

std::string SiStripDetVOffTkMapPlotter::m_condDb
private

Definition at line 32 of file SiStripDetVOffTkMapPlotter.cc.

Referenced by analyze().

◆ m_connectionPool

cond::persistency::ConnectionPool SiStripDetVOffTkMapPlotter::m_connectionPool
private

Definition at line 31 of file SiStripDetVOffTkMapPlotter.cc.

Referenced by analyze(), and SiStripDetVOffTkMapPlotter().

◆ m_IOV

cond::Time_t SiStripDetVOffTkMapPlotter::m_IOV
private

Definition at line 36 of file SiStripDetVOffTkMapPlotter.cc.

Referenced by analyze().

◆ m_outputFile

std::string SiStripDetVOffTkMapPlotter::m_outputFile
private

Definition at line 42 of file SiStripDetVOffTkMapPlotter.cc.

Referenced by analyze().

◆ m_plotFormat

std::string SiStripDetVOffTkMapPlotter::m_plotFormat
private

Definition at line 40 of file SiStripDetVOffTkMapPlotter.cc.

Referenced by analyze().

◆ m_plotTag

std::string SiStripDetVOffTkMapPlotter::m_plotTag
private

Definition at line 33 of file SiStripDetVOffTkMapPlotter.cc.

Referenced by analyze().

◆ m_Time

std::string SiStripDetVOffTkMapPlotter::m_Time
private

Definition at line 38 of file SiStripDetVOffTkMapPlotter.cc.

Referenced by analyze().

◆ tkDetMapToken_

edm::ESGetToken<TkDetMap, TrackerTopologyRcd> SiStripDetVOffTkMapPlotter::tkDetMapToken_
private

Definition at line 44 of file SiStripDetVOffTkMapPlotter.cc.

Referenced by analyze().