CMS 3D CMS Logo

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

Public Member Functions

 SiPixelGenErrorDBObjectReader (const edm::ParameterSet &)
 
 ~SiPixelGenErrorDBObjectReader () 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 final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const 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
 
bool wantsStreamRuns () const
 
 ~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
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
bool registeredToConsumeMany (TypeID const &, 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::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

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

Private Attributes

edm::ESGetToken< SiPixelGenErrorDBObject, SiPixelGenErrorDBObjectRcdgenErrToken_
 
bool theDetailedGenErrorDBErrorOutput
 
bool theFullGenErrorDBOutput
 
std::string theGenErrorCalibrationLocation
 

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 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<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 31 of file SiPixelGenErrorDBObjectReader.cc.

Constructor & Destructor Documentation

◆ SiPixelGenErrorDBObjectReader()

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

Definition at line 48 of file SiPixelGenErrorDBObjectReader.cc.

49  : theGenErrorCalibrationLocation(iConfig.getParameter<std::string>("siPixelGenErrorCalibrationLocation")),
50  theDetailedGenErrorDBErrorOutput(iConfig.getParameter<bool>("wantDetailedGenErrorDBErrorOutput")),
51  theFullGenErrorDBOutput(iConfig.getParameter<bool>("wantFullGenErrorDBOutput")),
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::ESGetToken< SiPixelGenErrorDBObject, SiPixelGenErrorDBObjectRcd > genErrToken_

◆ ~SiPixelGenErrorDBObjectReader()

SiPixelGenErrorDBObjectReader::~SiPixelGenErrorDBObjectReader ( )
overridedefault

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 58 of file SiPixelGenErrorDBObjectReader.cc.

References funct::abs(), dqmiodatasetharvest::db, change_name::diff, relativeConstraints::error, SiPixelGenErrorDBObject::fail(), genErrToken_, edm::EventSetup::getData(), SiPixelGenErrorDBObject::getGenErrorIDs(), mps_fire::i, recoMuon::in, runGCPTkAlMap::in_file, SiPixelGenErrorDBObject::index(), SiPixelGenError::lorxwidth(), SiPixelGenError::lorywidth(), SiPixelGenErrorDBObject::maxIndex(), SiPixelGenErrorDBObject::numOfTempl(), SiPixelGenError::pushfile(), mps_update::status, AlCaHLTBitMon_QueryRunRegistry::string, SiPixelGenErrorDBObject::sVector(), groupFilesInBlocks::temp, theDetailedGenErrorDBErrorOutput, theFullGenErrorDBOutput, theGenErrorCalibrationLocation, and SiPixelGenErrorDBObject::version().

58  {
59  edm::LogPrint("SiPixelGenErrorDBObjectReader") << "\nLoading ... " << std::endl;
60 
61  SiPixelGenErrorDBObject dbobject = *&iSetup.getData(genErrToken_);
63 
64  // these seem to be the only variables I can get directly from the object class
65  edm::LogPrint("SiPixelGenErrorDBObjectReader")
66  << " DBObject version " << dbobject.version() << " index " << dbobject.index() << " max " << dbobject.maxIndex()
67  << " fail " << dbobject.fail() << " numOfTeml " << dbobject.numOfTempl() << std::endl;
68 
70  edm::LogPrint("SiPixelGenErrorDBObjectReader") << "Map info" << std::endl;
71  std::vector<short> tempMapId;
72  std::map<unsigned int, short> templMap = dbobject.getGenErrorIDs();
73  for (std::map<unsigned int, short>::const_iterator it = templMap.begin(); it != templMap.end(); ++it) {
74  if (tempMapId.empty())
75  tempMapId.push_back(it->second);
76  for (unsigned int i = 0; i < tempMapId.size(); ++i) {
77  if (tempMapId[i] == it->second)
78  continue;
79  else if (i == tempMapId.size() - 1) {
80  tempMapId.push_back(it->second);
81  break;
82  }
83  }
84 
85  edm::LogPrint("SiPixelGenErrorDBObjectReader") << "DetId: " << it->first << " GenErrorID: " << it->second << "\n";
86  }
87 
88  edm::LogPrint("SiPixelGenErrorDBObjectReader") << "\nMap stores GenError Id(s): ";
89  for (unsigned int vindex = 0; vindex < tempMapId.size(); ++vindex)
90  edm::LogPrint("SiPixelGenErrorDBObjectReader") << tempMapId[vindex] << " ";
91  edm::LogPrint("SiPixelGenErrorDBObjectReader") << std::endl;
92  }
93 
94  // if the dircetory is an empty string ignore file comparison
95  if (theGenErrorCalibrationLocation.empty()) {
96  edm::LogPrint("SiPixelGenErrorDBObjectReader")
97  << " no file for camparison defined, comparison will be skipped " << std::endl;
98 
99  } else { // do the file comparision
100 
101  bool error = false;
102  int numOfTempl = dbobject.numOfTempl();
103  int index = 0;
104  float tempnum = 0, diff = 0;
105  float tol = 1.0E-23;
106  bool givenErrorMsg = false;
107 
108  edm::LogPrint("SiPixelGenErrorDBObjectReader")
109  << "\nChecking GenError DB object version " << dbobject.version() << " containing " << numOfTempl
110  << " calibration(s) at " << dbobject.sVector()[index + 22] << "T\n";
111 
112  for (int i = 0; i < numOfTempl; ++i) {
113  //Removes header in db object from diff
114  index += 20;
115 
116  //Tell the person viewing the output what the GenError ID and version are -- note that version is only valid for >=13
117  // Does not work correctly for data
118  edm::LogPrint("SiPixelGenErrorDBObjectReader")
119  << "Calibration " << i + 1 << " of " << numOfTempl << ", with GenError ID " << dbobject.sVector()[index]
120  << "\tand Version " << dbobject.sVector()[index + 1] << "\t-------- " << std::endl;
121 
122  //Opening the text-based GenError calibration
123  std::ostringstream tout;
124  tout << theGenErrorCalibrationLocation.c_str() << "generror_summary_zp" << std::setw(4) << std::setfill('0')
125  << std::right << dbobject.sVector()[index] << ".out" << std::ends;
126 
127  std::string temp = tout.str();
128  std::ifstream in_file(temp.c_str(), std::ios::in);
129 
130  edm::LogPrint("SiPixelGenErrorDBObjectReader")
131  << " open file " << tout.str() << " " << in_file.is_open() << std::endl;
132 
133  if (in_file.is_open()) {
134  //Removes header in textfile from diff
135  //First read in from the text file -- this will be compared with index = 20
136  in_file >> tempnum;
137 
138  //Read until the end of the current text file
139  while (!in_file.eof()) {
140  //Calculate the difference between the text file and the db object
141  diff = std::abs(tempnum - dbobject.sVector()[index]);
142 
143  //Is there a difference?
144  if (diff > tol) {
145  //We have the if statement to output the message only once
146  if (!givenErrorMsg)
147  edm::LogPrint("SiPixelGenErrorDBObjectReader") << "does NOT match\n";
148  //If there is an error we want to display a message upon completion
149  error = true;
150  givenErrorMsg = true;
151  //Do we want more detailed output?
153  edm::LogPrint("SiPixelGenErrorDBObjectReader")
154  << "from file = " << tempnum << "\t from dbobject = " << dbobject.sVector()[index]
155  << "\tdiff = " << diff << "\t db index = " << index << std::endl;
156  }
157  }
158  //Go to the next entries
159  in_file >> tempnum;
160  ++index;
161  }
162  //There were no errors, the two files match.
163  if (!givenErrorMsg)
164  edm::LogPrint("SiPixelGenErrorDBObjectReader") << "MATCHES\n";
165  } else { //end current file
166  edm::LogPrint("SiPixelGenErrorDBObjectReader")
167  << " ERROR: cannot open file, comparison will be stopped" << std::endl;
168  break;
169  }
170  in_file.close();
171  givenErrorMsg = false;
172 
173  } //end loop over all files
174 
176  edm::LogPrint("SiPixelGenErrorDBObjectReader")
177  << "\nThe were differences found between the files and the database.\n"
178  << "If you would like more detailed information please set\n"
179  << "wantDetailedOutput = True in the cfg file. If you would like a\n"
180  << "full output of the contents of the database file please set\n"
181  << "wantFullOutput = True. Make sure that you pipe the output to a\n"
182  << "log file. This could take a few minutes.\n\n";
183 
184  } // if compare
185 
186  // Try to interpret the object
187  std::vector<SiPixelGenErrorStore> thePixelGenError;
188  bool status = SiPixelGenError::pushfile(*db, thePixelGenError);
189  edm::LogPrint("SiPixelGenErrorDBObjectReader")
190  << " status = " << status << " size = " << thePixelGenError.size() << std::endl;
191 
192  SiPixelGenError genError(thePixelGenError);
193  // these are all 0 because qbin() was not run.
194  edm::LogPrint("SiPixelGenErrorDBObjectReader")
195  << " some values " << genError.lorxwidth() << " " << genError.lorywidth() << " " << std::endl;
196 
197  // Print the full object, I think it does not work, the print is for templates.
199  edm::LogPrint("SiPixelGenErrorDBObjectReader") << dbobject << std::endl;
200 }
static bool pushfile(int filenum, std::vector< SiPixelGenErrorStore > &pixelTemp, std::string dir="")
edm::ESGetToken< SiPixelGenErrorDBObject, SiPixelGenErrorDBObjectRcd > genErrToken_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool getData(T &iHolder) const
Definition: EventSetup.h:122
Log< level::Warning, true > LogPrint
std::vector< float > sVector() const
const std::map< unsigned int, short > & getGenErrorIDs() const

