CMS 3D CMS Logo

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

Public Member Functions

void analyze (const edm::Event &evt, const edm::EventSetup &evtSetup) override
 
void endJob () override
 
 SiStripDetVOffTkMapPlotter (const edm::ParameterSet &iConfig)
 
 ~SiStripDetVOffTkMapPlotter () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () 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)
 

Private Member Functions

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

Private Attributes

edm::Service< SiStripDetInfoFileReaderdetidReader
 
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
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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)
 

Detailed Description

Definition at line 22 of file SiStripDetVOffTkMapPlotter.cc.

Constructor & Destructor Documentation

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", "")) {
58 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void setParameters(const edm::ParameterSet &connectionPset)
unsigned long long Time_t
Definition: Time.h:16
cond::persistency::ConnectionPool m_connectionPool
SiStripDetVOffTkMapPlotter::~SiStripDetVOffTkMapPlotter ( )
override

Definition at line 60 of file SiStripDetVOffTkMapPlotter.cc.

60 {}

Member Function Documentation

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

Definition at line 62 of file SiStripDetVOffTkMapPlotter.cc.

References cond::persistency::ConnectionPool::createSession(), detidReader, TkHistoMap::dumpInTkMap(), cond::persistency::IOVProxy::end(), cond::persistency::Session::fetchPayload(), TkHistoMap::fill(), cond::persistency::IOVProxy::find(), formatIOV(), cond::time::from_boost(), edm::EventSetup::get(), SiStripDetInfoFileReader::getAllDetIds(), m_condDb, m_connectionPool, m_IOV, m_outputFile, m_plotFormat, m_plotTag, m_Time, jets_cff::payload, cond::persistency::Session::readIov(), TkHistoMap::save(), TrackerMap::save(), TrackerMap::setPalette(), cond::persistency::Transaction::start(), cond::time::to_boost(), and cond::persistency::Session::transaction().

62  {
63  cond::Time_t theIov = 0;
64  if (m_IOV != 0) {
65  theIov = m_IOV;
66  } else if (!m_Time.empty()) {
67  theIov = cond::time::from_boost(boost::posix_time::time_from_string(m_Time));
68  } else {
69  // Use the current time if no input. Will get the last IOV.
70  theIov = cond::time::from_boost(boost::posix_time::second_clock::universal_time());
71  }
72 
73  // open db session
74  edm::LogInfo("SiStripDetVOffMapPlotter") << "[SiStripDetVOffMapPlotter::" << __func__ << "] "
75  << "Query the condition database " << m_condDb << " for tag " << m_plotTag;
77  condDbSession.transaction().start(true);
78  cond::persistency::IOVProxy iovProxy = condDbSession.readIov(m_plotTag, true);
79  auto iiov = iovProxy.find(theIov);
80  if (iiov == iovProxy.end())
81  throw cms::Exception("Input IOV " + std::to_string(m_IOV) + "/" + m_Time + " is invalid!");
82 
83  theIov = (*iiov).since;
84  edm::LogInfo("SiStripDetVOffMapPlotter") << "[SiStripDetVOffMapPlotter::" << __func__ << "] "
85  << "Make tkMap for IOV " << theIov << " ("
86  << boost::posix_time::to_simple_string(cond::time::to_boost(theIov)) << ")";
87  auto payload = condDbSession.fetchPayload<SiStripDetVOff>((*iiov).payloadId);
88 
89  edm::ESHandle<TkDetMap> tkDetMapHandle;
90  evtSetup.get<TrackerTopologyRcd>().get(tkDetMapHandle);
91  const TkDetMap* tkDetMap = tkDetMapHandle.product();
92  TrackerMap lvmap, hvmap;
93  TkHistoMap lvhisto(tkDetMap, "LV_Status", "LV_Status", -1);
94  TkHistoMap hvhisto(tkDetMap, "HV_Status", "HV_Status", -1);
95 
96  auto detids = detidReader->getAllDetIds();
97  for (auto id : detids) {
98  if (payload->IsModuleLVOff(id))
99  lvhisto.fill(id, 1); // RED
100  else
101  lvhisto.fill(id, 0.5);
102 
103  if (payload->IsModuleHVOff(id))
104  hvhisto.fill(id, 1); // RED
105  else
106  hvhisto.fill(id, 0.5);
107  }
108 
109  lvhisto.dumpInTkMap(&lvmap);
110  hvhisto.dumpInTkMap(&hvmap);
111  lvmap.setPalette(1);
112  hvmap.setPalette(1);
113  lvmap.save(true, 0, 0, "LV_tkMap_" + formatIOV(theIov) + "." + m_plotFormat);
114  hvmap.save(true, 0, 0, "HV_tkMap_" + formatIOV(theIov) + "." + m_plotFormat);
115 
116  if (!m_outputFile.empty()) {
117  lvhisto.save(m_outputFile);
118  hvhisto.save(m_outputFile);
119  }
120 }
void start(bool readOnly=true)
Definition: Session.cc:22
std::unique_ptr< T > fetchPayload(const cond::Hash &payloadHash)
Definition: Session.h:218
Transaction & transaction()
Definition: Session.cc:66
edm::Service< SiStripDetInfoFileReader > detidReader
IOVProxy readIov(const std::string &tag, bool full=false)
Definition: Session.cc:81
unsigned long long Time_t
Definition: Time.h:16
const std::vector< uint32_t > & getAllDetIds() const
void setPalette(int numpalette)
Definition: TrackerMap.h:129
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:699
Iterator find(cond::Time_t time)
Definition: IOVProxy.cc:320
Session createSession(const std::string &connectionString, bool writeCapable=false)
Time_t from_boost(boost::posix_time::ptime bt)
cond::persistency::ConnectionPool m_connectionPool
std::string formatIOV(cond::Time_t iov, std::string format="%Y-%m-%d__%H_%M_%S")
T get() const
Definition: EventSetup.h:71
boost::posix_time::ptime to_boost(Time_t iValue)
Iterator end() const
Definition: IOVProxy.cc:297
void SiStripDetVOffTkMapPlotter::endJob ( void  )
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 122 of file SiStripDetVOffTkMapPlotter.cc.

