CMS 3D CMS Logo

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

Public Member Functions

 SiPixel2DTemplateDBObjectReader (const edm::ParameterSet &)
 
 ~SiPixel2DTemplateDBObjectReader () 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 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
 
void beginJob () override
 
void endJob () override
 

Private Attributes

bool hasTriggeredWatcher
 
edm::ESGetToken< MagneticField, IdealMagneticFieldRecordmagneticFieldToken_
 
edm::ESWatcher< SiPixel2DTemplateDBObjectESProducerRcdSiPix2DTemplDBObjectWatcher_
 
edm::ESWatcher< SiPixel2DTemplateDBObjectRcdSiPix2DTemplDBObjWatcher_
 
bool testGlobalTag
 
std::string the2DTemplateCalibrationLocation
 
edm::ESGetToken< SiPixel2DTemplateDBObject, SiPixel2DTemplateDBObjectESProducerRcdthe2DTemplateESProdToken_
 
edm::ESGetToken< SiPixel2DTemplateDBObject, SiPixel2DTemplateDBObjectRcdthe2DTemplateToken_
 
bool theDetailed2DTemplateDBErrorOutput
 
bool theFull2DTemplateDBOutput
 

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 27 of file SiPixel2DTemplateDBObjectReader.cc.

Constructor & Destructor Documentation

◆ SiPixel2DTemplateDBObjectReader()

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

Definition at line 50 of file SiPixel2DTemplateDBObjectReader.cc.

51  : the2DTemplateCalibrationLocation(iConfig.getParameter<std::string>("siPixel2DTemplateCalibrationLocation")),
52  theDetailed2DTemplateDBErrorOutput(iConfig.getParameter<bool>("wantDetailed2DTemplateDBErrorOutput")),
53  theFull2DTemplateDBOutput(iConfig.getParameter<bool>("wantFull2DTemplateDBOutput")),
54  testGlobalTag(iConfig.getParameter<bool>("TestGlobalTag")),
55  hasTriggeredWatcher(false),
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
edm::ESGetToken< SiPixel2DTemplateDBObject, SiPixel2DTemplateDBObjectRcd > the2DTemplateToken_
edm::ESGetToken< SiPixel2DTemplateDBObject, SiPixel2DTemplateDBObjectESProducerRcd > the2DTemplateESProdToken_

◆ ~SiPixel2DTemplateDBObjectReader()

SiPixel2DTemplateDBObjectReader::~SiPixel2DTemplateDBObjectReader ( )
overridedefault

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 64 of file SiPixel2DTemplateDBObjectReader.cc.

References funct::abs(), edm::ESWatcher< T >::check(), change_name::diff, relativeConstraints::error, geometryDiff::file, edm::EventSetup::getData(), edm::EventSetup::getHandle(), SiPixel2DTemplateDBObject::getTemplateIDs(), hasTriggeredWatcher, mps_fire::i, recoMuon::in, runGCPTkAlMap::in_file, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, volumeBasedMagneticField_160812_cfi::magfield, magneticFieldToken_, SiPixel2DTemplateDBObject::numOfTempl(), SiPix2DTemplDBObjWatcher_, SiPixel2DTemplateDBObject::sVector(), testGlobalTag, the2DTemplateCalibrationLocation, the2DTemplateESProdToken_, the2DTemplateToken_, theDetailed2DTemplateDBErrorOutput, theFull2DTemplateDBOutput, and SiPixel2DTemplateDBObject::version().

