CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
popcon::SiStripPopConHandlerUnitTest< T > Class Template Reference

#include <SiStripPopConHandlerUnitTest.h>

Inheritance diagram for popcon::SiStripPopConHandlerUnitTest< T >:
popcon::PopConSourceHandler< T >

Public Types

enum  DataType {
  UNDEFINED = 0, _Cabling = 1, _Pedestal = 2, _Noise = 3,
  _Threshold = 4, _BadStrip = 5
}
 
- Public Types inherited from popcon::PopConSourceHandler< T >
typedef std::map< Time_t, std::shared_ptr< T > > Container
 
typedef std::unique_ptr< TRef
 
typedef PopConSourceHandler< Tself
 
typedef cond::Time_t Time_t
 
typedef T value_type
 

Public Member Functions

void getNewObjects ()
 
std::string id () const
 
 SiStripPopConHandlerUnitTest (const edm::ParameterSet &pset)
 
 ~SiStripPopConHandlerUnitTest ()
 
- Public Member Functions inherited from popcon::PopConSourceHandler< T >
void initialize (const cond::persistency::Session &dbSession, cond::TagInfo_t const &tagInfo, cond::LogDBEntry_t const &logDBEntry)
 
Ref lastPayload () const
 
cond::LogDBEntry_t const & logDBEntry () const
 
std::pair< Container const *, std::string const > operator() (const cond::persistency::Session &session, cond::TagInfo_t const &tagInfo, cond::LogDBEntry_t const &logDBEntry) const
 
 PopConSourceHandler ()
 
Container const & returnData ()
 
cond::TagInfo_t const & tagInfo () const
 
std::string const & userTextLog () const
 
virtual ~PopConSourceHandler ()
 

Private Member Functions

void fillObject (T *&obj)
 
DataType getDataType ()
 
bool isTransferNeeded ()
 
void setForTransfer ()
 

Private Attributes

edm::Service< SiStripCondObjBuilderFromDbcondObjBuilder
 
bool m_debugMode
 
std::string m_name
 
unsigned long long m_since
 

Additional Inherited Members

- Protected Member Functions inherited from popcon::PopConSourceHandler< T >
cond::persistency::SessiondbSession () const
 
- Protected Attributes inherited from popcon::PopConSourceHandler< T >
Container m_iovs
 
std::vector< std::pair< T *, Time_t > > m_to_transfer
 
std::string m_userTextLog
 

Detailed Description

template<typename T>
class popcon::SiStripPopConHandlerUnitTest< T >

Definition at line 33 of file SiStripPopConHandlerUnitTest.h.

Member Enumeration Documentation

◆ DataType

Constructor & Destructor Documentation

◆ SiStripPopConHandlerUnitTest()

template<typename T >
popcon::SiStripPopConHandlerUnitTest< T >::SiStripPopConHandlerUnitTest ( const edm::ParameterSet pset)
inline

Definition at line 39 of file SiStripPopConHandlerUnitTest.h.

40  : m_name(pset.getUntrackedParameter<std::string>("name", "SiStripPopPopConConfigDbObjHandler")),
41  m_since(pset.getUntrackedParameter<uint32_t>("since", 5)),
42  m_debugMode(pset.getUntrackedParameter<bool>("debug", false)){};

◆ ~SiStripPopConHandlerUnitTest()

Definition at line 46 of file SiStripPopConHandlerUnitTest.h.

46 {};

Member Function Documentation

◆ fillObject()

template<typename T >
void popcon::SiStripPopConHandlerUnitTest< T >::fillObject ( T *&  obj)
inlineprivate

Definition at line 167 of file SiStripPopConHandlerUnitTest.h.

References submitPVResolutionJobs::count, SiStripDetInfoFileReader::kDefaultFile, hgchebackDigitizer_cfi::noise, getGTfromDQMFile::obj, SiStripDetInfoFileReader::read(), and digitizers_cfi::strip.

Referenced by popcon::SiStripPopConHandlerUnitTest< T >::setForTransfer().

