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=default
 
- 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

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

Private Attributes

bool hasTriggeredWatcher
 
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecordmagneticFieldToken_
 
edm::ESWatcher< SiPixelTemplateDBObjectESProducerRcdSiPixTemplDBObjectWatcher_
 
edm::ESWatcher< SiPixelTemplateDBObjectRcdSiPixTemplDBObjWatcher_
 
const bool testGlobalTag
 
const edm::ESGetToken< SiPixelTemplateDBObject, SiPixelTemplateDBObjectESProducerRcdthe1DTemplateESProdToken_
 
const edm::ESGetToken< SiPixelTemplateDBObject, SiPixelTemplateDBObjectRcdthe1DTemplateToken_
 
const bool theDetailedTemplateDBErrorOutput
 
const bool theFullTemplateDBOutput
 
const 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 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 26 of file SiPixelTemplateDBObjectReader.cc.

Constructor & Destructor Documentation

◆ SiPixelTemplateDBObjectReader()

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

Definition at line 48 of file SiPixelTemplateDBObjectReader.cc.

49  : hasTriggeredWatcher(false),
50  theTemplateCalibrationLocation(iConfig.getParameter<std::string>("siPixelTemplateCalibrationLocation")),
51  theDetailedTemplateDBErrorOutput(iConfig.getParameter<bool>("wantDetailedTemplateDBErrorOutput")),
52  theFullTemplateDBOutput(iConfig.getParameter<bool>("wantFullTemplateDBOutput")),
53  testGlobalTag(iConfig.getParameter<bool>("TestGlobalTag")),
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
const edm::ESGetToken< SiPixelTemplateDBObject, SiPixelTemplateDBObjectRcd > the1DTemplateToken_
const edm::ESGetToken< SiPixelTemplateDBObject, SiPixelTemplateDBObjectESProducerRcd > the1DTemplateESProdToken_
const 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 58 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, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, volumeBasedMagneticField_160812_cfi::magfield, magneticFieldToken_, SiPixelTemplateDBObject::numOfTempl(), SiPixTemplDBObjWatcher_, SiPixelTemplateDBObject::sVector(), testGlobalTag, the1DTemplateESProdToken_, the1DTemplateToken_, theDetailedTemplateDBErrorOutput, theFullTemplateDBOutput, theTemplateCalibrationLocation, and SiPixelTemplateDBObject::version().

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

Member Data Documentation

◆ hasTriggeredWatcher

bool SiPixelTemplateDBObjectReader::hasTriggeredWatcher
private

Definition at line 37 of file SiPixelTemplateDBObjectReader.cc.

Referenced by analyze().

◆ magneticFieldToken_

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

Definition at line 43 of file SiPixelTemplateDBObjectReader.cc.

Referenced by analyze().

◆ SiPixTemplDBObjectWatcher_

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

Definition at line 34 of file SiPixelTemplateDBObjectReader.cc.

◆ SiPixTemplDBObjWatcher_

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

Definition at line 35 of file SiPixelTemplateDBObjectReader.cc.

Referenced by analyze().

◆ testGlobalTag

const bool SiPixelTemplateDBObjectReader::testGlobalTag
private

Definition at line 42 of file SiPixelTemplateDBObjectReader.cc.

Referenced by analyze().

◆ the1DTemplateESProdToken_

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

Definition at line 44 of file SiPixelTemplateDBObjectReader.cc.

Referenced by analyze().

◆ the1DTemplateToken_

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

Definition at line 45 of file SiPixelTemplateDBObjectReader.cc.

Referenced by analyze().

◆ theDetailedTemplateDBErrorOutput

const bool SiPixelTemplateDBObjectReader::theDetailedTemplateDBErrorOutput
private

Definition at line 40 of file SiPixelTemplateDBObjectReader.cc.

Referenced by analyze().

◆ theFullTemplateDBOutput

const bool SiPixelTemplateDBObjectReader::theFullTemplateDBOutput
private

Definition at line 41 of file SiPixelTemplateDBObjectReader.cc.

Referenced by analyze().

◆ theTemplateCalibrationLocation

const std::string SiPixelTemplateDBObjectReader::theTemplateCalibrationLocation
private

Definition at line 39 of file SiPixelTemplateDBObjectReader.cc.

Referenced by analyze().