64  {
65  //To test with the ESProducer
67  if (testGlobalTag) {
68  // Get magnetic field
69  GlobalPoint center(0.0, 0.0, 0.0);
71  float theMagField = magfield.product()->inTesla(center).mag();
72 
73  edm::LogPrint("SiPixel2DTemplateDBObjectReader") << "\nTesting global tag at magnetic field = " << theMagField;
74  if (SiPix2DTemplDBObjWatcher_.check(iSetup)) {
75  edm::LogPrint("SiPixel2DTemplateDBObjectESProducerRcd") << "With record SiPixel2DTemplateDBObjectESProducerRcd";
76  dbobject = *&iSetup.getData(the2DTemplateESProdToken_);
77  hasTriggeredWatcher = true;
78  }
79  } else {
80  edm::LogPrint("SiPixel2DTemplateDBObjectReader") << "\nLoading from file " << std::endl;
81  if (SiPix2DTemplDBObjWatcher_.check(iSetup)) {
82  edm::LogPrint("SiPixelTemplateDBObjectReader") << "With record SiPixel2DTemplateDBObjectRcd";
83  dbobject = *&iSetup.getData(the2DTemplateToken_);
84  hasTriggeredWatcher = true;
85  }
86  }
87 
88  if (hasTriggeredWatcher) {
89  std::vector<short> tempMapId;
90 
92  edm::LogPrint("SiPixel2DTemplateDBObjectReader") << "Map info" << std::endl;
93  std::map<unsigned int, short> templMap = dbobject.getTemplateIDs();
94  for (std::map<unsigned int, short>::const_iterator it = templMap.begin(); it != templMap.end(); ++it) {
95  if (tempMapId.empty())
96  tempMapId.push_back(it->second);
97  for (unsigned int i = 0; i < tempMapId.size(); ++i) {
98  if (tempMapId[i] == it->second)
99  continue;
100  else if (i == tempMapId.size() - 1) {
101  tempMapId.push_back(it->second);
102  break;
103  }
104  }
105  edm::LogPrint("SiPixel2DTemplateDBObjectReader")
106  << "DetId: " << it->first << " 2DTemplateID: " << it->second << "\n";
107  }
108  }
109 
110  edm::LogPrint("SiPixel2DTemplateDBObjectReader") << "\nMap stores 2DTemplate Id(s): ";
111  for (unsigned int vindex = 0; vindex < tempMapId.size(); ++vindex)
112  edm::LogPrint("SiPixel2DTemplateDBObjectReader") << tempMapId[vindex] << " ";
113  edm::LogPrint("SiPixel2DTemplateDBObjectReader") << std::endl;
114 
115  //local variables
116  const char* tempfile;
117  int numOfTempl = dbobject.numOfTempl();
118  int index = 0;
119  float tempnum = 0, diff = 0;
120  float tol = 1.0E-23;
121  bool error = false, givenErrorMsg = false;
122  ;
123 
124  edm::LogPrint("SiPixel2DTemplateDBObjectReader")
125  << "\nChecking 2DTemplate 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 2DTemplate ID and version are -- note that version is only valid for >=13
132  edm::LogPrint("SiPixel2DTemplateDBObjectReader")
133  << "Calibration " << i + 1 << " of " << numOfTempl << ", with 2DTemplate ID " << dbobject.sVector()[index]
134  << "\tand Version " << dbobject.sVector()[index + 1] << "\t-------- ";
135 
136  //Opening the text-based 2DTemplate calibration
137  std::ostringstream tout;
138  //tout << the2DTemplateCalibrationLocation.c_str() << "/data/generror_summary_zp"
139  tout << the2DTemplateCalibrationLocation.c_str() << "/data/template2D_IOV5/template_summary2D_zp" << std::setw(4)
140  << std::setfill('0') << std::right << dbobject.sVector()[index] << ".out" << std::ends;
141 
142  edm::FileInPath file(tout.str());
143  tempfile = (file.fullPath()).c_str();
144  std::ifstream in_file(tempfile, 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("SiPixel2DTemplateDBObjectReader") << "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("SiPixel2DTemplateDBObjectReader")
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("SiPixel2DTemplateDBObjectReader") << "MATCHES\n";
178  } //end current file
179  in_file.close();
180  givenErrorMsg = false;
181  } //end loop over all files
182 
184  edm::LogPrint("SiPixel2DTemplateDBObjectReader")
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("SiPixel2DTemplateDBObjectReader") << dbobject << std::endl;
194  }
195 }
std::vector< float > const & sVector() const
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > magneticFieldToken_
edm::ESGetToken< SiPixel2DTemplateDBObject, SiPixel2DTemplateDBObjectRcd > the2DTemplateToken_
edm::ESGetToken< SiPixel2DTemplateDBObject, SiPixel2DTemplateDBObjectESProducerRcd > the2DTemplateESProdToken_
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Log< level::Warning, true > LogPrint
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
edm::ESWatcher< SiPixel2DTemplateDBObjectRcd > SiPix2DTemplDBObjWatcher_
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
const std::map< unsigned int, short > & getTemplateIDs() const

