CMS 3D CMS Logo

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

Public Member Functions

 SiPixelTemplateDBObjectReader (const edm::ParameterSet &)
 
 ~SiPixelTemplateDBObjectReader () 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

bool hasTriggeredWatcher
 
edm::ESGetToken< MagneticField, IdealMagneticFieldRecordmagneticFieldToken_
 
edm::ESWatcher< SiPixelTemplateDBObjectESProducerRcdSiPixTemplDBObjectWatcher_
 
edm::ESWatcher< SiPixelTemplateDBObjectRcdSiPixTemplDBObjWatcher_
 
bool testGlobalTag
 
edm::ESGetToken< SiPixelTemplateDBObject, SiPixelTemplateDBObjectESProducerRcdthe1DTemplateESProdToken_
 
edm::ESGetToken< SiPixelTemplateDBObject, SiPixelTemplateDBObjectRcdthe1DTemplateToken_
 
bool theDetailedTemplateDBErrorOutput
 
bool theFullTemplateDBOutput
 
std::string theTemplateCalibrationLocation
 

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 28 of file SiPixelTemplateDBObjectReader.cc.

Constructor & Destructor Documentation

◆ SiPixelTemplateDBObjectReader()

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

Definition at line 51 of file SiPixelTemplateDBObjectReader.cc.

52  : theTemplateCalibrationLocation(iConfig.getParameter<std::string>("siPixelTemplateCalibrationLocation")),
53  theDetailedTemplateDBErrorOutput(iConfig.getParameter<bool>("wantDetailedTemplateDBErrorOutput")),
54  theFullTemplateDBOutput(iConfig.getParameter<bool>("wantFullTemplateDBOutput")),
55  testGlobalTag(iConfig.getParameter<bool>("TestGlobalTag")),
56  hasTriggeredWatcher(false),
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
edm::ESGetToken< SiPixelTemplateDBObject, SiPixelTemplateDBObjectRcd > the1DTemplateToken_
edm::ESGetToken< SiPixelTemplateDBObject, SiPixelTemplateDBObjectESProducerRcd > the1DTemplateESProdToken_
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_

◆ ~SiPixelTemplateDBObjectReader()

SiPixelTemplateDBObjectReader::~SiPixelTemplateDBObjectReader ( )
overridedefault

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 65 of file SiPixelTemplateDBObjectReader.cc.

References funct::abs(), edm::ESWatcher< T >::check(), change_name::diff, relativeConstraints::error, geometryDiff::file, edm::EventSetup::getData(), edm::EventSetup::getHandle(), SiPixelTemplateDBObject::getTemplateIDs(), hasTriggeredWatcher, mps_fire::i, recoMuon::in, runGCPTkAlMap::in_file, volumeBasedMagneticField_160812_cfi::magfield, magneticFieldToken_, SiPixelTemplateDBObject::numOfTempl(), SiPixTemplDBObjWatcher_, SiPixelTemplateDBObject::sVector(), testGlobalTag, the1DTemplateESProdToken_, the1DTemplateToken_, theDetailedTemplateDBErrorOutput, theFullTemplateDBOutput, theTemplateCalibrationLocation, and SiPixelTemplateDBObject::version().