◆ beginJob()

void SiPixelGenErrorDBObjectReader::beginJob ( )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 56 of file SiPixelGenErrorDBObjectReader.cc.

56 {}

◆ endJob()

void SiPixelGenErrorDBObjectReader::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 202 of file SiPixelGenErrorDBObjectReader.cc.

202 {}

Member Data Documentation

◆ genErrToken_

edm::ESGetToken<SiPixelGenErrorDBObject, SiPixelGenErrorDBObjectRcd> SiPixelGenErrorDBObjectReader::genErrToken_
private

Definition at line 45 of file SiPixelGenErrorDBObjectReader.cc.

Referenced by analyze().

◆ theDetailedGenErrorDBErrorOutput

bool SiPixelGenErrorDBObjectReader::theDetailedGenErrorDBErrorOutput
private

Definition at line 42 of file SiPixelGenErrorDBObjectReader.cc.

Referenced by analyze().

◆ theFullGenErrorDBOutput

bool SiPixelGenErrorDBObjectReader::theFullGenErrorDBOutput
private

Definition at line 43 of file SiPixelGenErrorDBObjectReader.cc.

Referenced by analyze().

◆ theGenErrorCalibrationLocation

std::string SiPixelGenErrorDBObjectReader::theGenErrorCalibrationLocation
private

Definition at line 41 of file SiPixelGenErrorDBObjectReader.cc.

Referenced by analyze().