◆ beginJob()

void SiPixel2DTemplateDBObjectReader::beginJob ( )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 62 of file SiPixel2DTemplateDBObjectReader.cc.

62 {}

◆ endJob()

void SiPixel2DTemplateDBObjectReader::endJob ( void  )
overrideprivatevirtual

Reimplemented from edm::one::EDAnalyzerBase.

Definition at line 197 of file SiPixel2DTemplateDBObjectReader.cc.

197 {}

Member Data Documentation

◆ hasTriggeredWatcher

bool SiPixel2DTemplateDBObjectReader::hasTriggeredWatcher
private

Definition at line 44 of file SiPixel2DTemplateDBObjectReader.cc.

Referenced by analyze().

◆ magneticFieldToken_

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

Definition at line 45 of file SiPixel2DTemplateDBObjectReader.cc.

Referenced by analyze().

◆ SiPix2DTemplDBObjectWatcher_

edm::ESWatcher<SiPixel2DTemplateDBObjectESProducerRcd> SiPixel2DTemplateDBObjectReader::SiPix2DTemplDBObjectWatcher_
private

Definition at line 37 of file SiPixel2DTemplateDBObjectReader.cc.

◆ SiPix2DTemplDBObjWatcher_

edm::ESWatcher<SiPixel2DTemplateDBObjectRcd> SiPixel2DTemplateDBObjectReader::SiPix2DTemplDBObjWatcher_
private

Definition at line 38 of file SiPixel2DTemplateDBObjectReader.cc.

Referenced by analyze().

◆ testGlobalTag

bool SiPixel2DTemplateDBObjectReader::testGlobalTag
private

Definition at line 43 of file SiPixel2DTemplateDBObjectReader.cc.

Referenced by analyze().

◆ the2DTemplateCalibrationLocation

std::string SiPixel2DTemplateDBObjectReader::the2DTemplateCalibrationLocation
private

Definition at line 40 of file SiPixel2DTemplateDBObjectReader.cc.

Referenced by analyze().

◆ the2DTemplateESProdToken_

edm::ESGetToken<SiPixel2DTemplateDBObject, SiPixel2DTemplateDBObjectESProducerRcd> SiPixel2DTemplateDBObjectReader::the2DTemplateESProdToken_
private

Definition at line 46 of file SiPixel2DTemplateDBObjectReader.cc.

Referenced by analyze().

◆ the2DTemplateToken_

edm::ESGetToken<SiPixel2DTemplateDBObject, SiPixel2DTemplateDBObjectRcd> SiPixel2DTemplateDBObjectReader::the2DTemplateToken_
private

Definition at line 47 of file SiPixel2DTemplateDBObjectReader.cc.

Referenced by analyze().

◆ theDetailed2DTemplateDBErrorOutput

bool SiPixel2DTemplateDBObjectReader::theDetailed2DTemplateDBErrorOutput
private

Definition at line 41 of file SiPixel2DTemplateDBObjectReader.cc.

Referenced by analyze().

◆ theFull2DTemplateDBOutput

bool SiPixel2DTemplateDBObjectReader::theFull2DTemplateDBOutput
private

Definition at line 42 of file SiPixel2DTemplateDBObjectReader.cc.

Referenced by analyze().