167  {
168  if (typeid(T) == typeid(SiStripNoises)) {
169  obj = new SiStripNoises();
170 
171  const auto detInfo =
173  int count = -1;
174  for (const auto& it : detInfo.getAllData()) {
175  count++;
176  //Generate Noise for det detid
177  SiStripNoises::InputVector theSiStripVector;
178  for (int strip = 0; strip < 128 * it.second.nApvs; ++strip) {
179  float MeanNoise = 5;
180  float RmsNoise = 1;
181 
182  float noise = CLHEP::RandGauss::shoot(MeanNoise, RmsNoise);
183 
184  //double badStripProb = .5;
185  //bool disable = (CLHEP::RandFlat::shoot(1.) < badStripProb ? true:false);
186 
187  obj->setData(noise, theSiStripVector);
188  if (count < 6)
189  edm::LogInfo("SiStripNoisesBuilder") << "detid " << it.first << " \t"
190  << " strip " << strip << " \t" << noise << " \t"
191  << theSiStripVector.back() / 10 << " \t" << std::endl;
192  }
193 
194  if (!obj->put(it.first, theSiStripVector))
195  edm::LogError("SiStripNoisesBuilder")
196  << "[SiStripNoisesBuilder::analyze] detid already exists" << std::endl;
197  }
198  }
199  }
std::vector< uint16_t > InputVector
Definition: SiStripNoises.h:50
SiStripDetInfo read(std::string filePath)
Log< level::Info, false > LogInfo
static constexpr char const *const kDefaultFile
long double T

◆ getDataType()

template<typename T >
DataType popcon::SiStripPopConHandlerUnitTest< T >::getDataType ( )
inlineprivate

Definition at line 94 of file SiStripPopConHandlerUnitTest.h.

References popcon::SiStripPopConHandlerUnitTest< T >::_Cabling, popcon::SiStripPopConHandlerUnitTest< T >::m_name, Skims_PA_cff::name, and popcon::SiStripPopConHandlerUnitTest< T >::UNDEFINED.

94  {
95  if (typeid(T) == typeid(SiStripFedCabling)) {
96  edm::LogInfo("SiStripPopPopConConfigDbObjHandler")
97  << "[getDataType] for PopCon application " << m_name << " " << typeid(T).name();
98  return _Cabling;
99  }
100  return UNDEFINED;
101  }
Log< level::Info, false > LogInfo
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
long double T

◆ getNewObjects()

template<typename T >
void popcon::SiStripPopConHandlerUnitTest< T >::getNewObjects ( )
inlinevirtual

Implements popcon::PopConSourceHandler< T >.

Definition at line 50 of file SiStripPopConHandlerUnitTest.h.

References cond::LogDBEntry_t::destinationDB, cond::LogDBEntry_t::execmessage, cond::LogDBEntry_t::exectime, cond::LogDBEntry_t::iovtag, cond::LogDBEntry_t::iovtimetype, popcon::SiStripPopConHandlerUnitTest< T >::isTransferNeeded(), cond::TagInfo_t::lastInterval, popcon::PopConSourceHandler< T >::logDBEntry(), cond::LogDBEntry_t::logId, popcon::SiStripPopConHandlerUnitTest< T >::m_debugMode, popcon::SiStripPopConHandlerUnitTest< T >::m_name, cond::TagInfo_t::name, cond::Iov_t::payloadId, cond::LogDBEntry_t::payloadIdx, cond::LogDBEntry_t::payloadToken, cond::LogDBEntry_t::provenance, popcon::SiStripPopConHandlerUnitTest< T >::setForTransfer(), cond::Iov_t::since, cond::TagInfo_t::size, findQualityFiles::size, contentValuesCheck::ss, popcon::PopConSourceHandler< T >::tagInfo(), cond::LogDBEntry_t::usertext, and popcon::PopConSourceHandler< T >::userTextLog().