65  {
66  //To test with the ESProducer
67  SiPixelTemplateDBObject dbobject;
68  if (testGlobalTag) {
69  // Get magnetic field
70  GlobalPoint center(0.0, 0.0, 0.0);
72  float theMagField = magfield.product()->inTesla(center).mag();
73 
74  edm::LogPrint("SiPixelTemplateDBObjectReader") << "\nTesting global tag at magfield = " << theMagField;
75  if (SiPixTemplDBObjWatcher_.check(iSetup)) {
76  edm::LogPrint("SiPixelTemplateDBObjectReader") << "With record SiPixelTemplateDBObjectESProducerRcd";
77  dbobject = *&iSetup.getData(the1DTemplateESProdToken_);
78  hasTriggeredWatcher = true;
79  }
80  } else {
81  edm::LogPrint("SiPixelTemplateDBObjectReader") << "\nLoading from file " << std::endl;
82  if (SiPixTemplDBObjWatcher_.check(iSetup)) {
83  edm::LogPrint("SiPixelTemplateDBObjectReader") << "With record SiPixelTemplateDBObjectRcd";
84  dbobject = *&iSetup.getData(the1DTemplateToken_);
85  hasTriggeredWatcher = true;
86  }
87  }
88 
89  if (hasTriggeredWatcher) {
90  std::vector<short> tempMapId;
91 
93  edm::LogPrint("SiPixelTemplateDBObjectReader") << "Map info" << std::endl;
94  std::map<unsigned int, short> templMap = dbobject.getTemplateIDs();
95  for (std::map<unsigned int, short>::const_iterator it = templMap.begin(); it != templMap.end(); ++it) {
96  if (tempMapId.empty())
97  tempMapId.push_back(it->second);
98  for (unsigned int i = 0; i < tempMapId.size(); ++i) {
99  if (tempMapId[i] == it->second)
100  continue;
101  else if (i == tempMapId.size() - 1) {
102  tempMapId.push_back(it->second);
103  break;
104  }
105  }
107  edm::LogPrint("SiPixelTemplateDBObjectReader")
108  << "DetId: " << it->first << " TemplateID: " << it->second << "\n";
109  }
110 
111  edm::LogPrint("SiPixelTemplateDBObjectReader") << "\nMap stores template Id(s): ";
112  for (unsigned int vindex = 0; vindex < tempMapId.size(); ++vindex)
113  edm::LogPrint("SiPixelTemplateDBObjectReader") << tempMapId[vindex] << " ";
114  edm::LogPrint("SiPixelTemplateDBObjectReader") << std::endl;
115 
116  //local variables
117  const char* tempfile;
118  int numOfTempl = dbobject.numOfTempl();
119  int index = 0;
120  float tempnum = 0, diff = 0;
121  float tol = 1.0E-23;
122  bool error = false, givenErrorMsg = false;
123 
124  edm::LogPrint("SiPixelTemplateDBObjectReader")
125  << "\nChecking Template DB object version " << dbobject.version() << " containing " << numOfTempl
126  << " calibration(s) at " << dbobject.sVector()[index + 22] << "T\n";
127  for (int i = 0; i < numOfTempl; ++i) {
128  //Removes header in db object from diff
129  index += 20;
130 
131  //Tell the person viewing the output what the template ID and version are -- note that version is only valid for >=13
132  edm::LogPrint("SiPixelTemplateDBObjectReader")
133  << "Calibration " << i + 1 << " of " << numOfTempl << ", with Template ID " << dbobject.sVector()[index]
134  << "\tand Version " << dbobject.sVector()[index + 1] << "\t-------- ";
135 
136  //Opening the text-based template calibration
137  std::ostringstream tout;
138  tout << theTemplateCalibrationLocation.c_str() << "/data/template_summary_zp" << std::setw(4) << std::setfill('0')
139  << std::right << dbobject.sVector()[index] << ".out" << std::ends;
140 
141  edm::FileInPath file(tout.str());
142  tempfile = (file.fullPath()).c_str();
143  std::ifstream in_file(tempfile, std::ios::in);
144 
145  if (in_file.is_open()) {
146  //Removes header in textfile from diff
147  //First read in from the text file -- this will be compared with index = 20
148  in_file >> tempnum;
149 
150  //Read until the end of the current text file
151  while (!in_file.eof()) {
152  //Calculate the difference between the text file and the db object
153  diff = std::abs(tempnum - dbobject.sVector()[index]);
154 
155  //Is there a difference?
156  if (diff > tol) {
157  //We have the if statement to output the message only once
158  if (!givenErrorMsg)
159  edm::LogPrint("SiPixelTemplateDBObjectReader") << "does NOT match\n";
160  //If there is an error we want to display a message upon completion
161  error = true;
162  givenErrorMsg = true;
163  //Do we want more detailed output?
165  edm::LogPrint("SiPixelTemplateDBObjectReader")
166  << "from file = " << tempnum << "\t from dbobject = " << dbobject.sVector()[index]
167  << "\tdiff = " << diff << "\t db index = " << index << std::endl;
168  }
169  }
170  //Go to the next entries
171  in_file >> tempnum;
172  ++index;
173  }
174  //There were no errors, the two files match.
175  if (!givenErrorMsg)
176  edm::LogPrint("SiPixelTemplateDBObjectReader") << "MATCHES\n";
177  } //end current file
178  in_file.close();
179  givenErrorMsg = false;
180  } //end loop over all files
181 
183  edm::LogPrint("SiPixelTemplateDBObjectReader")
184  << "\nThe were differences found between the files and the database.\n"
185  << "If you would like more detailed information please set\n"
186  << "wantDetailedOutput = True in the cfg file. If you would like a\n"
187  << "full output of the contents of the database file please set\n"
188  << "wantFullOutput = True. Make sure that you pipe the output to a\n"
189  << "log file. This could take a few minutes.\n\n";
190 
192  edm::LogPrint("SiPixelTemplateDBObjectReader") << dbobject << std::endl;
193  }
194 }
edm::ESGetToken< SiPixelTemplateDBObject, SiPixelTemplateDBObjectRcd > the1DTemplateToken_
edm::ESGetToken< SiPixelTemplateDBObject, SiPixelTemplateDBObjectESProducerRcd > the1DTemplateESProdToken_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::ESWatcher< SiPixelTemplateDBObjectRcd > SiPixTemplDBObjWatcher_
bool getData(T &iHolder) const
Definition: EventSetup.h:122
std::vector< float > const & sVector() const
Log< level::Warning, true > LogPrint
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:151
const std::map< unsigned int, short > & getTemplateIDs() const
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_