Referenced by o2olib.O2ORunMgr::executeJob().

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

Definition at line 124 of file SiStripDetVOffTkMapPlotter.cc.

References DEFINE_FWK_MODULE, and cond::time::to_boost().

Referenced by analyze().

124  {
125  auto facet = new boost::posix_time::time_facet(format.c_str());
126  std::ostringstream stream;
127  stream.imbue(std::locale(stream.getloc(), facet));
128  stream << cond::time::to_boost(iov);
129  return stream.str();
130 }
boost::posix_time::ptime to_boost(Time_t iValue)

Member Data Documentation

edm::Service<SiStripDetInfoFileReader> SiStripDetVOffTkMapPlotter::detidReader
private

Definition at line 45 of file SiStripDetVOffTkMapPlotter.cc.

Referenced by analyze().

std::string SiStripDetVOffTkMapPlotter::m_condDb
private

Definition at line 33 of file SiStripDetVOffTkMapPlotter.cc.

Referenced by analyze().

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

Definition at line 32 of file SiStripDetVOffTkMapPlotter.cc.

Referenced by analyze(), and SiStripDetVOffTkMapPlotter().

cond::Time_t SiStripDetVOffTkMapPlotter::m_IOV
private

Definition at line 37 of file SiStripDetVOffTkMapPlotter.cc.

Referenced by analyze().

std::string SiStripDetVOffTkMapPlotter::m_outputFile
private

Definition at line 43 of file SiStripDetVOffTkMapPlotter.cc.

Referenced by analyze().

std::string SiStripDetVOffTkMapPlotter::m_plotFormat
private

Definition at line 41 of file SiStripDetVOffTkMapPlotter.cc.

Referenced by analyze().

std::string SiStripDetVOffTkMapPlotter::m_plotTag
private

Definition at line 34 of file SiStripDetVOffTkMapPlotter.cc.

Referenced by analyze().

std::string SiStripDetVOffTkMapPlotter::m_Time
private

Definition at line 39 of file SiStripDetVOffTkMapPlotter.cc.

Referenced by analyze().