50  {
51  edm::LogInfo("SiStripPopPopConConfigDbObjHandler") << "[getNewObjects] for PopCon application " << m_name;
52 
53  if (m_debugMode) {
54  std::stringstream ss;
55  ss << "\n\n------- " << m_name << " - > getNewObjects\n";
56  if (this->tagInfo().size) {
57  //check whats already inside of database
58  ss << "got offlineInfo" << this->tagInfo().name << ", size " << this->tagInfo().size
59  << " , last object valid since " << this->tagInfo().lastInterval.since << " token "
60  << this->tagInfo().lastInterval.payloadId << "\n\n UserText " << this->userTextLog() << "\n LogDBEntry \n"
61  << this->logDBEntry().logId << "\n"
62  << this->logDBEntry().destinationDB << "\n"
63  << this->logDBEntry().provenance << "\n"
64  << this->logDBEntry().usertext << "\n"
65  << this->logDBEntry().iovtag << "\n"
66  << this->logDBEntry().iovtimetype << "\n"
67  << this->logDBEntry().payloadIdx << "\n"
68  << this->logDBEntry().payloadName << "\n"
69  << this->logDBEntry().payloadToken << "\n"
70  << this->logDBEntry().payloadContainer << "\n"
71  << this->logDBEntry().exectime << "\n"
72  << this->logDBEntry().execmessage << "\n"
73  << "\n\n-- user text "
74  << this->logDBEntry().usertext.substr(this->logDBEntry().usertext.find_last_of("@"));
75  } else {
76  ss << " First object for this tag ";
77  }
78  edm::LogInfo("SiStripPopPopConConfigDbObjHandler") << ss.str();
79  }
80  if (isTransferNeeded())
82 
83  edm::LogInfo("SiStripPopPopConConfigDbObjHandler")
84  << "[getNewObjects] for PopCon application " << m_name << " Done\n--------------\n";
85  }
size
Write out results.
Iov_t lastInterval
Definition: Types.h:73
unsigned long long logId
Definition: Types.h:87
std::string provenance
Definition: Types.h:89
std::string payloadToken
Definition: Types.h:96
Time_t since
Definition: Types.h:53
size_t size
Definition: Types.h:74
std::string execmessage
Definition: Types.h:98
std::string name
Definition: Types.h:72
cond::TagInfo_t const & tagInfo() const
Hash payloadId
Definition: Types.h:55
std::string destinationDB
Definition: Types.h:88
Log< level::Info, false > LogInfo
std::string exectime
Definition: Types.h:97
cond::LogDBEntry_t const & logDBEntry() const
std::string const & userTextLog() const
unsigned int payloadIdx
Definition: Types.h:93
std::string usertext
Definition: Types.h:90
std::string iovtimetype
Definition: Types.h:92
std::string iovtag
Definition: Types.h:91

◆ id()

template<typename T >
std::string popcon::SiStripPopConHandlerUnitTest< T >::id ( void  ) const
inlinevirtual

◆ isTransferNeeded()

template<typename T >
bool popcon::SiStripPopConHandlerUnitTest< T >::isTransferNeeded ( )
inlineprivate

Definition at line 105 of file SiStripPopConHandlerUnitTest.h.

References cond::LogDBEntry_t::destinationDB, cond::TagInfo_t::lastInterval, popcon::PopConSourceHandler< T >::logDBEntry(), popcon::PopConSourceHandler< T >::m_userTextLog, cond::Iov_t::since, findQualityFiles::size, contentValuesCheck::ss, popcon::PopConSourceHandler< T >::tagInfo(), and cond::LogDBEntry_t::usertext.

Referenced by popcon::SiStripPopConHandlerUnitTest< T >::getNewObjects().