◆ beginJob()

void SiPixelTemplateDBObjectReader::beginJob ( )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 63 of file SiPixelTemplateDBObjectReader.cc.

63 {}

◆ endJob()

void SiPixelTemplateDBObjectReader::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 196 of file SiPixelTemplateDBObjectReader.cc.

196 {}

Member Data Documentation

◆ hasTriggeredWatcher

bool SiPixelTemplateDBObjectReader::hasTriggeredWatcher
private

Definition at line 45 of file SiPixelTemplateDBObjectReader.cc.

Referenced by analyze().

◆ magneticFieldToken_

edm::ESGetToken<MagneticField, IdealMagneticFieldRecord> SiPixelTemplateDBObjectReader::magneticFieldToken_
private

Definition at line 46 of file SiPixelTemplateDBObjectReader.cc.

Referenced by analyze().

◆ SiPixTemplDBObjectWatcher_

edm::ESWatcher<SiPixelTemplateDBObjectESProducerRcd> SiPixelTemplateDBObjectReader::SiPixTemplDBObjectWatcher_
private

Definition at line 38 of file SiPixelTemplateDBObjectReader.cc.

◆ SiPixTemplDBObjWatcher_

edm::ESWatcher<SiPixelTemplateDBObjectRcd> SiPixelTemplateDBObjectReader::SiPixTemplDBObjWatcher_
private

Definition at line 39 of file SiPixelTemplateDBObjectReader.cc.

Referenced by analyze().

◆ testGlobalTag

bool SiPixelTemplateDBObjectReader::testGlobalTag
private

Definition at line 44 of file SiPixelTemplateDBObjectReader.cc.

Referenced by analyze().

◆ the1DTemplateESProdToken_

edm::ESGetToken<SiPixelTemplateDBObject, SiPixelTemplateDBObjectESProducerRcd> SiPixelTemplateDBObjectReader::the1DTemplateESProdToken_
private

Definition at line 47 of file SiPixelTemplateDBObjectReader.cc.

Referenced by analyze().

◆ the1DTemplateToken_

edm::ESGetToken<SiPixelTemplateDBObject, SiPixelTemplateDBObjectRcd> SiPixelTemplateDBObjectReader::the1DTemplateToken_
private

Definition at line 48 of file SiPixelTemplateDBObjectReader.cc.

Referenced by analyze().

◆ theDetailedTemplateDBErrorOutput

bool SiPixelTemplateDBObjectReader::theDetailedTemplateDBErrorOutput
private

Definition at line 42 of file SiPixelTemplateDBObjectReader.cc.

Referenced by analyze().

◆ theFullTemplateDBOutput

bool SiPixelTemplateDBObjectReader::theFullTemplateDBOutput
private

Definition at line 43 of file SiPixelTemplateDBObjectReader.cc.

Referenced by analyze().

◆ theTemplateCalibrationLocation

std::string SiPixelTemplateDBObjectReader::theTemplateCalibrationLocation
private

Definition at line 41 of file SiPixelTemplateDBObjectReader.cc.

Referenced by analyze().