105  {
106  edm::LogInfo("SiStripPopPopConConfigDbObjHandler") << "[isTransferNeeded] checking for transfer" << std::endl;
107  std::stringstream ss_logdb, ss;
108  std::stringstream ss1;
109 
110  //get log information from previous upload
111  if (this->tagInfo().size)
112  ss_logdb << this->logDBEntry().usertext.substr(this->logDBEntry().usertext.find_last_of("@"));
113  else
114  ss_logdb << "";
115 
116  ss << "@ " << clock();
117 
118  if (!strcmp(ss.str().c_str(), ss_logdb.str().c_str())) {
119  //string are equal, no need to do transfer
120  edm::LogInfo("SiStripPopPopConConfigDbObjHandler")
121  << "[isTransferNeeded] the selected conditions are already uploaded in the last iov ("
122  << this->tagInfo().lastInterval.since << ") open for the object " << this->logDBEntry().payloadName
123  << " in the db " << this->logDBEntry().destinationDB << " parameters: " << ss.str()
124  << "\n NO TRANSFER NEEDED";
125  return false;
126  }
127  this->m_userTextLog = ss.str();
128  edm::LogInfo("SiStripPopPopConConfigDbObjHandler")
129  << "[isTransferNeeded] the selected conditions will be uploaded: " << ss.str() << "\n A- " << ss.str()
130  << "\n B- " << ss_logdb.str() << "\n Fine";
131 
132  return true;
133  }
size
Write out results.
Iov_t lastInterval
Definition: Types.h:73
Time_t since
Definition: Types.h:53
cond::TagInfo_t const & tagInfo() const
std::string destinationDB
Definition: Types.h:88
Log< level::Info, false > LogInfo
cond::LogDBEntry_t const & logDBEntry() const
std::string usertext
Definition: Types.h:90

◆ setForTransfer()

template<typename T >
void popcon::SiStripPopConHandlerUnitTest< T >::setForTransfer ( )
inlineprivate

Definition at line 137 of file SiStripPopConHandlerUnitTest.h.

References popcon::SiStripPopConHandlerUnitTest< T >::fillObject(), cond::TagInfo_t::lastInterval, popcon::SiStripPopConHandlerUnitTest< T >::m_debugMode, popcon::SiStripPopConHandlerUnitTest< T >::m_name, popcon::SiStripPopConHandlerUnitTest< T >::m_since, popcon::PopConSourceHandler< T >::m_to_transfer, Skims_PA_cff::name, getGTfromDQMFile::obj, cond::Iov_t::since, findQualityFiles::size, and popcon::PopConSourceHandler< T >::tagInfo().

Referenced by popcon::SiStripPopConHandlerUnitTest< T >::getNewObjects().

137  {
138  edm::LogInfo("SiStripPopPopConConfigDbObjHandler")
139  << "[setForTransfer] " << m_name << " getting data to be transferred " << std::endl;
140 
141  T* obj = 0;
142 
143  fillObject(obj);
144 
145  if (!this->tagInfo().size)
146  m_since = 1;
147  else if (m_debugMode)
148  m_since = this->tagInfo().lastInterval.since + 1;
149 
150  if (obj != 0) {
151  edm::LogInfo("SiStripPopPopConConfigDbObjHandler") << "setting since = " << m_since << std::endl;
152  this->m_to_transfer.push_back(std::make_pair(obj, m_since));
153  } else {
154  edm::LogError("SiStripPopPopConConfigDbObjHandler")
155  << "[setForTransfer] " << m_name << " : NULL pointer of obj " << typeid(T).name()
156  << " reported by SiStripCondObjBuilderFromDb\n Transfer aborted" << std::endl;
157  }
158  }
size
Write out results.
Iov_t lastInterval
Definition: Types.h:73
Time_t since
Definition: Types.h:53
Log< level::Error, false > LogError
cond::TagInfo_t const & tagInfo() const
std::vector< std::pair< T *, Time_t > > m_to_transfer
Log< level::Info, false > LogInfo
long double T

Member Data Documentation

◆ condObjBuilder

template<typename T >
edm::Service<SiStripCondObjBuilderFromDb> popcon::SiStripPopConHandlerUnitTest< T >::condObjBuilder
private

Definition at line 165 of file SiStripPopConHandlerUnitTest.h.

◆ m_debugMode

template<typename T >
bool popcon::SiStripPopConHandlerUnitTest< T >::m_debugMode
private

◆ m_name

template<typename T >
std::string popcon::SiStripPopConHandlerUnitTest< T >::m_name
private

◆ m_since

template<typename T >
unsigned long long popcon::SiStripPopConHandlerUnitTest< T >::m_since
private